diff options
Diffstat (limited to 'Cubehole.cpp')
-rw-r--r-- | Cubehole.cpp | 175 |
1 files changed, 9 insertions, 166 deletions
diff --git a/Cubehole.cpp b/Cubehole.cpp index 428cc7a..0806f79 100644 --- a/Cubehole.cpp +++ b/Cubehole.cpp @@ -1,162 +1,19 @@ #include "Cubehole.h" #include "gl.h" -std::list<Triangle> Cubehole::getTriangles(/*const Matrix &modelview*/) +std::list<Triangle> Cubehole::getTriangles() { std::list<Triangle> 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<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) { - t->transform(modelview); - }*/ + std::list<Triangle> tf = front.getTriangles(); + triangles.splice(triangles.end(), tf); + std::list<Triangle> tr = right.getTriangles(); + triangles.splice(triangles.end(), tr); + std::list<Triangle> tb = back.getTriangles(); + triangles.splice(triangles.end(), tb); + std::list<Triangle> tl = left.getTriangles(); + triangles.splice(triangles.end(), tl); return triangles; } @@ -190,17 +47,3 @@ 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; -} |