Confused by initial forces on Bodies.

AzCopey

11-02-2009 17:54:35

I'm trying to use Ode to do Collision Detection and movement in a Ogre application. The collision detection works, however there is a problem with the initial forces/velocities of my bodies - all the entities all start with a random velocity in the X axis.

The constructor for my Entities function i believe sets all of the initial velocities and stuff so they should only fall under gravity. For the sake of testing i've removed gravity all together, but that hasnt stopped every newly created entity floating away.

Constructor:WorldEntity::WorldEntity(Ogre::SceneManager * _SceneMgr, OgreOde::World * _pWorld, OgreOde::Space * _pSpace, string _name, string _mesh){
m_name = _name;
id = WorldEntity::entityCount;
WorldEntity::entityCount++;
m_state = STATE_NORMAL;
m_sceneMgr = _SceneMgr;

m_HitBoxSize = Ogre::Vector3(50,50,50);
m_Mass = OgreOde::BoxMass(0.5,m_HitBoxSize);

//add these to the scene
m_entity = m_sceneMgr->createEntity( _name, _mesh );
m_position = m_sceneMgr->getRootSceneNode()->createChildSceneNode( _name );
m_position->attachObject( m_entity );

m_pBody = new OgreOde::Body(_pWorld);
m_position->attachObject(m_pBody);

//here...
m_pBody->setLinearVelocity(Ogre::Vector3(0,0,0));
m_pBody->setForce(Ogre::Vector3(0,0,0));
m_pBody->setAngularVelocity(Ogre::Vector3(0,0,0));
m_pBody->setTorque(Ogre::Vector3(0,0,0));
m_pBody->setPosition(Ogre::Vector3(100,-50,0));
//to here....

m_pGeom = (OgreOde::Geometry*)new OgreOde::BoxGeometry(m_HitBoxSize, _pWorld, _pSpace);
m_pBody->setMass(m_Mass);
m_pGeom->setBody(m_pBody);

m_pBody->updateCurrentState();
m_entity->setUserObject(m_pGeom);
}


The section between the comments is where i believe everything is being set to 0, however my understanding of OgreOde is limited at best. I've also looked through every function within Body, and i cannot see anything else that should obviously be set to 0, but clearing i'm missing something somewhere.

Basically i was wondering if anyone can see an obvious problem here, as currently Bodies are not altered any where else in the code, or have encountered a similar problem before?