EasyTok/Tokamak - how to detect collision?

Blitz3D Forums/Blitz3D Userlibs/EasyTok/Tokamak - how to detect collision?

Boiled Sweets(Posted 2006) [#1]
Is there a clever way to check whether a RB cube is collided with an AB cube?

Basically I need to know whether a cube is 'sitting' on another cube (the 2nd cube is a flattened larger cube)


Filax(Posted 2006) [#2]
Do you look the example : Beginning - Camera Move 01.bb
It's an example with camera moving with physic + collisions


Boiled Sweets(Posted 2006) [#3]
I have EasyTok 1.1 - it does not have that example


Filax(Posted 2006) [#4]
??? 1.1 ??? Send me an email at "pagnisola at exequo dot com"


Boiled Sweets(Posted 2006) [#5]
done


Filax(Posted 2006) [#6]
not received yet.


Boiled Sweets(Posted 2006) [#7]
Sent again from work this time.


Filax(Posted 2006) [#8]
Sended :)


Boiled Sweets(Posted 2006) [#9]
Gotted :-)

Thanks.


Boiled Sweets(Posted 2006) [#10]
There is no Beginning - Camera Move 01.bb exmaple in the 1.3 archive :-(


Bain(Posted 2006) [#11]
Hi can someone please explaine how to detect collisions with EasyTok, if I load a mesh
MyMesh=LoadMesh("MyMesh.3ds")
TOK_CreateRBCube("Object",MyMesh,0,0,0,0,0,0,2,2,2,6,"",255,255,255,1,0)
and set it for a Rb object
and if i create a TokCollider ie
Map1=LoadMesh("Map1.b3d")
TOK_CreateTokCollider(Map1,"",Map1,0);,Erase=False

I can see that the collisions work the two object interact with each other but I need know if they have collided.

can anyone help pls ?


Boiled Sweets(Posted 2006) [#12]
That's exactly my point!

You cannot use the Blitz collision detection as we are using dynamic bodies here.

I don't think it can be done.


Filax(Posted 2006) [#13]
The only way that i have find to make collisions
is under the example : Beginning - Push Object 01.bb
you can see how the camera can push an object.


Boiled Sweets(Posted 2006) [#14]
Filax,

but that is not good for dymanic colisions.


Filax(Posted 2006) [#15]
I know but i have not solutions for the moment :/


Bain(Posted 2006) [#16]
I have noticed that TOK_CreateTokCollider has a flag for collision but TOK_CreateRBCube has no flag not sure how to use the collision flag in TOK_CreateTokCollider or even how to get a result from it, anyway I have thought of a possible workaround using Blitz collisions

MyMesh=LoadMesh("MyMesh.3ds")
TOK_CreateRBCube("Object",MyMesh,0,0,0,0,0,0,2,2,2,6,"",255,255,255,1,0)
Map1=LoadMesh("Map1.b3d")
TOK_CreateTokCollider(Map1,"",Map1,0);,Erase=False
freeentity MyMesh

CollisionFlag=createcube(0)
scaleentity CollisionFlag,2,2,2
entityalpha CollisionFlag,0
Repeat
;keep the CollisionFlag entity at same position as the Rb ;object
CollisionFlagX#=(TOK_GetRBY#"Object")
CollisionFlagY#=(TOK_GetRBY#"Object")
CollisionFlagZ#=(TOK_GetRBY#"Object")
positionmeshCollisionFlag,CollisionFlagX,CollisionFlagY,CollisionFlagZ
Until KeyHit (1)

and just check for collisions with the CollisionFlag mesh and the map1 blitz mesh,I have not tested this and am assuming that when you create a Tok_CreateTokCollider mesh that the original biltz mesh is copyed and is still there. anyway this is just a quick idea I will test it tonight.


Bain(Posted 2006) [#17]
--


Bain(Posted 2006) [#18]
This is a bit better but it is still not detecting a collision on every impact any ideas anyone mabey I need to play around with TOK_RefreshPhysic(.1,2)?

Include "Inc_EasyTOK.bb"

Const Balls=1,Maps=2

Graphics3D 800,600
SetBuffer BackBuffer()
Cam=CreateCamera()
PositionEntity Cam,0,0,-40

Global Light=CreateLight()
PositionEntity Light,0,50,-10

TOK_InitWorld(0,-.6,0,1000,100)

Ball1=CreateSphere()
EntityType(ball1,Balls)
TOK_CreateRBSphere("Ball",Ball1,0,0,0,0,0,0,1,.2,"",255,255,255,1,0)
FreeEntity Ball1

Global Map=CreateCube()
ScaleEntity Map,2,2,2
EntityType Map,Maps
EntityColor Map,255,0,0
PositionEntity Map,0,-20,0
TOK_CreateTokCollider(Map,"",Map,Maps,0); Set the collision type to maps

Collisions Balls,Maps,2,2

Repeat

UpdateWorld()

TOK_RefreshPhysic(.1,2)
TOK_RefreshEasyTOK()

RenderWorld()
If EntityCollided(TOK_GetRBMesh("Ball"),Maps)
TOK_ApplyImpulse("ball",0,.5,0)
EndIf

Flip
Until KeyHit(1)

TOK_FreePhysic()
End


Filax(Posted 2006) [#19]
You must know bain that blit have many many problems with collisions and moving objects :( In pure blitz detect
collisions with animated objects is the hell, so with
tokamak ...