summaryrefslogtreecommitdiffstats
path: root/Trapezocube.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Trapezocube.cpp')
-rw-r--r--Trapezocube.cpp78
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;
+}
+