Tokamak Physics Thread 5

Blitz3D Forums/Blitz3D Userlibs/Tokamak Physics Thread 5

Random Hint:
There is a SetUserData function, with which you can link your tokamak objects to your visual objects :)



Now... I'm at the last stage of the last 20 lines of code of the last function of my first release of my program.

The question: Setboxinertiatensor, etc.
The docs are a bit clumsily worded for this function (or maybe it's the example, or maybe it's just me).


Description:
Sets a box Rigid Body inertia tensor. For Rigid Bodies with only a box geometry, use this command along with the diminsions of the box and the mass of the rigid body.


This creates a table and sets its box inertia tensor
i=1
obj(i) = CreateCube()
ScaleEntity obj(i),10,.5,10
rb(i) = TOKRB_Create()
TOKRB_AddBox rb(i),20.0,1.0,20.0
TOKRB_SetPosition rb(i),0,20,0
TOKRB_SetLinearDamping rb(i),0.001
TOKRB_SetAngularDamping rb(i),0.002
TOKRB_SetMass rb(i),2.0
TOKRB_SetBoxInertiaTensor rb(i),20.0,10.0,20.0,2.0
TOKRB_SetSleepingParameter rb(i),0
Addbox obj(i),rb(i),9,-5,9,2,10,2
Addbox obj(i),rb(i),-9,-5,9,2,10,2
Addbox obj(i),rb(i),9,-5,-9,2,10,2
Addbox obj(i),rb(i),-9,-5,-9,2,10,2
TOKRB_UpdateBoundingInfo(RB(i))
toks=toks+1

Function addbox(mesh,RigidBody,x#,y#,z#,Width#,Height#,Depth#,Pitch#=0,Yaw#=0,Roll#=0,alpha=1)
TOKGEOM_SetPositionAndRotation TOKRB_AddBox(RigidBody,Width#,Height#,Depth#),x#,y#,z#,Pitch#,Yaw#,Roll#
c=CreateCube(mesh)
ScaleEntity c,Width#/2,Height#/2,Depth#/2,1
PositionEntity c,x#,y#,z#,1
RotateEntity c,Pitch#,Yaw#,Roll#,1
End Function



So... Do I create the intertia tensor to fill up the full size of my mesh? What is it for? Do I have to call Set[shape]InertiaTensor after creating one geometry before going on to create others? Do I use it only if I'm using a single particular shape in my object?