#ifndef __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__
#define __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__
#include "IParticleSystemSceneNode.h"
#include "irrArray.h"
#include "irrList.h"
#include "SMeshBuffer.h"
namespace irr
{
namespace scene
{
class CParticleSystemSceneNode : public IParticleSystemSceneNode
{
public:
CParticleSystemSceneNode(bool createDefaultEmitter,
ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position,
const core::vector3df& rotation,
const core::vector3df& scale);
virtual ~CParticleSystemSceneNode();
virtual IParticleEmitter* getEmitter();
virtual void setEmitter(IParticleEmitter* emitter);
virtual void addAffector(IParticleAffector* affector);
virtual const core::list<IParticleAffector*>& getAffectors() const;
virtual void removeAllAffectors();
virtual video::SMaterial& getMaterial(u32 i);
virtual u32 getMaterialCount() const;
virtual void OnRegisterSceneNode();
virtual void render();
virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(
scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false, u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticleBoxEmitter* createBoxEmitter(
const core::aabbox3df& box = core::aabbox3d<f32>(-10,0,-10,5,30,10),
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticleCylinderEmitter* createCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.5f,0.0f),
u32 minParticlesPerSecond = 5, u32 maxParticlesPersSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticleMeshEmitter* createMeshEmitter(
scene::IMesh* mesh, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticlePointEmitter* createPointEmitter(
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticleRingEmitter* createRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticleSphereEmitter* createSphereEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0,
const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) );
virtual IParticleAttractionAffector* createAttractionAffector(
const core::vector3df& point, f32 speed = 1.0f, bool attract = true,
bool affectX = true, bool affectY = true, bool affectZ = true);
virtual IParticleAffector* createScaleParticleAffector(const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f));
virtual IParticleFadeOutAffector* createFadeOutParticleAffector(
const video::SColor& targetColor = video::SColor(0,0,0,0),
u32 timeNeededToFadeOut = 1000);
virtual IParticleGravityAffector* createGravityAffector(
const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),
u32 timeForceLost = 1000);
virtual IParticleRotationAffector* createRotationAffector(
const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f),
const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) );
virtual void setParticleSize(
const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f));
virtual void setParticlesAreGlobal(bool global=true);
virtual void clearParticles();
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
virtual ESCENE_NODE_TYPE getType() const { return ESNT_PARTICLE_SYSTEM; }
private:
void doParticleSystem(u32 time);
void reallocateBuffers();
core::list<IParticleAffector*> AffectorList;
IParticleEmitter* Emitter;
core::array<SParticle> Particles;
core::dimension2d<f32> ParticleSize;
u32 LastEmitTime;
s32 MaxParticles;
SMeshBuffer* Buffer;
enum E_PARTICLES_PRIMITIVE
{
EPP_POINT=0,
EPP_BILLBOARD,
EPP_POINTSPRITE
};
E_PARTICLES_PRIMITIVE ParticlePrimitive;
bool ParticlesAreGlobal;
};
}
}
#endif