TOK : Determining collision with scenery

Blitz3D Forums/Blitz3D Userlibs/TOK : Determining collision with scenery

Shifty Geezer(Posted 2005) [#1]
I've created scenery using TOK_AddMesh() from the TOKAMAK_Extras_Lib. Is there a way to determine if an RB has collidied with it?

I've tried TOKRB_GetCollisionID() but it always comes up zero, even when lots of RBs are banging around. What does this function do if not return what I think it does?


RepeatUntil(Posted 2005) [#2]
First, be sure to make a call to TOK_SetMesh() after TOK_AddMesh().
Then the ID of a static mesh is -1. Do you have the utility functions from botBuilder (I think it's him). If not, take them from the last version of the tokamak wrapper.
Then I have added some useful functions for what you do: this check collision between all types of body in Tokamak. Here it is:



Example of use (don't forget that a static ID is -1) :


That should work! Tell me if it helps...

<EDIT> Code updated


Shifty Geezer(Posted 2005) [#3]
Thanks much for this, but it's not working at the moment.

First off I had to find the functions like 'TOKCOL_TypeA(index)' they weren't included in the wrapper (v0.6) nor the TOK_Extras lib, but I found them in a PlayersForum post here

[url]http://playerfactory.proboards25.com/index.cgi?board=tokamak2&action=display&num=1077666832[/url]

I've copied and pasted these and your functions into my TOK_Extras lib.

When I compile, I'm shown your reference to TOKCOL_TypeA(index) has only one parameter, whereas the version provided by Botbuilder has (bank,index).

Plus you use a value 'iColl' in your CheckCollision function which isn't set to anything my end. I'm thinking I'm supposed to be settings banks or something?

Sorry for being so daft and needing your help, and thanks muchly for your help.


RepeatUntil(Posted 2005) [#4]
Sorry, that's true that there was some zone of mystery in my code!!
First of all, in fact I modified a bit the functions of botbuilder, and used a bank (collBank) which is defined as global...
And yes, you have to set your bank...
iColl is the collision number when you check your collision everty loop...

Normally you can find all the functions of BotBuilder (last version) in the documentation that comes with Tokamak. Some commands have examples in their description, and there you can find these utility functions... (don't remember which command though)

So I have updated the code in my post above, to include all these changes. Give it a try, and tell me if this time you have everything!!


Shifty Geezer(Posted 2005) [#5]
No joy. I found the functions in the Manual entry for TOKSIM_SetCInfoBank(CInfoBank). Obviously there's more hidden in Tok than I realised!

The program compiles okay, runs okay, but there's no collsion feedback. A call to TOKSIM_GetCollisionCount() always returns zero. I thought I'd set the size of CollBank to 0 to see if I get a memory problem, but no. It appears as though no collision info is being written to the CollBank, best as my limited understanding can figure.

I also set both Collision Responses to 0 to turn off collisions and that had no effect.


EDIT : Update

I've just tried on a much simpler TOK simulator, and I could turn of collision and count them without trouble by copying and pasting from my other non-working simulation.
This also caused the expected memory error when the bank was set too small.

It seems something in my other program is preventing this, but there's nothing there I can see. Any clues?


Shifty Geezer(Posted 2005) [#6]
Fixed it! I was using SetCollisionID() when creating my RBs, so they weren't included in the collision tests.

Thanks very much for this. Now I just need do something useful with it all!