summaryrefslogtreecommitdiffstats
path: root/Cuboid.cpp
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 /Cuboid.cpp
parentebfd73503bc386e75d2debf2fc8858e1231e0ddf (diff)
downloadc3d-21736d4fee7e61b08227982a8402584887abda1e.tar
c3d-21736d4fee7e61b08227982a8402584887abda1e.zip
Positionsangabe (Quader) auf Mitte verlagert.
Diffstat (limited to 'Cuboid.cpp')
-rw-r--r--Cuboid.cpp72
1 files changed, 36 insertions, 36 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);