mirror of
https://github.com/glest/glest-source.git
synced 2025-08-12 03:14:00 +02:00
bugfix/improvement for teamcolor particles ** units can morph to flying units ** tech faction with particles
This commit is contained in:
@@ -30,6 +30,8 @@ namespace Glest{ namespace Game{
|
|||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
ParticleSystemType::ParticleSystemType(){
|
ParticleSystemType::ParticleSystemType(){
|
||||||
|
teamcolorNoEnergy=false;
|
||||||
|
teamcolorEnergy=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir){
|
void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir){
|
||||||
@@ -118,6 +120,17 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||||||
const XmlNode *energyVarNode= particleSystemNode->getChild("energy-var");
|
const XmlNode *energyVarNode= particleSystemNode->getChild("energy-var");
|
||||||
energyVar= energyVarNode->getAttribute("value")->getIntValue();
|
energyVar= energyVarNode->getAttribute("value")->getIntValue();
|
||||||
|
|
||||||
|
//teamcolorNoEnergy
|
||||||
|
if(particleSystemNode->hasChild("teamcolorNoEnergy")){
|
||||||
|
const XmlNode *teamcolorNoEnergyNode= particleSystemNode->getChild("teamcolorNoEnergy");
|
||||||
|
teamcolorNoEnergy= teamcolorNoEnergyNode->getAttribute("value")->getBoolValue();
|
||||||
|
}
|
||||||
|
//teamcolorEnergy
|
||||||
|
if(particleSystemNode->hasChild("teamcolorEnergy")){
|
||||||
|
const XmlNode *teamcolorEnergyNode= particleSystemNode->getChild("teamcolorEnergy");
|
||||||
|
teamcolorEnergy= teamcolorEnergyNode->getAttribute("value")->getBoolValue();
|
||||||
|
}
|
||||||
|
|
||||||
//mode
|
//mode
|
||||||
if(particleSystemNode->hasChild("mode")){
|
if(particleSystemNode->hasChild("mode")){
|
||||||
const XmlNode *modeNode= particleSystemNode->getChild("mode");
|
const XmlNode *modeNode= particleSystemNode->getChild("mode");
|
||||||
@@ -144,6 +157,8 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
|
|||||||
ats->setMaxParticleEnergy(energyMax);
|
ats->setMaxParticleEnergy(energyMax);
|
||||||
ats->setVarParticleEnergy(energyVar);
|
ats->setVarParticleEnergy(energyVar);
|
||||||
ats->setModel(model);
|
ats->setModel(model);
|
||||||
|
ats->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
||||||
|
ats->setTeamcolorEnergy(teamcolorEnergy);
|
||||||
ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
|
ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,6 +58,8 @@ protected:
|
|||||||
int energyMax;
|
int energyMax;
|
||||||
int energyVar;
|
int energyVar;
|
||||||
string mode;
|
string mode;
|
||||||
|
bool teamcolorNoEnergy;
|
||||||
|
bool teamcolorEnergy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ParticleSystemType();
|
ParticleSystemType();
|
||||||
|
@@ -125,12 +125,15 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
|
|||||||
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
||||||
|
|
||||||
//teamcolorNoEnergy
|
//teamcolorNoEnergy
|
||||||
|
if(particleSystemNode->hasChild("teamcolorNoEnergy")){
|
||||||
const XmlNode *teamcolorNoEnergyNode= particleSystemNode->getChild("teamcolorNoEnergy");
|
const XmlNode *teamcolorNoEnergyNode= particleSystemNode->getChild("teamcolorNoEnergy");
|
||||||
teamcolorNoEnergy= teamcolorNoEnergyNode->getAttribute("value")->getBoolValue();
|
teamcolorNoEnergy= teamcolorNoEnergyNode->getAttribute("value")->getBoolValue();
|
||||||
|
}
|
||||||
//teamcolorEnergy
|
//teamcolorEnergy
|
||||||
|
if(particleSystemNode->hasChild("teamcolorEnergy")){
|
||||||
const XmlNode *teamcolorEnergyNode= particleSystemNode->getChild("teamcolorEnergy");
|
const XmlNode *teamcolorEnergyNode= particleSystemNode->getChild("teamcolorEnergy");
|
||||||
teamcolorEnergy= teamcolorEnergyNode->getAttribute("value")->getBoolValue();
|
teamcolorEnergy= teamcolorEnergyNode->getAttribute("value")->getBoolValue();
|
||||||
|
}
|
||||||
|
|
||||||
//mode
|
//mode
|
||||||
if(particleSystemNode->hasChild("mode")){
|
if(particleSystemNode->hasChild("mode")){
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -84,7 +84,6 @@ bool Faction::getCpuControl() const{
|
|||||||
return control==ctCpuEasy ||control==ctCpu || control==ctCpuUltra|| control==ctCpuMega;
|
return control==ctCpuEasy ||control==ctCpu || control==ctCpuUltra|| control==ctCpuMega;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ==================== upgrade manager ====================
|
// ==================== upgrade manager ====================
|
||||||
|
|
||||||
void Faction::startUpgrade(const UpgradeType *ut){
|
void Faction::startUpgrade(const UpgradeType *ut){
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@@ -331,7 +331,7 @@ void Unit::setCurrSkill(const SkillType *currSkill){
|
|||||||
ups= new UnitParticleSystem(200);
|
ups= new UnitParticleSystem(200);
|
||||||
(*it)->setValues(ups);
|
(*it)->setValues(ups);
|
||||||
ups->setPos(getCurrVector());
|
ups->setPos(getCurrVector());
|
||||||
ups->setTeamNumber(getTeam());
|
ups->setFactionColor(getFaction()->getTexture()->getPixmap()->getPixel3f(0,0));
|
||||||
unitParticleSystems.push_back(ups);
|
unitParticleSystems.push_back(ups);
|
||||||
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
||||||
}
|
}
|
||||||
@@ -876,12 +876,16 @@ void Unit::incKills(){
|
|||||||
bool Unit::morph(const MorphCommandType *mct){
|
bool Unit::morph(const MorphCommandType *mct){
|
||||||
const UnitType *morphUnitType= mct->getMorphUnit();
|
const UnitType *morphUnitType= mct->getMorphUnit();
|
||||||
|
|
||||||
if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), currField, this)){
|
Field morphUnitField=fLand;
|
||||||
|
if(morphUnitType->getField(fAir)) morphUnitField=fAir;
|
||||||
|
if(morphUnitType->getField(fLand)) morphUnitField=fLand;
|
||||||
|
if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), morphUnitField, this)){
|
||||||
map->clearUnitCells(this, pos);
|
map->clearUnitCells(this, pos);
|
||||||
faction->deApplyStaticCosts(type);
|
faction->deApplyStaticCosts(type);
|
||||||
hp+= morphUnitType->getMaxHp() - type->getMaxHp();
|
hp+= morphUnitType->getMaxHp() - type->getMaxHp();
|
||||||
type= morphUnitType;
|
type= morphUnitType;
|
||||||
level= NULL;
|
level= NULL;
|
||||||
|
currField=morphUnitField;
|
||||||
computeTotalUpgrade();
|
computeTotalUpgrade();
|
||||||
map->putUnitCells(this, pos);
|
map->putUnitCells(this, pos);
|
||||||
faction->applyDiscount(morphUnitType, mct->getDiscount());
|
faction->applyDiscount(morphUnitType, mct->getDiscount());
|
||||||
|
@@ -703,6 +703,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
|
|||||||
psProj->setPath(startPos, endPos);
|
psProj->setPath(startPos, endPos);
|
||||||
psProj->setObserver(new ParticleDamager(unit, this, gameCamera));
|
psProj->setObserver(new ParticleDamager(unit, this, gameCamera));
|
||||||
psProj->setVisible(visible);
|
psProj->setVisible(visible);
|
||||||
|
psProj->setFactionColor(unit->getFaction()->getTexture()->getPixmap()->getPixel3f(0,0));
|
||||||
renderer.manageParticleSystem(psProj, rsGame);
|
renderer.manageParticleSystem(psProj, rsGame);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -714,6 +715,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
|
|||||||
psSplash= pstSplash->create();
|
psSplash= pstSplash->create();
|
||||||
psSplash->setPos(endPos);
|
psSplash->setPos(endPos);
|
||||||
psSplash->setVisible(visible);
|
psSplash->setVisible(visible);
|
||||||
|
psSplash->setFactionColor(unit->getFaction()->getTexture()->getPixmap()->getPixel3f(0,0));
|
||||||
renderer.manageParticleSystem(psSplash, rsGame);
|
renderer.manageParticleSystem(psSplash, rsGame);
|
||||||
if(pstProj!=NULL){
|
if(pstProj!=NULL){
|
||||||
psProj->link(psSplash);
|
psProj->link(psSplash);
|
||||||
|
@@ -114,6 +114,9 @@ protected:
|
|||||||
int varParticleEnergy;
|
int varParticleEnergy;
|
||||||
float particleSize;
|
float particleSize;
|
||||||
float speed;
|
float speed;
|
||||||
|
Vec3f factionColor;
|
||||||
|
bool teamcolorNoEnergy;
|
||||||
|
bool teamcolorEnergy;
|
||||||
|
|
||||||
ParticleObserver *particleObserver;
|
ParticleObserver *particleObserver;
|
||||||
|
|
||||||
@@ -152,6 +155,9 @@ public:
|
|||||||
void setObserver(ParticleObserver *particleObserver);
|
void setObserver(ParticleObserver *particleObserver);
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
void setBlendMode(BlendMode blendMode) {this->blendMode= blendMode;}
|
void setBlendMode(BlendMode blendMode) {this->blendMode= blendMode;}
|
||||||
|
void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;}
|
||||||
|
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
|
||||||
|
virtual void setFactionColor(Vec3f factionColor);
|
||||||
|
|
||||||
static BlendMode strToBlendMode(const string &str);
|
static BlendMode strToBlendMode(const string &str);
|
||||||
//misc
|
//misc
|
||||||
@@ -209,9 +215,6 @@ public:
|
|||||||
};
|
};
|
||||||
bool relative;
|
bool relative;
|
||||||
bool fixed;
|
bool fixed;
|
||||||
int teamNumber;
|
|
||||||
bool teamcolorNoEnergy;
|
|
||||||
bool teamcolorEnergy;
|
|
||||||
Model *model;
|
Model *model;
|
||||||
Primitive primitive;
|
Primitive primitive;
|
||||||
Vec3f offset;
|
Vec3f offset;
|
||||||
@@ -227,7 +230,6 @@ public:
|
|||||||
virtual void initParticle(Particle *p, int particleIndex);
|
virtual void initParticle(Particle *p, int particleIndex);
|
||||||
virtual void updateParticle(Particle *p);
|
virtual void updateParticle(Particle *p);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
virtual void setTeamNumber(int teamNumber);
|
|
||||||
virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
|
virtual void render(ParticleRenderer *pr, ModelRenderer *mr);
|
||||||
|
|
||||||
//set params
|
//set params
|
||||||
@@ -241,8 +243,6 @@ public:
|
|||||||
void setRotation(float rotation) {this->rotation= rotation;}
|
void setRotation(float rotation) {this->rotation= rotation;}
|
||||||
void setRelative(bool relative) {this->relative= relative;}
|
void setRelative(bool relative) {this->relative= relative;}
|
||||||
void setFixed(bool fixed) {this->fixed= fixed;}
|
void setFixed(bool fixed) {this->fixed= fixed;}
|
||||||
void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;}
|
|
||||||
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
|
|
||||||
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
||||||
|
|
||||||
static Primitive strToPrimitive(const string &str);
|
static Primitive strToPrimitive(const string &str);
|
||||||
|
@@ -50,6 +50,8 @@ ParticleSystem::ParticleSystem(int particleCount){
|
|||||||
colorNoEnergy= Vec4f(0.0f);
|
colorNoEnergy= Vec4f(0.0f);
|
||||||
emissionRate= 15;
|
emissionRate= 15;
|
||||||
speed= 1.0f;
|
speed= 1.0f;
|
||||||
|
teamcolorNoEnergy=false;
|
||||||
|
teamcolorEnergy=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleSystem::~ParticleSystem(){
|
ParticleSystem::~ParticleSystem(){
|
||||||
@@ -226,6 +228,21 @@ void ParticleSystem::killParticle(Particle *p){
|
|||||||
aliveParticleCount--;
|
aliveParticleCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ParticleSystem::setFactionColor(Vec3f factionColor){
|
||||||
|
this->factionColor=factionColor;
|
||||||
|
Vec3f tmpCol;
|
||||||
|
|
||||||
|
if(teamcolorEnergy)
|
||||||
|
{
|
||||||
|
this->color=Vec4f(factionColor.x,factionColor.y,factionColor.z,this->color.w);
|
||||||
|
}
|
||||||
|
if(teamcolorNoEnergy)
|
||||||
|
{
|
||||||
|
this->colorNoEnergy=Vec4f(factionColor.x,factionColor.y,factionColor.z,this->colorNoEnergy.w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// FireParticleSystem
|
// FireParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -308,8 +325,6 @@ UnitParticleSystem::UnitParticleSystem(int particleCount): ParticleSystem(partic
|
|||||||
gravity= 0.0f;
|
gravity= 0.0f;
|
||||||
|
|
||||||
fixed=false;
|
fixed=false;
|
||||||
teamcolorNoEnergy=false;
|
|
||||||
teamcolorEnergy=false;
|
|
||||||
rotation=0.0f;
|
rotation=0.0f;
|
||||||
|
|
||||||
cRotation= Vec3f(1.0f,1.0f,1.0f);
|
cRotation= Vec3f(1.0f,1.0f,1.0f);
|
||||||
@@ -436,36 +451,7 @@ void UnitParticleSystem::setWind(float windAngle, float windSpeed){
|
|||||||
this->windSpeed.z= cosf(degToRad(windAngle))*windSpeed;
|
this->windSpeed.z= cosf(degToRad(windAngle))*windSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitParticleSystem::setTeamNumber(int teamNumber){
|
|
||||||
this->teamNumber=teamNumber;
|
|
||||||
Vec3f tmpCol;
|
|
||||||
|
|
||||||
if(teamNumber==0)
|
|
||||||
{
|
|
||||||
tmpCol=Vec3f(1,0,0);
|
|
||||||
}
|
|
||||||
else if(teamNumber==1)
|
|
||||||
{
|
|
||||||
tmpCol=Vec3f(0,0,1);
|
|
||||||
}
|
|
||||||
else if(teamNumber==2)
|
|
||||||
{
|
|
||||||
tmpCol=Vec3f(0,1,0);
|
|
||||||
}
|
|
||||||
else if(teamNumber==3)
|
|
||||||
{
|
|
||||||
tmpCol=Vec3f(1,1,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(teamcolorEnergy)
|
|
||||||
{
|
|
||||||
this->color=Vec4f(tmpCol.x,tmpCol.y,tmpCol.z,this->color.w);
|
|
||||||
}
|
|
||||||
if(teamcolorNoEnergy)
|
|
||||||
{
|
|
||||||
this->colorNoEnergy=Vec4f(tmpCol.x,tmpCol.y,tmpCol.z,this->colorNoEnergy.w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
Reference in New Issue
Block a user