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_BOX_EMITTER_H_INCLUDED
|
|
|
|
#define IRR_C_PARTICLE_BOX_EMITTER_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_PARTICLES_
|
|
|
|
|
|
|
|
#include "IParticleBoxEmitter.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
#include "aabbox3d.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! A default box emitter
|
|
|
|
class CParticleBoxEmitter : public IParticleBoxEmitter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CParticleBoxEmitter(
|
|
|
|
const core::aabbox3df& box,
|
|
|
|
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
|
|
|
|
u32 minParticlesPerSecond = 20,
|
|
|
|
u32 maxParticlesPerSecond = 40,
|
|
|
|
video::SColor minStartColor = video::SColor(255,0,0,0),
|
|
|
|
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 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 minimum number of particles emitted 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 emitted 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 start color.
|
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 start color.
|
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
|
|
|
|
|
|
|
//! 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
|
|
|
|
|
|
|
//! Set box from which the particles are emitted.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setBox( const core::aabbox3df& box ) IRR_OVERRIDE { Box = box; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets 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
|
|
|
|
|
|
|
//! Gets minimum number of particles emitted 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
|
|
|
|
|
|
|
//! Gets maximum number of particles emitted 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
|
|
|
|
|
|
|
//! Gets minimum start color.
|
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
|
|
|
|
|
|
|
//! Gets maximum start color.
|
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
|
|
|
|
|
|
|
//! 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
|
|
|
|
|
|
|
//! Get box from which the particles are emitted.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::aabbox3df& getBox() const IRR_OVERRIDE { return Box; }
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Writes attributes of the object.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Reads attributes of the object.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
core::array<SParticle> Particles;
|
|
|
|
core::aabbox3df Box;
|
|
|
|
core::vector3df Direction;
|
|
|
|
core::dimension2df MaxStartSize, MinStartSize;
|
|
|
|
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
|
|
|
|
video::SColor MinStartColor, MaxStartColor;
|
|
|
|
u32 MinLifeTime, MaxLifeTime;
|
|
|
|
|
|
|
|
u32 Time;
|
|
|
|
s32 MaxAngleDegrees;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif // _IRR_COMPILE_WITH_PARTICLES_
|
|
|
|
|
|
|
|
#endif
|