/********************************************************************************* * Draw 'beethovan' object. **********************************************************************************/ void drawBet() { glPushMatrix(); glMultMatrixd(bet2wld.GLmatrix()); drawFrame(8); float frontColor[] = {0.8, 0.3, 0.1, 1.0}; glEnable(GL_LIGHTING); glMaterialfv(GL_FRONT, GL_AMBIENT, frontColor); glMaterialfv(GL_FRONT, GL_DIFFUSE, frontColor); glCallList(betID); glPopMatrix(); }
/********************************************************************************* * Draw 'cow' object. **********************************************************************************/ void drawCow(matrix4 const& _cow2wld, bool drawBB) { glPushMatrix(); // Push the current matrix of GL into stack. This is because the matrix of GL will be change while drawing cow. // The information about location of cow to be drawn is stored in cow2wld matrix. // (Project2 hint) If you change the value of the cow2wld matrix or the current matrix, cow would rotate or move. glMultMatrixd(_cow2wld.GLmatrix()); drawFrame(5); // Draw x, y, and z axis. float frontColor[] = {0.8, 0.2, 0.9, 1.0}; glEnable(GL_LIGHTING); glMaterialfv(GL_FRONT, GL_AMBIENT, frontColor); // Set ambient property frontColor. glMaterialfv(GL_FRONT, GL_DIFFUSE, frontColor); // Set diffuse property frontColor. glCallList(cowID); // Draw cow. glDisable(GL_LIGHTING); if(drawBB){ glBegin(GL_LINES); glColor3d(1,1,1); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmax.z); glColor3d(1,1,1); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmax.z); glColor3d(1,1,1); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmax.z); glColor3d(1,1,1); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmax.z); glColor3d(1,1,1); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmin.y, cow->bbmax.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmin.x, cow->bbmax.y, cow->bbmax.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmin.z); glVertex3d( cow->bbmax.x, cow->bbmax.y, cow->bbmax.z); glEnd(); } glPopMatrix(); // Pop the matrix in stack to GL. Change it the matrix before drawing cow. }