Page 1 of 1

Orthographic view

Posted: Mon Dec 20, 2021 1:52 pm
by beamlight
Hi I am currently working on a world hardest game clone in irrlicht. I want to implement a Orthographic view camera, but I donĀ“t know how to achieve it. Currently I have a perspective camera but want my meshes to be facing the camera. Do someone have a example or how I can set up Orthrographic view?

Re: Orthographic view

Posted: Mon Dec 20, 2021 5:45 pm
by CuteAlien
You set your own projection matrix to the camera. But Irrlicht can create it for you.
Something like:

Code: Select all

// Assuming you have already set position and target for camera
irr::core::matrix4 orthoMat;
orthoMat.buildProjectionMatrixOrthoLH(  width,
										height,
										ORTHO_CAM_ZNEAR,
										ORTHO_CAM_ZFAR,
										D3DStyle
										);

camera->setProjectionMatrix(orthoMat, true);
So first set position and target for camera. Then set how many units you want to see there (width/height/near/far).
The D3DStyle is only availabe in svn trunk (in Irrlicht 1.8 it's always true I think). So in trunk simply set it to true when you use Direct3D and false when you work with OpenGL (otherwise you get a tiny error in znear - most people won't even notice I suppose).