Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/mapfile.cc71
-rw-r--r--src/model/parts.cc16
-rw-r--r--src/model/parts.h183
3 files changed, 185 insertions, 85 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 271af06..36dc536 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -920,6 +920,7 @@ Model * MapFile::load(std::string const &name)
std::string modelname;
math::Vector3f location;
+ math::Color color;
typedef std::list<SubModel *> SubModelList;
SubModelList submodel_list;
@@ -1021,17 +1022,17 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.classname().compare("light") == 0) {
// light attributes
- if (mapfile.got_key_vector3f("origin", light->light_location)) {
- light->light_location *= SCALE;
+ if (mapfile.got_key_vector3f("origin", location)) {
+ light->set_location(location * SCALE);
continue;
} else if (mapfile.got_key_color("_color", light->light_color)) {
continue;
} else if (mapfile.got_key_int("spawnflags", u)) {
- light->light_strobe = spawnflag_isset(u, 1);
- light->light_entity = spawnflag_isset(u, 2);
- light->light_engine = spawnflag_isset(u, 4);
+ light->set_strobe(spawnflag_isset(u, 1));
+ light->set_entity(spawnflag_isset(u, 2));
+ light->set_engine(spawnflag_isset(u, 4));
} else if (mapfile.got_key_float("light", light->light_radius)) {
light->light_radius *= LIGHTSCALE;
@@ -1105,17 +1106,17 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.classname().compare("fx_flare") == 0) {
// flare attributes
- if (mapfile.got_key_vector3f("origin", flare->light_location)) {
- flare->light_location *= SCALE;
+ if (mapfile.got_key_vector3f("origin", location)) {
+ flare->set_location(location * SCALE);
continue;
} else if (mapfile.got_key_color("_color", flare->light_color)) {
continue;
} else if (mapfile.got_key_int("spawnflags", u)) {
- flare->light_strobe = spawnflag_isset(u, 1);
- flare->light_entity = spawnflag_isset(u, 2);
- flare->flare_engine = spawnflag_isset(u, 4);
+ flare->set_strobe(spawnflag_isset(u, 1));
+ flare->set_entity(spawnflag_isset(u, 2));
+ flare->set_engine(spawnflag_isset(u, 4));
} else if (mapfile.got_key_float("radius", flare->light_radius)) {
flare->light_radius *= LIGHTSCALE;
@@ -1134,30 +1135,30 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
- flare->flare_axis.change_pitch(90.0f);
+ flare->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
- flare->flare_axis.change_pitch(-90.0f);
+ flare->get_axis().change_pitch(-90.0f);
} else {
- flare->flare_axis.change_direction(angle);
+ flare->get_axis().change_direction(angle);
}
} else if (mapfile.got_key_float("direction", angle)) {
- flare->flare_axis.change_direction(angle);
+ flare->get_axis().change_direction(angle);
} else if (mapfile.got_key_float("pitch", angle)) {
- flare->flare_axis.change_pitch(angle);
+ flare->get_axis().change_pitch(angle);
} else if (mapfile.got_key_float("roll", angle)) {
- flare->flare_axis.change_roll(angle);
+ flare->get_axis().change_roll(angle);
} else if (mapfile.got_key_string("cull", str)) {
aux::to_lowercase(str);
if (str.compare("none") == 0) {
- flare->flare_cull = CullNone;
+ flare->set_cull(CullNone);
} else if (str.compare("back") == 0) {
- flare->flare_cull = CullBack;
+ flare->set_cull(CullBack);
} else if (str.compare("front") == 0) {
- flare->flare_cull = CullFront;
+ flare->set_cull(CullFront);
} else {
mapfile.unknown_value();
}
@@ -1215,31 +1216,31 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.classname().compare("fx_particles") == 0) {
// particle system attributes
- if (mapfile.got_key_vector3f("origin", particles->particles_location)) {
- particles->particles_location *= SCALE;
+ if (mapfile.got_key_vector3f("origin", location)) {
+ particles->set_location(location * SCALE);
continue;
} else if (mapfile.got_key_string("script", particles->particles_script)) {
continue;
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
- particles->particles_axis.change_pitch(90.0f);
+ particles->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
- particles->particles_axis.change_pitch(-90.0f);
+ particles->get_axis().change_pitch(-90.0f);
} else {
- particles->particles_axis.change_direction(angle);
+ particles->get_axis().change_direction(angle);
}
} else if (mapfile.got_key_float("direction", angle)) {
- particles->particles_axis.change_direction(angle);
+ particles->get_axis().change_direction(angle);
} else if (mapfile.got_key_float("pitch", angle)) {
- particles->particles_axis.change_pitch(angle);
+ particles->get_axis().change_pitch(angle);
} else if (mapfile.got_key_float("roll", angle)) {
- particles->particles_axis.change_roll(angle);
+ particles->get_axis().change_roll(angle);
} else if (mapfile.got_key_int("spawnflags", u)) {
- particles->particles_entity = spawnflag_isset(u, 2);
- particles->particles_engine = spawnflag_isset(u, 4);
+ particles->set_entity(spawnflag_isset(u, 2));
+ particles->set_engine(spawnflag_isset(u, 4));
} else if (mapfile.got_key_float("radius", r)) {
particles->set_radius(r * LIGHTSCALE);
@@ -1248,11 +1249,11 @@ Model * MapFile::load(std::string const &name)
aux::to_lowercase(str);
if (str.compare("none") == 0) {
- particles->particles_cull = CullNone;
+ particles->set_cull(CullNone);
} else if (str.compare("back") == 0) {
- particles->particles_cull = CullBack;
+ particles->set_cull(CullBack);
} else if (str.compare("front") == 0) {
- particles->particles_cull = CullFront;
+ particles->set_cull(CullFront);
} else {
mapfile.unknown_value();
}
@@ -1269,15 +1270,15 @@ Model * MapFile::load(std::string const &name)
// reposition docks, lights, flares and particles according to the model center
for (Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) {
- (*lit)->light_location -= mapfile.map_center;
+ (*lit)->get_location() -= mapfile.map_center;
}
for (Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); flit++) {
- (*flit)->light_location -= mapfile.map_center;
+ (*flit)->get_location() -= mapfile.map_center;
}
for (Model::ParticleSystems::iterator pit = model->particles().begin(); pit != model->particles().end(); pit++) {
- (*pit)->particles_location -= mapfile.map_center;
+ (*pit)->get_location() -= mapfile.map_center;
}
for (Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) {
diff --git a/src/model/parts.cc b/src/model/parts.cc
index d4ff20b..bcd8446 100644
--- a/src/model/parts.cc
+++ b/src/model/parts.cc
@@ -11,17 +11,20 @@ namespace model {
/* ---- class Light ------------------------------------------------ */
Light::Light() :
- light_location(),
+ Part(),
light_color(1.0f, 1.0f, 1.0f)
{
light_entity = false;
+ light_engine = false;
light_strobe = false;
+
light_radius = 1.0f;
light_frequency = 1.0f;
light_offset = 0.0f;
light_time = 0.5f;
+
light_flare = 0;
- light_engine = 0;
+
render_texture = 0;
}
@@ -32,7 +35,6 @@ Light::~Light()
Flare::Flare() : Light()
{
- flare_engine = false;
flare_cull = CullBack;
}
@@ -42,7 +44,7 @@ Flare::~Flare()
/* ---- class Particles -------------------------------------------- */
Particles::Particles() :
- particles_location()
+ Part()
{
particles_entity = false;
particles_engine = false;
@@ -51,16 +53,12 @@ Particles::Particles() :
}
Particles::Particles(math::Vector3f const & location) :
- particles_location(location)
+ Part(location)
{
}
Particles::~Particles()
-{}
-
-void Particles::set_radius(const float radius)
{
- particles_radius = radius;
}
/* ---- class Dock ------------------------------------------------- */
diff --git a/src/model/parts.h b/src/model/parts.h
index 3e5e74f..78ad5e4 100644
--- a/src/model/parts.h
+++ b/src/model/parts.h
@@ -14,6 +14,9 @@
namespace model
{
+/* ---- globals ---------------------------------------------------- */
+
+// FIXME this should end up in material.h
/**
* @brief
@@ -23,23 +26,82 @@ namespace model
*/
enum Cull { CullNone=0, CullBack=1, CullFront=2 };
+/* ---- class Part ------------------------------------------------- */
+
+/**
+ * @brief a special part of a model
+ */
+class Part
+{
+public:
+ /**
+ * @brief default constructor
+ */
+ inline Part() : part_location()
+ {
+ }
+
+ /**
+ * @brief constructor with location
+ */
+ inline Part(const math::Vector3f &location) : part_location(location)
+ {
+ }
+
+ /* ---- inspectors ----------------------------------------- */
+
+ /**
+ * @brief location of this part within the parent model
+ */
+ inline const math::Vector3f &location() const
+ {
+ return part_location;
+ }
+
+ /* ---- mutators ------------------------------------------- */
+ /**
+ * @brief set the location within the parent model
+ */
+ inline void set_location(const math::Vector3f location) { part_location.assign(location); }
+
+ /**
+ * @brief set the location within the parent model
+ */
+ inline void set_location(const float x, const float y, const float z) { part_location.assign(x, y, z); }
+
+ /* ---- actors --------------------------------------------- */
+
+ /**
+ * @brief mutable reference to the location of this part within the parent model
+ */
+ inline math::Vector3f &get_location()
+ {
+ return part_location;
+ }
+
+private:
+ math::Vector3f part_location;
+};
+
/* ---- class Light ------------------------------------------------ */
/// an exterior light
-class Light
+class Light : public Part
{
public:
+ /**
+ * @brief default constructor
+ */
Light();
-
- Light(const math::Vector3f & location, const math::Color & color, bool strobe=false, bool engine=false);
-
+
+ /**
+ * @brief destructor
+ */
~Light();
- inline const math::Vector3f & location() const
- {
- return light_location;
- }
-
+ /* ---- inspectors ----------------------------------------- */
+
+ /// light color
inline const math::Color & color() const
{
return light_color;
@@ -56,6 +118,12 @@ public:
{
return light_entity;
}
+
+ /// true if this light has engine activation
+ inline const bool engine() const
+ {
+ return light_engine;
+ }
/// size of the light, default is 1.0f
inline float radius() const
@@ -86,32 +154,42 @@ public:
{
return light_flare;
}
-
- /// true if this light has engine activation
- inline const bool engine() const
- {
- return light_engine;
- }
/// render texture number
inline size_t texture() const
{
return render_texture;
}
-
- math::Vector3f light_location;
+ /* ---- mutators ------------------------------------------- */
+
+ /// set strobe on or off
+ inline void set_strobe(bool strobe) { light_strobe = strobe; }
+
+ /**
+ * @brief set entity color on or off
+ */
+ inline void set_entity(bool entity) { light_entity = entity; }
+
+ /**
+ * @brief set engine activation on or off
+ */
+ inline void set_engine(bool engine) { light_engine = engine; }
+
+
math::Color light_color;
- bool light_strobe;
- bool light_entity;
- bool light_engine;
float light_radius;
float light_frequency;
float light_offset;
float light_time;
-
+
unsigned int light_flare;
-
+
size_t render_texture;
+
+private:
+ bool light_strobe;
+ bool light_engine;
+ bool light_entity;
};
/* ---- class Flare ------------------------------------------------ */
@@ -121,46 +199,47 @@ class Flare : public Light
{
public:
Flare();
+
~Flare();
+ /* ---- inspectors ----------------------------------------- */
+
inline const math::Axis axis() const
{
return flare_axis;
}
- inline const bool engine() const
- {
- return flare_engine;
- }
-
inline const Cull cull() const
{
return flare_cull;
}
+ /* ---- mutators ------------------------------------------- */
+
+ inline void set_cull(const Cull cull) { flare_cull = cull; }
+
+ /* ---- actors --------------------------------------------- */
+
+ /**
+ * @brief mutable reference to the axis
+ */
+ inline math::Axis &get_axis() { return flare_axis; }
+
+private:
math::Axis flare_axis;
- bool flare_engine;
Cull flare_cull;
};
/* ---- class Particles -------------------------------------------- */
/// a particle system
-class Particles
+class Particles : public Part
{
public:
Particles();
-
Particles(const math::Vector3f & location);
~Particles();
- void set_radius(const float radius);
-
- inline const math::Vector3f & location() const
- {
- return particles_location;
- }
-
inline const math::Axis &axis() const
{
return particles_axis;
@@ -191,14 +270,36 @@ public:
return particles_cull;
}
+ /* ---- mutators ------------------------------------------- */
+
+ /**
+ * @brief set entity color on or off
+ */
+ inline void set_entity(const bool entity) { particles_entity = entity; }
+
+ /**
+ * @brief set engine activation on or off
+ */
+ inline void set_engine(const bool engine) { particles_engine = engine; }
+
+ inline void set_radius(const float radius) { particles_radius = radius; }
+
+ inline void set_cull(const Cull cull) { particles_cull = cull; }
+
+ /* ---- actors --------------------------------------------- */
+
+ /**
+ * @brief mutable reference to the axis
+ */
+ inline math::Axis &get_axis() { return particles_axis; }
+
std::string particles_script;
- math::Vector3f particles_location;
- math::Axis particles_axis;
+private:
+ math::Axis particles_axis;
+ float particles_radius;
bool particles_entity;
bool particles_engine;
-
- float particles_radius;
Cull particles_cull;
};