Stationary collidable objects

sakshi2212

25-03-2008 01:27:08

I am placing some stuff on my terrains which are to be static. I am only creating geometry (not body) for the object. But the character still passes through it. I debugged the geom, I can see the geom there. I dont how to stop the character from passing through it. For this collision I have implemented the OgreOde collision tutorial.

rewb0rn

25-03-2008 12:38:18

Have you added the player and the geoms to the same space? Maybe you dont add forces to your player but set the position directly? That would prevent collision. Also it could be that your forces are too high so the player is just pushed through the walls. You can try higher bouncyness and erp values, too.

sakshi2212

25-03-2008 16:45:39

I am not adding force. With the force its not moving and also doesnt stop even though I set force and torque to zero and have applied high angular and linear damping values. I am using setLinearVelocity.

rewb0rn

25-03-2008 18:04:39

I think that can lead to problems, too. If you use forces and the bodies wont stop, try much higher dampings. Did collision work with forces?

sakshi2212

26-03-2008 17:10:28

Well I am moving it using forces now. And it stops also using high damping values now. But even though I am lowering the force values, its still going through those unmovable goems.

rewb0rn

26-03-2008 17:42:12

Then its probably because you use different spaces for the character and the geoms. Please show how you use and create them.

sakshi2212

26-03-2008 19:49:41

My code is distributed in a lot of files since I am making a framework for my project. But I am using world->getDefaultSpace everywhere. Well I am gonna try creating a global space object and pass it around. If that doesnt work, then will post my code.

sakshi2212

26-03-2008 20:16:34

It didnt work.

My world objects are:

const Ogre::Real _time_step = 0.5;
const Ogre::Real time_scale = Ogre::Real(1.7);
const Ogre::Real max_frame_time = Ogre::Real(1.0/4);
mMyWorld = new MyWorld(mSceneMgr, mCamera, "Examples/Rockwall", 1);
mSpace = mMyWorld->mGetWorld()->getDefaultSpace();
mStepper = new OgreOde::StepHandler(mMyWorld->mGetWorld(), OgreOde::StepHandler::QuickStep,_time_step, max_frame_time,
time_scale);


The MyWorld is my own object, which creates the world according to params sent.

For adding physic objects to entities:
void Physics::mSetBoxGeometry(Ogre::Entity *entity, Ogre::SceneNode *node, OgreOde::World *world, OgreOde::Space *space, Ogre::Vector3 size,
Ogre::Real scale, Ogre::Real mass, Ogre::Real density)
{

mBody = new OgreOde::Body(world, "Body");
Ogre::Vector3 s(size *scale);
OgreOde::BoxMass mMass(mass, s);
mMass.setDensity(density, s);
node->setScale(Ogre::Vector3(scale, scale, scale));
mGeom = (OgreOde::Geometry*)new OgreOde::BoxGeometry(size, world, space);
mBody->setMass(mMass);
mGeom->setBody(mBody);
node->attachObject(mBody);
OgreOde::TransformGeometry *trans_geom = new OgreOde::TransformGeometry(world, space);
trans_geom->setBody(mBody);
trans_geom->setEncapsulatedGeometry(mGeom);
entity->setUserObject(mGeom);
mBody->setAffectedByGravity(true);

}


For adding physics to the character, sends scale, mass and density:

mHero->mSetBoxGeometry(mHero->mGetEntity(), mNode, mMyWorld->mGetWorld(), mSpace, size, 1, Ogre::Real(1.0), Ogre::Real(1.0));

For adding the volcano non movable objects:
void Volcano::mCreateVolcano(Ogre::SceneManager *mgr, Ogre::Vector3 pos, int i)
{
this->mCreateEntity(mgr->createEntity(this->mGetEntityName(), this->mGetMeshName()));
Ogre::SceneNode * node = mgr->getRootSceneNode()->createChildSceneNode(this->mGetEntityName() + "Node");
node->attachObject(this->mGetEntity());
node->setScale(Ogre::Vector3(1, 1, 1));
Ogre::AxisAlignedBox box = this->mGetEntity()->getBoundingBox();
Ogre::Vector3 size(box.getSize());
mGeom = (OgreOde::Geometry*)new OgreOde::BoxGeometry(size, mWorld, mSpace);
this->mGetEntity()->setUserObject(mGeom);
OgreOde::TransformGeometry *trans_geom = new OgreOde::TransformGeometry(mWorld, mSpace);
trans_geom->setEncapsulatedGeometry(mGeom);
mGeom->setUserObject(static_cast<CollisionTestedObject*>(this));
Ogre::Vector3 distance(pos.x, pos.y, pos.z);
node->setPosition(distance);
mGeom->setDebug(true);


The mSpace is the object in the first code block. I debugged the space object also, its geom list contains all the volcano and character geoms, the body list contains only the charcter body. Am I missing something. I think using getDefaultSpace() would give the same world space right?

rewb0rn

27-03-2008 12:28:03

Have you called setInternalCollisions(false) on the space accidentally? Try setInternalCollisions(true)

sakshi2212

27-03-2008 20:57:52

It did not work. But I found something weird, it collides with something after going in to the geom. I can see being pushed back. But I am debugging the geom, I can see it around my volcano object. But still doesnt collide at the right place.
:cry:

Thanks a lot for the help. If you have any other ideas please let me know. I am working with game physics for the first time.

rewb0rn

27-03-2008 22:52:15

Are you debugging the transform geos or the geos? Because the transform would be the right one.

sakshi2212

27-03-2008 22:56:48

Then normal one. But now I was using the EntitiInformer::createSingleStaticBox function. I removed the trans geom part. Let me try again with that.