how to set the camera as orthogonal

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
humorstar
Posts: 25
Joined: Sat Oct 04, 2008 3:50 am

how to set the camera as orthogonal

Post 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,
bumbleBee
Posts: 4
Joined: Wed Feb 11, 2009 6:30 am

Post 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.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The easy way to setup the camera is to use buildProjectionMatrixOrthoRH() and then setProjectionMatrix().

Travis
humorstar
Posts: 25
Joined: Sat Oct 04, 2008 3:50 am

Post 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!
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

humorstar wrote:Is the irrlicht system by default a left hand system?
AFAIK, it is.
Hive Workshop | deviantART

I've moved to Ogre.
humorstar
Posts: 25
Joined: Sat Oct 04, 2008 3:50 am

Post 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,
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Post Reply