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

## 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

1. 1
2. 2
Rutin
20
3. 3
4. 4
frob
15
5. 5

• 9
• 9
• 13
• 9
• 33
• ### Forum Statistics

• Total Topics
632592
• Total Posts
3007284

×