diff -Nauwr Irrlicht/CParticleAttractionAffector.cpp Irrlicht/CParticleAttractionAffector.cpp --- Irrlicht/CParticleAttractionAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleAttractionAffector.cpp 2005-09-28 13:23:50.000000000 +0200 @@ -0,0 +1,62 @@ +// Copyright (C) 2002-2005 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleAttractionAffector.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleAttractionAffector::CParticleAttractionAffector( core::vector3df point, + f32 speed, bool affectX, bool affectY, bool affectZ ) +: Point( point ) +, Speed( speed ) +, AffectX( affectX ) +, AffectY( affectY ) +, AffectZ( affectZ ) +, LastTime( 0 ) +{ +} + + +//! Affects an array of particles. +void CParticleAttractionAffector::affect(u32 now, SParticle* particlearray, u32 count) +{ + if( LastTime == 0 ) + { + LastTime = now; + return; + } + + f32 timeDelta = ( now - LastTime ) / 1000.0f; + LastTime = now; + + if( Enabled ) + { + for (u32 i=0; i 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 Irrlicht/CParticleBoxEmitter.h Irrlicht/CParticleBoxEmitter.h --- Irrlicht/CParticleBoxEmitter.h 2005-08-20 22:17:52.000000000 +0200 +++ 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 Irrlicht/CParticleFadeOutAffector.cpp Irrlicht/CParticleFadeOutAffector.cpp --- Irrlicht/CParticleFadeOutAffector.cpp 2005-08-20 22:17:52.000000000 +0200 +++ 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 + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleMeshEmitter::CParticleMeshEmitter( + IMesh* mesh, bool useNormalDirection, core::vector3df direction, f32 normalDirectionModifier, s32 mbNumber, + bool everyMeshVertex, u32 minParticlesPerSecond, u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) + : Mesh(mesh), EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection), TotalVertices(0), Direction(direction), + MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond), + MinStartColor(minStartColor), MaxStartColor(maxStartColor), + MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), + MaxAngleDegrees(maxAngleDegrees), MBCount(0), MBNumber(mbNumber), NormalDirectionModifier(normalDirectionModifier) +{ + MBCount = Mesh->getMeshBufferCount(); + for( s32 i = 0; i < MBCount; ++i ) + { + VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() ); + TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount(); + } +} + + +//! Prepares an array with new particles to emitt into the system +//! and returns how much new particles there are. +s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) +{ + Time += timeSinceLastCall; + + u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); + f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; + f32 everyWhatMillisecond = 1000.0f / perSecond; + + if (Time > everyWhatMillisecond) + { + Particles.set_used(0); + s32 amount = (s32)((Time / everyWhatMillisecond) + 0.5f); + Time = 0; + SParticle p; + + if (amount > (s32)MaxParticlesPerSecond * 2) + amount = MaxParticlesPerSecond * 2; + + for (s32 i=0; igetMeshBufferCount(); ++j ) + { + for( s32 k=0; kgetMeshBuffer(j)->getVertexCount(); ++k ) + { + switch( Mesh->getMeshBuffer(j)->getVertexType() ) + { + case video::EVT_2TCOORDS: + p.pos = ((video::S3DVertex2TCoords*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex2TCoords*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_STANDARD: + p.pos = ((video::S3DVertex*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_TANGENTS: + p.pos = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + } + + p.startTime = now; + + //if( !UseNormalDirection && MaxAngleDegrees ) + //{ + // 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; + //} + + if (MaxLifeTime - MinLifeTime == 0) + p.endTime = now + MinLifeTime; + else + p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); + + p.color = MinStartColor.getInterpolated( + MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); + + p.startColor = p.color; + p.startVector = p.vector; + + Particles.push_back(p); + } + } + } + else + { + s32 randomMB = 0; + + if( MBNumber < 0 ) + { + randomMB = os::Randomizer::rand() % MBCount; + } + else + { + randomMB = MBNumber; + } + + s32 vertexNumber = os::Randomizer::rand() % Mesh->getMeshBuffer(randomMB)->getVertexCount(); + + switch( Mesh->getMeshBuffer(randomMB)->getVertexType() ) + { + case video::EVT_2TCOORDS: + p.pos = ((video::S3DVertex2TCoords*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex2TCoords*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_STANDARD: + p.pos = ((video::S3DVertex*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_TANGENTS: + p.pos = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + } + + p.startTime = now; + + //if (MaxAngleDegrees) + //{ + // 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; + //} + + if (MaxLifeTime - MinLifeTime == 0) + p.endTime = now + MinLifeTime; + else + p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime)); + + p.color = MinStartColor.getInterpolated( + MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f); + + p.startColor = p.color; + p.startVector = p.vector; + + Particles.push_back(p); + } + } + + outArray = Particles.pointer(); + + return Particles.size(); + } + + return 0; +} + +} // end namespace scene +} // end namespace irr + diff -Nauwr Irrlicht/CParticleMeshEmitter.h Irrlicht/CParticleMeshEmitter.h --- Irrlicht/CParticleMeshEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleMeshEmitter.h 2005-09-28 15:17:28.000000000 +0200 @@ -0,0 +1,137 @@ +// Copyright (C) 2002-2005 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 "IParticleMeshEmitter.h" +#include "irrArray.h" +#include "aabbox3d.h" + +namespace irr +{ +namespace scene +{ + +//! A default box emitter +class CParticleMeshEmitter : public IParticleMeshEmitter +{ +public: + + //! constructor + CParticleMeshEmitter( + IMesh* mesh, + bool useNormalDirection = true, + 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, + 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 + ); + + //! Prepares an array with new particles to emitt into the system + //! and returns how much new particles there are. + virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray); + + //! Set Mesh to emit particles from + virtual void setMesh( IMesh* mesh ) + { + Mesh = mesh; + + TotalVertices = 0; + MBCount = Mesh->getMeshBufferCount(); + for( s32 i = 0; i < MBCount; ++i ) + { + VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() ); + TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount(); + } + } + + //! Set whether to use vertex normal for direciton, or direction specified + virtual void setUseNormalDirection( bool useNormalDirection ) { UseNormalDirection = useNormalDirection; } + + //! Set direction the emitter emits particles + virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; } + + //! Set the amount that the normal is divided by for getting a particles direction + virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) { NormalDirectionModifier = normalDirectionModifier; } + + //! Sets whether to emit min<->max particles for every vertex per second, or to pick + //! min<->max vertices every second + virtual void setEveryMeshVertex( bool everyMeshVertex ) { EveryMeshVertex = everyMeshVertex; } + + //! Set minimum number of particles the emitter emits per second + virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; } + + //! Set maximum number of particles the emitter emits per second + virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; } + + //! Set minimum starting color for particles + virtual void setMinStartColor( video::SColor& color ) { MinStartColor = color; } + + //! Set maximum starting color for particles + virtual void setMaxStartColor( video::SColor& color ) { MaxStartColor = color; } + + //! Get Mesh we're emitting particles from + virtual const IMesh* getMesh() const { return Mesh; } + + //! Get whether to use vertex normal for direciton, or direction specified + virtual const bool& isUsingNormalDirection() const { return UseNormalDirection; } + + //! Get direction the emitter emits particles + virtual const core::vector3df& getDirection() const { return Direction; } + + //! Get the amount that the normal is divided by for getting a particles direction + virtual const f32& getNormalDirectionModifier() const { return NormalDirectionModifier; } + + //! Gets whether to emit min<->max particles for every vertex per second, or to pick + //! min<->max vertices every second + virtual const bool& getEveryMeshVertex() const { return EveryMeshVertex; } + + //! Get the minimum number of particles the emitter emits per second + virtual const u32& getMinParticlesPerSecond() const { return MinParticlesPerSecond; } + + //! Get the maximum number of particles the emitter emits per second + virtual const u32& getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; } + + //! Get the minimum starting color for particles + virtual const video::SColor& getMinStartColor() const { return MinStartColor; } + + //! Get the maximum starting color for particles + virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } + +private: + + IMesh* Mesh; + s32 TotalVertices; + s32 MBCount; + s32 MBNumber; + core::array VertexPerMeshBufferList; + + bool EveryMeshVertex; + bool UseNormalDirection; + f32 NormalDirectionModifier; + core::array Particles; + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __C_PARTICLE_MESH_EMITTER_H_INCLUDED__ + diff -Nauwr Irrlicht/CParticlePointEmitter.cpp Irrlicht/CParticlePointEmitter.cpp --- Irrlicht/CParticlePointEmitter.cpp 2005-08-20 22:17:54.000000000 +0200 +++ Irrlicht/CParticlePointEmitter.cpp 2005-09-26 21:39:02.000000000 +0200 @@ -13,11 +13,11 @@ //! constructor CParticlePointEmitter::CParticlePointEmitter( core::vector3df direction, u32 minParticlesPerSecond, - u32 maxParticlePerSecond, video::SColor minStartColor, + u32 maxParticlesPerSecond, video::SColor minStartColor, video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees) : Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), - MaxParticlesPerSecond(maxParticlePerSecond), + MaxParticlesPerSecond(maxParticlesPerSecond), MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) @@ -39,29 +39,41 @@ if (Time > 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; u32 MinLifeTime, MaxLifeTime; - s32 MaxAngleDegrees; u32 Time; u32 Emitted; + s32 MaxAngleDegrees; }; } // end namespace scene diff -Nauwr Irrlicht/CParticleRingEmitter.cpp Irrlicht/CParticleRingEmitter.cpp --- Irrlicht/CParticleRingEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleRingEmitter.cpp 2005-09-28 11:08:44.000000000 +0200 @@ -0,0 +1,108 @@ +// Copyright (C) 2002-2005 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleRingEmitter.h" +#include "os.h" +#include + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleRingEmitter::CParticleRingEmitter( + core::vector3df center, f32 radius, f32 ringThickness, + core::vector3df direction, u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) +: Center(center) +, Radius(radius) +, RingThickness(ringThickness) +, Direction(direction) +, MinParticlesPerSecond(minParticlesPerSecond) +, MaxParticlesPerSecond(maxParticlesPerSecond) +, MinStartColor(minStartColor) +, MaxStartColor(maxStartColor) +, MinLifeTime(lifeTimeMin) +, MaxLifeTime(lifeTimeMax) +, Time(0) +, Emitted(0) +, MaxAngleDegrees(maxAngleDegrees) +{ +} + + +//! Prepares an array with new particles to emitt into the system +//! and returns how much new particles there are. +s32 CParticleRingEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) +{ + Time += timeSinceLastCall; + + u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); + f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; + f32 everyWhatMillisecond = 1000.0f / perSecond; + + if (Time > everyWhatMillisecond) + { + Particles.set_used(0); + s32 amount = (s32)((Time / everyWhatMillisecond) + 0.5f); + Time = 0; + SParticle p; + + if (amount > (s32)MaxParticlesPerSecond*2) + amount = MaxParticlesPerSecond * 2; + + for (s32 i=0; i Particles; + + core::vector3df Center; + f32 Radius; + f32 RingThickness; + + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; + + f32 MinimumDistance; + f32 MaximumDistance; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Nauwr Irrlicht/CParticleRotationAffector.cpp Irrlicht/CParticleRotationAffector.cpp --- Irrlicht/CParticleRotationAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleRotationAffector.cpp 2005-09-28 13:24:14.000000000 +0200 @@ -0,0 +1,67 @@ +// Copyright (C) 2002-2005 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleRotationAffector.h" +#include "matrix4.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleRotationAffector::CParticleRotationAffector( f32 speedX, f32 speedY, f32 speedZ, + core::vector3df pivotPoint ) +: PivotPoint( pivotPoint ) +, SpeedX( speedX ) +, SpeedY( speedY ) +, SpeedZ( speedZ ) +, LastTime( 0 ) +{ +} + + +//! Affects an array of particles. +void CParticleRotationAffector::affect(u32 now, SParticle* particlearray, u32 count) +{ + if( LastTime == 0 ) + { + LastTime = now; + return; + } + + f32 timeDelta = ( now - LastTime ) / 1000.0f; + LastTime = now; + + if( Enabled ) + { + for (u32 i=0; i + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleSphereEmitter::CParticleSphereEmitter( + core::vector3df center, f32 radius, + core::vector3df direction, u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) + : Center(center), Radius(radius), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), + MaxParticlesPerSecond(maxParticlesPerSecond), + MinStartColor(minStartColor), MaxStartColor(maxStartColor), + MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), + MaxAngleDegrees(maxAngleDegrees) +{ +} + + +//! Prepares an array with new particles to emitt into the system +//! and returns how much new particles there are. +s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) +{ + Time += timeSinceLastCall; + + u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); + f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; + f32 everyWhatMillisecond = 1000.0f / perSecond; + + if (Time > everyWhatMillisecond) + { + Particles.set_used(0); + s32 amount = (s32)((Time / everyWhatMillisecond) + 0.5f); + Time = 0; + SParticle p; + + if (amount > (s32)MaxParticlesPerSecond*2) + amount = MaxParticlesPerSecond * 2; + + for (s32 i=0; i Particles; + + core::vector3df Center; + f32 Radius; + + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Nauwr Irrlicht/CParticleSystemSceneNode.cpp Irrlicht/CParticleSystemSceneNode.cpp --- Irrlicht/CParticleSystemSceneNode.cpp 2005-08-20 22:17:54.000000000 +0200 +++ Irrlicht/CParticleSystemSceneNode.cpp 2005-09-28 12:10:30.000000000 +0200 @@ -10,8 +10,13 @@ #include "CParticlePointEmitter.h" #include "CParticleBoxEmitter.h" +#include "CParticleSphereEmitter.h" +#include "CParticleRingEmitter.h" +#include "CParticleMeshEmitter.h" #include "CParticleFadeOutAffector.h" #include "CParticleGravityAffector.h" +#include "CParticleAttractionAffector.h" +#include "CParticleRotationAffector.h" namespace irr { @@ -25,7 +30,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 +62,6 @@ //! Sets the particle emitter, which creates the particles. void CParticleSystemSceneNode::setEmitter(IParticleEmitter* emitter) { - lastEmitTime = os::Timer::getTime(); - if (Emitter) Emitter->drop(); @@ -121,7 +124,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, @@ -134,10 +137,46 @@ } +//! Creates a sphere particle emitter. +IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter( + core::vector3df center, f32 radius, core::vector3df direction, + u32 minParticlesPerSecond, u32 maxParticlePerSecond, + video::SColor minStartColor, video::SColor maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) +{ + return new CParticleSphereEmitter(center, radius, direction, minParticlesPerSecond, + maxParticlePerSecond, minStartColor, maxStartColor, + lifeTimeMin, lifeTimeMax, maxAngleDegrees); +} + +//! Creates a ring particle emitter. +IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter( + core::vector3df center, f32 radius, f32 ringThickness, + core::vector3df direction, + u32 minParticlesPerSecond, u32 maxParticlePerSecond, + video::SColor minStartColor, video::SColor maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) +{ + return new CParticleRingEmitter( center, radius, ringThickness, direction, + minParticlesPerSecond, maxParticlePerSecond, minStartColor, + maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees ); +} + +//! Creates a mesh particle emitter. +IParticleMeshEmitter* CParticleSystemSceneNode::createMeshEmitter( + scene::IMesh* mesh, bool useNormalDirection, core::vector3df direction, f32 normalDirectionModifier, + s32 mbNumber, bool everyMeshVertex, u32 minParticlesPerSecond, u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) +{ + return new CParticleMeshEmitter( mesh, useNormalDirection, direction, normalDirectionModifier, + mbNumber, everyMeshVertex, minParticlesPerSecond, maxParticlesPerSecond, minStartColor, maxStartColor, + lifeTimeMin, lifeTimeMax, maxAngleDegrees ); +} //! Creates a fade out particle affector. -IParticleAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( +IParticleFadeOutAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( video::SColor targetColor, u32 timeNeededToFadeOut) { return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); @@ -145,20 +184,36 @@ //! Creates a gravity affector. -IParticleAffector* CParticleSystemSceneNode::createGravityAffector( +IParticleGravityAffector* CParticleSystemSceneNode::createGravityAffector( core::vector3df gravity, u32 timeForceLost) { return new CParticleGravityAffector(gravity, timeForceLost); } +//! 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. +IParticleAttractionAffector* CParticleSystemSceneNode::createAttractionAffector( + core::vector3df point, f32 speed, + bool affectX, bool affectY, bool affectZ ) +{ + return new CParticleAttractionAffector( point, speed, affectX, affectY, affectZ ); +} + +//! Creates a rotation affector. This affector rotates the particles around a specified pivot +//! point. The speed represents Degrees of rotation per second. +IParticleRotationAffector* CParticleSystemSceneNode::createRotationAffector( + f32 speedX, f32 speedY, f32 speedZ, core::vector3df pivotPoint ) +{ + return new CParticleRotationAffector( speedX, speedY, speedZ, pivotPoint ); +} //! pre render event void CParticleSystemSceneNode::OnPreRender() { - if (IsVisible) - { doParticleSystem(os::Timer::getTime()); + if (IsVisible) + { if (Particles.size() != 0) { SceneManager->registerNodeForRendering(this); @@ -261,13 +316,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 +344,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()) @@ -293,7 +353,6 @@ ++ait; } - if (ParticlesAreGlobal) Box.reset(AbsoluteTransformation.getTranslation()); else diff -Nauwr Irrlicht/CParticleSystemSceneNode.h Irrlicht/CParticleSystemSceneNode.h --- Irrlicht/CParticleSystemSceneNode.h 2005-08-20 22:17:54.000000000 +0200 +++ 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,28,-10,10,30,10), core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), u32 minParticlesPerSecond = 5, @@ -78,16 +78,62 @@ u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, s32 maxAngleDegrees=0); + //! Creates a sphere particle emitter. + virtual IParticleSphereEmitter* createSphereEmitter( + core::vector3df center, f32 radius, + core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlePerSecond = 10, + 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); + + //! Creates a sphere particle emitter. + virtual IParticleRingEmitter* createRingEmitter( + core::vector3df center, f32 radius, f32 ringThickness, + core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlePerSecond = 10, + 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); + + //! Creates a mesh particle emitter. + virtual IParticleMeshEmitter* createMeshEmitter( + scene::IMesh* mesh, bool useNormalDirection = true, + core::vector3df direction = core::vector3df(0.0f,0.0f,0.0f), + f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1, bool everyMeshVertex = false, + u32 minParticlesPerSecond = 5, + u32 maxParticlePerSecond = 10, + 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 ); + //! 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); + //! 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( + core::vector3df point, f32 speed, + bool affectX = true, bool affectY = true, bool affectZ = true); + + //! Creates a rotation affector. This affector rotates the particles around a specified pivot + //! point. The speed represents Degrees of rotation per second. + virtual IParticleRotationAffector* createRotationAffector( + f32 speedX = 5.0f, f32 speedY = 5.0f, f32 speedZ = 5.0f, + core::vector3df pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ); + //! Sets the size of all particles. virtual void setParticleSize( const core::dimension2d &size = core::dimension2d(5.0f, 5.0f)); @@ -107,7 +153,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 Irrlicht/include/IParticleAffector.h Irrlicht/include/IParticleAffector.h --- Irrlicht/include/IParticleAffector.h 2005-08-20 22:17:46.000000000 +0200 +++ Irrlicht/include/IParticleAffector.h 2005-09-28 13:17:34.000000000 +0200 @@ -24,6 +24,14 @@ //! \param count: Amount of particles in array. virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; + //! Sets whether or not the affector is currently enabled + virtual void setEnabled( bool enabled ) { Enabled = enabled; } + + //! Gets wheterh or not the affector is currently enabled + virtual const bool& getEnabled() const { return Enabled; } + +protected: + bool Enabled; }; } // end namespace scene diff -Nauwr Irrlicht/include/IParticleAttractionAffector.h Irrlicht/include/IParticleAttractionAffector.h --- Irrlicht/include/IParticleAttractionAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleAttractionAffector.h 2005-09-28 10:48:50.000000000 +0200 @@ -0,0 +1,39 @@ +// Copyright (C) 2002-2005 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_ATTRACTION_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector modifies particles. +class IParticleAttractionAffector : 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 point that particles will attract to + virtual void setPoint( core::vector3df point ) = 0; + + //! Get the point that particles are attracted to + virtual const core::vector3df& getPoint() const = 0; + +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ + diff -Nauwr Irrlicht/include/IParticleBoxEmitter.h Irrlicht/include/IParticleBoxEmitter.h --- Irrlicht/include/IParticleBoxEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleBoxEmitter.h 2005-09-27 15:34:28.000000000 +0200 @@ -0,0 +1,38 @@ +// Copyright (C) 2002-2005 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 Irrlicht/include/IParticleEmitter.h Irrlicht/include/IParticleEmitter.h --- Irrlicht/include/IParticleEmitter.h 2005-08-20 22:17:46.000000000 +0200 +++ Irrlicht/include/IParticleEmitter.h 2005-09-27 15:00:54.000000000 +0200 @@ -31,6 +31,36 @@ //! particles to add into the system. //! \return Returns amount of new particles in the array. Can be 0. virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) = 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 Irrlicht/include/IParticleFadeOutAffector.h Irrlicht/include/IParticleFadeOutAffector.h --- Irrlicht/include/IParticleFadeOutAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleFadeOutAffector.h 2005-09-28 10:19:42.000000000 +0200 @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2005 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 Irrlicht/include/IParticleGravityAffector.h Irrlicht/include/IParticleGravityAffector.h --- Irrlicht/include/IParticleGravityAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleGravityAffector.h 2005-09-28 10:21:24.000000000 +0200 @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2005 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 Irrlicht/include/IParticleMeshEmitter.h Irrlicht/include/IParticleMeshEmitter.h --- Irrlicht/include/IParticleMeshEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleMeshEmitter.h 2005-09-28 14:24:58.000000000 +0200 @@ -0,0 +1,58 @@ +// Copyright (C) 2002-2005 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_MESH_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_MESH_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ + +//! A particle emitter for using with particle systems. +/** A Particle emitter emitts new particles into a particle system. +*/ +class IParticleMeshEmitter : public IParticleEmitter +{ +public: + + //! destructor + virtual ~IParticleMeshEmitter() {}; + + //! Set Mesh to emit particles from + virtual void setMesh( IMesh* mesh ) = 0; + + //! Set whether to use vertex normal for direciton, or direction specified + virtual void setUseNormalDirection( bool useNormalDirection ) = 0; + + //! Set the amount that the normal is divided by for getting a particles direction + virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0; + + //! Sets whether to emit min<->max particles for every vertex per second, or to pick + //! min<->max vertices every second + virtual void setEveryMeshVertex( bool everyMeshVertex ) = 0; + + //! Get Mesh we're emitting particles from + virtual const IMesh* getMesh() const = 0; + + //! Get whether to use vertex normal for direciton, or direction specified + virtual const bool& isUsingNormalDirection() const = 0; + + //! Get the amount that the normal is divided by for getting a particles direction + virtual const f32& getNormalDirectionModifier() const = 0; + + //! Gets whether to emit min<->max particles for every vertex per second, or to pick + //! min<->max vertices every second + virtual const bool& getEveryMeshVertex() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Nauwr Irrlicht/include/IParticleRingEmitter.h Irrlicht/include/IParticleRingEmitter.h --- Irrlicht/include/IParticleRingEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleRingEmitter.h 2005-09-27 19:56:26.000000000 +0200 @@ -0,0 +1,49 @@ +// Copyright (C) 2002-2005 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_RING_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_RING_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" + +namespace irr +{ +namespace scene +{ + +//! A particle emitter for using with particle systems. +/** A Particle emitter emitts new particles into a particle system. +*/ +class IParticleRingEmitter : public IParticleEmitter +{ +public: + + //! destructor + virtual ~IParticleRingEmitter() {}; + + //! Set the center of the ring + virtual void setCenter( core::vector3df center ) = 0; + + //! Set the radius of the ring + virtual void setRadius( f32 radius ) = 0; + + //! Set the thickness of the ring + virtual void setRingThickness( f32 ringThickness ) = 0; + + //! Get the center of the ring + virtual const core::vector3df& getCenter() const = 0; + + //! Get the radius of the ring + virtual const f32& getRadius() const = 0; + + //! Get the thickness of the ring + virtual const f32& getRingThickness() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Nauwr Irrlicht/include/IParticleRotationAffector.h Irrlicht/include/IParticleRotationAffector.h --- Irrlicht/include/IParticleRotationAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleRotationAffector.h 2005-09-28 10:56:02.000000000 +0200 @@ -0,0 +1,56 @@ +// Copyright (C) 2002-2005 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_ROTATION_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector modifies particles. +class IParticleRotationAffector : 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 point that particles will attract to + virtual void setPivotPoint( core::vector3df point ) = 0; + + //! Set the speed in degrees per second, for rotation around the X axis + virtual void setSpeedX( f32 speed ) = 0; + + //! Set the speed in degrees per second, for rotation around the Y axis + virtual void setSpeedY( f32 speed ) = 0; + + //! Set the speed in degrees per second, for rotation around the Z axis + virtual void setSpeedZ( f32 speed ) = 0; + + //! Get the point that particles are attracted to + virtual const core::vector3df& getPivotPoint() const = 0; + + //! Get the speed in degrees per second, for rotation around the X axis + virtual const f32& getSpeedX() const = 0; + + //! Set the speed in degrees per second, for rotation around the Y axis + virtual const f32& getSpeedY() const = 0; + + //! Set the speed in degrees per second, for rotation around the Z axis + virtual const f32& getSpeedZ() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ + diff -Nauwr Irrlicht/include/IParticleSphereEmitter.h Irrlicht/include/IParticleSphereEmitter.h --- Irrlicht/include/IParticleSphereEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleSphereEmitter.h 2005-09-27 15:26:26.000000000 +0200 @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2005 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_SPHERE_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" + +namespace irr +{ +namespace scene +{ + +//! A particle emitter for using with particle systems. +/** A Particle emitter emitts new particles into a particle system. +*/ +class IParticleSphereEmitter : public IParticleEmitter +{ +public: + + //! destructor + virtual ~IParticleSphereEmitter() {}; + + //! Set the center of the sphere for particle emissions + virtual void setCenter( core::vector3df center ) = 0; + + //! Set the radius of the sphere for particle emissions + virtual void setRadius( f32 radius ) = 0; + + //! Get the center of the sphere for particle emissions + virtual const core::vector3df& getCenter() const = 0; + + //! Get the radius of the sphere for particle emissions + virtual const f32& getRadius() const = 0; + + + +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Nauwr Irrlicht/include/IParticleSystemSceneNode.h Irrlicht/include/IParticleSystemSceneNode.h --- Irrlicht/include/IParticleSystemSceneNode.h 2005-08-20 22:17:46.000000000 +0200 +++ Irrlicht/include/IParticleSystemSceneNode.h 2005-09-28 10:53:22.000000000 +0200 @@ -6,8 +6,17 @@ #define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ #include "ISceneNode.h" +#include "IMesh.h" #include "IParticleEmitter.h" +#include "IParticleMeshEmitter.h" +#include "IParticleSphereEmitter.h" +#include "IParticleBoxEmitter.h" +#include "IParticleRingEmitter.h" #include "IParticleAffector.h" +#include "IParticleFadeOutAffector.h" +#include "IParticleGravityAffector.h" +#include "IParticleAttractionAffector.h" +#include "IParticleRotationAffector.h" #include "dimension2d.h" namespace irr @@ -77,7 +86,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. @@ -101,7 +112,7 @@ virtual IParticleEmitter* createPointEmitter( core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), u32 minParticlesPerSecond = 5, - u32 maxParticlePerSecond = 10, + u32 maxParticlesPerSecond = 10, video::SColor minStartColor = video::SColor(255,0,0,0), video::SColor maxStartColor = video::SColor(255,255,255,255), u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, @@ -128,10 +139,125 @@ //! 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, + u32 maxParticlesPerSecond = 10, + 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) = 0; + + //! Creates a sphere particle emitter. + //! \param center: Center of sphere + //! \param radius: Radius of sphere + //! \param direction: Direction and speed of particle emission. + //! \param minParticlesPerSecond: Minimal amount of particles emitted + //! per second. + //! \param maxParticlesPerSecond: Maximal amount of particles emitted + //! per second. + //! \param minStartColor: Minimal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param maxStartColor: Maximal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param lifetimeMin: Minimal lifetime of a particle, in milliseconds. + //! \param lifetimeMax: Maximal lifetime of a particle, in milliseconds. + //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction + //! of the particle will differ from the orignial direction. + //! \return Returns a pointer to the created particle emitter. + //! To set this emitter as new emitter of this particle system, + //! 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 IParticleSphereEmitter* createSphereEmitter( + core::vector3df center, f32 radius, + core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, + 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) = 0; + + //! Creates a ring particle emitter. + //! \param center: Center of ring + //! \param radius: Distance of points from center, points will be rotated around the + //! Y axis at a random 360 degrees and will then be shifted by the provided ringThickness + //! values in each axis. + //! \param ringThickness : thickness of the ring or how wide the ring is + //! \param direction: Direction and speed of particle emission. + //! \param minParticlesPerSecond: Minimal amount of particles emitted + //! per second. + //! \param maxParticlesPerSecond: Maximal amount of particles emitted + //! per second. + //! \param minStartColor: Minimal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param maxStartColor: Maximal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param lifetimeMin: Minimal lifetime of a particle, in milliseconds. + //! \param lifetimeMax: Maximal lifetime of a particle, in milliseconds. + //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction + //! of the particle will differ from the orignial direction. + //! \return Returns a pointer to the created particle emitter. + //! To set this emitter as new emitter of this particle system, + //! 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 IParticleRingEmitter* createRingEmitter( + core::vector3df center, f32 radius, f32 ringThickness, + core::vector3df direction = core::vector3df(0.0f,0.03f,0.0f), + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, + 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) = 0; + + //! Creates a mesh particle emitter. + //! \param mesh: Pointer to mesh to emit particles from + //! \param useNormalDirection: If true, the direction of each particle created will + //! be the normal of the vertex that it's emitting from. The normal is divided by the + //! normalDirectionModifier parameter, which defaults to 100.0f. + //! \param direction: Direction and speed of particle emission. + //! \param normalDirectionModifier: If the emitter is using the normal direction + //! then the normal of the vertex that is being emitted from is divided by this number. + //! \param mbNumber: This allows you to specify a specific meshBuffer for the IMesh* + //! to emit particles from. The default value is -1, which means a random meshBuffer + //! picked from all of the meshes meshBuffers will be selected to pick a random vertex from. + //! If the value is 0 or greater, it will only pick random vertices from the meshBuffer + //! specified by this value. + //! \param everyMeshVertex: If true, the emitter will emit between min/max particles every second, + //! for every vertex in the mesh, if false, it will emit between min/max particles from random vertices + //! in the mesh. + //! \param minParticlesPerSecond: Minimal amount of particles emitted + //! per second. + //! \param maxParticlesPerSecond: Maximal amount of particles emitted + //! per second. + //! \param minStartColor: Minimal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param maxStartColor: Maximal initial start color of a particle. + //! The real color of every particle is calculated as random interpolation + //! between minStartColor and maxStartColor. + //! \param lifetimeMin: Minimal lifetime of a particle, in milliseconds. + //! \param lifetimeMax: Maximal lifetime of a particle, in milliseconds. + //! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction + //! of the particle will differ from the orignial direction. + //! \return Returns a pointer to the created particle emitter. + //! To set this emitter as new emitter of this particle system, + //! 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 IParticleMeshEmitter* createMeshEmitter( + scene::IMesh* mesh, bool useNormalDirection = true, + core::vector3df direction = core::vector3df(0.0f,0.0f,0.0f), + f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1, + bool everyMeshVertex = false, u32 minParticlesPerSecond = 5, u32 maxParticlePerSecond = 10, video::SColor minStartColor = video::SColor(255,0,0,0), video::SColor maxStartColor = video::SColor(255,255,255,255), @@ -152,7 +278,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,9 +296,40 @@ //! 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; + + //! 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. + //! \param point: Point to attract particles to. + //! \param speed: Speed in units per second, to attract to the specified point. + //! \param affectX: Whether or not this will affect the X position of the particle. + //! \param affectY: Whether or not this will affect the Y position of the particle. + //! \param affectZ: Whether or not this will affect the Z position of the particle. + //! \return Returns a pointer to the created particle affector. + //! To add this affector as new affector of this particle system, + //! 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 IParticleAttractionAffector* createAttractionAffector( + core::vector3df point, f32 speed, + bool affectX = true, bool affectY = true, bool affectZ = true) = 0; + + //! Creates a rotation affector. This affector modifies the positions of the + //! particles and attracts them to a specified point at a specified speed per second. + //! \param speedX: Rotation in degrees per second around the X axis + //! \param speedY: Rotation in degrees per second around the Y axis + //! \param speedZ: Rotation in degrees per second around the Z axis + //! \param pivotPoint: Point to rotate the particles around + //! \return Returns a pointer to the created particle affector. + //! To add this affector as new affector of this particle system, + //! 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 IParticleRotationAffector* createRotationAffector( + f32 speedX = 5.0f, f32 speedY = 5.0f, f32 speedZ = 5.0f, + core::vector3df pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) = 0; }; } // end namespace scene diff -Nauwr Irrlicht/include/irrlicht.h Irrlicht/include/irrlicht.h --- Irrlicht/include/irrlicht.h 2005-08-20 22:46:48.000000000 +0200 +++ Irrlicht/include/irrlicht.h 2005-09-28 10:14:26.000000000 +0200 @@ -89,7 +89,14 @@ #include "ITerrainSceneNode.h" #include "ITextSceneNode.h" #include "IParticleEmitter.h" +#include "IParticleMeshEmitter.h" +#include "IParticleSphereEmitter.h" +#include "IParticleBoxEmitter.h" +#include "IParticleRingEmitter.h" #include "IParticleAffector.h" +#include "IParticleFadeOutAffector.h" +#include "IParticleGravityAffector.h" +#include "IParticleAttractionAffector.h" #include "IBillboardSceneNode.h" #include "ITexture.h" #include "IUnknown.h"