Tokamak Movement?

Blitz3D Forums/Blitz3D Programming/Tokamak Movement?

I am working on a little tokamak program just trying to learn it. What I have is a box that I want to control with tokamak. Using the arrow keys up,down= move forward back, and left,right for turning. The problem is all the tokamak movement commands use global positioning. So how can I make it move like moveentity works?

Const Rigid_Bodies=1,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,-10,0) ;sets the gravity that acts on rigid bodies

SeedRnd MilliSecs()

Graphics3D 800,600

Const fps=60
l=CreateLight()
PositionEntity l,10,20,0
centerpoint=CreatePivot()
Global cam=CreateCamera(centerpoint)
PositionEntity cam,0,10,-50

 ;Setup The scene

ground=CreateCube()
EntityColor ground,5,5,55 
ScaleEntity ground,150,5,150 
PositionEntity ground,0,-5,0
PointEntity l,centerpoint

;Now, we'll set up the animated body For the ground. In this Case, it never actually moves.
abground = TOKAB_Create();TOKAB_Create creates an animated body And returns its Handle.
TOKAB_AddBox(abground,300.0,10.0,300.0);TOKAB_AddBox adds a box To the animated body. 
;The parameters are AnimatedBody, Width, Height, Depth.
TOKAB_SetPosition(abground,0.0,-5.0,0.0);TOKAB_SetPosition sets the position of the animated body. 
;The parameters are AnimatedBody, X, Y, Z.
;Here is the rest of the animated bodies setup:  

;Next, we create a rigid box.************************************************************************
Dim obj(Rigid_Bodies)                      ;Create a rigid box                                    
Dim rb(Rigid_Bodies)                                                                              
                                                                                                   
i=1                                                                                               
                                                                                                   
obj(i) = CreateCube() 
EntityColor obj(i),200,0,0                                                                            
ScaleEntity obj(i),1.0,1.0,1.0 ;                                                                         
rb(i) = TOKRB_Create() ;create rigid body                                                                           
TOKRB_AddBox rb(i),2.0,2.0,2.0 ;width*2,height*2,depth*2                                                                    
TOKRB_SetPosition rb(i),0,100,0  ;x,y,z                                                                  
TOKRB_SetLinearDamping rb(i),0.0 ;0-to-1                                                               
TOKRB_SetAngularDamping rb(i),0.02;                                                                 	
TOKRB_SetMass rb(i),3.0                                                                           
TOKRB_SetBoxInertiaTensor rb(i),2.0,2.0,2.0,2.0 ;width*2,height*2,depth*2 
PositionEntity obj(i),TOKRB_GetX#(rb(i)),TOKRB_GetY#(rb(i)),TOKRB_GetZ#(rb(i)) 
                                                  
;****************************************************************************************************


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

imptime=MilliSecs()

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
   

   For i=1 To Rigid_Bodies
	
    PositionEntity obj(i),TOKRB_GetX#(rb(i)),TOKRB_GetY#(rb(i)),TOKRB_GetZ#(rb(i)) 
    RotateEntity obj(i),TOKRB_GetPitch#(rb(i)),TOKRB_GetYaw#(rb(i)),TOKRB_GetRoll#(rb(i)),False 

    If KeyDown(57) Then
     TOKRB_ApplyImpulse (rb(i),0,3,0)
	 ;TOKRB_ApplyImpulse2 rb(i),0,0,1,10,10,10


    EndIf
	
	
	If KeyDown(200) Then ;upkey
		TOKRB_ApplyImpulse (rb(i),0,0,1)
		
		

	EndIf
	 
	If KeyDown(208) Then ;downkey
		TOKRB_ApplyImpulse (rb(i),0,0,-1)
		

	
	EndIf
	 
	If KeyDown(205) Then ;rightkey
		;TOKRB_ApplyImpulse2 (rb(i),0,0,-0.02,-0.2,0,.5)
	    TOKRB_ApplyTwist rb(i),0,4,0
		
		
	EndIf 
	
	If KeyDown(203) Then ;leftkey 
		;TOKRB_ApplyImpulse2 (rb(i),0,0,0.02,0.2,0,.5)
	 	TOKRB_ApplyTwist rb(i),0,-4,0
		

	EndIf 
	

   Next
  
	

  EndIf 
  TOKSIM_Advance(1.5/FPS,1)
  UpdateWorld
 Next

For i=1 To Rigid_Bodies


 
 camx#=Cos(rot#)*50
 camz#=Sin(rot#)*50

 ;PositionEntity centerpoint,EntityX(obj(i)),EntityY(obj(i)),EntityZ(obj(i))
 rot#=rot#+MouseXSpeed()
Next
  


 If rot#>360 Then rot#=0
 PositionEntity cam,camx#,10,camz#
 PointEntity cam,centerpoint
 
 RenderWorld tween
 Flip False
Wend

TOKSIM_DestroySimulator()
End


Try this...
	If KeyDown(200) Then ;upkey
	    TFormVector 0,0,1,obj(i),0 
		TOKRB_ApplyImpulse (rb(i),TFormedX#(),TFormedY#(),TFormedZ#())

	EndIf
	 
	If KeyDown(208) Then ;downkey
	    TFormVector 0,0,-1,obj(i),0 
		TOKRB_ApplyImpulse (rb(i),TFormedX#(),TFormedY#(),TFormedZ#())
	EndIf



Wow I didn't think it would be that simple!
Thank you very much.