Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-11-18 19:21:57 +0000
committerStijn Buys <ingar@osirion.org>2010-11-18 19:21:57 +0000
commita3b3dbf3ced35ae4c0aca148d89509a12f785062 (patch)
tree6fc93069f70eb6059d056a00790be818df2c2f9f /src/model
parent138dbc83d5720c8baa7270ece183ce356f619fce (diff)
Corrected default light and flare radius.
Suppoort for entity, engine and color keys in fx_particles and particle scripts. Have light, fx_flare and fx_particles color override engine color if the engine spawnflag is set.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/mapfile.cc11
-rw-r--r--src/model/tags.cc7
-rw-r--r--src/model/tags.h46
3 files changed, 49 insertions, 15 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index f8e541c..84fd108 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -811,8 +811,7 @@ bool MapFile::got_key_axis(math::Axis &axis)
axis.assign(yaw, pitch, roll);
} else {
unknown_value();
- }
-
+ }
return true;
} else if (got_key_float("pitch", pitch)) {
@@ -1111,7 +1110,7 @@ Model * MapFile::load(std::string const &name)
continue;
} else if (mapfile.got_key_color("_color", color)) {
- tag_light->get_color().assign(color);
+ tag_light->set_color(color);
continue;
} else if (mapfile.got_key_int("spawnflags", u)) {
@@ -1167,7 +1166,7 @@ Model * MapFile::load(std::string const &name)
continue;
} else if (mapfile.got_key_color("_color", color)) {
- tag_flare->get_color().assign(color);
+ tag_flare->set_color(color);
continue;
} else if (mapfile.got_key_int("spawnflags", u)) {
@@ -1232,6 +1231,10 @@ Model * MapFile::load(std::string const &name)
tag_particles->get_location().assign(location * SCALE);
continue;
+ } else if (mapfile.got_key_color("_color", color)) {
+ tag_particles->set_color(color);
+ continue;
+
} else if (mapfile.got_key_string("script", str)) {
tag_particles->set_script(str);
continue;
diff --git a/src/model/tags.cc b/src/model/tags.cc
index c1467a1..5993f99 100644
--- a/src/model/tags.cc
+++ b/src/model/tags.cc
@@ -4,6 +4,7 @@
the terms of the GNU General Public License version 2
*/
+#include "model/model.h"
#include "model/tags.h"
namespace model
@@ -32,8 +33,9 @@ Light::Light() :
light_entity = false;
light_engine = false;
light_strobe = false;
+ light_has_color = false;
- light_radius = 1.0f;
+ light_radius = 100.0f * SCALE;
light_frequency = 1.0f;
light_offset = 0.0f;
light_time = 0.5f;
@@ -50,6 +52,7 @@ Light::Light(const Light& other) :
light_entity = other.entity();
light_engine = other.engine();
light_strobe = other.strobe();
+ light_has_color = other.has_color();
light_radius = other.radius();
light_frequency = other.frequency();
@@ -93,6 +96,7 @@ Particles::Particles() :
{
particles_entity = false;
particles_engine = false;
+ particles_has_color = false;
particles_scale = 1.0f;
particles_cull = CullNone;
}
@@ -106,6 +110,7 @@ Particles::Particles(const Particles & other) :
particles_engine = other.engine();
particles_scale = other.scale();
particles_cull = other.cull();
+ particles_has_color = other.has_color();
}
Particles::~Particles()
diff --git a/src/model/tags.h b/src/model/tags.h
index af1bc27..586fd21 100644
--- a/src/model/tags.h
+++ b/src/model/tags.h
@@ -117,7 +117,12 @@ public:
/// light color
inline const math::Color& color() const {
return light_color;
- };
+ }
+
+ /// true if the color was set
+ inline bool has_color() const {
+ return light_has_color;
+ }
/// true if this is a strobe light
inline bool strobe() const {
@@ -166,7 +171,17 @@ public:
/* ---- mutators ------------------------------------------- */
/**
- * @brief set strobe color on or off
+ * @brief set the light color
+ * light color overrides engine color if the engine flag is set
+ * @see engine()
+ */
+ inline void set_color(const math::Color& color) {
+ light_color.assign(color);
+ light_has_color = true;
+ }
+
+ /**
+ * @brief set strobe on or off
*/
inline void set_strobe(const bool strobe) {
light_strobe = strobe;
@@ -227,14 +242,7 @@ public:
inline void set_texture(size_t texture) {
light_texture = texture;
}
-
- /**
- * @brief mutable reference to the color
- */
- inline math::Color& get_color() {
- return light_color;
- }
-
+
private:
bool light_strobe;
bool light_engine;
@@ -248,6 +256,7 @@ private:
float light_time;
math::Color light_color;
+ bool light_has_color;
size_t light_texture;
};
@@ -338,6 +347,16 @@ public:
inline bool engine() const {
return particles_engine;
}
+
+ inline const math::Color & color() const {
+ return particles_color;
+ }
+
+ /// true if the color was set
+ inline bool has_color() const {
+ return particles_has_color;
+ }
+
inline float scale() const {
return particles_scale;
@@ -374,6 +393,11 @@ public:
inline void set_scale(const float scale) {
particles_scale = scale;
}
+
+ inline void set_color(const math::Color &color) {
+ particles_color.assign(color);
+ particles_has_color = true;
+ }
/* ---- actors --------------------------------------------- */
@@ -387,11 +411,13 @@ public:
private:
bool particles_entity;
bool particles_engine;
+ bool particles_has_color;
Cull particles_cull;
float particles_scale;
+ math::Color particles_color;
math::Axis particles_axis;
std::string particles_script;
};