Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/model/mapfile.cc3
-rw-r--r--src/model/tags.cc4
-rw-r--r--src/model/tags.h379
-rw-r--r--src/render/draw.cc49
-rw-r--r--src/render/draw.h6
-rw-r--r--src/render/particles.cc40
-rwxr-xr-xsrc/ui/modelview.cc2
7 files changed, 353 insertions, 130 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index a516649..3df2659 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -1588,6 +1588,7 @@ Model * MapFile::load(std::string const &name)
tag_light->set_strobe(spawnflag_isset(u, 1));
tag_light->set_entity(spawnflag_isset(u, 2));
tag_light->set_engine(spawnflag_isset(u, 4));
+ tag_light->set_entity_second(spawnflag_isset(u, 8));
continue;
} else if (mapfile.got_key_float("light", r)) {
@@ -1644,6 +1645,7 @@ Model * MapFile::load(std::string const &name)
tag_flare->set_strobe(spawnflag_isset(u, 1));
tag_flare->set_entity(spawnflag_isset(u, 2));
tag_flare->set_engine(spawnflag_isset(u, 4));
+ tag_flare->set_entity_second(spawnflag_isset(u, 8));
} else if (mapfile.got_key_float("light", r)) {
tag_flare->set_radius(r * SCALE);
@@ -1713,6 +1715,7 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.got_key_int("spawnflags", u)) {
tag_particles->set_entity(spawnflag_isset(u, 2));
tag_particles->set_engine(spawnflag_isset(u, 4));
+ tag_particles->set_entity_second(spawnflag_isset(u, 8));
} else if (mapfile.got_key_float("scale", s)) {
tag_particles->set_scale(s);
diff --git a/src/model/tags.cc b/src/model/tags.cc
index 75580e5..76f18ce 100644
--- a/src/model/tags.cc
+++ b/src/model/tags.cc
@@ -31,6 +31,7 @@ Light::Light() :
light_color(1.0f, 1.0f, 1.0f)
{
light_entity = false;
+ light_entity_second = false;
light_engine = false;
light_strobe = false;
light_has_color = false;
@@ -50,6 +51,7 @@ Light::Light(const Light& other) :
light_color(other.color())
{
light_entity = other.entity();
+ light_entity_second = other.entity_second();
light_engine = other.engine();
light_strobe = other.strobe();
light_has_color = other.has_color();
@@ -95,6 +97,7 @@ Particles::Particles() :
particles_script()
{
particles_entity = false;
+ particles_entity_second = false;
particles_engine = false;
particles_has_color = false;
particles_scale = 1.0f;
@@ -107,6 +110,7 @@ Particles::Particles(const Particles & other) :
particles_script(other.script())
{
particles_entity = other.entity();
+ particles_entity_second = other.entity_second();
particles_engine = other.engine();
particles_scale = other.scale();
particles_cull = other.cull();
diff --git a/src/model/tags.h b/src/model/tags.h
index ff95954..200c977 100644
--- a/src/model/tags.h
+++ b/src/model/tags.h
@@ -1,5 +1,5 @@
/*
- model/classes.h
+ model/tags.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
@@ -22,7 +22,7 @@ namespace model
* culling parameter values
* Culling is a paremeter used by flares and particles to indicate
* with side of the polygons should be culled during rendering
- */
+ * */
enum Cull { CullNone = 0, CullBack = 1, CullFront = 2 };
/* ---- class Tag -------------------------------------------------- */
@@ -31,47 +31,50 @@ enum Cull { CullNone = 0, CullBack = 1, CullFront = 2 };
* @brief a location tag
* A location tag provides an anchor point for model extenions
* like lights, flares and sounds.
- */
+ * */
class Tag
{
public:
/**
* @brief default constructor
- */
+ * */
Tag();
/**
* @brief copy constructor
- */
+ * */
Tag(const Tag& other);
/**
* @brief default destructor
- */
+ * */
~Tag();
/* ---- inspectors ----------------------------------------- */
/**
* @brief location of this part within the parent model
- */
- inline const math::Vector3f& location() const {
+ * */
+ inline const math::Vector3f& location() const
+ {
return tag_location;
}
/* ---- mutators ------------------------------------------- */
/**
* @brief set the location within the parent model
- */
- inline void set_location(const math::Vector3f& location) {
+ * */
+ inline void set_location(const math::Vector3f& location)
+ {
tag_location.assign(location);
}
/**
* @brief set the location within the parent model
- */
- inline void set_location(const float x, const float y, const float z) {
+ * */
+ inline void set_location(const float x, const float y, const float z)
+ {
tag_location.assign(x, y, z);
}
@@ -79,8 +82,9 @@ public:
/**
* @brief mutable reference to the location of this part within the parent model
- */
- inline math::Vector3f& get_location() {
+ * */
+ inline math::Vector3f& get_location()
+ {
return tag_location;
}
@@ -99,73 +103,115 @@ class Light : public Tag
public:
/**
* @brief default constructor
- */
+ * */
Light();
/**
* @brief copy constructor
- */
+ * */
Light(const Light& other);
/**
* @brief destructor
- */
+ * */
~Light();
/* ---- inspectors ----------------------------------------- */
- /// light color
- inline const math::Color& color() const {
+ /**
+ * @brief light color
+ * */
+ inline const math::Color& color() const
+ {
return light_color;
}
- /// true if the color was set
- inline bool has_color() const {
+ /**
+ * @brief 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 {
+ /**
+ * @brief true if this is a strobe light
+ * */
+ inline bool strobe() const
+ {
return light_strobe;
}
- /// true if this light has entity color
- inline bool entity() const {
+ /**
+ * @brief true if this light has entity primary color
+ * */
+ inline bool entity() const
+ {
return light_entity;
}
+
+ /**
+ * @brief true if this light has entity secondary color
+ * */
+ inline bool entity_second() const
+ {
+ return light_entity_second;
+ }
- /// true if this light has engine activation
- inline bool engine() const {
+ /**
+ * @brief true if this light has engine activation
+ * The light's intensity will vary depedning on entity thrust,
+ * */
+ inline bool engine() const
+ {
return light_engine;
}
- /// size of the light, default is 1.0f
- inline float radius() const {
+ /**
+ * @brief size of the light, default is 1.0f
+ * */
+ inline float radius() const
+ {
return light_radius;
}
- /// strobe time offset, in seconds
- inline float offset() const {
+ /**
+ * @brief strobe time offset, in seconds
+ * */
+ inline float offset() const
+ {
return light_offset;
}
- /// strobe frequency in strobes per second, default is 1.0f
- inline float frequency() const {
+ /**
+ * @brief strobe frequency in strobes per second, default is 1.0f
+ * */
+ inline float frequency() const
+ {
return light_frequency;
}
- /// fraction a strobe light will be on, default is 0.5f
- inline float time() const {
+ /**
+ * @brief fraction a strobe light will be on, default is 0.5f
+ * */
+ inline float time() const
+ {
return light_time;
}
- /// flare texture number
- inline unsigned int flare() const {
+ /**
+ * @brief flare texture number
+ * */
+ inline unsigned int flare() const
+ {
return light_flare;
}
- /// render texture id
- inline size_t texture() const {
+ /**
+ * @brief render texture id
+ * */
+ inline size_t texture() const
+ {
return light_texture;
}
/* ---- mutators ------------------------------------------- */
@@ -188,58 +234,74 @@ public:
}
/**
- * @brief set entity color on or off
- */
- inline void set_entity(const bool entity) {
+ * @brief set entity prinary color on or off
+ * */
+ inline void set_entity(const bool entity)
+ {
light_entity = entity;
}
+
+ /**
+ * @brief set entity secondary color on or off
+ * */
+ inline void set_entity_second(const bool entity_second)
+ {
+ light_entity_second = entity_second;
+ }
/**
* @brief set engine activation on or off
- */
- inline void set_engine(const bool engine) {
+ * */
+ inline void set_engine(const bool engine)
+ {
light_engine = engine;
}
/**
* @brief set the light radius
- */
- inline void set_radius(const float radius) {
+ * */
+ inline void set_radius(const float radius)
+ {
light_radius = radius;
}
/**
* @brief set the light strobe frequency, in strobes per second
- */
- inline void set_frequency(const float frequency) {
+ * */
+ inline void set_frequency(const float frequency)
+ {
light_frequency = frequency;
}
/**
* @brief set the light on time, from 0.0 (always off) to 1.0 (always on)
- */
- inline void set_time(const float time) {
+ * */
+ inline void set_time(const float time)
+ {
light_time = time;
}
/**
* @brief set the light strobe time offset, in seconds
- */
- inline void set_offset(const float offset) {
+ * */
+ inline void set_offset(const float offset)
+ {
light_offset = offset;
}
/**
* @brief set the flare texture number
- */
- inline void set_flare(unsigned int flare) {
+ * */
+ inline void set_flare(unsigned int flare)
+ {
light_flare = flare;
}
/**
* @brief set the render texture id
- */
- inline void set_texture(size_t texture) {
+ * */
+ inline void set_texture(size_t texture)
+ {
light_texture = texture;
}
@@ -247,6 +309,7 @@ private:
bool light_strobe;
bool light_engine;
bool light_entity;
+ bool light_entity_second;
unsigned int light_flare;
@@ -280,17 +343,20 @@ public:
/* ---- inspectors ----------------------------------------- */
- inline const math::Axis &axis() const {
+ inline const math::Axis &axis() const
+ {
return flare_axis;
}
- inline Cull cull() const {
+ inline Cull cull() const
+ {
return flare_cull;
}
/* ---- mutators ------------------------------------------- */
- inline void set_cull(const Cull cull) {
+ inline void set_cull(const Cull cull)
+ {
flare_cull = cull;
}
@@ -298,8 +364,9 @@ public:
/**
* @brief mutable reference to the axis
- */
- inline math::Axis& get_axis() {
+ * */
+ inline math::Axis& get_axis()
+ {
return flare_axis;
}
@@ -310,91 +377,129 @@ private:
/* ---- class Particles -------------------------------------------- */
-/// a particle system
+/**
+ * @brief a particle system
+ * */
class Particles : public Tag
{
public:
/**
* @brief default constructor
- */
+ * */
Particles();
/**
* @brief copy constructor
- */
+ * */
Particles(const Particles & other);
/**
* @brief destructor
- */
+ * */
~Particles();
+
+ /* ---- inspectors ----------------------------------------- */
- inline const math::Axis &axis() const {
+ inline const math::Axis &axis() const
+ {
return particles_axis;
}
/**
* @brief name of the script to load
- */
- inline const std::string& script() const {
+ * */
+ inline const std::string& script() const
+ {
return particles_script;
}
- inline bool entity() const {
+ /**
+ * @brief if true, the particle system has entity primary color
+ * */
+ inline bool entity() const
+ {
return particles_entity;
}
+
+ /**
+ * @brief if true, the particle system has entity secondary color
+ * */
+ inline bool entity_second() const
+ {
+ return particles_entity_second;
+ }
- inline bool engine() const {
+ inline bool engine() const
+ {
return particles_engine;
}
- inline const math::Color & color() const {
+ inline const math::Color & color() const
+ {
return particles_color;
}
- /// true if the color was set
- inline bool has_color() const {
+ /**
+ * @brief true if the color was set
+ * */
+ inline bool has_color() const
+ {
return particles_has_color;
}
-
- inline float scale() const {
+ inline float scale() const
+ {
return particles_scale;
}
- inline Cull cull() const {
+ inline Cull cull() const
+ {
return particles_cull;
}
/* ---- mutators ------------------------------------------- */
/**
- * @brief set entity color on or off
+ * @brief set entity primary color on or off
*/
- inline void set_entity(const bool entity) {
+ inline void set_entity(const bool entity)
+ {
particles_entity = entity;
}
+
+ /**
+ * @brief set entity secondary color on or off
+ */
+ inline void set_entity_second(const bool entity_second)
+ {
+ particles_entity_second = entity_second;
+ }
/**
* @brief set engine activation on or off
*/
- inline void set_engine(const bool engine) {
+ inline void set_engine(const bool engine)
+ {
particles_engine = engine;
}
- inline void set_cull(const Cull cull) {
+ inline void set_cull(const Cull cull)
+ {
particles_cull = cull;
}
- inline void set_script(const std::string& script) {
+ inline void set_script(const std::string& script)
+ {
particles_script.assign(script);
}
- inline void set_scale(const float scale) {
+ inline void set_scale(const float scale)
+ {
particles_scale = scale;
}
- inline void set_color(const math::Color &color) {
+ inline void set_color(const math::Color &color)
+ {
particles_color.assign(color);
particles_has_color = true;
}
@@ -404,12 +509,14 @@ public:
/**
* @brief mutable reference to the axis
*/
- inline math::Axis& get_axis() {
+ inline math::Axis& get_axis()
+ {
return particles_axis;
}
private:
bool particles_entity;
+ bool particles_entity_second;
bool particles_engine;
bool particles_has_color;
@@ -430,35 +537,49 @@ class Dock : public Tag
public:
/**
* @brief default constructor
- */
+ * */
Dock();
/**
* @brief copy constructor
- */
+ * */
Dock(const Dock& other);
/**
* @brief destructor
- */
+ * */
~Dock();
+
+ /* ---- inspectors ----------------------------------------- */
- inline const math::Axis &axis() const {
- return dock_axis;
+ /**
+ * @brief dock radius, default is 0.01f
+ * */
+ inline float radius() const
+ {
+ return dock_radius;
}
- /// dock radius, default is 0.01f
- inline float radius() const {
- return dock_radius;
+ inline const math::Axis &axis() const
+ {
+ return dock_axis;
}
+
+ /* ---- mutators ------------------------------------------- */
- /// set dock radius
- inline void set_radius(const float radius) {
+ /**
+ * @brief set dock radius
+ * */
+ inline void set_radius(const float radius)
+ {
dock_radius = radius;
}
- /// set dock axis
- inline void set_axis(const math::Axis& axis) {
+ /**
+ * @brief set dock axis
+ * */
+ inline void set_axis(const math::Axis& axis)
+ {
dock_axis.assign(axis);
}
@@ -466,7 +587,7 @@ public:
/**
* @brief mutable reference to the axis
- */
+ * */
inline math::Axis& get_axis() {
return dock_axis;
}
@@ -489,13 +610,24 @@ public:
Sound(const Sound& other);
~Sound();
+
+ /* ---- inspectors ----------------------------------------- */
- /// name of the sound sample
- inline const std::string& name() const {
+ /**
+ * @brief name of the sound sample
+ * */
+ inline const std::string& name() const
+ {
return sound_name;
}
+
+ /* ---- mutators ------------------------------------------- */
- inline void set_name(const std::string& name) {
+ /**
+ * @brief set the name name of the sound sample
+ * */
+ inline void set_name(const std::string& name)
+ {
sound_name.assign(name);
}
private:
@@ -515,19 +647,25 @@ public:
SubModel(const SubModel& other);
~SubModel();
+
+ /* ---- inspectors ----------------------------------------- */
- inline const std::string& name() const {
+ inline const std::string& name() const
+ {
return submodel_name;
}
- inline const math::Axis& axis() const {
+ inline const math::Axis& axis() const
+ {
return submodel_axis;
}
- inline float scale() const {
+ inline float scale() const
+ {
return submodel_scale;
}
-
+
+ /* ---- mutators ------------------------------------------- */
inline void set_scale(const float scale) {
submodel_scale = scale;
@@ -566,35 +704,46 @@ class Weapon : public Tag
public:
/**
* @brief default constructor
- */
+ * */
Weapon();
/**
* @brief copy constructor
- */
+ * */
Weapon(const Weapon& other);
/**
* @brief destructor
- */
+ * */
~Weapon();
+
+ /* ---- inspectors ----------------------------------------- */
inline const math::Axis &axis() const {
return weapon_axis;
}
- /// weapon slot radius, default is 0.01f
- inline float radius() const {
+ /**
+ * @brief weapon slot radius, default is 0.01f
+ * */
+ inline float radius() const
+ {
return weapon_radius;
}
- /// set weapon slot radius
- inline void set_radius(const float radius) {
+ /**
+ * @brief set weapon slot radius
+ * */
+ inline void set_radius(const float radius)
+ {
weapon_radius = radius;
}
- /// set weapon slot axis
- inline void set_axis(const math::Axis& axis) {
+ /**
+ * @brief set weapon slot axis
+ * */
+ inline void set_axis(const math::Axis& axis)
+ {
weapon_axis.assign(axis);
}
@@ -602,7 +751,7 @@ public:
/**
* @brief mutable reference to the axis
- */
+ * */
inline math::Axis& get_axis() {
return weapon_axis;
}
@@ -615,5 +764,5 @@ private:
}
-#endif // __INCLUDED_MODEL_PARTS_H__
+#endif // __INCLUDED_MODEL_TAGS_H__
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 59f4a59..46d0906 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -782,7 +782,7 @@ void draw_pass_model_fragments()
void draw_model_lights(model::Model *model, const float scale,
const math::Vector3f & entity_location, const math::Axis & entity_axis,
- const math::Color & entity_color, const float thrust, const float fuzz)
+ const math::Color & entity_color, const math::Color & entity_color_second, const float thrust, const float fuzz)
{
float t = 0.0f;
float a = 0.0f;
@@ -823,13 +823,31 @@ void draw_model_lights(model::Model *model, const float scale,
// entity color overrides light color
// light color overrides engine color
if (light->entity()) {
- color.assign(entity_color);
+ if (light->entity_second()) {
+ // entity tertiary color
+ for (size_t i = 0; i < 3; i++) {
+ color[i] = (entity_color[i] + entity_color_second[i]) / 2;
+ }
+ } else {
+ // entity primary color
+ color.assign(entity_color);
+ }
+
+ } else if (light->entity_second()) {
+ // entity secondary color
+ color.assign(entity_color_second);
+
} else if (light->has_color()) {
+ // light color
color.assign(light->color());
+
} else if (light->engine()) {
+ // FIXME engine_color or thrust_activated
color.assign(model->enginecolor());
+
} else {
color.assign(light->color());
+
}
// default alpha is 0.8, engine flag alters alpha
@@ -890,16 +908,34 @@ void draw_model_lights(model::Model *model, const float scale,
continue; // next flare
}
- // entity color overrides light color
- // light color overrides engine color
+ // entity color overrides flare color
+ // flare color overrides engine color
if (flare->entity()) {
- color.assign(entity_color);
+ if (flare->entity_second()) {
+ // entity tertiary color
+ for (size_t i = 0; i < 3; i++) {
+ color[i] = (entity_color[i] + entity_color_second[i]) / 2;
+ }
+ } else {
+ // entity primary color
+ color.assign(entity_color);
+ }
+
+ } else if (flare->entity_second()) {
+ // entity secondary color
+ color.assign(entity_color_second);
+
} else if (flare->has_color()) {
+ // flare color
color.assign(flare->color());
+
} else if (flare->engine()) {
+ // FIXME engine_color or thrust_activated
color.assign(model->enginecolor());
+
} else {
color.assign(flare->color());
+
}
// default alpha is 0.8, engine flag alters alpha
@@ -979,7 +1015,8 @@ void draw_pass_model_fx(float elapsed)
const float modelscale = entity->radius() / entity->model()->radius();
draw_model_lights(entity->model(), modelscale,
- entity->location(), entity->axis(), entity->color(),
+ entity->location(), entity->axis(),
+ entity->color(), entity->color_second(),
ext_render(entity)->thrust(), ext_render(entity)->fuzz()
);
}
diff --git a/src/render/draw.h b/src/render/draw.h
index 21145c2..122d7cd 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -34,10 +34,10 @@ void draw_sphere(const math::Color & color, float radius);
void draw_globe_corona(const math::Vector3f location, const math::Color & color, const float radius, const size_t corona_id);
/// draw mode lights and flares
-void draw_model_lights(model::Model *model, const float scale,
+void draw_model_lights(
+ model::Model *model, const float scale,
const math::Vector3f & entity_location, const math::Axis & entity_axis,
- const math::Color & entity_color, const float thrust, const float fuzz
-);
+ const math::Color & entity_color, const math::Color & entity_color_second, const float thrust, const float fuzz);
/// draw a model
void draw_model_fragments(model::Model *model,
diff --git a/src/render/particles.cc b/src/render/particles.cc
index d5db8cf..fc27234 100644
--- a/src/render/particles.cc
+++ b/src/render/particles.cc
@@ -296,32 +296,62 @@ ParticleSystem::ParticleSystem(const ParticleScript *script, const core::Entity
particlesystem_radius = 1.0f;
if (particlesystem_script) {
+ // initial particle system parameters are set by the script
particlesystem_texture = Textures::load("textures/" + particlesystem_script->texture());
particlesystem_radius = particlesystem_script->radius();
particlesystem_cull = particlesystem_script->cull();
- // allow the script to override itself
if (particlesystem_script->entity()) {
- particlesystem_color.assign(entity->color());
+
+ if (particlesystem_script->entity_second()) {
+ // entity tertiary color
+ for (size_t i = 0; i < 3; i++) {
+ particlesystem_color[i] = (entity->color()[i] + entity->color_second()[i]) / 2;
+ }
+ } else {
+ // entity primary color
+ particlesystem_color.assign(entity->color());
+ }
+
} else if (particlesystem_script->entity_second()) {
+ // entity secondary color
particlesystem_color.assign(entity->color_second());
+
} else if (particlesystem_script->engine()) {
+ // FIXME engine_color or thrust_activated
particlesystem_color.assign(entity->model()->enginecolor());
+
} else {
particlesystem_color.assign(particlesystem_script->color());
- }
-
+ }
particlesystem_axis.assign(particlesystem_script->axis());
}
if (particlesystem_modelclass) {
+ // the modeltag can override the script parameters
particlesystem_radius *= particlesystem_modelclass->scale();
if (particlesystem_modelclass->entity()) {
- particlesystem_color.assign(entity->color());
+
+ if (particlesystem_modelclass->entity_second()) {
+ // entity tertiary color
+ for (size_t i = 0; i < 3; i++) {
+ particlesystem_color[i] = (entity->color()[i] + entity->color_second()[i]) / 2;
+ }
+ } else {
+ // entity primary color
+ particlesystem_color.assign(entity->color());
+ }
+
+ } else if (particlesystem_modelclass->entity_second()) {
+ // entity secondary color
+ particlesystem_color.assign(entity->color_second());
+
} else if (particlesystem_modelclass->has_color()) {
particlesystem_color.assign(particlesystem_modelclass->color());
+
} else if (particlesystem_modelclass->engine()) {
+ // FIXME engine_color or thrust_activated
particlesystem_color.assign(entity->model()->enginecolor());
}
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index b8d2a86..71fff6c 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -374,7 +374,7 @@ void ModelView::draw_model()
flare->set_texture(render::Textures::load(texturename.str()));
}
- render::draw_model_lights(model, modelscale, math::Vector3f(), modelview_axis, core::localplayer()->color(), thrust, 0.0f);
+ render::draw_model_lights(model, modelscale, math::Vector3f(), modelview_axis, core::localplayer()->color(), core::localplayer()->color_second(), thrust, 0.0f);
gl::disable(GL_TEXTURE_2D);
gl::disable(GL_COLOR_MATERIAL); // disable color tracking