/* render/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_CORE_MODEL_H__ #define __INCLUDED_CORE_MODEL_H__ #include #include #include #include "math/mathlib.h" #include "math/plane3f.h" #include "core/entity.h" namespace core { /// one face (polygon) of a model class Face { public: Face(math::Vector3f const & normal, math::Color const *color=0); ~Face(); /// the normal of this face inline math::Vector3f const & normal() const { return face_normal; }; /// the color of this face inline math::Color const *color() const { return face_color; }; /// add a vertex to the face void add_vertex(math::Vector3f const &vertex); /// face vertexes std::vector face_vertex; private: math::Vector3f face_normal; math::Color *face_color; }; /// a spacecraft engine class Engine { public: Engine(math::Vector3f const & location); ~Engine(); inline math::Vector3f const & location() const { return engine_location; } private: math::Vector3f engine_location; }; /// 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; } /// the Model registry static std::map 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 Faces std::list model_face; /// list of Engines std::list model_engine; private: void make_face(math::Plane3f *face, std::vector & planes); void add_engine(Engine *engine); void add_face(Face *face); std::string model_name; float model_scale; bool model_valid; }; } #endif // __INCLUDED_RENDER_MODEL_H__