- rollback last commit

This commit is contained in:
Mark Vejvoda
2013-09-26 16:37:32 +00:00
parent 7349a1f126
commit 37c2ace11a
24 changed files with 342 additions and 327 deletions

View File

@@ -45,11 +45,11 @@ class Model;
class Particle {
public:
//attributes
Vec3d pos;
Vec3d lastPos;
Vec3d speed;
Vec3d accel;
Vec4d color;
Vec3f pos;
Vec3f lastPos;
Vec3f speed;
Vec3f accel;
Vec4f color;
double size;
int energy;
@@ -59,14 +59,11 @@ public:
energy = 0;
}
//get
Vec3d getPos() const {return pos;}
Vec3f getPosAsFloat() const {return Vec3f(pos.x,pos.y,pos.z);}
Vec3d getLastPos() const {return lastPos;}
Vec3f getLastPosAsFloat() const {return Vec3f(lastPos.x,lastPos.y,lastPos.z);}
Vec3d getSpeed() const {return speed;}
Vec3d getAccel() const {return accel;}
Vec4d getColor() const {return color;}
Vec4f getColorAsFloat() const {return Vec4f(color.x,color.y,color.z,color.w);}
Vec3f getPos() const {return pos;}
Vec3f getLastPos() const {return lastPos;}
Vec3f getSpeed() const {return speed;}
Vec3f getAccel() const {return accel;}
Vec4f getColor() const {return color;}
double getSize() const {return size;}
int getEnergy() const {return energy;}
@@ -88,7 +85,6 @@ public:
class ParticleOwner {
public:
virtual ~ParticleOwner() {};
virtual void end(ParticleSystem *particleSystem)= 0;
};
@@ -97,6 +93,7 @@ public:
// =====================================================
class ParticleSystem {
public:
enum State {
@@ -138,16 +135,16 @@ protected:
int textureFileLoadDeferredComponents;
Texture *texture;
Vec3d pos;
Vec4d color;
Vec4d colorNoEnergy;
Vec3f pos;
Vec4f color;
Vec4f colorNoEnergy;
double emissionRate;
double emissionState;
int maxParticleEnergy;
int varParticleEnergy;
double particleSize;
double speed;
Vec3d factionColor;
Vec3f factionColor;
bool teamcolorNoEnergy;
bool teamcolorEnergy;
int alternations;
@@ -169,8 +166,7 @@ public:
State getState() const {return state;}
BlendMode getBlendMode() const {return blendMode;}
Texture *getTexture() const {return texture;}
Vec3d getPos() const {return pos;}
Vec3f getPosAsFloat() const {return Vec3f(pos.x,pos.y,pos.z);}
Vec3f getPos() const {return pos;}
Particle *getParticle(int i) {return &particles[i];}
const Particle *getParticle(int i) const {return &particles[i];}
int getAliveParticleCount() const {return aliveParticleCount;}
@@ -185,9 +181,9 @@ public:
//set
virtual void setState(State state);
void setTexture(Texture *texture);
virtual void setPos(Vec3d pos);
void setColor(Vec4d color);
void setColorNoEnergy(Vec4d color);
virtual void setPos(Vec3f pos);
void setColor(Vec4f color);
void setColorNoEnergy(Vec4f color);
void setEmissionRate(double emissionRate);
void setMaxParticleEnergy(int maxParticleEnergy);
void setVarParticleEnergy(int varParticleEnergy);
@@ -201,7 +197,7 @@ public:
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
void setAlternations(int alternations) {this->alternations= alternations;}
void setParticleSystemStartDelay(int delay) {this->particleSystemStartDelay= delay;}
virtual void setFactionColor(Vec3d factionColor);
virtual void setFactionColor(Vec3f factionColor);
static BlendMode strToBlendMode(const string &str);
//misc
@@ -241,7 +237,7 @@ protected:
class FireParticleSystem: public ParticleSystem{
private:
double radius;
Vec3d windSpeed;
Vec3f windSpeed;
public:
FireParticleSystem(int particleCount= 2000);
@@ -284,8 +280,8 @@ public:
ParticleSystem* getChild(int i);
void addChild(UnitParticleSystem* child);
void removeChild(UnitParticleSystem* child);
void setPos(Vec3d pos);
void setOffset(Vec3d offset);
void setPos(Vec3f pos);
void setOffset(Vec3f offset);
void setModel(Model *model) {this->model= model;}
virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
double getTween() { return tween; } // 0.0 -> 1.0 for animation of model
@@ -293,8 +289,7 @@ public:
virtual string getModelFileLoadDeferred();
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
Vec3d getDirection() const {return direction;}
Vec3f getDirectionAsFloat() const {return Vec3f(direction.x, direction.y, direction.z);}
Vec3f getDirection() const {return direction;}
void setModelCycle(double modelCycle) {this->modelCycle= modelCycle;}
virtual void saveGame(XmlNode *rootNode);
@@ -312,8 +307,8 @@ protected:
string modelFileLoadDeferred;
Model *model;
double modelCycle;
Vec3d offset;
Vec3d direction;
Vec3f offset;
Vec3f direction;
double tween;
GameParticleSystem(int particleCount);
@@ -328,14 +323,14 @@ protected:
class UnitParticleSystem: public GameParticleSystem{
public:
static bool isNight;
static Vec3d lightColor;
static Vec3f lightColor;
private:
double radius;
double minRadius;
Vec3d windSpeed;
Vec3d cRotation;
Vec3d fixedAddition;
Vec3d oldPosition;
Vec3f windSpeed;
Vec3f cRotation;
Vec3f fixedAddition;
Vec3f oldPosition;
bool energyUp;
double startTime;
double endTime;
@@ -390,7 +385,7 @@ public:
void setWind(double windAngle, double windSpeed);
void setDirection(Vec3d direction) {this->direction= direction;}
void setDirection(Vec3f direction) {this->direction= direction;}
void setSizeNoEnergy(double sizeNoEnergy) {this->sizeNoEnergy= sizeNoEnergy;}
void setGravity(double gravity) {this->gravity= gravity;}
void setRotation(double rotation);
@@ -409,7 +404,7 @@ public:
void setLifetime(int lifetime) {this->lifetime= lifetime;}
void setParent(GameParticleSystem* parent) {this->parent= parent;}
GameParticleSystem* getParent() const {return parent;}
void setParentDirection(Vec3d parentDirection);
void setParentDirection(Vec3f parentDirection);
static Shape strToShape(const string& str);
@@ -427,7 +422,7 @@ public:
class RainParticleSystem: public ParticleSystem{
private:
Vec3d windSpeed;
Vec3f windSpeed;
double radius;
public:
@@ -454,7 +449,7 @@ public:
class SnowParticleSystem: public ParticleSystem{
private:
Vec3d windSpeed;
Vec3f windSpeed;
double radius;
public:
@@ -519,14 +514,14 @@ public:
private:
SplashParticleSystem *nextParticleSystem;
Vec3d lastPos;
Vec3d startPos;
Vec3d endPos;
Vec3d flatPos;
Vec3f lastPos;
Vec3f startPos;
Vec3f endPos;
Vec3f flatPos;
Vec3d xVector;
Vec3d yVector;
Vec3d zVector;
Vec3f xVector;
Vec3f yVector;
Vec3f zVector;
Trajectory trajectory;
double trajectorySpeed;
@@ -555,7 +550,7 @@ public:
void setTrajectoryScale(double trajectoryScale) {this->trajectoryScale= trajectoryScale;}
void setTrajectoryFrequency(double trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;}
void setPath(Vec3d startPos, Vec3d endPos);
void setPath(Vec3f startPos, Vec3f endPos);
static Trajectory strToTrajectory(const string &str);

View File

@@ -109,8 +109,8 @@ void ParticleRendererGl::renderSystem(ParticleSystem *ps){
for(int i=0; i<ps->getAliveParticleCount(); ++i){
const Particle *particle= ps->getParticle(i);
float size= particle->getSize()/2.0f;
Vec3f pos= particle->getPosAsFloat();
Vec4f color= particle->getColorAsFloat();
Vec3f pos= particle->getPos();
Vec4f color= particle->getColor();
vertexBuffer[bufferIndex] = pos - (rightVector - upVector) * size;
vertexBuffer[bufferIndex+1] = pos - (rightVector + upVector) * size;
@@ -157,10 +157,10 @@ void ParticleRendererGl::renderSystemLine(ParticleSystem *ps){
for(int i=0; i<ps->getAliveParticleCount(); ++i){
particle= ps->getParticle(i);
Vec4f color= particle->getColorAsFloat();
Vec4f color= particle->getColor();
vertexBuffer[bufferIndex] = particle->getPosAsFloat();
vertexBuffer[bufferIndex+1] = particle->getLastPosAsFloat();
vertexBuffer[bufferIndex] = particle->getPos();
vertexBuffer[bufferIndex+1] = particle->getLastPos();
colorBuffer[bufferIndex]= color;
colorBuffer[bufferIndex+1]= color;
@@ -201,10 +201,10 @@ void ParticleRendererGl::renderSystemLineAlpha(ParticleSystem *ps){
for(int i=0; i<ps->getAliveParticleCount(); ++i){
particle= ps->getParticle(i);
Vec4f color= particle->getColorAsFloat();
Vec4f color= particle->getColor();
vertexBuffer[bufferIndex] = particle->getPosAsFloat();
vertexBuffer[bufferIndex+1] = particle->getLastPosAsFloat();
vertexBuffer[bufferIndex] = particle->getPos();
vertexBuffer[bufferIndex+1] = particle->getLastPos();
colorBuffer[bufferIndex]= color;
colorBuffer[bufferIndex+1]= color;
@@ -236,11 +236,11 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
glPushMatrix();
//translate
Vec3f pos= ps->getPosAsFloat();
Vec3f pos= ps->getPos();
glTranslatef(pos.x, pos.y, pos.z);
//rotate
Vec3f direction= ps->getDirectionAsFloat();
Vec3f direction= ps->getDirection();
Vec3f flatDirection= Vec3f(direction.x, 0.f, direction.z);
Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection);

View File

@@ -65,15 +65,15 @@ void Particle::loadGame(const XmlNode *rootNode) {
//particleNode = aiNode->getAttribute("startLoc")->getIntValue();
// Vec3f pos;
pos = Vec3d::strToVec3(particleNode->getAttribute("pos")->getValue());
pos = Vec3f::strToVec3(particleNode->getAttribute("pos")->getValue());
// Vec3f lastPos;
lastPos = Vec3d::strToVec3(particleNode->getAttribute("lastPos")->getValue());
lastPos = Vec3f::strToVec3(particleNode->getAttribute("lastPos")->getValue());
// Vec3f speed;
speed = Vec3d::strToVec3(particleNode->getAttribute("speed")->getValue());
speed = Vec3f::strToVec3(particleNode->getAttribute("speed")->getValue());
// Vec3f accel;
accel = Vec3d::strToVec3(particleNode->getAttribute("accel")->getValue());
accel = Vec3f::strToVec3(particleNode->getAttribute("accel")->getValue());
// Vec4f color;
color = Vec4d::strToVec4(particleNode->getAttribute("color")->getValue());
color = Vec4f::strToVec4(particleNode->getAttribute("color")->getValue());
// float size;
size = particleNode->getAttribute("size")->getFloatValue();
// int energy;
@@ -112,9 +112,9 @@ ParticleSystem::ParticleSystem(int particleCount) {
//this->particleCount= particles.size();
maxParticleEnergy= 250;
varParticleEnergy= 50;
pos= Vec3d(0.0f);
color= Vec4d(1.0f);
colorNoEnergy= Vec4d(0.0f);
pos= Vec3f(0.0f);
color= Vec4f(1.0f);
colorNoEnergy= Vec4f(0.0f);
emissionRate= 15.0f;
emissionState= 1.0f; // initialized with 1 because we must have at least one particle in the beginning!
speed= 1.0f;
@@ -251,17 +251,17 @@ void ParticleSystem::setTexture(Texture *texture){
this->texture= texture;
}
void ParticleSystem::setPos(Vec3d pos){
void ParticleSystem::setPos(Vec3f pos){
this->pos= pos;
for(int i=getChildCount()-1; i>=0; i--)
getChild(i)->setPos(pos);
}
void ParticleSystem::setColor(Vec4d color){
void ParticleSystem::setColor(Vec4f color){
this->color= color;
}
void ParticleSystem::setColorNoEnergy(Vec4d colorNoEnergy){
void ParticleSystem::setColorNoEnergy(Vec4f colorNoEnergy){
this->colorNoEnergy= colorNoEnergy;
}
@@ -485,11 +485,11 @@ void ParticleSystem::loadGame(const XmlNode *rootNode) {
}
// Vec3f pos;
pos = Vec3d::strToVec3(particleSystemNode->getAttribute("pos")->getValue());
pos = Vec3f::strToVec3(particleSystemNode->getAttribute("pos")->getValue());
// Vec4f color;
color = Vec4d::strToVec4(particleSystemNode->getAttribute("color")->getValue());
color = Vec4f::strToVec4(particleSystemNode->getAttribute("color")->getValue());
// Vec4f colorNoEnergy;
colorNoEnergy = Vec4d::strToVec4(particleSystemNode->getAttribute("colorNoEnergy")->getValue());
colorNoEnergy = Vec4f::strToVec4(particleSystemNode->getAttribute("colorNoEnergy")->getValue());
// float emissionRate;
emissionRate = particleSystemNode->getAttribute("emissionRate")->getFloatValue();
// float emissionState;
@@ -503,7 +503,7 @@ void ParticleSystem::loadGame(const XmlNode *rootNode) {
// float speed;
speed = particleSystemNode->getAttribute("speed")->getFloatValue();
// Vec3f factionColor;
factionColor = Vec3d::strToVec3(particleSystemNode->getAttribute("factionColor")->getValue());
factionColor = Vec3f::strToVec3(particleSystemNode->getAttribute("factionColor")->getValue());
// bool teamcolorNoEnergy;
teamcolorNoEnergy = particleSystemNode->getAttribute("teamcolorNoEnergy")->getIntValue() != 0;
// bool teamcolorEnergy;
@@ -601,9 +601,9 @@ Particle * ParticleSystem::createParticle(){
void ParticleSystem::initParticle(Particle *p, int particleIndex){
p->pos= pos;
p->lastPos= p->pos;
p->speed= Vec3d(0.0f);
p->accel= Vec3d(0.0f);
p->color= Vec4d(1.0f, 1.0f, 1.0f, 1.0);
p->speed= Vec3f(0.0f);
p->accel= Vec3f(0.0f);
p->color= Vec4f(1.0f, 1.0f, 1.0f, 1.0);
p->size= particleSize;
p->energy= maxParticleEnergy + random.randRange(-varParticleEnergy, varParticleEnergy);
}
@@ -623,15 +623,15 @@ void ParticleSystem::killParticle(Particle *p){
aliveParticleCount--;
}
void ParticleSystem::setFactionColor(Vec3d factionColor){
void ParticleSystem::setFactionColor(Vec3f factionColor){
this->factionColor= factionColor;
Vec3d tmpCol;
Vec3f tmpCol;
if(teamcolorEnergy){
this->color= Vec4d(factionColor.x, factionColor.y, factionColor.z, this->color.w);
this->color= Vec4f(factionColor.x, factionColor.y, factionColor.z, this->color.w);
}
if(teamcolorNoEnergy){
this->colorNoEnergy= Vec4d(factionColor.x, factionColor.y, factionColor.z, this->colorNoEnergy.w);
this->colorNoEnergy= Vec4f(factionColor.x, factionColor.y, factionColor.z, this->colorNoEnergy.w);
}
for(int i=getChildCount()-1; i>=0; i--)
getChild(i)->setFactionColor(factionColor);
@@ -647,10 +647,10 @@ FireParticleSystem::FireParticleSystem(int particleCount) :
radius= 0.5f;
speed= 0.01f;
windSpeed= Vec3d(0.0f);
windSpeed= Vec3f(0.0f);
setParticleSize(0.6f);
setColorNoEnergy(Vec4d(1.0f, 0.5f, 0.0f, 1.0f));
setColorNoEnergy(Vec4f(1.0f, 0.5f, 0.0f, 1.0f));
}
void FireParticleSystem::initParticle(Particle *p, int particleIndex){
@@ -676,10 +676,10 @@ void FireParticleSystem::initParticle(Particle *p, int particleIndex){
p->color= colorNoEnergy * 0.5f + colorNoEnergy * 0.5f * radRatio;
p->energy= static_cast<int> (maxParticleEnergy * radRatio)
+ random.randRange(-varParticleEnergy, varParticleEnergy);
p->pos= Vec3d(pos.x + x, pos.y + random.randRange(-radius / 2, radius / 2), pos.z + y);
p->pos= Vec3f(pos.x + x, pos.y + random.randRange(-radius / 2, radius / 2), pos.z + y);
p->lastPos= pos;
p->size= particleSize;
p->speed= Vec3d(0, speed + speed * random.randRange(-0.5f, 0.5f), 0) + windSpeed;
p->speed= Vec3f(0, speed + speed * random.randRange(-0.5f, 0.5f), 0) + windSpeed;
}
void FireParticleSystem::updateParticle(Particle *p){
@@ -744,7 +744,7 @@ void FireParticleSystem::loadGame(const XmlNode *rootNode) {
// float radius;
radius = fireParticleSystemNode->getAttribute("radius")->getFloatValue();
// Vec3f windSpeed;
windSpeed = Vec3d::strToVec3(fireParticleSystemNode->getAttribute("windSpeed")->getValue());
windSpeed = Vec3f::strToVec3(fireParticleSystemNode->getAttribute("windSpeed")->getValue());
}
Checksum FireParticleSystem::getCRC() {
@@ -810,18 +810,18 @@ void GameParticleSystem::removeChild(UnitParticleSystem* child){
children.erase(it);
}
void GameParticleSystem::setPos(Vec3d pos){
void GameParticleSystem::setPos(Vec3f pos){
this->pos= pos;
positionChildren();
}
void GameParticleSystem::positionChildren() {
Vec3d child_pos = pos - offset;
Vec3f child_pos = pos - offset;
for(int i=getChildCount()-1; i>=0; i--)
getChild(i)->setPos(child_pos);
}
void GameParticleSystem::setOffset(Vec3d offset){
void GameParticleSystem::setOffset(Vec3f offset){
this->offset= offset;
positionChildren();
}
@@ -952,9 +952,9 @@ void GameParticleSystem::loadGame(const XmlNode *rootNode) {
//gameParticleSystemNode->addAttribute("modelCycle",floatToStr(modelCycle), mapTagReplacements);
modelCycle = gameParticleSystemNode->getAttribute("modelCycle")->getFloatValue();
// Vec3f offset;
offset = Vec3d::strToVec3(gameParticleSystemNode->getAttribute("offset")->getValue());
offset = Vec3f::strToVec3(gameParticleSystemNode->getAttribute("offset")->getValue());
// Vec3f direction;
direction = Vec3d::strToVec3(gameParticleSystemNode->getAttribute("direction")->getValue());
direction = Vec3f::strToVec3(gameParticleSystemNode->getAttribute("direction")->getValue());
// float tween;
tween = gameParticleSystemNode->getAttribute("tween")->getFloatValue();
}
@@ -986,17 +986,17 @@ string GameParticleSystem::toString() const {
// UnitParticleSystem
// ===========================================================================
bool UnitParticleSystem::isNight= false;
Vec3d UnitParticleSystem::lightColor=Vec3d(1.0f,1.0f,1.0f);
Vec3f UnitParticleSystem::lightColor=Vec3f(1.0f,1.0f,1.0f);
UnitParticleSystem::UnitParticleSystem(int particleCount) :
GameParticleSystem(particleCount), parent(NULL) {
radius= 0.5f;
speed= 0.01f;
windSpeed= Vec3d(0.0f);
windSpeed= Vec3f(0.0f);
minRadius = 0.0;
setParticleSize(0.6f);
setColorNoEnergy(Vec4d(1.0f, 0.5f, 0.0f, 1.0f));
setColorNoEnergy(Vec4f(1.0f, 0.5f, 0.0f, 1.0f));
sizeNoEnergy=1.0f;
primitive= pQuad;
@@ -1014,8 +1014,8 @@ UnitParticleSystem::UnitParticleSystem(int particleCount) :
isVisibleAtDay= true;
isDaylightAffected= false;
cRotation= Vec3d(1.0f, 1.0f, 1.0f);
fixedAddition= Vec3d(0.0f, 0.0f, 0.0f);
cRotation= Vec3f(1.0f, 1.0f, 1.0f);
fixedAddition= Vec3f(0.0f, 0.0f, 0.0f);
//prepare system for given staticParticleCount
if(staticParticleCount > 0){
emissionState= (double) staticParticleCount;
@@ -1108,7 +1108,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
p->lastPos= pos;
oldPosition= pos;
p->size= particleSize;
p->accel= Vec3d(0.0f, -gravity, 0.0f);
p->accel= Vec3f(0.0f, -gravity, 0.0f);
// work out where we start for our shape (set speed and pos)
switch(shape){
@@ -1116,9 +1116,9 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
angle = (double)random.randRange(0,360);
// fall through
case sConical:{
Vec2d horiz = Vec2d(1,0).rotate(ang);
Vec2d vert = Vec2d(1,0).rotate(degToRad(angle));
Vec3d start = Vec3d(horiz.x*vert.y,vert.x,horiz.y).getNormalized(); // close enough
Vec2f horiz = Vec2f(1,0).rotate(ang);
Vec2f vert = Vec2f(1,0).rotate(degToRad(angle));
Vec3f start = Vec3f(horiz.x*vert.y,vert.x,horiz.y).getNormalized(); // close enough
p->speed = start * speed;
start = start * random.randRange(minRadius,radius);
p->pos = pos + offset + start;
@@ -1133,25 +1133,25 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
#endif
const double rad= degToRad(rotation);
if(!relative){
p->pos= Vec3d(pos.x + x + offset.x, pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y
p->pos= Vec3f(pos.x + x + offset.x, pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y
+ offset.z);
}
else{// rotate it according to rotation
#ifdef USE_STREFLOP
p->pos= Vec3d(pos.x+x+offset.z*streflop::sinf(static_cast<streflop::Simple>(rad))+offset.x*streflop::cosf(static_cast<streflop::Simple>(rad)), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(static_cast<streflop::Simple>(rad))-offset.x*streflop::sinf(static_cast<streflop::Simple>(rad))));
p->pos= Vec3f(pos.x+x+offset.z*streflop::sinf(static_cast<streflop::Simple>(rad))+offset.x*streflop::cosf(static_cast<streflop::Simple>(rad)), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(static_cast<streflop::Simple>(rad))-offset.x*streflop::sinf(static_cast<streflop::Simple>(rad))));
#else
p->pos= Vec3d(pos.x + x + offset.z * sinf(rad) + offset.x * cosf(rad), pos.y + random.randRange(-radius / 2,
p->pos= Vec3f(pos.x + x + offset.z * sinf(rad) + offset.x * cosf(rad), pos.y + random.randRange(-radius / 2,
radius / 2) + offset.y, pos.z + y + (offset.z * cosf(rad) - offset.x * sinf(rad)));
#endif
}
p->speed= Vec3d(direction.x + direction.x * random.randRange(-0.5f, 0.5f), direction.y + direction.y
p->speed= Vec3f(direction.x + direction.x * random.randRange(-0.5f, 0.5f), direction.y + direction.y
* random.randRange(-0.5f, 0.5f), direction.z + direction.z * random.randRange(-0.5f, 0.5f));
p->speed= p->speed * speed;
if(relative && relativeDirection){
#ifdef USE_STREFLOP
p->speed=Vec3d(p->speed.z*streflop::sinf(static_cast<streflop::Simple>(rad))+p->speed.x*streflop::cosf(static_cast<streflop::Simple>(rad)),p->speed.y,(p->speed.z*streflop::cosf(static_cast<streflop::Simple>(rad))-p->speed.x*streflop::sinf(static_cast<streflop::Simple>(rad))));
p->speed=Vec3f(p->speed.z*streflop::sinf(static_cast<streflop::Simple>(rad))+p->speed.x*streflop::cosf(static_cast<streflop::Simple>(rad)),p->speed.y,(p->speed.z*streflop::cosf(static_cast<streflop::Simple>(rad))-p->speed.x*streflop::sinf(static_cast<streflop::Simple>(rad))));
#else
p->speed= Vec3d(p->speed.z * sinf(rad) + p->speed.x * cosf(rad), p->speed.y, (p->speed.z * cosf(rad)
p->speed= Vec3f(p->speed.z * sinf(rad) + p->speed.x * cosf(rad), p->speed.y, (p->speed.z * cosf(rad)
- p->speed.x * sinf(rad)));
#endif
}
@@ -1175,7 +1175,7 @@ void UnitParticleSystem::update(){
}
}
if(fixed){
fixedAddition= Vec3d(pos.x - oldPosition.x, pos.y - oldPosition.y, pos.z - oldPosition.z);
fixedAddition= Vec3f(pos.x - oldPosition.x, pos.y - oldPosition.y, pos.z - oldPosition.z);
oldPosition= pos;
}
ParticleSystem::update();
@@ -1323,13 +1323,13 @@ void UnitParticleSystem::loadGame(const XmlNode *rootNode) {
// float minRadius;
minRadius = unitParticleSystemNode->getAttribute("minRadius")->getFloatValue();
// Vec3f windSpeed;
windSpeed = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("windSpeed")->getValue());
windSpeed = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("windSpeed")->getValue());
// Vec3f cRotation;
windSpeed = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("cRotation")->getValue());
windSpeed = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("cRotation")->getValue());
// Vec3f fixedAddition;
fixedAddition = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("fixedAddition")->getValue());
fixedAddition = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("fixedAddition")->getValue());
// Vec3f oldPosition;
oldPosition = Vec3d::strToVec3(unitParticleSystemNode->getAttribute("oldPosition")->getValue());
oldPosition = Vec3f::strToVec3(unitParticleSystemNode->getAttribute("oldPosition")->getValue());
// bool energyUp;
energyUp = unitParticleSystemNode->getAttribute("energyUp")->getIntValue() != 0;
// float startTime;
@@ -1434,7 +1434,7 @@ RainParticleSystem::RainParticleSystem(int particleCount) :
setEmissionRate(25.0f);
setParticleSize(3.0f);
setColor(Vec4d(0.5f, 0.5f, 0.5f, 0.3f));
setColor(Vec4f(0.5f, 0.5f, 0.5f, 0.3f));
setSpeed(0.2f);
}
@@ -1450,9 +1450,9 @@ void RainParticleSystem::initParticle(Particle *p, int particleIndex){
p->color= color;
p->energy= 10000;
p->pos= Vec3d(pos.x + x, pos.y, pos.z + y);
p->pos= Vec3f(pos.x + x, pos.y, pos.z + y);
p->lastPos= p->pos;
p->speed= Vec3d(random.randRange(-speed / 10, speed / 10), -speed, random.randRange(-speed / 10, speed / 10))
p->speed= Vec3f(random.randRange(-speed / 10, speed / 10), -speed, random.randRange(-speed / 10, speed / 10))
+ windSpeed;
}
@@ -1504,7 +1504,7 @@ SnowParticleSystem::SnowParticleSystem(int particleCount) :
setEmissionRate(2.0f);
setParticleSize(0.2f);
setColor(Vec4d(0.8f, 0.8f, 0.8f, 0.8f));
setColor(Vec4f(0.8f, 0.8f, 0.8f, 0.8f));
setSpeed(0.05f);
}
@@ -1517,9 +1517,9 @@ void SnowParticleSystem::initParticle(Particle *p, int particleIndex){
p->color= color;
p->energy= 10000;
p->pos= Vec3d(pos.x + x, pos.y, pos.z + y);
p->pos= Vec3f(pos.x + x, pos.y, pos.z + y);
p->lastPos= p->pos;
p->speed= Vec3d(0.0f, -speed, 0.0f) + windSpeed;
p->speed= Vec3f(0.0f, -speed, 0.0f) + windSpeed;
p->speed.x+= random.randRange(-0.005f, 0.005f);
p->speed.y+= random.randRange(-0.005f, 0.005f);
}
@@ -1617,7 +1617,7 @@ string AttackParticleSystem::toString() const {
ProjectileParticleSystem::ProjectileParticleSystem(int particleCount) :
AttackParticleSystem(particleCount){
setEmissionRate(20.0f);
setColor(Vec4d(1.0f, 0.3f, 0.0f, 0.5f));
setColor(Vec4f(1.0f, 0.3f, 0.0f, 0.5f));
setMaxParticleEnergy(100);
setVarParticleEnergy(50);
setParticleSize(0.4f);
@@ -1658,12 +1658,12 @@ void ProjectileParticleSystem::update(){
flatPos.y = truncateDecimal<double>(flatPos.y);
flatPos.z = truncateDecimal<double>(flatPos.z);
Vec3d targetVector = endPos - startPos;
Vec3f targetVector = endPos - startPos;
targetVector.x = truncateDecimal<double>(targetVector.x);
targetVector.y = truncateDecimal<double>(targetVector.y);
targetVector.z = truncateDecimal<double>(targetVector.z);
Vec3d currentVector = flatPos - startPos;
Vec3f currentVector = flatPos - startPos;
currentVector.x = truncateDecimal<double>(currentVector.x);
currentVector.y = truncateDecimal<double>(currentVector.y);
currentVector.z = truncateDecimal<double>(currentVector.z);
@@ -1775,9 +1775,9 @@ void ProjectileParticleSystem::initParticle(Particle *p, int particleIndex){
p->pos= pos + (lastPos - pos) * t;
p->lastPos= lastPos;
p->speed= Vec3d(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f))
p->speed= Vec3f(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f))
* speed;
p->accel= Vec3d(0.0f, -gravity, 0.0f);
p->accel= Vec3f(0.0f, -gravity, 0.0f);
updateParticle(p);
}
@@ -1794,12 +1794,12 @@ void ProjectileParticleSystem::updateParticle(Particle *p){
p->energy--;
}
void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){
void ProjectileParticleSystem::setPath(Vec3f startPos, Vec3f endPos){
//compute axis
zVector= endPos - startPos;
zVector.normalize();
yVector= Vec3d(0.0f, 1.0f, 0.0f);
yVector= Vec3f(0.0f, 1.0f, 0.0f);
xVector= zVector.cross(yVector);
//apply offset
@@ -1814,7 +1814,7 @@ void ProjectileParticleSystem::setPath(Vec3d startPos, Vec3d endPos){
//recompute axis
zVector= endPos - startPos;
zVector.normalize();
yVector= Vec3d(0.0f, 1.0f, 0.0f);
yVector= Vec3f(0.0f, 1.0f, 0.0f);
xVector= zVector.cross(yVector);
// set members
@@ -1894,20 +1894,20 @@ void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) {
nextParticleSystem->loadGame(splashParticleSystemNode);
}
// Vec3f lastPos;
lastPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("lastPos")->getValue());
lastPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("lastPos")->getValue());
// Vec3f startPos;
startPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("startPos")->getValue());
startPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("startPos")->getValue());
// Vec3f endPos;
endPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("endPos")->getValue());
endPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("endPos")->getValue());
// Vec3f flatPos;
flatPos = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("flatPos")->getValue());
flatPos = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("flatPos")->getValue());
//
// Vec3f xVector;
xVector = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("xVector")->getValue());
xVector = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("xVector")->getValue());
// Vec3f yVector;
yVector = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("yVector")->getValue());
yVector = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("yVector")->getValue());
// Vec3f zVector;
zVector = Vec3d::strToVec3(projectileParticleSystemNode->getAttribute("zVector")->getValue());
zVector = Vec3f::strToVec3(projectileParticleSystemNode->getAttribute("zVector")->getValue());
// Trajectory trajectory;
trajectory = static_cast<Trajectory>(projectileParticleSystemNode->getAttribute("trajectory")->getIntValue());
// float trajectorySpeed;
@@ -1958,7 +1958,7 @@ string ProjectileParticleSystem::toString() const {
SplashParticleSystem::SplashParticleSystem(int particleCount) :
AttackParticleSystem(particleCount){
setColor(Vec4d(1.0f, 0.3f, 0.0f, 0.8f));
setColor(Vec4f(1.0f, 0.3f, 0.0f, 0.8f));
setMaxParticleEnergy(100);
setVarParticleEnergy(50);
setParticleSize(1.0f);
@@ -2008,13 +2008,13 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
p->size= particleSize;
p->color= color;
p->speed= Vec3d(horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB, verticalSpreadA
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)
+ horizontalSpreadB);
p->speed.normalize();
p->speed= p->speed * speed;
p->accel= Vec3d(0.0f, -gravity, 0.0f);
p->accel= Vec3f(0.0f, -gravity, 0.0f);
}
void SplashParticleSystem::updateParticle(Particle *p){