particles have more switches: day/night visibility , alternating value , radiusBasedStartenergy ( can be disabled now! )
This commit is contained in:
parent
28f74a15f7
commit
c54174061f
|
@ -35,6 +35,7 @@ namespace Glest{ namespace Game{
|
|||
ParticleSystemType::ParticleSystemType() {
|
||||
teamcolorNoEnergy=false;
|
||||
teamcolorEnergy=false;
|
||||
alternations=false;
|
||||
texture=NULL;
|
||||
model=NULL;
|
||||
}
|
||||
|
@ -141,7 +142,11 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||
const XmlNode *teamcolorEnergyNode= particleSystemNode->getChild("teamcolorEnergy");
|
||||
teamcolorEnergy= teamcolorEnergyNode->getAttribute("value")->getBoolValue();
|
||||
}
|
||||
|
||||
//alternations
|
||||
if(particleSystemNode->hasChild("alternations")){
|
||||
const XmlNode *alternatingNode= particleSystemNode->getChild("alternations");
|
||||
alternations= alternatingNode->getAttribute("value")->getIntValue();
|
||||
}
|
||||
//mode
|
||||
if(particleSystemNode->hasChild("mode")){
|
||||
const XmlNode *modeNode= particleSystemNode->getChild("mode");
|
||||
|
@ -169,6 +174,7 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
|
|||
ats->setModel(model);
|
||||
ats->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
||||
ats->setTeamcolorEnergy(teamcolorEnergy);
|
||||
ats->setAlternations(alternations);
|
||||
ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
|||
string mode;
|
||||
bool teamcolorNoEnergy;
|
||||
bool teamcolorEnergy;
|
||||
int alternations;
|
||||
|
||||
public:
|
||||
ParticleSystemType();
|
||||
|
|
|
@ -63,6 +63,33 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
|
|||
staticParticleCount=0;
|
||||
}
|
||||
|
||||
//isVisibleAtNight
|
||||
if(particleSystemNode->hasChild("isVisibleAtNight")){
|
||||
const XmlNode *isVisibleAtNightNode= particleSystemNode->getChild("isVisibleAtNight");
|
||||
isVisibleAtNight= isVisibleAtNightNode->getAttribute("value")->getBoolValue();
|
||||
}
|
||||
else {
|
||||
isVisibleAtNight=true;
|
||||
}
|
||||
|
||||
//isVisibleAtDay
|
||||
if(particleSystemNode->hasChild("isVisibleAtDay")){
|
||||
const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("isVisibleAtDay");
|
||||
isVisibleAtDay= isVisibleAtDayNode->getAttribute("value")->getBoolValue();
|
||||
}
|
||||
else {
|
||||
isVisibleAtDay=true;
|
||||
}
|
||||
|
||||
//radiusBasedStartenergy
|
||||
if(particleSystemNode->hasChild("radiusBasedStartenergy")){
|
||||
const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("radiusBasedStartenergy");
|
||||
radiusBasedStartenergy= isVisibleAtDayNode->getAttribute("value")->getBoolValue();
|
||||
}
|
||||
else{
|
||||
radiusBasedStartenergy= true;
|
||||
}
|
||||
|
||||
//fixed
|
||||
const XmlNode *fixedNode= particleSystemNode->getChild("fixed");
|
||||
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
||||
|
@ -87,9 +114,14 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
|||
ups->setRelativeDirection(relativeDirection);
|
||||
ups->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
||||
ups->setTeamcolorEnergy(teamcolorEnergy);
|
||||
ups->setAlternations(alternations);
|
||||
|
||||
ups->setIsVisibleAtNight(isVisibleAtNight);
|
||||
ups->setIsVisibleAtDay(isVisibleAtDay);
|
||||
ups->setStaticParticleCount(staticParticleCount);
|
||||
ups->setRadius(radius);
|
||||
ups->setBlendMode(ParticleSystem::strToBlendMode(mode));
|
||||
ups->setRadiusBasedStartenergy(radiusBasedStartenergy);
|
||||
//prepare system for given staticParticleCount
|
||||
if(staticParticleCount>0)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,9 @@ protected:
|
|||
bool relativeDirection;
|
||||
bool fixed;
|
||||
int staticParticleCount;
|
||||
bool isVisibleAtNight;
|
||||
bool isVisibleAtDay;
|
||||
bool radiusBasedStartenergy;
|
||||
|
||||
public:
|
||||
void load(const XmlNode *particleSystemNode, const string &dir, RendererInterface *newTexture);
|
||||
|
|
|
@ -56,6 +56,7 @@ void TimeFlow::update() {
|
|||
//day
|
||||
if(lastTime<dawn && time>=dawn){
|
||||
soundRenderer.stopAmbient(ambientSounds->getNight());
|
||||
UnitParticleSystem::isNight=false;
|
||||
}
|
||||
|
||||
if((lastTime<dawn && time>=dawn) || firstTime){
|
||||
|
@ -75,6 +76,7 @@ void TimeFlow::update() {
|
|||
//night
|
||||
if(lastTime<dusk && time>=dusk){
|
||||
soundRenderer.stopAmbient(ambientSounds->getDay());
|
||||
UnitParticleSystem::isNight=true;
|
||||
}
|
||||
|
||||
if(lastTime<dusk && time>=dusk){
|
||||
|
|
|
@ -1332,6 +1332,19 @@ void UnitUpdater::updateRepair(Unit *unit) {
|
|||
//repairPos = command->getPos()-Vec2i(1);
|
||||
}
|
||||
|
||||
if(startRepairing == false && repaired == NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
// we have a repair command to the ground! We must find first units in visible range of target point.
|
||||
|
||||
startRepairing = damagedRepairableUnitOnRange(rct, repairPos, unit->getType()->getSight(), &repaired);
|
||||
//if(startRepairing) command->setPos(repaired->getCenteredPos());
|
||||
if(repaired != NULL){
|
||||
startRepairing = true;
|
||||
nextToRepaired = repaired != NULL && map->isNextTo(unit->getPos(), repaired);
|
||||
repairPos=repaired->getCenteredPos();
|
||||
command->setPos(repairPos);
|
||||
}
|
||||
}
|
||||
//if not repairing
|
||||
if(startRepairing == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -1836,6 +1849,40 @@ void UnitUpdater::findEnemiesForCell(const AttackSkillType *ast, Cell *cell, con
|
|||
}
|
||||
}
|
||||
|
||||
bool UnitUpdater::damagedRepairableUnitOnRange(const RepairCommandType* rct, Vec2i repairPos, int range, Unit **unitToRepair){
|
||||
Vec2f floatRepairPos = Vec2f(repairPos.x, repairPos.y);
|
||||
|
||||
Unit* damagedUnit=NULL;
|
||||
int bestDistanced=-1;
|
||||
|
||||
for(int i=repairPos.x-range; i<repairPos.x+range+1; ++i){
|
||||
for(int j=repairPos.y-range; j<repairPos.y+range+1; ++j){
|
||||
//cells inside map and in range
|
||||
#ifdef USE_STREFLOP
|
||||
if(map->isInside(i, j) && streflop::floor(floatRepairPos.dist(Vec2f((float)i, (float)j))) <= (range+1)){
|
||||
#else
|
||||
if(map->isInside(i, j) && floor(floatRepairPos.dist(Vec2f((float)i, (float)j))) <= (range+1)){
|
||||
#endif
|
||||
Cell *cell = map->getCell(i,j);
|
||||
for(int k = 0; k < fieldCount; k++) {
|
||||
Field f= static_cast<Field>(k);
|
||||
Unit *possibleUnit = cell->getUnit(f);
|
||||
if( possibleUnit != NULL &&
|
||||
possibleUnit->getTeam()==world->getThisTeamIndex() &&
|
||||
rct->isRepairableUnitType(possibleUnit->getType()) &&
|
||||
possibleUnit->isDamaged()) {
|
||||
// possible unit!
|
||||
*unitToRepair=possibleUnit;
|
||||
return true;
|
||||
// TODO choose nearest to repair unit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//if the unit has any enemy on range
|
||||
bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||
const AttackSkillType *ast){
|
||||
|
|
|
@ -126,6 +126,7 @@ private:
|
|||
bool attackableOnRange(const Unit *unit, Unit **enemyPtr, const AttackSkillType *ast);
|
||||
bool unitOnRange(const Unit *unit, int range, Unit **enemyPtr, const AttackSkillType *ast);
|
||||
void enemiesAtDistance(const Unit *unit, const Unit *priorityUnit, int distance, vector<Unit*> &enemies);
|
||||
bool damagedRepairableUnitOnRange(const RepairCommandType* rct, Vec2i repairPos, int range, Unit **unitToRepair);
|
||||
|
||||
Unit * findPeerUnitBuilder(Unit *unit);
|
||||
void SwapActiveCommand(Unit *unitSrc, Unit *unitDest);
|
||||
|
|
|
@ -131,6 +131,7 @@ protected:
|
|||
Vec3f factionColor;
|
||||
bool teamcolorNoEnergy;
|
||||
bool teamcolorEnergy;
|
||||
int alternations;
|
||||
|
||||
ParticleObserver *particleObserver;
|
||||
|
||||
|
@ -154,7 +155,7 @@ public:
|
|||
const Particle *getParticle(int i) const {return &particles[i];}
|
||||
int getAliveParticleCount() const {return aliveParticleCount;}
|
||||
bool getActive() const {return active;}
|
||||
bool getVisible() const {return visible;}
|
||||
virtual bool getVisible() const {return visible;}
|
||||
|
||||
//set
|
||||
void setState(State state);
|
||||
|
@ -173,6 +174,7 @@ public:
|
|||
void setBlendMode(BlendMode blendMode) {this->blendMode= blendMode;}
|
||||
void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;}
|
||||
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
|
||||
void setAlternations(int alternations) {this->alternations= alternations;}
|
||||
virtual void setFactionColor(Vec3f factionColor);
|
||||
|
||||
static BlendMode strToBlendMode(const string &str);
|
||||
|
@ -219,6 +221,8 @@ public:
|
|||
// =====================================================
|
||||
|
||||
class UnitParticleSystem: public ParticleSystem{
|
||||
public:
|
||||
static bool isNight;
|
||||
private:
|
||||
float radius;
|
||||
Vec3f windSpeed;
|
||||
|
@ -242,6 +246,10 @@ public:
|
|||
float sizeNoEnergy;
|
||||
float gravity;
|
||||
float rotation;
|
||||
bool isVisibleAtNight;
|
||||
bool isVisibleAtDay;
|
||||
bool radiusBasedStartenergy;
|
||||
|
||||
int staticParticleCount;
|
||||
|
||||
public:
|
||||
|
@ -254,6 +262,7 @@ public:
|
|||
virtual void updateParticle(Particle *p);
|
||||
virtual void update();
|
||||
virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
|
||||
virtual bool getVisible() const;
|
||||
|
||||
//set params
|
||||
void setRadius(float radius);
|
||||
|
@ -269,6 +278,9 @@ public:
|
|||
void setFixed(bool fixed) {this->fixed= fixed;}
|
||||
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
||||
void setStaticParticleCount(int staticParticleCount){this->staticParticleCount= staticParticleCount;}
|
||||
void setIsVisibleAtNight(bool value) {this->isVisibleAtNight= value;}
|
||||
void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;}
|
||||
void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;}
|
||||
|
||||
static Primitive strToPrimitive(const string &str);
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ using namespace std;
|
|||
using namespace Shared::Util;
|
||||
using namespace Shared::PlatformCommon;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
namespace Shared {
|
||||
namespace Graphics {
|
||||
|
||||
// =====================================================
|
||||
// class ParticleSystem
|
||||
|
@ -62,6 +63,7 @@ ParticleSystem::ParticleSystem(int particleCount) {
|
|||
speed= 1.0f;
|
||||
teamcolorNoEnergy= false;
|
||||
teamcolorEnergy= false;
|
||||
alternations= 0;
|
||||
}
|
||||
|
||||
ParticleSystem::~ParticleSystem(){
|
||||
|
@ -69,7 +71,6 @@ ParticleSystem::~ParticleSystem(){
|
|||
particles.clear();
|
||||
}
|
||||
|
||||
|
||||
// =============== VIRTUAL ======================
|
||||
|
||||
//updates all living particles and creates new ones
|
||||
|
@ -124,7 +125,6 @@ ParticleSystem::BlendMode ParticleSystem::strToBlendMode(const string &str){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// =============== SET ==========================
|
||||
|
||||
void ParticleSystem::setState(State state){
|
||||
|
@ -270,23 +270,21 @@ void ParticleSystem::setFactionColor(Vec3f factionColor){
|
|||
this->factionColor= factionColor;
|
||||
Vec3f tmpCol;
|
||||
|
||||
if(teamcolorEnergy)
|
||||
{
|
||||
if(teamcolorEnergy){
|
||||
this->color= Vec4f(factionColor.x, factionColor.y, factionColor.z, this->color.w);
|
||||
}
|
||||
if(teamcolorNoEnergy)
|
||||
{
|
||||
if(teamcolorNoEnergy){
|
||||
this->colorNoEnergy= Vec4f(factionColor.x, factionColor.y, factionColor.z, this->colorNoEnergy.w);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
// FireParticleSystem
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
FireParticleSystem::FireParticleSystem(int particleCount): ParticleSystem(particleCount){
|
||||
FireParticleSystem::FireParticleSystem(int particleCount) :
|
||||
ParticleSystem(particleCount){
|
||||
|
||||
radius= 0.5f;
|
||||
speed= 0.01f;
|
||||
|
@ -317,7 +315,8 @@ void FireParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
#endif
|
||||
|
||||
p->color= colorNoEnergy * 0.5f + colorNoEnergy * 0.5f * radRatio;
|
||||
p->energy= static_cast<int>(maxParticleEnergy*radRatio) + random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
p->energy= static_cast<int> (maxParticleEnergy * radRatio)
|
||||
+ random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
p->pos= Vec3f(pos.x + x, pos.y + random.randRange(-radius / 2, radius / 2), pos.z + y);
|
||||
p->lastPos= pos;
|
||||
p->size= particleSize;
|
||||
|
@ -358,13 +357,13 @@ void FireParticleSystem::setWind(float windAngle, float windSpeed){
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
// UnitParticleSystem
|
||||
// ===========================================================================
|
||||
bool UnitParticleSystem::isNight= false;
|
||||
|
||||
UnitParticleSystem::UnitParticleSystem(int particleCount): ParticleSystem(particleCount){
|
||||
|
||||
UnitParticleSystem::UnitParticleSystem(int particleCount) :
|
||||
ParticleSystem(particleCount){
|
||||
radius= 0.5f;
|
||||
speed= 0.01f;
|
||||
windSpeed= Vec3f(0.0f);
|
||||
|
@ -383,16 +382,28 @@ UnitParticleSystem::UnitParticleSystem(int particleCount): ParticleSystem(partic
|
|||
relative= false;
|
||||
staticParticleCount= 0;
|
||||
|
||||
isVisibleAtNight= true;
|
||||
isVisibleAtDay= true;
|
||||
|
||||
cRotation= Vec3f(1.0f, 1.0f, 1.0f);
|
||||
fixedAddition= Vec3f(0.0f, 0.0f, 0.0f);
|
||||
//prepare system for given staticParticleCount
|
||||
if(staticParticleCount>0)
|
||||
{
|
||||
if(staticParticleCount > 0){
|
||||
emissionState= (float) staticParticleCount;
|
||||
}
|
||||
energyUp= false;
|
||||
}
|
||||
|
||||
bool UnitParticleSystem::getVisible() const{
|
||||
if((isNight==true) && (isVisibleAtNight==true)){
|
||||
return visible;
|
||||
}
|
||||
else if((isNight==false) && (isVisibleAtDay==true)){
|
||||
return visible;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
void UnitParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
|
||||
//if(active){
|
||||
switch(primitive){
|
||||
|
@ -420,7 +431,6 @@ UnitParticleSystem::Primitive UnitParticleSystem::strToPrimitive(const string &s
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||
ParticleSystem::initParticle(p, particleIndex);
|
||||
|
||||
|
@ -443,23 +453,28 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
|
||||
//p->color= color*0.5f + color*0.5f*radRatio;
|
||||
p->color= color;
|
||||
p->energy= static_cast<int>(maxParticleEnergy*radRatio) + random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
if(radiusBasedStartenergy == true){
|
||||
p->energy= static_cast<int> (maxParticleEnergy * radRatio) + random.randRange(-varParticleEnergy,
|
||||
varParticleEnergy);
|
||||
}
|
||||
else{
|
||||
p->energy= static_cast<int> (maxParticleEnergy) + random.randRange(-varParticleEnergy, varParticleEnergy);
|
||||
}
|
||||
|
||||
p->lastPos= pos;
|
||||
oldPosition= pos;
|
||||
p->size= particleSize;
|
||||
|
||||
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= 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;
|
||||
p->accel= Vec3f(0.0f, -gravity, 0.0f);
|
||||
|
||||
if(relative == false){
|
||||
p->pos= Vec3f(pos.x+x+offset.x, pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+offset.z);
|
||||
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
|
||||
else{// rotate it according to rotation
|
||||
float rad= degToRad(rotation);
|
||||
#ifdef USE_STREFLOP
|
||||
p->pos= Vec3f(pos.x+x+offset.z*streflop::sinf(rad)+offset.x*streflop::cosf(rad), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(rad)-offset.x*streflop::sinf(rad)));
|
||||
|
@ -467,9 +482,11 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->speed=Vec3f(p->speed.z*streflop::sinf(rad)+p->speed.x*streflop::cosf(rad),p->speed.y,(p->speed.z*streflop::cosf(rad)-p->speed.x*streflop::sinf(rad)));
|
||||
}
|
||||
#else
|
||||
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)));
|
||||
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)));
|
||||
if(relativeDirection){
|
||||
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)));
|
||||
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
|
||||
|
@ -477,8 +494,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
}
|
||||
|
||||
void UnitParticleSystem::update(){
|
||||
if(fixed)
|
||||
{
|
||||
if(fixed){
|
||||
fixedAddition= Vec3f(pos.x - oldPosition.x, pos.y - oldPosition.y, pos.z - oldPosition.z);
|
||||
oldPosition= pos;
|
||||
}
|
||||
|
@ -486,27 +502,37 @@ void UnitParticleSystem::update(){
|
|||
}
|
||||
|
||||
void UnitParticleSystem::updateParticle(Particle *p){
|
||||
float energyRatio;
|
||||
if(alternations > 0){
|
||||
int interval= (maxParticleEnergy / alternations);
|
||||
float moduloValue= static_cast<int> (static_cast<float> (p->energy)) % interval;
|
||||
|
||||
float energyRatio= clamp(static_cast<float>(p->energy)/maxParticleEnergy, 0.f, 1.f);
|
||||
if(moduloValue < interval / 2){
|
||||
energyRatio= (interval - moduloValue) / interval;
|
||||
}
|
||||
else{
|
||||
energyRatio= moduloValue / interval;
|
||||
}
|
||||
energyRatio= clamp(energyRatio, 0.f, 1.f);
|
||||
}
|
||||
else{
|
||||
energyRatio= clamp(static_cast<float> (p->energy) / maxParticleEnergy, 0.f, 1.f);
|
||||
}
|
||||
|
||||
p->lastPos+= p->speed;
|
||||
p->pos+= p->speed;
|
||||
if(fixed)
|
||||
{
|
||||
if(fixed){
|
||||
p->lastPos+= fixedAddition;
|
||||
p->pos+= fixedAddition;
|
||||
}
|
||||
p->speed+= p->accel;
|
||||
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
|
||||
p->size= particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio);
|
||||
if(state == ParticleSystem::sFade || staticParticleCount<1)
|
||||
{
|
||||
if(state == ParticleSystem::sFade || staticParticleCount < 1){
|
||||
p->energy--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(maxParticleEnergy>2)
|
||||
{
|
||||
else{
|
||||
if(maxParticleEnergy > 2){
|
||||
if(energyUp){
|
||||
p->energy++;
|
||||
}
|
||||
|
@ -542,15 +568,13 @@ void UnitParticleSystem::setWind(float windAngle, float windSpeed){
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
// RainParticleSystem
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
RainParticleSystem::RainParticleSystem(int particleCount):ParticleSystem(particleCount){
|
||||
RainParticleSystem::RainParticleSystem(int particleCount) :
|
||||
ParticleSystem(particleCount){
|
||||
setWind(0.0f, 0.0f);
|
||||
setRadius(20.0f);
|
||||
|
||||
|
@ -574,7 +598,8 @@ void RainParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->energy= 10000;
|
||||
p->pos= Vec3f(pos.x + x, pos.y, pos.z + y);
|
||||
p->lastPos= p->pos;
|
||||
p->speed= Vec3f(random.randRange(-speed/10, speed/10), -speed, random.randRange(-speed/10, speed/10)) + windSpeed;
|
||||
p->speed= Vec3f(random.randRange(-speed / 10, speed / 10), -speed, random.randRange(-speed / 10, speed / 10))
|
||||
+ windSpeed;
|
||||
}
|
||||
|
||||
bool RainParticleSystem::deathTest(Particle *p){
|
||||
|
@ -602,7 +627,8 @@ void RainParticleSystem::setWind(float windAngle, float windSpeed){
|
|||
// SnowParticleSystem
|
||||
// ===========================================================================
|
||||
|
||||
SnowParticleSystem::SnowParticleSystem(int particleCount):ParticleSystem(particleCount){
|
||||
SnowParticleSystem::SnowParticleSystem(int particleCount) :
|
||||
ParticleSystem(particleCount){
|
||||
setWind(0.0f, 0.0f);
|
||||
setRadius(30.0f);
|
||||
|
||||
|
@ -652,7 +678,8 @@ void SnowParticleSystem::setWind(float windAngle, float windSpeed){
|
|||
// AttackParticleSystem
|
||||
// ===========================================================================
|
||||
|
||||
AttackParticleSystem::AttackParticleSystem(int particleCount): ParticleSystem(particleCount){
|
||||
AttackParticleSystem::AttackParticleSystem(int particleCount) :
|
||||
ParticleSystem(particleCount){
|
||||
model= NULL;
|
||||
primitive= pQuad;
|
||||
offset= Vec3f(0.0f);
|
||||
|
@ -694,7 +721,8 @@ AttackParticleSystem::Primitive AttackParticleSystem::strToPrimitive(const strin
|
|||
// ProjectileParticleSystem
|
||||
// ===========================================================================
|
||||
|
||||
ProjectileParticleSystem::ProjectileParticleSystem(int particleCount): AttackParticleSystem(particleCount){
|
||||
ProjectileParticleSystem::ProjectileParticleSystem(int particleCount) :
|
||||
AttackParticleSystem(particleCount){
|
||||
setEmissionRate(20.0f);
|
||||
setColor(Vec4f(1.0f, 0.3f, 0.0f, 0.5f));
|
||||
setMaxParticleEnergy(100);
|
||||
|
@ -736,14 +764,12 @@ void ProjectileParticleSystem::update(){
|
|||
|
||||
// trajectory
|
||||
switch(trajectory){
|
||||
case tLinear:
|
||||
{
|
||||
case tLinear: {
|
||||
pos= flatPos;
|
||||
}
|
||||
break;
|
||||
|
||||
case tParabolic:
|
||||
{
|
||||
case tParabolic: {
|
||||
float scaledT= 2.0f * (t - 0.5f);
|
||||
float paraboleY= (1.0f - scaledT * scaledT) * trajectoryScale;
|
||||
|
||||
|
@ -752,8 +778,7 @@ void ProjectileParticleSystem::update(){
|
|||
}
|
||||
break;
|
||||
|
||||
case tSpiral:
|
||||
{
|
||||
case tSpiral: {
|
||||
pos= flatPos;
|
||||
#ifdef USE_STREFLOP
|
||||
pos+= xVector * streflop::cos(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
|
@ -799,7 +824,8 @@ void ProjectileParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
|
||||
p->pos= pos + (lastPos - pos) * t;
|
||||
p->lastPos= lastPos;
|
||||
p->speed= Vec3f(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f)) * speed;
|
||||
p->speed= Vec3f(random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f), random.randRange(-0.1f, 0.1f))
|
||||
* speed;
|
||||
p->accel= Vec3f(0.0f, -gravity, 0.0f);
|
||||
|
||||
updateParticle(p);
|
||||
|
@ -863,7 +889,8 @@ ProjectileParticleSystem::Trajectory ProjectileParticleSystem::strToTrajectory(c
|
|||
// SplashParticleSystem
|
||||
// ===========================================================================
|
||||
|
||||
SplashParticleSystem::SplashParticleSystem(int particleCount): AttackParticleSystem(particleCount){
|
||||
SplashParticleSystem::SplashParticleSystem(int particleCount) :
|
||||
AttackParticleSystem(particleCount){
|
||||
setColor(Vec4f(1.0f, 0.3f, 0.0f, 0.8f));
|
||||
setMaxParticleEnergy(100);
|
||||
setVarParticleEnergy(50);
|
||||
|
@ -889,8 +916,7 @@ void SplashParticleSystem::update(){
|
|||
ParticleSystem::update();
|
||||
if(state != sPause){
|
||||
emissionRate-= emissionRateFade;
|
||||
if(emissionRate<0.0f)
|
||||
{//otherwise this system lives forever!
|
||||
if(emissionRate < 0.0f){//otherwise this system lives forever!
|
||||
fade();
|
||||
}
|
||||
}
|
||||
|
@ -903,10 +929,9 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
|
|||
p->size= particleSize;
|
||||
p->color= color;
|
||||
|
||||
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= 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;
|
||||
|
||||
|
@ -954,8 +979,7 @@ bool ParticleManager::hasActiveParticleSystem(ParticleSystem::ParticleSystemType
|
|||
currentParticleCount+= ps->getAliveParticleCount();
|
||||
|
||||
bool showParticle= true;
|
||||
if( dynamic_cast<UnitParticleSystem *>(ps) != NULL ||
|
||||
dynamic_cast<FireParticleSystem *>(ps) != NULL ) {
|
||||
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){
|
||||
showParticle= ps->getVisible() || (ps->getState() == ParticleSystem::sFade);
|
||||
}
|
||||
if(showParticle == true){
|
||||
|
@ -987,8 +1011,7 @@ void ParticleManager::update(int renderFps) {
|
|||
currentParticleCount+= ps->getAliveParticleCount();
|
||||
|
||||
bool showParticle= true;
|
||||
if( dynamic_cast<UnitParticleSystem *>(ps) != NULL ||
|
||||
dynamic_cast<FireParticleSystem *>(ps) != NULL ) {
|
||||
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){
|
||||
showParticle= ps->getVisible() || (ps->getState() == ParticleSystem::sFade);
|
||||
}
|
||||
if(showParticle == true){
|
||||
|
@ -1004,7 +1027,8 @@ void ParticleManager::update(int renderFps) {
|
|||
//particleSystems.remove(NULL);
|
||||
cleanupParticleSystems(cleanupParticleSystemsList);
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld, particleSystemCount = %d, currentParticleCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),particleSystemCount,currentParticleCount);
|
||||
if(chrono.getMillis() > 0)
|
||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld, particleSystemCount = %d, currentParticleCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),particleSystemCount,currentParticleCount);
|
||||
}
|
||||
|
||||
bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particleSystem) const{
|
||||
|
@ -1065,4 +1089,5 @@ void ParticleManager::end() {
|
|||
}
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
}
|
||||
}//end namespace
|
||||
|
|
Loading…
Reference in New Issue
Block a user