To test use the following code and play with the setNearValue and setFarValue settings:
Code: Select all
#include <irrlicht.h>
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main(int argc, char *argv[])
{
IrrlichtDevice * Device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640,480) );
//IrrlichtDevice * Device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<u32>(640,480) ); // that one is fine
if (!Device)
return false;
scene::ISceneManager* smgr = Device->getSceneManager();
gui::IGUIEnvironment* guiEnv = Device->getGUIEnvironment();
video::IVideoDriver* videoDriver = Device->getVideoDriver();
// looking straight at the cube
irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNode (0, core::vector3df(0, 0, 0),
core::vector3df(0, 0, 100),
-1);
cam->setNearValue(35.f);
cam->setFarValue(62.f); // far value is correct
// center 30 units away, cube from 20-40 units distance
irr::scene::ISceneNode * cube = smgr->addCubeSceneNode (20.0f, 0, -1,
core::vector3df(0, 0, 30),
core::vector3df(0, 0, 0),
core::vector3df(1.0f, 1.0f, 1.0f));
cube->setMaterialFlag(irr::video::EMF_LIGHTING, false);
cube->setMaterialFlag(irr::video::EMF_WIREFRAME, true);
cube->setMaterialFlag(irr::video::EMF_BACK_FACE_CULLING, false);
// center 30 units away, cube has only size 1
cube = smgr->addCubeSceneNode (1.0f, 0, -1,
core::vector3df(0, 0, 30),
core::vector3df(0, 0, 0),
core::vector3df(1.0f, 1.0f, 1.0f));
cube->setMaterialFlag(irr::video::EMF_LIGHTING, false);
cube->setMaterialFlag(irr::video::EMF_WIREFRAME, true);
cube->setMaterialFlag(irr::video::EMF_BACK_FACE_CULLING, false);
while ( Device->run() )
{
if ( Device->isWindowActive() )
{
videoDriver->beginScene(true, true);
smgr->drawAll();
guiEnv->drawAll();
videoDriver->endScene();
}
Device->sleep( 1 );
}
Device->closeDevice();
Device->drop();
return 0;
}