The problem is this: I've loaded my mesh and made a IAnimatedMeshSceneNode for it. I've made a triangle selector and collision response animator. However, whenever I try to move (WASD) it either acts as there's an invisible wall in one direction or falls through the floor and keeps going down indefinately in other directions.
Here's the relevant code snippet: (note that it's mainly taken from the "terrain" tutorial on the forum)
Code: Select all
//fps cam
scene::ICameraSceneNode* camera = 0;
//camera = smgr->addCameraSceneNodeFPS();
camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 10, false); //1st value= obligatory 0-2nd value= mouse sensitivity-3rd value handles cam speed
camera->setPosition(core::vector3df(0,300,0));
camera->setFarValue ( 50000.0f ) ; //sets the distance for the clipping plane, the bigger the farther
camera->setFOV(1.1f); // a value of 0.5 makes it look alienish
//camera->setRotation(core::vector3df(0,0,0)); //rotate the camera x,y,z degrees
//-----------------------------------------------------------------------------------------------//
// create sky box
scene::ISceneNode* skyboxNode = smgr->addSkyBoxSceneNode(
driver->getTexture("./data/stars.jpg"),
driver->getTexture("./data/stars.jpg"),
driver->getTexture("./data/stars.jpg"),
driver->getTexture("./data/stars.jpg"),
driver->getTexture("./data/stars.jpg"),
driver->getTexture("./data/stars.jpg"));
//-----------------------------------------------------------------------------------------------//
//add 3d terrain
scene::IAnimatedMesh* terrain = 0;
terrain = smgr->getMesh("./data/terrain.x");
//-----------------------------------------------------------------------------------------------//
//terrain node
scene::IAnimatedMeshSceneNode* terrainnode = 0;
terrainnode = smgr->addAnimatedMeshSceneNode(terrain);
//terrainnode = smgr->addAnimatedMeshSceneNode(terrain, camera, -1);//parents node to camera
scene::ITriangleSelector* selector = 0;
if (terrainnode)
{
selector = smgr->createOctTreeTriangleSelector(terrain->getMesh(0), terrainnode, 128);
terrainnode->setTriangleSelector(selector);
}
if (selector)
{
const core::aabbox3d<f32>& box = camera->getBoundingBox();
core::vector3df radius = box.MaxEdge - box.getCenter();
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, vector3df(30,50,30),
core::vector3df(0,-3,0),
core::vector3df(0,50,0));
selector->drop();
camera->addAnimator(anim);
anim->drop();
}
Starting the program:
and when you're falling (this is the bottom of the terrain you see):
Any help is appreciated!