Orthographic View

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Orthographic View

Post by joy »

Hi everybody, I need your help!!!!

I still try to make a GUI with Irrlicht (thats hard work, because just idiots like me come up with this idea).
I set up an viewport and a camera with the position 0,0,-10 facing to 0,0,0. When I insert object and set their positon , the object is distorted to the middle of the viewport. That's fine, but it is not what I need. I need the orthographic view, so that no object gets distorted at all:

-----------------------Viewport
._
|_|object one, I can just see the front



._
|_|(2nd ob. just front).......|_|(3rd object, just see the front)

--------------------------
That it what I want it to look like. Do you get an idea?
It seems that saigumi was trying the same thing and set up an tutorial:
http://irrlicht.sourceforge.net/phpBB2/ ... thographic
But I am not sure that he is trying to do the same thing as me, because the tutorial doesn't help me at all. to get the orthographic view, I think saigumi uses buildProjectionMatrixOrthoLH() but why not the right handed? and what exactly do the terms widthOfViewVolume, heightOfViewVolume, zNear, zFar mean to me (what do I have to set there?)

Please help me to set the orthographic view.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I am not experienced in this at all but I think that left or right handed is for DirectX or OpenGL which use diferent coordinate sistems.

OpenGL uses right-handed coordinates; DirectX uses left-handed
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

It's all a matter of perspective. In the case of orthographic, it's all a matter of no perspective.

Code: Select all

	//!Add the camera and set the Orthogonal Matrix
	irr::core::matrix4 MyMatrix;
	MyMatrix.buildProjectionMatrixOrthoLH(16.0f,12.0f,1.5f,-32.5f);
	camera = smgr->addCameraSceneNode(Center,irr::core::vector3df(-14.0f,14.0f,-14.0f),irr::core::vector3df(0,0,0));
	camera->setProjectionMatrix(MyMatrix);
In buildProjectionMatrixOrthoLH, you set the width, height, and Z.

It may be easier to think of ortho and perspective like this.

Perspective

Code: Select all

Field of View
\     /
 \   /
  \ /
Camera
Ortho

Code: Select all

Field of View
|     |
|     |
|     |
Camera
The width is the width of the area you want to see, height is the same. You basically looking down a big box instead of a cone. If you want to get the same effect, grab a cardboard box and stick your head in it.

The Z is the near and far area you want to see. So, in essence, these 4 numbers generate the framework of a cube.

The Z would be the distance from the lid of the box to the back. The witdth and height would be the dimensions of the opening of the box.
Crud, how do I do this again?
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

We ARE talking about the same thing. :)
Well, I am using right now the Software-Renderer because I still have some difficulties with OpenGL and Direct X so I would have to fix them first. But I think that orthographic view should work with the software renderer too. Am I right??

Your explaination was good saigumi, but I still can't see any object. When I load the object (I always set the objects to the 0,0,0 in the beginning) in the "normal" view, I could see the object. Now when I use either the left or right handed function no object appears even though it is correctly loaded.

I set the my viewport (640X480) not exactly in the middle of my screen. 640x480 is about 29.0f of with and 21.0f of height. And I set my camera to 0,0, -10 . I tried to use your explaination to set my values for the function buildProjectionMatrixOrthoLH right. I got this:

MyMatrix.buildProjectionMatrixOrthoRH(29.0f,21.0f,-9.5f,9.5f);

I don't understand, why I am not seeing my objects anymore. When I use the Right handed one I can at least pick the object even though I can't see it.

Any help?
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

I played around with the values for the functions a lot just to see if I get this view. But no matter what the objects seem to be vanished. I even tried to scale my objects (they are definitly loaded) but still I cannot see them.
I am a little frustrated because this view is extremely important for me. I would be glad if anyone has an idea and suggestion.

Thanks
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

I really got stuck on this. I mean Saigumi says his one works, so I have no explaination. May be because I am using a viewport?
Please help!!
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

I mean: a smaller viewport
yellowfever13
Posts: 34
Joined: Thu Aug 17, 2006 10:32 pm

I am having the same problem

Post by yellowfever13 »

was this ever solved? I am having the exact same problem. I am setting up my ortho matrix, but when I apply it, I see nothing. my height, width, near, far are well within encompassing my geometry. I zoom pan around and I cannot find it! I set the target right where my geometry is...so not sure what is going on.
Fashizzle
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I think this is because some of the matrix functions are wrong. Have a look at the definition of buildProjectionMatrixOrthoLH and compare that to the matrix provided by msdn here. There are others.

I found that after fixing the matrix build functions I needed to fix the camera in a few places, but everything seemed to come out okay. I'm not at home right now so I can't post the diffs. I'll try to remember when I get home tonight.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I have adapted all 6 matrices from the MSDN versions in one of the latest SVN revisions. If there are more changes necessary I'd like to hear about, all examples are running ok.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Anyone have a working ortho camera? I can't get poop to work with the ortho projections. Does irrEdit use ortho Projection?

This orthographic stuff is like magic to me, I've no clue what values are doing what when building the matrix. Well I have a clue, but what I think should be good values results it complete garbage.
Image
mandrav
Posts: 117
Joined: Sat Aug 27, 2005 8:29 pm
Contact:

Post by mandrav »

Spintz wrote:Anyone have a working ortho camera? I can't get ***** to work with the ortho projections. Does irrEdit use ortho Projection?

This orthographic stuff is like magic to me, I've no clue what values are doing what when building the matrix. Well I have a clue, but what I think should be good values results it complete garbage.
I don't know if it's of any use to you but I don't use a camera to change the projection. That's because I only need to change it to draw some screen aligned quads manually :).

Anyway, here goes:

Code: Select all

// keep backup of the current matrices (if you care)
m_ProjectionBackup = driver->getTransform(irr::video::ETS_PROJECTION);
m_ViewBackup = driver->getTransform(irr::video::ETS_VIEW);
m_WorldBackup = driver->getTransform(irr::video::ETS_WORLD);

irr::core::matrix4 identity;
identity.makeIdentity();

// build the orthographic projection matrix
// play with the values here to change the coordinate system
// the values I use below, set a coordinate system from (-0.5,-0.5) to (0.5,0.5). This means that the center of the screen is at (0,0)
irr::core::matrix4 orthoProjection;
orthoProjection.buildProjectionMatrixOrthoLH(1.0f, 1.0f, 0.0f, 1.0f);

// update the matrices in the driver
driver->setTransform(irr::video::ETS_PROJECTION, orthoProjection);
driver->setTransform(irr::video::ETS_VIEW, identity);
driver->setTransform(irr::video::ETS_WORLD, identity);

// here, render whatever you want in orthographic projection
//...

// finally, restore the previous matrices
driver->setTransform(irr::video::ETS_PROJECTION, m_ProjectionBackup);
driver->setTransform(irr::video::ETS_VIEW, m_ViewBackup);
driver->setTransform(irr::video::ETS_WORLD, m_WorldBackup);
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Thanks, I get it now.
Image
Post Reply