Particlesystems can now be positioned unit height independend

In the faction.xml you can set teh following now:
<flat-particle-positions value="true"/>
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.
This commit is contained in:
titiger 2014-11-26 00:38:04 +01:00
parent 54905c0e5c
commit 3eb9c05b4a
5 changed files with 29 additions and 12 deletions

View File

@ -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<UnitParticleSystem*> &
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()) {

View File

@ -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;

View File

@ -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");

View File

@ -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;

View File

@ -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