centre of mass of a convex hull

unclepauly

16-10-2006 21:24:55

hello,

what is the best way to calculate the centre of mass when using a convex hull?

here is my situation: the rigid body for my car is a convex hull. i use this code:


OgreNewt::ConvexCollision* col = new OgreNewt::CollisionPrimitives::ConvexHull(mWorld, mCarNode);
Ogre::Vector3 inertia;
col->calculateInertialMatrix(inertia, mOffset);
OgreNewt::Body* bod = new OgreNewt::Body(mWorld, col);
delete col;


mOffset is then used in the setup() function, to set the car's centre of mass, like this:


m_chassis->setCenterOfMass(mOffset);


i found that with this method, the car fliped over on its side whenever i turned a corner (it didn't even have to be going at a high speed for it to happen). it reminded me of a double-decker bus taking a sharp corner at high speeds, and just falling on its side. so, i guessed that the centre of mass was too high.

so then i did this:


Ogre::Vector3 com = Ogre::Vector3(mOffset.x, mOffset.y - 0.3, mOffset.z);
m_chassis->setCenterOfMass(com);


so this just makes the centre of mass a bit lower. it certainly stops the problem, but is there a better way of doing this?

unclepauly

17-10-2006 16:35:53

i would still like to know the answer to my question above.

btw, a compound collision surely is not the 'correct' way to do it (as i have read in the newton forums) because my car mesh is one mesh, not made up of different meshes.

so basically, is using the offset as returned from calculateInertialMatrix the correct way to set the centre of mass? and if the car flips over when turning a corner, is setting the centre of mass to a lower point recomended or is there a better alternative?

thank you.

unclepauly

17-10-2006 17:36:41

got an answer on the newton forum - turns out i am doing it correctly!

happy days.