From 3eb9c05b4a5dd4f865d02f001c73a3c10550966f Mon Sep 17 00:00:00 2001 From: titiger Date: Wed, 26 Nov 2014 00:38:04 +0100 Subject: [PATCH] Particlesystems can now be positioned unit height independend In the faction.xml you can set teh following now: By this the positions of the particle systems ( attack and unit particles ) can be done based of the units centered ground position and by this height independend. --- source/glest_game/type_instances/unit.cpp | 29 +++++++++++++++-------- source/glest_game/type_instances/unit.h | 1 + source/glest_game/types/faction_type.cpp | 6 +++++ source/glest_game/types/faction_type.h | 3 ++- source/glest_game/world/unit_updater.cpp | 2 +- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 6e614e1c..66788446 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -334,7 +334,7 @@ void UnitAttackBoostEffect::applyLoadedAttackBoostParticles(UnitParticleSystemTy ups->setParticleType(upst); upst->setValues(ups); - ups->setPos(unit->getCurrMidHeightVector()); + ups->setPos(unit->getCurrVectorForParticlesystems()); ups->setRotation(unit->getRotation()); ups->setUnitModel(unit->getCurrentModelPtr()); if (unit->getFaction()->getTexture()) { @@ -1600,6 +1600,15 @@ bool Unit::checkModelStateInfoForNewHpValue() { return result; } +Vec3f Unit::getCurrVectorForParticlesystems() const{ + if(getFaction()->getType()->isFlatParticlePositions()){ + return getCurrVectorFlat(); + } + else { + return getCurrMidHeightVector(); + } +} + Vec3f Unit::getCurrMidHeightVector() const{ if(type == NULL) { char szBuf[8096]=""; @@ -2441,7 +2450,7 @@ void Unit::updateAttackBoostProgress(const Game* game) { currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues( currentAttackBoostOriginatorEffect.currentAppliedEffect->ups); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos( - getCurrMidHeightVector()); + getCurrVectorForParticlesystems()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setRotation(getRotation()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setUnitModel(getCurrentModelPtr()); @@ -2554,7 +2563,7 @@ void Unit::updateAttackBoostProgress(const Game* game) { currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues( currentAttackBoostOriginatorEffect.currentAppliedEffect->ups); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos( - getCurrMidHeightVector()); + getCurrVectorForParticlesystems()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setRotation(getRotation()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setUnitModel(getCurrentModelPtr()); @@ -2761,7 +2770,7 @@ bool Unit::update() { if(effect != NULL && effect->ups != NULL) { bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(effect->ups,rsGame); if(particleValid == true) { - effect->ups->setPos(getCurrMidHeightVector()); + effect->ups->setPos(getCurrVectorForParticlesystems()); effect->ups->setRotation(getRotation()); effect->ups->setUnitModel(getCurrentModelPtr()); } @@ -2776,7 +2785,7 @@ bool Unit::update() { if(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups != NULL) { bool particleValid = Renderer::getInstance().validateParticleSystemStillExists(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups,rsGame); if(particleValid == true) { - currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(getCurrMidHeightVector()); + currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(getCurrVectorForParticlesystems()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setRotation(getRotation()); currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setUnitModel(getCurrentModelPtr()); } @@ -2833,7 +2842,7 @@ void Unit::updateTimedParticles() { ups->setParticleType(pst); pst->setValues(ups); - ups->setPos(getCurrMidHeightVector()); + ups->setPos(getCurrVectorForParticlesystems()); ups->setRotation(getRotation()); ups->setUnitModel(getCurrentModelPtr()); @@ -2976,7 +2985,7 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) { effect->ups->setParticleType(effect->upst); effect->upst->setValues(effect->ups); - effect->ups->setPos(getCurrMidHeightVector()); + effect->ups->setPos(getCurrVectorForParticlesystems()); effect->ups->setRotation(getRotation()); effect->ups->setUnitModel(getCurrentModelPtr()); if(getFaction()->getTexture()) { @@ -4120,7 +4129,7 @@ void Unit::checkCustomizedUnitParticleListTriggers(vector & ups->setParticleType(pst); pst->setValues(ups); - ups->setPos(getCurrMidHeightVector()); + ups->setPos(getCurrVectorForParticlesystems()); ups->setRotation(getRotation()); ups->setUnitModel(getCurrentModelPtr()); if(getFaction()->getTexture()) { @@ -4237,7 +4246,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) { ups->setParticleType(pst); pst->setValues(ups); - ups->setPos(getCurrMidHeightVector()); + ups->setPos(getCurrVectorForParticlesystems()); ups->setRotation(getRotation()); ups->setUnitModel(getCurrentModelPtr()); if(getFaction()->getTexture()) { @@ -4268,7 +4277,7 @@ void Unit::startDamageParticles() { ups->setParticleType(pst); pst->setValues(ups); - ups->setPos(getCurrMidHeightVector()); + ups->setPos(getCurrVectorForParticlesystems()); ups->setRotation(getRotation()); ups->setUnitModel(getCurrentModelPtr()); if(getFaction()->getTexture()) { diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index e126675c..56ce11f0 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -638,6 +638,7 @@ public: const Model *getCurrentModel(); Model *getCurrentModelPtr(); Vec3f getCurrMidHeightVector() const; + Vec3f getCurrVectorForParticlesystems() const; Vec3f getCurrVectorAsTarget() const; Vec3f getCurrBurnVector() const; Vec3f getCurrVectorFlat() const; diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index 676aeb84..7c826d22 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -43,6 +43,7 @@ FactionType::FactionType() { healthbarLineBorder=true; healthbarTexture=NULL; healthbarBackgroundTexture=NULL; + flatParticlePositions=false; } //load a faction, given a directory @@ -281,6 +282,11 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec loadedFileList[musicNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(path,musicNode->getAttribute("path")->getRestrictedValue())); } + if(factionNode->hasChild("flat-particle-positions")) { + const XmlNode *node= factionNode->getChild("flat-particle-positions"); + flatParticlePositions = node->getAttribute("value")->getBoolValue(); + } + //healthbar if(factionNode->hasChild("healthbar")) { const XmlNode *healthbarNode= factionNode->getChild("healthbar"); diff --git a/source/glest_game/types/faction_type.h b/source/glest_game/types/faction_type.h index abc0ee84..c965f0ce 100644 --- a/source/glest_game/types/faction_type.h +++ b/source/glest_game/types/faction_type.h @@ -104,7 +104,7 @@ private: bool healthbarLineBorder; Texture2D *healthbarTexture; Texture2D *healthbarBackgroundTexture; - + bool flatParticlePositions; public: //init @@ -138,6 +138,7 @@ public: inline bool isHealthbarLineBorder() const {return healthbarLineBorder;} Texture2D *getHealthbarTexture() const {return healthbarTexture;} Texture2D *getHealthbarBackgroundTexture() const {return healthbarBackgroundTexture;} + bool isFlatParticlePositions() const {return flatParticlePositions;} const UnitType *getUnitType(const string &name) const; diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index d869ec3d..24160cd2 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2665,7 +2665,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit, float lastAnimProgress, ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType(); bool hasProjectile = !ast->projectileTypes.empty(); - Vec3f startPos= unit->getCurrMidHeightVector(); + Vec3f startPos= unit->getCurrVectorForParticlesystems(); Vec3f endPos= unit->getTargetVec(); //make particle system