terrain level of detail changing using 3rdperson cam[SOLVED]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ice
Posts: 6
Joined: Mon Sep 18, 2006 3:43 pm

terrain level of detail changing using 3rdperson cam[SOLVED]

Post by ice »

hi,
I've added an object and a camera attached to it (a 3rd person camera) to the terrain demo, and I've set simple movement controls.

the problem is that when I'm using the simple camera attached to the object, the terrain changes to a very angulous detail (all the elevations turn into piramid shape).

however when use the fps camera in free mode (without attaching it to the object), with the exact same terrain settings, the terrain looks smooth just like it was supposted to be (like in the terrain demo).

does anyone knows what's happening and how can I fix this?

thanks,
ice

here's my code (jirr - java):
__________________________

Code: Select all

// terrain scene node
ITerrainSceneNode terrain = smgr.addTerrainSceneNode("../media/terrain.bmp");
terrain.setScale(new vector3df(40, 3, 40));
terrain.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
terrain.setMaterialTexture(0, driver.getTexture("../media/terrain_texture.jpg"));
terrain.setMaterialTexture(1, driver.getTexture("../media/detailmap3.jpg"));
terrain.setMaterialType(E_MATERIAL_TYPE.EMT_DETAIL_MAP);
terrain.scaleTexture(1.0f, 20.0f);

// object creation
IAnimatedMesh mesh = smgr.getMesh("../media/barrel01.3ds");
IAnimatedMeshSceneNode object = smgr.addAnimatedMeshSceneNode(mesh);
object.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
object.setPosition(new vector3df(1000, 150, 2500));
object.setScale(new vector3df(1, 0.1f, 0.7f));

// attach a camera to the object
ICameraSceneNode camera = smgr.addCameraSceneNode();
camera.setPosition(new vector3df(0, 350, -150));
camera.setTarget(object.getPosition());
camera.setFarValue(12000.0f);

object.addChild(camera);

Last edited by ice on Thu Sep 21, 2006 3:52 pm, edited 1 time in total.
ice
Posts: 6
Joined: Mon Sep 18, 2006 3:43 pm

Post by ice »

I've solved the problem by not attaching the camera to the object, but by moving it to the position of a dummy node attached (in a relative position) to it.

Anyway, it seams that when I attach the camera to the object (using the function addChild, or assing a parent in the creation function) the detail of the terrain changes dramatically. Just as if the "far distance" of the camera is the distance to the object in front and so, everything else get's a high decrease in the detail.

Does anybody know why?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

hmm this is an old bug to do with the terrain node using getPosition instead of getAbsolutePosition. look in CTerrainSceneNode.cpp and change the line that contains "line.start" to:

Code: Select all

line.start = SceneManager->getActiveCamera()->getAbsolutePosition();
and recompile :)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply