Problems whit collision among objects.

rruiz

23-06-2008 22:19:52

Hello. I have 2 objects and a plane ... the objects collide with the plane but they do not collide among themselves ...my base class


this is my class:

class BaseApplication : public OgreOde::CollisionListener
{
public:
BaseApplication(void);
virtual ~BaseApplication(void);

virtual void go(void);


protected:
....
virtual bool collision(OgreOde::Contact* contact);

....
OgreOde::World *mWorld;
OgreOde::Space *mSpace;
OgreOde::StepHandler *mStepper;
OgreOde::Geometry* sGeom;

OgreOde::InfinitePlaneGeometry *mGround;
OgreOde::Body *mBody;
Ogre::SceneNode *mNode;
Ogre::Entity *mEntity;
};



and this is my metod collision


bool BaseApplication::collision(OgreOde::Contact* contact)
{
// Check for collisions between things that are connected and ignore them
OgreOde::Geometry * const g1 = contact->getFirstGeometry();
OgreOde::Geometry * const g2 = contact->getSecondGeometry();

if (g1 && g2)
{
const OgreOde::Body * const b1 = g1->getBody();
const OgreOde::Body * const b2 = g2->getBody();
if (b1 && b2 && OgreOde::Joint::areConnected(b1, b2))
return false;
}
//set contact parameters:
contact->setBouncyness(1.0);
contact->setCoulombFriction(OgreOde::Utility::Infinity);
contact->setForceDependentSlip(1.0);
contact->setAdditionalFDS(1.0);
return true;
}



and this is a object
mEntity = mSceneMgr->createEntity("crate","habPrueba.mesh");
mEntity->setQueryFlags (1<<2);
SceneNode* mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mNode->attachObject(mEntity);
mEntity->setNormaliseNormals(true);
mEntity->setCastShadows(true);

mBody = new OgreOde::Body(mWorld);
mNode->attachObject(mBody);
Vector3 size(2.0,2.0,2.0);
OgreOde::BoxMass mMass(1,size);
mMass.setDensity(5.0,size);
mGeom = (OgreOde::Geometry*)new OgreOde::BoxGeometry(size, mWorld, mSpace);
mNode->setScale(size.x * 2.0,size.y * 2.0,size.z * 2.0);
mBody->setMass(mMass);
mGeom->setBody(mBody);



the other are defined like this.

why dont work???

rewb0rn

24-06-2008 21:26:28

Have you read this thread?
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=7451

rruiz

26-06-2008 19:22:05

hi.. i saw, and i added that code to my proyect but didn't solve my problem i dont know what is wrong

Happy-Howard

27-06-2008 08:19:16

Are you sure your collision geometries align with your meshes?

If you haven't done that already you should enable debug geometries:

mWorld->setShowDebugGeometries(true);


The meshes must be modelled around (0, 0, 0) to align with the OgreOde::BoxGeometry