Detecting Collision with Tokamak

Blitz3D Forums/Blitz3D Userlibs/Detecting Collision with Tokamak

I am trying to figure out collisions of rigid bodies with a static mesh. is this possible at all? does anyone know?
i have been trying to get collision-data with materialIDs too mut did not succeed.

i load my level with botbuilders TOK_AddMesh() ... commands as a static mesh and i want to detect when the rigid bodies hit my level. so i thought this must be a common problem, isn't it ?

I believe the collision ID so a static mesh is -1. It's been a while.

Regards,
Eric

hm. i tried all of that. could not get any result yet.
can anyone show me how to test this?
i tried this:

; --> Collision Check
If TOKSIM_GetCollisionCount() > 0
    For c = 0 To TOKSIM_GetCollisionCount()-1
        DebugLog "A >> " + TOKCOL_GetCollisionIdA(colbank, c)
        DebugLog "B >> " + TOKCOL_GetCollisionIdB(colbank, c)
    Next
Endif


Have you assigned collision IDs to the bodies that are colliding with the static mesh?

This section of code worked for me -

		;check collision forces
		For c=0 To (TOKSIM_GetCollisionCount()-1)
		
			BodyA=PeekInt(GAMEDATA\ColBank,0+(c*104))												;id of body A
			BodyB=PeekInt(GAMEDATA\ColBank,4+(c*104))												;id of body B
			TypeA=PeekInt(GAMEDATA\ColBank,8+(c*104))												;type of body A
			TypeB=PeekInt(GAMEDATA\ColBank,12+(c*104))												;type of body B

			If TypeA=1 Then
				CollID_A = TOKRB_GetCollisionID(BodyA)										;body A is of type 1
			ElseIf TypeA=2 Then
				CollID_A = TOKAB_GetCollisionID(BodyA)										;body A is of type 2
			EndIf

			If TypeB=0 Then
				CollID_B = -1 															;impact on terrain
			ElseIf TypeB=1 Then
				CollID_B = TOKRB_GetCollisionID(BodyB)										;impact on rigidbody
			ElseIf TypeB=2 Then
				CollID_B = TOKAB_GetCollisionID(BodyB)										;impact on animbody
			EndIf		

			xf# = TOKCOL_RelativeVelocityx#(GAMEDATA\ColBank,c)										;rel vel x
			yf# = TOKCOL_RelativeVelocityY#(GAMEDATA\ColBank,c)										;rel vel y
			zf# = TOKCOL_RelativeVelocityz#(GAMEDATA\ColBank,c)										;rel vel z
			imp# = Abs(Sqr#( (xf# * xf#) + (yf# * yf#) + (zf# * zf#) ))							;work out vel. vector (not normalised)

			impx# = TOKCOL_WorldContactPointAX#(GAMEDATA\ColBank,c)
			impy# = TOKCOL_WorldContactPointAY#(GAMEDATA\ColBank,c)
			impz# = TOKCOL_WorldContactPointAZ#(GAMEDATA\ColBank,c)

			If (BodyA = GAMEDATA\vehicle1\RL_wheel_RB) tempdeb$ = zf# ; imp#
			
			;check if bodyA is a wheel
			If (BodyA = GAMEDATA\vehicle1\RL_wheel_RB) Or (BodyA = GAMEDATA\vehicle1\RR_wheel_RB) Or (BodyA = GAMEDATA\vehicle1\FL_wheel_RB) Or (BodyA = GAMEDATA\vehicle1\FR_wheel_RB)
;				If (imp# > 20.0)
;					chan = PlaySound(SFX_landing_tarmac)
;					ChannelVolume chan , 1.0
;				EndIf
			EndIf
			
			;sparks if body hits track
			If (BodyA = GAMEDATA\vehicle1\chassis_RB)
				If (Abs(GAMEDATA\vehicle1\speed#) > 5.0) 
					If UI\ENABLE_PARTICLES
						FUNC_Create_Spark(impx#,impy#,impz#,Rnd(-20,-80),Rnd(360),GAMEDATA)
					EndIf
				EndIf
			EndIf
						
		Next


thx vorderman, i tried this code. but it does not detect my static-mesh either.
it detects all other collision-objects but not the level-file i loaded.

well finally i am using blitz3d "linepick()" to detect collision between level- and player-mesh.
not as good as i wanted. but it works at last.