I saw some threads about stereo rendering/camera...
so I thought to do some experiments about this...
I thought about the principle of stereo cameras that also is used as the principle for vr-goggles...
so I created a split screen with 2 cameras (one for each eye)...
you'll have to squint on the screen until the 2 screens overlap...
or in other words: you have to look at the left screen with your right eye and at the right screen with your left eye...
if you do it right then you'll see 3 screens and the middle screen is in real 3d !!!
unfortunately you can't do this for a longer time because you'll get a headache then...
ok, no more words, here is the code:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main(){
IrrlichtDevice *device = createDevice(EDT_DIRECT3D9, dimension2d<u32>(800, 600), 16, true, false, false, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
// load the quake map
device->getFileSystem()->addZipFileArchive("media/map-20kdm2.pk3");
IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
ISceneNode* node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 128);
node->setPosition(core::vector3df(-1350,-90,-1400));
ITriangleSelector* selector = smgr->createOctreeTriangleSelector(mesh->getMesh(0), node, 128);
node->setTriangleSelector(selector);
selector->drop();
// load a faerie
IAnimatedMesh* faerie = smgr->getMesh("media/faerie.md2");
IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(faerie);
node2->setMaterialTexture(0, driver->getTexture("media/faerie2.bmp"));
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setPosition(vector3df(-70,0,-30));
node2->setMD2Animation(EMAT_SALUTE);
// setup and run Irrlicht render loop
ICameraSceneNode* camLeft = smgr->addCameraSceneNodeFPS();
ICameraSceneNode* camRight = smgr->addCameraSceneNode(camLeft);
// we set the right cam to the left because we need to squint
camRight->setPosition(vector3df(-5,0,0));
device->getCursorControl()->setVisible(false);
line3d<f32> line;
vector3df intersection;
triangle3df tri;
while(device->run()){
// get the focus point
line.start = camLeft->getPosition();
line.end = line.start + (camLeft->getTarget() - line.start).normalize() * 1000.0f;
if(smgr->getSceneCollisionManager()->getSceneNodeAndCollisionPointFromRay(line, intersection, tri, 0, 0)){
camRight->setTarget(intersection);
}
// begin scene
driver->setViewPort(rect<s32>(0,0,800,600));
driver->beginScene(true,true,SColor(0,100,100,100));
// draw right camera
smgr->setActiveCamera(camRight);
driver->setViewPort(rect<s32>(401,0,800,600));
smgr->drawAll();
// draw left camera
smgr->setActiveCamera(camLeft);
driver->setViewPort(rect<s32>(0,0,399,600));
smgr->drawAll();
// end scene
driver->endScene();
}
device->drop();
return 0;
}
just squint on it so your left eye looks at the right image and your right eye looks at the left image...
and don't get to close to the screen, if you're farther away it's easier and you can do it for a longer time...