Collision is wierd, sometimes the objects go thru the other

hoffhoff

03-11-2006 18:49:31

Hello,
I have the objects moving fine, and also the collision with the scenary.
I was using the two ogre models (ninja and robot) and it was working fine too, but now I put my models, and what is happening is:



This another screen shows the vertices:



It looks ok. Also, the collision do work, but when forcing the yellow craft start entering inside the white one.
What could be the problem?

Here is my init code in the CCraft class:


Ogre::Entity* ent;
OgreNewt::ConvexCollision* conv;
//OgreNewt::Collision* conv;
Ogre::Vector3 inertia;
Ogre::Vector3 offset;
std::string entityname = m_Name + "entity";
std::string scenenodename = m_Name + "scenenode";

//create the entity
ent = m_pSceneManager->createEntity(entityname, m_MeshFileName);

//Create a new scenenode
m_pSceneNode = m_pSceneManager->getRootSceneNode()->createChildSceneNode(scenenodename);
m_pSceneNode->setScale(m_Scale);
m_pSceneNode->attachObject(ent);
//m_pSceneNode->setPosition(m_Pos);
//m_pSceneNode->setOrientation(NULL);//m_Orientation);

//Now create the newton body
conv = new OgreNewt::CollisionPrimitives::ConvexHull(m_pWorld, m_pSceneNode, m_pSceneNode->getOrientation(), m_pSceneNode->getPosition());
//conv = new OgreNewt::CollisionPrimitives::TreeCollision(m_pWorld, m_pSceneNode, false);

m_pBody= new OgreNewt::Body(m_pWorld, conv);

//m_pBody->setMaterialGroupID(pMatCollision->getMaterialID(this->m_Material));

m_pBody->attachToNode( m_pSceneNode );
m_pBody->setPositionOrientation( m_Pos, m_pSceneNode->getOrientation() );
m_pBody->setUserData(this);
m_pBody->setAutoFreeze(0);
conv->calculateInertialMatrix(inertia, offset);

//conv->calculateInertialMatrix(inertia, offset);
//We dont need conv anymore
delete conv;
//Set the mass matix
m_pBody->setMassMatrix(m_Mass, inertia);
//Set force callback
m_pBody->setCustomForceAndTorqueCallback(boomwar::local::CCraft::craftForceandTorqueCallback);
return true;




Thanks!