/* 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 #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() const { return face_detail; } /// surface flags inline unsigned int surface_flags() const { return face_surface_flags; } /** * @brief return texture transformation vectors * @param index 0 <= i < 2 */ inline const math::Vector3f &tex_vec(size_t index) { return face_tex_vec[index]; } /// return texture shift inline const math::Vector2f &tex_shift() { return face_tex_shift; } inline void set_material(Material *material) { face_material = material; } inline void set_detail(const bool detail = true) { face_detail = detail; } inline void set_surface_flags(const unsigned int flags) { face_surface_flags = flags; } /** * @brief return texture transformation vectors * @param index 0 <= i < 2 */ inline math::Vector3f &get_tex_vec(size_t index) { return face_tex_vec[index]; } /// return texture shift inline math::Vector2f &get_tex_shift() { return face_tex_shift; } 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__