diff options
Diffstat (limited to 'src/model/model.h')
-rw-r--r-- | src/model/model.h | 88 |
1 files changed, 26 insertions, 62 deletions
diff --git a/src/model/model.h b/src/model/model.h index f94c170..f13c466 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -7,48 +7,20 @@ #ifndef __INCLUDED_MODEL_MODEL_H__ #define __INCLUDED_MODEL_MODEL_H__ -#include <vector> -#include <map> +#include <string> #include <list> +#include <map> #include "math/mathlib.h" -#include "math/plane3f.h" #include "model/engine.h" #include "model/light.h" -#include "model/vertexarray.h" +/// classes representing 3D geometry namespace model { -/// a model triangle -class Triangle -{ -public: - /// a new triangle with 3 vertices, a normal, color and a detail flag - Triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &n, - math::Color *color=0, bool detail=false); - ~Triangle(); - - /// normal of the triangle - inline math::Vector3f const & normal() const { return triangle_normal; } - /// color of the triangle - inline math::Color const & color() const { return triangle_color;} - /// indidcates if this triangle was generated from a detail brush - inline bool detail() const { return triangle_detail; } - - /// triangle vertex 0 - math::Vector3f triangle_v0; - /// triangle vertex 1 - math::Vector3f triangle_v1; - /// triangle vertex 2 - math::Vector3f triangle_v2; - -private: - math::Vector3f triangle_normal; - math::Color triangle_color; - bool triangle_detail; -}; - +/// scaling factor when loading .map geometry +const float SCALE = 1.0f / 1024.0f; /// a 3D model contains a list of faces class Model @@ -97,49 +69,24 @@ public: /// radius inline float radius() const { return model_radius; } - /// the Model registry - static std::map<std::string, Model*> registry; - - /* ---- static functions for the Model registry -------------------- */ - - /// get name model, returns 0 if not found - static Model *find(std::string const & name); - - /// get named model from the registry and load it if necessary - static Model *get(std::string const & name); - - /// clear the model registry - static void clear(); - - /// list the content of the model registry - static void list(); - /// list of Engines std::list<Engine *> model_engine; + /// add an engine to the model + void add_engine(Engine *engine); + /// list of Lights std::list<Light *> model_light; - - -private: - void make_face(math::Plane3f *face, std::vector<math::Plane3f *> & planes, bool detail); - void add_engine(Engine *engine); + /// add a light to the model void add_light(Light *light); std::string model_name; - float model_radius; - float model_scale; - bool model_valid; math::Vector3f model_maxbbox; math::Vector3f model_minbbox; - // tmp lists with triangles - std::list<Triangle *> model_tris; - std::list<Triangle *> model_etris; - size_t model_first_vertex; size_t model_vertex_count; size_t model_vertex_countdetail; @@ -147,6 +94,23 @@ private: size_t model_first_evertex; size_t model_evertex_count; size_t model_evertex_countdetail; + + /* ---- static functions for the Model registry -------------------- */ + + /// the Model registry + static std::map<std::string, Model*> registry; + + /// get name model, returns 0 if not found + static Model *find(std::string const & name); + + /// get named model from the registry and load it if necessary + static Model *load(std::string const & name); + + /// clear the model registry + static void clear(); + + /// list the content of the model registry + static void list(); }; } |