Steps to make player walk on large terrain mesh?

Kosmos

08-08-2011 20:34:03

Hello
i have an terrain as large mesh.
so i loading it as normal mesh, attaching to node and etc.
what should i do to make another meshes (character, monsters, etc) walk on that large mesh? would be good to hear what functions should i use.

i already tried some things, but in the best case i got character falling on the surface, reaction of fall by rotating like box and next it fall through island surface -_-

here is video that can explain it: http://www.youtube.com/watch?v=2HOJsxOMLww

the code i using:
_SinbadEnt = _sceneManager->createEntity("Sinbad.mesh");
_SinbadNode = _sceneManager->getRootSceneNode()->createChildSceneNode();
_SinbadNode->attachObject(_SinbadEnt);
_SinbadNode->setPosition(150, 100, 50);

Ogre::ParticleSystem* partSystem = _sceneManager->createParticleSystem("Smoke", "MySmoke1");
_SinbadNode->attachObject(partSystem);

Ogre::Entity* island = _sceneManager->createEntity("isl2.mesh");
Ogre::SceneNode* isl_node = _sceneManager->getRootSceneNode()->createChildSceneNode();
isl_node->attachObject(island);
isl_node->setPosition(0, -100, 0);
isl_node->showBoundingBox(true);

OgreBulletCollisions::StaticMeshToShapeConverter* smtsc = new OgreBulletCollisions::StaticMeshToShapeConverter(island);
OgreBulletCollisions::TriangleMeshCollisionShape* trimesh = smtsc->createTrimesh();

OgreBulletDynamics::RigidBody *defaultPlaneBody = new OgreBulletDynamics::RigidBody("BasePlane", bm->GetBulletWorld());
defaultPlaneBody->setStaticShape(trimesh, 0.1, 0.8); // (shape, restitution, friction)

bm->IncreasemNumEntitiesInstanced();
bm->AddmShape(trimesh);
bm->AddmBody(defaultPlaneBody);

//for sinbad mesh
OgreBulletCollisions::AnimatedMeshToShapeConverter* amtsc = new OgreBulletCollisions::AnimatedMeshToShapeConverter(_SinbadEnt);
OgreBulletCollisions::CollisionShape* sinbad_shape = amtsc->createBox();

OgreBulletDynamics::RigidBody* sinbad_body = new OgreBulletDynamics::RigidBody("sinbad", bm->GetBulletWorld());
sinbad_body->setShape(_SinbadNode, sinbad_shape, 0.6f, 0.6f, 1.0f, _SinbadNode->getPosition(), _SinbadNode->getOrientation());

bm->IncreasemNumEntitiesInstanced();
bm->AddmShape(sinbad_shape);
bm->AddmBody(sinbad_body);

tried to change mass, friction, etc, nothing changes...
what i am doing wrong? could anyone list steps needed to make meshes walk on large mesh? or stay at large mesh at least...
there is a lot of examples about positioning char on heighmap based terrains, but i can't find anything about mesh based terrains

Caith

13-08-2011 09:31:15

It seems that graphics and physics are not in sync, as you set
isl_node->setPosition(0, -100, 0);
defaultPlaneBody->setStaticShape(trimesh, 0.1, 0.8);

You need to pass position to setStaticShape.