moving tokamak entities

Blitz3D Forums/Blitz3D Programming/moving tokamak entities

slenkar(Posted 2004) [#1]
In every loop the blitz entities are positioned where the tokamak rigid bodies are but how is player-movement integrated into this?

e.g. when you press forward, what do you do in blitz to make sure the rigid body moves with the blitz entity?

Also, is there a quick way to find the blitz entity in a type that collided when the rigid bodies are colliding?

finding 100 blitz entity types could be slow.


poopla(Posted 2004) [#2]
TOKRB_SetPosition
TokRB_GetX
TOKRB_GetY
TokRB_GetZ

You can easily reposition the tokomak entity yourself, or you can just as easily control the tokomak entity rather then the blitz entity. I would do the later.


Bot Builder(Posted 2004) [#3]
Well, depends on what you are doing. in the case that your player is an actual person, you only move the rigid bodies as soon as physics is initiated (say, when the player dies). If the player is somthing like a ball or a car etc. You would want to apply an impulse.

To position and rotate a rigid body(these ignore collisions) do this:
TOKRB_SetPosition(RigidBody%,X#,Y#,Z#)
TOKRB_SetRotation(RigidBody%,Pitch#,Yaw#,Roll#)


To apply an impulse:
TOKRB_ApplyImpulse(RigidBody%,X#,Y#,Z#)


Note, however, that apply impulse is global, so you have to do somthing different for local coords:
TFormVector X#,Y#,Z#,obj,0				;Where obj is the rigid body's physical representation
TOKRB_ApplyImpulse RB,TFormedX(),TFormedY(),TFormedZ()	;Where rb is the rigid body


So, using the code above, assuming your player is either an animated mesh with no physics applied to the limbs, or a non-animated object, when the player presses up, set Y to some positive value.

As for getting the entity handle quick, this may be available in future versions of the wrapper, because tokamak does support this. It's called "UserData".


poopla(Posted 2004) [#4]
Nice description. I'm too busy atm to go into such detail :).


slenkar(Posted 2004) [#5]
If im applying an impulse to the rigid body it doesnt interfere or replace the physics?


Almo(Posted 2004) [#6]
if tokamak properly implements impulse, that's a physics thing and it doesn't disrupt anything. It's an average force multiplied by the time over which that average was taken.

So if you apply an impulse of say, 5 Newton-Seconds (Newtons are a measurement of force), that's equivalent pushing for 5 seconds with a force of 1 Newton.

The upshot is that if you apply an Impulse every frame, it should be the force to be applied times the timestep for the frame.

It's the weird units (force multiplied by time) that make Impulses odd to work with.