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
|
|
|
|
|
|
|
|
#ifndef __C_PARTICLE_MESH_EMITTER_H_INCLUDED__
|
|
|
|
#define __C_PARTICLE_MESH_EMITTER_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_PARTICLES_
|
|
|
|
|
|
|
|
#include "IParticleMeshEmitter.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
#include "aabbox3d.h"
|
|
|
|
#include "IMeshBuffer.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! A default box emitter
|
|
|
|
class CParticleMeshEmitter : public IParticleMeshEmitter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CParticleMeshEmitter(
|
|
|
|
IMesh* mesh, bool useNormalDirection = true,
|
|
|
|
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
|
|
|
|
f32 normalDirectionModifier = 100.0f,
|
|
|
|
s32 mbNumber = -1,
|
|
|
|
bool everyMeshVertex = false,
|
|
|
|
u32 minParticlesPerSecond = 20,
|
|
|
|
u32 maxParticlesPerSecond = 40,
|
|
|
|
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)
|
|
|
|
);
|
|
|
|
|
|
|
|
//! Prepares an array with new particles to emitt into the system
|
|
|
|
//! and returns how much new particles there are.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set Mesh to emit particles from
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMesh( IMesh* mesh ) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set whether to use vertex normal for direction, or direction specified
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setUseNormalDirection( bool useNormalDirection ) IRR_OVERRIDE { UseNormalDirection = useNormalDirection; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set direction the emitter emits particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setDirection( const core::vector3df& newDirection ) IRR_OVERRIDE { Direction = newDirection; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the amount that the normal is divided by for getting a particles direction
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) IRR_OVERRIDE { NormalDirectionModifier = normalDirectionModifier; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets whether to emit min<->max particles for every vertex per second, or to pick
|
|
|
|
//! min<->max vertices every second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setEveryMeshVertex( bool everyMeshVertex ) IRR_OVERRIDE { EveryMeshVertex = everyMeshVertex; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set minimum number of particles the emitter emits per second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMinParticlesPerSecond( u32 minPPS ) IRR_OVERRIDE { MinParticlesPerSecond = minPPS; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set maximum number of particles the emitter emits per second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMaxParticlesPerSecond( u32 maxPPS ) IRR_OVERRIDE { MaxParticlesPerSecond = maxPPS; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set minimum starting color for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMinStartColor( const video::SColor& color ) IRR_OVERRIDE { MinStartColor = color; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set maximum starting color for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMaxStartColor( const video::SColor& color ) IRR_OVERRIDE { MaxStartColor = color; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the maximum starting size for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMaxStartSize( const core::dimension2df& size ) IRR_OVERRIDE { MaxStartSize = size; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the minimum starting size for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMinStartSize( const core::dimension2df& size ) IRR_OVERRIDE { MinStartSize = size; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the minimum particle life-time in milliseconds
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMinLifeTime( u32 lifeTimeMin ) IRR_OVERRIDE { MinLifeTime = lifeTimeMin; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the maximum particle life-time in milliseconds
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMaxLifeTime( u32 lifeTimeMax ) IRR_OVERRIDE { MaxLifeTime = lifeTimeMax; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set maximal random derivation from the direction
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMaxAngleDegrees( s32 maxAngleDegrees ) IRR_OVERRIDE { MaxAngleDegrees = maxAngleDegrees; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get Mesh we're emitting particles from
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const IMesh* getMesh() const IRR_OVERRIDE { return Mesh; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get whether to use vertex normal for direciton, or direction specified
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isUsingNormalDirection() const IRR_OVERRIDE { return UseNormalDirection; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get direction the emitter emits particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::vector3df& getDirection() const IRR_OVERRIDE { return Direction; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the amount that the normal is divided by for getting a particles direction
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getNormalDirectionModifier() const IRR_OVERRIDE { return NormalDirectionModifier; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets whether to emit min<->max particles for every vertex per second, or to pick
|
|
|
|
//! min<->max vertices every second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool getEveryMeshVertex() const IRR_OVERRIDE { return EveryMeshVertex; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the minimum number of particles the emitter emits per second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMinParticlesPerSecond() const IRR_OVERRIDE { return MinParticlesPerSecond; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the maximum number of particles the emitter emits per second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMaxParticlesPerSecond() const IRR_OVERRIDE { return MaxParticlesPerSecond; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the minimum starting color for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const video::SColor& getMinStartColor() const IRR_OVERRIDE { return MinStartColor; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the maximum starting color for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const video::SColor& getMaxStartColor() const IRR_OVERRIDE { return MaxStartColor; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the maximum starting size for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::dimension2df& getMaxStartSize() const IRR_OVERRIDE { return MaxStartSize; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the minimum starting size for particles
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::dimension2df& getMinStartSize() const IRR_OVERRIDE { return MinStartSize; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the minimum particle life-time in milliseconds
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMinLifeTime() const IRR_OVERRIDE { return MinLifeTime; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the maximum particle life-time in milliseconds
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMaxLifeTime() const IRR_OVERRIDE { return MaxLifeTime; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get maximal random derivation from the direction
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual s32 getMaxAngleDegrees() const IRR_OVERRIDE { return MaxAngleDegrees; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
const IMesh* Mesh;
|
|
|
|
core::array<s32> VertexPerMeshBufferList;
|
|
|
|
s32 TotalVertices;
|
|
|
|
u32 MBCount;
|
|
|
|
s32 MBNumber;
|
|
|
|
|
|
|
|
f32 NormalDirectionModifier;
|
|
|
|
core::array<SParticle> Particles;
|
|
|
|
core::vector3df Direction;
|
|
|
|
core::dimension2df MaxStartSize, MinStartSize;
|
|
|
|
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
|
|
|
|
video::SColor MinStartColor, MaxStartColor;
|
|
|
|
u32 MinLifeTime, MaxLifeTime;
|
|
|
|
|
|
|
|
u32 Time;
|
|
|
|
s32 MaxAngleDegrees;
|
|
|
|
|
|
|
|
bool EveryMeshVertex;
|
|
|
|
bool UseNormalDirection;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif // _IRR_COMPILE_WITH_PARTICLES_
|
|
|
|
|
|
|
|
#endif // __C_PARTICLE_MESH_EMITTER_H_INCLUDED__
|
|
|
|
|