diff options
author | Stijn Buys <ingar@osirion.org> | 2008-03-06 21:49:54 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-03-06 21:49:54 +0000 |
commit | d1b9fa9ebb493674c95983fe690bffb730b1ece2 (patch) | |
tree | 1de0975318cb41835f87c0a27f76e5f7c60ca7b7 /src/core/model.h | |
parent | c3d56342784bd97cce666f24539db31cbd5506d9 (diff) |
moving model to core
Diffstat (limited to 'src/core/model.h')
-rw-r--r-- | src/core/model.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/core/model.h b/src/core/model.h new file mode 100644 index 0000000..eca896b --- /dev/null +++ b/src/core/model.h @@ -0,0 +1,93 @@ +/* + 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_RENDER_MODEL_H__ +#define __INCLUDED_RENDER_MODEL_H__ + +#include <map> +#include <list> + +#include "math/plane3f.h" +#include "core/entity.h" +#include "render/face.h" + +namespace render +{ + +/// 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<std::string, Model*> registry; + + /// draw the model for an entity + /** This will not draw attached engines, turrents and cannons + */ + void draw(core::Entity const * entity, math::Vector3f const & eye); + + /// draw the model for a controlable enity + /** This will draw all attached engines, turrents and cannons + */ + void draw(core::EntityControlable const * entity, math::Vector3f const & eye); + + /* ---- 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(); + +private: + void make_face(math::Plane3f *face, std::vector<math::Plane3f *> & planes); + void add_engine(Engine *engine); + void add_face(Face *face); + + std::list<Face *> model_face; + std::list<Engine *> model_engine; + std::string model_name; + + float model_scale; + +}; + +} + +#endif // __INCLUDED_RENDER_MODEL_H__ + |