tokamak - how do I rotate an object?

Blitz3D Forums/Blitz3D Programming/tokamak - how do I rotate an object?

Vorderman(Posted 2004) [#1]
I want to rotate an object (and by this I mean a thing made up from a few rigid bodies joined by joints), but how can I do this? I want to be able to position it at a certain place and at a certain orientation, and have it start off from that point with zero velocity or momentum.

If I just rotate the central rigid body, it imparts a huge torque onto the object causing it to spin.

I've tried using the SetMomentum and SetTorque commands to zero the momentum on all parts of the object, but it still spins.

Anyone know how I can achieve this apparently simple thing?

Thanks


Rob(Posted 2004) [#2]
I'd like to know this too. Because if you try and rotate it, it rotates just the RB, and not all it's bits n bobs.

I've done the position part - spent all day on it today - basically it's just TOKRB_SetPosition applied to all rbs at once.

setting the rotation and position ignores collisions by the way but I'm guessing this is what you want. I'm doing it the hard way I suppose.

One thing I need help with is actual steering! it's got me hilariously confused now.


Chi3f Stadi(Posted 2004) [#3]
Does this help you ?

;AT THE BEGINNING
model=CreateCube()
rigidbody = TOKRB_Create()
geom = TOKRB_AddBox (rigidbody,2.0,2.0,2.0)
...
TOKRB_SetPosition rigidbody,0,0,0
TOKRB_SetRotation rigidbody,0,0,0
PositionEntity cube,TOKAB_GetX#(rigidbody),TOKAB_GetY#(rigidbody),TOKAB_GetZ#(rigidbody)
RotateEntity cube,TOKAB_GetPitch#(rigidbody),TOKAB_GetYaw#(rigidbody),TOKAB_GetRoll#(rigidbody)

;TO TURN YOU COULD USE FOR EXAMPLE
TOKRB_SetAngularMomentum rigidbody,0,-6,0

In the beginning i had the same problem with my rigidbodies. Spineffect could be stopped by adjusting the TOKRB_SetBoxInertiaTensor values !


IPete2(Posted 2004) [#4]
Er...

Shouldn't you be using AnimatedBodies for collections of objects and none collision objects?

TOKAB commands are for tokamak animated bodies. These are not affected by physics, and are positioned and rotated by your program. They have to be made out of the tokamak primitives, and like rigid bodies, can have more complex shapes constructed from the geometries. Uses for these are things like moving platforms, doors, gates, traps, etc.

Is this what you meant or am I up the wrong tree again?

There is also an example on player factory of connecting RBs together, making a table and chair, find it here:

http://playerfactory.proboards25.com/index.cgi?board=tokamak2&action=display&num=1076363448

IPete2.


Bot Builder(Posted 2004) [#5]
If you still want to use a jointed model, you could parent the meshs representing the jointed parts to the center part you rotate around (if it isn' already), then position and rotate you blit model to the proper position. then, pass global position and rotation on to tokamak.


Rob(Posted 2004) [#6]
Thats quite elegent. Perhaps a hierarchy of pivots. Each pivot's name could hold the rb handle.


Vorderman(Posted 2004) [#7]
What I want to do is reset my car back on the track after it plummets off. It's the block car from the demo, with 4 RBs for wheels.

What I actually want to happen is that it is repositioned over the track and set the correct orientation, with no momentum or velocities. However, there seems to be no way within Tokamak perform a sort of 'reset' on the entity to achieve this.

I've tried zeroing the momentum of each part, but they still aquires enormous momentums from the twist.

I shall try setting the interia tensors of all to zero before reorienting to object, to see if that works...


Sweenie(Posted 2004) [#8]
Do you reset the velocity as well?

This should work...
TOKRB_SetVelocity RB,0,0,0
TOKRB_SetAngularMomentum RB,0,0,0
Apply this to ALL parts.

It's also important that all parts are repositioned correctly or else the joints could generate unwanted forces to bring the parts together.


Vorderman(Posted 2004) [#9]
Cheers guys - I got it working. I had to set all the inertia tensors to zero, velocities to zero and momentums to zero, then rotate the central object and reset all the inertia tensors afterwards. It works OK now.