/* model/model.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_MODEL_H__ #define __INCLUDED_MODEL_MODEL_H__ #include #include #include #include "math/mathlib.h" #include "model/engine.h" #include "model/light.h" #include "model/flare.h" /// classes representing 3D geometry namespace model { /// scaling factor when loading .map geometry const float SCALE = 1.0f / 1024.0f; /// a 3D model contains a list of faces class Model { public: /// load a model from disk Model(std::string const & name); ~Model(); /// the name of the model inline std::string const & name() const { return model_name; } /// maximum values of the bounding box inline math::Vector3f const & maxbbox() const { return model_maxbbox; } /// minimum values of the bounding box inline math::Vector3f const & minbbox() const { return model_minbbox; } /// first vertex in the global VertexArray inline size_t first_vertex() const { return model_first_vertex; } /// number of structural vertices in this model inline size_t vertex_structural() const { return model_vertex_count; } /// number of detail vertices inline size_t vertex_detail() const { return model_vertex_countdetail; } /// first evertex in the global VertexArray inline size_t first_evertex() const { return model_first_evertex; } /// number of structural evertices in this model inline size_t evertex_structural() const { return model_evertex_count; } /// number of detail evertices in this model inline size_t evertex_detail() const { return model_evertex_countdetail; } /// first lvertex in the global VertexArray inline size_t first_lvertex() const { return model_first_lvertex; } /// number of structural lvertices in this model inline size_t lvertex_structural() const { return model_lvertex_count; } /// number of detail evertices in this model inline size_t lvertex_detail() const { return model_lvertex_countdetail; } /// engine sound loop for this model inline unsigned int enginesound() const { return model_enginesound; } /// total number of triangles in this model size_t tris() const; /// number of detail triangles in this model size_t details() const; /// radius inline float radius() const { return model_radius; } /// list of Engines std::list model_engine; /// add an engine to the model void add_engine(Engine *engine); /// list of Lights std::list model_light; /// add a light to the model void add_light(Light *light); /// list of flares std::list model_flare; /// add a flare to the model void add_flare(Flare *flare); std::string model_name; float model_radius; math::Vector3f model_maxbbox; math::Vector3f model_minbbox; size_t model_first_vertex; size_t model_vertex_count; size_t model_vertex_countdetail; size_t model_first_evertex; size_t model_evertex_count; size_t model_evertex_countdetail; size_t model_first_lvertex; size_t model_lvertex_count; size_t model_lvertex_countdetail; unsigned int model_enginesound; /* ---- static functions for the Model registry -------------------- */ /// the Model registry static std::map 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(); }; } #endif // __INCLUDED_MODEL_MODEL_H__