diff -Nauwr source/Irrlicht/CParticleBoxEmitter.cpp source/Irrlicht/CParticleBoxEmitter.cpp --- source/Irrlicht/CParticleBoxEmitter.cpp 2005-08-20 22:17:52.000000000 +0200 +++ source/Irrlicht/CParticleBoxEmitter.cpp 2005-09-26 21:35:04.000000000 +0200 @@ -15,11 +15,11 @@ CParticleBoxEmitter::CParticleBoxEmitter( core::aabbox3d box, core::vector3df direction, u32 minParticlesPerSecond, - u32 maxParticlePerSecond, video::SColor minStartColor, + u32 maxParticlesPerSecond, video::SColor minStartColor, video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees) : Box(box), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlePerSecond), + MaxParticlesPerSecond(maxParticlesPerSecond), MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) @@ -66,6 +66,7 @@ core::vector3df tgt = Direction; tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); + tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0)); p.vector = tgt; } diff -Nauwr source/Irrlicht/CParticleBoxEmitter.h source/Irrlicht/CParticleBoxEmitter.h --- source/Irrlicht/CParticleBoxEmitter.h 2005-08-20 22:17:52.000000000 +0200 +++ source/Irrlicht/CParticleBoxEmitter.h 2005-09-27 15:34:20.000000000 +0200 @@ -5,9 +5,8 @@ #ifndef __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ #define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ -#include "IParticleEmitter.h" +#include "IParticleBoxEmitter.h" #include "irrArray.h" -#include "aabbox3d.h" namespace irr { @@ -15,7 +14,7 @@ { //! A default box emitter -class CParticleBoxEmitter : public IParticleEmitter +class CParticleBoxEmitter : public IParticleBoxEmitter { public: @@ -24,7 +23,7 @@ core::aabbox3d box, core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), u32 minParticlesPerSecond = 20, - u32 maxParticlePerSecond = 40, + u32 maxParticlesPerSecond = 40, video::SColor minStartColor = video::SColor(255,0,0,0), video::SColor maxStartColor = video::SColor(255,255,255,255), u32 lifeTimeMin=2000, @@ -35,6 +34,42 @@ //! and returns how much new particles there are. virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); + //! Set direction the emitter emits particles + virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } + + //! Set direction the emitter emits particles + virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } + + //! Set direction the emitter emits particles + virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } + + //! Set direction the emitter emits particles + virtual void setMinStartColor( video::SColor& color ) { MinStartColor = color; } + + //! Set direction the emitter emits particles + virtual void setMaxStartColor( video::SColor& color ) { MaxStartColor = color; } + + //! Set whether to use vertex normal for direciton, or direction specified + virtual void setBox( core::aabbox3df box ) { Box = box; } + + //! Gets direction the emitter emits particles + virtual const core::vector3df& getDirection() const { return Direction; } + + //! Gets direction the emitter emits particles + virtual const u32& getMinParticlesPerSecond() const { return MinParticlesPerSecond; } + + //! Gets direction the emitter emits particles + virtual const u32& getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } + + //! Gets direction the emitter emits particles + virtual const video::SColor& getMinStartColor() const { return MinStartColor; } + + //! Gets direction the emitter emits particles + virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } + + //! Set the amount that the normal is divided by for getting a particles direction + virtual const core::aabbox3df& getBox() const { return Box; } + private: core::array Particles; diff -Nauwr source/Irrlicht/CParticleFadeOutAffector.cpp source/Irrlicht/CParticleFadeOutAffector.cpp --- source/Irrlicht/CParticleFadeOutAffector.cpp 2005-08-20 22:17:52.000000000 +0200 +++ source/Irrlicht/CParticleFadeOutAffector.cpp 2005-09-28 13:18:18.000000000 +0200 @@ -22,6 +22,8 @@ //! Affects an array of particles. void CParticleFadeOutAffector::affect(u32 now, SParticle* particlearray, u32 count) { + if( Enabled ) + { f32 d; for (u32 i=0; i everyWhatMillisecond) { + Particles.set_used(0); + s32 amount = (s32)((Time / everyWhatMillisecond ) + 0.5f); Time = 0; - Particle.startTime = now; - Particle.vector = Direction; + SParticle p; + + if (amount > (s32)MaxParticlesPerSecond*2) + amount = MaxParticlesPerSecond * 2; + + for(s32 i=0; i Particles; core::vector3df Direction; u32 MinParticlesPerSecond, MaxParticlesPerSecond; video::SColor MinStartColor, MaxStartColor; diff -Nauwr source/Irrlicht/CParticleSystemSceneNode.cpp source/Irrlicht/CParticleSystemSceneNode.cpp --- source/Irrlicht/CParticleSystemSceneNode.cpp 2005-08-20 22:17:54.000000000 +0200 +++ source/Irrlicht/CParticleSystemSceneNode.cpp 2005-09-28 12:10:30.000000000 +0200 @@ -25,7 +28,7 @@ const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) : IParticleSystemSceneNode(parent, mgr, id, position, rotation, scale), - Emitter(0), ParticlesAreGlobal(true) + Emitter(0), ParticlesAreGlobal(true), LastEmitTime(0) { #ifdef _DEBUG setDebugName("CParticleSystemSceneNode"); @@ -57,8 +60,6 @@ //! Sets the particle emitter, which creates the particles. void CParticleSystemSceneNode::setEmitter(IParticleEmitter* emitter) { - lastEmitTime = os::Timer::getTime(); - if (Emitter) Emitter->drop(); @@ -121,7 +122,7 @@ //! Creates a box particle emitter. -IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter( +IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter( core::aabbox3d box, core::vector3df direction, u32 minParticlesPerSecond, u32 maxParticlePerSecond, video::SColor minStartColor, video::SColor maxStartColor, @@ -137,7 +138,7 @@ //! Creates a fade out particle affector. -IParticleAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( +IParticleFadeOutAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( video::SColor targetColor, u32 timeNeededToFadeOut) { return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); @@ -145,7 +146,7 @@ //! Creates a gravity affector. -IParticleAffector* CParticleSystemSceneNode::createGravityAffector( +IParticleGravityAffector* CParticleSystemSceneNode::createGravityAffector( core::vector3df gravity, u32 timeForceLost) { return new CParticleGravityAffector(gravity, timeForceLost); @@ -155,10 +156,10 @@ //! pre render event void CParticleSystemSceneNode::OnPreRender() { - if (IsVisible) - { doParticleSystem(os::Timer::getTime()); + if (IsVisible) + { if (Particles.size() != 0) { SceneManager->registerNodeForRendering(this); @@ -258,13 +259,18 @@ void CParticleSystemSceneNode::doParticleSystem(u32 time) { - u32 now = os::Timer::getTime(); - u32 timediff = now - lastEmitTime; - lastEmitTime = now; + if( LastEmitTime == 0 ) + { + LastEmitTime = time; + return; + } - // run emitter + u32 now = time; + u32 timediff = time - LastEmitTime; + LastEmitTime = time; - if (Emitter) + // run emitter + if( Emitter && IsVisible ) { SParticle* array = 0; s32 newParticles = Emitter->emitt(now, timediff, array); @@ -284,7 +290,7 @@ } } - // run affectors + // run affectors whether the system is visible or not. This way particles can fade out core::list::Iterator ait; ait = AffectorList.begin(); while (ait != AffectorList.end()) diff -Nauwr source/Irrlicht/CParticleSystemSceneNode.h source/Irrlicht/CParticleSystemSceneNode.h --- source/Irrlicht/CParticleSystemSceneNode.h 2005-08-20 22:17:54.000000000 +0200 +++ source/Irrlicht/CParticleSystemSceneNode.h 2005-09-28 12:10:08.000000000 +0200 @@ -68,7 +68,7 @@ s32 maxAngleDegrees=0); //! Creates a box particle emitter. - virtual IParticleEmitter* createBoxEmitter( + virtual IParticleBoxEmitter* createBoxEmitter( core::aabbox3d box = core::aabbox3d(-10,0,-10,5,30,10), core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), u32 minParticlesPerSecond = 5, @@ -79,12 +79,12 @@ s32 maxAngleDegrees=0); //! Creates a fade out particle affector. - virtual IParticleAffector* createFadeOutParticleAffector( + virtual IParticleFadeOutAffector* createFadeOutParticleAffector( video::SColor targetColor = video::SColor(0,0,0,0), u32 timeNeededToFadeOut = 1000); //! Creates a gravity affector. - virtual IParticleAffector* createGravityAffector( + virtual IParticleGravityAffector* createGravityAffector( core::vector3df gravity = core::vector3df(0.0f,-0.03f,0.0f), u32 timeForceLost = 1000); @@ -107,7 +107,7 @@ core::array Particles; video::SMaterial Material; core::aabbox3d Box; - u32 lastEmitTime; + u32 LastEmitTime; core::dimension2d ParticleSize; core::array Vertices; // 4 vertices per particle diff -Nauwr include/IParticleAffector.h include/IParticleAffector.h --- include/IParticleAffector.h 2005-08-20 22:17:46.000000000 +0200 +++ include/IParticleAffector.h 2005-09-28 13:17:34.000000000 +0200 @@ -24,6 +24,15 @@ //! Get emitter type virtual E_PARTICLE_AFFECTOR_TYPE getType() = 0; + + //! Sets whether or not the affector is currently enabled + virtual void setEnabled( bool enabled ) { Enabled = enabled; } + + //! Gets wheter or not the affector is currently enabled + virtual const bool& getEnabled() const { return Enabled; } + +protected: + bool Enabled; }; } // end namespace scene diff -Nauwr include/IParticleBoxEmitter.h include/IParticleBoxEmitter.h --- include/IParticleBoxEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ include/IParticleBoxEmitter.h 2005-09-27 15:34:28.000000000 +0200 @@ -0,0 +1,38 @@ +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_BOX_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_BOX_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" +#include "aabbox3d.h" + +namespace irr +{ +namespace scene +{ + +//! A particle emitter for using with particle systems. +/** A Particle emitter emitts new particles into a particle system. +*/ +class IParticleBoxEmitter : public IParticleEmitter +{ +public: + + //! destructor + virtual ~IParticleBoxEmitter() {}; + + //! Set whether to use vertex normal for direciton, or direction specified + virtual void setBox( core::aabbox3df box ) = 0; + + //! Set the amount that the normal is divided by for getting a particles direction + virtual const core::aabbox3df& getBox() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Nauwr include/IParticleEmitter.h include/IParticleEmitter.h --- include/IParticleEmitter.h 2005-08-20 22:17:46.000000000 +0200 +++ include/IParticleEmitter.h 2005-09-27 15:00:54.000000000 +0200 @@ -31,6 +31,36 @@ //! Get emitter type virtual E_PARTICLE_EMITTER_TYPE getType() = 0; + + //! Set direction the emitter emits particles + virtual void setDirection( const core::vector3df& newDirection ) = 0; + + //! Set minimum number of particles the emitter emits per second + virtual void setMinParticlesPerSecond( u32 minPPS ) = 0; + + //! Set maximum number of particles the emitter emits per second + virtual void setMaxParticlesPerSecond( u32 maxPPS ) = 0; + + //! Set minimum starting color for particles + virtual void setMinStartColor( video::SColor& color ) = 0; + + //! Set maximum starting color for particles + virtual void setMaxStartColor( video::SColor& color ) = 0; + + //! Get direction the emitter emits particles + virtual const core::vector3df& getDirection() const = 0; + + //! Get the minimum number of particles the emitter emits per second + virtual const u32& getMinParticlesPerSecond() const = 0; + + //! Get the maximum number of particles the emitter emits per second + virtual const u32& getMaxParticlesPerSecond() const = 0; + + //! Get the minimum starting color for particles + virtual const video::SColor& getMinStartColor() const = 0; + + //! Get the maximum starting color for particles + virtual const video::SColor& getMaxStartColor() const = 0; }; } // end namespace scene diff -Nauwr include/IParticleFadeOutAffector.h include/IParticleFadeOutAffector.h --- include/IParticleFadeOutAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ include/IParticleFadeOutAffector.h 2005-09-28 10:19:42.000000000 +0200 @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector modifies particles. +class IParticleFadeOutAffector : public IParticleAffector +{ +public: + + //! Affects an array of particles. + //! \param now: Current time. (Same as ITimer::getTime() would return) + //! \param particlearray: Array of particles. + //! \param count: Amount of particles in array. + virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; + + //! Sets the targetColor, or the color that the partilces color will interpolate + //! to over the specified time. + virtual void setTargetColor( video::SColor targetColor ) = 0; + + //! Sets the amount of time it takes for each particle to fade out. + virtual void setFadeOutTime( f32 fadeOutTime ) = 0; + + //! Sets the targetColor, or the color that the partilces color will interpolate + //! to over the specified time. + virtual const video::SColor& getTargetColor() const = 0; + + //! Sets the amount of time it takes for each particle to fade out. + virtual const f32& getFadeOutTime() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ + diff -Nauwr include/IParticleGravityAffector.h include/IParticleGravityAffector.h --- include/IParticleGravityAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ include/IParticleGravityAffector.h 2005-09-28 10:21:24.000000000 +0200 @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2006 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector modifies particles. +class IParticleGravityAffector : public IParticleAffector +{ +public: + + //! Affects an array of particles. + //! \param now: Current time. (Same as ITimer::getTime() would return) + //! \param particlearray: Array of particles. + //! \param count: Amount of particles in array. + virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; + + //! Set the time in milliseconds when the force of the emitter is totally + //! lost and the particle does not move any more. + virtual void setTimeForceLost( f32 timeForceLost ) = 0; + + //! Set the direction and force of gravity. + virtual void setGravity( core::vector3df gravity ) = 0; + + //! Set the time in milliseconds when the force of the emitter is totally + //! lost and the particle does not move any more. + virtual const f32& getTimeForceLost() const = 0; + + //! Set the direction and force of gravity. + virtual const core::vector3df& getGravity() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ + diff -Nauwr include/IParticleSystemSceneNode.h include/IParticleSystemSceneNode.h --- include/IParticleSystemSceneNode.h 2005-08-20 22:17:46.000000000 +0200 +++ include/IParticleSystemSceneNode.h 2005-09-28 10:53:22.000000000 +0200 @@ -6,8 +6,12 @@ #define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ #include "ISceneNode.h" +#include "IMesh.h" #include "IParticleEmitter.h" +#include "IParticleBoxEmitter.h" #include "IParticleAffector.h" +#include "IParticleFadeOutAffector.h" +#include "IParticleGravityAffector.h" #include "dimension2d.h" namespace irr @@ -77,7 +81,9 @@ //! Removes all particle affectors in the particle system. virtual void removeAllAffectors() = 0; - //! Creates a point particle emitter. + //! Creates a point particle emitter. Note that the point particle emitter + //! does not have a specific interface class, it has no additional properties that + //! IParticleEmitter does not provide functionality to access, so none is needed. //! \param direction: Direction and speed of particle emission. //! \param minParticlesPerSecond: Minimal amount of particles emitted //! per second. @@ -128,7 +134,7 @@ //! just call setEmitter(). Note that you'll have to drop() the //! returned pointer, after you don't need it any more, see //! IUnknown::drop() for more informations. - virtual IParticleEmitter* createBoxEmitter( + virtual IParticleBoxEmitter* createBoxEmitter( core::aabbox3d box = core::aabbox3d(-10,28,-10,10,30,10), core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), u32 minParticlesPerSecond = 5, @@ -152,7 +158,7 @@ //! just call addAffector(). Note that you'll have to drop() the //! returned pointer, after you don't need it any more, see //! IUnknown::drop() for more informations. - virtual IParticleAffector* createFadeOutParticleAffector( + virtual IParticleFadeOutAffector* createFadeOutParticleAffector( video::SColor targetColor = video::SColor(0,0,0,0), u32 timeNeededToFadeOut = 1000) = 0; @@ -170,7 +176,7 @@ //! just call addAffector(). Note that you'll have to drop() the //! returned pointer, after you don't need it any more, see //! IUnknown::drop() for more informations. - virtual IParticleAffector* createGravityAffector( + virtual IParticleGravityAffector* createGravityAffector( core::vector3df gravity = core::vector3df(0.0f,-0.03f,0.0f), u32 timeForceLost = 1000) = 0; }; diff -Nauwr include/irrlicht.h include/irrlicht.h --- include/irrlicht.h 2005-08-20 22:46:48.000000000 +0200 +++ include/irrlicht.h 2005-09-28 10:14:26.000000000 +0200 @@ -89,7 +89,10 @@ #include "ITerrainSceneNode.h" #include "ITextSceneNode.h" #include "IParticleEmitter.h" +#include "IParticleBoxEmitter.h" #include "IParticleAffector.h" +#include "IParticleFadeOutAffector.h" +#include "IParticleGravityAffector.h" #include "IBillboardSceneNode.h" #include "ITexture.h" #include "IUnknown.h"