Sign in to follow this  
John Stuart

glOrtho problem

Recommended Posts

John Stuart    100
I can view the object when I put the x and z eye position of gluLookAt() to 1-6 values with a glOrtho(-3.0, 3.0, -3.0, 3.0, 1.0, 6.0). But when I try to view it top/bottom view by changing the value of y eye position of gluLookAt()... nothing appears. Can anyone here help me out?

Share this post


Link to post
Share on other sites
Brother Bob    10344
Nothing appears most likely because it is outside the view volume.

Basically, gluLookAt defines a viewpoint and a viewpoint orientation. What is visible on the screen is, in your case, anything within +/-3 units left and right of, +/-3 units above and below, and 1 to 6 units in front of the viewpoint. Left/right/above/below/in front of are all defined relative the orientation of the viewpoint.

Your object is most likely not within these ranges relative the viewpoint and its orientation.

Share this post


Link to post
Share on other sites
John Stuart    100
I still don't get it why I can't view the line that I really think that should be visible.

What I understand is that:

I have a 3 lines representing x, y, and z axis with a length of 20 ( -10 to 10 )

I have the eye position set up in ( 0, 3, 0 ) looking at ( 0, 0, 0 ) with a near plane at ( 0, 2, 0 ) and far plane at ( 0, -3, 0 )

Now, the x and z should be visible because I only drew them in y=0. Please correct me. I know something is wrong because something is not right.

John Stuart

Share this post


Link to post
Share on other sites
Brother Bob    10344
What do you mean with the near and far planes? The near and far planes are set with the last two parameters to glOrtho; 1 and 6 in your case. Show exactly what values you pass to gluLookAt, and what coordinates you pass when drawing the lines, and if you have any additional transformations other than glOrtho and gluLookAt.

Share this post


Link to post
Share on other sites
John Stuart    100
What I mean about the near and far plane is the coordinates of the nearer and farther depth clipping planes. I hope you get what I mean.
glOrtho(-3.0, 3.0, -3.0, 3.0, 1.0, 6.0);
gluLookAt(0, 3, 0, 0, 0, 0, 0, 1, 0);

Share this post


Link to post
Share on other sites
Brother Bob    10344
No, I don't understand what you mean by the near and far planes. The planes are not coordinates, and they are specified in glOrtho which shows numbers that doesn't match what your "plane coordinates" say. But that is irrelevant to the problem anyway.

You're looking down the Y-axis, but the up-vector is also the Y-vector. The up vector, which is used to determine the orientation (the rotation along the view vector), must be anything but co-linear with the view direction. Try any up-vector in the XZ-plane, depending on how you want to orient your viewpoint.

Share this post


Link to post
Share on other sites
John Stuart    100
Woah. Now I got it working. I need to change the up-vector. lol

Maybe I'm wrong with the near and far plane. Or maybe I just use the wrong term for it.

Well....

Thank you very much for your help. :D
John Stuart

Share this post


Link to post
Share on other sites
Brother Bob    10344
Your terminology correct with respect to the diagram. I just now notices the connection between the values. The near plane it 1 unit in front of the camera, placing it at 2 units from the origin. You are correct, sorry, we were just talking about it with different references.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this