Jump to content
  • Advertisement
Sign in to follow this  
coordz

additional clip planes

This topic is 4171 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

I'd like to add an additional clip plane for debugging purposes. This is how I'm going things now:
//
// set up my camera as per usual here
//
// .......

//
// set up clipping plane
//
GLdouble eqn[4] = {0.0f, 0.0f, 1.0f, 0.0f};
glPushMatrix();
glTranslatef(objPos[0], objPos[1], objPos[2]);
glRotatef(objAngle[0], 1, 0, 0);
glRotatef(objAngle[1], 0, 1, 0);
glRotatef(objAngle[2], 0, 0, 1);
glClipPlane(GL_CLIP_PLANE0, eqn);
glPopMatrix();
glEnable(GL_CLIP_PLANE0);

// draw the scene
glPushMatrix();
glRotatef(myAngle, 1, 0, 0);
drawCube();
glPopMatrix();

// done with clipping plane
glDisable(GL_CLIP_PLANE0);

//
// draw the clipping plane so I can see where it is
//
glPushMatrix();
glTranslatef(objPos[0], objPos[1], objPos[2]);
glRotatef(objAngle[0], 1, 0, 0);
glRotatef(objAngle[1], 0, 1, 0);
glRotatef(objAngle[2], 0, 0, 1);
glColor4f( 0.0, 1.0, 0.0, 1.0);
glBegin(GL_LINE_LOOP);
  glVertex3f(1.0, -1.0, 0.0);
  glVertex3f(-1.0, -1.0, 0.0);			
  glVertex3f(-1.0, 1.0, 0.0);
  glVertex3f(1.0, 1.0, 0.0);		
glEnd();
glBegin(GL_LINES);
  glVertex3f(1.0, -1.0, 0.0);
  glVertex3f(-1.0, 1.0, 0.0);
  glVertex3f(-1.0, -1.0, 0.0);			
  glVertex3f(1.0, 1.0, 0.0);		
glEnd();
glPopMatrix();

For testing purposes drawScene() just draws a rotating cube. Glancing at my Red book I see that the clipping plane coeffs are multiplied by the inverse of the "current modelview matrix at the time glClipPlane() is called". So I reckon the clipping plane should stay still as my cube rotates and that the plane (okay, square) that I draw in green matches the position of the clipping plane. This doesn't seem to be the case. While fiddling around with objPos and objAngle changes the position of the clip plane, so does the rotation applied to the cube, i.e. the clip plane rotates with the cube. So what's wrong? Where do I put the call to glClipPlane() for the desired result? TIA

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!