Commit 2b1118e4 authored by hybrid's avatar hybrid

Particle scale patch from Dark Kilauea.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1743 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 99aedb34
...@@ -70,6 +70,12 @@ public: ...@@ -70,6 +70,12 @@ public:
//! Set maximum starting color for particles //! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) = 0; virtual void setMaxStartColor( const video::SColor& color ) = 0;
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) = 0;
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) = 0;
//! Get direction the emitter emits particles //! Get direction the emitter emits particles
virtual const core::vector3df& getDirection() const = 0; virtual const core::vector3df& getDirection() const = 0;
...@@ -85,6 +91,12 @@ public: ...@@ -85,6 +91,12 @@ public:
//! Get the maximum starting color for particles //! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const = 0; virtual const video::SColor& getMaxStartColor() const = 0;
//! Get the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const = 0;
//! Get the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const = 0;
//! Writes attributes of the object. //! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for //! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes. //! scripting languages, editors, debuggers or xml serialization purposes.
......
...@@ -128,6 +128,12 @@ public: ...@@ -128,6 +128,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -141,7 +147,9 @@ public: ...@@ -141,7 +147,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ) = 0; s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a box particle emitter. //! Creates a box particle emitter.
/** \param box: The box for the emitter. /** \param box: The box for the emitter.
...@@ -160,6 +168,12 @@ public: ...@@ -160,6 +168,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -172,7 +186,9 @@ public: ...@@ -172,7 +186,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0; s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a particle emitter for emitting from a cylinder //! Creates a particle emitter for emitting from a cylinder
/** \param center: The center of the circle at the base of the cylinder /** \param center: The center of the circle at the base of the cylinder
...@@ -196,6 +212,12 @@ public: ...@@ -196,6 +212,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -209,7 +231,9 @@ public: ...@@ -209,7 +231,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ) = 0; s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a mesh particle emitter. //! Creates a mesh particle emitter.
/** \param mesh: Pointer to mesh to emit particles from /** \param mesh: Pointer to mesh to emit particles from
...@@ -244,6 +268,12 @@ public: ...@@ -244,6 +268,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -257,7 +287,9 @@ public: ...@@ -257,7 +287,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ) = 0; s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a point particle emitter. //! Creates a point particle emitter.
/** \param direction: Direction and speed of particle emission. /** \param direction: Direction and speed of particle emission.
...@@ -275,6 +307,12 @@ public: ...@@ -275,6 +307,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -286,7 +324,9 @@ public: ...@@ -286,7 +324,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0; s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a ring particle emitter. //! Creates a ring particle emitter.
/** \param center: Center of ring /** \param center: Center of ring
...@@ -309,6 +349,12 @@ public: ...@@ -309,6 +349,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -321,7 +367,9 @@ public: ...@@ -321,7 +367,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0; s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a sphere particle emitter. //! Creates a sphere particle emitter.
/** \param center: Center of sphere /** \param center: Center of sphere
...@@ -341,6 +389,12 @@ public: ...@@ -341,6 +389,12 @@ public:
\param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
\param maxAngleDegrees: Maximal angle in degrees, the emitting \param maxAngleDegrees: Maximal angle in degrees, the emitting
direction of the particle will differ from the original direction. direction of the particle will differ from the original direction.
\param minStartSize: Minimal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\param maxStartSize: Maximal initial start size of a particle. The
real size of every particle is calculated as random interpolation
between minStartSize and maxStartSize.
\return Pointer to the created particle emitter. To set this emitter \return Pointer to the created particle emitter. To set this emitter
as new emitter of this particle system, just call setEmitter(). Note 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 that you'll have to drop() the returned pointer, after you don't need
...@@ -353,7 +407,9 @@ public: ...@@ -353,7 +407,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0; s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) ) = 0;
//! Creates a point attraction affector. //! Creates a point attraction affector.
/** This affector modifies the positions of the particles and attracts /** This affector modifies the positions of the particles and attracts
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define __S_PARTICLE_H_INCLUDED__ #define __S_PARTICLE_H_INCLUDED__
#include "vector3d.h" #include "vector3d.h"
#include "vector2d.h"
#include "SColor.h" #include "SColor.h"
namespace irr namespace irr
...@@ -37,6 +38,14 @@ namespace scene ...@@ -37,6 +38,14 @@ namespace scene
//! Original direction and speed of the particle. //! Original direction and speed of the particle.
/** The direction and speed the particle had when it was emitted. */ /** The direction and speed the particle had when it was emitted. */
core::vector3df startVector; core::vector3df startVector;
//! Scale of the particle.
/** The current scale of the particle. */
core::vector2df size;
//! Original scale of the particle.
/** The scale of the particle when it was emitted. */
core::vector2df startSize;
}; };
......
...@@ -19,30 +19,21 @@ CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter( ...@@ -19,30 +19,21 @@ CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter(
s32 mbNumber, bool everyMeshVertex, s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
: Node(node), TotalVertices(0), MBCount(0), MBNumber(mbNumber), const core::vector2df& minStartSize, const core::vector2df& maxStartSize )
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection), : Node(0), AnimatedMesh(0), BaseMesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
NormalDirectionModifier(normalDirectionModifier), Direction(direction), Direction(direction), NormalDirectionModifier(normalDirectionModifier),
MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond), MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) MaxStartSize(maxStartSize), MinStartSize(minStartSize),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees),
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CParticleAnimatedMeshSceneNodeEmitter"); setDebugName("CParticleAnimatedMeshSceneNodeEmitter");
#endif #endif
setAnimatedMeshSceneNode(node);
AnimatedMesh = node->getMesh();
BaseMesh = AnimatedMesh->getMesh(0);
TotalVertices = 0;
MBCount = BaseMesh->getMeshBufferCount();
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() );
TotalVertices += BaseMesh->getMeshBuffer(i)->getVertexCount();
}
} }
...@@ -52,9 +43,9 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -52,9 +43,9 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
{ {
Time += timeSinceLastCall; Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond; const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond) if(Time > everyWhatMillisecond)
{ {
...@@ -106,6 +97,13 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -106,6 +97,13 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
} }
...@@ -113,15 +111,10 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -113,15 +111,10 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
else else
{ {
s32 randomMB = 0; s32 randomMB = 0;
if( MBNumber < 0 ) if( MBNumber < 0 )
{
randomMB = os::Randomizer::rand() % MBCount; randomMB = os::Randomizer::rand() % MBCount;
}
else else
{
randomMB = MBNumber; randomMB = MBNumber;
}
u32 vertexNumber = frameMesh->getMeshBuffer(randomMB)->getVertexCount(); u32 vertexNumber = frameMesh->getMeshBuffer(randomMB)->getVertexCount();
if (!vertexNumber) if (!vertexNumber)
...@@ -157,6 +150,13 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -157,6 +150,13 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
} }
...@@ -169,6 +169,7 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, ...@@ -169,6 +169,7 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
return 0; return 0;
} }
//! Set Mesh to emit particles from //! Set Mesh to emit particles from
void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node )
{ {
...@@ -178,6 +179,7 @@ void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedM ...@@ -178,6 +179,7 @@ void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedM
TotalVertices = 0; TotalVertices = 0;
MBCount = BaseMesh->getMeshBufferCount(); MBCount = BaseMesh->getMeshBufferCount();
VertexPerMeshBufferList.reallocate(MBCount);
for( u32 i = 0; i < MBCount; ++i ) for( u32 i = 0; i < MBCount; ++i )
{ {
VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() ); VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() );
......
...@@ -32,7 +32,9 @@ public: ...@@ -32,7 +32,9 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMin = 2000,
u32 lifeTimeMax = 4000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f)
); );
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
...@@ -67,6 +69,12 @@ public: ...@@ -67,6 +69,12 @@ public:
//! Set maximum starting color for particles //! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Get Mesh we're emitting particles from //! Get Mesh we're emitting particles from
virtual const IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const { return Node; } virtual const IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const { return Node; }
...@@ -95,28 +103,36 @@ public: ...@@ -95,28 +103,36 @@ public:
//! Get the maximum starting color for particles //! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Get the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Get the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
private: private:
IAnimatedMeshSceneNode* Node; IAnimatedMeshSceneNode* Node;
IAnimatedMesh* AnimatedMesh; IAnimatedMesh* AnimatedMesh;
const IMesh* BaseMesh; const IMesh* BaseMesh;
s32 TotalVertices; s32 TotalVertices;
u32 MBCount; u32 MBCount;
s32 MBNumber; s32 MBNumber;
core::array<s32> VertexPerMeshBufferList; core::array<s32> VertexPerMeshBufferList;
bool EveryMeshVertex;
bool UseNormalDirection;
f32 NormalDirectionModifier;
core::array<SParticle> Particles; core::array<SParticle> Particles;
core::vector3df Direction; core::vector3df Direction;
f32 NormalDirectionModifier;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
core::vector2df MaxStartSize, MinStartSize;
u32 Time; u32 Time;
u32 Emitted; u32 Emitted;
s32 MaxAngleDegrees; s32 MaxAngleDegrees;
bool EveryMeshVertex;
bool UseNormalDirection;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -14,16 +14,18 @@ namespace scene ...@@ -14,16 +14,18 @@ namespace scene
//! constructor //! constructor
CParticleBoxEmitter::CParticleBoxEmitter( CParticleBoxEmitter::CParticleBoxEmitter(
const core::aabbox3df& box, const core::aabbox3df& box, const core::vector3df& direction,
const core::vector3df& direction, u32 minParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
u32 maxParticlesPerSecond, video::SColor minStartColor, video::SColor minStartColor, video::SColor maxStartColor,
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
s32 maxAngleDegrees) const core::vector2df& minStartSize, const core::vector2df& maxStartSize)
: Box(box), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), : Box(box), Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
MaxAngleDegrees(maxAngleDegrees) Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CParticleBoxEmitter"); setDebugName("CParticleBoxEmitter");
...@@ -31,16 +33,15 @@ CParticleBoxEmitter::CParticleBoxEmitter( ...@@ -31,16 +33,15 @@ CParticleBoxEmitter::CParticleBoxEmitter(
} }
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{ {
Time += timeSinceLastCall; Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond; const f32 everyWhatMillisecond = 1000.0f / perSecond;
if (Time > everyWhatMillisecond) if (Time > everyWhatMillisecond)
{ {
...@@ -82,6 +83,13 @@ s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outAr ...@@ -82,6 +83,13 @@ s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outAr
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
......
...@@ -29,7 +29,10 @@ public: ...@@ -29,7 +29,10 @@ public:
video::SColor maxStartColor = video::SColor(255,255,255,255), video::SColor maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMin=2000,
u32 lifeTimeMax=4000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f)
);
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
...@@ -50,6 +53,12 @@ public: ...@@ -50,6 +53,12 @@ public:
//! Set maximum start color. //! Set maximum start color.
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Set box from which the particles are emitted. //! Set box from which the particles are emitted.
virtual void setBox( const core::aabbox3df& box ) { Box = box; } virtual void setBox( const core::aabbox3df& box ) { Box = box; }
...@@ -68,6 +77,12 @@ public: ...@@ -68,6 +77,12 @@ public:
//! Gets maximum start color. //! Gets maximum start color.
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Gets the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Gets the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
//! Get box from which the particles are emitted. //! Get box from which the particles are emitted.
virtual const core::aabbox3df& getBox() const { return Box; } virtual const core::aabbox3df& getBox() const { return Box; }
...@@ -82,6 +97,7 @@ private: ...@@ -82,6 +97,7 @@ private:
core::array<SParticle> Particles; core::array<SParticle> Particles;
core::aabbox3df Box; core::aabbox3df Box;
core::vector3df Direction; core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
......
...@@ -17,15 +17,18 @@ CParticleCylinderEmitter::CParticleCylinderEmitter( ...@@ -17,15 +17,18 @@ CParticleCylinderEmitter::CParticleCylinderEmitter(
bool outlineOnly, const core::vector3df& direction, bool outlineOnly, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
: Center(center), Normal(normal), Radius(radius), Length(length), OutlineOnly( outlineOnly ), const core::vector2df& minStartSize,
Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), const core::vector2df& maxStartSize )
: Center(center), Normal(normal), Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
MaxAngleDegrees(maxAngleDegrees) Radius(radius), Length(length), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees), OutlineOnly(outlineOnly)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CParticleCylinderEmitter"); setDebugName("CParticleCylinderEmitter");
#endif #endif
...@@ -38,9 +41,9 @@ s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ...@@ -38,9 +41,9 @@ s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*&
{ {
Time += timeSinceLastCall; Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond; const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond) if(Time > everyWhatMillisecond)
{ {
...@@ -94,6 +97,13 @@ s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ...@@ -94,6 +97,13 @@ s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*&
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
......
...@@ -29,7 +29,10 @@ public: ...@@ -29,7 +29,10 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMin=2000,
u32 lifeTimeMax=4000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f)
);
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
...@@ -65,6 +68,12 @@ public: ...@@ -65,6 +68,12 @@ public:
//! Set direction the emitter emits particles //! Set direction the emitter emits particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Get the center of the cylinder //! Get the center of the cylinder
virtual const core::vector3df& getCenter() const { return Center; } virtual const core::vector3df& getCenter() const { return Center; }
...@@ -95,24 +104,32 @@ public: ...@@ -95,24 +104,32 @@ public:
//! Gets direction the emitter emits particles //! Gets direction the emitter emits particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Gets the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Gets the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
private: private:
core::array<SParticle> Particles; core::array<SParticle> Particles;
core::vector3df Center; core::vector3df Center;
core::vector3df Normal; core::vector3df Normal;
f32 Radius;
f32 Length;
bool OutlineOnly;
core::vector3df Direction; core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
f32 Radius;
f32 Length;
u32 Time; u32 Time;
u32 Emitted; u32 Emitted;
s32 MaxAngleDegrees; s32 MaxAngleDegrees;
bool OutlineOnly;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#include "CParticleMeshEmitter.h" #include "CParticleMeshEmitter.h"
#include "os.h" #include "os.h"
#include <math.h>
namespace irr namespace irr
{ {
...@@ -19,26 +18,22 @@ CParticleMeshEmitter::CParticleMeshEmitter( ...@@ -19,26 +18,22 @@ CParticleMeshEmitter::CParticleMeshEmitter(
s32 mbNumber, bool everyMeshVertex, s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
: Mesh(mesh), TotalVertices(0), MBCount(0), MBNumber(mbNumber), const core::vector2df& minStartSize,
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection), const core::vector2df& maxStartSize )
: Mesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
NormalDirectionModifier(normalDirectionModifier), Direction(direction), NormalDirectionModifier(normalDirectionModifier), Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond), MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees),
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CParticleMeshEmitter"); setDebugName("CParticleMeshEmitter");
#endif #endif
setMesh(mesh);
MBCount = Mesh->getMeshBufferCount();
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() );
TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount();
}
} }
...@@ -48,9 +43,9 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -48,9 +43,9 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
{ {
Time += timeSinceLastCall; Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond; const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond) if(Time > everyWhatMillisecond)
{ {
...@@ -99,6 +94,13 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -99,6 +94,13 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
} }
...@@ -150,6 +152,13 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -150,6 +152,13 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
} }
...@@ -162,13 +171,15 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -162,13 +171,15 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
return 0; return 0;
} }
//! Set Mesh to emit particles from //! Set Mesh to emit particles from
void CParticleMeshEmitter::setMesh( IMesh* mesh ) void CParticleMeshEmitter::setMesh(IMesh* mesh)
{ {
Mesh = mesh; Mesh = mesh;
TotalVertices = 0; TotalVertices = 0;
MBCount = Mesh->getMeshBufferCount(); MBCount = Mesh->getMeshBufferCount();
VertexPerMeshBufferList.reallocate(MBCount);
for( u32 i = 0; i < MBCount; ++i ) for( u32 i = 0; i < MBCount; ++i )
{ {
VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() ); VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() );
......
...@@ -33,7 +33,9 @@ public: ...@@ -33,7 +33,9 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMin = 2000,
u32 lifeTimeMax = 4000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f)
); );
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
...@@ -68,6 +70,12 @@ public: ...@@ -68,6 +70,12 @@ public:
//! Set maximum starting color for particles //! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Get Mesh we're emitting particles from //! Get Mesh we're emitting particles from
virtual const IMesh* getMesh() const { return Mesh; } virtual const IMesh* getMesh() const { return Mesh; }
...@@ -96,19 +104,24 @@ public: ...@@ -96,19 +104,24 @@ public:
//! Get the maximum starting color for particles //! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Gets the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Gets the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
private: private:
const IMesh* Mesh; const IMesh* Mesh;
core::array<s32> VertexPerMeshBufferList;
s32 TotalVertices; s32 TotalVertices;
u32 MBCount; u32 MBCount;
s32 MBNumber; s32 MBNumber;
core::array<s32> VertexPerMeshBufferList;
bool EveryMeshVertex;
bool UseNormalDirection;
f32 NormalDirectionModifier; f32 NormalDirectionModifier;
core::array<SParticle> Particles; core::array<SParticle> Particles;
core::vector3df Direction; core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
...@@ -116,6 +129,9 @@ private: ...@@ -116,6 +129,9 @@ private:
u32 Time; u32 Time;
u32 Emitted; u32 Emitted;
s32 MaxAngleDegrees; s32 MaxAngleDegrees;
bool EveryMeshVertex;
bool UseNormalDirection;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -16,8 +16,12 @@ CParticlePointEmitter::CParticlePointEmitter( ...@@ -16,8 +16,12 @@ CParticlePointEmitter::CParticlePointEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond, const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, video::SColor minStartColor, u32 maxParticlesPerSecond, video::SColor minStartColor,
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees) s32 maxAngleDegrees,
: Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), const core::vector2df& minStartSize,
const core::vector2df& maxStartSize)
: Direction(direction),
MinStartSize(minStartSize), MaxStartSize(maxStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
...@@ -29,16 +33,15 @@ CParticlePointEmitter::CParticlePointEmitter( ...@@ -29,16 +33,15 @@ CParticlePointEmitter::CParticlePointEmitter(
} }
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{ {
Time += timeSinceLastCall; Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond; const f32 everyWhatMillisecond = 1000.0f / perSecond;
if (Time > everyWhatMillisecond) if (Time > everyWhatMillisecond)
{ {
...@@ -65,6 +68,14 @@ s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& out ...@@ -65,6 +68,14 @@ s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& out
Particle.startColor = Particle.color; Particle.startColor = Particle.color;
Particle.startVector = Particle.vector; Particle.startVector = Particle.vector;
if (MinStartSize==MaxStartSize)
Particle.startSize = MinStartSize;
else
Particle.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
Particle.size = Particle.startSize;
outArray = &Particle; outArray = &Particle;
return 1; return 1;
} }
......
...@@ -27,7 +27,9 @@ public: ...@@ -27,7 +27,9 @@ public:
video::SColor maxStartColor = video::SColor(255,255,255,255), video::SColor maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMin=2000,
u32 lifeTimeMax=4000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
...@@ -48,6 +50,12 @@ public: ...@@ -48,6 +50,12 @@ public:
//! Set maximum start color. //! Set maximum start color.
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Gets direction the emitter emits particles. //! Gets direction the emitter emits particles.
virtual const core::vector3df& getDirection() const { return Direction; } virtual const core::vector3df& getDirection() const { return Direction; }
...@@ -63,6 +71,12 @@ public: ...@@ -63,6 +71,12 @@ public:
//! Gets maximum start color. //! Gets maximum start color.
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Gets the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Gets the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
//! Writes attributes of the object. //! Writes attributes of the object.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
...@@ -73,6 +87,7 @@ private: ...@@ -73,6 +87,7 @@ private:
SParticle Particle; SParticle Particle;
core::vector3df Direction; core::vector3df Direction;
core::vector2df MinStartSize, MaxStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
......
...@@ -16,11 +16,16 @@ CParticleRingEmitter::CParticleRingEmitter( ...@@ -16,11 +16,16 @@ CParticleRingEmitter::CParticleRingEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond, const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, const video::SColor& minStartColor, u32 maxParticlesPerSecond, const video::SColor& minStartColor,
const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees) s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
: Center(center), Radius(radius), RingThickness(ringThickness), : Center(center), Radius(radius), RingThickness(ringThickness),
Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), Direction(direction),
MaxParticlesPerSecond(maxParticlesPerSecond), MinStartColor(minStartColor), MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MaxStartColor(maxStartColor), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees) Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -83,6 +88,13 @@ s32 CParticleRingEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA ...@@ -83,6 +88,13 @@ s32 CParticleRingEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
......
...@@ -28,7 +28,10 @@ public: ...@@ -28,7 +28,10 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMin=2000,
u32 lifeTimeMax=4000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f)
);
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
...@@ -49,6 +52,12 @@ public: ...@@ -49,6 +52,12 @@ public:
//! Set maximum starting color for particles //! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Set the center of the ring //! Set the center of the ring
virtual void setCenter( const core::vector3df& center ) { Center = center; } virtual void setCenter( const core::vector3df& center ) { Center = center; }
...@@ -73,6 +82,12 @@ public: ...@@ -73,6 +82,12 @@ public:
//! Gets the maximum starting color for particles //! Gets the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Gets the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Gets the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
//! Get the center of the ring //! Get the center of the ring
virtual const core::vector3df& getCenter() const { return Center; } virtual const core::vector3df& getCenter() const { return Center; }
...@@ -91,6 +106,7 @@ private: ...@@ -91,6 +106,7 @@ private:
f32 RingThickness; f32 RingThickness;
core::vector3df Direction; core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
...@@ -98,9 +114,6 @@ private: ...@@ -98,9 +114,6 @@ private:
u32 Time; u32 Time;
u32 Emitted; u32 Emitted;
s32 MaxAngleDegrees; s32 MaxAngleDegrees;
f32 MinimumDistance;
f32 MaximumDistance;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#include "CParticleSphereEmitter.h" #include "CParticleSphereEmitter.h"
#include "os.h" #include "os.h"
#include <math.h>
namespace irr namespace irr
{ {
...@@ -18,14 +17,17 @@ CParticleSphereEmitter::CParticleSphereEmitter( ...@@ -18,14 +17,17 @@ CParticleSphereEmitter::CParticleSphereEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond, const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, const video::SColor& minStartColor, u32 maxParticlesPerSecond, const video::SColor& minStartColor,
const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees) s32 maxAngleDegrees,
: Center(center), Radius(radius), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond), const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
: Center(center), Radius(radius), Direction(direction),
MinStartSize(minStartSize), MaxStartSize(maxStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor), MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
MaxAngleDegrees(maxAngleDegrees) Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CParticleSphereEmitter"); setDebugName("CParticleSphereEmitter");
#endif #endif
...@@ -39,9 +41,9 @@ s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ou ...@@ -39,9 +41,9 @@ s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ou
{ {
Time += timeSinceLastCall; Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond; const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond; const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond) if(Time > everyWhatMillisecond)
{ {
...@@ -87,6 +89,13 @@ s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ou ...@@ -87,6 +89,13 @@ s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ou
p.startColor = p.color; p.startColor = p.color;
p.startVector = p.vector; p.startVector = p.vector;
if (MinStartSize==MaxStartSize)
p.startSize = MinStartSize;
else
p.startSize = MinStartSize.getInterpolated(
MaxStartSize, (os::Randomizer::rand() % 100) / 100.0f);
p.size = p.startSize;
Particles.push_back(p); Particles.push_back(p);
} }
......
...@@ -29,7 +29,9 @@ public: ...@@ -29,7 +29,9 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMin=2000,
u32 lifeTimeMax=4000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Prepares an array with new particles to emitt into the system //! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are. //! and returns how much new particles there are.
...@@ -50,6 +52,12 @@ public: ...@@ -50,6 +52,12 @@ public:
//! Set maximum start color //! Set maximum start color
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; } virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the maximum starting size for particles
virtual void setMaxStartSize( const core::vector2df& size ) { MaxStartSize = size; };
//! Set the minimum starting size for particles
virtual void setMinStartSize( const core::vector2df& size ) { MinStartSize = size; };
//! Set the center of the sphere for particle emissions //! Set the center of the sphere for particle emissions
virtual void setCenter( const core::vector3df& center ) { Center = center; } virtual void setCenter( const core::vector3df& center ) { Center = center; }
...@@ -71,6 +79,12 @@ public: ...@@ -71,6 +79,12 @@ public:
//! Get maximum start color //! Get maximum start color
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; } virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Gets the maximum starting size for particles
virtual const core::vector2df& getMaxStartSize() const { return MaxStartSize; };
//! Gets the minimum starting size for particles
virtual const core::vector2df& getMinStartSize() const { return MinStartSize; };
//! Get the center of the sphere for particle emissions //! Get the center of the sphere for particle emissions
virtual const core::vector3df& getCenter() const { return Center; } virtual const core::vector3df& getCenter() const { return Center; }
...@@ -83,8 +97,9 @@ private: ...@@ -83,8 +97,9 @@ private:
core::vector3df Center; core::vector3df Center;
f32 Radius; f32 Radius;
core::vector3df Direction; core::vector3df Direction;
core::vector2df MinStartSize, MaxStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond; u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor; video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime; u32 MinLifeTime, MaxLifeTime;
......
...@@ -125,14 +125,17 @@ CParticleSystemSceneNode::createAnimatedMeshSceneNodeEmitter( ...@@ -125,14 +125,17 @@ CParticleSystemSceneNode::createAnimatedMeshSceneNodeEmitter(
s32 mbNumber, bool everyMeshVertex, s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{ {
return new CParticleAnimatedMeshSceneNodeEmitter( node, return new CParticleAnimatedMeshSceneNodeEmitter( node,
useNormalDirection, direction, normalDirectionModifier, useNormalDirection, direction, normalDirectionModifier,
mbNumber, everyMeshVertex, mbNumber, everyMeshVertex,
minParticlesPerSecond, maxParticlesPerSecond, minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees ); lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -142,11 +145,13 @@ IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter( ...@@ -142,11 +145,13 @@ IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter(
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees) s32 maxAngleDegrees, const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{ {
return new CParticleBoxEmitter(box, direction, minParticlesPerSecond, return new CParticleBoxEmitter(box, direction, minParticlesPerSecond,
maxParticlesPerSecond, minStartColor, maxStartColor, maxParticlesPerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees); lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -157,13 +162,16 @@ IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter( ...@@ -157,13 +162,16 @@ IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter(
bool outlineOnly, const core::vector3df& direction, bool outlineOnly, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{ {
return new CParticleCylinderEmitter( center, radius, normal, length, return new CParticleCylinderEmitter( center, radius, normal, length,
outlineOnly, direction, outlineOnly, direction,
minParticlesPerSecond, maxParticlesPerSecond, minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees ); lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -174,13 +182,16 @@ IParticleMeshEmitter* CParticleSystemSceneNode::createMeshEmitter( ...@@ -174,13 +182,16 @@ IParticleMeshEmitter* CParticleSystemSceneNode::createMeshEmitter(
s32 mbNumber, bool everyMeshVertex, s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize)
{ {
return new CParticleMeshEmitter( mesh, useNormalDirection, direction, return new CParticleMeshEmitter( mesh, useNormalDirection, direction,
normalDirectionModifier, mbNumber, everyMeshVertex, normalDirectionModifier, mbNumber, everyMeshVertex,
minParticlesPerSecond, maxParticlesPerSecond, minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees ); lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -189,11 +200,13 @@ IParticlePointEmitter* CParticleSystemSceneNode::createPointEmitter( ...@@ -189,11 +200,13 @@ IParticlePointEmitter* CParticleSystemSceneNode::createPointEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond, const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, const video::SColor& minStartColor, u32 maxParticlesPerSecond, const video::SColor& minStartColor,
const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees) s32 maxAngleDegrees, const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{ {
return new CParticlePointEmitter(direction, minParticlesPerSecond, return new CParticlePointEmitter(direction, minParticlesPerSecond,
maxParticlesPerSecond, minStartColor, maxStartColor, maxParticlesPerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees); lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -203,11 +216,13 @@ IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter( ...@@ -203,11 +216,13 @@ IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter(
const core::vector3df& direction, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees ) u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize, const core::vector2df& maxStartSize )
{ {
return new CParticleRingEmitter( center, radius, ringThickness, direction, return new CParticleRingEmitter( center, radius, ringThickness, direction,
minParticlesPerSecond, maxParticlesPerSecond, minStartColor, minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees ); maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -217,12 +232,14 @@ IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter( ...@@ -217,12 +232,14 @@ IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter(
u32 minParticlesPerSecond, u32 maxParticlesPerSecond, u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor, const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees) s32 maxAngleDegrees, const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{ {
return new CParticleSphereEmitter(center, radius, direction, return new CParticleSphereEmitter(center, radius, direction,
minParticlesPerSecond, maxParticlesPerSecond, minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees); lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
} }
...@@ -289,28 +306,12 @@ void CParticleSystemSceneNode::render() ...@@ -289,28 +306,12 @@ void CParticleSystemSceneNode::render()
core::vector3df view(camera->getTarget() - camera->getAbsolutePosition()); core::vector3df view(camera->getTarget() - camera->getAbsolutePosition());
view.normalize(); view.normalize();
core::vector3df horizontal = camera->getUpVector().crossProduct(view);
horizontal.normalize();
horizontal *= 0.5f * ParticleSize.Width;
core::vector3df vertical = horizontal.crossProduct(view);
vertical.normalize();
vertical *= 0.5f * ParticleSize.Height;
view *= -1.0f; view *= -1.0f;
#else #else
const core::matrix4 &m = camera->getViewFrustum()->Matrices [ video::ETS_VIEW ]; const core::matrix4 &m = camera->getViewFrustum()->Matrices [ video::ETS_VIEW ];
f32 f;
f = 0.5f * ParticleSize.Width;
const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f );
f = -0.5f * ParticleSize.Height;
const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f );
const core::vector3df view ( -m[2], -m[6] , -m[10] ); const core::vector3df view ( -m[2], -m[6] , -m[10] );
#endif #endif
...@@ -324,6 +325,25 @@ void CParticleSystemSceneNode::render() ...@@ -324,6 +325,25 @@ void CParticleSystemSceneNode::render()
{ {
const SParticle& particle = Particles[i]; const SParticle& particle = Particles[i];
#if 0
core::vector3df horizontal = camera->getUpVector().crossProduct(view);
horizontal.normalize();
horizontal *= 0.5f * particle.size.X;
core::vector3df vertical = horizontal.crossProduct(view);
vertical.normalize();
vertical *= 0.5f * particle.size.Y;
#else
f32 f;
f = 0.5f * particle.size.X;
const core::vector3df horizontal ( m[0] * f, m[4] * f, m[8] * f );
f = -0.5f * particle.size.Y;
const core::vector3df vertical ( m[1] * f, m[5] * f, m[9] * f );
#endif
Buffer->Vertices[0+idx].Pos = particle.pos + horizontal + vertical; Buffer->Vertices[0+idx].Pos = particle.pos + horizontal + vertical;
Buffer->Vertices[0+idx].Color = particle.color; Buffer->Vertices[0+idx].Color = particle.color;
Buffer->Vertices[0+idx].Normal = view; Buffer->Vertices[0+idx].Normal = view;
...@@ -462,6 +482,10 @@ void CParticleSystemSceneNode::setParticlesAreGlobal(bool global) ...@@ -462,6 +482,10 @@ void CParticleSystemSceneNode::setParticlesAreGlobal(bool global)
//! Sets the size of all particles. //! Sets the size of all particles.
void CParticleSystemSceneNode::setParticleSize(const core::dimension2d<f32> &size) void CParticleSystemSceneNode::setParticleSize(const core::dimension2d<f32> &size)
{ {
//A bit of a hack, but better here than in the particle code
const core::vector2df tempsize(size.Width, size.Height);
Emitter->setMinStartSize(tempsize);
Emitter->setMaxStartSize(tempsize);
ParticleSize = size; ParticleSize = size;
} }
......
...@@ -70,7 +70,9 @@ public: ...@@ -70,7 +70,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ); s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a box particle emitter. //! Creates a box particle emitter.
virtual IParticleBoxEmitter* createBoxEmitter( virtual IParticleBoxEmitter* createBoxEmitter(
...@@ -81,7 +83,9 @@ public: ...@@ -81,7 +83,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a particle emitter for emitting from a cylinder //! Creates a particle emitter for emitting from a cylinder
virtual IParticleCylinderEmitter* createCylinderEmitter( virtual IParticleCylinderEmitter* createCylinderEmitter(
...@@ -92,7 +96,9 @@ public: ...@@ -92,7 +96,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ); s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a mesh particle emitter. //! Creates a mesh particle emitter.
virtual IParticleMeshEmitter* createMeshEmitter( virtual IParticleMeshEmitter* createMeshEmitter(
...@@ -105,7 +111,9 @@ public: ...@@ -105,7 +111,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
s32 maxAngleDegrees = 0 ); s32 maxAngleDegrees = 0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a point particle emitter. //! Creates a point particle emitter.
virtual IParticlePointEmitter* createPointEmitter( virtual IParticlePointEmitter* createPointEmitter(
...@@ -115,7 +123,9 @@ public: ...@@ -115,7 +123,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a ring particle emitter. //! Creates a ring particle emitter.
virtual IParticleRingEmitter* createRingEmitter( virtual IParticleRingEmitter* createRingEmitter(
...@@ -126,7 +136,9 @@ public: ...@@ -126,7 +136,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a sphere particle emitter. //! Creates a sphere particle emitter.
virtual IParticleSphereEmitter* createSphereEmitter( virtual IParticleSphereEmitter* createSphereEmitter(
...@@ -137,7 +149,9 @@ public: ...@@ -137,7 +149,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0), const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255), const video::SColor& maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); s32 maxAngleDegrees=0,
const core::vector2df& minStartSize = core::vector2df(5.0f,5.0f),
const core::vector2df& maxStartSize = core::vector2df(5.0f,5.0f) );
//! Creates a point attraction affector. This affector modifies the positions of the //! 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. //! particles and attracts them to a specified point at a specified speed per second.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment