summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2009-12-03 18:43:00 +0100
committerConstantin Riß <constantin.riss@dre.de>2009-12-03 18:43:00 +0100
commitfabe45bc9a1ad186673cbaa1b574536c2cee2ac9 (patch)
treeebc117d257190213f93a6dc48a3ccc78ac1bed85
parent8c8948a6fc78aa769ac4ceeb0a1e6d0471376ef1 (diff)
downloadc3d-fabe45bc9a1ad186673cbaa1b574536c2cee2ac9.tar
c3d-fabe45bc9a1ad186673cbaa1b574536c2cee2ac9.zip
Einen Quader mit einem Loch in der Mitte geaddet.
-rw-r--r--CMakeLists.txt1
-rw-r--r--Cuboid.cpp1
-rw-r--r--Cuboid.h3
-rw-r--r--DisplayClass.cpp13
-rw-r--r--DisplayClass.h2
5 files changed, 12 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50e80ca..8021c91 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ add_executable(c3d
BSPGenerator.cpp BSPGenerator.h
BSPTree.h
Color.h
+ Cubehole.cpp Cubehole.h
Cuboid.cpp Cuboid.h
DisplayClass.cpp DisplayClass.h
gl.h
diff --git a/Cuboid.cpp b/Cuboid.cpp
index 6b58294..b53dada 100644
--- a/Cuboid.cpp
+++ b/Cuboid.cpp
@@ -63,7 +63,6 @@ void Cuboid::setPos(float x, float y, float z)
std::list<Triangle> Cuboid::getTriangles(const Matrix &modelview)
{
std::list<Triangle> triangles;
- //srand(time(NULL));
// width, height, depth
// Front face
Color c(0.0, 0.0, 1.0, 0.5);
diff --git a/Cuboid.h b/Cuboid.h
index 05580e1..ae9f2a1 100644
--- a/Cuboid.h
+++ b/Cuboid.h
@@ -25,7 +25,8 @@ class Cuboid
private:
float width, height, depth;
- float x, y, z;
+ float x, y, z;
+
};
#endif /*_CUBOID_H_*/
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index 3a43569..0822058 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -5,7 +5,7 @@
DisplayClass::DisplayClass() {
- static const float pos[5] = {0.0, 1.0, 3.0, 6.0, 10.0};
+ 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) {
@@ -19,6 +19,7 @@ DisplayClass::DisplayClass() {
void DisplayClass::renderScene(unsigned long delta)
{
+ Cubehole cubeing(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5);
static float angle = 0.0;
angle += delta*0.05;
if(angle >= 360)
@@ -32,7 +33,7 @@ void DisplayClass::renderScene(unsigned long delta)
std::list<Triangle> triangles;
glLoadIdentity(); // Clean up matrix
- glTranslatef(0.0, 0.0, -40.0); // Then set up transformation
+ glTranslatef(0.0, 0.0, -10.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);
@@ -40,15 +41,17 @@ void DisplayClass::renderScene(unsigned long delta)
glRotatef(-angle*5, 1.0, 1.0, 1.0);
m.store(); // Save current transformation
- for(int i = 0; i < 5; ++i) {
+ /*for(int i = 0; i < 5; ++i) {
for(int j = 0; j < 5; ++j) {
for(int k = 0; k < 5; ++k) {
std::list<Triangle> ct = cubes[i][j][k].getTriangles(m);
triangles.splice(triangles.end(), ct);
}
}
- }
-
+ }*/
+ std::list<Triangle> ct = cubeing.getTriangles(m);
+ triangles.splice(triangles.end(), ct);
+
glLoadIdentity();
glBegin(GL_TRIANGLES);
diff --git a/DisplayClass.h b/DisplayClass.h
index 367e51a..51f8636 100644
--- a/DisplayClass.h
+++ b/DisplayClass.h
@@ -2,7 +2,7 @@
#define _DISPLAYCLASS_H_
#include "Cuboid.h"
-
+#include "Cubehole.h"
class DisplayClass
{