diff -Nauwr source/Irrlicht/CParticleAttractionAffector.cpp source/Irrlicht/CParticleAttractionAffector.cpp --- source/Irrlicht/CParticleAttractionAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ source/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 + +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 source/Irrlicht/CParticleMeshEmitter.h source/Irrlicht/CParticleMeshEmitter.h --- source/Irrlicht/CParticleMeshEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ source/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 source/Irrlicht/CParticleRingEmitter.cpp source/Irrlicht/CParticleRingEmitter.cpp --- source/Irrlicht/CParticleRingEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ source/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 source/Irrlicht/CParticleRotationAffector.cpp source/Irrlicht/CParticleRotationAffector.cpp --- source/Irrlicht/CParticleRotationAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ source/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 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 @@ -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 { @@ -134,6 +137,42 @@ } +//! 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. @@ -151,6 +190,22 @@ return new CParticleGravityAffector(gravity, timeForceLost); } +//! Creates a particle 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() 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 @@ -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 IParticleFadeOutAffector* createFadeOutParticleAffector( video::SColor targetColor = video::SColor(0,0,0,0), u32 timeNeededToFadeOut = 1000); //! Creates a gravity affector. 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)); diff -Nauwr include/IParticleAttractionAffector.h include/IParticleAttractionAffector.h --- include/IParticleAttractionAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ 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 include/IParticleMeshEmitter.h include/IParticleMeshEmitter.h --- include/IParticleMeshEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ 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 include/IParticleRingEmitter.h include/IParticleRingEmitter.h --- include/IParticleRingEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ 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 include/IParticleRotationAffector.h include/IParticleRotationAffector.h --- include/IParticleRotationAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ 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 include/IParticleSphereEmitter.h include/IParticleSphereEmitter.h --- include/IParticleSphereEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ 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 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 @@ -8,10 +8,15 @@ #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 @@ -139,6 +150,121 @@ 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 maxParticlesPerSecond = 10, video::SColor minStartColor = video::SColor(255,0,0,0), video::SColor maxStartColor = video::SColor(255,255,255,255), @@ -180,6 +306,37 @@ 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 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,10 +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"