/* manage model */ GLUquadricObj * wireTool;
wireTool
in display()
.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); wireTool=gluNewQuadric(); gluQuadricDrawStyle(wireTool,GLU_LINE); renderView(); glFlush(); gluDeleteQuadric(wireTool);
void renderDancer(){ glColor3fv(colour[green]); gluCylinder(wireTool,1.0,0.25,1.7,9,2); } void renderView(){ renderDancer(); }
glColor3fv(colour[magenta]); gluSphere(wireTool,0.45,15,15);
/* manage model transforms */ enum {head}; GLdouble t[][3]={ {0,0,1.925} };
renderDancer()
.
glTranslated(t[head][x],t[head][y],t[head][z]);
enum {dancer,head}; GLdouble t[][3]={ {0,0,0},{0,0,1.925} }; GLdouble ra[]={ -90,0 }; GLdouble r[][3]={ {1,0,0},{0,0,1} };
glRotated(ra[dancer],r[dancer][x],r[dancer][y],r[dancer][z]);
renderView()
before the code to renderDancer().
glTranslated(t[dancer][x],t[dancer][y],t[dancer][z]);
glutSpecialFunc
function with GLUT.void specialKeys(int key,int xMouse,int yMouse){ int i; switch(key){ case GLUT_KEY_PAGE_UP : t[dancer][z]+= 0.1; break; case GLUT_KEY_PAGE_DOWN: t[dancer][z]+=-0.1; break; } glutPostRedisplay(); }