diff options
author | Constantin Riß <constantin.riss@dre.de> | 2009-12-03 22:15:45 +0100 |
---|---|---|
committer | Constantin Riß <constantin.riss@dre.de> | 2009-12-03 22:15:45 +0100 |
commit | bfa11fa56f513f68cfd9ec1da1443c5cf624c4dc (patch) | |
tree | 7e1e8963f255df7d92a0c4389ae98e006714ddb5 /Trapezocube.cpp | |
parent | 9581542002a57f72afcbaebfe1ae6fc3b4021400 (diff) | |
download | c3d-bfa11fa56f513f68cfd9ec1da1443c5cf624c4dc.tar c3d-bfa11fa56f513f68cfd9ec1da1443c5cf624c4dc.zip |
Dateien zu adden wurde nachgeholt.
Diffstat (limited to 'Trapezocube.cpp')
-rw-r--r-- | Trapezocube.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Trapezocube.cpp b/Trapezocube.cpp new file mode 100644 index 0000000..e9877de --- /dev/null +++ b/Trapezocube.cpp @@ -0,0 +1,78 @@ +#include "Trapezocube.h" + +std::list<Triangle> Trapezocube::getTriangles(const Matrix &modelview) +{ + std::list<Triangle> triangles; + // width, height, depth + //glRotatef(rotate, 0.0, 1.0, 0.0); + // Front face + Color c(0.0, 0.0, 1.0, 0.5); + + triangles.push_back(Triangle(Vertex(x-widthfront/2, y+height/2, z+depth/2), + Vertex(x+widthfront/2, y+height/2, z+depth/2), + Vertex(x-widthfront/2, y-height/2, z+depth/2), c)); + + triangles.push_back(Triangle(Vertex(x-widthfront/2, y-height/2, z+depth/2), + Vertex(x+widthfront/2, y+height/2, z+depth/2), + Vertex(x+widthfront/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-widthback/2, y+height/2, z-depth/2), + Vertex(x-widthback/2, y-height/2, z-depth/2), + Vertex(x+widthback/2, y+height/2, z-depth/2), c)); + + triangles.push_back(Triangle(Vertex(x-widthback/2, y-height/2, z-depth/2), + Vertex(x+widthback/2, y+height/2, z-depth/2), + Vertex(x+widthback/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-widthfront /2, y+height/2, z+depth/2), + Vertex(x-widthfront /2, y-height/2, z+depth/2), + Vertex(x-widthback /2, y+height/2, z-depth/2), c)); + + triangles.push_back(Triangle(Vertex(x-widthback /2, y-height/2, z-depth/2), + Vertex(x-widthback /2, y+height/2, z-depth/2), + Vertex(x-widthfront /2, y-height/2, z+depth/2), c)); + + // Right face + + triangles.push_back(Triangle(Vertex(x+widthfront/2, y+height/2, z+depth/2), + Vertex(x+widthfront/2, y-height/2, z+depth/2), + Vertex(x+widthback /2, y+height/2, z-depth/2), c)); + + triangles.push_back(Triangle(Vertex(x+widthback /2, y-height/2, z-depth/2), + Vertex(x+widthback /2, y+height/2, z-depth/2), + Vertex(x+widthfront/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-widthfront/2, y+height/2, z+depth/2), + Vertex(x+widthfront/2, y+height/2, z+depth/2), + Vertex(x-widthback /2, y+height/2, z-depth/2), c)); + + triangles.push_back(Triangle(Vertex(x+widthfront/2, y+height/2, z+depth/2), + Vertex(x+widthback /2, y+height/2, z-depth/2), + Vertex(x-widthback /2, y+height/2, z-depth/2), c)); + + // Bottom face + + triangles.push_back(Triangle(Vertex(x-widthfront/2, y-height/2, z+depth/2), + Vertex(x+widthfront/2, y-height/2, z+depth/2), + Vertex(x-widthback /2, y-height/2, z-depth/2), c)); + + triangles.push_back(Triangle(Vertex(x+widthfront/2, y-height/2, z+depth/2), + Vertex(x+widthback /2, y-height/2, z-depth/2), + Vertex(x-widthback /2, y-height/2, z-depth/2), c)); + + for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) { + t->transform(modelview); + } + + return triangles; +} + |