The problem is that I (the camera) can't jump/climb up on the cubes. If I build a nice flat area of cubes and try jumping up on it the gravity just keeps trying to pull me down through the cubes and I (the camera) starts to slide towards the end of the flat area of cubes down on the terrain again. Also I can't jump while being on these cubes. I would like these cubes to interact with the camera's gravity and collision just like the terrain does.
I used to create the camera with the terrain's selector, and I thought that was the reason for it not working. So I checked the demo example and saw that they used metaSelector, so I tried that, but without luck.
Relevant code:
Adding camera and creating metaSelector:
Code: Select all
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.0f, .4f, -1, 0, 0, false, 3.f);
camera->setPosition(core::vector3df(500,100,500));
camera->setTarget(core::vector3df(100,30,100));
ITriangleSelector* cameraSelector = 0;
ISceneNodeAnimator* cameraAnim = 0;
// Create meta selector
IMetaTriangleSelector* metaSelector;
metaSelector = smgr->createMetaTriangleSelector();
if (cameraSelector)
{
ISceneNodeAnimatorCollisionResponse* cameraAnim = smgr->createCollisionResponseAnimator(metaSelector, camera, vector3df(25,50,25), vector3df(0,-10,0), vector3df(0,45,0), 0.005f);
//ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(metaSelector, camera, vector3df(25,50,25), vector3df(0,-10,0), vector3df(0,45,0), 0.005f);
// I used this one before trying metaSelector.
cameraSelector->drop(); // As soon as we're done with the selector, drop it.
camera->addAnimator(cameraAnim);
cameraAnim->drop(); // And likewise, drop the animator when we're done referring to it.
}
Code: Select all
ITerrainSceneNode* terrainNode = smgr->addTerrainSceneNode("media/terrain-heightmap.bmp");
terrainNode->setScale(vector3df(80, 8.8f, 80));
terrainNode->setMaterialFlag(EMF_LIGHTING, false);
terrainNode->setMaterialTexture(0, driver->getTexture("media/terrain-texture3.jpg"));
terrainNode->setMaterialType(EMT_DETAIL_MAP);
terrainNode->scaleTexture(40.0f, 20.0f);
// create triangle selector for the terrain
ITriangleSelector* terrainSelector = smgr->createTerrainTriangleSelector(terrainNode, 0);
terrainNode->setTriangleSelector(terrainSelector);
// create triangle for camera aka collision controll
if (terrainSelector)
{
ISceneNodeAnimator* terrainAnim = smgr->createCollisionResponseAnimator(
terrainSelector, camera, vector3df(30,50,30),
vector3df(0,-10,0),
vector3df(0,10,0));
camera->addAnimator(terrainAnim);
terrainAnim->drop();
}
metaSelector->addTriangleSelector(terrainSelector);
Code: Select all
metaSelector->addTriangleSelector(objectSelector[objectId]);
Incase you don't understand what my problem is / if u wanna try it
Thanks in advance!