Added also the particle emitters from irrSpintz.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@872 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-08-29 16:13:38 +00:00
parent 8ce11fa5ba
commit 218f837bff
30 changed files with 2212 additions and 107 deletions

View File

@ -1,5 +1,7 @@
Changes in version 1.4 (... 2007)
- Added several new particle emitters and affectors from IrrSpintz. Also some new getter and setter methods were added.
- D3D transparent materials do not disable zbuffer writing automatically anymore. This has to be done by the user to keep those settings configurable.
- OpenGL texture now also require a regenerateMipmapLevels() after unlocking. This is the same as for d3d devices now.

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__
#define __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "IAnimatedMeshSceneNode.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits particles from mesh vertices.
class IParticleAnimatedMeshSceneNodeEmitter : public IParticleEmitter
{
public:
//! destructor
virtual ~IParticleAnimatedMeshSceneNodeEmitter() {};
//! Set Mesh to emit particles from
virtual void setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) = 0;
//! Set whether to use vertex normal for direction, or direction specified
virtual void setUseNormalDirection( bool useNormalDirection = true ) = 0;
//! Set the amount that the normal is divided by for getting a particles direction
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0;
//! Sets whether to emit min<->max particles for every vertex per
//! second, or to pick min<->max vertices every second
virtual void setEveryMeshVertex( bool everyMeshVertex = true ) = 0;
//! Get Mesh we're emitting particles from
virtual const IAnimatedMeshSceneNode* const getAnimatedMeshSceneNode() const = 0;
//! Get whether to use vertex normal for direction, or direction specified
virtual bool isUsingNormalDirection() const = 0;
//! Get the amount that the normal is divided by for getting a particles direction
virtual f32 getNormalDirectionModifier() const = 0;
//! Gets whether to emit min<->max particles for every vertex per
//! second, or to pick min<->max vertices every second
virtual bool getEveryMeshVertex() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif // __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__

View File

@ -0,0 +1,39 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_BOX_EMITTER_H_INCLUDED__
#define __I_PARTICLE_BOX_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "aabbox3d.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits particles from a box shaped space
class IParticleBoxEmitter : public IParticleEmitter
{
public:
//! destructor
virtual ~IParticleBoxEmitter() {};
//! Set the box shape
virtual void setBox( const core::aabbox3df& box ) = 0;
//! Get the box shape set
virtual const core::aabbox3df& getBox() const = 0;
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_BOX; }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,59 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
#define __I_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits from a cylindrically shaped space.
class IParticleCylinderEmitter : public IParticleEmitter
{
public:
//! destructor
virtual ~IParticleCylinderEmitter() {};
//! Set the center of the radius for the cylinder, at one end of the cylinder
virtual void setCenter( const core::vector3df& center ) = 0;
//! Set the normal of the cylinder
virtual void setNormal( const core::vector3df& normal ) = 0;
//! Set the radius of the cylinder
virtual void setRadius( f32 radius ) = 0;
//! Set the length of the cylinder
virtual void setLength( f32 length ) = 0;
//! Set whether or not to draw points inside the cylinder
virtual void setOutlineOnly( bool outlineOnly = true ) = 0;
//! Get the center of the cylinder
virtual const core::vector3df& getCenter() const = 0;
//! Get the normal of the cylinder
virtual const core::vector3df& getNormal() const = 0;
//! Get the radius of the cylinder
virtual f32 getRadius() const = 0;
//! Get the center of the cylinder
virtual f32 getLength() const = 0;
//! Get whether or not to draw points inside the cylinder
virtual bool getOutlineOnly() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -22,7 +22,7 @@ enum E_PARTICLE_EMITTER_TYPE
};
//! Names for built in particle emitters
const c8* const ParticleEmitterTypeNames[] =
const c8* const ParticleEmitterTypeNames[] =
{
"Point",
"Box",
@ -43,18 +43,48 @@ public:
//! and returns how much new particles there are.
//! \param now: Current time.
//! \param timeSinceLastCall: Time elapsed since last call, in milliseconds.
//! \param outArray: Pointer which will point to the array with the new
//! \param outArray: Pointer which will point to the array with the new
//! particles to add into the system.
//! \return Returns amount of new particles in the array. Can be 0.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) = 0;
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) = 0;
//! Set minimum number of particles the emitter emits per second
virtual void setMinParticlesPerSecond( u32 minPPS ) = 0;
//! Set maximum number of particles the emitter emits per second
virtual void setMaxParticlesPerSecond( u32 maxPPS ) = 0;
//! Set minimum starting color for particles
virtual void setMinStartColor( const video::SColor& color ) = 0;
//! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) = 0;
//! Get direction the emitter emits particles
virtual const core::vector3df& getDirection() const = 0;
//! Get the minimum number of particles the emitter emits per second
virtual u32 getMinParticlesPerSecond() const = 0;
//! Get the maximum number of particles the emitter emits per second
virtual u32 getMaxParticlesPerSecond() const = 0;
//! Get the minimum starting color for particles
virtual const video::SColor& getMinStartColor() const = 0;
//! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const = 0;
//! 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.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {}
//! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for
//! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes.
//! \param startIndex: start index where to start reading attributes.
//! \param in: The attributes to work with.
@ -63,9 +93,11 @@ public:
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { return 0; }
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const = 0;
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_POINT; }
};
typedef IParticleEmitter IParticlePointEmitter;
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,56 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_MESH_EMITTER_H_INCLUDED__
#define __I_PARTICLE_MESH_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "IMesh.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits from vertices of a mesh
class IParticleMeshEmitter : public IParticleEmitter
{
public:
//! destructor
virtual ~IParticleMeshEmitter() {};
//! Set Mesh to emit particles from
virtual void setMesh( IMesh* mesh ) = 0;
//! Set whether to use vertex normal for direction, or direction specified
virtual void setUseNormalDirection( bool useNormalDirection = true ) = 0;
//! Set the amount that the normal is divided by for getting a particles direction
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) = 0;
//! Sets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual void setEveryMeshVertex( bool everyMeshVertex = true ) = 0;
//! Get Mesh we're emitting particles from
virtual const IMesh* const getMesh() const = 0;
//! Get whether to use vertex normal for direction, or direction specified
virtual bool isUsingNormalDirection() const = 0;
//! Get the amount that the normal is divided by for getting a particles direction
virtual f32 getNormalDirectionModifier() const = 0;
//! Gets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual bool getEveryMeshVertex() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,47 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_RING_EMITTER_H_INCLUDED__
#define __I_PARTICLE_RING_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits particles along a ring shaped area.
class IParticleRingEmitter : public IParticleEmitter
{
public:
//! destructor
virtual ~IParticleRingEmitter() {};
//! Set the center of the ring
virtual void setCenter( const core::vector3df& center ) = 0;
//! Set the radius of the ring
virtual void setRadius( f32 radius ) = 0;
//! Set the thickness of the ring
virtual void setRingThickness( f32 ringThickness ) = 0;
//! Get the center of the ring
virtual const core::vector3df& getCenter() const = 0;
//! Get the radius of the ring
virtual f32 getRadius() const = 0;
//! Get the thickness of the ring
virtual f32 getRingThickness() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,41 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__
#define __I_PARTICLE_SPHERE_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
namespace irr
{
namespace scene
{
//! A particle emitter which emits from a spherical space.
class IParticleSphereEmitter : public IParticleEmitter
{
public:
//! destructor
virtual ~IParticleSphereEmitter() {};
//! Set the center of the sphere for particle emissions
virtual void setCenter( const core::vector3df& center ) = 0;
//! Set the radius of the sphere for particle emissions
virtual void setRadius( f32 radius ) = 0;
//! Get the center of the sphere for particle emissions
virtual const core::vector3df& getCenter() const = 0;
//! Get the radius of the sphere for particle emissions
virtual f32 getRadius() const = 0;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -6,7 +6,12 @@
#define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h"
#include "IParticleEmitter.h"
#include "IParticleAnimatedMeshSceneNodeEmitter.h"
#include "IParticleBoxEmitter.h"
#include "IParticleCylinderEmitter.h"
#include "IParticleMeshEmitter.h"
#include "IParticleRingEmitter.h"
#include "IParticleSphereEmitter.h"
#include "IParticleAttractionAffector.h"
#include "IParticleFadeOutAffector.h"
#include "IParticleGravityAffector.h"
@ -27,7 +32,7 @@ You can for example easily a campfire by doing this:
scene::IParticleSystemSceneNode* p = scenemgr->addParticleSystemSceneNode();
p->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f));
scene::IParticleEmitter* em = p->createBoxEmitter(
core::aabbox3d<f32>(-5,0,-5,5,1,5),
core::aabbox3d<f32>(-5,0,-5,5,1,5),
core::vector3df(0.0f,0.03f,0.0f),
40,80, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 1100,2000);
p->setEmitter(em);
@ -43,7 +48,7 @@ class IParticleSystemSceneNode : public ISceneNode
public:
//! constructor
IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
@ -53,13 +58,13 @@ public:
virtual void setParticleSize(
const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)) = 0;
//! Sets if the particles should be global. If it is, the particles are affected by
//! the movement of the particle system scene node too, otherwise they completely
//! Sets if the particles should be global. If it is, the particles are affected by
//! the movement of the particle system scene node too, otherwise they completely
//! ignore it. Default is true.
virtual void setParticlesAreGlobal(bool global) = 0;
//! Sets the particle emitter, which creates the particles.
//! A particle emitter can be created using one of the
//! A particle emitter can be created using one of the
//! methods. For example to create and use a simple PointEmitter,
//! call IParticleEmitter* p = createPointEmitter(); setEmitter(p); p->drop();
//! \param emitter: Sets the particle emitter. You can set this to 0
@ -80,16 +85,30 @@ public:
//! Removes all particle affectors in the particle system.
virtual void removeAllAffectors() = 0;
//! Creates a point particle emitter.
//! Creates a particle emitter for an animated mesh scene node
//! \param node: Pointer to the animated mesh scene node to emit particles from
//! \param useNormalDirection: If true, the direction of each particle created will
//! be the normal of the vertex that it's emitting from. The normal is divided by the
//! normalDirectionModifier parameter, which defaults to 100.0f.
//! \param direction: Direction and speed of particle emission.
//! \param normalDirectionModifier: If the emitter is using the normal direction
//! then the normal of the vertex that is being emitted from is divided by this number.
//! \param mbNumber: This allows you to specify a specific meshBuffer for the IMesh*
//! to emit particles from. The default value is -1, which means a random meshBuffer
//! picked from all of the meshes meshBuffers will be selected to pick a random vertex from.
//! If the value is 0 or greater, it will only pick random vertices from the meshBuffer
//! specified by this value.
//! \param everyMeshVertex: If true, the emitter will emit between min/max particles every second,
//! for every vertex in the mesh, if false, it will emit between min/max particles from random vertices
//! in the mesh.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
@ -101,14 +120,16 @@ public:
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticleEmitter* createPointEmitter(
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
video::SColor minStartColor = video::SColor(255,0,0,0),
video::SColor maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0;
virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(
scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
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;
//! Creates a box particle emitter.
//! \param box: The box for the emitter.
@ -117,10 +138,10 @@ public:
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
@ -132,13 +153,191 @@ public:
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticleEmitter* createBoxEmitter(
virtual IParticleBoxEmitter* createBoxEmitter(
const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10),
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
video::SColor minStartColor = video::SColor(255,0,0,0),
video::SColor maxStartColor = video::SColor(255,255,255,255),
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;
//! Creates a particle emitter for emitting from a cylinder
//! \param center: The center of the circle at the base of the cylinder
//! \param radius: The thickness of the cylinder
//! \param normal: Direction of the length of the cylinder
//! \param length: The length of the the cylinder
//! \param outlineOnly: Whether or not to put points inside the cylinder or on the outline only
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticleCylinderEmitter* createCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
bool outlineOnly = false,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
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;
//! Creates a mesh particle emitter.
//! \param mesh: Pointer to mesh to emit particles from
//! \param useNormalDirection: If true, the direction of each particle created will
//! be the normal of the vertex that it's emitting from. The normal is divided by the
//! normalDirectionModifier parameter, which defaults to 100.0f.
//! \param direction: Direction and speed of particle emission.
//! \param normalDirectionModifier: If the emitter is using the normal direction
//! then the normal of the vertex that is being emitted from is divided by this number.
//! \param mbNumber: This allows you to specify a specific meshBuffer for the IMesh*
//! to emit particles from. The default value is -1, which means a random meshBuffer
//! picked from all of the meshes meshBuffers will be selected to pick a random vertex from.
//! If the value is 0 or greater, it will only pick random vertices from the meshBuffer
//! specified by this value.
//! \param everyMeshVertex: If true, the emitter will emit between min/max particles every second,
//! for every vertex in the mesh, if false, it will emit between min/max particles from random vertices
//! in the mesh.
//! \param minParticlesPerSecond: Minimal amount of particles emitted per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticleMeshEmitter* createMeshEmitter(
scene::IMesh* mesh, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
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;
//! Creates a point particle emitter.
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticlePointEmitter* createPointEmitter(
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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;
//! Creates a ring particle emitter.
//! \param center: Center of ring
//! \param radius: Distance of points from center, points will be rotated around the
//! Y axis at a random 360 degrees and will then be shifted by the provided ringThickness
//! values in each axis.
//! \param ringThickness : thickness of the ring or how wide the ring is
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticleRingEmitter* createRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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;
//! Creates a sphere particle emitter.
//! \param center: Center of sphere
//! \param radius: Radius of sphere
//! \param direction: Direction and speed of particle emission.
//! \param minParticlesPerSecond: Minimal amount of particles emitted
//! per second.
//! \param maxParticlesPerSecond: Maximal amount of particles emitted
//! per second.
//! \param minStartColor: Minimal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param maxStartColor: Maximal initial start color of a particle.
//! The real color of every particle is calculated as random interpolation
//! between minStartColor and maxStartColor.
//! \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
//! \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
//! \param maxAngleDegrees: Maximal angle in degrees, the emitting direction
//! of the particle will differ from the orignial direction.
//! \return Returns a pointer to the created particle emitter.
//! To set this emitter as new emitter of this particle system,
//! just call setEmitter(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations.
virtual IParticleSphereEmitter* createSphereEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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;
@ -166,8 +365,8 @@ public:
//! material is used and the targetColor is video::SColor(0,0,0,0):
//! Particles are fading out into void with this setting.
//! \param targetColor: Color whereto the color of the particle is changed.
//! \param timeNeededToFadeOut: How much time in milli seconds
//! should the affector need to change the color to the targetColor.
//! \param timeNeededToFadeOut: How much time in milli seconds
//! should the affector need to change the color to the targetColor.
//! \return Returns a pointer to the created particle affector.
//! To add this affector as new affector of this particle system,
//! just call addAffector(). Note that you'll have to drop() the
@ -183,7 +382,7 @@ public:
//! and is catched by the gravity then. This affector is ideal for
//! creating things like fountains.
//! \param gravity: Direction and force of gravity.
//! \param timeForceLost: Time in milli seconds when the force
//! \param timeForceLost: Time in milli seconds when the force
//! of the emitter is totally lost and the particle does not move any more.
//! This is the time where gravity fully affects the particle.
//! \return Returns a pointer to the created particle affector.

View File

@ -103,11 +103,9 @@
#include "ISceneNodeAnimatorFactory.h"
#include "ISceneNodeAnimatorCollisionResponse.h"
#include "IShaderConstantSetCallBack.h"
#include "IParticleSystemSceneNode.h"
#include "IParticleSystemSceneNode.h" // also includes all emitters and attractors
#include "ITerrainSceneNode.h"
#include "ITextSceneNode.h"
#include "IParticleEmitter.h"
#include "IParticleAffector.h"
#include "ITexture.h"
#include "IUnknown.h"
#include "IVideoDriver.h"

View File

@ -1013,6 +1013,82 @@ void CIrrDeviceLinux::setResizeAble(bool resize)
}
//! \return Returns a pointer to a list with all video modes supported
//! by the gfx adapter.
video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
{
if (!VideoModeList.getVideoModeCount())
{
bool temporaryDisplay = false;
if (!display)
{
display = XOpenDisplay(0);
temporaryDisplay=true;
}
if (!display)
{
s32 eventbase, errorbase;
s32 defaultDepth=DefaultDepth(display,screennr);
#ifdef _IRR_LINUX_X11_VIDMODE_
if (XF86VidModeQueryExtension(display, &eventbase, &errorbase))
{
// enumerate video modes
int modeCount;
XF86VidModeModeInfo** modes;
XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes);
// save current video mode
oldVideoMode = *modes[0];
// find fitting mode
VideoModeList.setDesktop(defaultDepth, core::dimension2d<s32>(
modes[0]->hdisplay, modes[0]->vdisplay));
for (int i = 0; i<modeCount; ++i)
{
VideoModeList.addMode(core::dimension2d<s32>(
modes[i]->hdisplay, modes[i]->vdisplay), defaultDepth);
}
XFree(modes);
}
else
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (XRRQueryExtension(display, &eventbase, &errorbase))
{
int modeCount;
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation);
XRRScreenSize *modes=XRRConfigSizes(config,&modeCount);
VideoModeList.setDesktop(defaultDepth, core::dimension2d<s32>(
modes[oldRandrMode].width, modes[oldRandrMode].height));
for (int i = 0; i<modeCount; ++i)
{
VideoModeList.addMode(core::dimension2d<s32>(
modes[i].width, modes[i].height), defaultDepth);
}
XRRFreeScreenConfigInfo(config);
}
else
#endif
{
os::Printer::log("VidMode or RandR X11 extension requireed for VideoModeList." , ELL_WARNING);
}
}
if (display && temporaryDisplay)
{
XCloseDisplay(display);
}
}
return &VideoModeList;
}
void CIrrDeviceLinux::createKeyMap()
{

View File

@ -77,6 +77,10 @@ namespace irr
//! notifies the device that it should close itself
virtual void closeDevice();
//! \return Returns a pointer to a list with all video modes
//! supported by the gfx adapter.
video::IVideoModeList* getVideoModeList();
//! Sets if the window should be resizeable in windowed mode.
virtual void setResizeAble(bool resize=false);
@ -105,14 +109,13 @@ namespace irr
unsigned long valuemask = 0;
XColor fg, bg;
int depth = 1;
// this code, for making the cursor invisible was sent in by
// Sirshane, thank your very much!
Pixmap invisBitmap = XCreatePixmap( Device->display, Device->window, 32, 32, depth );
Pixmap maskBitmap = XCreatePixmap( Device->display, Device->window, 32, 32, depth );
Pixmap invisBitmap = XCreatePixmap(Device->display, Device->window, 32, 32, 1);
Pixmap maskBitmap = XCreatePixmap(Device->display, Device->window, 32, 32, 1);
Colormap screen_colormap = DefaultColormap( Device->display, DefaultScreen( Device->display ) );
XAllocNamedColor( Device->display, screen_colormap, "black", &fg, &fg );
XAllocNamedColor( Device->display, screen_colormap, "white", &bg, &bg );
@ -131,10 +134,6 @@ namespace irr
#endif
}
~CCursorControl()
{
}
//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible)
{

View File

@ -249,7 +249,7 @@ namespace video
//! Returns whether disabling was successful or not.
bool disableTextures(u32 fromStage=0);
//! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or
//! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or
//! vertex shaders to render geometry.
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData);

View File

@ -0,0 +1,203 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CParticleAnimatedMeshSceneNodeEmitter.h"
#include "IAnimatedMeshSceneNode.h"
#include "IMesh.h"
#include "os.h"
namespace irr
{
namespace scene
{
//! constructor
CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter(
IAnimatedMeshSceneNode* node, bool useNormalDirection,
const core::vector3df& direction, f32 normalDirectionModifier,
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),
MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{
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();
}
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
Particles.set_used(0);
u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
Time = 0;
SParticle p;
if(amount > MaxParticlesPerSecond * 2)
amount = MaxParticlesPerSecond * 2;
// Get Mesh for this frame
IMesh* frameMesh = AnimatedMesh->getMesh( Node->getFrameNr(), 255, Node->getStartFrame(), Node->getEndFrame() );
for(u32 i=0; i<amount; ++i)
{
if( EveryMeshVertex )
{
for( u32 j=0; j<frameMesh->getMeshBufferCount(); ++j )
{
for( u32 k=0; k<frameMesh->getMeshBuffer(j)->getVertexCount(); ++k )
{
switch( frameMesh->getMeshBuffer(j)->getVertexType() )
{
case video::EVT_STANDARD:
p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now;
if( MaxAngleDegrees )
{
core::vector3df tgt = p.vector;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
}
}
else
{
s32 randomMB = 0;
if( MBNumber < 0 )
{
randomMB = os::Randomizer::rand() % MBCount;
}
else
{
randomMB = MBNumber;
}
u32 vertexNumber = os::Randomizer::rand() % frameMesh->getMeshBuffer(randomMB)->getVertexCount();
switch( frameMesh->getMeshBuffer(randomMB)->getVertexType() )
{
case video::EVT_STANDARD:
p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now;
if( MaxAngleDegrees )
{
core::vector3df tgt = Direction;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
}
outArray = Particles.pointer();
return Particles.size();
}
return 0;
}
//! Set Mesh to emit particles from
void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node )
{
Node = 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();
}
}
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,127 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__
#define __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__
#include "IParticleAnimatedMeshSceneNodeEmitter.h"
#include "irrArray.h"
namespace irr
{
namespace scene
{
//! An animated mesh emitter
class CParticleAnimatedMeshSceneNodeEmitter : public IParticleAnimatedMeshSceneNodeEmitter
{
public:
//! constructor
CParticleAnimatedMeshSceneNodeEmitter(
IAnimatedMeshSceneNode* node,
bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,-1.0f),
f32 normalDirectionModifier = 100.0f,
s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 20,
u32 maxParticlesPerSecond = 40,
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
);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set Mesh to emit particles from
virtual void setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node );
//! Set whether to use vertex normal for direction, or direction specified
virtual void setUseNormalDirection( bool useNormalDirection ) { UseNormalDirection = useNormalDirection; }
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set the amount that the normal is divided by for getting a particles direction
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) { NormalDirectionModifier = normalDirectionModifier; }
//! Sets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual void setEveryMeshVertex( bool everyMeshVertex ) { EveryMeshVertex = everyMeshVertex; }
//! Set minimum number of particles the emitter emits per second
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set maximum number of particles the emitter emits per second
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set minimum starting color for particles
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Get Mesh we're emitting particles from
virtual const IAnimatedMeshSceneNode* const getAnimatedMeshSceneNode() const { return Node; }
//! Get whether to use vertex normal for direciton, or direction specified
virtual bool isUsingNormalDirection() const { return UseNormalDirection; }
//! Get direction the emitter emits particles
virtual const core::vector3df& getDirection() const { return Direction; }
//! Get the amount that the normal is divided by for getting a particles direction
virtual f32 getNormalDirectionModifier() const { return NormalDirectionModifier; }
//! Gets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual bool getEveryMeshVertex() const { return EveryMeshVertex; }
//! Get the minimum number of particles the emitter emits per second
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Get the maximum number of particles the emitter emits per second
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Get the minimum starting color for particles
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
private:
IAnimatedMeshSceneNode* Node;
IAnimatedMesh* AnimatedMesh;
IMesh* BaseMesh;
s32 TotalVertices;
u32 MBCount;
s32 MBNumber;
core::array<s32> VertexPerMeshBufferList;
bool EveryMeshVertex;
bool UseNormalDirection;
f32 NormalDirectionModifier;
core::array<SParticle> Particles;
core::vector3df Direction;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
};
} // end namespace scene
} // end namespace irr
#endif // __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__

View File

@ -20,7 +20,7 @@ CParticleBoxEmitter::CParticleBoxEmitter(
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
: Box(box), Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees)
@ -42,15 +42,15 @@ s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outAr
if (Time > everyWhatMillisecond)
{
Particles.set_used(0);
s32 amount = (s32)((Time / everyWhatMillisecond) + 0.5f);
u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
Time = 0;
SParticle p;
const core::vector3df& extent = Box.getExtent();
if (amount > (s32)MaxParticlesPerSecond*2)
if (amount > MaxParticlesPerSecond*2)
amount = MaxParticlesPerSecond * 2;
for (s32 i=0; i<amount; ++i)
for (u32 i=0; i<amount; ++i)
{
p.pos.X = Box.MinEdge.X + fmodf((f32)os::Randomizer::rand(), extent.X);
p.pos.Y = Box.MinEdge.Y + fmodf((f32)os::Randomizer::rand(), extent.Y);
@ -62,9 +62,9 @@ s32 CParticleBoxEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outAr
if (MaxAngleDegrees)
{
core::vector3df tgt = Direction;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
p.vector = tgt;
}
@ -136,10 +136,10 @@ s32 CParticleBoxEmitter::deserializeAttributes(s32 startIndex, io::IAttributes*
MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond");
MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond");
MinParticlesPerSecond = core::max_<s32>(1, MinParticlesPerSecond);
MaxParticlesPerSecond = core::max_<s32>(MaxParticlesPerSecond, 1);
MaxParticlesPerSecond = core::min_<s32>(MaxParticlesPerSecond, 200);
MinParticlesPerSecond = core::min_<s32>(MinParticlesPerSecond, MaxParticlesPerSecond);
MinParticlesPerSecond = core::max_(1u, MinParticlesPerSecond);
MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1u);
MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200u);
MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond);
MinStartColor = in->getAttributeAsColor("MinStartColor");
MaxStartColor = in->getAttributeAsColor("MaxStartColor");
@ -147,9 +147,9 @@ s32 CParticleBoxEmitter::deserializeAttributes(s32 startIndex, io::IAttributes*
MaxLifeTime = in->getAttributeAsInt("MaxLifeTime");
MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees");
MinLifeTime = core::max_<s32>(0, MinLifeTime);
MaxLifeTime = core::max_<s32>(MaxLifeTime, MinLifeTime);
MinLifeTime = core::min_<s32>(MinLifeTime, MaxLifeTime);
MinLifeTime = core::max_(0u, MinLifeTime);
MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime);
MinLifeTime = core::min_(MinLifeTime, MaxLifeTime);
return in->findAttribute("MaxAngleDegrees");
}

View File

@ -5,7 +5,7 @@
#ifndef __C_PARTICLE_BOX_EMITTER_H_INCLUDED__
#define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__
#include "IParticleEmitter.h"
#include "IParticleBoxEmitter.h"
#include "irrArray.h"
#include "aabbox3d.h"
@ -15,14 +15,14 @@ namespace scene
{
//! A default box emitter
class CParticleBoxEmitter : public IParticleEmitter
class CParticleBoxEmitter : public IParticleBoxEmitter
{
public:
//! constructor
CParticleBoxEmitter(
const core::aabbox3df& box,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 20,
u32 maxParticlesPerSecond = 40,
video::SColor minStartColor = video::SColor(255,0,0,0),
@ -35,23 +35,56 @@ public:
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set direction the emitter emits particles.
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set minimum number of particles emitted per second.
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set maximum number of particles emitted per second.
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set minimum start color.
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set maximum start color.
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set box from which the particles are emitted.
virtual void setBox( const core::aabbox3df& box ) { Box = box; }
//! Gets direction the emitter emits particles.
virtual const core::vector3df& getDirection() const { return Direction; }
//! Gets minimum number of particles emitted per second.
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Gets maximum number of particles emitted per second.
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Gets minimum start color.
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Gets maximum start color.
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Get box from which the particles are emitted.
virtual const core::aabbox3df& getBox() const { return Box; }
//! Writes attributes of the object.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options);
//! Reads attributes of the object.
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options);
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_BOX; }
private:
core::array<SParticle> Particles;
core::aabbox3df Box;
core::vector3df Direction;
s32 MinParticlesPerSecond, MaxParticlesPerSecond;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
s32 MinLifeTime, MaxLifeTime;
u32 MinLifeTime, MaxLifeTime;
u32 Time;
u32 Emitted;

View File

@ -0,0 +1,108 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CParticleCylinderEmitter.h"
#include "os.h"
namespace irr
{
namespace scene
{
//! constructor
CParticleCylinderEmitter::CParticleCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
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),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees)
{
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
Particles.set_used(0);
u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
Time = 0;
SParticle p;
if(amount > MaxParticlesPerSecond*2)
amount = MaxParticlesPerSecond * 2;
for(u32 i=0; i<amount; ++i)
{
// Random distance from center if outline only is not true
f32 distance;
if( !OutlineOnly )
distance = fmodf( (f32)os::Randomizer::rand(), Radius * 1000.0f ) * 0.001f;
else
distance = Radius;
// Random direction from center
p.pos.X = Center.X + distance;
p.pos.Y = Center.Y;
p.pos.Z = Center.Z + distance;
p.pos.rotateXZBy( os::Randomizer::rand() % 360, Center );
// Random length
const f32 length = fmodf( (f32)os::Randomizer::rand(), Length * 1000.0f ) * 0.001f;
// Random point along the cylinders length
p.pos += Normal * length;
p.startTime = now;
p.vector = Direction;
if( MaxAngleDegrees )
{
core::vector3df tgt = Direction;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
outArray = Particles.pointer();
return Particles.size();
}
return 0;
}
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,123 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
#define __C_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
#include "IParticleCylinderEmitter.h"
#include "irrArray.h"
namespace irr
{
namespace scene
{
//! A default box emitter
class CParticleCylinderEmitter : public IParticleCylinderEmitter
{
public:
//! constructor
CParticleCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 20,
u32 maxParticlesPerSecond = 40,
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);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set the center of the radius for the cylinder, at one end of the cylinder
virtual void setCenter( const core::vector3df& center ) { Center = center; }
//! Set the normal of the cylinder
virtual void setNormal( const core::vector3df& normal ) { Normal = normal; }
//! Set the radius of the cylinder
virtual void setRadius( f32 radius ) { Radius = radius; }
//! Set the length of the cylinder
virtual void setLength( f32 length ) { Length = length; }
//! Set whether or not to draw points inside the cylinder
virtual void setOutlineOnly( bool outlineOnly ) { OutlineOnly = outlineOnly; }
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set direction the emitter emits particles
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set direction the emitter emits particles
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set direction the emitter emits particles
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set direction the emitter emits particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Get the center of the cylinder
virtual const core::vector3df& getCenter() const { return Center; }
//! Get the normal of the cylinder
virtual const core::vector3df& getNormal() const { return Normal; }
//! Get the radius of the cylinder
virtual f32 getRadius() const { return Radius; }
//! Get the center of the cylinder
virtual f32 getLength() const { return Length; }
//! Get whether or not to draw points inside the cylinder
virtual bool getOutlineOnly() const { return OutlineOnly; }
//! Gets direction the emitter emits particles
virtual const core::vector3df& getDirection() const { return Direction; }
//! Gets direction the emitter emits particles
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Gets direction the emitter emits particles
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Gets direction the emitter emits particles
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Gets direction the emitter emits particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
private:
core::array<SParticle> Particles;
core::vector3df Center;
core::vector3df Normal;
f32 Radius;
f32 Length;
bool OutlineOnly;
core::vector3df Direction;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,196 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#include "CParticleMeshEmitter.h"
#include "os.h"
#include <math.h>
namespace irr
{
namespace scene
{
//! constructor
CParticleMeshEmitter::CParticleMeshEmitter(
IMesh* mesh, bool useNormalDirection,
const core::vector3df& direction, f32 normalDirectionModifier,
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),
NormalDirectionModifier(normalDirectionModifier), Direction(direction),
MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{
MBCount = Mesh->getMeshBufferCount();
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() );
TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount();
}
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticleMeshEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
Particles.set_used(0);
u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
Time = 0;
SParticle p;
if(amount > MaxParticlesPerSecond * 2)
amount = MaxParticlesPerSecond * 2;
for(u32 i=0; i<amount; ++i)
{
if( EveryMeshVertex )
{
for( u32 j=0; j<Mesh->getMeshBufferCount(); ++j )
{
for( u32 k=0; k<Mesh->getMeshBuffer(j)->getVertexCount(); ++k )
{
switch( Mesh->getMeshBuffer(j)->getVertexType() )
{
case video::EVT_STANDARD:
p.pos = ((video::S3DVertex*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertex*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(j)->getVertices())[k].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now;
if( MaxAngleDegrees )
{
core::vector3df tgt = p.vector;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
}
}
else
{
s32 randomMB = 0;
if( MBNumber < 0 )
{
randomMB = os::Randomizer::rand() % MBCount;
}
else
{
randomMB = MBNumber;
}
u32 vertexNumber = os::Randomizer::rand() % Mesh->getMeshBuffer(randomMB)->getVertexCount();
switch( Mesh->getMeshBuffer(randomMB)->getVertexType() )
{
case video::EVT_STANDARD:
p.pos = ((video::S3DVertex*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertex*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
case video::EVT_TANGENTS:
p.pos = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Pos;
if( UseNormalDirection )
p.vector = ((video::S3DVertexTangents*)Mesh->getMeshBuffer(randomMB)->getVertices())[vertexNumber].Normal / NormalDirectionModifier;
else
p.vector = Direction;
break;
}
p.startTime = now;
if( MaxAngleDegrees )
{
core::vector3df tgt = Direction;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df(0,0,0));
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
}
outArray = Particles.pointer();
return Particles.size();
}
return 0;
}
//! Set Mesh to emit particles from
void CParticleMeshEmitter::setMesh( IMesh* mesh )
{
Mesh = mesh;
TotalVertices = 0;
MBCount = Mesh->getMeshBufferCount();
for( u32 i = 0; i < MBCount; ++i )
{
VertexPerMeshBufferList.push_back( Mesh->getMeshBuffer(i)->getVertexCount() );
TotalVertices += Mesh->getMeshBuffer(i)->getVertexCount();
}
}
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,126 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_MESH_EMITTER_H_INCLUDED__
#define __C_PARTICLE_MESH_EMITTER_H_INCLUDED__
#include "IParticleMeshEmitter.h"
#include "irrArray.h"
#include "aabbox3d.h"
#include "IMeshBuffer.h"
namespace irr
{
namespace scene
{
//! A default box emitter
class CParticleMeshEmitter : public IParticleMeshEmitter
{
public:
//! constructor
CParticleMeshEmitter(
IMesh* mesh, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f,
s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 20,
u32 maxParticlesPerSecond = 40,
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
);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set Mesh to emit particles from
virtual void setMesh( IMesh* mesh );
//! Set whether to use vertex normal for direction, or direction specified
virtual void setUseNormalDirection( bool useNormalDirection ) { UseNormalDirection = useNormalDirection; }
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set the amount that the normal is divided by for getting a particles direction
virtual void setNormalDirectionModifier( f32 normalDirectionModifier ) { NormalDirectionModifier = normalDirectionModifier; }
//! Sets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual void setEveryMeshVertex( bool everyMeshVertex ) { EveryMeshVertex = everyMeshVertex; }
//! Set minimum number of particles the emitter emits per second
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set maximum number of particles the emitter emits per second
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set minimum starting color for particles
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Get Mesh we're emitting particles from
virtual const IMesh* const getMesh() const { return Mesh; }
//! Get whether to use vertex normal for direciton, or direction specified
virtual bool isUsingNormalDirection() const { return UseNormalDirection; }
//! Get direction the emitter emits particles
virtual const core::vector3df& getDirection() const { return Direction; }
//! Get the amount that the normal is divided by for getting a particles direction
virtual f32 getNormalDirectionModifier() const { return NormalDirectionModifier; }
//! Gets whether to emit min<->max particles for every vertex per second, or to pick
//! min<->max vertices every second
virtual bool getEveryMeshVertex() const { return EveryMeshVertex; }
//! Get the minimum number of particles the emitter emits per second
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Get the maximum number of particles the emitter emits per second
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Get the minimum starting color for particles
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Get the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
private:
IMesh* Mesh;
s32 TotalVertices;
u32 MBCount;
s32 MBNumber;
core::array<s32> VertexPerMeshBufferList;
bool EveryMeshVertex;
bool UseNormalDirection;
f32 NormalDirectionModifier;
core::array<SParticle> Particles;
core::vector3df Direction;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
};
} // end namespace scene
} // end namespace irr
#endif // __C_PARTICLE_MESH_EMITTER_H_INCLUDED__

View File

@ -18,7 +18,7 @@ CParticlePointEmitter::CParticlePointEmitter(
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
: Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
MaxAngleDegrees(maxAngleDegrees), Time(0), Emitted(0)
@ -95,10 +95,10 @@ s32 CParticlePointEmitter::deserializeAttributes(s32 startIndex, io::IAttributes
MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond");
MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond");
MinParticlesPerSecond = core::max_<s32>(1, MinParticlesPerSecond);
MaxParticlesPerSecond = core::max_<s32>(MaxParticlesPerSecond, 1);
MaxParticlesPerSecond = core::min_<s32>(MaxParticlesPerSecond, 200);
MinParticlesPerSecond = core::min_<s32>(MinParticlesPerSecond, MaxParticlesPerSecond);
MinParticlesPerSecond = core::max_(1u, MinParticlesPerSecond);
MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1u);
MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200u);
MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond);
MinStartColor = in->getAttributeAsColor("MinStartColor");
MaxStartColor = in->getAttributeAsColor("MaxStartColor");
@ -106,9 +106,9 @@ s32 CParticlePointEmitter::deserializeAttributes(s32 startIndex, io::IAttributes
MaxLifeTime = in->getAttributeAsInt("MaxLifeTime");
MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees");
MinLifeTime = core::max_<s32>(0, MinLifeTime);
MaxLifeTime = core::max_<s32>(MaxLifeTime, MinLifeTime);
MinLifeTime = core::min_<s32>(MinLifeTime, MaxLifeTime);
MinLifeTime = core::max_(0u, MinLifeTime);
MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime);
MinLifeTime = core::min_(MinLifeTime, MaxLifeTime);
return in->findAttribute("MaxAngleDegrees");
}

View File

@ -14,7 +14,7 @@ namespace scene
{
//! A default point emitter
class CParticlePointEmitter : public IParticleEmitter
class CParticlePointEmitter : public IParticlePointEmitter
{
public:
@ -33,22 +33,49 @@ public:
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set direction the emitter emits particles.
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set minimum number of particles emitted per second.
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set maximum number of particles emitted per second.
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set minimum start color.
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set maximum start color.
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Gets direction the emitter emits particles.
virtual const core::vector3df& getDirection() const { return Direction; }
//! Gets minimum number of particles emitted per second.
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Gets maximum number of particles emitted per second.
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Gets minimum start color.
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Gets maximum start color.
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Writes attributes of the object.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options);
//! Reads attributes of the object.
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options);
//! Get emitter type
virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_POINT; }
private:
SParticle Particle;
core::vector3df Direction;
s32 MinParticlesPerSecond, MaxParticlesPerSecond;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
s32 MinLifeTime, MaxLifeTime;
u32 MinLifeTime, MaxLifeTime;
s32 MaxAngleDegrees;
u32 Time;

View File

@ -0,0 +1,99 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CParticleRingEmitter.h"
#include "os.h"
namespace irr
{
namespace scene
{
//! constructor
CParticleRingEmitter::CParticleRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
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), RingThickness(ringThickness),
Direction(direction), MinParticlesPerSecond(minParticlesPerSecond),
MaxParticlesPerSecond(maxParticlesPerSecond), MinStartColor(minStartColor),
MaxStartColor(maxStartColor), MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees)
{
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticleRingEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
Particles.set_used(0);
u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
Time = 0;
SParticle p;
if(amount > MaxParticlesPerSecond*2)
amount = MaxParticlesPerSecond * 2;
for(u32 i=0; i<amount; ++i)
{
f32 distance = fmodf( (f32)os::Randomizer::rand(), RingThickness * 0.5f * 1000.0f ) * 0.001f;
s32 plusMinus = os::Randomizer::rand() % 2;
if( plusMinus )
distance *= -1.0f;
distance += Radius;
p.pos.X = Center.X + distance;
p.pos.Y = Center.Y;
p.pos.Z = Center.Z + distance;
p.pos.rotateXZBy( ( os::Randomizer::rand() % 3600 ) * 0.1f, Center );
p.startTime = now;
p.vector = Direction;
if(MaxAngleDegrees)
{
core::vector3df tgt = Direction;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, Center );
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, Center );
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, Center );
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
outArray = Particles.pointer();
return Particles.size();
}
return 0;
}
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,111 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_RING_EMITTER_H_INCLUDED__
#define __C_PARTICLE_RING_EMITTER_H_INCLUDED__
#include "IParticleRingEmitter.h"
#include "irrArray.h"
namespace irr
{
namespace scene
{
//! A ring emitter
class CParticleRingEmitter : public IParticleRingEmitter
{
public:
//! constructor
CParticleRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 20,
u32 maxParticlesPerSecond = 40,
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);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set minimum number of particles the emitter emits per second
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set maximum number of particles the emitter emits per second
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set minimum starting color for particles
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set maximum starting color for particles
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the center of the ring
virtual void setCenter( const core::vector3df& center ) { Center = center; }
//! Set the radius of the ring
virtual void setRadius( f32 radius ) { Radius = radius; }
//! Set the thickness of the ring
virtual void setRingThickness( f32 ringThickness ) { RingThickness = ringThickness; }
//! Gets direction the emitter emits particles
virtual const core::vector3df& getDirection() const { return Direction; }
//! Gets the minimum number of particles the emitter emits per second
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Gets the maximum number of particles the emitter emits per second
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Gets the minimum starting color for particles
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Gets the maximum starting color for particles
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Get the center of the ring
virtual const core::vector3df& getCenter() const { return Center; }
//! Get the radius of the ring
virtual f32 getRadius() const { return Radius; }
//! Get the thickness of the ring
virtual f32 getRingThickness() const { return RingThickness; }
private:
core::array<SParticle> Particles;
core::vector3df Center;
f32 Radius;
f32 RingThickness;
core::vector3df Direction;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
f32 MinimumDistance;
f32 MaximumDistance;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -0,0 +1,100 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#include "CParticleSphereEmitter.h"
#include "os.h"
#include <math.h>
namespace irr
{
namespace scene
{
//! constructor
CParticleSphereEmitter::CParticleSphereEmitter(
const core::vector3df& center, f32 radius,
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),
MaxParticlesPerSecond(maxParticlesPerSecond),
MinStartColor(minStartColor), MaxStartColor(maxStartColor),
MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), Time(0), Emitted(0),
MaxAngleDegrees(maxAngleDegrees)
{
}
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
s32 CParticleSphereEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
{
Time += timeSinceLastCall;
u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
f32 perSecond = pps ? (f32)MinParticlesPerSecond + (os::Randomizer::rand() % pps) : MinParticlesPerSecond;
f32 everyWhatMillisecond = 1000.0f / perSecond;
if(Time > everyWhatMillisecond)
{
Particles.set_used(0);
u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
Time = 0;
SParticle p;
if(amount > MaxParticlesPerSecond*2)
amount = MaxParticlesPerSecond * 2;
for(u32 i=0; i<amount; ++i)
{
// Random distance from center
f32 distance = fmodf( (f32)os::Randomizer::rand(), Radius * 1000.0f ) * 0.001f;
// Random direction from center
p.pos.X = Center.X + distance;
p.pos.Y = Center.Y + distance;
p.pos.Z = Center.Z + distance;
p.pos.rotateXYBy( os::Randomizer::rand() % 360, Center );
p.pos.rotateYZBy( os::Randomizer::rand() % 360, Center );
p.pos.rotateXZBy( os::Randomizer::rand() % 360, Center );
p.startTime = now;
p.vector = Direction;
if(MaxAngleDegrees)
{
core::vector3df tgt = Direction;
tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateYZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
tgt.rotateXZBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df());
p.vector = tgt;
}
if(MaxLifeTime - MinLifeTime == 0)
p.endTime = now + MinLifeTime;
else
p.endTime = now + MinLifeTime + (os::Randomizer::rand() % (MaxLifeTime - MinLifeTime));
p.color = MinStartColor.getInterpolated(
MaxStartColor, (os::Randomizer::rand() % 100) / 100.0f);
p.startColor = p.color;
p.startVector = p.vector;
Particles.push_back(p);
}
outArray = Particles.pointer();
return Particles.size();
}
return 0;
}
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,102 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_SPHERE_EMITTER_H_INCLUDED__
#define __C_PARTICLE_SPHERE_EMITTER_H_INCLUDED__
#include "IParticleSphereEmitter.h"
#include "irrArray.h"
#include "aabbox3d.h"
namespace irr
{
namespace scene
{
//! A default box emitter
class CParticleSphereEmitter : public IParticleSphereEmitter
{
public:
//! constructor
CParticleSphereEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 20,
u32 maxParticlesPerSecond = 40,
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);
//! Prepares an array with new particles to emitt into the system
//! and returns how much new particles there are.
virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
//! Set direction the emitter emits particles
virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
//! Set minimum number of particles per second.
virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
//! Set maximum number of particles per second.
virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
//! Set minimum start color
virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
//! Set maximum start color
virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
//! Set the center of the sphere for particle emissions
virtual void setCenter( const core::vector3df& center ) { Center = center; }
//! Set the radius of the sphere for particle emissions
virtual void setRadius( f32 radius ) { Radius = radius; }
//! Gets direction the emitter emits particles
virtual const core::vector3df& getDirection() const { return Direction; }
//! Get minimum number of particles per second.
virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
//! Get maximum number of particles per second.
virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
//! Get minimum start color
virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
//! Get maximum start color
virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
//! Get the center of the sphere for particle emissions
virtual const core::vector3df& getCenter() const { return Center; }
//! Get the radius of the sphere for particle emissions
virtual f32 getRadius() const { return Radius; }
private:
core::array<SParticle> Particles;
core::vector3df Center;
f32 Radius;
core::vector3df Direction;
u32 MinParticlesPerSecond, MaxParticlesPerSecond;
video::SColor MinStartColor, MaxStartColor;
u32 MinLifeTime, MaxLifeTime;
u32 Time;
u32 Emitted;
s32 MaxAngleDegrees;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -8,8 +8,13 @@
#include "ICameraSceneNode.h"
#include "IVideoDriver.h"
#include "CParticlePointEmitter.h"
#include "CParticleAnimatedMeshSceneNodeEmitter.h"
#include "CParticleBoxEmitter.h"
#include "CParticleCylinderEmitter.h"
#include "CParticleMeshEmitter.h"
#include "CParticlePointEmitter.h"
#include "CParticleRingEmitter.h"
#include "CParticleSphereEmitter.h"
#include "CParticleAttractionAffector.h"
#include "CParticleFadeOutAffector.h"
#include "CParticleGravityAffector.h"
@ -106,34 +111,117 @@ u32 CParticleSystemSceneNode::getMaterialCount()
}
//! Creates a point particle emitter.
IParticleEmitter* CParticleSystemSceneNode::createPointEmitter(
const core::vector3df& direction, u32 minParticlesPerSecond,
u32 maxParticlePerSecond, video::SColor minStartColor,
video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
//! Creates a particle emitter for an animated mesh scene node
IParticleAnimatedMeshSceneNodeEmitter*
CParticleSystemSceneNode::createAnimatedMeshSceneNodeEmitter(
scene::IAnimatedMeshSceneNode* node, bool useNormalDirection,
const core::vector3df& direction, f32 normalDirectionModifier,
s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees )
{
return new CParticlePointEmitter(direction, minParticlesPerSecond,
maxParticlePerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
return new CParticleAnimatedMeshSceneNodeEmitter( node,
useNormalDirection, direction, normalDirectionModifier,
mbNumber, everyMeshVertex,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees );
}
//! Creates a box particle emitter.
IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter(
IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter(
const core::aabbox3df& box, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlePerSecond,
video::SColor minStartColor, video::SColor maxStartColor,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
{
return new CParticleBoxEmitter(box, direction, minParticlesPerSecond,
maxParticlePerSecond, minStartColor, maxStartColor,
maxParticlesPerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
}
//! Creates a particle emitter for emitting from a cylinder
IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
bool outlineOnly, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees )
{
return new CParticleCylinderEmitter( center, radius, normal, length,
outlineOnly, direction,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees );
}
//! Creates a mesh particle emitter.
IParticleMeshEmitter* CParticleSystemSceneNode::createMeshEmitter(
scene::IMesh* mesh, bool useNormalDirection,
const core::vector3df& direction, f32 normalDirectionModifier,
s32 mbNumber, bool everyMeshVertex,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees )
{
return new CParticleMeshEmitter( mesh, useNormalDirection, direction,
normalDirectionModifier, mbNumber, everyMeshVertex,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees );
}
//! Creates a point particle emitter.
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)
{
return new CParticlePointEmitter(direction, minParticlesPerSecond,
maxParticlesPerSecond, minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
}
//! Creates a ring particle emitter.
IParticleRingEmitter* CParticleSystemSceneNode::createRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees )
{
return new CParticleRingEmitter( center, radius, ringThickness, direction,
minParticlesPerSecond, maxParticlesPerSecond, minStartColor,
maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees );
}
//! Creates a sphere particle emitter.
IParticleSphereEmitter* CParticleSystemSceneNode::createSphereEmitter(
const core::vector3df& center, f32 radius, const core::vector3df& direction,
u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
const video::SColor& minStartColor, const video::SColor& maxStartColor,
u32 lifeTimeMin, u32 lifeTimeMax,
s32 maxAngleDegrees)
{
return new CParticleSphereEmitter(center, radius, direction,
minParticlesPerSecond, maxParticlesPerSecond,
minStartColor, maxStartColor,
lifeTimeMin, lifeTimeMax, maxAngleDegrees);
}
//! 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.

View File

@ -57,24 +57,82 @@ public:
//! returns the axis aligned bounding box of this node
virtual const core::aabbox3d<f32>& getBoundingBox() const;
//! Creates a point particle emitter.
virtual IParticleEmitter* createPointEmitter(
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlePerSecond = 10,
video::SColor minStartColor = video::SColor(255,0,0,0),
video::SColor maxStartColor = video::SColor(255,255,255,255),
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0);
//! Creates a particle emitter for an animated mesh scene node
virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(
scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false, u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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 );
//! Creates a box particle emitter.
virtual IParticleEmitter* createBoxEmitter(
virtual IParticleBoxEmitter* createBoxEmitter(
const core::aabbox3df& box = core::aabbox3d<f32>(-10,0,-10,5,30,10),
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlePerSecond = 10,
video::SColor minStartColor = video::SColor(255,0,0,0),
video::SColor maxStartColor = video::SColor(255,255,255,255),
u32 maxParticlesPerSecond = 10,
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);
//! Creates a particle emitter for emitting from a cylinder
virtual IParticleCylinderEmitter* createCylinderEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& normal, f32 length,
bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
u32 minParticlesPerSecond = 5, u32 maxParticlesPersSecond = 10,
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 );
//! Creates a mesh particle emitter.
virtual IParticleMeshEmitter* createMeshEmitter(
scene::IMesh* mesh, bool useNormalDirection = true,
const core::vector3df& direction = core::vector3df(0.0f,0.0f,0.0f),
f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
bool everyMeshVertex = false,
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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 );
//! Creates a point particle emitter.
virtual IParticlePointEmitter* createPointEmitter(
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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);
//! Creates a ring particle emitter.
virtual IParticleRingEmitter* createRingEmitter(
const core::vector3df& center, f32 radius, f32 ringThickness,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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);
//! Creates a sphere particle emitter.
virtual IParticleSphereEmitter* createSphereEmitter(
const core::vector3df& center, f32 radius,
const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
u32 minParticlesPerSecond = 5,
u32 maxParticlesPerSecond = 10,
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);

View File

@ -19,7 +19,7 @@ VERSION = 1.3.1
#
#List of object files, separated based on engine architecture
IRROBJ = C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o CMD3MeshFileLoader.o CAnimatedMeshMS3D.o CAnimatedMeshB3d.o CAnimatedMeshSceneNode.o CBillboardSceneNode.o CCameraFPSSceneNode.o CCameraMayaSceneNode.o CCameraSceneNode.o CColladaFileLoader.o CCSMLoader.o CDefaultMeshFormatLoader.o CDMFLoader.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CLMTSMeshFileLoader.o CMeshManipulator.o CMeshSceneNode.o CMetaTriangleSelector.o CMY3DMeshFileLoader.o COCTLoader.o COctTreeSceneNode.o COctTreeTriangleSelector.o CParticleBoxEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticlePointEmitter.o CParticleSystemSceneNode.o CQ3LevelMesh.o CSceneCollisionManager.o CSceneManager.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CXAnimationPlayer.o CXFileReader.o CXMeshFileLoader.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CQuake3ShaderSceneNode.o
IRROBJ = C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o CMD3MeshFileLoader.o CAnimatedMeshMS3D.o CAnimatedMeshB3d.o CAnimatedMeshSceneNode.o CBillboardSceneNode.o CCameraFPSSceneNode.o CCameraMayaSceneNode.o CCameraSceneNode.o CColladaFileLoader.o CCSMLoader.o CDefaultMeshFormatLoader.o CDMFLoader.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CLMTSMeshFileLoader.o CMeshManipulator.o CMeshSceneNode.o CMetaTriangleSelector.o CMY3DMeshFileLoader.o COCTLoader.o COctTreeSceneNode.o COctTreeTriangleSelector.o CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CQ3LevelMesh.o CSceneCollisionManager.o CSceneManager.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CXAnimationPlayer.o CXFileReader.o CXMeshFileLoader.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CQuake3ShaderSceneNode.o
IRRVIDEOOBJ = COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CColorConverter.o CFPSCounter.o CImage.o CImageLoaderBMP.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o CNullDriver.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o CVideoModeList.o
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o
IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o