/* 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/collisionmodel.h" #include "model/tags.h" #include "model/fragment.h" /// classes representing 3D geometry namespace model { /// scaling factor when loading model geometry const float SCALE = 1.0f / 1024.0f; const float ANGLEUP = -1.0f; const float ANGLEDOWN = -2.0f; /// a 3D model contains a list of faces class Model { public: /// type definition for the model registry typedef std::map Registry; /// type definition for a list of model fragments typedef std::list Fragments; /// type definition for a list of model light tags typedef std::list Lights; /// type definition for a list of model flare tags typedef std::list Flares; /// type definition for a list of model slot tags typedef std::list Slots; /// type definition for a list of model particle system tags typedef std::list ParticleSystems; /// type definition for a list of model sound tags typedef std::list Sounds; /// type definition for a list of FragmentGroups typedef std::list Groups; /// create a model with a name Model(const std::string & name); /// delete the model, and all fragments, lights, etc ~Model(); /// the name of the model inline const std::string & name() const { return model_name; } /// radius inline float radius() const { return model_radius; } /// print information about the model to console void print() const; /// model fragment groups inline Groups & groups() { return model_groups; } /// associated collisionmodel inline CollisionModel *collisionmodel() { return model_collisionmodel; } /// list of model light tags inline Lights & lights() { return model_lights; } /// list of model slot tags inline Slots & slots() { return model_slots; } /// list of model flare tags inline Flares & flares() { return model_flares; } /// list of model sound tags inline Sounds & sounds() { return model_sounds; } /// list of model particle system tags inline ParticleSystems & particles() { return model_particles; } inline const math::BoundingBox3f & box() const { return model_box; } /// engine sound loop for this model inline unsigned int enginesound() const { return model_enginesound; } /// impulse sound set for this model inline unsigned int impulsesound() const { return model_impulsesound; } /// engine color for this model inline const math::Color & enginecolor() const { return model_enginecolor; } /// original model origin inline const math::Vector3f & origin() const { return model_origin; } /// add a light tag to the model void add_light(Light *light); /// add a particle system tag to the model void add_particles(Particles *particles); /// add a flare tag to the model void add_flare(Flare *flare); /// add a slot tag to the model void add_slot(Slot *slot); /// add a sound tag to the model void add_sound(Sound *sound); /// add a fragment group to the model void add_group(FragmentGroup *group); /// set model radius void set_radius(const float radius); /// set collision model void set_collisionmodel(CollisionModel *collisionmodel); /// set model origin void set_origin(const math::Vector3f &origin); math::Vector3f model_origin; math::BoundingBox3f model_box; unsigned int model_enginesound; unsigned int model_impulsesound; math::Color model_enginecolor; /// total number of triangles size_t model_tris_count; /// number of detail triangles size_t model_tris_detail_count; /// total number of quads size_t model_quad_count; /// number of detail quads size_t model_quad_detail_count; /* ---- static functions for the Model registry -------------------- */ /// the model registry static inline Registry & registry() { return model_registry; } /// search the model registry static Model *find(const std::string & name); /// search the model registry for a partial name static Model *search(const std::string & searchname); /** * @brief load a model * If the model has already been loaded, a pointer to the existing instance will be returned * */ static Model *load(const std::string & name); /// clear the model registry static void clear(); /// list the content of the model registry static void list(); private: /** * @brief sort model tags according to location * */ void sort(); std::string model_name; Slots model_slots; Flares model_flares; Sounds model_sounds; Lights model_lights; ParticleSystems model_particles; Groups model_groups; float model_radius; CollisionModel *model_collisionmodel; static Registry model_registry; }; } #endif // __INCLUDED_MODEL_MODEL_H__