Tokamak Collisions problem ? bug ?

Blitz3D Forums/Blitz3D Programming/Tokamak Collisions problem ? bug ?

OverDozing(Posted 2004) [#1]
Hey,
I've been experiencing a problem with tokamak and classic blitz collision detection.

Take a look at the code, try it like that it will detect the collision ground,ball perfectly!
Now add ; to the size1 lines, and uncomment the ones size2 and see the collisions are not detected anymore??? how come ? any ideas? any solutions ?

---------------------------

;Set Graphics
Graphics3D 640,480,0,2 : SetBuffer BackBuffer()
;Consts
Const FPS = 50 : Const RBCOUNT = 1 : Const ABCOUNT = 5
;Camera
cam = CreateCamera() : PositionEntity cam,0,1,-20 : RotateEntity cam,45,0,0
;Light
light1 = CreateLight() : RotateEntity light1,0,60,0

TOKSIM_CreateSimulator 0,-10,0

;The Ball
ball = CreateSphere(16)
ScaleEntity ball,1,1,1 ;<--------------Size1 ... ok
;ScaleEntity ball,2,2,2 ;<--------------PROBLEM HERE
rbBall = TOKRB_Create()
TOKRB_AddSphere rbBall,2 ;<--------------Size1 ... ok
;TOKRB_AddSphere rbBall,4 ;<--------------PROBLEM HERE
TOKRB_SetMass rbBall,2
TOKRB_SetSphereInertiaTensor rbBall,2,2 ;<--------------Size1 ... ok
;TOKRB_SetSphereInertiaTensor rbBall,4,2 ;<--------------PROBLEM HERE
TOKRB_SetLinearDamping rbBall,0.001
TOKRB_SetAngularDamping rbBall,0.02
TOKRB_SetPosition rbBall,0,40,0

;Plane
plane = CreatePlane()
EntityColor plane,0,0,100
EntityAlpha plane,0.9
mirror = CreateMirror()
abPlane = TOKAB_Create()
TOKAB_AddBox abPlane,130,2,130
TOKAB_SetPosition abPlane,0,-1,0

;collisions setup
EntityType plane,1
EntityType ball,2
Collisions 2,1,2,2

;The walls
wallLeft = CreateCube()
ScaleEntity wallLeft,1,30,65
PositionEntity wallLeft,-65,30,0
abWallLeft = TOKAB_Create()
TOKAB_AddBox abWallLeft,2,60,130
TOKAB_SetPosition abWallLeft,-65,30,0
wallRight = CreateCube()
ScaleEntity wallRight,1,30,65
PositionEntity wallRight,65,30,0
abWallRight = TOKAB_Create()
TOKAB_AddBox abWallRight,2,60,130
TOKAB_SetPosition abWallRight,65,30,0
wallFront = CreateCube()
ScaleEntity wallFront,65,30,1
PositionEntity wallFront,0,30,65
abWallFront = TOKAB_Create()
TOKAB_AddBox abWallFront,130,60,2
TOKAB_SetPosition abWallFront,0,30,65
wallBack = CreateCube()
ScaleEntity wallBack,65,30,1
PositionEntity wallBack,0,30,-65
EntityAlpha wallBack,0.1
abWallBack = TOKAB_Create()
TOKAB_AddBox abWallBack,130,60,2
TOKAB_SetPosition abWallBack,0,30,-65

;Torque
torque# = 200

period = 1000/FPS
time = MilliSecs() - period

;Main loop
While Not KeyHit(1)

Repeat
elapsed = MilliSecs() - time
Until elapsed

ticks = elapsed/period

tween# = Float(elapsed Mod period)/Float(period)

For k = 1 To ticks
time = time + period
If k = ticks Then CaptureWorld

torqueX# = (KeyDown(203) - KeyDown(205)) * torque#
torqueZ# = (KeyDown(200) - KeyDown(208)) * torque#

TOKRB_SetTorque rbBall,torqueZ#,0,torqueX#
TOKRB_SetForce rbBall,-torqueX# * 0.1,0,torqueZ# * 0.1

;Advance the simulator
TOKSIM_Advance(1.5/FPS,1)

PositionEntity ball,TOKRB_GetX(rbBall),TOKRB_GetY(rbBall),TOKRB_GetZ(rbBall)
RotateEntity ball,TOKRB_GetPitch(rbBall),TOKRB_GetYaw(rbBall),TOKRB_GetRoll(rbBall)
PointEntity cam,ball

UpdateWorld
Next

RenderWorld tween
Color 255,0,0 : Text 0,0,CountCollisions(ball)

Flip
Wend
;Destroy
TOKSIM_DestroySimulator
End

---------------------


Bot Builder(Posted 2004) [#2]
You have to tell the blitz collision system that the ball has a radius of 2:
EntityRadius ball,2



OverDozing(Posted 2004) [#3]
Oh man! thank you so much, I cant believe this, it's working ! :)


Nacra(Posted 2004) [#4]
Pardon my ignance but what are the benefits of blitz collisions over tokamak collisions? Speed versus flexibility?

I've just been using TOKAB_SetCollisionID, TOKSIM_SetMaterial, and TOKSIM_SetCollisionResponse and letting tokamak handle everything.


thanks


Rob(Posted 2004) [#5]
Tokamak is way more flexible.

But the reason we use tokamak is because it's a physics engine like HAVOK or Mathengine/Karma.

Ragdolls, cars, crates etc...


Bot Builder(Posted 2004) [#6]
Well, I presume it would be for a FPS or somthing. HRC_SPIDER - you know you can use tokamak collisions to detect stuff right?


OverDozing(Posted 2004) [#7]
Well, I have to admit, I did try using the tokamak collisions detection but after one day trying to make it work on my project, I started addind the classic collision detected from blitz and as it work perfectly now, I have been very happy about the result.

Is Tokamak collisions detection is faster ?

I am using collisions detecting to know if the wheels are on the ground, 1 or 2 or 3 .... it makes different cases...

I would add tokamak collision with pleasure but I have to say, after 1 day trying, I am not sure if I can do it.