Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
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/render
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/render')
-rw-r--r--src/render/draw.cc35
-rw-r--r--src/render/particles.cc40
-rw-r--r--src/render/particles.h18
3 files changed, 69 insertions, 24 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 9ebe2cc..4cf5571 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -939,21 +939,27 @@ void draw_pass_model_fx(float elapsed)
continue; // next light
}
}
-
- // default alpha is 0.8
- a = 0.8f;
+
+ // entity color overrides light color
+ // light color overrides engine color
if (light->entity()) {
color.assign(entity->color());
+ } else if (light->has_color()) {
+ color.assign(light->color());
} else if (light->engine()) {
color.assign(entity->model()->enginecolor());
- a *= thrust;
} else {
color.assign(light->color());
}
+
+ // default alpha is 0.8, engine flag alters alpha
+ a = 0.8f;
+ if (light->engine()) {
+ a *= thrust;
+ }
color.a = a;
- location.assign(entity->location() + (entity->axis() * light->location()) * modelscale);
-
+ location.assign(entity->location() + (entity->axis() * light->location()) * modelscale);
light_size = light->radius() * modelscale;
// track OpenGL state changes
@@ -1010,24 +1016,31 @@ void draw_pass_model_fx(float elapsed)
// calulcate viewing angle factor
flare_axis.assign(entity->axis() * flare->axis());
a = math::absf(dotproduct(flare_axis.forward(), Camera::axis().forward()));
- if (a < 0.01f) {
+ if (a < 0.001f) {
continue; // next flare
}
- // alpha decreases with viewing angle
- a *= 0.8f;
+ // entity color overrides light color
+ // light color overrides engine color
if (flare->entity()) {
color.assign(entity->color());
+ } else if (flare->has_color()) {
+ color.assign(flare->color());
} else if (flare->engine()) {
color.assign(entity->model()->enginecolor());
- a *= thrust;
} else {
color.assign(flare->color());
}
+
+ // default alpha is 0.8, engine flag alters alpha
+ // alpha decreases with viewing angle
+ a *= 0.8f;
+ if (flare->engine()) {
+ a *= thrust;
+ }
color.a = a;
location.assign(entity->location() + (entity->axis() * flare->location()) * modelscale );
-
light_size = flare->radius() * modelscale;
// track OpenGL state changes
diff --git a/src/render/particles.cc b/src/render/particles.cc
index 7a0094d..2e65449 100644
--- a/src/render/particles.cc
+++ b/src/render/particles.cc
@@ -171,8 +171,12 @@ ParticleScript *ParticleScript::load(const std::string &label)
} else if (inifile.got_key_float("timeout", script->particlescript_timeout)) {
continue;
} else if (inifile.got_key_color("color", script->particlescript_color)) {
+ script->particlescript_has_color = true;
+ continue;
+ } else if (inifile.got_key_bool("engine", script->particlescript_engine)) {
+ continue;
+ } else if (inifile.got_key_bool("entity", script->particlescript_entity)) {
continue;
-
} else if (inifile.got_key_float("angle", yaw)) {
if (yaw == model::ANGLEUP) {
@@ -244,20 +248,21 @@ ParticleScript *ParticleScript::load(const std::string &label)
ParticleScript::ParticleScript(const std::string & label) : particlescript_label(label)
{
+ particlescript_entity = false;
+ particlescript_engine = false;
+ particlescript_has_color = true;
particlescript_radius = 1.0f;
particlescript_alpha = 1.0f;
particlescript_speed = 0.0f;
particlescript_timeout = 2.0f;
particlescript_eject = 0.25f;
-
particlescript_offset = 0.1f;
-
+
particlescript_color.assign(1.0f, 1.0f);
+ particlescript_cull = model::CullNone;
particlescript_next = 0;
-
- particlescript_cull = model::CullNone;
}
ParticleScript::~ParticleScript()
@@ -284,22 +289,31 @@ ParticleSystem::ParticleSystem(const ParticleScript *script, const core::Entity
particlesystem_texture = Textures::load("textures/" + particlesystem_script->texture());
particlesystem_radius = particlesystem_script->radius();
particlesystem_cull = particlesystem_script->cull();
- particlesystem_color.assign(particlesystem_script->color());
+
+ if (particlesystem_script->entity()) {
+ particlesystem_color.assign(entity->color());
+ } else if (particlesystem_script->has_color()) {
+ particlesystem_color.assign(particlesystem_script->color());
+ } else if (particlesystem_script->engine()) {
+ particlesystem_color.assign(entity->model()->enginecolor());
+ }
+
particlesystem_axis.assign(particlesystem_script->axis());
}
if (particlesystem_modelclass) {
- particlesystem_location.assign(modelclass->location());
-
- if (modelclass->entity()) {
+ particlesystem_radius *= particlesystem_modelclass->scale();
+
+ if (particlesystem_modelclass->entity()) {
particlesystem_color.assign(entity->color());
- }
- if (modelclass->engine()) {
- // FIXME if not modelclass->has_color();
+ } else if (particlesystem_modelclass->has_color()) {
+ particlesystem_color.assign(particlesystem_modelclass->color());
+ } else if (particlesystem_modelclass->engine()) {
particlesystem_color.assign(entity->model()->enginecolor());
}
+
+ particlesystem_location.assign(modelclass->location());
particlesystem_axis.assign(modelclass->axis() * particlesystem_axis);
- particlesystem_radius *= particlesystem_modelclass->scale();
}
diff --git a/src/render/particles.h b/src/render/particles.h
index 909d027..a41065c 100644
--- a/src/render/particles.h
+++ b/src/render/particles.h
@@ -72,11 +72,25 @@ public:
return particlescript_color;
}
+ inline bool has_color() const {
+ return particlescript_has_color;
+ }
+
/// axis transformation relative to the ejector
inline const math::Axis &axis() const {
return particlescript_axis;
}
+ /// true if entity color is to be applied
+ inline bool engine() const {
+ return particlescript_engine;
+ }
+
+ /// true if engine color is to be applied
+ inline bool entity() const {
+ return particlescript_entity;
+ }
+
inline float radius() const {
return particlescript_radius;
}
@@ -125,6 +139,10 @@ private:
Type particlescript_type;
math::Color particlescript_color;
math::Axis particlescript_axis;
+
+ bool particlescript_entity;
+ bool particlescript_engine;
+ bool particlescript_has_color;
float particlescript_radius;
float particlescript_timeout;