mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 23:21:19 +02:00
- daylight effects for unit particles ( best use with mode "black" )
- meadow has good looking mist in night now - startdelay for particles
This commit is contained in:
@@ -43,7 +43,8 @@ ParticleSystemType::ParticleSystemType() {
|
|||||||
|
|
||||||
teamcolorNoEnergy=false;
|
teamcolorNoEnergy=false;
|
||||||
teamcolorEnergy=false;
|
teamcolorEnergy=false;
|
||||||
alternations=false;
|
alternations=0;
|
||||||
|
particleSystemStartDelay=0;
|
||||||
texture=NULL;
|
texture=NULL;
|
||||||
model=NULL;
|
model=NULL;
|
||||||
minmaxEnabled=false;
|
minmaxEnabled=false;
|
||||||
@@ -101,6 +102,7 @@ void ParticleSystemType::copyAll(const ParticleSystemType &src) {
|
|||||||
this->teamcolorNoEnergy = src.teamcolorNoEnergy;
|
this->teamcolorNoEnergy = src.teamcolorNoEnergy;
|
||||||
this->teamcolorEnergy = src.teamcolorEnergy;
|
this->teamcolorEnergy = src.teamcolorEnergy;
|
||||||
this->alternations = src.alternations;
|
this->alternations = src.alternations;
|
||||||
|
this->particleSystemStartDelay= src.particleSystemStartDelay;
|
||||||
for(Children::iterator it = children.begin(); it != children.end(); ++it) {
|
for(Children::iterator it = children.begin(); it != children.end(); ++it) {
|
||||||
UnitParticleSystemType *child = *it;
|
UnitParticleSystemType *child = *it;
|
||||||
|
|
||||||
@@ -239,6 +241,11 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||||||
const XmlNode *alternatingNode= particleSystemNode->getChild("alternations");
|
const XmlNode *alternatingNode= particleSystemNode->getChild("alternations");
|
||||||
alternations= alternatingNode->getAttribute("value")->getIntValue();
|
alternations= alternatingNode->getAttribute("value")->getIntValue();
|
||||||
}
|
}
|
||||||
|
//particleSystemStartDelay
|
||||||
|
if(particleSystemNode->hasChild("particleSystemStartDelay")){
|
||||||
|
const XmlNode *node= particleSystemNode->getChild("particleSystemStartDelay");
|
||||||
|
particleSystemStartDelay= node->getAttribute("value")->getIntValue();
|
||||||
|
}
|
||||||
//mode
|
//mode
|
||||||
if(particleSystemNode->hasChild("mode")) {
|
if(particleSystemNode->hasChild("mode")) {
|
||||||
const XmlNode *modeNode= particleSystemNode->getChild("mode");
|
const XmlNode *modeNode= particleSystemNode->getChild("mode");
|
||||||
@@ -293,6 +300,7 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
|
|||||||
ats->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
ats->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
||||||
ats->setTeamcolorEnergy(teamcolorEnergy);
|
ats->setTeamcolorEnergy(teamcolorEnergy);
|
||||||
ats->setAlternations(alternations);
|
ats->setAlternations(alternations);
|
||||||
|
ats->setParticleSystemStartDelay(particleSystemStartDelay);
|
||||||
ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
|
ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,6 +69,7 @@ protected:
|
|||||||
bool teamcolorNoEnergy;
|
bool teamcolorNoEnergy;
|
||||||
bool teamcolorEnergy;
|
bool teamcolorEnergy;
|
||||||
int alternations;
|
int alternations;
|
||||||
|
int particleSystemStartDelay;
|
||||||
typedef std::list<UnitParticleSystemType*> Children;
|
typedef std::list<UnitParticleSystemType*> Children;
|
||||||
Children children;
|
Children children;
|
||||||
|
|
||||||
|
@@ -839,7 +839,7 @@ void Renderer::setupLighting() {
|
|||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
//sun/moon light
|
//sun/moon light
|
||||||
Vec3f lightColor= computeLightColor(time);
|
Vec3f lightColor= timeFlow->computeLightColor();
|
||||||
Vec3f fogColor= world->getTileset()->getFogColor();
|
Vec3f fogColor= world->getTileset()->getFogColor();
|
||||||
Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time);
|
Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time);
|
||||||
nearestLightPos= lightPos;
|
nearestLightPos= lightPos;
|
||||||
@@ -4183,7 +4183,7 @@ void Renderer::renderObjects(const int renderFps) {
|
|||||||
|
|
||||||
const Texture2D *fowTex = world->getMinimap()->getFowTexture();
|
const Texture2D *fowTex = world->getMinimap()->getFowTexture();
|
||||||
const Pixmap2D *fowTexPixmap = fowTex->getPixmapConst();
|
const Pixmap2D *fowTexPixmap = fowTex->getPixmapConst();
|
||||||
Vec3f baseFogColor = world->getTileset()->getFogColor() * computeLightColor(world->getTimeFlow()->getTime());
|
Vec3f baseFogColor = world->getTileset()->getFogColor() * world->getTimeFlow()->computeLightColor();
|
||||||
|
|
||||||
bool modelRenderStarted = false;
|
bool modelRenderStarted = false;
|
||||||
|
|
||||||
@@ -6461,35 +6461,6 @@ Vec4f Renderer::computeMoonPos(float time) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f Renderer::computeLightColor(float time) {
|
|
||||||
const Tileset *tileset= game->getWorld()->getTileset();
|
|
||||||
Vec3f color;
|
|
||||||
|
|
||||||
const float transition= 2;
|
|
||||||
const float dayStart= TimeFlow::dawn;
|
|
||||||
const float dayEnd= TimeFlow::dusk-transition;
|
|
||||||
const float nightStart= TimeFlow::dusk;
|
|
||||||
const float nightEnd= TimeFlow::dawn-transition;
|
|
||||||
|
|
||||||
if(time>dayStart && time<dayEnd) {
|
|
||||||
color= tileset->getSunLightColor();
|
|
||||||
}
|
|
||||||
else if(time>nightStart || time<nightEnd) {
|
|
||||||
color= tileset->getMoonLightColor();
|
|
||||||
}
|
|
||||||
else if(time>=dayEnd && time<=nightStart) {
|
|
||||||
color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor());
|
|
||||||
}
|
|
||||||
else if(time>=nightEnd && time<=dayStart) {
|
|
||||||
color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert(false);
|
|
||||||
color= tileset->getSunLightColor();
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec4f Renderer::computeWaterColor(float waterLevel, float cellHeight) {
|
Vec4f Renderer::computeWaterColor(float waterLevel, float cellHeight) {
|
||||||
const float waterFactor= 1.5f;
|
const float waterFactor= 1.5f;
|
||||||
return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight)*waterFactor, 0.f, 1.f));
|
return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight)*waterFactor, 0.f, 1.f));
|
||||||
|
@@ -581,7 +581,6 @@ private:
|
|||||||
float computeMoonAngle(float time);
|
float computeMoonAngle(float time);
|
||||||
Vec4f computeSunPos(float time);
|
Vec4f computeSunPos(float time);
|
||||||
Vec4f computeMoonPos(float time);
|
Vec4f computeMoonPos(float time);
|
||||||
Vec3f computeLightColor(float time);
|
|
||||||
Vec4f computeWaterColor(float waterLevel, float cellHeight);
|
Vec4f computeWaterColor(float waterLevel, float cellHeight);
|
||||||
void checkExtension(const string &extension, const string &msg);
|
void checkExtension(const string &extension, const string &msg);
|
||||||
|
|
||||||
|
@@ -40,8 +40,9 @@ UnitParticleSystemType::UnitParticleSystemType() : ParticleSystemType() {
|
|||||||
relativeDirection = false;
|
relativeDirection = false;
|
||||||
fixed = false;
|
fixed = false;
|
||||||
staticParticleCount = 0;
|
staticParticleCount = 0;
|
||||||
isVisibleAtNight = false;
|
isVisibleAtNight = true;
|
||||||
isVisibleAtDay = false;
|
isVisibleAtDay = true;
|
||||||
|
isDaylightAffected = false;
|
||||||
radiusBasedStartenergy = false;
|
radiusBasedStartenergy = false;
|
||||||
delay = 0;
|
delay = 0;
|
||||||
lifetime = 0;
|
lifetime = 0;
|
||||||
@@ -146,6 +147,15 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
|
|||||||
isVisibleAtDay=true;
|
isVisibleAtDay=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//isDaylightAffected
|
||||||
|
if(particleSystemNode->hasChild("isDaylightAffected")){
|
||||||
|
const XmlNode *node= particleSystemNode->getChild("isDaylightAffected");
|
||||||
|
isDaylightAffected= node->getAttribute("value")->getBoolValue();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isDaylightAffected=false;
|
||||||
|
}
|
||||||
|
|
||||||
//radiusBasedStartenergy
|
//radiusBasedStartenergy
|
||||||
if(particleSystemNode->hasChild("radiusBasedStartenergy")){
|
if(particleSystemNode->hasChild("radiusBasedStartenergy")){
|
||||||
const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("radiusBasedStartenergy");
|
const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("radiusBasedStartenergy");
|
||||||
@@ -217,9 +227,11 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
|||||||
ups->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
ups->setTeamcolorNoEnergy(teamcolorNoEnergy);
|
||||||
ups->setTeamcolorEnergy(teamcolorEnergy);
|
ups->setTeamcolorEnergy(teamcolorEnergy);
|
||||||
ups->setAlternations(alternations);
|
ups->setAlternations(alternations);
|
||||||
|
ups->setParticleSystemStartDelay(particleSystemStartDelay);
|
||||||
|
|
||||||
ups->setIsVisibleAtNight(isVisibleAtNight);
|
ups->setIsVisibleAtNight(isVisibleAtNight);
|
||||||
ups->setIsVisibleAtDay(isVisibleAtDay);
|
ups->setIsVisibleAtDay(isVisibleAtDay);
|
||||||
|
ups->setIsDaylightAffected(isDaylightAffected);
|
||||||
ups->setStaticParticleCount(staticParticleCount);
|
ups->setStaticParticleCount(staticParticleCount);
|
||||||
ups->setRadius(radius);
|
ups->setRadius(radius);
|
||||||
ups->setMinRadius(minRadius);
|
ups->setMinRadius(minRadius);
|
||||||
|
@@ -58,6 +58,7 @@ protected:
|
|||||||
int staticParticleCount;
|
int staticParticleCount;
|
||||||
bool isVisibleAtNight;
|
bool isVisibleAtNight;
|
||||||
bool isVisibleAtDay;
|
bool isVisibleAtDay;
|
||||||
|
bool isDaylightAffected;
|
||||||
bool radiusBasedStartenergy;
|
bool radiusBasedStartenergy;
|
||||||
int delay;
|
int delay;
|
||||||
int lifetime;
|
int lifetime;
|
||||||
|
@@ -55,6 +55,7 @@ void TimeFlow::update() {
|
|||||||
soundRenderer.stopAmbient(ambientSounds->getNight());
|
soundRenderer.stopAmbient(ambientSounds->getNight());
|
||||||
UnitParticleSystem::isNight=false;
|
UnitParticleSystem::isNight=false;
|
||||||
}
|
}
|
||||||
|
UnitParticleSystem::lightColor=computeLightColor();
|
||||||
|
|
||||||
if((lastTime<dawn && time>=dawn) || firstTime){
|
if((lastTime<dawn && time>=dawn) || firstTime){
|
||||||
|
|
||||||
@@ -94,4 +95,35 @@ void TimeFlow::update() {
|
|||||||
// return (this->time>=time) && (this->time<time+timeInc);
|
// return (this->time>=time) && (this->time<time+timeInc);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
Vec3f TimeFlow::computeLightColor() const {
|
||||||
|
Vec3f color;
|
||||||
|
|
||||||
|
float time=getTime();
|
||||||
|
|
||||||
|
const float transition= 2;
|
||||||
|
const float dayStart= TimeFlow::dawn;
|
||||||
|
const float dayEnd= TimeFlow::dusk-transition;
|
||||||
|
const float nightStart= TimeFlow::dusk;
|
||||||
|
const float nightEnd= TimeFlow::dawn-transition;
|
||||||
|
|
||||||
|
if(time>dayStart && time<dayEnd) {
|
||||||
|
color= tileset->getSunLightColor();
|
||||||
|
}
|
||||||
|
else if(time>nightStart || time<nightEnd) {
|
||||||
|
color= tileset->getMoonLightColor();
|
||||||
|
}
|
||||||
|
else if(time>=dayEnd && time<=nightStart) {
|
||||||
|
color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor());
|
||||||
|
}
|
||||||
|
else if(time>=nightEnd && time<=dayStart) {
|
||||||
|
color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(false);
|
||||||
|
color= tileset->getSunLightColor();
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -57,6 +57,7 @@ public:
|
|||||||
bool isTotalNight() const {return time<dawn+1.f || time>dusk-1.f;}
|
bool isTotalNight() const {return time<dawn+1.f || time>dusk-1.f;}
|
||||||
float getTimeInc() const {return timeInc;}
|
float getTimeInc() const {return timeInc;}
|
||||||
|
|
||||||
|
Vec3f computeLightColor() const;
|
||||||
void update();
|
void update();
|
||||||
private:
|
private:
|
||||||
//bool isAproxTime(float time) const;
|
//bool isAproxTime(float time) const;
|
||||||
|
@@ -132,6 +132,7 @@ protected:
|
|||||||
bool teamcolorNoEnergy;
|
bool teamcolorNoEnergy;
|
||||||
bool teamcolorEnergy;
|
bool teamcolorEnergy;
|
||||||
int alternations;
|
int alternations;
|
||||||
|
int particleSystemStartDelay;
|
||||||
ParticleObserver *particleObserver;
|
ParticleObserver *particleObserver;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -173,6 +174,7 @@ public:
|
|||||||
void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;}
|
void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;}
|
||||||
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
|
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
|
||||||
void setAlternations(int alternations) {this->alternations= alternations;}
|
void setAlternations(int alternations) {this->alternations= alternations;}
|
||||||
|
void setParticleSystemStartDelay(int delay) {this->particleSystemStartDelay= delay;}
|
||||||
virtual void setFactionColor(Vec3f factionColor);
|
virtual void setFactionColor(Vec3f factionColor);
|
||||||
|
|
||||||
static BlendMode strToBlendMode(const string &str);
|
static BlendMode strToBlendMode(const string &str);
|
||||||
@@ -269,6 +271,7 @@ protected:
|
|||||||
class UnitParticleSystem: public GameParticleSystem{
|
class UnitParticleSystem: public GameParticleSystem{
|
||||||
public:
|
public:
|
||||||
static bool isNight;
|
static bool isNight;
|
||||||
|
static Vec3f lightColor;
|
||||||
private:
|
private:
|
||||||
float radius;
|
float radius;
|
||||||
float minRadius;
|
float minRadius;
|
||||||
@@ -296,6 +299,7 @@ public:
|
|||||||
float rotation;
|
float rotation;
|
||||||
bool isVisibleAtNight;
|
bool isVisibleAtNight;
|
||||||
bool isVisibleAtDay;
|
bool isVisibleAtDay;
|
||||||
|
bool isDaylightAffected;
|
||||||
bool radiusBasedStartenergy;
|
bool radiusBasedStartenergy;
|
||||||
int staticParticleCount;
|
int staticParticleCount;
|
||||||
int delay;
|
int delay;
|
||||||
@@ -339,6 +343,7 @@ public:
|
|||||||
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
||||||
void setStaticParticleCount(int staticParticleCount){this->staticParticleCount= staticParticleCount;}
|
void setStaticParticleCount(int staticParticleCount){this->staticParticleCount= staticParticleCount;}
|
||||||
void setIsVisibleAtNight(bool value) {this->isVisibleAtNight= value;}
|
void setIsVisibleAtNight(bool value) {this->isVisibleAtNight= value;}
|
||||||
|
void setIsDaylightAffected(bool value) {this->isDaylightAffected= value;}
|
||||||
void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;}
|
void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;}
|
||||||
void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;}
|
void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;}
|
||||||
void setShape(Shape shape) {this->shape= shape;}
|
void setShape(Shape shape) {this->shape= shape;}
|
||||||
|
@@ -74,6 +74,7 @@ ParticleSystem::ParticleSystem(int particleCount) {
|
|||||||
teamcolorNoEnergy= false;
|
teamcolorNoEnergy= false;
|
||||||
teamcolorEnergy= false;
|
teamcolorEnergy= false;
|
||||||
alternations= 0;
|
alternations= 0;
|
||||||
|
particleSystemStartDelay= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleSystem::~ParticleSystem(){
|
ParticleSystem::~ParticleSystem(){
|
||||||
@@ -97,8 +98,10 @@ void ParticleSystem::update(){
|
|||||||
if(aliveParticleCount > (int) particles.size()){
|
if(aliveParticleCount > (int) particles.size()){
|
||||||
throw runtime_error("aliveParticleCount >= particles.size()");
|
throw runtime_error("aliveParticleCount >= particles.size()");
|
||||||
}
|
}
|
||||||
|
if(particleSystemStartDelay>0){
|
||||||
if(state != sPause){
|
particleSystemStartDelay--;
|
||||||
|
}
|
||||||
|
else if(state != sPause){
|
||||||
for(int i= 0; i < aliveParticleCount; ++i){
|
for(int i= 0; i < aliveParticleCount; ++i){
|
||||||
updateParticle(&particles[i]);
|
updateParticle(&particles[i]);
|
||||||
|
|
||||||
@@ -527,6 +530,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
|
|||||||
// UnitParticleSystem
|
// UnitParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
bool UnitParticleSystem::isNight= false;
|
bool UnitParticleSystem::isNight= false;
|
||||||
|
Vec3f UnitParticleSystem::lightColor=Vec3f(1.0f,1.0f,1.0f);
|
||||||
|
|
||||||
UnitParticleSystem::UnitParticleSystem(int particleCount):
|
UnitParticleSystem::UnitParticleSystem(int particleCount):
|
||||||
GameParticleSystem(particleCount),
|
GameParticleSystem(particleCount),
|
||||||
@@ -549,6 +553,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount):
|
|||||||
|
|
||||||
isVisibleAtNight= true;
|
isVisibleAtNight= true;
|
||||||
isVisibleAtDay= true;
|
isVisibleAtDay= true;
|
||||||
|
isDaylightAffected= false;
|
||||||
|
|
||||||
cRotation= Vec3f(1.0f, 1.0f, 1.0f);
|
cRotation= Vec3f(1.0f, 1.0f, 1.0f);
|
||||||
fixedAddition= Vec3f(0.0f, 0.0f, 0.0f);
|
fixedAddition= Vec3f(0.0f, 0.0f, 0.0f);
|
||||||
@@ -736,6 +741,12 @@ void UnitParticleSystem::updateParticle(Particle *p){
|
|||||||
}
|
}
|
||||||
p->speed+= p->accel;
|
p->speed+= p->accel;
|
||||||
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
|
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
|
||||||
|
if(isDaylightAffected)
|
||||||
|
{
|
||||||
|
p->color.x=p->color.x*lightColor.x;
|
||||||
|
p->color.y=p->color.y*lightColor.y;
|
||||||
|
p->color.z=p->color.z*lightColor.z;
|
||||||
|
}
|
||||||
p->size= particleSize * energyRatio + sizeNoEnergy * (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--;
|
p->energy--;
|
||||||
|
Reference in New Issue
Block a user