weird zoom-in behavior

This topic is 3715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

My world has a coordinate system that represents the earth using the ECF (earth-centered/fixed) coordinate system. I can pan around my earth, and zoom in/out of my earth. I pan by calling gluLookAt(x, y, z, 0, 0, 0, 0, 0, 1), where x, y, z is the center point of my canvas in ECF coordinates. The user uses the arrow keys to pan, each of which change the center point by some small amount in a certain direction. I zoom by calling glOrtho(l, r, b, t, n, f), where l, r, b, and t are a function of my current zoom level, and n/f (z-ratio) is consistently between .001 and .002. As my zoom level changes, as does l, r, b, and t. That is, when I zoom in, the 4 variables get smaller, and vice-versa for zooming out. To test something, I am drawing a small square at the center of the screen. I call gluUnproject to convert the center-screen coordinates to world coordinates, and then make glVertex calls to draw the square. This works fine when I am zoomed out. However, when I zoom in very close, my square starts to get drawn inaccurately. It will be a quadrilateral, but certainly not a square. Again, when I am zoomed out, no problem, the square it drawn correctly. I noticed that if I am panned to a point that is parallel to a plane (xz, yz, etc) in ECF space, the square is drawn correctly at all zoom levels. For example, when I am panned to the equivalent of 0 degrees latitude, 0 degrees longitude, where the square is parallel to the YZ-plane, there is no problem. Same with 0 degrees latitude, 90 degrees longitude (parallel to XZ-plane). But if I draw the square at 0 degrees latitude, 45 degrees latitude, is it drawn wonky. Does this make sense to anyone? Why would I only see the problem in certain cases but not others? I have tried switching to using gluPerspective instead (just to test), and I see the same issues. I have tried all sorts of z-ratios, to no avail. If I can provide any other useful information, let me know.

Share on other sites
Maybe this will help people...

This is my code for setting the perspective.

-mViewingAlt is changed every time the user zooms in or out.
-mCenterLat and mCenterLon are changed every time the user pans.
-geodeticToXyz is just assuming a spherical earth.

Again, the issue is that any time I am zoomed way in, and not aligned with an axis, my rendering gets all screwed up.

void setPerspective()  {    double near_plane = 0.1;    double far_plane = 63781377*1.1;    glMatrixMode(GL_PROJECTION);    glLoadIdentity();    glOrtho(-mViewingAlt, mViewingAlt, -mViewingAlt, mViewingAlt,             near_plane, far_plane);    double x, y, z;    geodeticToXyz(mCenterLat, mCenterLon, mViewingAlt, x, y, z);    gluLookAt(x, y, z, 0, 0, 0, 0, 0, 1);        glMatrixMode(GL_MODELVIEW);    Refresh(true);  }

This is my init. code:

  void InitGL()  {    glClearColor(0.0, 0.0, 0.0, 0.0);     glClearDepth(1.0f);    glDepthFunc(GL_ALWAYS);     glEnable(GL_DEPTH_TEST);    int w, h;    GetClientSize(&w, &h);    glViewport(0, 0, w, h);    setPerspective();  }

Share on other sites
I think you're on the right track with suspecting the problem is with perspective. It sounds like your X-Y ratio might be off, which would cause polygons to skew a bit when you change your orientation to them. Beyond that, I'm at a loss. I generally try to stay away from glu functions...

Share on other sites
What can I do to check my XY ratio? What defines my XY ratio? Is it something I have control over, or is OpenGL handling it?

FYI, I tried putting in translate/rotate calls that were equivalent to gluLookAt, and I still had the issue.

Share on other sites
this looks like it could be a problem

double near_plane = 0.1;
double far_plane = 63781377*1.1;

see here
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

if thats not the answer post a screenshot of the problem

Share on other sites
I've tried many z-buffer ratios, and none of them fixed the problem.
The closer I zoom into my earth, the closer my camera gets to zNear. I don't think there is anything I can do to prevent this, unless I want to switch to using glScale to simulate zooming.

Here is an overview of my earth:

Here is the camera zoomed way in on latitude 0, longitude 0. Notice that it looks fine.

Here is the camera zoomed way in on somewhere in the southern hemisphere. Notice that it is distorted. There is no pattern to the distortion; as I zoom in further at this point, the "square" continuously changes shape.

Share on other sites
I think I found a clue:

This is similar to what is happening to me.

I'm going to print it out and read it tomorrow. If I find the solution I will post it here.

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 16
• 10
• 14
• 10
• Forum Statistics

• Total Topics
632659
• Total Posts
3007692
• Who's Online (See full list)

There are no registered users currently online

×