diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleAffector.h Irrlicht_starsonata/include/IParticleAffector.h --- irrlicht-svn-ss/trunk/include/IParticleAffector.h 2007-07-26 02:11:22.000000000 +0200 +++ Irrlicht_starsonata/include/IParticleAffector.h 2008-06-04 00:40:52.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -17,8 +17,10 @@ namespace scene enum E_PARTICLE_AFFECTOR_TYPE { EPAT_NONE = 0, + EPAT_ATTRACT, EPAT_FADE_OUT, EPAT_GRAVITY, + EPAT_ROTATE, EPAT_COUNT }; @@ -26,8 +28,10 @@ enum E_PARTICLE_AFFECTOR_TYPE const c8* const ParticleAffectorTypeNames[] = { "None", + "Attract", "FadeOut", "Gravity", + "Rotate", 0 }; @@ -46,15 +50,15 @@ public: virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; //! Sets whether or not the affector is currently enabled. - virtual void setEnabled(bool enabled) {Enabled = enabled;} + virtual void setEnabled(bool enabled) { Enabled = enabled; } //! Gets whether or not the affector is currently enabled. - virtual bool getEnabled() const { return Enabled;} + virtual bool getEnabled() const { return Enabled; } //! Writes attributes of the object. //! Implement this to expose the attributes of your scene node animator for //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} //! Reads attributes of the object. //! Implement this to set the attributes of your scene node animator for diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleAnimatedMeshSceneNodeEmitter.h Irrlicht_starsonata/include/IParticleAnimatedMeshSceneNodeEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleAnimatedMeshSceneNodeEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleAnimatedMeshSceneNodeEmitter.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,56 @@ +// Copyright (C) 2002-2008 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: + + //! 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* 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; + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_ANIMATED_MESH; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleAttractionAffector.h Irrlicht_starsonata/include/IParticleAttractionAffector.h --- irrlicht-svn-ss/trunk/include/IParticleAttractionAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleAttractionAffector.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,59 @@ +// Copyright (C) 2002-2008 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector which attracts or detracts particles. +class IParticleAttractionAffector : public IParticleAffector +{ +public: + + //! Set the point that particles will attract to + virtual void setPoint( const core::vector3df& point ) = 0; + + //! Set whether or not the particles are attracting or detracting + virtual void setAttract( bool attract ) = 0; + + //! Set whether or not this will affect particles in the X direction + virtual void setAffectX( bool affect ) = 0; + + //! Set whether or not this will affect particles in the Y direction + virtual void setAffectY( bool affect ) = 0; + + //! Set whether or not this will affect particles in the Z direction + virtual void setAffectZ( bool affect ) = 0; + + //! Get the point that particles are attracted to + virtual const core::vector3df& getPoint() const = 0; + + //! Get whether or not the particles are attracting or detracting + virtual bool getAttract() const = 0; + + //! Get whether or not the particles X position are affected + virtual bool getAffectX() const = 0; + + //! Get whether or not the particles Y position are affected + virtual bool getAffectY() const = 0; + + //! Get whether or not the particles Z position are affected + virtual bool getAffectZ() const = 0; + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_ATTRACT; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleBoxEmitter.h Irrlicht_starsonata/include/IParticleBoxEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleBoxEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleBoxEmitter.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,36 @@ +// Copyright (C) 2002-2008 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: + + //! 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 + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleCylinderEmitter.h Irrlicht_starsonata/include/IParticleCylinderEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleCylinderEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleCylinderEmitter.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,59 @@ +// Copyright (C) 2002-2008 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: + + //! 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; + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_CYLINDER; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleEmitter.h Irrlicht_starsonata/include/IParticleEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleEmitter.h 2007-07-26 02:11:22.000000000 +0200 +++ Irrlicht_starsonata/include/IParticleEmitter.h 2008-06-04 00:40:52.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -17,7 +17,12 @@ namespace scene enum E_PARTICLE_EMITTER_TYPE { EPET_POINT = 0, + EPET_ANIMATED_MESH, EPET_BOX, + EPET_CYLINDER, + EPET_MESH, + EPET_RING, + EPET_SPHERE, EPET_COUNT }; @@ -25,7 +30,12 @@ enum E_PARTICLE_EMITTER_TYPE const c8* const ParticleEmitterTypeNames[] = { "Point", + "AnimatedMesh", "Box", + "Cylinder", + "Mesh", + "Ring", + "Sphere", 0 }; @@ -36,9 +46,6 @@ class IParticleEmitter : public virtual { public: - //! destructor - virtual ~IParticleEmitter() {}; - //! Prepares an array with new particles to emitt into the system //! and returns how much new particles there are. //! \param now: Current time. @@ -48,10 +55,40 @@ public: //! \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 //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) {} + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const {} //! Reads attributes of the object. //! Implement this to set the attributes of your scene node animator for @@ -63,9 +100,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 diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleFadeOutAffector.h Irrlicht_starsonata/include/IParticleFadeOutAffector.h --- irrlicht-svn-ss/trunk/include/IParticleFadeOutAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleFadeOutAffector.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,43 @@ +// Copyright (C) 2002-2008 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_FADE_OUT_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector which fades out the particles. +class IParticleFadeOutAffector : public IParticleAffector +{ +public: + + //! Sets the targetColor, i.e. the color the particles will interpolate + //! to over time. + virtual void setTargetColor( const video::SColor& targetColor ) = 0; + + //! Sets the amount of time it takes for each particle to fade out. + virtual void setFadeOutTime( f32 fadeOutTime ) = 0; + + //! Gets the targetColor, i.e. the color the particles will interpolate + //! to over time. + virtual const video::SColor& getTargetColor() const = 0; + + //! Gets the amount of time it takes for each particle to fade out. + virtual f32 getFadeOutTime() const = 0; + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_FADE_OUT; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleGravityAffector.h Irrlicht_starsonata/include/IParticleGravityAffector.h --- irrlicht-svn-ss/trunk/include/IParticleGravityAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleGravityAffector.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,43 @@ +// Copyright (C) 2002-2008 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_GRAVITY_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector which applies gravity to particles. +class IParticleGravityAffector : public IParticleAffector +{ +public: + + //! Set the time in milliseconds when the gravity force is totally + //! lost and the particle does not move any more. + virtual void setTimeForceLost( f32 timeForceLost ) = 0; + + //! Set the direction and force of gravity in all 3 dimensions. + virtual void setGravity( const core::vector3df& gravity ) = 0; + + //! Get the time in milliseconds when the gravity force is totally + //! lost and the particle does not move any more. + virtual f32 getTimeForceLost() const = 0; + + //! Get the direction and force of gravity. + virtual const core::vector3df& getGravity() const = 0; + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_GRAVITY; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleMeshEmitter.h Irrlicht_starsonata/include/IParticleMeshEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleMeshEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleMeshEmitter.h 2008-06-04 00:40:48.000000000 +0200 @@ -0,0 +1,56 @@ +// Copyright (C) 2002-2008 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: + + //! 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* 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; + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_MESH; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleRingEmitter.h Irrlicht_starsonata/include/IParticleRingEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleRingEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleRingEmitter.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,47 @@ +// Copyright (C) 2002-2008 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: + + //! 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; + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_RING; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleRotationAffector.h Irrlicht_starsonata/include/IParticleRotationAffector.h --- irrlicht-svn-ss/trunk/include/IParticleRotationAffector.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleRotationAffector.h 2008-06-04 00:40:52.000000000 +0200 @@ -0,0 +1,41 @@ +// Copyright (C) 2002-2008 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ +#define __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ + +#include "IParticleAffector.h" + +namespace irr +{ +namespace scene +{ + +//! A particle affector which rotates the particle system. +class IParticleRotationAffector : public IParticleAffector +{ +public: + + //! Set the point that particles will rotate around + virtual void setPivotPoint( const core::vector3df& point ) = 0; + + //! Set the speed in degrees per second in all 3 dimensions + virtual void setSpeed( const core::vector3df& speed ) = 0; + + //! Get the point that particles are attracted to + virtual const core::vector3df& getPivotPoint() const = 0; + + //! Get the speed in degrees per second in all 3 dimensions + virtual const core::vector3df& getSpeed() const = 0; + + //! Get emitter type + virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_ROTATE; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __I_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleSphereEmitter.h Irrlicht_starsonata/include/IParticleSphereEmitter.h --- irrlicht-svn-ss/trunk/include/IParticleSphereEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/IParticleSphereEmitter.h 2008-06-04 00:40:50.000000000 +0200 @@ -0,0 +1,41 @@ +// Copyright (C) 2002-2008 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: + + //! 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; + + //! Get emitter type + virtual E_PARTICLE_EMITTER_TYPE getType() const { return EPET_SPHERE; } +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IParticleSystemSceneNode.h Irrlicht_starsonata/include/IParticleSystemSceneNode.h --- irrlicht-svn-ss/trunk/include/IParticleSystemSceneNode.h 2007-07-26 02:11:22.000000000 +0200 +++ Irrlicht_starsonata/include/IParticleSystemSceneNode.h 2008-06-04 00:40:50.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -6,8 +6,16 @@ #define __I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__ #include "ISceneNode.h" -#include "IParticleEmitter.h" -#include "IParticleAffector.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" +#include "IParticleRotationAffector.h" #include "dimension2d.h" namespace irr @@ -39,7 +47,7 @@ class IParticleSystemSceneNode : public { public: - //! constructor + //! Constructor 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), @@ -50,130 +58,367 @@ public: virtual void setParticleSize( const core::dimension2d &size = core::dimension2d(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 - //! ignore it. Default is true. + //! 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 - //! 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 - //! for removing the current emitter and stopping the particle system - //! emitting new particles. + /** 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 for + removing the current emitter and stopping the particle system emitting + new particles. */ virtual void setEmitter(IParticleEmitter* emitter) = 0; - //! Adds new particle effector to the particle system. A particle - //! affector modifies the particles. For example, the FadeOut - //! affector lets all particles fade out after some time. It is created - //! and used in this way: IParticleAffector* p = createFadeOutParticleAffector(); - //! addAffector(p); p->drop(); - //! Please note that a affector is not necessary for the particle - //! system to work. - //! \param affector: New affector. + //! Adds new particle effector to the particle system. + /** A particle affector modifies the particles. For example, the FadeOut + affector lets all particles fade out after some time. It is created and + used in this way: + \code + IParticleAffector* p = createFadeOutParticleAffector(); + addAffector(p); + p->drop(); + \endcode + Please note that a affector is not necessary for the particle system to + work. + \param affector: New affector. */ virtual void addAffector(IParticleAffector* affector) = 0; //! Removes all particle affectors in the particle system. virtual void removeAllAffectors() = 0; + //! Creates a particle emitter for an animated mesh scene node + /** \param node: Pointer to the animated mesh scene node to emit + particles from + \param useNormalDirection: If true, the direction of each particle + created will be the normal of the vertex that it's emitting from. The + normal is divided by the normalDirectionModifier parameter, which + defaults to 100.0f. + \param direction: Direction and speed of particle emission. + \param normalDirectionModifier: If the emitter is using the normal + direction then the normal of the vertex that is being emitted from is + divided by this number. + \param mbNumber: This allows you to specify a specific meshBuffer for + the IMesh* to emit particles from. The default value is -1, which + means a random meshBuffer picked from all of the meshes meshBuffers + will be selected to pick a random vertex from. If the value is 0 or + greater, it will only pick random vertices from the meshBuffer + specified by this value. + \param everyMeshVertex: If true, the emitter will emit between min/max + particles every second, for every vertex in the mesh, if false, it will + emit between min/max particles from random vertices in the mesh. + \param minParticlesPerSecond: Minimal amount of particles emitted per + second. + \param maxParticlesPerSecond: Maximal amount of particles emitted per + second. + \param minStartColor: Minimal initial start color of a particle. The + real color of every particle is calculated as random interpolation + between minStartColor and maxStartColor. + \param maxStartColor: Maximal initial start color of a particle. The + real color of every particle is calculated as random interpolation + between minStartColor and maxStartColor. + \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds. + \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds. + \param maxAngleDegrees: Maximal angle in degrees, the emitting + direction of the particle will differ from the original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::drop() for more informations. */ + 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. + \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 original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::drop() for more informations. */ + 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), + 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 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 original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::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 original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::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 IParticleEmitter* createPointEmitter( + /** \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 original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::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, - 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 box particle emitter. - //! \param box: The box for the 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 IParticleEmitter* createBoxEmitter( - const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10), + //! 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 original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::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, - 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 fade out particle affector. This affector modifies - //! the color of every particle and and reaches the final color - //! when the particle dies. - //! This affector looks really good, if the EMT_TRANSPARENT_VERTEX_ALPHA - //! 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. - //! \return Returns a pointer to the created particle affector. - //! To add this affector as new affector of this particle system, - //! just call addAffector(). Note that you'll have to drop() the - //! returned pointer, after you don't need it any more, see - //! IUnknown::drop() for more informations. - virtual IParticleAffector* createFadeOutParticleAffector( - video::SColor targetColor = video::SColor(0,0,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 original direction. + \return Pointer to the created particle emitter. To set this emitter + as new emitter of this particle system, just call setEmitter(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::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; + + //! Creates a point attraction affector. + /** This affector modifies the positions of the particles and attracts + them to a specified point at a specified speed per second. + \param point: Point to attract particles to. + \param speed: Speed in units per second, to attract to the specified + point. + \param attract: Whether the particles attract or detract from this + point. + \param affectX: Whether or not this will affect the X position of the + particle. + \param affectY: Whether or not this will affect the Y position of the + particle. + \param affectZ: Whether or not this will affect the Z position of the + particle. + \return Pointer to the created particle affector. To add this affector + as new affector of this particle system, just call addAffector(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::drop() for more informations. */ + virtual IParticleAttractionAffector* createAttractionAffector( + const core::vector3df& point, f32 speed = 1.0f, bool attract = true, + bool affectX = true, bool affectY = true, bool affectZ = true) = 0; + + //! Creates a fade out particle affector. + /** This affector modifies the color of every particle and and reaches + the final color when the particle dies. This affector looks really + good, if the EMT_TRANSPARENT_VERTEX_ALPHA 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. + \return Pointer to the created particle affector. To add this affector + as new affector of this particle system, just call addAffector(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::drop() for more informations. */ + virtual IParticleFadeOutAffector* createFadeOutParticleAffector( + const video::SColor& targetColor = video::SColor(0,0,0,0), u32 timeNeededToFadeOut = 1000) = 0; - //! Creates a gravity affector. This affector modifies the direction - //! of the particle. It assumes that the particle is fired out of the - //! emitter with huge force, but is loosing this after some time - //! 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 - //! 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. - //! To add this affector as new affector of this particle system, - //! just call addAffector(). Note that you'll have to drop() the - //! returned pointer, after you don't need it any more, see - //! IUnknown::drop() for more informations. - virtual IParticleAffector* createGravityAffector( + //! Creates a gravity affector. + /** This affector modifies the direction of the particle. It assumes + that the particle is fired out of the emitter with huge force, but is + loosing this after some time 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 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 Pointer to the created particle affector. To add this affector + as new affector of this particle system, just call addAffector(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::drop() for more informations. */ + virtual IParticleGravityAffector* createGravityAffector( const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), u32 timeForceLost = 1000) = 0; + + //! Creates a rotation affector. + /** This affector modifies the positions of the particles and attracts + them to a specified point at a specified speed per second. + \param speed: Rotation in degrees per second + \param pivotPoint: Point to rotate the particles around + \return Pointer to the created particle affector. To add this affector + as new affector of this particle system, just call addAffector(). Note + that you'll have to drop() the returned pointer, after you don't need + it any more, see IReferenceCounted::drop() for more informations. */ + virtual IParticleRotationAffector* createRotationAffector( + const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f), + const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) = 0; }; } // end namespace scene diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp Irrlicht_starsonata/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp 2008-07-31 00:19:32.000000000 +0200 @@ -0,0 +1,210 @@ +// Copyright (C) 2002-2008 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( core::floor32(Node->getFrameNr()), + 255, Node->getStartFrame(), Node->getEndFrame() ); + for(u32 i=0; igetMeshBufferCount(); ++j ) + { + for( u32 k=0; kgetMeshBuffer(j)->getVertexCount(); ++k ) + { + switch( frameMesh->getMeshBuffer(j)->getVertexType() ) + { + case video::EVT_STANDARD: + p.pos = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertex*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / NormalDirectionModifier; + else + p.vector = Direction; + break; + case video::EVT_TANGENTS: + p.pos = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Pos; + if( UseNormalDirection ) + p.vector = ((video::S3DVertexTangents*)frameMesh->getMeshBuffer(j)->getVertices())[k].Normal / + NormalDirectionModifier; + else + p.vector = Direction; + break; + } + + p.startTime = now; + + if( MaxAngleDegrees ) + { + core::vector3df tgt = p.vector; + tgt.rotateXYBy((os::Randomizer::rand()%(MaxAngleDegrees*2)) - MaxAngleDegrees, core::vector3df()); + 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 vertexCount = frameMesh->getMeshBuffer(randomMB)->getVertexCount(); + if ( !vertexCount ) + continue; + u32 vertexNumber = os::Randomizer::rand() % vertexCount; + + 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 + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h Irrlicht_starsonata/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.h 2008-06-04 00:40:42.000000000 +0200 @@ -0,0 +1,127 @@ +// Copyright (C) 2002-2008 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* 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; + const IMesh* BaseMesh; + s32 TotalVertices; + u32 MBCount; + s32 MBNumber; + core::array VertexPerMeshBufferList; + + bool EveryMeshVertex; + bool UseNormalDirection; + f32 NormalDirectionModifier; + core::array Particles; + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __C_PARTICLE_ANIMATED_MESH_SCENE_NODE_EMITTER_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleAttractionAffector.cpp Irrlicht_starsonata/source/Irrlicht/CParticleAttractionAffector.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleAttractionAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleAttractionAffector.cpp 2008-06-04 00:40:34.000000000 +0200 @@ -0,0 +1,59 @@ +// Copyright (C) 2002-2008 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleAttractionAffector.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleAttractionAffector::CParticleAttractionAffector( + const core::vector3df& point, f32 speed, bool attract, + bool affectX, bool affectY, bool affectZ ) + : Point(point), Speed(speed), AffectX(affectX), AffectY(affectY), + AffectZ(affectZ), Attract(attract), LastTime(0) +{ +} + + +//! Affects an array of particles. +void CParticleAttractionAffector::affect(u32 now, SParticle* particlearray, u32 count) +{ + if( LastTime == 0 ) + { + LastTime = now; + return; + } + + f32 timeDelta = ( now - LastTime ) / 1000.0f; + LastTime = now; + + if( !Enabled ) + return; + + for(u32 i=0; i 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; igetAttributeAsInt("MinParticlesPerSecond"); MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); - MinParticlesPerSecond = core::max_(1, MinParticlesPerSecond); - MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1); - MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200); - MinParticlesPerSecond = core::min_(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::deserializeAttr MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); - MinLifeTime = core::max_(0, MinLifeTime); - MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); - MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); + MinLifeTime = core::max_(0u, MinLifeTime); + MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); + MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); return in->findAttribute("MaxAngleDegrees"); } diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleBoxEmitter.h Irrlicht_starsonata/source/Irrlicht/CParticleBoxEmitter.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleBoxEmitter.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleBoxEmitter.h 2008-06-04 00:40:40.000000000 +0200 @@ -1,11 +1,11 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 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_BOX_EMITTER_H_INCLUDED__ #define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__ -#include "IParticleEmitter.h" +#include "IParticleBoxEmitter.h" #include "irrArray.h" #include "aabbox3d.h" @@ -15,7 +15,7 @@ namespace scene { //! A default box emitter -class CParticleBoxEmitter : public IParticleEmitter +class CParticleBoxEmitter : public IParticleBoxEmitter { public: @@ -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); + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; //! 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 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; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleCylinderEmitter.cpp Irrlicht_starsonata/source/Irrlicht/CParticleCylinderEmitter.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleCylinderEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleCylinderEmitter.cpp 2008-06-04 00:40:36.000000000 +0200 @@ -0,0 +1,108 @@ +// Copyright (C) 2002-2008 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 Particles; + + core::vector3df Center; + core::vector3df Normal; + f32 Radius; + f32 Length; + bool OutlineOnly; + + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleFadeOutAffector.cpp Irrlicht_starsonata/source/Irrlicht/CParticleFadeOutAffector.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleFadeOutAffector.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleFadeOutAffector.cpp 2008-06-04 00:40:42.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -13,10 +13,10 @@ namespace scene //! constructor CParticleFadeOutAffector::CParticleFadeOutAffector( - video::SColor targetColor, u32 fadeOutTime) - : IParticleAffector(), TargetColor(targetColor) + const video::SColor& targetColor, u32 fadeOutTime) + : IParticleFadeOutAffector(), TargetColor(targetColor) { - FadeOutTime = fadeOutTime ? (f32)fadeOutTime : 1.0f; + FadeOutTime = fadeOutTime ? static_cast(fadeOutTime) : 1.0f; } @@ -42,7 +42,7 @@ void CParticleFadeOutAffector::affect(u3 //! Writes attributes of the object. //! Implement this to expose the attributes of your scene node animator for //! scripting languages, editors, debuggers or xml serialization purposes. -void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const { out->addColor("TargetColor", TargetColor); out->addFloat("FadeOutTime", FadeOutTime); diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleFadeOutAffector.h Irrlicht_starsonata/source/Irrlicht/CParticleFadeOutAffector.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleFadeOutAffector.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleFadeOutAffector.h 2008-06-04 00:40:36.000000000 +0200 @@ -1,11 +1,11 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 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_FADE_OUT_AFFECTOR_H_INCLUDED__ #define __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ -#include "IParticleAffector.h" +#include "IParticleFadeOutAffector.h" #include "SColor.h" namespace irr @@ -14,19 +14,33 @@ namespace scene { //! Particle Affector for fading out a color -class CParticleFadeOutAffector : public IParticleAffector +class CParticleFadeOutAffector : public IParticleFadeOutAffector { public: - CParticleFadeOutAffector(video::SColor targetColor, u32 fadeOutTime); + CParticleFadeOutAffector(const video::SColor& targetColor, u32 fadeOutTime); //! Affects a particle. virtual void affect(u32 now, SParticle* particlearray, u32 count); + //! Sets the targetColor, i.e. the color the particles will interpolate + //! to over time. + virtual void setTargetColor( const video::SColor& targetColor ) { TargetColor = targetColor; } + + //! Sets the amount of time it takes for each particle to fade out. + virtual void setFadeOutTime( f32 fadeOutTime ) { FadeOutTime = fadeOutTime; } + + //! Sets the targetColor, i.e. the color the particles will interpolate + //! to over time. + virtual const video::SColor& getTargetColor() const { return TargetColor; } + + //! Sets the amount of time it takes for each particle to fade out. + virtual f32 getFadeOutTime() const { return FadeOutTime; } + //! Writes attributes of the object. //! Implement this to expose the attributes of your scene node animator for //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; //! Reads attributes of the object. //! Implement this to set the attributes of your scene node animator for @@ -35,9 +49,6 @@ public: //! \return: returns last index of an attribute read by this affector virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_FADE_OUT; } - private: video::SColor TargetColor; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleGravityAffector.cpp Irrlicht_starsonata/source/Irrlicht/CParticleGravityAffector.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleGravityAffector.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleGravityAffector.cpp 2008-06-04 00:40:42.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -14,7 +14,7 @@ namespace scene //! constructor CParticleGravityAffector::CParticleGravityAffector( const core::vector3df& gravity, u32 timeForceLost) - : IParticleAffector(), TimeForceLost((f32)timeForceLost), Gravity(gravity) + : IParticleGravityAffector(), TimeForceLost(static_cast(timeForceLost)), Gravity(gravity) { } @@ -40,7 +40,7 @@ void CParticleGravityAffector::affect(u3 } //! Writes attributes of the object. -void CParticleGravityAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +void CParticleGravityAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const { out->addVector3d("Gravity", Gravity); out->addFloat("TimeForceLost", TimeForceLost); diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleGravityAffector.h Irrlicht_starsonata/source/Irrlicht/CParticleGravityAffector.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleGravityAffector.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleGravityAffector.h 2008-06-04 00:40:38.000000000 +0200 @@ -1,11 +1,11 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 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_GRAVITY_AFFECTOR_H_INCLUDED__ #define __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ -#include "IParticleAffector.h" +#include "IParticleGravityAffector.h" #include "SColor.h" namespace irr @@ -14,7 +14,7 @@ namespace scene { //! Particle Affector for affecting direction of particle -class CParticleGravityAffector : public IParticleAffector +class CParticleGravityAffector : public IParticleGravityAffector { public: @@ -25,10 +25,24 @@ public: //! Affects a particle. virtual void affect(u32 now, SParticle* particlearray, u32 count); + //! Set the time in milliseconds when the gravity force is totally + //! lost and the particle does not move any more. + virtual void setTimeForceLost( f32 timeForceLost ) { TimeForceLost = timeForceLost; } + + //! Set the direction and force of gravity. + virtual void setGravity( const core::vector3df& gravity ) { Gravity = gravity; } + + //! Set the time in milliseconds when the gravity force is totally + //! lost and the particle does not move any more. + virtual f32 getTimeForceLost() const { return TimeForceLost; } + + //! Set the direction and force of gravity. + virtual const core::vector3df& getGravity() const { return Gravity; } + //! Writes attributes of the object. //! Implement this to expose the attributes of your scene node animator for //! scripting languages, editors, debuggers or xml serialization purposes. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; //! Reads attributes of the object. //! Implement this to set the attributes of your scene node animator for @@ -37,9 +51,6 @@ public: //! \return: returns last index of an attribute read by this affector virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); - //! Get emitter type - virtual E_PARTICLE_AFFECTOR_TYPE getType() const { return EPAT_GRAVITY; } - private: f32 TimeForceLost; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleMeshEmitter.cpp Irrlicht_starsonata/source/Irrlicht/CParticleMeshEmitter.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleMeshEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleMeshEmitter.cpp 2008-06-04 00:40:42.000000000 +0200 @@ -0,0 +1,199 @@ +// Copyright (C) 2002-2008 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 + +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; igetMeshBufferCount(); ++j ) + { + for( u32 k=0; kgetMeshBuffer(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 + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleMeshEmitter.h Irrlicht_starsonata/source/Irrlicht/CParticleMeshEmitter.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleMeshEmitter.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleMeshEmitter.h 2008-06-04 00:40:40.000000000 +0200 @@ -0,0 +1,126 @@ +// Copyright (C) 2002-2008 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* 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: + + const IMesh* Mesh; + s32 TotalVertices; + u32 MBCount; + s32 MBNumber; + core::array VertexPerMeshBufferList; + + bool EveryMeshVertex; + bool UseNormalDirection; + f32 NormalDirectionModifier; + core::array Particles; + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif // __C_PARTICLE_MESH_EMITTER_H_INCLUDED__ + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticlePointEmitter.cpp Irrlicht_starsonata/source/Irrlicht/CParticlePointEmitter.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticlePointEmitter.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticlePointEmitter.cpp 2008-06-04 00:40:34.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -72,7 +72,7 @@ s32 CParticlePointEmitter::emitt(u32 now //! Writes attributes of the object. -void CParticlePointEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +void CParticlePointEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const { out->addVector3d("Direction", Direction); out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); @@ -95,10 +95,10 @@ s32 CParticlePointEmitter::deserializeAt MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); - MinParticlesPerSecond = core::max_(1, MinParticlesPerSecond); - MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1); - MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200); - MinParticlesPerSecond = core::min_(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::deserializeAt MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); - MinLifeTime = core::max_(0, MinLifeTime); - MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); - MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); + MinLifeTime = core::max_(0u, MinLifeTime); + MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); + MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); return in->findAttribute("MaxAngleDegrees"); } diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticlePointEmitter.h Irrlicht_starsonata/source/Irrlicht/CParticlePointEmitter.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticlePointEmitter.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticlePointEmitter.h 2008-06-04 00:40:36.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -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); + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; //! 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; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleRingEmitter.cpp Irrlicht_starsonata/source/Irrlicht/CParticleRingEmitter.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleRingEmitter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleRingEmitter.cpp 2008-06-04 00:40:34.000000000 +0200 @@ -0,0 +1,99 @@ +// Copyright (C) 2002-2008 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 Particles; + + core::vector3df Center; + f32 Radius; + f32 RingThickness; + + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; + + f32 MinimumDistance; + f32 MaximumDistance; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleRotationAffector.cpp Irrlicht_starsonata/source/Irrlicht/CParticleRotationAffector.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleRotationAffector.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/CParticleRotationAffector.cpp 2008-06-04 00:40:40.000000000 +0200 @@ -0,0 +1,50 @@ +// Copyright (C) 2002-2008 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CParticleRotationAffector.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CParticleRotationAffector::CParticleRotationAffector( const core::vector3df& speed, const core::vector3df& pivotPoint ) + : PivotPoint(pivotPoint), Speed(speed), LastTime(0) +{ +} + + +//! Affects an array of particles. +void CParticleRotationAffector::affect(u32 now, SParticle* particlearray, u32 count) +{ + if( LastTime == 0 ) + { + LastTime = now; + return; + } + + f32 timeDelta = ( now - LastTime ) / 1000.0f; + LastTime = now; + + if( !Enabled ) + return; + + for(u32 i=0; i + +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 Particles; + + core::vector3df Center; + f32 Radius; + + core::vector3df Direction; + u32 MinParticlesPerSecond, MaxParticlesPerSecond; + video::SColor MinStartColor, MaxStartColor; + u32 MinLifeTime, MaxLifeTime; + + u32 Time; + u32 Emitted; + s32 MaxAngleDegrees; +}; + +} // end namespace scene +} // end namespace irr + + +#endif + diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleSystemSceneNode.cpp Irrlicht_starsonata/source/Irrlicht/CParticleSystemSceneNode.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleSystemSceneNode.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleSystemSceneNode.cpp 2008-07-25 19:26:54.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -8,10 +8,17 @@ #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" +#include "CParticleRotationAffector.h" #include "SViewFrustum.h" namespace irr @@ -104,51 +111,154 @@ u32 CParticleSystemSceneNode::getMateria } +//! 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 CParticleAnimatedMeshSceneNodeEmitter( node, + useNormalDirection, direction, normalDirectionModifier, + mbNumber, everyMeshVertex, + minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, + lifeTimeMin, lifeTimeMax, maxAngleDegrees ); +} + + + +//! Creates a box particle emitter. +IParticleBoxEmitter* CParticleSystemSceneNode::createBoxEmitter( + const core::aabbox3df& box, const core::vector3df& direction, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, + const video::SColor& minStartColor, const video::SColor& maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees) +{ + return new CParticleBoxEmitter(box, direction, minParticlesPerSecond, + 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. -IParticleEmitter* CParticleSystemSceneNode::createPointEmitter( +IParticlePointEmitter* CParticleSystemSceneNode::createPointEmitter( const core::vector3df& direction, u32 minParticlesPerSecond, - u32 maxParticlePerSecond, video::SColor minStartColor, - video::SColor maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, + u32 maxParticlesPerSecond, const video::SColor& minStartColor, + const video::SColor& maxStartColor, u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees) { return new CParticlePointEmitter(direction, minParticlesPerSecond, - maxParticlePerSecond, minStartColor, maxStartColor, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees); } -//! Creates a box particle emitter. -IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter( - const core::aabbox3df& box, const core::vector3df& direction, - u32 minParticlesPerSecond, u32 maxParticlePerSecond, - video::SColor minStartColor, video::SColor maxStartColor, +//! 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 CParticleBoxEmitter(box, direction, minParticlesPerSecond, - maxParticlePerSecond, minStartColor, maxStartColor, + 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. +IParticleAttractionAffector* CParticleSystemSceneNode::createAttractionAffector( + const core::vector3df& point, f32 speed, bool attract, + bool affectX, bool affectY, bool affectZ ) +{ + return new CParticleAttractionAffector( point, speed, attract, affectX, affectY, affectZ ); +} + + //! Creates a fade out particle affector. -IParticleAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( - video::SColor targetColor, u32 timeNeededToFadeOut) +IParticleFadeOutAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( + const video::SColor& targetColor, u32 timeNeededToFadeOut) { return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); } //! Creates a gravity affector. -IParticleAffector* CParticleSystemSceneNode::createGravityAffector( +IParticleGravityAffector* CParticleSystemSceneNode::createGravityAffector( const core::vector3df& gravity, u32 timeForceLost) { return new CParticleGravityAffector(gravity, timeForceLost); } +//! Creates a rotation affector. This affector rotates the particles around a specified pivot +//! point. The speed represents Degrees of rotation per second. +IParticleRotationAffector* CParticleSystemSceneNode::createRotationAffector( + const core::vector3df& speed, const core::vector3df& pivotPoint ) +{ + return new CParticleRotationAffector( speed, pivotPoint ); +} + + + //! pre render event void CParticleSystemSceneNode::OnRegisterSceneNode() { @@ -247,9 +357,9 @@ void CParticleSystemSceneNode::render() if ( DebugDataVisible & scene::EDS_BBOX ) { driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); - video::SMaterial m; - m.Lighting = false; - driver->setMaterial(m); + video::SMaterial deb_m; + deb_m.Lighting = false; + driver->setMaterial(deb_m); driver->draw3DBox(Buffer.BoundingBox, video::SColor(0,255,255,255)); } } @@ -312,7 +422,7 @@ void CParticleSystemSceneNode::doParticl // animate all particles f32 scale = (f32)timediff; - for (s32 i=0; i<(s32)Particles.size();) + for (u32 i=0; i Particles[i].endTime) Particles.erase(i); @@ -473,7 +583,7 @@ void CParticleSystemSceneNode::deseriali break; } - s32 idx = 0; + u32 idx = 0; if (Emitter) idx = Emitter->deserializeAttributes(idx, in); @@ -483,7 +593,7 @@ void CParticleSystemSceneNode::deseriali // read affectors removeAllAffectors(); - s32 cnt = in->getAttributeCount(); + u32 cnt = in->getAttributeCount(); while(idx < cnt) { diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CParticleSystemSceneNode.h Irrlicht_starsonata/source/Irrlicht/CParticleSystemSceneNode.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CParticleSystemSceneNode.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CParticleSystemSceneNode.h 2008-07-25 19:26:50.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -57,37 +57,107 @@ public: //! returns the axis aligned bounding box of this node virtual const core::aabbox3d& getBoundingBox() const; + //! 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 IParticleBoxEmitter* createBoxEmitter( + const core::aabbox3df& box = core::aabbox3d(-10,0,-10,5,30,10), + 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 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 IParticleEmitter* createPointEmitter( + virtual IParticlePointEmitter* 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 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( - const core::aabbox3df& box = core::aabbox3d(-10,0,-10,5,30,10), + //! 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 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 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); + + //! Creates a point attraction affector. This affector modifies the positions of the + //! particles and attracts them to a specified point at a specified speed per second. + virtual IParticleAttractionAffector* createAttractionAffector( + const core::vector3df& point, f32 speed = 1.0f, bool attract = true, + bool affectX = true, bool affectY = true, bool affectZ = true); + //! Creates a fade out particle affector. - virtual IParticleAffector* createFadeOutParticleAffector( - video::SColor targetColor = video::SColor(0,0,0,0), + virtual IParticleFadeOutAffector* createFadeOutParticleAffector( + const video::SColor& targetColor = video::SColor(0,0,0,0), u32 timeNeededToFadeOut = 1000); //! Creates a gravity affector. - virtual IParticleAffector* createGravityAffector( + virtual IParticleGravityAffector* createGravityAffector( const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), u32 timeForceLost = 1000); + //! Creates a rotation affector. This affector rotates the particles + //! around a specified pivot point. The speed is in Degrees per second. + virtual IParticleRotationAffector* createRotationAffector( + const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f), + const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ); + //! Sets the size of all particles. virtual void setParticleSize( const core::dimension2d &size = core::dimension2d(5.0f, 5.0f));