After using
smgr->addCameraSceneNode(0, vector3df(0,0,-15), vector3df(0,0,0));
to add the camera, how to change the camera setting to orthogonal, instead of perspective?
Thank you,
how to set the camera as orthogonal
Hi humorstar,
you can :
1. set your camera matrix (view matrix) to identity
2. setup a orthographic matrix as projection matrix, like this :
3. render your scene as usual
this should be what you want and hope it helps.
you can :
1. set your camera matrix (view matrix) to identity
2. setup a orthographic matrix as projection matrix, like this :
Code: Select all
(left-handed) :
------------------------------------------------
2/w 0 0 0
0 2/h 0 0
0 0 1/(zf-zn) 0
0 0 -zn/(zf-zn) 1
or (right-handed) :
------------------------------------------------
2/w 0 0 0
0 2/h 0 0
0 0 1/(zn-zf) 0
0 0 zn/(zn-zf) 1
this should be what you want and hope it helps.
The easy way to setup the camera is to use buildProjectionMatrixOrthoRH() and then setProjectionMatrix().
Travis
Travis
Thanks to both of you!
When I tried the following:
It works for the left hand coordinate system. But I want to have the right hand system. If I use buildProjectionMatrixOrthoRH() I don't see anything in the scene. Is the irrlicht system by default a left hand system? How do I change it to right hand?
Thank you!
When I tried the following:
Code: Select all
smgr->addCameraSceneNode(0, vector3df(0,0,-15), vector3df(0,0,0));
scene::ICameraSceneNode* Camera = smgr->getActiveCamera();
irr::core::CMatrix4<float> prjMat;
prjMat.buildProjectionMatrixOrthoLH(f32(STAGE_SIZE*2), f32(STAGE_SIZE*2*WINDOW_HEIGHT/WINDOW_WIDTH), 1, 3000);
Camera->setProjectionMatrix(prjMat, true);
Thank you!
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
If you do all your meshes on your own in the code (or you will use a mesh manipulation call after loading the mesh), it should be enough to change the projection and transformation matrices. But there's usually not much sense in changing the handedness, because you'll change some things anyway. When using Irrlicht, it's usually the right way to change your app to be left-handed, instead of making Irrlicht right-handed.