summaryrefslogtreecommitdiffstats
path: root/Trapezocube.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Trapezocube.cpp')
-rw-r--r--Trapezocube.cpp95
1 files changed, 51 insertions, 44 deletions
diff --git a/Trapezocube.cpp b/Trapezocube.cpp
index 20aa1c4..8205ee6 100644
--- a/Trapezocube.cpp
+++ b/Trapezocube.cpp
@@ -1,73 +1,80 @@
#include "Trapezocube.h"
-std::list<Triangle> Trapezocube::getTriangles(/*const Matrix &modelview*/)
+
+std::list<Triangle> Trapezocube::getTriangles()
{
std::list<Triangle> triangles;
+ // width, height, depth
- glPushMatrix();
- glLoadIdentity();
- glRotatef(rotate, 0.0, 1.0, 0.0);
- Matrix rotation;
- glPopMatrix();
+ vmml::mat4f rotation(vmml::mat4f::IDENTITY);
+ rotation.rotate_y(M_PI*rotate/180.0f);
// Front 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+widthfront/2, y+height/2, z+depth/2), color));
+ vmml::vec4f c(0.0, 0.0, 1.0, 0.5);
+
+ triangles.push_back(Triangle(vmml::vec3f(x-widthfront/2, y+height/2, z+depth/2),
+ vmml::vec3f(x-widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(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), color));
+ triangles.push_back(Triangle(vmml::vec3f(x-widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(x+widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(x+widthfront/2, y+height/2, z+depth/2), c));
// Back face
- 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), color));
+ c = vmml::vec4f(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), color));
+ triangles.push_back(Triangle(vmml::vec3f(x-widthback/2, y+height/2, z-depth/2),
+ vmml::vec3f(x+widthback/2, y+height/2, z-depth/2),
+ vmml::vec3f(x-widthback/2, y-height/2, z-depth/2), c));
+
+ triangles.push_back(Triangle(vmml::vec3f(x-widthback/2, y-height/2, z-depth/2),
+ vmml::vec3f(x+widthback/2, y+height/2, z-depth/2),
+ vmml::vec3f(x+widthback/2, y-height/2, z-depth/2), c));
// Left face
- triangles.push_back(Triangle(Vertex(x-widthfront/2, y+height/2, z+depth/2),
- Vertex(x-widthback /2, // width, height, depth
- y+height/2, z-depth/2),
- Vertex(x-widthfront/2, y-height/2, z+depth/2), color));
+ c = vmml::vec4f(0.0, 1.0, 0.0, 0.5);
+
+ triangles.push_back(Triangle(vmml::vec3f(x-widthfront/2, y+height/2, z+depth/2),
+ vmml::vec3f(x-widthback /2, y+height/2, z-depth/2),
+ vmml::vec3f(x-widthfront/2, y-height/2, z+depth/2), c));
- triangles.push_back(Triangle(Vertex(x-widthback /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), color));
+ triangles.push_back(Triangle(vmml::vec3f(x-widthback /2, y-height/2, z-depth/2),
+ vmml::vec3f(x-widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(x-widthback /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), color));
- 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), color));
+ triangles.push_back(Triangle(vmml::vec3f(x+widthfront/2, y+height/2, z+depth/2),
+ vmml::vec3f(x+widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(x+widthback /2, y+height/2, z-depth/2), c));
+
+ triangles.push_back(Triangle(vmml::vec3f(x+widthback /2, y-height/2, z-depth/2),
+ vmml::vec3f(x+widthback /2, y+height/2, z-depth/2),
+ vmml::vec3f(x+widthfront/2, y-height/2, z+depth/2), c));
// Top 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), color));
+ c = vmml::vec4f(1.0, 0.0, 0.0, 0.5);
+
+ triangles.push_back(Triangle(vmml::vec3f(x-widthfront/2, y+height/2, z+depth/2),
+ vmml::vec3f(x+widthfront/2, y+height/2, z+depth/2),
+ vmml::vec3f(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), color));
+ triangles.push_back(Triangle(vmml::vec3f(x+widthfront/2, y+height/2, z+depth/2),
+ vmml::vec3f(x+widthback /2, y+height/2, z-depth/2),
+ vmml::vec3f(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-widthback /2, y-height/2, z-depth/2),
- Vertex(x+widthfront/2, y-height/2, z+depth/2), color));
- 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), color));
+ triangles.push_back(Triangle(vmml::vec3f(x-widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(x-widthback /2, y-height/2, z-depth/2),
+ vmml::vec3f(x+widthfront/2, y-height/2, z+depth/2), c));
+
+ triangles.push_back(Triangle(vmml::vec3f(x+widthfront/2, y-height/2, z+depth/2),
+ vmml::vec3f(x-widthback /2, y-height/2, z-depth/2),
+ vmml::vec3f(x+widthback /2, y-height/2, z-depth/2), c));
for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
t->transform(rotation);
- //t->transform(modelview);
}
return triangles;