#include "DisplayClass.h" #include "Matrix.h" #include "gl.h" //#include #include "Trapezocube.h" #include "BSPTree.h" DisplayClass::DisplayClass() { static const float pos[5] = {-3.0, -2.0, 0.0, 2.0, 3.0}; for(int i = 0; i < 5; ++i) { for(int j = 0; j < 5; ++j) { for(int k = 0; k < 5; ++k) { cubes[i][j][k].setSize(0.5, 0.5, 0.5); cubes[i][j][k].setPos(pos[k], pos[j], pos[i]); } } } } void DisplayClass::renderScene(unsigned long delta) { //Cubehole cubeing(3.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.5); Trapezocube cubeing1(11.0, 10.0, 10.0, 0.5, 0.0, 0.0, 1.75, 0); Trapezocube cubeing2(10.0, 9.0, 9.0, 0.5, 0.0, 0.0, 2.25, 90); Trapezocube cubeing3(9.0, 8.0, 8.0, 0.5, 0.0, 0.0, 2.75, 180); Trapezocube cubeing4(8.0, 7.0, 7.0, 0.5, 0.0, 0.0, 3.25, 270); Trapezocube cubeing5(7.0, 6.0, 6.0, 0.5, 0.0, 0.0, 3.75, 0); Trapezocube cubeing6(6.0, 5.0, 5.0, 0.5, 0.0, 0.0, 4.25, 90); Trapezocube cubeing7(5.0, 4.0, 4.0, 0.5, 0.0, 0.0, 4.75, 180); Trapezocube cubeing8(4.0, 3.0, 3.0, 0.5, 0.0, 0.0, 5.25, 270); static float angle = 0.0; angle += delta*0.025; if(angle >= 360) angle -= 360; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Matrix p(GL_PROJECTION_MATRIX); //Matrix m; std::list triangles; glLoadIdentity(); // Clean up matrix glTranslatef(0.0, 0.0, -30.0); // Then set up transformation glRotatef(angle, 0.0, 1.0, 0.0); glRotatef(angle*2, 1.0, 0.0, 0.0); glRotatef(angle*3, 0.0, 0.0, 1.0); glRotatef(-angle*5, 1.0, 1.0, 1.0); //m.store(); // Save current transformation /*for(int i = 0; i < 5; ++i) { for(int j = 0; j < 5; ++j) { for(int k = 0; k < 5; ++k) { std::list ct = cubes[i][j][k].getTriangles(m); triangles.splice(triangles.end(), ct); } } }*/ std::list ct1 = cubeing1.getTriangles(); triangles.splice(triangles.end(), ct1); std::list ct2 = cubeing2.getTriangles(); triangles.splice(triangles.end(), ct2); std::list ct3 = cubeing3.getTriangles(); triangles.splice(triangles.end(), ct3); std::list ct4 = cubeing4.getTriangles(); triangles.splice(triangles.end(), ct4); std::list ct5 = cubeing5.getTriangles(); triangles.splice(triangles.end(), ct5); std::list ct6 = cubeing6.getTriangles(); triangles.splice(triangles.end(), ct6); std::list ct7 = cubeing7.getTriangles(); triangles.splice(triangles.end(), ct7); std::list ct8 = cubeing8.getTriangles(); triangles.splice(triangles.end(), ct8); //glLoadIdentity(); glBegin(GL_TRIANGLES); for(std::list::reverse_iterator t = triangles.rbegin(); t != triangles.rend(); ++t) { t->render(); } glEnd(); glFlush(); }