summaryrefslogtreecommitdiffstats
path: root/DisplayClass.cpp
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2009-12-23 17:51:38 +0100
committerConstantin Riß <constantin.riss@dre.de>2009-12-23 17:51:38 +0100
commitd2abe4f728824ef708dd1f316f4f211fb799251d (patch)
treef5fdb1b4f2d51fea974d93d1ec8a4882e4b495f1 /DisplayClass.cpp
parent6cc98762e5e0c18e4b2c1cbe29d42ae485774609 (diff)
parent90b27bca4d75df07adbe9939a40eafb5c785f903 (diff)
downloadc3d-d2abe4f728824ef708dd1f316f4f211fb799251d.tar
c3d-d2abe4f728824ef708dd1f316f4f211fb799251d.zip
Merge branch 'master' of git://git.gamezock.de/c3d
Diffstat (limited to 'DisplayClass.cpp')
-rw-r--r--DisplayClass.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index b47fc48..2c4489b 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -1,11 +1,10 @@
#include "DisplayClass.h"
#include "gl.h"
-#include "BSPTree.h"
DisplayClass::Renderer DisplayClass::renderer;
-DisplayClass::DisplayClass() {
+DisplayClass::DisplayClass() : angle(0) {
cubehole0 = Cubehole(3.0, 6.0, 3.0, 0.0, 0.0, 0.0, 2.5, 2.5,
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
@@ -36,11 +35,27 @@ DisplayClass::DisplayClass() {
vmml::vec4f(1.0, 0.0, 0.06, 0.5),
vmml::vec4f(1.0, 0.0, 0.06, 0.5),
vmml::vec4f(1.0, 0.0, 0.06, 0.5));
+
+ std::list<Triangle> triangles = cubehole0.getTriangles();
+ std::list<Triangle> t1 = cubehole1.getTriangles();
+ triangles.splice(triangles.end(), t1);
+ std::list<Triangle> t2 = cubehole2.getTriangles();
+ triangles.splice(triangles.end(), t2);
+ std::list<Triangle> t3 = cubehole3.getTriangles();
+ triangles.splice(triangles.end(), t3);
+ std::list<Triangle> t4 = cubehole4.getTriangles();
+ triangles.splice(triangles.end(), t4);
+ std::list<Triangle> t5 = cubehole5.getTriangles();
+ triangles.splice(triangles.end(), t5);
+
+ tree = new BSPTree(triangles);
+}
+
+DisplayClass::~DisplayClass() {
+ delete tree;
}
-void DisplayClass::renderScene(unsigned long delta)
-{
- static float angle = 0.0;
+void DisplayClass::renderScene(unsigned long delta) {
angle += delta*0.025;
if(angle >= 360)
angle -= 360;
@@ -55,7 +70,7 @@ void DisplayClass::renderScene(unsigned long delta)
glRotatef(-angle*5, 1.0, 1.0, 1.0);
- std::list<Triangle> triangles = cubehole0.getTriangles();
+ /*std::list<Triangle> triangles = cubehole0.getTriangles();
std::list<Triangle> t1 = cubehole1.getTriangles();
triangles.splice(triangles.end(), t1);
std::list<Triangle> t2 = cubehole2.getTriangles();
@@ -67,7 +82,7 @@ void DisplayClass::renderScene(unsigned long delta)
std::list<Triangle> t5 = cubehole5.getTriangles();
triangles.splice(triangles.end(), t5);
- BSPTree tree(triangles);
+ BSPTree tree(triangles);*/
vmml::mat4f transform, inverseTransform;
glGetFloatv(GL_MODELVIEW_MATRIX, transform.array);
@@ -77,7 +92,7 @@ void DisplayClass::renderScene(unsigned long delta)
vmml::vec3f viewPoint = inverseTransform*vmml::vec3f::ZERO;
glBegin(GL_TRIANGLES);
- tree.visit(renderer, viewPoint);
+ tree->visit(renderer, viewPoint);
glEnd();
glFlush();