Commit 9a1db251 authored by hybrid's avatar hybrid

Added particle affectors with interfaces from IrrSpintz.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@869 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0f0a06c2
...@@ -17,8 +17,10 @@ namespace scene ...@@ -17,8 +17,10 @@ namespace scene
enum E_PARTICLE_AFFECTOR_TYPE enum E_PARTICLE_AFFECTOR_TYPE
{ {
EPAT_NONE = 0, EPAT_NONE = 0,
EPAT_ATTRACT,
EPAT_FADE_OUT, EPAT_FADE_OUT,
EPAT_GRAVITY, EPAT_GRAVITY,
EPAT_ROTATE,
EPAT_COUNT EPAT_COUNT
}; };
...@@ -26,8 +28,10 @@ enum E_PARTICLE_AFFECTOR_TYPE ...@@ -26,8 +28,10 @@ enum E_PARTICLE_AFFECTOR_TYPE
const c8* const ParticleAffectorTypeNames[] = const c8* const ParticleAffectorTypeNames[] =
{ {
"None", "None",
"Attract",
"FadeOut", "FadeOut",
"Gravity", "Gravity",
"Rotate",
0 0
}; };
...@@ -46,10 +50,10 @@ public: ...@@ -46,10 +50,10 @@ public:
virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0; virtual void affect(u32 now, SParticle* particlearray, u32 count) = 0;
//! Sets whether or not the affector is currently enabled. //! 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. //! 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. //! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for //! Implement this to expose the attributes of your scene node animator for
......
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_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__
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_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;
//! Sets the targetColor, i.e.the color the particles will interpolate
//! to over time.
virtual const video::SColor& getTargetColor() const = 0;
//! Sets 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__
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_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__
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_PARTICLE_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__
...@@ -7,7 +7,10 @@ ...@@ -7,7 +7,10 @@
#include "ISceneNode.h" #include "ISceneNode.h"
#include "IParticleEmitter.h" #include "IParticleEmitter.h"
#include "IParticleAffector.h" #include "IParticleAttractionAffector.h"
#include "IParticleFadeOutAffector.h"
#include "IParticleGravityAffector.h"
#include "IParticleRotationAffector.h"
#include "dimension2d.h" #include "dimension2d.h"
namespace irr namespace irr
...@@ -139,6 +142,23 @@ public: ...@@ -139,6 +142,23 @@ public:
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0) = 0; 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 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 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 //! Creates a fade out particle affector. This affector modifies
//! the color of every particle and and reaches the final color //! the color of every particle and and reaches the final color
//! when the particle dies. //! when the particle dies.
...@@ -153,8 +173,8 @@ public: ...@@ -153,8 +173,8 @@ public:
//! just call addAffector(). Note that you'll have to drop() the //! just call addAffector(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see //! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations. //! IUnknown::drop() for more informations.
virtual IParticleAffector* createFadeOutParticleAffector( virtual IParticleFadeOutAffector* createFadeOutParticleAffector(
video::SColor targetColor = video::SColor(0,0,0,0), const video::SColor& targetColor = video::SColor(0,0,0,0),
u32 timeNeededToFadeOut = 1000) = 0; u32 timeNeededToFadeOut = 1000) = 0;
//! Creates a gravity affector. This affector modifies the direction //! Creates a gravity affector. This affector modifies the direction
...@@ -171,9 +191,22 @@ public: ...@@ -171,9 +191,22 @@ public:
//! just call addAffector(). Note that you'll have to drop() the //! just call addAffector(). Note that you'll have to drop() the
//! returned pointer, after you don't need it any more, see //! returned pointer, after you don't need it any more, see
//! IUnknown::drop() for more informations. //! IUnknown::drop() for more informations.
virtual IParticleAffector* createGravityAffector( virtual IParticleGravityAffector* createGravityAffector(
const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),
u32 timeForceLost = 1000) = 0; 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 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 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 } // end namespace scene
......
This diff is collapsed.
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "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<count; ++i)
{
core::vector3df direction = (Point - particlearray[i].pos).normalize();
direction *= Speed * timeDelta;
if( !Attract )
direction *= -1.0f;
if( AffectX )
particlearray[i].pos.X += direction.X;
if( AffectY )
particlearray[i].pos.Y += direction.Y;
if( AffectZ )
particlearray[i].pos.Z += direction.Z;
}
}
} // end namespace scene
} // end namespace irr
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__
#define __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__
#include "IParticleAttractionAffector.h"
namespace irr
{
namespace scene
{
//! Particle Affector for attracting particles to a point
class CParticleAttractionAffector : public IParticleAttractionAffector
{
public:
CParticleAttractionAffector(
const core::vector3df& point = core::vector3df(), f32 speed = 1.0f,
bool attract = true, bool affectX = true,
bool affectY = true, bool affectZ = true );
//! Affects a particle.
virtual void affect(u32 now, SParticle* particlearray, u32 count);
//! Set the point that particles will attract to
virtual void setPoint( const core::vector3df& point ) { Point = point; }
//! Set the speed, in game units per second that the particles will attract to
//! the specified point
virtual void setSpeed( f32 speed ) { Speed = speed; }
//! Set whether or not the particles are attracting or detracting
virtual void setAttract( bool attract ) { Attract = attract; }
//! Set whether or not this will affect particles in the X direction
virtual void setAffectX( bool affect ) { AffectX = affect; }
//! Set whether or not this will affect particles in the Y direction
virtual void setAffectY( bool affect ) { AffectY = affect; }
//! Set whether or not this will affect particles in the Z direction
virtual void setAffectZ( bool affect ) { AffectZ = affect; }
//! Get the point that particles are attracted to
virtual const core::vector3df& getPoint() const { return Point; }
//! Get the speed that points attract to the specified point
virtual f32 getSpeed() const { return Speed; }
//! Get whether or not the particles are attracting or detracting
virtual bool getAttract() const { return Attract; }
//! Get whether or not the particles X position are affected
virtual bool getAffectX() const { return AffectX; }
//! Get whether or not the particles Y position are affected
virtual bool getAffectY() const { return AffectY; }
//! Get whether or not the particles Z position are affected
virtual bool getAffectZ() const { return AffectZ; }
private:
core::vector3df Point;
f32 Speed;
bool AffectX;
bool AffectY;
bool AffectZ;
bool Attract;
u32 LastTime;
};
} // end namespace scene
} // end namespace irr
#endif // __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__
...@@ -13,10 +13,10 @@ namespace scene ...@@ -13,10 +13,10 @@ namespace scene
//! constructor //! constructor
CParticleFadeOutAffector::CParticleFadeOutAffector( CParticleFadeOutAffector::CParticleFadeOutAffector(
video::SColor targetColor, u32 fadeOutTime) const video::SColor& targetColor, u32 fadeOutTime)
: IParticleAffector(), TargetColor(targetColor) : IParticleFadeOutAffector(), TargetColor(targetColor)
{ {
FadeOutTime = fadeOutTime ? (f32)fadeOutTime : 1.0f; FadeOutTime = fadeOutTime ? static_cast<f32>(fadeOutTime) : 1.0f;
} }
...@@ -40,7 +40,7 @@ void CParticleFadeOutAffector::affect(u32 now, SParticle* particlearray, u32 cou ...@@ -40,7 +40,7 @@ void CParticleFadeOutAffector::affect(u32 now, SParticle* particlearray, u32 cou
//! Writes attributes of the object. //! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for //! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes. //! scripting languages, editors, debuggers or xml serialization purposes.
void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options)
{ {
...@@ -49,7 +49,7 @@ void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAt ...@@ -49,7 +49,7 @@ void CParticleFadeOutAffector::serializeAttributes(io::IAttributes* out, io::SAt
} }
//! Reads attributes of the object. //! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for //! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes. //! scripting languages, editors, debuggers or xml deserialization purposes.
//! \param startIndex: start index where to start reading attributes. //! \param startIndex: start index where to start reading attributes.
//! \return: returns last index of an attribute read by this affector //! \return: returns last index of an attribute read by this affector
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ #ifndef __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__
#define __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__ #define __C_PARTICLE_FADE_OUT_AFFECTOR_H_INCLUDED__
#include "IParticleAffector.h" #include "IParticleFadeOutAffector.h"
#include "SColor.h" #include "SColor.h"
namespace irr namespace irr
...@@ -14,15 +14,29 @@ namespace scene ...@@ -14,15 +14,29 @@ namespace scene
{ {
//! Particle Affector for fading out a color //! Particle Affector for fading out a color
class CParticleFadeOutAffector : public IParticleAffector class CParticleFadeOutAffector : public IParticleFadeOutAffector
{ {
public: public:
CParticleFadeOutAffector(video::SColor targetColor, u32 fadeOutTime); CParticleFadeOutAffector(const video::SColor& targetColor, u32 fadeOutTime);
//! Affects a particle. //! Affects a particle.
virtual void affect(u32 now, SParticle* particlearray, u32 count); 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. //! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for //! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes. //! scripting languages, editors, debuggers or xml serialization purposes.
...@@ -35,9 +49,6 @@ public: ...@@ -35,9 +49,6 @@ public:
//! \return: returns last index of an attribute read by this affector //! \return: returns last index of an attribute read by this affector
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); 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: private:
video::SColor TargetColor; video::SColor TargetColor;
......
...@@ -14,7 +14,7 @@ namespace scene ...@@ -14,7 +14,7 @@ namespace scene
//! constructor //! constructor
CParticleGravityAffector::CParticleGravityAffector( CParticleGravityAffector::CParticleGravityAffector(
const core::vector3df& gravity, u32 timeForceLost) const core::vector3df& gravity, u32 timeForceLost)
: IParticleAffector(), TimeForceLost((f32)timeForceLost), Gravity(gravity) : IParticleGravityAffector(), TimeForceLost(static_cast<f32>(timeForceLost)), Gravity(gravity)
{ {
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ #ifndef __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__
#define __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__ #define __C_PARTICLE_GRAVITY_AFFECTOR_H_INCLUDED__
#include "IParticleAffector.h" #include "IParticleGravityAffector.h"
#include "SColor.h" #include "SColor.h"
namespace irr namespace irr
...@@ -14,7 +14,7 @@ namespace scene ...@@ -14,7 +14,7 @@ namespace scene
{ {
//! Particle Affector for affecting direction of particle //! Particle Affector for affecting direction of particle
class CParticleGravityAffector : public IParticleAffector class CParticleGravityAffector : public IParticleGravityAffector
{ {
public: public:
...@@ -25,21 +25,32 @@ public: ...@@ -25,21 +25,32 @@ public:
//! Affects a particle. //! Affects a particle.
virtual void affect(u32 now, SParticle* particlearray, u32 count); 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. //! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for //! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes. //! scripting languages, editors, debuggers or xml serialization purposes.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options);
//! Reads attributes of the object. //! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for //! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes. //! scripting languages, editors, debuggers or xml deserialization purposes.
//! \param startIndex: start index where to start reading attributes. //! \param startIndex: start index where to start reading attributes.
//! \return: returns last index of an attribute read by this affector //! \return: returns last index of an attribute read by this affector
virtual s32 deserializeAttributes(s32 startIndex, io::IAttributes* in, io::SAttributeReadWriteOptions* options); 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: private:
f32 TimeForceLost; f32 TimeForceLost;
......
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "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<count; ++i)
{
if( Speed.X != 0.0f )
particlearray[i].pos.rotateYZBy( timeDelta * Speed.X, PivotPoint );
if( Speed.Y != 0.0f )
particlearray[i].pos.rotateXZBy( timeDelta * Speed.Y, PivotPoint );
if( Speed.Z != 0.0f )
particlearray[i].pos.rotateXYBy( timeDelta * Speed.Z, PivotPoint );
}
}
} // end namespace scene
} // end namespace irr
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__
#define __C_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__
#include "IParticleRotationAffector.h"
namespace irr
{
namespace scene
{
//! Particle Affector for rotating particles about a point
class CParticleRotationAffector : public IParticleRotationAffector
{
public:
CParticleRotationAffector( const core::vector3df& speed = core::vector3df(5.0f, 5.0f, 5.0f),
const core::vector3df& point = core::vector3df() );
//! Affects a particle.
virtual void affect(u32 now, SParticle* particlearray, u32 count);
//! Set the point that particles will attract to
virtual void setPivotPoint( const core::vector3df& point ) { PivotPoint = point; }
//! Set the speed in degrees per second
virtual void setSpeed( const core::vector3df& speed ) { Speed = speed; }
//! Get the point that particles are attracted to
virtual const core::vector3df& getPivotPoint() const { return PivotPoint; }
//! Get the speed in degrees per second
virtual const core::vector3df& getSpeed() const { return Speed; }
private:
core::vector3df PivotPoint;
core::vector3df Speed;
u32 LastTime;
};
} // end namespace scene
} // end namespace irr
#endif // __C_PARTICLE_ROTATION_AFFECTOR_H_INCLUDED__
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#include "CParticlePointEmitter.h" #include "CParticlePointEmitter.h"
#include "CParticleBoxEmitter.h" #include "CParticleBoxEmitter.h"
#include "CParticleAttractionAffector.h"
#include "CParticleFadeOutAffector.h" #include "CParticleFadeOutAffector.h"
#include "CParticleGravityAffector.h" #include "CParticleGravityAffector.h"
#include "CParticleRotationAffector.h"
#include "SViewFrustum.h" #include "SViewFrustum.h"
namespace irr namespace irr
...@@ -133,22 +135,42 @@ IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter( ...@@ -133,22 +135,42 @@ IParticleEmitter* CParticleSystemSceneNode::createBoxEmitter(
//! 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. //! Creates a fade out particle affector.
IParticleAffector* CParticleSystemSceneNode::createFadeOutParticleAffector( IParticleFadeOutAffector* CParticleSystemSceneNode::createFadeOutParticleAffector(
video::SColor targetColor, u32 timeNeededToFadeOut) const video::SColor& targetColor, u32 timeNeededToFadeOut)
{ {
return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut); return new CParticleFadeOutAffector(targetColor, timeNeededToFadeOut);
} }
//! Creates a gravity affector. //! Creates a gravity affector.
IParticleAffector* CParticleSystemSceneNode::createGravityAffector( IParticleGravityAffector* CParticleSystemSceneNode::createGravityAffector(
const core::vector3df& gravity, u32 timeForceLost) const core::vector3df& gravity, u32 timeForceLost)
{ {
return new CParticleGravityAffector(gravity, 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 //! pre render event
void CParticleSystemSceneNode::OnRegisterSceneNode() void CParticleSystemSceneNode::OnRegisterSceneNode()
{ {
......
...@@ -78,16 +78,28 @@ public: ...@@ -78,16 +78,28 @@ public:
u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
s32 maxAngleDegrees=0); 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. //! Creates a fade out particle affector.
virtual IParticleAffector* createFadeOutParticleAffector( virtual IParticleFadeOutAffector* createFadeOutParticleAffector(
video::SColor targetColor = video::SColor(0,0,0,0), const video::SColor& targetColor = video::SColor(0,0,0,0),
u32 timeNeededToFadeOut = 1000); u32 timeNeededToFadeOut = 1000);
//! Creates a gravity affector. //! Creates a gravity affector.
virtual IParticleAffector* createGravityAffector( virtual IParticleGravityAffector* createGravityAffector(
const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f), const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),
u32 timeForceLost = 1000); 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. //! Sets the size of all particles.
virtual void setParticleSize( virtual void setParticleSize(
const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)); const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f));
......
...@@ -19,7 +19,7 @@ VERSION = 1.3.1 ...@@ -19,7 +19,7 @@ VERSION = 1.3.1
# #
#List of object files, separated based on engine architecture #List of object files, separated based on engine architecture
IRROBJ = C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o CMD3MeshFileLoader.o CAnimatedMeshMS3D.o CAnimatedMeshB3d.o CAnimatedMeshSceneNode.o CBillboardSceneNode.o CCameraFPSSceneNode.o CCameraMayaSceneNode.o CCameraSceneNode.o CColladaFileLoader.o CCSMLoader.o CDefaultMeshFormatLoader.o CDMFLoader.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CLMTSMeshFileLoader.o CMeshManipulator.o CMeshSceneNode.o CMetaTriangleSelector.o CMY3DMeshFileLoader.o COCTLoader.o COctTreeSceneNode.o COctTreeTriangleSelector.o CParticleBoxEmitter.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticlePointEmitter.o CParticleSystemSceneNode.o CQ3LevelMesh.o CSceneCollisionManager.o CSceneManager.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CXAnimationPlayer.o CXFileReader.o CXMeshFileLoader.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CQuake3ShaderSceneNode.o IRROBJ = C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o CMD3MeshFileLoader.o CAnimatedMeshMS3D.o CAnimatedMeshB3d.o CAnimatedMeshSceneNode.o CBillboardSceneNode.o CCameraFPSSceneNode.o CCameraMayaSceneNode.o CCameraSceneNode.o CColladaFileLoader.o CCSMLoader.o CDefaultMeshFormatLoader.o CDMFLoader.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CLMTSMeshFileLoader.o CMeshManipulator.o CMeshSceneNode.o CMetaTriangleSelector.o CMY3DMeshFileLoader.o COCTLoader.o COctTreeSceneNode.o COctTreeTriangleSelector.o CParticleBoxEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticlePointEmitter.o CParticleSystemSceneNode.o CQ3LevelMesh.o CSceneCollisionManager.o CSceneManager.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CXAnimationPlayer.o CXFileReader.o CXMeshFileLoader.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CQuake3ShaderSceneNode.o
IRRVIDEOOBJ = COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CColorConverter.o CFPSCounter.o CImage.o CImageLoaderBMP.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o CNullDriver.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o CVideoModeList.o IRRVIDEOOBJ = COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CColorConverter.o CFPSCounter.o CImage.o CImageLoaderBMP.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o CNullDriver.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o CVideoModeList.o
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o
IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o
...@@ -38,7 +38,7 @@ CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng ...@@ -38,7 +38,7 @@ CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng
CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1 CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1
CXXFLAGS = -Wall CXXFLAGS = -Wall
ifndef NDEBUG ifndef NDEBUG
CXXFLAGS += -g CXXFLAGS += -g -D_DEBUG
else else
CXXFLAGS += -fexpensive-optimizations -O3 CXXFLAGS += -fexpensive-optimizations -O3
endif endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment