#include "Cubehole.h" #include "gl.h" std::list Cubehole::getTriangles(/*const Matrix &modelview*/) { std::list triangles; // width, height, depth // Front face vmml::vec4f c(0.0, 0.0, 1.0, 0.5); 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(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 = vmml::vec4f(1.0, 1.0, 0.0, 0.5); 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(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 = vmml::vec4f(0.0, 1.0, 0.0, 0.5); 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(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(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(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 = vmml::vec4f(1.0, 0.0, 0.0, 0.5); 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+innerdepth/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+innerdepth/2), vmml::vec3f(x-width/2, y+height/2, z+innerdepth/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-innerdepth/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-innerdepth/2), vmml::vec3f(x-width/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x- width/2, y+height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x- width/2, y+height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y+height/2, z-innerdepth/2), vmml::vec3f(x- width/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x+ width/2, y+height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x+ width/2, y+height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z-innerdepth/2), vmml::vec3f(x+ width/2, y+height/2, z-innerdepth/2), c)); // Bottom face 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+innerdepth/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+innerdepth/2), vmml::vec3f(x-width/2, y-height/2, z+innerdepth/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-innerdepth/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-innerdepth/2), vmml::vec3f(x-width/2, y-height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x- width/2, y-height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x- width/2, y-height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z-innerdepth/2), vmml::vec3f(x- width/2, y-height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x+ width/2, y-height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x+ width/2, y-height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z-innerdepth/2), vmml::vec3f(x+ width/2, y-height/2, z-innerdepth/2), c)); // FrontInner face c = vmml::vec4f(1.0, 1.0, 1.0, 0.5); triangles.push_back(Triangle(vmml::vec3f(x-innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z+innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x-innerwidth/2, y-height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z+innerdepth/2), c)); // BackInner face c = vmml::vec4f(1.0, 0.5, 0.0, 0.5); triangles.push_back(Triangle(vmml::vec3f(x-innerwidth/2, y+height/2, z-innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z-innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x-innerwidth/2, y-height/2, z-innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z-innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z-innerdepth/2), c)); // LeftInner face c = vmml::vec4f(0.0, 1.0, 0.0, 0.5); triangles.push_back(Triangle(vmml::vec3f(x-innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z+innerdepth/2), vmml::vec3f(x-innerwidth/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x-innerwidth/2, y-height/2, z-innerdepth/2), vmml::vec3f(x-innerwidth/2, y+height/2, z-innerdepth/2), vmml::vec3f(x-innerwidth/2, y-height/2, z+innerdepth/2), c)); // RightInner face triangles.push_back(Triangle(vmml::vec3f(x+innerwidth/2, y+height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z+innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z-innerdepth/2), c)); triangles.push_back(Triangle(vmml::vec3f(x+innerwidth/2, y-height/2, z-innerdepth/2), vmml::vec3f(x+innerwidth/2, y+height/2, z-innerdepth/2), vmml::vec3f(x+innerwidth/2, y-height/2, z+innerdepth/2), c)); /*for(std::list::iterator t = triangles.begin(); t != triangles.end(); ++t) { t->transform(modelview); }*/ return triangles; } float Cubehole::getHeight() { return height; } float Cubehole::getWidth() { return width; } float Cubehole::getDepth() { return depth; } float Cubehole::getPosX() { return x; } float Cubehole::getPosY() { return y; } float Cubehole::getPosZ() { return z; } void Cubehole::setSize(float w, float h, float d) { width = w; height = h; depth = d; } void Cubehole::setPos(float x, float y, float z) { this->x = x; this->y = y; this->z = z; }