From da66d49b8a7bcc808df201bee5c7cb787b6f30b7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 13 Dec 2009 18:49:36 +0100 Subject: Basic infrastructure --- Triangle.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Triangle.h (limited to 'Triangle.h') diff --git a/Triangle.h b/Triangle.h new file mode 100644 index 0000000..16b0d73 --- /dev/null +++ b/Triangle.h @@ -0,0 +1,47 @@ +#ifndef ZOOM_TRIANGLE_H_ +#define ZOOM_TRIANGLE_H_ + +#include "gl.h" +#include +#include + +namespace Zoom { + +class Triangle { + public: + Triangle() : c(vmml::vec4f::ONE) { + v[0] = v[1] = v[2] = vmml::vec3f::ZERO; + } + + Triangle(const vmml::vec3f &v1, const vmml::vec3f &v2, const vmml::vec3f &v3, const vmml::vec4f &c0) : c(c0) { + v[0] = v1; + v[1] = v2; + v[2] = v3; + } + + const vmml::vec3f& getVertex(int i) const {return v[i];} + const vmml::vec4f& getColor() const {return c;} + + vmml::vec3f getNormal() const { + return v[0].compute_normal(v[1], v[2]); + } + + void transform(const vmml::mat4f &m) { + for(int i = 0; i < 3; ++i) { + v[i] = m*v[i]; + } + } + + vmml::vec3f getCenter() const { + return (v[0]+v[1]+v[2])/3; + } + + private: + vmml::vec3f v[3]; + vmml::vec4f c; +}; + +} + +#endif /*ZOOM_TRIANGLE_H_*/ + -- cgit v1.2.3