I want to clip a 3D model from head to toe after every 20 mm, start the clipping from head on the z-axis, i have 5 clipping planes right now, when i press 1 the portion above the head part gets clipped off, pressing 2 clips the portion above neck, pressing 3 clips the body portion above chest. The distance between these clipping planes is large right now, the distance should be 20 mm. Creating a huge number of clipping planes in this way is that really possible? i was wondering if i create only one clipping plane and then by pressing the down arrow key translate that clipping plane with a distance of 0.02 m on negative z-axis and pressing the up arrow key moves the clipping plane on positive z-axis. Is that really possible? If yes how to do that , i would be really thank full for all the help.
Here is my code for clipping planes
// toggle each of clipping planes
GLboolean g_clip1 = GL_FALSE;
GLboolean g_clip2 = GL_FALSE;
GLboolean g_clip3 = GL_FALSE;
GLboolean g_clip4 = GL_FALSE;
GLboolean g_clip5 = GL_FALSE;
// clipping planes
GLdouble eqn1[4] = { 0.0, 0.0, -1.0, 0.0 }; //head clip
GLdouble eqn2[4] = { 0.0, 0.0, -1.0, 0.0 }; //face clip
GLdouble eqn3[4] = { 0.0, 0.0, -1.0, 0.0 };// chest clip
GLdouble eqn4[4] = { 0.0, 0.0, -1.0, 0.0 };// abdomen clip
GLdouble eqn5[4] = { 0.0, 0.0, -1.0, 0.0 };// legs clip
// translation for the clipping planes
GLfloat g_clip_1 = 0.47f;
GLfloat g_clip_2 = 0.27f;
GLfloat g_clip_3 = 0.07f;
GLfloat g_clip_4 = -0.13f;
GLfloat g_clip_5 = -0.33f;
// set up the clipping planes
glPushMatrix( );
glTranslatef( 0.0f, 0.0f, g_clip_1 );
glClipPlane( GL_CLIP_PLANE0, eqn1 );
glPopMatrix( );
glPushMatrix( );
glTranslatef( 0.0f, 0.0f, g_clip_2);
glClipPlane( GL_CLIP_PLANE1, eqn2 );
glPopMatrix( );
glPushMatrix( );
glTranslatef( 0.0f, 0.0f, g_clip_3);
glClipPlane( GL_CLIP_PLANE2, eqn3 );
glPopMatrix( );
glPushMatrix( );
glTranslatef( 0.0f, 0.0f, g_clip_4 );
glClipPlane( GL_CLIP_PLANE3, eqn4 );
glPopMatrix( );
glPushMatrix( );
glTranslatef( 0.0f, 0.0f, g_clip_5 );
glClipPlane( GL_CLIP_PLANE4, eqn5 );
glPopMatrix( );
// enable each clipping plane
if( g_clip1 )
glEnable( GL_CLIP_PLANE0 );
else
glDisable( GL_CLIP_PLANE0 );
if( g_clip2 )
glEnable( GL_CLIP_PLANE1 );
else
glDisable( GL_CLIP_PLANE1 );
if( g_clip3 )
glEnable( GL_CLIP_PLANE2 );
else
glDisable( GL_CLIP_PLANE2 );
if( g_clip4 )
glEnable( GL_CLIP_PLANE3 );
else
glDisable( GL_CLIP_PLANE3 );
if( g_clip5 )
glEnable( GL_CLIP_PLANE4 );
else
glDisable( GL_CLIP_PLANE4 );
void keyboard ( unsigned char key, int x, int y )
{
switch ( key )
{
case KEY_ESCAPE:
exit ( 0 );
break;
// toggle the clipping planes
case '1':
g_clip1 = !g_clip1;
break;
case '2':
g_clip2 = !g_clip2;
break;
case '3':
g_clip3 = !g_clip3;
break;
case '4':
g_clip4 = !g_clip4;
break;
case '5':
g_clip5 = !g_clip5;
break;
default:
break;
}
}