2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED
|
|
|
|
#define IRR_C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_PARTICLES_
|
|
|
|
|
|
|
|
#include "IParticleSystemSceneNode.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
#include "irrList.h"
|
|
|
|
#include "SMeshBuffer.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! A particle system scene node.
|
|
|
|
/** A scene node controlling a particle system. The behavior of the particles
|
|
|
|
can be controlled by setting the right particle emitters and affectors.
|
|
|
|
*/
|
|
|
|
class CParticleSystemSceneNode : public IParticleSystemSceneNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CParticleSystemSceneNode(bool createDefaultEmitter,
|
|
|
|
ISceneNode* parent, ISceneManager* mgr, s32 id,
|
|
|
|
const core::vector3df& position,
|
|
|
|
const core::vector3df& rotation,
|
|
|
|
const core::vector3df& scale);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CParticleSystemSceneNode();
|
|
|
|
|
|
|
|
//! Gets the particle emitter, which creates the particles.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IParticleEmitter* getEmitter() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the particle emitter, which creates the particles.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setEmitter(IParticleEmitter* emitter) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Adds new particle affector to the particle system.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void addAffector(IParticleAffector* affector) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get a list of all particle affectors.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::list<IParticleAffector*>& getAffectors() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Removes all particle affectors in the particle system.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void removeAllAffectors() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the material based on the zero based index i.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::SMaterial& getMaterial(u32 i) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns amount of materials used by this scene node.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMaterialCount() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! pre render event
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void OnRegisterSceneNode() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! render
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void render() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! returns the axis aligned bounding box of this node
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::aabbox3d<f32>& getBoundingBox() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a particle emitter for an animated mesh scene node
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a box particle emitter.
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a particle emitter for emitting from a cylinder
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a mesh particle emitter.
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a point particle emitter.
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a ring particle emitter.
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a sphere particle emitter.
|
|
|
|
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),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a point attraction affector. This affector modifies the positions of the
|
|
|
|
//! particles and attracts them to a specified point at a specified speed per second.
|
|
|
|
virtual IParticleAttractionAffector* createAttractionAffector(
|
|
|
|
const core::vector3df& point, f32 speed = 1.0f, bool attract = true,
|
2021-08-27 14:55:10 +02:00
|
|
|
bool affectX = true, bool affectY = true, bool affectZ = true) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a scale particle affector.
|
|
|
|
virtual IParticleAffector* createScaleParticleAffector(
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f)) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a fade out particle affector.
|
|
|
|
virtual IParticleFadeOutAffector* createFadeOutParticleAffector(
|
|
|
|
const video::SColor& targetColor = video::SColor(0,0,0,0),
|
2021-08-27 14:55:10 +02:00
|
|
|
u32 timeNeededToFadeOut = 1000) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a gravity affector.
|
|
|
|
virtual IParticleGravityAffector* createGravityAffector(
|
|
|
|
const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),
|
2021-08-27 14:55:10 +02:00
|
|
|
u32 timeForceLost = 1000) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a rotation affector. This affector rotates the particles
|
|
|
|
//! around a specified pivot point. The speed is in Degrees per second.
|
|
|
|
virtual IParticleRotationAffector* createRotationAffector(
|
|
|
|
const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f),
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the size of all particles.
|
|
|
|
virtual void setParticleSize(
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets if the particles should be global. If they are, the particles are affected by
|
|
|
|
//! the movement of the particle system scene node too, otherwise they completely
|
|
|
|
//! ignore it. Default is true.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setParticlesAreGlobal(bool global=true) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Remove all currently visible particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void clearParticles() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets if the node should be visible or not.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setVisible(bool isVisible) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Do manually update the particles.
|
|
|
|
//! This should only be called when you want to render the node outside the scenegraph,
|
|
|
|
//! as the node will care about this otherwise automatically.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void doParticleSystem(u32 time) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Writes attributes of the scene node.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Reads attributes of the scene node.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns type of the scene node
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ESCENE_NODE_TYPE getType() const IRR_OVERRIDE { return ESNT_PARTICLE_SYSTEM; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void reallocateBuffers();
|
|
|
|
|
|
|
|
core::list<IParticleAffector*> AffectorList;
|
|
|
|
IParticleEmitter* Emitter;
|
|
|
|
core::array<SParticle> Particles;
|
|
|
|
core::dimension2d<f32> ParticleSize;
|
|
|
|
u32 LastEmitTime;
|
|
|
|
core::matrix4 LastAbsoluteTransformation;
|
|
|
|
|
|
|
|
SMeshBuffer* Buffer;
|
|
|
|
|
|
|
|
// TODO: That was obviously planned by someone at some point and sounds like a good idea.
|
|
|
|
// But seems it was never implemented.
|
|
|
|
// enum E_PARTICLES_PRIMITIVE
|
|
|
|
// {
|
|
|
|
// EPP_POINT=0,
|
|
|
|
// EPP_BILLBOARD,
|
|
|
|
// EPP_POINTSPRITE
|
|
|
|
// };
|
|
|
|
// E_PARTICLES_PRIMITIVE ParticlePrimitive;
|
|
|
|
|
|
|
|
bool ParticlesAreGlobal;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif // _IRR_COMPILE_WITH_PARTICLES_
|
|
|
|
|
|
|
|
#endif
|