#include "Trapezocube.h" std::list Trapezocube::getTriangles(const Matrix &modelview) { std::list 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::iterator t = triangles.begin(); t != triangles.end(); ++t) { t->transform(modelview); } return triangles; }