Inertia tensor

kangaroo
Posts: 11
Joined: Wed Mar 13, 2013 10:18 pm

Inertia tensor

Post by kangaroo »

Hi. I want to set a constraint on two bodies. One of them has to have an inertia tensor, that can vary and also cant be diagonalized since its local coordinate system is just rigidly attached to it in a specific manner. An inertia tensor of a rigid body is a private attribute and also cant be set by any of the member functions i know of. If i declare it a public attribute and then set it every time before the simulation steps forward, will this do the trick? Thanks.
papaonn
Posts: 41
Joined: Wed Nov 20, 2013 4:14 pm

Re: Inertia tensor

Post by papaonn »

Hi since the inertia tensor is private member, there is no alternative to access it except for the object itself,
so probably you will need to try this suggestion :

A non-within-class function that take care of the rest :

void gfnSetInertiaTensor(int objIndex){
glpCollisionShape[objIndex]->calculateLocalInertia(...);
}


void GameObj::Run(){
if(ObjA->needSomeChangesOnOtherObj){
gfnSetInertiaTensor( ObjB.geIndex() );
}
}
kangaroo
Posts: 11
Joined: Wed Mar 13, 2013 10:18 pm

Re: Inertia tensor

Post by kangaroo »

yes, it would be a good idea, but i have not found any implementation of setLocalInertia that would take an array of vertices with different masses and calculate its inertia. So, it would probably be better to add a function to the rigid body class, somthing like setInvInertiaTensorWorld and set it before constraints are solved.
papaonn
Posts: 41
Joined: Wed Nov 20, 2013 4:14 pm

Re: Inertia tensor

Post by papaonn »

It's a good suggestion ;)
Perhaps the team has several reasons not to deal with it for the time being,
let's wait for the future version =)
kangaroo
Posts: 11
Joined: Wed Mar 13, 2013 10:18 pm

Re: Inertia tensor

Post by kangaroo »

Why would i wait if it is an open-source. I can do it on my own, all it takes is just writing this function and recompiling.