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:
//! Set maximum starting color for particles
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
virtual const core::vector3df& getDirection() const = 0;
......@@ -85,6 +91,12 @@ public:
//! Get the maximum starting color for particles
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.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
......
......@@ -128,6 +128,12 @@ public:
\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 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
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
......@@ -141,7 +147,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
/** \param box: The box for the emitter.
......@@ -160,6 +168,12 @@ public:
\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 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
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
......@@ -172,7 +186,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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
/** \param center: The center of the circle at the base of the cylinder
......@@ -196,6 +212,12 @@ public:
\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 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
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
......@@ -209,7 +231,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
/** \param mesh: Pointer to mesh to emit particles from
......@@ -244,6 +268,12 @@ public:
\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 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
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
......@@ -257,7 +287,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
/** \param direction: Direction and speed of particle emission.
......@@ -275,6 +307,12 @@ public:
\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 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
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
......@@ -286,7 +324,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
/** \param center: Center of ring
......@@ -309,6 +349,12 @@ public:
\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 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
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
......@@ -321,7 +367,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
/** \param center: Center of sphere
......@@ -341,6 +389,12 @@ public:
\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 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
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
......@@ -353,7 +407,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
/** This affector modifies the positions of the particles and attracts
......
......@@ -6,6 +6,7 @@
#define __S_PARTICLE_H_INCLUDED__
#include "vector3d.h"
#include "vector2d.h"
#include "SColor.h"
namespace irr
......@@ -37,6 +38,14 @@ namespace scene
//! Original direction and speed of the particle.
/** The direction and speed the particle had when it was emitted. */
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(
s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees )
: Node(node), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection),
NormalDirectionModifier(normalDirectionModifier), Direction(direction),
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize, const core::vector2df& maxStartSize )
: Node(0), AnimatedMesh(0), BaseMesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
Direction(direction), NormalDirectionModifier(normalDirectionModifier),
MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
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
setDebugName("CParticleAnimatedMeshSceneNodeEmitter");
#endif
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();
}
setAnimatedMeshSceneNode(node);
}
......@@ -52,9 +43,9 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
......@@ -106,6 +97,13 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
p.startColor = p.color;
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);
}
}
......@@ -113,15 +111,10 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
else
{
s32 randomMB = 0;
if( MBNumber < 0 )
{
randomMB = os::Randomizer::rand() % MBCount;
}
else
{
randomMB = MBNumber;
}
u32 vertexNumber = frameMesh->getMeshBuffer(randomMB)->getVertexCount();
if (!vertexNumber)
......@@ -157,6 +150,13 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
p.startColor = p.color;
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);
}
}
......@@ -169,6 +169,7 @@ s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall,
return 0;
}
//! Set Mesh to emit particles from
void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node )
{
......@@ -178,6 +179,7 @@ void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedM
TotalVertices = 0;
MBCount = BaseMesh->getMeshBufferCount();
VertexPerMeshBufferList.reallocate(MBCount);
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() );
......
......@@ -32,7 +32,9 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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)
);
//! Prepares an array with new particles to emitt into the system
......@@ -67,6 +69,12 @@ public:
//! Set maximum starting color for particles
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
virtual const IAnimatedMeshSceneNode* getAnimatedMeshSceneNode() const { return Node; }
......@@ -95,28 +103,36 @@ public:
//! Get the maximum starting color for particles
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:
IAnimatedMeshSceneNode* Node;
IAnimatedMesh* AnimatedMesh;
const IMesh* BaseMesh;
const IMesh* BaseMesh;
s32 TotalVertices;
u32 MBCount;
s32 MBNumber;
core::array<s32> VertexPerMeshBufferList;
bool EveryMeshVertex;
bool UseNormalDirection;
f32 NormalDirectionModifier;
core::array<SParticle> Particles;
core::vector3df Direction;
f32 NormalDirectionModifier;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
core::vector2df MaxStartSize, MinStartSize;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
bool EveryMeshVertex;
bool UseNormalDirection;
};
} // end namespace scene
......
......@@ -14,16 +14,18 @@ namespace scene
//! constructor
CParticleBoxEmitter::CParticleBoxEmitter(
const core::aabbox3df& box,
const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, video::SColor minStartColor,
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
: Box(box), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
const core::aabbox3df& box, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
video::SColor minStartColor, video::SColor maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize, const core::vector2df& maxStartSize)
: Box(box), Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees)
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{
#ifdef _DEBUG
setDebugName("CParticleBoxEmitter");
......@@ -31,16 +33,15 @@ CParticleBoxEmitter::CParticleBoxEmitter(
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticleBoxEmitter::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;
const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
const f32 everyWhatMillisecond = 1000.0f / perSecond;
if (Time > everyWhatMillisecond)
{
......@@ -82,6 +83,13 @@ s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outAr
p.startColor = p.color;
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);
}
......
......@@ -29,7 +29,10 @@ public:
video::SColor maxStartColor = video::SColor(255,255,255,255),
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)
);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
......@@ -50,6 +53,12 @@ public:
//! Set maximum start 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.
virtual void setBox( const core::aabbox3df& box ) { Box = box; }
......@@ -68,6 +77,12 @@ public:
//! Gets maximum start color.
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.
virtual const core::aabbox3df& getBox() const { return Box; }
......@@ -82,6 +97,7 @@ private:
core::array<SParticle> Particles;
core::aabbox3df Box;
core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
......
......@@ -17,15 +17,18 @@ CParticleCylinderEmitter::CParticleCylinderEmitter(
bool outlineOnly, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees)
: Center(center), Normal(normal), Radius(radius), Length(length), OutlineOnly( outlineOnly ),
Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
: Center(center), Normal(normal), Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees)
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Radius(radius), Length(length), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees), OutlineOnly(outlineOnly)
{
#ifdef _DEBUG
setDebugName("CParticleCylinderEmitter");
#endif
......@@ -38,9 +41,9 @@ s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*&
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
......@@ -94,6 +97,13 @@ s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*&
p.startColor = p.color;
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);
}
......
......@@ -29,7 +29,10 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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)
);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
......@@ -65,6 +68,12 @@ public:
//! Set direction the emitter emits particles
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
virtual const core::vector3df& getCenter() const { return Center; }
......@@ -95,24 +104,32 @@ public:
//! Gets direction the emitter emits particles
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:
core::array<SParticle> Particles;
core::vector3df Center;
core::vector3df Normal;
f32 Radius;
f32 Length;
bool OutlineOnly;
core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
f32 Radius;
f32 Length;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
bool OutlineOnly;
};
} // end namespace scene
......
......@@ -5,7 +5,6 @@
#include "IrrCompileConfig.h"
#include "CParticleMeshEmitter.h"
#include "os.h"
#include <math.h>
namespace irr
{
......@@ -19,26 +18,22 @@ CParticleMeshEmitter::CParticleMeshEmitter(
s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees )
: Mesh(mesh), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection),
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
: Mesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
NormalDirectionModifier(normalDirectionModifier), Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees),
EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection)
{
#ifdef _DEBUG
setDebugName("CParticleMeshEmitter");
#endif
MBCount = Mesh->getMeshBufferCount();
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() );
TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount();
}
setMesh(mesh);
}
......@@ -48,9 +43,9 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
......@@ -99,6 +94,13 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
p.startColor = p.color;
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);
}
}
......@@ -150,6 +152,13 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
p.startColor = p.color;
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);
}
}
......@@ -162,13 +171,15 @@ s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
return 0;
}
//! Set Mesh to emit particles from
void CParticleMeshEmitter::setMesh( IMesh* mesh )
void CParticleMeshEmitter::setMesh(IMesh* mesh)
{
Mesh = mesh;
TotalVertices = 0;
MBCount = Mesh->getMeshBufferCount();
VertexPerMeshBufferList.reallocate(MBCount);
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() );
......
......@@ -33,7 +33,9 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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)
);
//! Prepares an array with new particles to emitt into the system
......@@ -68,6 +70,12 @@ public:
//! Set maximum starting color for particles
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
virtual const IMesh* getMesh() const { return Mesh; }
......@@ -96,19 +104,24 @@ public:
//! Get the maximum starting color for particles
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:
const IMesh* Mesh;
core::array<s32> VertexPerMeshBufferList;
s32 TotalVertices;
u32 MBCount;
s32 MBNumber;
core::array<s32> VertexPerMeshBufferList;
bool EveryMeshVertex;
bool UseNormalDirection;
f32 NormalDirectionModifier;
core::array<SParticle> Particles;
core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
......@@ -116,6 +129,9 @@ private:
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
bool EveryMeshVertex;
bool UseNormalDirection;
};
} // end namespace scene
......
......@@ -16,8 +16,12 @@ CParticlePointEmitter::CParticlePointEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, video::SColor minStartColor,
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
: Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize)
: Direction(direction),
MinStartSize(minStartSize), MaxStartSize(maxStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
......@@ -29,16 +33,15 @@ CParticlePointEmitter::CParticlePointEmitter(
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticlePointEmitter::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;
const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
const f32 everyWhatMillisecond = 1000.0f / perSecond;
if (Time > everyWhatMillisecond)
{
......@@ -65,6 +68,14 @@ s32 CParticlePointEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& out
Particle.startColor = Particle.color;
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;
return 1;
}
......
......@@ -27,7 +27,9 @@ public:
video::SColor maxStartColor = video::SColor(255,255,255,255),
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) );
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
......@@ -48,6 +50,12 @@ public:
//! Set maximum start 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.
virtual const core::vector3df& getDirection() const { return Direction; }
......@@ -63,6 +71,12 @@ public:
//! Gets maximum start color.
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.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
......@@ -73,6 +87,7 @@ private:
SParticle Particle;
core::vector3df Direction;
core::vector2df MinStartSize, MaxStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
......
......@@ -16,11 +16,16 @@ CParticleRingEmitter::CParticleRingEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, const video::SColor& minStartColor,
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),
Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond), MinStartColor(minStartColor),
MaxStartColor(maxStartColor), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Direction(direction),
MaxStartSize(maxStartSize), MinStartSize(minStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{
#ifdef _DEBUG
......@@ -83,6 +88,13 @@ s32 CParticleRingEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outA
p.startColor = p.color;
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);
}
......
......@@ -28,7 +28,10 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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)
);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
......@@ -49,6 +52,12 @@ public:
//! Set maximum starting color for particles
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
virtual void setCenter( const core::vector3df& center ) { Center = center; }
......@@ -73,6 +82,12 @@ public:
//! Gets the maximum starting color for particles
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
virtual const core::vector3df& getCenter() const { return Center; }
......@@ -91,6 +106,7 @@ private:
f32 RingThickness;
core::vector3df Direction;
core::vector2df MaxStartSize, MinStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
......@@ -98,9 +114,6 @@ private:
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
f32 MinimumDistance;
f32 MaximumDistance;
};
} // end namespace scene
......
......@@ -5,7 +5,6 @@
#include "IrrCompileConfig.h"
#include "CParticleSphereEmitter.h"
#include "os.h"
#include <math.h>
namespace irr
{
......@@ -18,14 +17,17 @@ CParticleSphereEmitter::CParticleSphereEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, const video::SColor& minStartColor,
const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
: Center(center), Radius(radius), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
s32 maxAngleDegrees,
const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
: Center(center), Radius(radius), Direction(direction),
MinStartSize(minStartSize), MaxStartSize(maxStartSize),
MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees)
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{
#ifdef _DEBUG
setDebugName("CParticleSphereEmitter");
#endif
......@@ -39,9 +41,9 @@ s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ou
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
const f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
const f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
......@@ -87,6 +89,13 @@ s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& ou
p.startColor = p.color;
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);
}
......
......@@ -29,7 +29,9 @@ public:
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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) );
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
......@@ -50,6 +52,12 @@ public:
//! Set maximum start 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
virtual void setCenter( const core::vector3df& center ) { Center = center; }
......@@ -71,6 +79,12 @@ public:
//! Get maximum start color
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
virtual const core::vector3df& getCenter() const { return Center; }
......@@ -83,8 +97,9 @@ private:
core::vector3df Center;
f32 Radius;
core::vector3df Direction;
core::vector2df MinStartSize, MaxStartSize;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
......
......@@ -125,14 +125,17 @@ CParticleSystemSceneNode::createAnimatedMeshSceneNodeEmitter(
s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
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,
useNormalDirection, direction, normalDirectionModifier,
mbNumber, everyMeshVertex,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees );
lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -142,11 +145,13 @@ IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter(
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
s32 maxAngleDegrees, const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{
return new CParticleBoxEmitter(box, direction, minParticlesPerSecond,
maxParticlesPerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -157,13 +162,16 @@ IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter(
bool outlineOnly, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
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,
outlineOnly, direction,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees );
lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -174,13 +182,16 @@ IParticleMeshEmitter* CParticleSystemSceneNode::createMeshEmitter(
s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
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,
normalDirectionModifier, mbNumber, everyMeshVertex,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees );
lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -189,11 +200,13 @@ IParticlePointEmitter* CParticleSystemSceneNode::createPointEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlesPerSecond, const video::SColor& minStartColor,
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,
maxParticlesPerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -203,11 +216,13 @@ IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter(
const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
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,
minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees );
maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -217,12 +232,14 @@ IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter(
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
s32 maxAngleDegrees, const core::vector2df& minStartSize,
const core::vector2df& maxStartSize )
{
return new CParticleSphereEmitter(center, radius, direction,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
lifeTimeMin, lifeTimeMax, maxAngleDegrees,
minStartSize, maxStartSize );
}
......@@ -289,28 +306,12 @@ void CParticleSystemSceneNode::render()
core::vector3df view(camera->getTarget() - camera->getAbsolutePosition());
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;
#else
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] );
#endif
......@@ -324,6 +325,25 @@ void CParticleSystemSceneNode::render()
{
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].Color = particle.color;
Buffer->Vertices[0+idx].Normal = view;
......@@ -462,6 +482,10 @@ void CParticleSystemSceneNode::setParticlesAreGlobal(bool global)
//! Sets the size of all particles.
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;
}
......
......@@ -70,7 +70,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
virtual IParticleBoxEmitter* createBoxEmitter(
......@@ -81,7 +83,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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
virtual IParticleCylinderEmitter* createCylinderEmitter(
......@@ -92,7 +96,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
virtual IParticleMeshEmitter* createMeshEmitter(
......@@ -105,7 +111,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
virtual IParticlePointEmitter* createPointEmitter(
......@@ -115,7 +123,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
virtual IParticleRingEmitter* createRingEmitter(
......@@ -126,7 +136,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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.
virtual IParticleSphereEmitter* createSphereEmitter(
......@@ -137,7 +149,9 @@ public:
const video::SColor& minStartColor = video::SColor(255,0,0,0),
const video::SColor& maxStartColor = video::SColor(255,255,255,255),
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
//! 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