I've been running through the tutorials, and am now trying to create a heightmap with a quake3 map (a castle) situated in the middle. The problem is getting the camera to properly collide with both the terrain and the map at the same time.
Having no idea how to manage it, I've been fiddling myself and trying to work it out through experimentation, and, well here's the relevent code (or at least what I think is relevent).
Code: Select all
//Create two selectors
scene::ITriangleSelector* selector = 0;
scene::ITriangleSelector* selector2 = 0;
Code: Select all
//Set up first selector (well, selector2)
selector2 = smgr->createOctTreeTriangleSelector(
q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector2);
selector2->drop();
Code: Select all
//Set up camera
scene::ICameraSceneNode* camera =
camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
camera->setFarValue(12000.0f);
Code: Select all
//Create terrain
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"media/terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40, 4.4f, 40));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture(
"media/terrain-texture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture(
"media/detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(1.0f, 20.0f);
Code: Select all
//Create second selector (for terrain)
selector =
smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
Code: Select all
//create two animators and attatch them to the camera
scene::ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-0.5,0),
core::vector3df(0,50,0));
scene::ISceneNodeAnimator* anim2 = smgr->createCollisionResponseAnimator(
selector2, camera, core::vector3df(30,50,30),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
camera->addAnimator(anim2);
anim->drop();
Now the method I've used there seems to allow me to walk on the terrain and inside the quake map, but for some reason I can't walk over even really small ledges in the quake map, even though when I created a quake map by itself before, I was able to walk up steps perfectly without a problem.
If anyone knows whats wrong here, or whether I'm using the correct method to handle this, please help me,
thanks alot