summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2009-12-02 17:19:57 +0100
committerConstantin Riß <constantin.riss@dre.de>2009-12-02 17:19:57 +0100
commit21736d4fee7e61b08227982a8402584887abda1e (patch)
tree4965fa0511f17981ef4d6ef1588194b60f46f47e
parentebfd73503bc386e75d2debf2fc8858e1231e0ddf (diff)
downloadc3d-21736d4fee7e61b08227982a8402584887abda1e.tar
c3d-21736d4fee7e61b08227982a8402584887abda1e.zip
Positionsangabe (Quader) auf Mitte verlagert.
-rw-r--r--Cuboid.cpp72
-rw-r--r--DisplayClass.cpp8
2 files changed, 40 insertions, 40 deletions
diff --git a/Cuboid.cpp b/Cuboid.cpp
index 6569e31..6b58294 100644
--- a/Cuboid.cpp
+++ b/Cuboid.cpp
@@ -68,66 +68,66 @@ std::list<Triangle> Cuboid::getTriangles(const Matrix &modelview)
// Front face
Color c(0.0, 0.0, 1.0, 0.5);
- triangles.push_back(Triangle(Vertex(x , y , z),
- Vertex(x+width, y , z),
- Vertex(x , y-height, z), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y+height/2, z+depth/2),
+ Vertex(x+width/2, y+height/2, z+depth/2),
+ Vertex(x-width/2, y-height/2, z+depth/2), c));
- triangles.push_back(Triangle(Vertex(x , y-height, z),
- Vertex(x+width, y , z),
- Vertex(x+width, y-height, z), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y-height/2, z+depth/2),
+ Vertex(x+width/2, y+height/2, z+depth/2),
+ Vertex(x+width/2, y-height/2, z+depth/2), c));
// Back face
c = Color(1.0, 1.0, 0.0, 0.5);
- triangles.push_back(Triangle(Vertex(x , y , z-depth),
- Vertex(x , y-height, z-depth),
- Vertex(x+width, y , z-depth), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y+height/2, z-depth/2),
+ Vertex(x-width/2, y-height/2, z-depth/2),
+ Vertex(x+width/2, y+height/2, z-depth/2), c));
- triangles.push_back(Triangle(Vertex(x , y-height, z-depth),
- Vertex(x+width, y , z-depth),
- Vertex(x+width, y-height, z-depth), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y-height/2, z-depth/2),
+ Vertex(x+width/2, y+height/2, z-depth/2),
+ Vertex(x+width/2, y-height/2, z-depth/2), c));
// Left face
c = Color(0.0, 1.0, 0.0, 0.5);
- triangles.push_back(Triangle(Vertex(x, y , z ),
- Vertex(x, y-height, z ),
- Vertex(x, y , z-depth), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y+height/2, z+depth/2),
+ Vertex(x-width/2, y-height/2, z+depth/2),
+ Vertex(x-width/2, y+height/2, z-depth/2), c));
- triangles.push_back(Triangle(Vertex(x, y-height, z-depth),
- Vertex(x, y , z-depth),
- Vertex(x, y-height, z ), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y-height/2, z-depth/2),
+ Vertex(x-width/2, y+height/2, z-depth/2),
+ Vertex(x-width/2, y-height/2, z+depth/2), c));
// Right face
- triangles.push_back(Triangle(Vertex(x+width, y , z ),
- Vertex(x+width, y-height, z ),
- Vertex(x+width, y , z-depth), c));
+ triangles.push_back(Triangle(Vertex(x+width/2, y+height/2, z+depth/2),
+ Vertex(x+width/2, y-height/2, z+depth/2),
+ Vertex(x+width/2, y+height/2, z-depth/2), c));
- triangles.push_back(Triangle(Vertex(x+width, y-height, z-depth),
- Vertex(x+width, y , z-depth),
- Vertex(x+width, y-height, z ), c));
+ triangles.push_back(Triangle(Vertex(x+width/2, y-height/2, z-depth/2),
+ Vertex(x+width/2, y+height/2, z-depth/2),
+ Vertex(x+width/2, y-height/2, z+depth/2), c));
// Top face
c = Color(1.0, 0.0, 0.0, 0.5);
- triangles.push_back(Triangle(Vertex(x , y, z ),
- Vertex(x+width, y, z ),
- Vertex(x , y, z-depth), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y+height/2, z+depth/2),
+ Vertex(x+width/2, y+height/2, z+depth/2),
+ Vertex(x-width/2, y+height/2, z-depth/2), c));
- triangles.push_back(Triangle(Vertex(x+width, y, z ),
- Vertex(x+width, y, z-depth),
- Vertex(x , y, z-depth), c));
+ triangles.push_back(Triangle(Vertex(x+width/2, y+height/2, z+depth/2),
+ Vertex(x+width/2, y+height/2, z-depth/2),
+ Vertex(x-width/2, y+height/2, z-depth/2), c));
// Bottom face
- triangles.push_back(Triangle(Vertex(x , y-height, z ),
- Vertex(x+width, y-height, z ),
- Vertex(x , y-height, z-depth), c));
+ triangles.push_back(Triangle(Vertex(x-width/2, y-height/2, z+depth/2),
+ Vertex(x+width/2, y-height/2, z+depth/2),
+ Vertex(x-width/2, y-height/2, z-depth/2), c));
- triangles.push_back(Triangle(Vertex(x+width, y-height, z ),
- Vertex(x+width, y-height, z-depth),
- Vertex(x , y-height, z-depth), c));
+ triangles.push_back(Triangle(Vertex(x+width/2, y-height/2, z+depth/2),
+ Vertex(x+width/2, y-height/2, z-depth/2),
+ Vertex(x-width/2, y-height/2, z-depth/2), c));
for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
t->transform(modelview);
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index 9cae95c..30abdcb 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -11,8 +11,8 @@ void DisplayClass::renderScene(unsigned long delta)
//Cuboid cube2(1, 1, 2, -0.5, 0.5, -1.5);
static const Cuboid dc(0.8, 2, 0.8);
- static const float xs[5] = {-2.5, -1.5, -0.5, 0.5, 1.5};
- static const float zs[5] = {-1.5, -0.5, 0.5, 1.5, 2.5};
+ static const float xs[5] = {-2.0, -1.0, 0.0, 1.0, 2.0};
+ static const float zs[5] = {-2.0, -1.0, 0.0, 1.0, 2.0};
Cuboid cubes[5][5] = {
{dc, dc, dc, dc, dc},
@@ -24,7 +24,7 @@ void DisplayClass::renderScene(unsigned long delta)
for(int i = 0; i < 5; ++i) {
for(int j = 0; j < 5; ++j) {
- cubes[i][j].setPos(xs[j], 1.0, zs[i]);
+ cubes[i][j].setPos(xs[j], 0.0, zs[i]);
}
}
/* {Cuboid(2, 1, 1, -2.5, 1.0, -1.5), Cuboid(2, 1, 1, -1.5, 1.0, -1.5), Cuboid(2, 1, 1, -0.5, 1.0, -1.5), Cuboid(2, 1, 1, 0.5, 1.0, -1.5), Cuboid(2, 1, 1, 1.5, 1.0, -1.5)},
@@ -33,7 +33,7 @@ void DisplayClass::renderScene(unsigned long delta)
{Cuboid(2, 1, 1, -2.5, 1.0, 1.5), Cuboid(2, 1, 1, -1.5, 1.0, -1.5), Cuboid(2, 1, 1, -0.5, 1.0, -1.5), Cuboid(2, 1, 1, 0.5, 1.0, -1.5), Cuboid(2, 1, 1, 1.5, 1.0, 1.5)},
{Cuboid(2, 1, 1, -2.5, 1.0, 2.5), Cuboid(2, 1, 1, -1.5, 1.0, 2.5), Cuboid(2, 1, 1, -0.5, 1.0, 2.5), Cuboid(2, 1, 1, 0.5, 1.0, 2.5), Cuboid(2, 1, 1, 1.5, 1.0, 2.5)}};*/
static float angle = 0.0;
- angle += delta*0.043;
+ angle += delta*0.05;
if(angle >= 360)
angle -= 360;