mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 10:49:48 +02:00
particles for ressouces ... the gold will glow tomorrow :-D
This commit is contained in:
@@ -68,7 +68,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
|
|||||||
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
||||||
ups->setTexture(texture);
|
ups->setTexture(texture);
|
||||||
ups->setPrimitive(UnitParticleSystem::strToPrimitive(primitive));
|
ups->setPrimitive(UnitParticleSystem::strToPrimitive(primitive));
|
||||||
ups->setOffset(offset);
|
ups->setOffset(offset);
|
||||||
|
@@ -55,7 +55,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
void load(const XmlNode *particleSystemNode, const string &dir, RendererInterface *newTexture);
|
void load(const XmlNode *particleSystemNode, const string &dir, RendererInterface *newTexture);
|
||||||
void load(const string &dir, const string &path, RendererInterface *newTexture);
|
void load(const string &dir, const string &path, RendererInterface *newTexture);
|
||||||
void setValues(UnitParticleSystem *uts);
|
const void setValues (UnitParticleSystem *uts);
|
||||||
bool hasTexture() const { return(texture != NULL); }
|
bool hasTexture() const { return(texture != NULL); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -81,22 +81,27 @@ void Object::initParticles(){
|
|||||||
if(this->objectType==NULL) return;
|
if(this->objectType==NULL) return;
|
||||||
if(this->objectType->hasParticles()){
|
if(this->objectType->hasParticles()){
|
||||||
ObjectParticleSystemTypes *particleTypes= this->objectType->getObjectParticleSystemTypes(variation);
|
ObjectParticleSystemTypes *particleTypes= this->objectType->getObjectParticleSystemTypes(variation);
|
||||||
if(Config::getInstance().getBool("TilesetParticles","true") && (particleTypes->empty() == false)
|
initParticlesFromTypes(particleTypes);
|
||||||
&& (unitParticleSystems.empty() == true)){
|
|
||||||
for(ObjectParticleSystemTypes::const_iterator it= particleTypes->begin(); it != particleTypes->end(); ++it){
|
|
||||||
UnitParticleSystem *ups= new UnitParticleSystem(200);
|
|
||||||
(*it)->setValues(ups);
|
|
||||||
ups->setPos(this->pos);
|
|
||||||
ups->setRotation(this->rotation);
|
|
||||||
ups->setFactionColor(Vec3f(0, 0, 0));
|
|
||||||
ups->setVisible(false);
|
|
||||||
this->unitParticleSystems.push_back(ups);
|
|
||||||
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::initParticlesFromTypes(const ObjectParticleSystemTypes *particleTypes){
|
||||||
|
if(Config::getInstance().getBool("TilesetParticles","true") && (particleTypes->empty() == false)
|
||||||
|
&& (unitParticleSystems.empty() == true)){
|
||||||
|
for(ObjectParticleSystemTypes::const_iterator it= particleTypes->begin(); it != particleTypes->end(); ++it){
|
||||||
|
UnitParticleSystem *ups= new UnitParticleSystem(200);
|
||||||
|
(*it)->setValues(ups);
|
||||||
|
ups->setPos(this->pos);
|
||||||
|
ups->setRotation(this->rotation);
|
||||||
|
ups->setFactionColor(Vec3f(0, 0, 0));
|
||||||
|
ups->setVisible(false);
|
||||||
|
this->unitParticleSystems.push_back(ups);
|
||||||
|
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Object::setHeight(float height){
|
void Object::setHeight(float height){
|
||||||
pos.y=height;
|
pos.y=height;
|
||||||
|
|
||||||
@@ -120,6 +125,7 @@ bool Object::getWalkable() const{
|
|||||||
void Object::setResource(const ResourceType *resourceType, const Vec2i &pos){
|
void Object::setResource(const ResourceType *resourceType, const Vec2i &pos){
|
||||||
resource= new Resource();
|
resource= new Resource();
|
||||||
resource->init(resourceType, pos);
|
resource->init(resourceType, pos);
|
||||||
|
initParticlesFromTypes(resourceType->getObjectParticleSystemTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::setVisible( bool visible)
|
void Object::setVisible( bool visible)
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "object_type.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ public:
|
|||||||
|
|
||||||
void end(); //to kill particles
|
void end(); //to kill particles
|
||||||
void initParticles();
|
void initParticles();
|
||||||
|
void initParticlesFromTypes(const ObjectParticleSystemTypes *particleTypes);
|
||||||
static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; }
|
static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; }
|
||||||
|
|
||||||
const ObjectType *getType() const {return objectType;}
|
const ObjectType *getType() const {return objectType;}
|
||||||
|
@@ -38,6 +38,13 @@ ResourceType::ResourceType() {
|
|||||||
model = NULL;
|
model = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResourceType::~ResourceType(){
|
||||||
|
while(!(particleTypes.empty())){
|
||||||
|
delete particleTypes.back();
|
||||||
|
particleTypes.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum) {
|
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum) {
|
||||||
|
|
||||||
string path, str;
|
string path, str;
|
||||||
@@ -79,6 +86,21 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||||||
model= renderer.newModel(rsGame);
|
model= renderer.newModel(rsGame);
|
||||||
model->load(path);
|
model->load(path);
|
||||||
|
|
||||||
|
if(modelNode->hasChild("particles")){
|
||||||
|
const XmlNode *particleNode= modelNode->getChild("particles");
|
||||||
|
bool particleEnabled= particleNode->getAttribute("value")->getBoolValue();
|
||||||
|
if(particleEnabled){
|
||||||
|
for(int k= 0; k < particleNode->getChildCount(); ++k){
|
||||||
|
const XmlNode *particleFileNode= particleNode->getChild("particle-file", k);
|
||||||
|
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
|
||||||
|
|
||||||
|
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
|
||||||
|
objectParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||||
|
particleTypes.push_back(objectParticleSystemType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//default resources
|
//default resources
|
||||||
const XmlNode *defaultAmountNode= typeNode->getChild("default-amount");
|
const XmlNode *defaultAmountNode= typeNode->getChild("default-amount");
|
||||||
defResPerPatch= defaultAmountNode->getAttribute("value")->getIntValue();
|
defResPerPatch= defaultAmountNode->getAttribute("value")->getIntValue();
|
||||||
@@ -134,7 +156,6 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ==================== misc ====================
|
// ==================== misc ====================
|
||||||
|
|
||||||
ResourceClass ResourceType::strToRc(const string &s){
|
ResourceClass ResourceType::strToRc(const string &s){
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "checksum.h"
|
#include "checksum.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
#include "unit_particle_type.h"
|
||||||
|
#include "object_type.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ enum ResourceClass{
|
|||||||
/// A type of resource that can be harvested or not
|
/// A type of resource that can be harvested or not
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
|
||||||
class ResourceType: public DisplayableType{
|
class ResourceType: public DisplayableType{
|
||||||
private:
|
private:
|
||||||
ResourceClass resourceClass;
|
ResourceClass resourceClass;
|
||||||
@@ -45,9 +48,11 @@ private:
|
|||||||
bool recoup_cost;
|
bool recoup_cost;
|
||||||
|
|
||||||
Model *model;
|
Model *model;
|
||||||
|
ObjectParticleSystemTypes particleTypes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResourceType();
|
ResourceType();
|
||||||
|
~ResourceType();
|
||||||
void load(const string &dir, Checksum* checksum,Checksum *techtreeChecksum);
|
void load(const string &dir, Checksum* checksum,Checksum *techtreeChecksum);
|
||||||
|
|
||||||
//get
|
//get
|
||||||
@@ -59,6 +64,10 @@ public:
|
|||||||
Model *getModel() const {return model;}
|
Model *getModel() const {return model;}
|
||||||
bool getRecoup_cost() const { return recoup_cost;}
|
bool getRecoup_cost() const { return recoup_cost;}
|
||||||
|
|
||||||
|
bool hasParticles() const {return !particleTypes.empty();}
|
||||||
|
const ObjectParticleSystemTypes *getObjectParticleSystemTypes() const {return &particleTypes;}
|
||||||
|
|
||||||
|
|
||||||
static ResourceClass strToRc(const string &s);
|
static ResourceClass strToRc(const string &s);
|
||||||
void deletePixels();
|
void deletePixels();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user