particles for tilesets ( too much rendered at the moment )
This commit is contained in:
parent
18c863364f
commit
792d0aa665
|
@ -58,13 +58,15 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
||||||
}
|
}
|
||||||
|
|
||||||
//model
|
//model
|
||||||
const XmlNode *modelNode= particleSystemNode->getChild("model");
|
if(particleSystemNode->hasChild("model")){
|
||||||
bool modelEnabled= modelNode->getAttribute("value")->getBoolValue();
|
const XmlNode *modelNode= particleSystemNode->getChild("model");
|
||||||
if(modelEnabled) {
|
bool modelEnabled= modelNode->getAttribute("value")->getBoolValue();
|
||||||
string path= modelNode->getAttribute("path")->getRestrictedValue();
|
if(modelEnabled){
|
||||||
model= renderer->newModel(rsGame);
|
string path= modelNode->getAttribute("path")->getRestrictedValue();
|
||||||
|
model= renderer->newModel(rsGame);
|
||||||
|
|
||||||
model->load(dir + "/" + path);
|
model->load(dir + "/" + path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
model= NULL;
|
model= NULL;
|
||||||
|
|
|
@ -29,101 +29,22 @@ namespace Glest{ namespace Game{
|
||||||
// class UnitParticleSystemType
|
// class UnitParticleSystemType
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
UnitParticleSystemType::UnitParticleSystemType(){
|
|
||||||
texture = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir, RendererInterface *renderer) {
|
void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir, RendererInterface *renderer) {
|
||||||
//texture
|
ParticleSystemType::load(particleSystemNode, dir, renderer);
|
||||||
const XmlNode *textureNode= particleSystemNode->getChild("texture");
|
//radius
|
||||||
bool textureEnabled= textureNode->getAttribute("value")->getBoolValue();
|
const XmlNode *radiusNode= particleSystemNode->getChild("radius");
|
||||||
if(textureEnabled == true) {
|
radius= radiusNode->getAttribute("value")->getFloatValue();
|
||||||
//Renderer &renderer= Renderer::getInstance();
|
|
||||||
texture= renderer->newTexture2D(rsGame);
|
|
||||||
//texture = newTexture;
|
|
||||||
|
|
||||||
if(textureNode->getAttribute("luminance")->getBoolValue()){
|
|
||||||
texture->setFormat(Texture::fAlpha);
|
|
||||||
texture->getPixmap()->init(1);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
texture->getPixmap()->init(4);
|
|
||||||
}
|
|
||||||
texture->load(dir + "/" + textureNode->getAttribute("path")->getRestrictedValue());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
texture= NULL;
|
|
||||||
|
|
||||||
//delete newTexture;
|
|
||||||
//newTexture = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//primitive
|
|
||||||
const XmlNode *primitiveNode= particleSystemNode->getChild("primitive");
|
|
||||||
primitive= primitiveNode->getAttribute("value")->getRestrictedValue();
|
|
||||||
|
|
||||||
//offset
|
|
||||||
const XmlNode *offsetNode= particleSystemNode->getChild("offset");
|
|
||||||
offset.x= offsetNode->getAttribute("x")->getFloatValue();
|
|
||||||
offset.y= offsetNode->getAttribute("y")->getFloatValue();
|
|
||||||
offset.z= offsetNode->getAttribute("z")->getFloatValue();
|
|
||||||
|
|
||||||
|
//relative
|
||||||
|
const XmlNode *relativeNode= particleSystemNode->getChild("relative");
|
||||||
|
relative= relativeNode->getAttribute("value")->getBoolValue();
|
||||||
|
|
||||||
//direction
|
//direction
|
||||||
const XmlNode *directionNode= particleSystemNode->getChild("direction");
|
const XmlNode *directionNode= particleSystemNode->getChild("direction");
|
||||||
direction.x= directionNode->getAttribute("x")->getFloatValue();
|
direction.x= directionNode->getAttribute("x")->getFloatValue();
|
||||||
direction.y= directionNode->getAttribute("y")->getFloatValue();
|
direction.y= directionNode->getAttribute("y")->getFloatValue();
|
||||||
direction.z= directionNode->getAttribute("z")->getFloatValue();
|
direction.z= directionNode->getAttribute("z")->getFloatValue();
|
||||||
|
|
||||||
//color
|
|
||||||
const XmlNode *colorNode= particleSystemNode->getChild("color");
|
|
||||||
color.x= colorNode->getAttribute("red")->getFloatValue(0.f, 1.0f);
|
|
||||||
color.y= colorNode->getAttribute("green")->getFloatValue(0.f, 1.0f);
|
|
||||||
color.z= colorNode->getAttribute("blue")->getFloatValue(0.f, 1.0f);
|
|
||||||
color.w= colorNode->getAttribute("alpha")->getFloatValue(0.f, 1.0f);
|
|
||||||
|
|
||||||
//color
|
|
||||||
const XmlNode *colorNoEnergyNode= particleSystemNode->getChild("color-no-energy");
|
|
||||||
colorNoEnergy.x= colorNoEnergyNode->getAttribute("red")->getFloatValue(0.f, 1.0f);
|
|
||||||
colorNoEnergy.y= colorNoEnergyNode->getAttribute("green")->getFloatValue(0.f, 1.0f);
|
|
||||||
colorNoEnergy.z= colorNoEnergyNode->getAttribute("blue")->getFloatValue(0.f, 1.0f);
|
|
||||||
colorNoEnergy.w= colorNoEnergyNode->getAttribute("alpha")->getFloatValue(0.f, 1.0f);
|
|
||||||
|
|
||||||
//radius
|
|
||||||
const XmlNode *radiusNode= particleSystemNode->getChild("radius");
|
|
||||||
radius= radiusNode->getAttribute("value")->getFloatValue();
|
|
||||||
|
|
||||||
//size
|
|
||||||
const XmlNode *sizeNode= particleSystemNode->getChild("size");
|
|
||||||
size= sizeNode->getAttribute("value")->getFloatValue();
|
|
||||||
|
|
||||||
//sizeNoEnergy
|
|
||||||
const XmlNode *sizeNoEnergyNode= particleSystemNode->getChild("size-no-energy");
|
|
||||||
sizeNoEnergy= sizeNoEnergyNode->getAttribute("value")->getFloatValue();
|
|
||||||
|
|
||||||
//speed
|
|
||||||
const XmlNode *speedNode= particleSystemNode->getChild("speed");
|
|
||||||
speed= speedNode->getAttribute("value")->getFloatValue()/GameConstants::updateFps;
|
|
||||||
|
|
||||||
//gravity
|
|
||||||
const XmlNode *gravityNode= particleSystemNode->getChild("gravity");
|
|
||||||
gravity= gravityNode->getAttribute("value")->getFloatValue()/GameConstants::updateFps;
|
|
||||||
|
|
||||||
//emission rate
|
|
||||||
const XmlNode *emissionRateNode= particleSystemNode->getChild("emission-rate");
|
|
||||||
emissionRate= emissionRateNode->getAttribute("value")->getFloatValue();
|
|
||||||
|
|
||||||
//energy max
|
|
||||||
const XmlNode *energyMaxNode= particleSystemNode->getChild("energy-max");
|
|
||||||
energyMax= energyMaxNode->getAttribute("value")->getIntValue();
|
|
||||||
|
|
||||||
//speed
|
|
||||||
const XmlNode *energyVarNode= particleSystemNode->getChild("energy-var");
|
|
||||||
energyVar= energyVarNode->getAttribute("value")->getIntValue();
|
|
||||||
|
|
||||||
//relative
|
|
||||||
const XmlNode *relativeNode= particleSystemNode->getChild("relative");
|
|
||||||
relative= relativeNode->getAttribute("value")->getBoolValue();
|
|
||||||
|
|
||||||
//relativeDirection
|
//relativeDirection
|
||||||
if(particleSystemNode->hasChild("relativeDirection")){
|
if(particleSystemNode->hasChild("relativeDirection")){
|
||||||
const XmlNode *relativeDirectionNode= particleSystemNode->getChild("relativeDirection");
|
const XmlNode *relativeDirectionNode= particleSystemNode->getChild("relativeDirection");
|
||||||
|
@ -145,35 +66,6 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
|
||||||
//fixed
|
//fixed
|
||||||
const XmlNode *fixedNode= particleSystemNode->getChild("fixed");
|
const XmlNode *fixedNode= particleSystemNode->getChild("fixed");
|
||||||
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
||||||
|
|
||||||
//teamcolorNoEnergy
|
|
||||||
if(particleSystemNode->hasChild("teamcolorNoEnergy")){
|
|
||||||
const XmlNode *teamcolorNoEnergyNode= particleSystemNode->getChild("teamcolorNoEnergy");
|
|
||||||
teamcolorNoEnergy= teamcolorNoEnergyNode->getAttribute("value")->getBoolValue();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
teamcolorNoEnergy=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//teamcolorEnergy
|
|
||||||
if(particleSystemNode->hasChild("teamcolorEnergy")){
|
|
||||||
const XmlNode *teamcolorEnergyNode= particleSystemNode->getChild("teamcolorEnergy");
|
|
||||||
teamcolorEnergy= teamcolorEnergyNode->getAttribute("value")->getBoolValue();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
teamcolorEnergy=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//mode
|
|
||||||
if(particleSystemNode->hasChild("mode")){
|
|
||||||
const XmlNode *modeNode= particleSystemNode->getChild("mode");
|
|
||||||
mode= modeNode->getAttribute("value")->getRestrictedValue();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mode="normal";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "xml_parser.h"
|
#include "xml_parser.h"
|
||||||
#include "graphics_interface.h"
|
#include "graphics_interface.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
#include "particle_type.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
|
@ -41,39 +42,26 @@ using Shared::Xml::XmlNode;
|
||||||
/// A type of particle system
|
/// A type of particle system
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
|
||||||
class UnitParticleSystemType{
|
class UnitParticleSystemType: public ParticleSystemType{
|
||||||
protected:
|
protected:
|
||||||
string type;
|
|
||||||
Texture2D *texture;
|
|
||||||
string primitive;
|
|
||||||
Vec3f offset;
|
|
||||||
Vec3f direction;
|
|
||||||
Vec4f color;
|
|
||||||
Vec4f colorNoEnergy;
|
|
||||||
float radius;
|
float radius;
|
||||||
float size;
|
Vec3f direction;
|
||||||
float sizeNoEnergy;
|
|
||||||
float speed;
|
|
||||||
float gravity;
|
|
||||||
float emissionRate;
|
|
||||||
int energyMax;
|
|
||||||
int energyVar;
|
|
||||||
bool relative;
|
bool relative;
|
||||||
bool relativeDirection;
|
bool relativeDirection;
|
||||||
bool fixed;
|
bool fixed;
|
||||||
bool teamcolorNoEnergy;
|
|
||||||
bool teamcolorEnergy;
|
|
||||||
int staticParticleCount;
|
int staticParticleCount;
|
||||||
string mode;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnitParticleSystemType();
|
|
||||||
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);
|
void setValues(UnitParticleSystem *uts);
|
||||||
bool hasTexture() const { return(texture != NULL); }
|
bool hasTexture() const { return(texture != NULL); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ObjectParticleSystemType: public UnitParticleSystemType{
|
||||||
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
|
|
||||||
#include "faction_type.h"
|
#include "faction_type.h"
|
||||||
|
#include "config.h"
|
||||||
#include "tech_tree.h"
|
#include "tech_tree.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "upgrade.h"
|
#include "upgrade.h"
|
||||||
|
@ -54,9 +55,41 @@ Object::~Object(){
|
||||||
stateCallback->removingObjectEvent(this);
|
stateCallback->removingObjectEvent(this);
|
||||||
//renderer.getGame()->getGui()->removeObject(this);
|
//renderer.getGame()->getGui()->removeObject(this);
|
||||||
}
|
}
|
||||||
|
// fade(and by this remove) all unit particle systems
|
||||||
|
while(unitParticleSystems.empty() == false) {
|
||||||
|
unitParticleSystems.back()->fade();
|
||||||
|
unitParticleSystems.pop_back();
|
||||||
|
}
|
||||||
delete resource;
|
delete resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::initParticles(){
|
||||||
|
if(this->objectType==NULL) return;
|
||||||
|
if(this->objectType->hasParticles()){
|
||||||
|
ObjectParticleSystemTypes *particleTypes= this->objectType->getObjectParticleSystemTypes(variation);
|
||||||
|
if(Config::getInstance().getBool("UnitParticles") && (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));
|
||||||
|
this->unitParticleSystems.push_back(ups);
|
||||||
|
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::setHeight(float height){
|
||||||
|
pos.y=height;
|
||||||
|
|
||||||
|
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
|
||||||
|
(*it)->setPos(this->pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Model *Object::getModelPtr() const {
|
Model *Object::getModelPtr() const {
|
||||||
return objectType==NULL ? (resource != NULL && resource->getType() != NULL ? resource->getType()->getModel() : NULL ) : objectType->getModel(variation);
|
return objectType==NULL ? (resource != NULL && resource->getType() != NULL ? resource->getType()->getModel() : NULL ) : objectType->getModel(variation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
#include "particle.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ class Resource;
|
||||||
using Shared::Graphics::Model;
|
using Shared::Graphics::Model;
|
||||||
using Shared::Graphics::Vec2i;
|
using Shared::Graphics::Vec2i;
|
||||||
using Shared::Graphics::Vec3f;
|
using Shared::Graphics::Vec3f;
|
||||||
|
using Shared::Graphics::UnitParticleSystem;
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Object
|
// class Object
|
||||||
|
@ -39,8 +41,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class Object {
|
class Object {
|
||||||
|
private:
|
||||||
|
typedef vector<UnitParticleSystem*> UnitParticleSystems;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ObjectType *objectType;
|
ObjectType *objectType;
|
||||||
|
vector<UnitParticleSystem*> unitParticleSystems;
|
||||||
Resource *resource;
|
Resource *resource;
|
||||||
Vec3f pos;
|
Vec3f pos;
|
||||||
float rotation;
|
float rotation;
|
||||||
|
@ -54,10 +60,9 @@ public:
|
||||||
Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos);
|
Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos);
|
||||||
~Object();
|
~Object();
|
||||||
|
|
||||||
|
void initParticles();
|
||||||
static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; }
|
static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; }
|
||||||
|
|
||||||
void setHeight(float height) {pos.y= height;}
|
|
||||||
|
|
||||||
const ObjectType *getType() const {return objectType;}
|
const ObjectType *getType() const {return objectType;}
|
||||||
Resource *getResource() const {return resource;}
|
Resource *getResource() const {return resource;}
|
||||||
Vec3f getPos() const {return pos;}
|
Vec3f getPos() const {return pos;}
|
||||||
|
@ -68,6 +73,7 @@ public:
|
||||||
bool getWalkable() const;
|
bool getWalkable() const;
|
||||||
|
|
||||||
void setResource(const ResourceType *resourceType, const Vec2i &pos);
|
void setResource(const ResourceType *resourceType, const Vec2i &pos);
|
||||||
|
void setHeight(float height);
|
||||||
|
|
||||||
int getLastRenderFrame() const { return lastRenderFrame; }
|
int getLastRenderFrame() const { return lastRenderFrame; }
|
||||||
void setLastRenderFrame(int value) { lastRenderFrame = value; }
|
void setLastRenderFrame(int value) { lastRenderFrame = value; }
|
||||||
|
|
|
@ -22,11 +22,23 @@ namespace Glest{ namespace Game{
|
||||||
|
|
||||||
void ObjectType::init(int modelCount, int objectClass, bool walkable, int height) {
|
void ObjectType::init(int modelCount, int objectClass, bool walkable, int height) {
|
||||||
models.reserve(modelCount);
|
models.reserve(modelCount);
|
||||||
|
particles.reserve(modelCount); // one list per model
|
||||||
this->objectClass= objectClass;
|
this->objectClass= objectClass;
|
||||||
this->walkable= walkable;
|
this->walkable= walkable;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectType::~ObjectType(){
|
||||||
|
|
||||||
|
for(int i=0;i<particles.size();i++ ){
|
||||||
|
while(!(particles[i].empty())){
|
||||||
|
delete particles[i].back();
|
||||||
|
particles[i].pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Logger::getInstance().add("ObjectType", true);
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectType::loadModel(const string &path){
|
void ObjectType::loadModel(const string &path){
|
||||||
Model *model= Renderer::getInstance().newModel(rsGame);
|
Model *model= Renderer::getInstance().newModel(rsGame);
|
||||||
model->load(path);
|
model->load(path);
|
||||||
|
@ -36,6 +48,11 @@ void ObjectType::loadModel(const string &path){
|
||||||
color= p->getPixel3f(p->getW()/2, p->getH()/2);
|
color= p->getPixel3f(p->getW()/2, p->getH()/2);
|
||||||
}
|
}
|
||||||
models.push_back(model);
|
models.push_back(model);
|
||||||
|
particles.resize(particles.size()+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectType::addParticleSystem(ObjectParticleSystemType *particleSystem){
|
||||||
|
particles.back().push_back(particleSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectType::deletePixels() {
|
void ObjectType::deletePixels() {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
#include "unit_particle_type.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
@ -30,10 +31,14 @@ using Shared::Graphics::Vec3f;
|
||||||
/// Each of the possible objects of the map: trees, stones ...
|
/// Each of the possible objects of the map: trees, stones ...
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
typedef vector<ObjectParticleSystemType*> ObjectParticleSystemTypes;
|
||||||
|
typedef vector<ObjectParticleSystemTypes> ObjectParticleVector;
|
||||||
|
|
||||||
class ObjectType{
|
class ObjectType{
|
||||||
private:
|
private:
|
||||||
typedef vector<Model*> Models;
|
typedef vector<Model*> Models;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int tree1= 0;
|
static const int tree1= 0;
|
||||||
static const int tree2= 1;
|
static const int tree2= 1;
|
||||||
|
@ -41,17 +46,22 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Models models;
|
Models models;
|
||||||
|
ObjectParticleVector particles;
|
||||||
Vec3f color;
|
Vec3f color;
|
||||||
int objectClass;
|
int objectClass;
|
||||||
bool walkable;
|
bool walkable;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~ObjectType();
|
||||||
void init(int modelCount, int objectClass, bool walkable, int height);
|
void init(int modelCount, int objectClass, bool walkable, int height);
|
||||||
|
|
||||||
void loadModel(const string &path);
|
void loadModel(const string &path);
|
||||||
|
void addParticleSystem(ObjectParticleSystemType *particleSystem);
|
||||||
|
|
||||||
Model *getModel(int i) {return models[i];}
|
Model *getModel(int i) {return models[i];}
|
||||||
|
bool hasParticles() const {return !particles.empty();}
|
||||||
|
ObjectParticleSystemTypes *getObjectParticleSystemTypes(int i) {return &particles[i];}
|
||||||
int getModelCount() const {return models.size();}
|
int getModelCount() const {return models.size();}
|
||||||
const Vec3f &getColor() const {return color;}
|
const Vec3f &getColor() const {return color;}
|
||||||
int getClass() const {return objectClass;}
|
int getClass() const {return objectClass;}
|
||||||
|
|
|
@ -179,6 +179,20 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
||||||
const XmlNode *modelNode= objectNode->getChild("model", j);
|
const XmlNode *modelNode= objectNode->getChild("model", j);
|
||||||
const XmlAttribute *pathAttribute= modelNode->getAttribute("path");
|
const XmlAttribute *pathAttribute= modelNode->getAttribute("path");
|
||||||
objectTypes[i].loadModel(dir +"/"+ pathAttribute->getRestrictedValue());
|
objectTypes[i].loadModel(dir +"/"+ pathAttribute->getRestrictedValue());
|
||||||
|
|
||||||
|
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());
|
||||||
|
objectTypes[i].addParticleSystem((objectParticleSystemType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ World::World(){
|
||||||
Config &config= Config::getInstance();
|
Config &config= Config::getInstance();
|
||||||
|
|
||||||
staggeredFactionUpdates = config.getBool("StaggeredFactionUpdates","false");
|
staggeredFactionUpdates = config.getBool("StaggeredFactionUpdates","false");
|
||||||
|
unitParticlesEnabled=config.getBool("UnitParticles");
|
||||||
|
|
||||||
ExploredCellsLookupItemCache.clear();
|
ExploredCellsLookupItemCache.clear();
|
||||||
ExploredCellsLookupItemCacheTimer.clear();
|
ExploredCellsLookupItemCacheTimer.clear();
|
||||||
|
@ -1056,7 +1057,9 @@ void World::initCells(bool fogOfWar) {
|
||||||
if(sc == NULL) {
|
if(sc == NULL) {
|
||||||
throw runtime_error("sc == NULL");
|
throw runtime_error("sc == NULL");
|
||||||
}
|
}
|
||||||
|
if(sc->getObject()!=NULL){
|
||||||
|
sc->getObject()->initParticles();
|
||||||
|
}
|
||||||
sc->setFowTexCoord(Vec2f(
|
sc->setFowTexCoord(Vec2f(
|
||||||
i/(next2Power(map.getSurfaceW())-1.f),
|
i/(next2Power(map.getSurfaceW())-1.f),
|
||||||
j/(next2Power(map.getSurfaceH())-1.f)));
|
j/(next2Power(map.getSurfaceH())-1.f)));
|
||||||
|
|
|
@ -135,6 +135,7 @@ private:
|
||||||
Chrono chronoPerfTimer;
|
Chrono chronoPerfTimer;
|
||||||
bool perfTimerEnabled;
|
bool perfTimerEnabled;
|
||||||
|
|
||||||
|
bool unitParticlesEnabled;
|
||||||
bool staggeredFactionUpdates;
|
bool staggeredFactionUpdates;
|
||||||
std::map<string,StaticSound *> staticSoundList;
|
std::map<string,StaticSound *> staticSoundList;
|
||||||
std::map<string,StrSound *> streamSoundList;
|
std::map<string,StrSound *> streamSoundList;
|
||||||
|
|
Loading…
Reference in New Issue