Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-12 12:03:18 +0000
committerStijn Buys <ingar@osirion.org>2009-08-12 12:03:18 +0000
commit183f0f0b905715f0d89b38174fdfd44641c1a79c (patch)
tree6cae553ac6284044002fb668c7991da27291825d /src/model/face.h
parent8bf8afe68ca15c61b0dea1f5c1ef5fc7186dca0f (diff)
src/model filenames cleanup, parse .map texture coordinates, early loading of material textures
Diffstat (limited to 'src/model/face.h')
-rw-r--r--src/model/face.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/model/face.h b/src/model/face.h
new file mode 100644
index 0000000..8c75522
--- /dev/null
+++ b/src/model/face.h
@@ -0,0 +1,113 @@
+/*
+ model/face.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_MODEL_FACE_H__
+#define __INCLUDED_MODEL_FACE_H__
+
+#include <string>
+
+#include "math/vector2f.h"
+#include "math/vector3f.h"
+#include "model/material.h"
+
+namespace model
+{
+
+/** @brief A class representing the plane of a single model face
+ * all points p(x, y, z) on the plane satisfy the general equation
+ * x*a() + y*b() + z*c() + d() = 0
+ */
+class Face
+{
+public:
+ /// a plane defined by 3 points in space
+ Face(math::Vector3f const & point0, math::Vector3f const &point1, math::Vector3f const &point2);
+
+ /// copy constructor
+ Face(Face const & other);
+
+ /// normal of the plane, not normalized to lenght 1
+ inline math::Vector3f const & normal() const
+ {
+ return face_normal;
+ }
+
+ /// the points defining the plane.
+ /// @param index 0 <= i < 3
+ inline math::Vector3f const & point(size_t index) const
+ {
+ return face_point[index];
+ }
+
+ /// face material
+ inline Material *material() const
+ {
+ return face_material;
+ }
+
+ /// first parameter of the general plane equation
+ inline float a() const
+ {
+ return face_normal[0];
+ }
+
+ /// second parameter of the general plane equation
+ inline float b() const
+ {
+ return face_normal[1];
+ }
+
+ /// third param of the general plane equation
+ inline float c() const
+ {
+ return face_normal[2];
+ }
+
+ /// fourth parameter of the general plane equation
+ inline float d() const
+ {
+ return pd;
+ }
+
+ /// indidcates if this plane was generated from a detail brush
+ inline bool & detail()
+ {
+ return face_detail;
+ }
+
+ /// surface flags
+ inline unsigned int & surface_flags()
+ {
+ return face_surface_flags;
+ }
+
+ /// return texture transformation vectors
+ /// @param index 0 <= i < 2
+ inline math::Vector3f &tex_vec(size_t index) { return face_tex_vec[index]; }
+
+ /// return texture shift
+ inline math::Vector2f &tex_shift() { return face_tex_shift; }
+
+
+ inline void set_material(Material *material) { face_material = material; }
+
+
+private:
+ math::Vector3f face_normal;
+ math::Vector3f face_point[3];
+
+ math::Vector3f face_tex_vec[2];
+ math::Vector2f face_tex_shift;
+
+ Material *face_material;
+ unsigned int face_surface_flags;
+ bool face_detail;
+ float pd;
+};
+
+}
+
+#endif // __INCLUDED_MODEL_FACE_H__