luffy
07-03-2006 21:28:54
Hi, i am having some problems detecting collisions.
I have 2 objects in my world, the two have the same size, mesh, body, etc. This is the code of (one) them
My problem is that the collision ONLY start when the center of the objects collide. ¿What i am doing wrong?
I have 2 objects in my world, the two have the same size, mesh, body, etc. This is the code of (one) them
Entidad::Entidad(OGR* ogre, NWT* newton, string nombre, string mesh, Vector3 tamanno, const OgreNewt::MaterialID* mat)
{
// OGRE Object creation
mEntidad = ogre->mSceneManager0->createEntity(nombre,mesh);
mNode = ogre->mSceneManager0->getRootSceneNode()->createChildSceneNode("n" + nombre);
mNode->attachObject(mEntidad);
mNode->setPosition(0,0,0);
mNode->yaw(Radian(90));
mNode->setScale(tamanno);
mEntidad->setNormaliseNormals(true);
// Newton object creation
mMat = mat;
mColision = new OgreNewt::CollisionPrimitives::Box(newton->mWorld,tamanno);
mBody = new OgreNewt::Body(newton->mWorld,mColision);
mBody->attachToNode(mNode);
mBody->setMaterialGroupID(mMat);
// Destoy collision object
delete mColision;
// Mass + inertia
Ogre::Vector3 inercia = OgreNewt::MomentOfInertia::CalcBoxSolid(10.0,tamanno);
mBody->setMassMatrix( 10.0, inercia );
mBody->setAutoFreeze(false);
// Position Orientation
mBody->setPositionOrientation(mNode->getWorldPosition(), mNode->getOrientation());
// Store a pointer to the Entidad object
this->mBody->setUserData(this);
}
My problem is that the collision ONLY start when the center of the objects collide. ¿What i am doing wrong?