When objects move - Collision

sakshi2212

08-03-2008 06:46:36

I am translating my objects node (SceneNode) when I press key:
node->translate(mDirection * move * time);

I have implemented the complete collision detection tutorial. My objects collide with the terrain, but they are passing through each other. So do I have to move the body/geom also when I move the node? Cause when the two objects are touching, its not going into the collision function, where we check the two objects in the contact object.

sakshi2212

08-03-2008 08:14:35

One more thing,

I am using the Robot model of Ogre, when I set the body and geom to be of the size as same as the bounding box of robot, the robot floats half way up in the geom. I did Body->setDebug(true), the size is same as the robot, but the robot floats half way up in the body. I have used Box Geometry.

rewb0rn

08-03-2008 11:44:38

1) you are working around the collision detection. using a physics sdk you should never try to change the positions of objects directly. Add Forces (better) to your body or set the velocity (worse). That way the collisions will work as expected.

2) Afaik its not possible to set an offset with a normal geometry. Try TransformGeometry (TG->setEncapsulatedObject(YourGeometry) I think).

sakshi2212

09-03-2008 01:36:09

The code I used for my robot mesh -
I even added the TransformGeometry part

mEntity = mSceneMgr->createEntity("robot", "robot.mesh");
mEntity->setQueryFlags(1<<2);
mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("robot");
mNode->attachObject(mEntity);
mEntity->setNormaliseNormals(true);
mEntity->setCastShadows(true);
Ogre::AxisAlignedBox box = mEntity->getBoundingBox();
Vector3 size(box.getSize());
mBody = new OgreOde::Body(mWorld);
mNode->attachObject(mBody);
OgreOde::BoxMass mMass(0.5, size);
mMass.setDensity(5.0, size);
mGeom = (OgreOde::Geometry *)new OgreOde::BoxGeometry(size, mWorld, mSpace);
mBody->setMass(mMass);
mGeom->setBody(mBody);
OgreOde::TransformGeometry *trans_geom = new OgreOde::TransformGeometry(mWorld, mSpace);
trans_geom->setEncapsulatedGeometry(mGeom);
trans_geom->setBody(mBody);
mEntity->setUserObject(mGeom);
mGeom->setDebug(true);
mBody->setOrientation(Quaternion(Radian(0.5), Vector3(0,0,0)));
mBody->setPosition(Vector3(0, 200, -20));



This is how it looks:

http://code.google.com/p/game-spring-2008-uic/wiki/ImageProblem?updated=ImageProblem&ts=1205026478

This does not happen if I use the ogreode crate mesh.

rewb0rn

10-03-2008 10:08:48

Guess you should call it like this:

trans_geom->setBody(mBody);
mEntity->setUserObject(trans_geom);

Then set the offset of the trans_geom by setting a position, I dont have it all in mind but check simplescenes for transformgeometry there should be an example somewhere.