diff options
-rw-r--r-- | DisplayClass.cpp | 22 | ||||
-rw-r--r-- | DisplayClass.h | 21 | ||||
-rw-r--r-- | Triangle.h | 1 | ||||
-rw-r--r-- | main.cpp | 2 |
4 files changed, 15 insertions, 31 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp index d993e3b..cf7a0f9 100644 --- a/DisplayClass.cpp +++ b/DisplayClass.cpp @@ -3,46 +3,43 @@ #include "BSPTree.h" -DisplayClass::OpaqueRenderer DisplayClass::opaqueRenderer; -DisplayClass::TransparentRenderer DisplayClass::transparentRenderer; +DisplayClass::Renderer DisplayClass::renderer; DisplayClass::DisplayClass() { - /*cubeing[0] = Trapezocube(11.0, 10.0, 10.0, 0.5, 0.0, 0.0, 1.75, 0); + cubeing[0] = Trapezocube(11.0, 10.0, 10.0, 0.5, 0.0, 0.0, 1.75, 0); cubeing[1] = Trapezocube(10.0, 9.0, 9.0, 0.5, 0.0, 0.0, 2.25, 90); cubeing[2] = Trapezocube(9.0, 8.0, 8.0, 0.5, 0.0, 0.0, 2.75, 180); cubeing[3] = Trapezocube(8.0, 7.0, 7.0, 0.5, 0.0, 0.0, 3.25, 270); cubeing[4] = Trapezocube(7.0, 6.0, 6.0, 0.5, 0.0, 0.0, 3.75, 0); cubeing[5] = Trapezocube(6.0, 5.0, 5.0, 0.5, 0.0, 0.0, 4.25, 90); cubeing[6] = Trapezocube(5.0, 4.0, 4.0, 0.5, 0.0, 0.0, 4.75, 180); - cubeing[7] = Trapezocube(4.0, 3.0, 3.0, 0.5, 0.0, 0.0, 5.25, 270);*/ - - cube = Cuboid(1, 1, 1, 0, 0, 0); + cubeing[7] = Trapezocube(4.0, 3.0, 3.0, 0.5, 0.0, 0.0, 5.25, 270); } void DisplayClass::renderScene(unsigned long delta) { static float angle = 0.0; - angle += delta*0.015; + angle += delta*0.025; if(angle >= 360) angle -= 360; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Clean up matrix - glTranslatef(0.0, 0.0, -5.0); // Then set up transformation + 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); - std::list<Triangle> triangles = cube.getTriangles(); + std::list<Triangle> triangles; - /*for(int i = 0; i < 8; ++i) { + for(int i = 0; i < 8; ++i) { std::list<Triangle> t = cubeing[i].getTriangles(); triangles.splice(triangles.end(), t); - }*/ + } BSPTree tree(triangles); @@ -54,8 +51,7 @@ void DisplayClass::renderScene(unsigned long delta) vmml::vec3f viewPoint = inverseTransform*vmml::vec3f(0, 0, 0); glBegin(GL_TRIANGLES); - tree.visit(opaqueRenderer, viewPoint); - tree.visit(transparentRenderer, viewPoint); + tree.visit(renderer, viewPoint); glEnd(); glFlush(); diff --git a/DisplayClass.h b/DisplayClass.h index d1e56ba..0b24dc6 100644 --- a/DisplayClass.h +++ b/DisplayClass.h @@ -1,8 +1,7 @@ #ifndef _DISPLAYCLASS_H_ #define _DISPLAYCLASS_H_ -//#include "Trapezocube.h" -#include "Cuboid.h" +#include "Trapezocube.h" class DisplayClass
{
@@ -12,25 +11,15 @@ class DisplayClass void renderScene(unsigned long delta); private: - struct OpaqueRenderer { + struct Renderer { void operator() (const Triangle &t) const { - if(t.getColor().a() == 1.0) - t.render(); + t.render(); } }; - struct TransparentRenderer { - void operator() (const Triangle &t) const { - if(t.getColor().a() != 1.0) - t.render(); - } - }; - - static OpaqueRenderer opaqueRenderer; - static TransparentRenderer transparentRenderer; + static Renderer renderer; - //Trapezocube cubeing[8]; - Cuboid cube;
+ Trapezocube cubeing[8];
};
#endif /*_DISPLAYCLASS_H_*/ @@ -24,7 +24,6 @@ class Triangle } void render() const { - glColor4fv(c.array); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c.array); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (c/2).array); @@ -18,7 +18,7 @@ void initGL(bool multisample); void resize(int width, int height); void initGL(bool multisample) { - glClearColor(0, 0, 0, 1.0); + glClearColor(1.0, 0.85, 0.06, 1.0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); |