diff -Naurw Irrlicht/include/IParticleGlitterAffector.h Irrlicht/include/IParticleGlitterAffector.h --- Irrlicht/include/IParticleGlitterAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleGlitterAffector.h 2005-09-30 07:37:28.000000000 +0200 @@ -0,0 +1,59 @@ +// 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_MATERIAL_GLITTER_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_MATERIAL_GLITTER_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" +#include "SColor.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector modifies particles. +class IParticleGlitterAffector : 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 minimum specular color + virtual void setMinSpecularColor( video::SColor minSpecularColor ) = 0; + //! Set the maximum specular color + virtual void setMaxSpecularColor( video::SColor maxSpecularColor ) = 0; + //! Set the minimum ambient color + virtual void setMinAmbientColor( video::SColor minAmbientColor ) = 0; + //! Set the maximum ambient color + virtual void setMaxAmbientColor( video::SColor maxAmbientColor ) = 0; + //! Set the minimum diffuse color + virtual void setMinDiffuseColor( video::SColor minDiffuseColor ) = 0; + //! Set the maximum diffuse color + virtual void setMaxDiffuseColor( video::SColor maxDiffuseColor ) = 0; + + //! Get the minimum specular color + virtual const video::SColor& getMinSpecularColor() = 0; + //! Get the maximum specular color + virtual const video::SColor& getMaxSpecularColor() = 0; + //! Get the minimum ambient color + virtual const video::SColor& getMinAmbientColor() = 0; + //! Get the maximum ambient color + virtual const video::SColor& getMaxAmbientColor() = 0; + //! Get the minimum diffuse color + virtual const video::SColor& getMinDiffuseColor() = 0; + //! Get the maximum diffuse color + virtual const video::SColor& getMaxDiffuseColor() = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_MATERIAL_GLITTER_AFFECTOR_H_INCLUDED__ + diff -Naurw Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp --- Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp 2005-11-21 08:11:32.000000000 +0100 @@ -0,0 +1,181 @@ +// 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 "CParticleAnimatedMeshSceneNodeEmitter.h" +#include "os.h" +#include + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter( + IAnimatedMeshSceneNode* node, 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 ) + : Node(node), 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) +{ + AnimatedMesh = node->getAnimatedMesh(); + BaseMesh = AnimatedMesh->getMesh(0); + + TotalVertices = 0; + MBCount = BaseMesh->getMeshBufferCount(); + for( s32 i = 0; i < MBCount; ++i ) + { + VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() ); + TotalVertices += BaseMesh->getMeshBuffer(i)->getVertexCount(); + } +} + + +//! Prepares an array with new particles to emitt into the system +//! and returns how much new particles there are. +s32 CParticleAnimatedMeshSceneNodeEmitter::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; + + // Get Mesh for this frame + IMesh* frameMesh = AnimatedMesh->getMesh( Node->getFrameNr(), 255, Node->getStartFrame(), Node->getEndFrame() ); + for (s32 i=0; igetMeshBufferCount(); ++j ) + { + for( s32 k=0; kgetMeshBuffer(j)->getVertexCount(); ++k ) + { + switch( frameMesh->getMeshBuffer(j)->getVertexType() ) + { + case video::EVT_STANDARD: + p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_TANGENTS: + p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + } + + p.startTime = now; + + if( MaxAngleDegrees ) + { + core::vector3df tgt = p.vector; + 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() % frameMesh->getMeshBuffer(randomMB)->getVertexCount(); + + switch( frameMesh->getMeshBuffer(randomMB)->getVertexType() ) + { + case video::EVT_STANDARD: + p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_TANGENTS: + p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertexTangents*)frameMesh->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 -Naurw Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h --- Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h 2005-11-21 08:11:22.000000000 +0100 @@ -0,0 +1,141 @@ +// 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_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ +#define __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ + +#include "IParticleAnimatedMeshSceneNodeEmitter.h" +#include "irrArray.h" +#include "aabbox3d.h" + +namespace irr +{ +namespace scene +{ + +//! A default box emitter +class CParticleAnimatedMeshSceneNodeEmitter : public IParticleAnimatedMeshSceneNodeEmitter +{ +public: + + //! constructor + CParticleAnimatedMeshSceneNodeEmitter( + IAnimatedMeshSceneNode* node, + 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 setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) + { + Node = node; + AnimatedMesh = node->getAnimatedMesh(); + BaseMesh = AnimatedMesh->getMesh(0); + + TotalVertices = 0; + MBCount = BaseMesh->getMeshBufferCount(); + for( s32 i = 0; i < MBCount; ++i ) + { + VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() ); + TotalVertices += BaseMesh->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 IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const { return Node; } + + //! 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: + + IAnimatedMeshSceneNode* Node; + IAnimatedMesh* AnimatedMesh; + IMesh* BaseMesh; + 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_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ + diff -Naurw Irrlicht/CParticleCylinderEmitter.cpp Irrlicht/CParticleCylinderEmitter.cpp --- Irrlicht/CParticleCylinderEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleCylinderEmitter.cpp 2005-09-29 09:47:06.000000000 +0200 @@ -0,0 +1,110 @@ +// 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 "CParticleCylinderEmitter.h" +#include "os.h" +#include + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleCylinderEmitter::CParticleCylinderEmitter( + core::vector3df center, f32 radius, core::vector3df normal, f32 length, + bool outlineOnly, core::vector3df direction, u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, video::SColor minStartColor, + video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) +: Center(center), Normal(normal), Radius(radius), Length(length), OutlineOnly( outlineOnly ), + 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 CParticleCylinderEmitter::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; + core::vector3df Normal; + f32 Radius; + f32 Length; + bool OutlineOnly; + + 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 -Naurw Irrlicht/CParticleGlitterAffector.cpp Irrlicht/CParticleGlitterAffector.cpp --- Irrlicht/CParticleGlitterAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CParticleGlitterAffector.cpp 2005-09-30 07:33:50.000000000 +0200 @@ -0,0 +1,45 @@ +// 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 "CParticleGlitterAffector.h" +#include "matrix4.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleGlitterAffector::CParticleGlitterAffector( video::SColor minSpecularColor, + video::SColor maxSpecularColor, video::SColor minAmbientColor, video::SColor maxAmbientColor, + video::SColor minDiffuseColor, video::SColor maxDiffuseColor ) +{ +} + + +//! Affects an array of particles. +void CParticleGlitterAffector::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, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, video::SColor minStartColor, video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees) { return new CParticleBoxEmitter(box, direction, minParticlesPerSecond, - maxParticlePerSecond, minStartColor, maxStartColor, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees); } @@ -140,13 +142,13 @@ //! Creates a sphere particle emitter. IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter( core::vector3df center, f32 radius, core::vector3df direction, - u32 minParticlesPerSecond, u32 maxParticlePerSecond, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, video::SColor minStartColor, video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees) { return new CParticleSphereEmitter(center, radius, direction, minParticlesPerSecond, - maxParticlePerSecond, minStartColor, maxStartColor, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees); } @@ -154,12 +156,12 @@ IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter( core::vector3df center, f32 radius, f32 ringThickness, core::vector3df direction, - u32 minParticlesPerSecond, u32 maxParticlePerSecond, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, video::SColor minStartColor, video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) { return new CParticleRingEmitter( center, radius, ringThickness, direction, - minParticlesPerSecond, maxParticlePerSecond, minStartColor, + minParticlesPerSecond, maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees ); } @@ -174,6 +176,31 @@ lifeTimeMin, lifeTimeMax, maxAngleDegrees ); } +//! Creates a particle emitter for an animated mesh scene node +IParticleAnimatedMeshSceneNodeEmitter* CParticleSystemSceneNode::createAnimatedMeshSceneNodeEmitter( + scene::IAnimatedMeshSceneNode* node, 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 CParticleAnimatedMeshSceneNodeEmitter( node, useNormalDirection, + direction, normalDirectionModifier, mbNumber, everyMeshVertex, minParticlesPerSecond, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, + maxAngleDegrees ); +} + +//! Creates a particle emitter for emitting from a cylinder +IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter( + core::vector3df center, f32 radius, core::vector3df normal, f32 length, + bool outlineOnly, core::vector3df direction, u32 minParticlesPerSecond, u32 maxParticlesPerSecond, + video::SColor minStartColor, video::SColor maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) +{ + return new CParticleCylinderEmitter( center, radius, normal, length, outlineOnly, direction, + minParticlesPerSecond, maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, + lifeTimeMax, maxAngleDegrees ); +} //! Creates a fade out particle affector. IParticleFadeOutAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( @@ -300,7 +328,7 @@ video::SMaterial m; m.Lighting = false; driver->setMaterial(m); - driver->draw3DBox(Box, video::SColor(0,255,255,255)); + driver->draw3DBox(Box, video::SColor(0,255,0,255)); } } diff -Naurw Irrlicht/CParticleSystemSceneNode.h Irrlicht/CParticleSystemSceneNode.h --- Irrlicht/CParticleSystemSceneNode.h 2005-09-28 12:10:08.000000000 +0200 +++ Irrlicht/CParticleSystemSceneNode.h 2005-11-21 08:43:22.000000000 +0100 @@ -61,7 +61,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, @@ -72,7 +72,7 @@ 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 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, @@ -83,7 +83,7 @@ core::vector3df center, f32 radius, 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, @@ -94,7 +94,7 @@ core::vector3df center, f32 radius, f32 ringThickness, 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, @@ -106,7 +106,29 @@ 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, + 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 ); + + //! Creates a particle emitter for an animated mesh scene node + virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter( + scene::IAnimatedMeshSceneNode* node, 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), + u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, + s32 maxAngleDegrees = 0 ); + + //! Creates a particle emitter for emitting from a cylinder + virtual IParticleCylinderEmitter* createCylinderEmitter( + core::vector3df center, f32 radius, core::vector3df normal, f32 length, + bool outlineOnly = false, core::vector3df direction = core::vector3df(0.0f,0.0f,0.0f), + u32 minParticlesPerSecond = 5, u32 maxParticlesPersSecond = 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, diff -Naurw Irrlicht/CParticleMeshEmitter.cpp Irrlicht/CParticleMeshEmitter.cpp --- Irrlicht/CParticleMeshEmitter.cpp 2005-09-28 15:17:28.000000000 +0200 +++ Irrlicht/CParticleMeshEmitter.cpp 2005-10-31 10:36:28.000000000 +0100 @@ -86,14 +79,14 @@ 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( MaxAngleDegrees ) + { + core::vector3df tgt = p.vector; + 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; @@ -152,14 +138,14 @@ 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( 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; diff -Naurw Irrlicht/CParticleSphereEmitter.cpp Irrlicht/CParticleSphereEmitter.cpp --- Irrlicht/CParticleSphereEmitter.cpp 2005-09-28 13:33:00.000000000 +0200 +++ Irrlicht/CParticleSphereEmitter.cpp 2005-10-03 18:10:08.000000000 +0200 @@ -63,14 +63,14 @@ p.startTime = now; p.vector = Direction; - //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 (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; diff -Naurw Irrlicht/include/IParticleAnimatedMeshSceneNodeEmitter.h Irrlicht/include/IParticleAnimatedMeshSceneNodeEmitter.h --- Irrlicht/include/IParticleAnimatedMeshSceneNodeEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleAnimatedMeshSceneNodeEmitter.h 2005-09-29 07:39:28.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_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ + +#include "IParticleEmitter.h" +#include "IAnimatedMeshSceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! A particle emitter for using with particle systems. +/** A Particle emitter emitts new particles into a particle system. +*/ +class IParticleAnimatedMeshSceneNodeEmitter : public IParticleEmitter +{ +public: + + //! destructor + virtual ~IParticleAnimatedMeshSceneNodeEmitter() {}; + + //! Set Mesh to emit particles from + virtual void setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) = 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 IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() 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 // __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ + diff -Naurw Irrlicht/include/IParticleCylinderEmitter.h Irrlicht/include/IParticleCylinderEmitter.h --- Irrlicht/include/IParticleCylinderEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/include/IParticleCylinderEmitter.h 2005-09-29 09:41:24.000000000 +0200 @@ -0,0 +1,61 @@ +// 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_CYLINDER_EMITTER_H_INCLUDED__ +#define __I_PARTICLE_CYLINDER_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 IParticleCylinderEmitter : public IParticleEmitter +{ +public: + + //! destructor + virtual ~IParticleCylinderEmitter() {}; + + //! Set the center of the radius for the cylinder, at one end of the cylinder + virtual void setCenter( core::vector3df center ) = 0; + + //! Set the normal of the cylinder + virtual void setNormal( core::vector3df normal ) = 0; + + //! Set the radius of the cylinder + virtual void setRadius( f32 radius ) = 0; + + //! Set the length of the cylinder + virtual void setLength( f32 length ) = 0; + + //! Set whether or not to draw points inside the cylinder + virtual void setOutlineOnly( bool outlineOnly ) = 0; + + //! Get the center of the cylinder + virtual const core::vector3df& getCenter() const = 0; + + //! Get the normal of the cylinder + virtual const core::vector3df& getNormal() const = 0; + + //! Get the radius of the cylinder + virtual const f32& getRadius() const = 0; + + //! Get the center of the cylinder + virtual const f32& getLength() const = 0; + + //! Get whether or not to draw points inside the cylinder + virtual const bool& getOutlineOnly() const = 0; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -Naurw Irrlicht/include/IParticleSystemSceneNode.h Irrlicht/include/IParticleSystemSceneNode.h --- Irrlicht/include/IParticleSystemSceneNode.h 2005-09-28 10:53:22.000000000 +0200 +++ Irrlicht/include/IParticleSystemSceneNode.h 2005-09-30 16:41:14.000000000 +0200 @@ -9,14 +9,17 @@ #include "IMesh.h" #include "IParticleEmitter.h" #include "IParticleMeshEmitter.h" +#include "IParticleAnimatedMeshSceneNodeEmitter.h" #include "IParticleSphereEmitter.h" #include "IParticleBoxEmitter.h" #include "IParticleRingEmitter.h" +#include "IParticleCylinderEmitter.h" #include "IParticleAffector.h" #include "IParticleFadeOutAffector.h" #include "IParticleGravityAffector.h" #include "IParticleAttractionAffector.h" #include "IParticleRotationAffector.h" +#include "IParticleGlitterAffector.h" #include "dimension2d.h" namespace irr @@ -258,7 +261,88 @@ 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, + 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 particle emitter for an animated mesh scene node + //! \param node: Pointer to the animated mesh scene node 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 + //! IrrUnknown::drop() for more informations. + virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter( + scene::IAnimatedMeshSceneNode* node, 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 maxParticlesPersSecond = 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 particle emitter for emitting from a cylinder + //! \param center: The center of the circle at the base of the cylinder + //! \param radius: The thickness of the cylinder + //! \param normal: Direction of the length of the cylinder + //! \param length: The length of the the cylinder + //! \param outlineOnly: Whether or not to put points inside the cylinder or on the outline only + //! \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 + //! IrrUnknown::drop() for more informations. + virtual IParticleCylinderEmitter* createCylinderEmitter( + core::vector3df center, f32 radius, core::vector3df normal, f32 length, + bool outlineOnly = false, core::vector3df direction = core::vector3df(0.0f,0.0f,0.0f), + u32 minParticlesPerSecond = 5, u32 maxParticlesPersSecond = 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, diff -Naurw Irrlicht/include/irrlicht.h Irrlicht/include/irrlicht.h --- Irrlicht/include/irrlicht.h 2005-09-28 10:14:26.000000000 +0200 +++ Irrlicht/include/irrlicht.h 2005-11-12 09:01:42.000000000 +0100 @@ -97,9 +97,11 @@ #include "ITextSceneNode.h" #include "IParticleEmitter.h" #include "IParticleMeshEmitter.h" +#include "IParticleAnimatedMeshSceneNodeEmitter.h" #include "IParticleSphereEmitter.h" #include "IParticleBoxEmitter.h" #include "IParticleRingEmitter.h" +#include "IParticleCylinderEmitter.h" #include "IParticleAffector.h" #include "IParticleFadeOutAffector.h" #include "IParticleGravityAffector.h"