Sign in to follow this  

Clipping issue with a display list

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all. I've been having some weird issues with my code, and I can't figure out what exactly is happening. My goal is to call a previously created display list and have it appear in a location that is advantageous to the viewer. What I'm currently trying:
  glLoadIdentity();
  glScalef( 1.0f, 1.0f, -1.0f );

  // Make the object upright
  glRotatef(180,1,0,0);  
  glRotatef(90,0,1,0);

  // Move the object so the "camera" can see it
  glTranslatef(XDistance, YDistance, ZDistance );

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glCallList( ListId );  
  glFinish();
Basically, I have some code that will vary XDistance, YDistance and ZDistance based on user input, which will then move the "view" of the object drawn. If I vary YDistance, the object will move up or down in the plane of view, and if I vary ZDistance, the object will move right or left in the plane of view. However, if I vary XDistance, the object does not appear to move forward or backward (the only remaining axis), but instead seems to move the visible display box forward and back (more clarification: Say I start with x = 0. The apple tree I'm rendering appears in its entirety. If I move x = 1, the apples in the rear of the tree [along with the rest of the rear of the tree, the apples are just the easiest to identify] are not rendered. If I move x = -1, the rear apples are rendered while the close ones aren't. ). I've tried adding calls to glFrustum and glProspective, with no success (glFrustum has no visible effect and glProspective prevents all rendering). So I guess I have a couple of questions. One, why is my stuff getting "clipped" when I vary translation in my XDirection. And two, why does translating in XDirection have such a different effect than translating in either YDirection or ZDirection. Thanks much for your time and help, Ryan

Share this post


Link to post
Share on other sites
it seems a messy way of doing it (Scaling has adverse effects as well sometimes, eg polygon winding order, lighting brightness etc)

something like the following is easier to understand/cleaner

gluLookAt( obj.x+eyeoffsetX, obj.y+eyeoffsety, obj.z+eyeoffsetZ, obj.x, obj.y, obj.z, 0,1,0 );
glCallList( ListId );

Share this post


Link to post
Share on other sites
Quote:
Original post by zedz
it seems a messy way of doing it (Scaling has adverse effects as well sometimes, eg polygon winding order, lighting brightness etc)

something like the following is easier to understand/cleaner

gluLookAt( obj.x+eyeoffsetX, obj.y+eyeoffsety, obj.z+eyeoffsetZ, obj.x, obj.y, obj.z, 0,1,0 );
glCallList( ListId );


Thanks, gluLookAt does work. I'm still confused as to what was causing my problems the other way though, although as long as I have something working I guess I'm alright.

Thanks again,

Ryan

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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