tokamak physics thread 4

Blitz3D Forums/Blitz3D Programming/tokamak physics thread 4

How doesn't it work? just doesn't move at all? try debugging various variables - see what the problem is. Make sure you've set the RB variable, and the Getx/y/z things are typed properly. Debug the values of the tformedx/y/z. See if they are responding to your input.

[edit]Okay so there was a little error :P I made a demo to test:
Const Rigid_Bodies=100,Animated_Bodies=5
TOKSIM_SetRigidBodiesCount Rigid_Bodies
TOKSIM_SetAnimatedBodiesCount Animated_Bodies
TOKSIM_SetRigidParticleCount 0
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount Rigid_bodies+Animated_Bodies ;Assuming each one only has one geometry.  Not true with more complex rigid bodies and animated bodies.
TOKSIM_CreateSimulator(0,0,0)

Graphics3D 640,480
;Setup The scene
lander=CreateCube()
landerb=TOKRB_Create()
TOKRB_AddBox landerb,2,2,2
campiv=CreatePivot()
cam=CreateCamera(campiv)
PositionEntity cam,0,0,-5

l=CreateLight()

While Not KeyHit(1)
	TurnEntity campiv,0,.25,0
	TOKSIM_Advance .1,1
	;Position graphical representation
	PositionEntity lander,TOKRB_GetX(landerb),TOKRB_GetY(landerb),TOKRB_GetZ(landerb)
	RotateEntity lander,TOKRB_GetPitch(landerb),TOKRB_GetYaw(landerb),TOKRB_GetRoll(landerb)
	TFormVector .1,0,0,cam,0
	x#=TFormedX()
	y#=TFormedY()
	z#=TFormedZ()
	TFormVector 0,(KeyDown(205)-KeyDown(203))/100.0,0,cam,0
	TOKRB_ApplyImpulse2 landerb,x#,y#,z#,TOKRB_GetX(landerb)+TFormedX(),TOKRB_GetY(landerb)+TFormedY(),TOKRB_GetZ(landerb)+TFormedZ()
	TOKRB_ApplyImpulse2 landerb,-x#,-y#,-z#,TOKRB_GetX(landerb)-TFormedX(),TOKRB_GetY(landerb)-TFormedY(),TOKRB_GetZ(landerb)-TFormedZ()
	RenderWorld
	Flip
Wend
TOKSIM_DestroySimulator
I don't think its a very suitable way to control a lunar lander sim but oh well.