mirror of
https://github.com/glest/glest-source.git
synced 2025-08-27 17:59:48 +02:00
Unit and Splash particles can be speeded up.
You can set a constant value and a relative value.
This commit is contained in:
@@ -50,6 +50,10 @@ void Particle::saveGame(XmlNode *rootNode) {
|
||||
particleNode->addAttribute("lastPos",lastPos.getString(), mapTagReplacements);
|
||||
// Vec3f speed;
|
||||
particleNode->addAttribute("speed",speed.getString(), mapTagReplacements);
|
||||
// Vec3f speedUpRelative;
|
||||
particleNode->addAttribute("speedUpRelative",floatToStr(speedUpRelative,6), mapTagReplacements);
|
||||
// Vec3f speedUpConstant;
|
||||
particleNode->addAttribute("speedUpConstant",speedUpConstant.getString(), mapTagReplacements);
|
||||
// Vec3f accel;
|
||||
particleNode->addAttribute("accel",accel.getString(), mapTagReplacements);
|
||||
// Vec4f color;
|
||||
@@ -70,6 +74,10 @@ void Particle::loadGame(const XmlNode *rootNode) {
|
||||
lastPos = Vec3f::strToVec3(particleNode->getAttribute("lastPos")->getValue());
|
||||
// Vec3f speed;
|
||||
speed = Vec3f::strToVec3(particleNode->getAttribute("speed")->getValue());
|
||||
// Vec3f speed;
|
||||
speedUpRelative = particleNode->getAttribute("speedUpRelative")->getFloatValue();
|
||||
// Vec3f speed;
|
||||
speedUpConstant = Vec3f::strToVec3(particleNode->getAttribute("speedUpConstant")->getValue());
|
||||
// Vec3f accel;
|
||||
accel = Vec3f::strToVec3(particleNode->getAttribute("accel")->getValue());
|
||||
// Vec4f color;
|
||||
@@ -290,6 +298,16 @@ void ParticleSystem::setSpeed(float speed){
|
||||
this->speed = truncateDecimal<float>(this->speed,6);
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpeedUpRelative(float speedUpRelative){
|
||||
this->speedUpRelative= speedUpRelative;
|
||||
this->speedUpRelative = truncateDecimal<float>(this->speedUpRelative,6);
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpeedUpConstant(float speedUpConstant){
|
||||
this->speedUpConstant= speedUpConstant;
|
||||
this->speedUpConstant = truncateDecimal<float>(this->speedUpConstant,6);
|
||||
}
|
||||
|
||||
void ParticleSystem::setActive(bool active){
|
||||
this->active= active;
|
||||
for(int i=getChildCount()-1; i>=0; i--)
|
||||
@@ -1114,9 +1132,10 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
p->lastPos= pos;
|
||||
oldPosition= pos;
|
||||
p->size= particleSize;
|
||||
p->speedUpRelative= speedUpRelative;
|
||||
p->accel= Vec3f(0.0f, -gravity, 0.0f);
|
||||
p->accel.x = truncateDecimal<float>(p->accel.x,6);
|
||||
p->accel.y = truncateDecimal<float>(p->accel.y,6);
|
||||
p->accel.y = truncateDecimal<float>(p->accel.y-gravity,6);
|
||||
p->accel.z = truncateDecimal<float>(p->accel.z,6);
|
||||
|
||||
// work out where we start for our shape (set speed and pos)
|
||||
@@ -1228,6 +1247,8 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
} break;
|
||||
default: throw megaglest_runtime_error("bad shape");
|
||||
}
|
||||
//need to do that down here because we need p->speed for it.
|
||||
p->speedUpConstant= Vec3f(speedUpConstant)*p->speed;
|
||||
}
|
||||
|
||||
void UnitParticleSystem::update(){
|
||||
@@ -1299,6 +1320,8 @@ void UnitParticleSystem::updateParticle(Particle *p){
|
||||
p->pos.z = truncateDecimal<float>(p->pos.z,6);
|
||||
}
|
||||
p->speed += p->accel;
|
||||
p->speed += p->speedUpConstant;
|
||||
p->speed=p->speed*(1+p->speedUpRelative);
|
||||
p->speed.x = truncateDecimal<float>(p->speed.x,6);
|
||||
p->speed.y = truncateDecimal<float>(p->speed.y,6);
|
||||
p->speed.z = truncateDecimal<float>(p->speed.z,6);
|
||||
@@ -2220,6 +2243,7 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
p->energy= maxParticleEnergy;
|
||||
p->size= particleSize;
|
||||
p->color= color;
|
||||
p->speedUpRelative= speedUpRelative;
|
||||
|
||||
p->speed= Vec3f(horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB, verticalSpreadA
|
||||
* random.randRange(-1.0f, 1.0f) + verticalSpreadB, horizontalSpreadA * random.randRange(-1.0f, 1.0f)
|
||||
@@ -2243,6 +2267,7 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
p->accel.y = truncateDecimal<float>(p->accel.y,6);
|
||||
p->accel.z = truncateDecimal<float>(p->accel.z,6);
|
||||
|
||||
p->speedUpConstant= Vec3f(speedUpConstant)*p->speed;
|
||||
}
|
||||
|
||||
void SplashParticleSystem::updateParticle(Particle *p){
|
||||
@@ -2254,6 +2279,8 @@ void SplashParticleSystem::updateParticle(Particle *p){
|
||||
p->pos.y = truncateDecimal<float>(p->pos.y,6);
|
||||
p->pos.z = truncateDecimal<float>(p->pos.z,6);
|
||||
|
||||
p->speed += p->speedUpConstant;
|
||||
p->speed=p->speed*(1+p->speedUpRelative);
|
||||
p->speed= p->speed + p->accel;
|
||||
p->speed.x = truncateDecimal<float>(p->speed.x,6);
|
||||
p->speed.y = truncateDecimal<float>(p->speed.y,6);
|
||||
|
Reference in New Issue
Block a user