diff options
author | Stijn Buys <ingar@osirion.org> | 2009-01-12 20:25:28 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-01-12 20:25:28 +0000 |
commit | 784e5c24d505aab001ae398cd53b039baed59f1f (patch) | |
tree | 5af692e35848cacff27c8ad529c4042b26b2d020 /src | |
parent | c55945a1e81f5e49ef706cb3d0d37f17dbb84709 (diff) |
radius key for fx_particles, overrules the script value
Diffstat (limited to 'src')
-rw-r--r-- | src/model/classes.cc | 6 | ||||
-rw-r--r-- | src/model/classes.h | 13 | ||||
-rw-r--r-- | src/model/map.cc | 9 | ||||
-rw-r--r-- | src/render/particles.cc | 71 | ||||
-rw-r--r-- | src/render/particles.h | 4 |
5 files changed, 62 insertions, 41 deletions
diff --git a/src/model/classes.cc b/src/model/classes.cc index b601a42..07a36f3 100644 --- a/src/model/classes.cc +++ b/src/model/classes.cc @@ -54,6 +54,7 @@ Particles::Particles() : { particles_entity = false; particles_engine = false; + particles_radius = 0.0f; } Particles::Particles(math::Vector3f const & location) : @@ -64,6 +65,11 @@ Particles::Particles(math::Vector3f const & location) : Particles::~Particles() {} +void Particles::set_radius(const float radius) +{ + particles_radius = radius; +} + /* ---- class Dock ------------------------------------------------- */ Dock::Dock() diff --git a/src/model/classes.h b/src/model/classes.h index f853da8..c6bf3b1 100644 --- a/src/model/classes.h +++ b/src/model/classes.h @@ -154,6 +154,8 @@ public: Particles(const math::Vector3f & location); ~Particles(); + void set_radius(const float radius); + inline const math::Vector3f & location() const { return particles_location; @@ -169,21 +171,28 @@ public: return particles_script; } - inline bool entity() const + inline const bool entity() const { return particles_entity; } - inline bool engine() const + inline const bool engine() const { return particles_engine; } + + inline const float radius() const + { + return particles_radius; + } std::string particles_script; math::Vector3f particles_location; math::Axis particles_axis; bool particles_entity; bool particles_engine; + + float particles_radius; }; /* ---- class Dock ------------------------------------------------- */ diff --git a/src/model/map.cc b/src/model/map.cc index 955410f..a59d2ff 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -836,6 +836,7 @@ Model * Map::load(std::string const &name) unsigned int u; float angle; + float r; while (mapfile.getline()) { @@ -1094,10 +1095,10 @@ Model * Map::load(std::string const &name) } else if (mapfile.got_key_int("spawnflags", u)) { particles->particles_entity = spawnflag_isset(u, 2); particles->particles_engine = spawnflag_isset(u, 4); -/* - } else if (mapfile.got_key_float("radius", particles->particles_radius)) { - particles->particles_radius *= LIGHTSCALE; -*/ + + } else if (mapfile.got_key_float("radius", r)) { + particles->set_radius(r * LIGHTSCALE); + } else if (mapfile.got_key()) { mapfile.unknown_key(); } diff --git a/src/render/particles.cc b/src/render/particles.cc index 71ec26b..07a8dc1 100644 --- a/src/render/particles.cc +++ b/src/render/particles.cc @@ -188,8 +188,13 @@ ParticleSystem::ParticleSystem(ParticleScript *script, core::Entity *entity, mod if (particlesystem_script) { particlesystem_texture = Textures::load("textures/" + particlesystem_script->texture()); + + // map entity radius overrules script value + if (modelclass->radius()) + particlesystem_radius = modelclass->radius(); + else + particlesystem_radius = particlesystem_script->radius(); - radius = particlesystem_script->radius(); color.assign(particlesystem_script->color()); } @@ -310,7 +315,7 @@ void Jet::draw(float elapsed) { } f *= f; - float radius = particlesystem_script->radius() * f; + float radius = particlesystem_radius * f; color.a = f * particlesystem_script->alpha(); gl::color(color); @@ -369,7 +374,7 @@ void Spray::draw(float elapsed) { } f *= f; - float radius = particlesystem_script->radius() * f; + float radius = particlesystem_radius * f; color.a = f * particlesystem_script->alpha(); gl::color(color); @@ -437,9 +442,9 @@ void Trail::draw(float elapsed) { gl::color(color); glTexCoord2f(0,1); - gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_radius * fp); glTexCoord2f(1,1); - gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_radius * fp); Stats::quads++; } @@ -462,17 +467,17 @@ void Trail::draw(float elapsed) { gl::color(color); glTexCoord2f(1,0); - gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_radius * fp); glTexCoord2f(0,0); - gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_radius * fp); color.a = f * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,1); - gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_radius * f); glTexCoord2f(1,1); - gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_radius * f); Stats::quads++; @@ -533,9 +538,9 @@ void Flame::draw(float elapsed) { color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,tp); - gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_radius * fp); glTexCoord2f(1,tp); - gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_radius * fp); Stats::quads++; color.a = 0; @@ -548,9 +553,9 @@ void Flame::draw(float elapsed) { color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,tp); - gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_radius * fp); glTexCoord2f(1,tp); - gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_radius * fp); Stats::quads++; color.a = 0; @@ -563,9 +568,9 @@ void Flame::draw(float elapsed) { color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,tp); - gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_radius * fp); glTexCoord2f(1,tp); - gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_radius * fp); Stats::quads++; color.a = 0; @@ -578,9 +583,9 @@ void Flame::draw(float elapsed) { color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,tp); - gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_radius * fp); glTexCoord2f(1,tp); - gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_radius * fp); Stats::quads++; } @@ -601,61 +606,61 @@ void Flame::draw(float elapsed) { color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(1,tp); - gl::vertex((*first)->location() + (*first)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() + (*first)->axis().up() * particlesystem_radius * fp); glTexCoord2f(0,tp); - gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_radius * fp); color.a = f * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,t); - gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_radius * f); glTexCoord2f(1,t); - gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_radius * f); Stats::quads++; color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(1,tp); - gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_radius * fp); glTexCoord2f(0,tp); - gl::vertex((*first)->location() + (*first)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() + (*first)->axis().up() * particlesystem_radius * fp); color.a = f * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,t); - gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() + (*next)->axis().up() * particlesystem_radius * f); glTexCoord2f(1,t); - gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_radius * f); Stats::quads++; color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(1,tp); - gl::vertex((*first)->location() - (*first)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() - (*first)->axis().up() * particlesystem_radius * fp); glTexCoord2f(0,tp); - gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() + (*first)->axis().left() * particlesystem_radius * fp); color.a = f * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,t); - gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() + (*next)->axis().left() * particlesystem_radius * f); glTexCoord2f(1,t); - gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_radius * f); Stats::quads++; color.a = fp * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(1,tp); - gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() - (*first)->axis().left() * particlesystem_radius * fp); glTexCoord2f(0,tp); - gl::vertex((*first)->location() - (*first)->axis().up() * particlesystem_script->radius() * fp); + gl::vertex((*first)->location() - (*first)->axis().up() * particlesystem_radius * fp); color.a = f * particlesystem_script->alpha(); gl::color(color); glTexCoord2f(0,t); - gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() - (*next)->axis().up() * particlesystem_radius * f); glTexCoord2f(1,t); - gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_script->radius() * f); + gl::vertex((*next)->location() - (*next)->axis().left() * particlesystem_radius * f); Stats::quads++; first = next; diff --git a/src/render/particles.h b/src/render/particles.h index 88789a5..096833c 100644 --- a/src/render/particles.h +++ b/src/render/particles.h @@ -111,7 +111,7 @@ public: /// axis of the particle system within the entity inline const math::Axis &axis() const { return particlesystem_axis; } - + virtual void draw(float elapsed); void set_timeout(float timeout); @@ -141,7 +141,7 @@ protected: math::Vector3f ejector_location; bool ejector_active; - float radius; + float particlesystem_radius; float now; math::Color color; |