Page 1 of 1

how to set the camera as orthogonal

Posted: Fri Feb 13, 2009 4:34 am
by humorstar
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,

Posted: Fri Feb 13, 2009 5:17 am
by bumbleBee
Hi humorstar,

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
3. render your scene as usual

this should be what you want and hope it helps.

Posted: Fri Feb 13, 2009 8:31 am
by vitek
The easy way to setup the camera is to use buildProjectionMatrixOrthoRH() and then setProjectionMatrix().

Travis

Posted: Sat Feb 14, 2009 3:37 am
by humorstar
Thanks to both of 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);
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!

Posted: Sat Feb 14, 2009 8:07 pm
by Pyritie
humorstar wrote:Is the irrlicht system by default a left hand system?
AFAIK, it is.

Posted: Sun Feb 15, 2009 4:20 am
by humorstar
Pyritie wrote:
humorstar wrote:Is the irrlicht system by default a left hand system?
AFAIK, it is.
Is there no way to change?

Another related question: how to capture onsize or onResize event so that I can change the camera setting whenever the window viewport is changed?

Thank you,

Posted: Sun Feb 15, 2009 10:39 pm
by hybrid
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.