Why ... why ... why... :(

Blitz3D Forums/Blitz3D Userlibs/Why ... why ... why... :(

I just don't understand...

Leave the code running for a few seconds and tell why the box just
keep rebounding stupidly until it gets into the hole... WHY just
can't get freeze as it would happen in any simple simulation...
... WHY just can't it remains OUT of the animated bodies...

I believe this has nothing to do with the Sweenie's wrapper, but
with Toka ... Why would care releasing a lib with just a ridiculous bug,
this is not even a complex simulation ... :(

Please tell me I'm wrong... WHAT THE HELL IS HAPPENING???

Graphics3D 640,480,16,2

Const FPS=60

AmbientLight 50,50,50

l=CreateLight(2)
	PositionEntity l,-5,5,-5
	LightRange l,15

cam=CreateCamera()
	PositionEntity cam,0,3,-8

;TOKA
TOKSIM_CreateSimulator(0,-10,0)


;Anim bodie:
ab_vis=CreateMesh()

ab=TOKAB_Create()
	geo=TOKAB_AddBox(ab,10,.5,10)
	vis=CreateCube():ScaleMesh vis,5,.25,5:AddMesh vis,ab_vis:FreeEntity vis

	geo=TOKAB_AddBox(ab,2,6,10)
		TOKGEOM_SetPositionAndRotation geo,2,3,0,0,0,0
	vis=CreateCube():ScaleMesh vis,1,3,5:PositionMesh vis,2,3,0:AddMesh vis,ab_vis:FreeEntity vis

	geo=TOKAB_AddBox(ab,2,2,10)
		TOKGEOM_SetPositionAndRotation geo,-2,1,0,0,0,0
	vis=CreateCube():ScaleMesh vis,1,1,5:PositionMesh vis,-2,1,0:AddMesh vis,ab_vis:FreeEntity vis


;Rigid bodie:
rb_vis=CreateCube()
	ScaleMesh rb_vis,1.5,1,1.5
	EntityColor rb_vis,255,0,0

rb=TOKRB_Create()
	TOKRB_AddBox rb,3,2,3
	TOKRB_SetPosition rb,-.75,4,0

	TOKRB_SetLinearDamping rb,.002
	TOKRB_SetAngularDamping rb,.01

	TOKRB_SetMass rb,5
	TOKRB_SetBoxInertiaTensor rb,3,2,3,5

;_------------------------------	



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

While Not KeyDown(1)

	;------ FPS Counter ----------
	fps_count=fps_count+1:fps_timer=fps_timer+(MilliSecs()-fps_millis):fps_millis=MilliSecs()
	If fps_timer>1000:fps_timer=0:fpsc=fps_count:fps_count=0:EndIf
	;---------------------------------------

	Repeat
		elapsed=MilliSecs()-time
	Until elapsed
	;how many 'frames' have elapsed	
	ticks=elapsed/period
	;fractional remainder
	tween#=Float(elapsed Mod period)/Float(period)

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

		TOKSIM_Advance(1.5/FPS,3)

		If KeyHit(57)
		TOKRB_SetPosition rb,-.75,4,0
		TOKRB_SetRotation rb,0,0,0
		EndIf

		If KeyHit(17) w=Not w WireFrame w

		UpdateWorld


		PositionEntity rb_vis,TOKRB_GetX(rb),TOKRB_GetY(rb),TOKRB_GetZ(rb)
		RotateEntity rb_vis,TOKRB_GetPitch(rb),TOKRB_GetYaw(rb),TOKRB_GetRoll(rb)
	Next
	

	RenderWorld tween
	
	Text 20,20,"Hit Space to reset"
	Text 20,35,"W to wireframe"
	
	Text 10,50,"FPS: "+fpsc
	Flip
Wend

MoveMouse 400,300:End

;---------------------------


Thanks
Paolo.

Making the three static boxes separate ab's (and by calling TOKAB_UpdateBoundingInfo) prevents the rb from "jumping" but it still doesn't prevent the rb from slowly moving inside the tall static box.
This is a VERY bad behaviour from the Tokamak-sim and I guess it's why many people choose not to use Tokamak.
If the Tokamak-crew just got rid of these nasty bugs I think Tokamak would be one of the best physics-sims around.
In the end I don't think users wants lots and lots of features but instead a fast and stable simulation.

Thanks Sweenie,
it works better now, and I think I can make a workaround for the box to not go inside the AB.