diff options
Diffstat (limited to 'Cuboid.cpp')
-rw-r--r-- | Cuboid.cpp | 90 |
1 files changed, 41 insertions, 49 deletions
@@ -1,10 +1,6 @@ #include "Cuboid.h" #include "gl.h" -#include <iostream> -//#include <stdlib.h> -//#include <time.h> - Cuboid::Cuboid(float width, float height, float depth) { setSize(width, height, depth); setPos(0, 0, 0); @@ -60,77 +56,73 @@ void Cuboid::setPos(float x, float y, float z) this->z = z; } -std::list<Triangle> Cuboid::getTriangles(const Matrix &modelview) +std::list<Triangle> Cuboid::getTriangles() { std::list<Triangle> triangles; // width, height, depth // Front face - Color c(0.0, 0.0, 1.0, 0.5); + vmml::vec4f c(0.0, 0.0, 1.0, 0.5); - 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(vmml::vec3f(x-width/2, y+height/2, z+depth/2), + vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z+depth/2), 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(vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z+depth/2), c)); // Back face - c = Color(1.0, 1.0, 0.0, 0.5); + c = vmml::vec4f(1.0, 1.0, 0.0, 0.5); - 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(vmml::vec3f(x-width/2, y+height/2, z-depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x-width/2, y-height/2, z-depth/2), 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(vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z-depth/2), c)); // Left face - c = Color(0.0, 1.0, 0.0, 0.5); + c = vmml::vec4f(0.0, 1.0, 0.0, 0.5); - 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(vmml::vec3f(x-width/2, y+height/2, z+depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), + vmml::vec3f(x-width/2, y-height/2, z+depth/2), 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(vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); // Right face - 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(vmml::vec3f(x+width/2, y+height/2, z+depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), 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(vmml::vec3f(x+width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), c)); // Top face - c = Color(1.0, 0.0, 0.0, 0.5); + c = vmml::vec4f(1.0, 0.0, 0.0, 0.5); - 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(vmml::vec3f(x-width/2, y+height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z+depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), 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(vmml::vec3f(x+width/2, y+height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); // Bottom face - 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(vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), 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); - } + triangles.push_back(Triangle(vmml::vec3f(x+width/2, y-height/2, z+depth/2), + vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z-depth/2), c)); return triangles; } |