diff options
author | Constantin Riß <constantin.riss@dre.de> | 2009-12-02 17:19:57 +0100 |
---|---|---|
committer | Constantin Riß <constantin.riss@dre.de> | 2009-12-02 17:19:57 +0100 |
commit | 21736d4fee7e61b08227982a8402584887abda1e (patch) | |
tree | 4965fa0511f17981ef4d6ef1588194b60f46f47e /Cuboid.cpp | |
parent | ebfd73503bc386e75d2debf2fc8858e1231e0ddf (diff) | |
download | c3d-21736d4fee7e61b08227982a8402584887abda1e.tar c3d-21736d4fee7e61b08227982a8402584887abda1e.zip |
Positionsangabe (Quader) auf Mitte verlagert.
Diffstat (limited to 'Cuboid.cpp')
-rw-r--r-- | Cuboid.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
@@ -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); |