48 static const float SIN45 = 0.707106781F;
56 Map *
const map,
const int rotation,
57 const std::string& dyePalettes) :
58 mParticleTarget(target),
63 mParticleAnimation(
"particle animation"),
64 mParticleRotation(
"particle rotation"),
67 mParticleChildEmitters(),
70 mDeathEffectConditions(0),
71 mParticleFollow(false)
93 if (emitterNode ==
nullptr)
97 if (xmlNameEqual(propertyNode,
"property"))
100 propertyNode,
"name",
"");
102 if (name ==
"position-x")
106 else if (name ==
"position-y")
113 else if (name ==
"position-z")
120 else if (name ==
"image")
123 propertyNode,
"value",
"");
127 if (!dyePalettes.empty())
132 else if (name ==
"subimage")
135 propertyNode,
"value",
"");
139 if (!dyePalettes.empty())
157 else if (name ==
"horizontal-angle")
162 +=
static_cast<float>(rotation);
165 +=
static_cast<float>(rotation);
169 else if (name ==
"vertical-angle")
177 else if (name ==
"power")
181 else if (name ==
"gravity")
185 else if (name ==
"randomnes"
186 || name ==
"randomness")
190 else if (name ==
"bounce")
194 else if (name ==
"lifetime")
199 else if (name ==
"output")
204 else if (name ==
"output-pause")
209 else if (name ==
"acceleration")
214 else if (name ==
"die-distance")
219 else if (name ==
"momentum")
224 else if (name ==
"fade-out")
228 else if (name ==
"fade-in")
232 else if (name ==
"alpha")
236 else if (name ==
"follow-parent")
240 if (value ==
"1" || value ==
"true")
246 "unknown emitter property \"%s\"",
250 else if (xmlNameEqual(propertyNode,
"emitter"))
253 rotation, dyePalettes);
256 else if (xmlNameEqual(propertyNode,
"rotation")
257 || xmlNameEqual(propertyNode,
"animation"))
260 if (imageset ==
nullptr)
267 Animation &animation = (xmlNameEqual(propertyNode,
"rotation")) !=
274 frameNode,
"delay", 0, 0, 100000);
280 frameNode,
"rand", 100, 0, 100);
282 if (xmlNameEqual(frameNode,
"frame"))
292 Image *
const img = imageset->
get(index);
296 logger->
log(
"No image at index %d", index);
301 offsetX, offsetY, rand);
303 else if (xmlNameEqual(frameNode,
"sequence"))
308 if (
start < 0 || end < 0)
310 logger->
log1(
"No valid value for 'start' or 'end'");
324 offsetX, offsetY, rand);
328 else if (xmlNameEqual(frameNode,
"end"))
334 else if (xmlNameEqual(propertyNode,
"deatheffect"))
336 if (!XmlHaveChildContent(propertyNode))
381 node,
"imageset",
""));
478 static_cast<double>(def)));
481 propertyNode,
"max",
static_cast<double>(def))));
484 propertyNode,
"change-func",
"none");
486 "change-amplitude", 0.0));
490 if (change ==
"saw" || change ==
"sawtooth")
493 amplitude, period, phase);
495 else if (change ==
"sine" || change ==
"sinewave")
498 amplitude, period, phase);
500 else if (change ==
"triangle")
503 amplitude, period, phase);
505 else if (change ==
"square")
508 amplitude, period, phase);
515 STD_VECTOR<Particle*> &newParticles)
567 newParticle->
moveTo(position);
570 const float cosAngleH =
static_cast<float>(cos(angleH));
571 const float sinAngleH =
static_cast<float>(sin(angleH));
573 const float cosAngleV =
static_cast<float>(cos(angleV));
574 const float sinAngleV =
static_cast<float>(sin(angleV));
576 newParticle->
setVelocity(cosAngleH * cosAngleV * power,
577 sinAngleH * cosAngleV * power,
602 newParticles.push_back(newParticle);
608 if (w == 0 || h == 0)
625 const int newArea = w * h;
627 const float outputFactor =
static_cast<float>(newArea)
628 /
static_cast<float>(oldArea);
virtual void setMap(Map *const map)
void addTerminator(const int rand)
void addFrame(Image *const image, const int delay, const int offsetX, const int offsetY, const int rand)
static void instantiate(std::string &target, const std::string &palettes)
static StringIntMap imageParticleCountByName
Image * get(const size_type i) const
void log(const char *const log_text,...)
void log1(const char *const log_text)
ParticleEmitter(const xmlNode *const emitterNode, Particle *const target, Map *const map, const int rotation, const std::string &dyePalettes)
Particle * mParticleTarget
ParticleEmitterProp< float > mParticlePosZ
ParticleEmitterProp< int > mOutput
static ImageSet * getImageSet(xmlNode *const node)
ParticleEmitterProp< float > mParticleAngleHorizontal
ParticleEmitterProp< float > mParticleDieDistance
ParticleEmitterProp< int > mParticleFadeIn
std::list< ParticleEmitter > mParticleChildEmitters
static ParticleEmitterProp< T > readParticleEmitterProp(xmlNode *const propertyNode, T def)
signed char mDeathEffectConditions
ParticleEmitterProp< int > mParticleRandomness
ParticleEmitterProp< float > mParticlePower
ParticleEmitterProp< int > mParticleLifetime
void adjustSize(const int w, const int h)
ParticleEmitterProp< float > mParticleAngleVertical
ParticleEmitterProp< float > mParticleAcceleration
ParticleEmitterProp< float > mParticleGravity
void createParticles(const int tick, std::vector< Particle * > &newParticles)
ParticleEmitter & operator=(const ParticleEmitter &o)
ParticleEmitterProp< int > mParticleFadeOut
ParticleEmitterProp< float > mParticleAlpha
Animation mParticleAnimation
ParticleEmitterProp< float > mParticlePosX
ParticleEmitterProp< float > mParticleBounce
Animation mParticleRotation
std::vector< ImageSet * > mTempSets
ParticleEmitterProp< float > mParticleMomentum
ParticleEmitterProp< float > mParticlePosY
ParticleEmitterProp< int > mOutputPause
void setDieDistance(const float dist)
void setLifetime(const int lifetime)
void setDestination(Particle *const target, const float accel, const float moment)
void setGravity(const float gravity)
void setBounce(const float bouncieness)
void setFollow(const bool follow)
void setRandomness(const int r)
virtual void setDeathEffect(const std::string &effectFile, const signed char conditions)
void addEmitter(ParticleEmitter *const emitter)
void setFadeIn(const int fadeIn)
void setFadeOut(const int fadeOut)
void moveTo(const Vector &pos)
void setAlpha(const float alpha)
void setVelocity(const float x, const float y, const float z)
static const int mapTileSize
#define FOR_EACH(type, iter, array)
#define for_each_xml_child_node(var, parent)
bool find(const std::string &key)
ImageSet * getSubImageSet(Image *const parent, const int width, const int height)
Image * getImage(const std::string &idPath)
ImageSet * getImageSet(const std::string &imagePath, const int w, const int h)
Image * getSubImage(Image *const parent, const int x, const int y, const int width, const int height)
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
int getProperty(const xmlNodePtr node, const char *const name, int def)
int getIntProperty(const xmlNodePtr node, const char *const name, int def, const int min, const int max)
double getDoubleProperty(const xmlNodePtr node, const char *const name, double def)
std::vector< ImageSet * >::const_iterator ImageSetVectorCIter
std::list< ParticleEmitter >::const_iterator ParticleEmitterListCIter
static const float DEG_RAD_FACTOR
void setFunction(ParticleChangeFuncT func, T amplitude, const int period, const int phase)
void set(const T min, const T max)