Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/model.h')
-rw-r--r--src/model/model.h179
1 files changed, 100 insertions, 79 deletions
diff --git a/src/model/model.h b/src/model/model.h
index d2b7d65..552d7dd 100644
--- a/src/model/model.h
+++ b/src/model/model.h
@@ -13,6 +13,7 @@
#include "math/mathlib.h"
#include "model/engine.h"
+#include "model/fragment.h"
#include "model/light.h"
#include "model/flare.h"
@@ -20,15 +21,29 @@
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
+ /// type definition for the model registry
+ typedef std::map<std::string, Model*> Registry;
+
+ /// type definition for a list of model fragments
+ typedef std::list<Fragment *> Fragments;
+
+ /// type definition for a list of model lights
+ typedef std::list<Light *> Lights;
+
+ /// type definition for a list of model flares
+ typedef std::list<Flare *> Flares;
+
+ /// type definition for a list of model engines
+ typedef std::list<Engine *> Engines;
+
+ /// create a model with a name
Model(std::string const & name);
+
+ /// delete the model, and all fragments, lights, etc
~Model();
/// the name of the model
@@ -36,95 +51,79 @@ public:
{
return model_name;
}
-
+
+ /// radius
+ inline float radius() const
+ {
+ return model_radius;
+ }
+
+ /// list of fragments
+ inline Fragments & fragments()
+ {
+ return model_fragments;
+ }
+
+ /// list of lights
+ inline Lights & lights()
+ {
+ return model_lights;
+ }
+
+ /// list of flares
+ inline Flares & flares()
+ {
+ return model_flares;
+ }
+
+ /// list of engines
+ inline Engines & engines()
+ {
+ return model_engines;
+ }
+
/// maximum values of the bounding box
- inline math::Vector3f const & maxbbox() const { return model_maxbbox; }
+ 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; }
-
+ inline math::Vector3f const & minbbox() const
+ {
+ return model_minbbox;
+ }
+
/// 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<Engine *> model_engine;
-
- /// add an engine to the model
- void add_engine(Engine *engine);
-
- /// list of Lights
- std::list<Light *> model_light;
-
+ inline unsigned int & enginesound()
+ {
+ return model_enginesound;
+ }
+
/// add a light to the model
void add_light(Light *light);
-
- /// list of flares
- std::list<Flare *> model_flare;
-
+
+ /// add an engine to the model
+ void add_engine(Engine *engine);
+
/// 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<std::string, Model*> registry;
-
+
+ /// the model registry
+ static inline Registry & registry()
+ {
+ return model_registry;
+ }
+
/// get name model, returns 0 if not found
static Model *find(std::string const & name);
@@ -136,6 +135,28 @@ public:
/// list the content of the model registry
static void list();
+
+ /// list one model
+ static void list_model(Model *model);
+
+ /// 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;
+
+private:
+ static Registry model_registry;
+
+ std::string model_name;
+
+ Fragments model_fragments;
+ Flares model_flares;
+ Engines model_engines;
+ Lights model_lights;
};
}