void keyboard(unsigned char key, int x0, int y0) { switch (key) { case 27 : exit(0); case ' ': static int i = 0; i++; if (i == 2) i = 0; mesh.read(paths[i]); if (drawAABB) boundingBox.computeAxisAlignedBox(mesh.vertices); else boundingBox.computeOrientedBox(mesh.vertices); break; case 'b': drawAABB = !drawAABB; if (drawAABB) { boundingBox.computeAxisAlignedBox(mesh.vertices); glutSetWindowTitle("Bounding Box - Axis Aligned"); } else { boundingBox.computeOrientedBox(mesh.vertices); glutSetWindowTitle("Bounding Box - Oriented"); } break; case 'a': x -= 0.03; break; case 'd': x += 0.03; break; case 'w': y += 0.03; break; case 's': y -= 0.03; break; } glutPostRedisplay(); }
int main(int argc, char** argv) { success = mesh.read(paths[0]); if (success) boundingBox.computeAxisAlignedBox(mesh.vertices); printInstructions(); glutInitWindowSize(gridX, gridY); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInit(&argc, argv); glutCreateWindow("Bounding Box - Axis Aligned"); init(); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutSpecialFunc(special); glutMainLoop(); return 0; }