Orthographic View not working...

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
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Orthographic View not working...

Post by Thomas_ »

So, I found a thread: (http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2643) which in the end did have a solution for how to enter an orthographic mode, but I am having two problems. Here is the code i am using to enter the ortho view:

Code: Select all

    GetManager()->addCameraSceneNode(0, vector3df(0,0,100), vector3df(0,0,0));

    // Enter orthographic view
    matrix4 identity, orthoProjection;
    identity.makeIdentity();
    orthoProjection.buildProjectionMatrixOrthoLH(100.0f, 100.0f, 0.0f, 200.0f);
    GetDriver()->setTransform(ETS_PROJECTION, orthoProjection);
    GetDriver()->setTransform(ETS_VIEW, identity);
    GetDriver()->setTransform(ETS_WORLD, identity);

First off, I have tried both buildProjectionMatrixOrthoLH and RH and both have -100,-100 in the bottom right hand corner which is not what I expect and is cirtainly not optimal for the program im working on...

Secondly, and much more seriously, I am not really sure if it is ortho at all..., Billboards get bigger as their Z position gets larger toward 100... and the edges of the screen are not where they are supposed to be, the frame of (-50,-50)->(50,50) which should be the entire screen is only part of it...

Could someone tell me what is wrong?

Thanks!!

-Tom
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The problem is that you are explicitly setting the world, view and projection matrices and providing a camera. When a camera renders it sets the view and projection matrices, so when you call drawAll() on your scene manager those matrices you explicitly provided will be overridden. The matrices will be set from the camera that you added in the top line of your source code.

If you want to use a camera and set a projection matrix, you should use...

Code: Select all

// build your matrix
matrix4 orthoProjection;
orthoProjection.buildProjectionMatrixOrthoLH(100.f, 100.f, 0.f, 200.f);

// tell the camera to use your projection matrix
camera->setProjectionMatrix(orthoProjection);

// set flag in camera saying that this is an ortho projection
camera->setIsOrthogonal(true);

// if you care to tweak the view matrix, you need to do that like this...
camera->setPosition(...);
camera->setTarget(...);
The buildProjectionMatrixOrthoLH should have 1 in the bottom right corner [m.M[15]]. I don't know how you think you got -100, but it most definitely should not be. The buildProjectionMatrixOrthoRH should have a -1 in that same position.

Travis
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Many MANY thanks!

Its working. I only have one problem left right now, and i think my own code is to blame...

The orthographic view is working now! I am still not sure I get why the coordinates are where they are, but even if I cannot change the coordinates to be lowest in the upper left, i can manage...

What exactly IS the difference between ...OrthoLH() and ...OrthoRH()?
Thanks!
The buildProjectionMatrixOrthoLH should have 1 in the bottom right corner [m.M[15]]. I don't know how you think you got -100, but it most definitely should not be.
Hmm... I put in the values of (100, 100, 0, 200) for the ...OrthoLH method, does this not mean that my view will be a box 100 by 100 starting immidiatly at the camera and going 200 deep centered around 0,0?

Wouldn't that make the coordinates at the lower right (for whatever reason) 50,50?

-Tom
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I think I misunderstood your original post. I thought you were saying the bottom right entry in the matrix was -100. As it turns out, you were asking about the bottom-right corner of the view area. Not the same thing. Sorry for my misunderstanding.

If the camera is positioned at (0, 0, 100) and the view area has a height and width of 100 your view area will be from (50, 50) in the upper left corner to (-50, -50) in the lower right corner and (0, 0) in the center. At least I'm pretty sure that is what you should see...

Travis
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Alright,

Thanks a bunch!

-Tom
Post Reply