Adding a SimpleSpace to another SimpleSpace

simdevode

23-09-2006 01:09:19

Hi, I'm trying to create a SimpleSpace container -- basically have chunks of geoms in each space, and then trying to capture collisions between the spaces.

I tried SimpleSpace->AddGeometry but then it eventually fails at assert in the dAddSpace method where its checking for the geom's ID.

Any ideas?

Apurva

tuan kuranes

23-09-2006 12:57:27

Be sure to check Ode mailing list for ODE related question (Real Odea and Physic simulation experts are overthere...)

Can you be more specific what assert ?
Did you make sure that each geom belongs to one and only one space ?

simdevode

24-09-2006 00:17:39

In the ODE documentation, I read that you could use space also as a collection of spaces. I was trying to do it, but ODE's dSpaceAdd method only takes a dGeomId, and not a space. As the code follows below, I have a player in one space with internal collisions disabled, and office furniture in another space again with internal collision disabled. I thought we could add the two spaces to a third space, and call dSpaceCollide when the two space collide amongst themselves. Keeping the player in the same space as the furniture will require internal collision to be set true. And there's just so much furniture that collision between the furniture pieces kills the performance.



// Setting the collision listener
gameWorld->setCollisionListener(this);

// Adding a character in space playerSpace
OgreOde::SimpleSpace *playerSpace = new OgreOde::SimpleSpace();
playerSpace->setInternalCollisions(false);

// Creating node for the player, lights and camera
modelNode = mSceneMgr->getRootSceneNode ()->createChildSceneNode (playerName + "_node");
mSightNode = modelNode->createChildSceneNode (playerName + "_sight", Vector3 (0, 0, 100));
mCameraNode = modelNode->createChildSceneNode (playerName + "_camera", Vector3 (0, 50, -100));

// Adding the mesh
playerEntity = mSceneMgr->createEntity("playerName" + "_entity", "player.mesh");
modelNode->attachObject(playerEntity);

// Giving physical properties to the character mesh
OgreOde::Body playerBody = new OgreOde::Body("Player");
playerBody->setMass(OgreOde::CapsuleMass(70.01*2.5,radius,Vector3::UNIT_Y,radius));
OgreOde::CapsuleGeometry* playerGeom = new OgreOde::CapsuleGeometry(radius+1, size.y*radius, 0);
OgreOde::TransformGeometry* playerTrans = new OgreOde::TransformGeometry(playerSpace);
playerNode->translate(Vector3(100, -25, 0));
playerTrans->setBody(playerBody);
playerTrans->setEncapsulatedGeometry(playerGeom);
playerNode->attachObject(playerBody);





//Loading furnitire in officeSpace
OgreOde::SimpleSpace *officeSpace = new OgreOde::SimpleSpace();
officeSpace->setInternalCollisions(false);

// Make static boxes (loop stuff snipped in the post, just the essentials)
OgreOde::EntityInformer ei(pEntity, Matrix4::getScale(pObjNode->getScale()));

// Collision geometry
//OgreOde::Geometry *aGeom = ei.createStaticTriangleMesh(officeSpace);
aGeom->setUserObject((void *)pszName);



Now I was basically trying to capture collisions between the two spaces. How do I go about this? Using the code as posted above, I am not getting any collisions at all. Also, I don't want my character to walk through the furnitire or fall through the floor. So do I need to add mass to each static object as well? How would I do that?

Thanks for you help!