summaryrefslogtreecommitdiff
path: root/src/particleemitter.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-10-26 15:41:57 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-10-26 15:41:57 +0000
commit3925d9c41709dece19fe60c0e4bb111247f1886e (patch)
tree9b46a1ed60547c4e3f075536a50faa5342cbbc28 /src/particleemitter.cpp
parent6d426d55fed55f2c01bdafca348cc8bbb06ee063 (diff)
downloadmana-3925d9c41709dece19fe60c0e4bb111247f1886e.tar.gz
mana-3925d9c41709dece19fe60c0e4bb111247f1886e.tar.bz2
mana-3925d9c41709dece19fe60c0e4bb111247f1886e.tar.xz
mana-3925d9c41709dece19fe60c0e4bb111247f1886e.zip
Merged revisions 4302,4338,4360-4362,4526,4528,4534,4547 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0 ........ r4302 | crush_tmw | 2008-05-28 18:51:26 +0200 (Wed, 28 May 2008) | 1 line Changed the way particle emitter skip is handled to make linear and circular emitters work with particleEmitterSkip enabled. ........ r4338 | crush_tmw | 2008-06-05 20:41:39 +0200 (Thu, 05 Jun 2008) | 1 line Lowered default particle detail level. ........ r4360 | crush_tmw | 2008-06-23 16:44:20 +0200 (Mon, 23 Jun 2008) | 1 line Implemented "alpha" particle property. ........ r4361 | crush_tmw | 2008-06-23 22:20:05 +0200 (Mon, 23 Jun 2008) | 1 line Forgot changelog with last commit. ........ r4362 | crush_tmw | 2008-06-24 14:29:33 +0200 (Tue, 24 Jun 2008) | 1 line Added particle property "follow-parent" which makes the particle move when its parent particle is moved. ........ r4526 | crush_tmw | 2008-08-24 20:52:00 +0200 (Sun, 24 Aug 2008) | 1 line Added new particle emitter property "output-pause" which allows to define a fixed (or random) interval between two outputs. ........ r4528 | crush_tmw | 2008-08-24 20:58:39 +0200 (Sun, 24 Aug 2008) | 1 line fix for an error in the last commit ........ r4534 | b_lindeijer | 2008-08-27 20:48:13 +0200 (Wed, 27 Aug 2008) | 3 lines Renamed "randomnes" to "randomness", so that it won't show up as part of Fate's patch. ........ r4547 | crush_tmw | 2008-08-29 00:44:43 +0200 (Fri, 29 Aug 2008) | 1 line Added output-pause to copy constructor of particle emitters. ........
Diffstat (limited to 'src/particleemitter.cpp')
-rw-r--r--src/particleemitter.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index 23c6879e..cd80fb58 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -39,6 +39,7 @@
#define DEG_RAD_FACTOR 0.017453293f
ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, int rotation):
+ mOutputPauseLeft(0),
mParticleImage(0)
{
mMap = map;
@@ -52,8 +53,9 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *
mParticleAngleVertical.set(0.0f);
mParticlePower.set(0.0f);
mParticleGravity.set(0.0f);
- mParticleRandomnes.set(0);
+ mParticleRandomness.set(0);
mParticleBounce.set(0.0f);
+ mParticleFollow = false;
mParticleAcceleration.set(0.0f);
mParticleDieDistance.set(-1.0f);
mParticleMomentum.set(1.0f);
@@ -61,6 +63,8 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *
mParticleFadeOut.set(0);
mParticleFadeIn.set(0);
mOutput.set(1);
+ mOutputPause.set(0);
+ mParticleAlpha.set(1.0f);
for_each_xml_child_node(propertyNode, emitterNode)
{
@@ -114,9 +118,9 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *
{
mParticleGravity = readMinMax(propertyNode, 0.0f);
}
- else if (name == "randomnes")
+ else if (name == "randomnes" || name == "randomness") // legacy bug
{
- mParticleRandomnes = readMinMax(propertyNode, 0);
+ mParticleRandomness = readMinMax(propertyNode, 0);
}
else if (name == "bounce")
{
@@ -132,6 +136,11 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *
mOutput = readMinMax(propertyNode, 0);
mOutput.maxVal +=1;
}
+ else if (name == "output-pause")
+ {
+ mOutputPause = readMinMax(propertyNode, 0);
+ mOutputPauseLeft = mOutputPause.value();
+ }
else if (name == "acceleration")
{
mParticleAcceleration = readMinMax(propertyNode, 0.0f);
@@ -152,6 +161,14 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *
{
mParticleFadeIn = readMinMax(propertyNode, 0);
}
+ else if (name == "alpha")
+ {
+ mParticleAlpha = readMinMax(propertyNode, 1.0f);
+ }
+ else if (name == "follow-parent")
+ {
+ mParticleFollow = true;
+ }
else
{
logger->log("Particle Engine: Warning, unknown emitter property \"%s\"",
@@ -249,8 +266,9 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
mParticleAngleVertical = o.mParticleAngleVertical;
mParticlePower = o.mParticlePower;
mParticleGravity = o.mParticleGravity;
- mParticleRandomnes = o.mParticleRandomnes;
+ mParticleRandomness = o.mParticleRandomness;
mParticleBounce = o.mParticleBounce;
+ mParticleFollow = o.mParticleFollow;
mParticleTarget = o.mParticleTarget;
mParticleAcceleration = o.mParticleAcceleration;
mParticleDieDistance = o.mParticleDieDistance;
@@ -258,12 +276,16 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
mParticleLifetime = o.mParticleLifetime;
mParticleFadeOut = o.mParticleFadeOut;
mParticleFadeIn = o.mParticleFadeIn;
+ mParticleAlpha = o.mParticleAlpha;
mMap = o.mMap;
mOutput = o.mOutput;
+ mOutputPause = o.mOutputPause;
mParticleImage = o.mParticleImage;
mParticleAnimation = o.mParticleAnimation;
mParticleChildEmitters = o.mParticleChildEmitters;
+ mOutputPauseLeft = 0;
+
if (mParticleImage) mParticleImage->incRef();
return *this;
@@ -294,6 +316,13 @@ ParticleEmitter::createParticles()
{
std::list<Particle *> newParticles;
+ if (mOutputPauseLeft > 0)
+ {
+ mOutputPauseLeft--;
+ return newParticles;
+ }
+ mOutputPauseLeft = mOutputPause.value();
+
for (int i = mOutput.value(); i > 0; i--)
{
// Limit maximum particles
@@ -328,9 +357,10 @@ ParticleEmitter::createParticles()
sin(angleH) * cos(angleV) * power,
sin(angleV) * power);
- newParticle->setRandomnes(mParticleRandomnes.value());
+ newParticle->setRandomness(mParticleRandomness.value());
newParticle->setGravity(mParticleGravity.value());
newParticle->setBounce(mParticleBounce.value());
+ newParticle->setFollow(mParticleFollow);
newParticle->setDestination(mParticleTarget,
mParticleAcceleration.value(),
@@ -341,6 +371,7 @@ ParticleEmitter::createParticles()
newParticle->setLifetime(mParticleLifetime.value());
newParticle->setFadeOut(mParticleFadeOut.value());
newParticle->setFadeIn(mParticleFadeIn.value());
+ newParticle->setAlpha(mParticleAlpha.value());
for (std::list<ParticleEmitter>::iterator i = mParticleChildEmitters.begin();
i != mParticleChildEmitters.end();