summaryrefslogtreecommitdiffstats
path: root/Triangle.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-11-27 20:47:58 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-11-27 20:47:58 +0100
commit59360094e5ac1ddeb5eda365ac4ccf765786635f (patch)
tree4ddf107804febdfb4550a0e616a07945c65c5e96 /Triangle.h
downloadc3d-59360094e5ac1ddeb5eda365ac4ccf765786635f.tar
c3d-59360094e5ac1ddeb5eda365ac4ccf765786635f.zip
Initial commit
Diffstat (limited to 'Triangle.h')
-rw-r--r--Triangle.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/Triangle.h b/Triangle.h
new file mode 100644
index 0000000..807b5b9
--- /dev/null
+++ b/Triangle.h
@@ -0,0 +1,45 @@
+#ifndef _TRIANGLE_H_
+#define _TRIANGLE_H_
+
+#include "gl.h"
+#include "Color.h"
+#include "Vector.h"
+#include "Vertex.h"
+#include "Matrix.h"
+
+class Triangle
+{
+ public:
+ Triangle(const Vertex &v1, const Vertex &v2, const Vertex &v3, const Color &c0) : c(c0)
+ {
+ v[0] = v1;
+ v[1] = v2;
+ v[2] = v3;
+ }
+
+ const Vertex& getVertex(int i) const {return v[i];}
+ const Color& getColor() const {return c;}
+
+ void render() const {
+ glColor4f(c.getR(), c.getG(), c.getB(), c.getA());
+
+ for(int i = 0; i < 3; ++i)
+ {
+ glVertex3f(v[i].getX(), v[i].getY(), v[i].getZ());
+ }
+ }
+
+ void transform(const Matrix &m) {
+ for(int i = 0; i < 3; ++i)
+ {
+ v[i] = m*v[i];
+ }
+ }
+
+ private:
+ Vertex v[3];
+ Color c;
+};
+
+#endif /*_TRIANGLE_H_*/
+