(Irrlicht 1.4.2)
Here are without clipplane:
here is with clipplane (DX9)
and the same code, with OpenGL driver.
With the OpenGL driver, all the Objects are cut in the middle. Is this normal ?
the code:
Code: Select all
#include <iostream>
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
// librairies
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
// globals data
bool _bExit = false;
IVideoDriver* driver;
ISceneNode* node1;
ISceneNode* node2;
ISceneNode* node3;
// IEventReceiver, keyboard management
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
_bExit = true;
return true;
}
case KEY_KEY_S:
{
core::plane3df reflexion ( core::vector3df( 0 , 10 , 0 ) , core::vector3df ( 0 , 1 , 0 ) );
driver->setClipPlane( 1 , reflexion , false );
return true;
}
}
}
return false;
}
};
// main entry
int main()
{
static int oldTime;
MyEventReceiver _EventReceiver;
// let user select driver type
video::E_DRIVER_TYPE driverType;
printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");
char i;
std::cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_BURNINGSVIDEO; break;
case 'f': driverType = video::EDT_NULL; break;
default: return 0;
}
IrrlichtDevice *device = createDevice( driverType,
dimension2d<s32>(800, 600),
32,
false,
false,
true,
&_EventReceiver);
// video driver, SceneManager et GUI.
driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
ITimer *timer = device->getTimer();
// my nodes
node1 = smgr->addCubeSceneNode(15.0f);
node2 = smgr->addSphereSceneNode(7.0f);
node2->setPosition( vector3df(10,20,0));
node3 = smgr->addSphereSceneNode(7.0f);
node3->setPosition( vector3df(-10,10,0));
//textures and light=false
if (node1)
{ node1->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
node1->setMaterialFlag ( video::EMF_LIGHTING , false ); }
if (node2)
{ node2->setMaterialTexture( 0, driver->getTexture("../../media/fire.bmp") );
node2->setMaterialFlag ( video::EMF_LIGHTING , false ); }
if (node3)
{ node3->setMaterialTexture( 0, driver->getTexture("../../media/fire.bmp") );
node3->setMaterialFlag ( video::EMF_LIGHTING , false ); }
// FPS Camera.
SKeyMap keyMap[4] =
{
{EKA_MOVE_FORWARD, KEY_UP},
{EKA_MOVE_BACKWARD, KEY_DOWN},
{EKA_STRAFE_LEFT, KEY_LEFT},
{EKA_STRAFE_RIGHT, KEY_RIGHT},
};
smgr->addCameraSceneNodeFPS( NULL , 100.0f, 310.0f, -1, keyMap, 4);
smgr->getActiveCamera()->setPosition(core::vector3df(0,20,-30));
smgr->getActiveCamera()->setTarget(core::vector3df(0,5,0) );
// clipping creation
core::plane3df reflexion ( core::vector3df( 0 , 4 , 0 ) , core::vector3df ( 0 , 1 , 0 ) );
driver->setClipPlane( 1 , reflexion , false );
// main loop
int lastFPS = -1;
while(device->run() & !_bExit)
{
driver->beginScene(true, true, SColor(255,100,101,140));
driver->enableClipPlane ( 1 , true );
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Thank you in advance for your answers.