Setting Inertia Tensor

Is it possible to set the inertia tensor used for a rigid body control?

I have understood thus far that it is possible to set the mass and principal moments of inertia for a rigid body through function calls to jbullet itself through the following functions:

final javax.vecmath.Vector3f principalInertia = new javax.vecmath.Vector3f(inertia.toArray(null));
rbc.getObjectId().setMassProps(mass_kg, principalInertia);

or to set the principal inertias more directly:

final javax.vecmath.Vector3f principalInertia = new javax.vecmath.Vector3f(inertia.toArray(null));
setInvInertiaDiagLocal(Vector3f diagInvInertia);

However, I have not been able to find any way to set the off diagonal terms of the inertia tensor, namely through specifying the principal axes. At the very least, I expected it to be pretty straightforward something as basic as the entire inertia matrix for an rbc to exist, but i have not been able to find anything. At first i considered that jbullet might limit itself to have all rigid bodies require principal axes that align with the reference frame unit vectors( which would be severely limiting, but i considered it nonetheless) but I could clearly see that it was possible to get the inertia tensor as a whole(but not set it?) that the off diagonal terms were not zero. Namely this was observed with the function:

javax.vecmath.Matrix3f inertiaTensor = new javax.vecmath.Matrix3f();

Since the off diagonal terms were clearly non-zero, then the principal axes are clearly not aligned with the rbc reference frame. So the question remains, how can either the principal axes or the entire inertia tensor as a whole be set?

bullet uses a Inertia vector for this kind of stuff, see

It might be that the current bullet binding for native does not have these functions wrapped, but I’m not sure on that, if so I guess adding these should be doable.

Hope this helps.

1 Like

Thanks for that find; but wow, so bullet expects models to be put in aligned to their principal axes.

<rant> That's kind of stupid, then why even bother storing the tensor and using it in multiplications? The first response that it "isn't uncommon" seems biased. I have found most physics engines to utilize the entire tensor. Only elementary physics engines try to avoid the inertia tensor calculations. But even then, simple ones like ODE utilize the inertia tensor </rant>

I will see if i can modify the “basic demo” program they provided in that forum post for this program and report back here.

Thanks again.