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
---------------------
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
---------------------