summaryrefslogtreecommitdiffstats
path: root/Cuboid.cpp
diff options
context:
space:
mode:
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);