Collision problem

one_eddie

08-06-2007 18:13:57

i'v setup OgreNewt an ran it.

I'v got 2 simple meshes.


I set collisions by:

mRobotEntity = mSceneMgr->createEntity("MovingRobot", "robot.mesh");
mRobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mRobotNode->attachObject(mRobotEntity);

OgreNewt::Collision* robotCollision =
new OgreNewt::CollisionPrimitives::Box(mWorld, mRobotEntity->getBoundingBox().getMaximum());
mRobotBody = new OgreNewt::Body( mWorld, robotCollision );
delete robotCollision;

mRobotBody->setMassMatrix( 10.0, OgreNewt::MomentOfInertia::CalcBoxSolid( 10.0, mRobotEntity->getBoundingBox().getMaximum() ) );
mRobotBody->attachToNode( mRobotNode );


and

Entity* entLabirynth = mSceneMgr->createEntity("Labirynth01", "labirynth.mesh");

mLabirynthNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mLabirynthNode->attachObject(entLabirynth);
mLabirynthNode->setVisible(false);
mLabirynthNode->scale(1.0f, 0.5f, 1.0f);

OgreNewt::Collision* labCollision = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld, mLabirynthNode, false);
OgreNewt::Body* body = new OgreNewt::Body( mWorld, labCollision );
delete labCollision;

body->attachToNode( mLabirynthNode );


But this doesn't work. Robot is stuck in this corrner (he can't move). When I disable colision creation its ok (but he can walk trought walls).



Please give me any advice. Where's the mistake?

walaber

08-06-2007 18:15:42

how are you moving the robot?

one_eddie

08-06-2007 18:33:20

how are you moving the robot?

Ommiting less important i move it like this:

mRobotNode->translate(mRobotNode->getOrientation() * Vector3(90 * evt.timeSinceLastFrame, 0, 0));

walaber

08-06-2007 19:04:15

if you want to use OgreNewt for collision, you have to move the object through physics calculations. please search this forum for "character control" and other similar words for various solutions.

one_eddie

08-06-2007 20:47:03

I'v got it. My character is moving and the bounding|collision rect too. But i can still walk trought walls?

Did I miss something?