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:
mOffset is then used in the setup() function, to set the car's centre of mass, like this:
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:
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?
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?