positioning/orientation of carbody...

me_go_fast

14-05-2006 00:10:43

Hello, when I try to create a vehicle with a shape different than a cube, I cannot get gravity to affect it. I originally thought it could be from a big gap between the tires and body, but then when I tried to move the body and tires closer nothing changed? If anyone has any idea what may be the problem, please let me know. Below is the code I use to create the carbody.

Ogre::Real mass = 900;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( mass, size );
Ogre::Entity* carMesh = sceneMgr->createEntity("Car"+Ogre::StringConverter::toString(mEntityCount++),"Car02.mesh");
carMesh->setCastShadows(false);
Ogre::SceneNode* carNode = sceneMgr->getRootSceneNode()->createChildSceneNode(pos, orient);
carNode->attachObject(carMesh);
carNode->setScale(0.0005,0.0005,0.0005);
// Creates and places the camera via a child node off of the car node
Ogre::SceneNode* camNode = carNode->createChildSceneNode(Ogre::Vector3(carNode->getPosition().x - 2000, carNode->getPosition().y + 2000, carNode->getPosition().z),Ogre::Quaternion(Ogre::Quaternion(sqrt(0.5),0,-sqrt(0.5),0)));
camNode->attachObject(mCamera);
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld, carNode, false);
OgreNewt::Body* bod = new OgreNewt::Body(mWorld, col);
delete col;
bod->attachToNode(carNode);
bod->setMassMatrix( mass, inertia );
bod->setStandardForceCallback();
bod->setPositionOrientation(pos,orient);
return bod;


Thanks

walaber

15-05-2006 17:58:40

you cannot use TreeCollision for dyamic (moving) objects. you need to use ConvexHull for those!

me_go_fast

15-05-2006 22:44:10

Good point! Thanks! :oops: I feel stupid for overlooking something so simple!