Orthographic View
Orthographic View
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.
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.
It's all a matter of perspective. In the case of orthographic, it's all a matter of no perspective.
In buildProjectionMatrixOrthoLH, you set the width, height, and Z.
It may be easier to think of ortho and perspective like this.
Perspective
Ortho
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.
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);
It may be easier to think of ortho and perspective like this.
Perspective
Code: Select all
Field of View
\ /
\ /
\ /
Camera
Code: Select all
Field of View
| |
| |
| |
Camera
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?
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?
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?
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
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
-
- Posts: 34
- Joined: Thu Aug 17, 2006 10:32 pm
I am having the same problem
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
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.
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.
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.
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 .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.
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);