summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-12-10 21:24:40 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-12-10 21:24:40 +0100
commite744ab213aeaccfe1aea6050907019aad9cf1911 (patch)
treee9d741a393e2178c5b90f48df0d0e3975f564e63
parent823e55c9c49cf97531b66e6b15c41d9f9003bc32 (diff)
parentd439daec66c28f85debc2479e95eadb5fc3c00a2 (diff)
downloadc3d-e744ab213aeaccfe1aea6050907019aad9cf1911.tar
c3d-e744ab213aeaccfe1aea6050907019aad9cf1911.zip
Merge branch 'master' of git://git.gamezock.de/c3d
Conflicts: Cubehole.cpp Cubehole.h DisplayClass.cpp Trapezocube.cpp
-rw-r--r--BSPTree.h38
-rw-r--r--Cubehole.cpp175
-rw-r--r--Cubehole.h71
-rw-r--r--Cuboid.cpp6
-rw-r--r--Cuboid.h2
-rw-r--r--DisplayClass.cpp27
-rw-r--r--DisplayClass.h4
-rw-r--r--Trapezocube.cpp3
-rw-r--r--Trapezocube.h15
-rw-r--r--Triangle.h1
10 files changed, 88 insertions, 254 deletions
diff --git a/BSPTree.h b/BSPTree.h
index 0b13b6b..50f18df 100644
--- a/BSPTree.h
+++ b/BSPTree.h
@@ -79,32 +79,21 @@ class BSPTree {
template<typename T>
void visit(const T& visitor, const vmml::vec3f &p) {
- if(plane.isBehind(p)) {
- if(frontTree)
- frontTree->visit(visitor, p);
-
- for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
- visitor(*t);
- }
-
- if(backTree)
- backTree->visit(visitor, p);
- }
- else {
- if(backTree)
- backTree->visit(visitor, p);
-
- for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
- visitor(*t);
- }
-
- if(frontTree)
- frontTree->visit(visitor, p);
- }
+ doVisit<const T>(visitor, p);
}
template<typename T>
void visit(T& visitor, const vmml::vec3f &p) {
+ doVisit(visitor, p);
+ }
+
+ private:
+ Plane plane;
+ std::list<Triangle> triangles;
+ BSPTree *frontTree, *backTree;
+
+ template<typename T>
+ void doVisit(T& visitor, const vmml::vec3f &p) {
if(plane.isBehind(p)) {
if(frontTree)
frontTree->visit(visitor, p);
@@ -129,11 +118,6 @@ class BSPTree {
}
}
- private:
- Plane plane;
- std::list<Triangle> triangles;
- BSPTree *frontTree, *backTree;
-
static vmml::vec3f findCenter(const std::list<Triangle> &triangles);
static const Triangle* findNearestTriangle(const std::list<Triangle> &triangles, const vmml::vec3f &v);
};
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;
-}
diff --git a/Cubehole.h b/Cubehole.h
index 9da2026..c8e8736 100644
--- a/Cubehole.h
+++ b/Cubehole.h
@@ -1,6 +1,7 @@
#ifndef _CUBEHOLE_H_
#define _CUBEHOLE_H_
+#include "Trapezocube.h"
#include "Triangle.h"
#include <list>
@@ -9,43 +10,65 @@ class Cubehole
{
public:
Cubehole(): width(0), height(0), depth(0), x(0), y(0), z(0), innerwidth(0), innerdepth(0) {}
- Cubehole(float width, float height, float depth): x(0), y(0), z(0), innerwidth(0), innerdepth(0){
- setSize(width, height, depth);
- }
- Cubehole(float width, float height, float depth, float x, float y, float z): innerwidth(0), innerdepth(0) {
- setSize(width, height, depth);
- setPos(x, y, z);
- }
- Cubehole(float width, float height, float depth, float x, float y, float z, float innerwidth, float innerdepth) {
- setSize(width, height, depth);
- setPos(x, y, z);
- setInnerSize(innerwidth, innerdepth);
+
+ Cubehole(float width0, float height0, float depth0, float x0, float y0, float z0,
+ float innerwidth0, float innerdepth0,
+ const vmml::vec4f &colorfront0, const vmml::vec4f &colorright0,
+ const vmml::vec4f &colorback0, const vmml::vec4f &colorleft0) {
+ setSize(width0, height0, depth0, innerwidth0, innerdepth0);
+ setPos(x0, y0, z0);
+ setColor(colorfront0, colorright0, colorback0, colorleft0);
+ front.setRotate(0);
+ right.setRotate(90);
+ back.setRotate(180);
+ left.setRotate(270);
}
+
float getHeight();
float getWidth();
float getDepth();
float getPosX();
float getPosY();
float getPosZ();
- float getInnerWidth()
- {
- return innerwidth;
- }
- float getInnerDepth()
- {
- return innerdepth;
- }
- void setInnerSize(float iw, float id)
- {
+
+ float getInnerWidth() {return innerwidth;}
+ float getInnerDepth() {return innerdepth;}
+
+ void setSize(float w, float h, float d, float iw, float id){
+ width = w;
+ height = h;
+ depth = d;
innerwidth = iw;
innerdepth = id;
+ front.setSize(width, innerwidth, height, (depth-innerdepth)/2);
+ right.setSize(width, innerdepth, height, (width-innerwidth)/2);
+ back.setSize(width, innerwidth, height, (depth-innerdepth)/2);
+ left.setSize(width, innerdepth, height, (width-innerwidth)/2);
+ }
+
+ void setPos(float x0, float y0, float z0) {
+ x = x0;
+ y = y0;
+ z = z0;
+ front.setPos(x, y, depth-(depth-innerdepth)/2);
+ right.setPos(x, y, width-(width-innerwidth)/2);
+ back.setPos(x, y, depth-(depth-innerdepth)/2);
+ left.setPos(x, y, width-(width-innerwidth)/2);
}
- void setSize(float w, float h, float d);
- void setPos(float x, float y, float z);
- std::list<Triangle> getTriangles(/*const Matrix &modelview*/);
+
+ void setColor(const vmml::vec4f &cf, const vmml::vec4f &cr, const vmml::vec4f &cb, const vmml::vec4f &cl) {
+ front.setColor(cf);
+ right.setColor(cr);
+ back.setColor(cb);
+ left.setColor(cl);
+ }
+
+ std::list<Triangle> getTriangles();
private:
float x, y, z, width, height, depth, innerwidth, innerdepth;
+ vmml::vec4f colorfront, colorleft, colorback, colorright;
+ Trapezocube front, right, back, left;
};
diff --git a/Cuboid.cpp b/Cuboid.cpp
index 5b1af49..5afae93 100644
--- a/Cuboid.cpp
+++ b/Cuboid.cpp
@@ -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,7 +56,7 @@ 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
diff --git a/Cuboid.h b/Cuboid.h
index 7c4b4c5..25d9f73 100644
--- a/Cuboid.h
+++ b/Cuboid.h
@@ -19,7 +19,7 @@ class Cuboid
float getPosZ();
void setSize(float w, float h, float d);
void setPos(float x, float y, float z);
- std::list<Triangle> getTriangles(/*const Matrix &modelview*/);
+ std::list<Triangle> getTriangles();
private:
float width, height, depth;
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index cf7a0f9..6d9fdee 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -5,16 +5,12 @@
DisplayClass::Renderer DisplayClass::renderer;
-
DisplayClass::DisplayClass() {
- cubeing[0] = Trapezocube(11.0, 10.0, 10.0, 0.5, 0.0, 0.0, 1.75, 0);
- cubeing[1] = Trapezocube(10.0, 9.0, 9.0, 0.5, 0.0, 0.0, 2.25, 90);
- cubeing[2] = Trapezocube(9.0, 8.0, 8.0, 0.5, 0.0, 0.0, 2.75, 180);
- cubeing[3] = Trapezocube(8.0, 7.0, 7.0, 0.5, 0.0, 0.0, 3.25, 270);
- cubeing[4] = Trapezocube(7.0, 6.0, 6.0, 0.5, 0.0, 0.0, 3.75, 0);
- cubeing[5] = Trapezocube(6.0, 5.0, 5.0, 0.5, 0.0, 0.0, 4.25, 90);
- cubeing[6] = Trapezocube(5.0, 4.0, 4.0, 0.5, 0.0, 0.0, 4.75, 180);
- cubeing[7] = Trapezocube(4.0, 3.0, 3.0, 0.5, 0.0, 0.0, 5.25, 270);
+ cubehole = Cubehole(3.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.5,
+ vmml::vec4f(1.0, 0.0, 0.0),
+ vmml::vec4f(0.0, 1.0, 0.0),
+ vmml::vec4f(0.0, 0.0, 1.0),
+ vmml::vec4f(1.0, 0.85, 0.06));
}
void DisplayClass::renderScene(unsigned long delta)
@@ -27,20 +23,15 @@ void DisplayClass::renderScene(unsigned long delta)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Clean up matrix
- glTranslatef(0.0, 0.0, -30.0); // Then set up transformation
+ glTranslatef(0.0, 0.0, -10.0); // Then set up transformation
glRotatef(angle, 0.0, 1.0, 0.0);
glRotatef(angle*2, 1.0, 0.0, 0.0);
glRotatef(angle*3, 0.0, 0.0, 1.0);
glRotatef(-angle*5, 1.0, 1.0, 1.0);
- std::list<Triangle> triangles;
-
- for(int i = 0; i < 8; ++i) {
- std::list<Triangle> t = cubeing[i].getTriangles();
- triangles.splice(triangles.end(), t);
- }
-
+ std::list<Triangle> triangles = cubehole.getTriangles();
+
BSPTree tree(triangles);
vmml::mat4f transform, inverseTransform;
@@ -48,7 +39,7 @@ void DisplayClass::renderScene(unsigned long delta)
transform.inverse(inverseTransform);
- vmml::vec3f viewPoint = inverseTransform*vmml::vec3f(0, 0, 0);
+ vmml::vec3f viewPoint = inverseTransform*vmml::vec3f::ZERO;
glBegin(GL_TRIANGLES);
tree.visit(renderer, viewPoint);
diff --git a/DisplayClass.h b/DisplayClass.h
index 0b24dc6..04ff651 100644
--- a/DisplayClass.h
+++ b/DisplayClass.h
@@ -1,7 +1,7 @@
#ifndef _DISPLAYCLASS_H_
#define _DISPLAYCLASS_H_
-#include "Trapezocube.h"
+#include "Cubehole.h"
class DisplayClass
{
@@ -19,7 +19,7 @@ class DisplayClass
static Renderer renderer;
- Trapezocube cubeing[8];
+ Cubehole cubehole;
};
#endif /*_DISPLAYCLASS_H_*/
diff --git a/Trapezocube.cpp b/Trapezocube.cpp
index bfb82c3..8205ee6 100644
--- a/Trapezocube.cpp
+++ b/Trapezocube.cpp
@@ -1,7 +1,7 @@
#include "Trapezocube.h"
-std::list<Triangle> Trapezocube::getTriangles(/*const Matrix &modelview*/)
+std::list<Triangle> Trapezocube::getTriangles()
{
std::list<Triangle> triangles;
// width, height, depth
@@ -75,7 +75,6 @@ std::list<Triangle> Trapezocube::getTriangles(/*const Matrix &modelview*/)
for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
t->transform(rotation);
- //t->transform(modelview);
}
return triangles;
diff --git a/Trapezocube.h b/Trapezocube.h
index 694ecde..c291e21 100644
--- a/Trapezocube.h
+++ b/Trapezocube.h
@@ -9,17 +9,12 @@ class Trapezocube
{
public:
Trapezocube(): widthfront(0), widthback(0), height(0), depth(0), x(0), y(0), z(0), rotate(0) {}
- Trapezocube(float widthfront, float widthback, float height, float depth): x(0), y(0), z(0), rotate(0){
- setSize(widthfront, widthback, height, depth);
- }
- Trapezocube(float widthfront, float widthback, float height, float depth, float x, float y, float z): rotate(0) {
- setSize(widthfront, widthback, height, depth);
- setPos(x, y, z);
- }
- Trapezocube(float widthfront, float widthback, float height, float depth, float x, float y, float z, float rotate) {
+
+ Trapezocube(float widthfront, float widthback, float height, float depth, float x, float y, float z, float rotate, const vmml::vec4f &col) {
setSize(widthfront, widthback, height, depth);
setPos(x, y, z);
setRotate(rotate);
+ setColor(col);
}
float getHeight() {return height;}
float getWidthFront() {return widthfront;}
@@ -29,6 +24,8 @@ class Trapezocube
float getPosY() {return y;}
float getPosZ() {return z;}
float getRotate() {return rotate;}
+ vmml::vec4f getColor() {return color;}
+
void setSize(float wf, float wb, float h, float d)
{
widthfront = wf;
@@ -44,7 +41,7 @@ class Trapezocube
}
void setRotate(float r) {rotate = r;}
void setColor(const vmml::vec4f &col) {color = col;}
- std::list<Triangle> getTriangles(/*const Matrix &modelview*/);
+ std::list<Triangle> getTriangles();
private:
float x, y, z, widthfront, widthback, height, depth, rotate;
diff --git a/Triangle.h b/Triangle.h
index dc48071..febcb3d 100644
--- a/Triangle.h
+++ b/Triangle.h
@@ -24,6 +24,7 @@ class Triangle
}
void render() const {
+ glColor4fv(c.array);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c.array);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (c/2).array);