[692] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #ifndef __LinearForceAffector_H__
|
---|
| 26 | #define __LinearForceAffector_H__
|
---|
| 27 |
|
---|
| 28 | #include "OgreParticleFXPrerequisites.h"
|
---|
| 29 | #include "OgreParticleAffector.h"
|
---|
| 30 | #include "OgreVector3.h"
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | namespace Ogre {
|
---|
| 34 |
|
---|
| 35 | /** This class defines a ParticleAffector which applies a linear force to particles in a system.
|
---|
| 36 | @remarks
|
---|
| 37 | This affector (see ParticleAffector) applies a linear force, such as gravity, to a particle system.
|
---|
| 38 | This force can be applied in 2 ways: by taking the average of the particle's current momentum and the
|
---|
| 39 | force vector, or by adding the force vector to the current particle's momentum.
|
---|
| 40 | @par
|
---|
| 41 | The former approach is self-stabilising i.e. once a particle's momentum
|
---|
| 42 | is equal to the force vector, no further change is made to it's momentum. It also results in
|
---|
| 43 | a non-linear acceleration of particles.
|
---|
| 44 | The latter approach is simpler and applies a constant acceleration to particles. However,
|
---|
| 45 | it is not self-stabilising and can lead to perpetually increasing particle velocities.
|
---|
| 46 | You choose the approach by calling the setForceApplication method.
|
---|
| 47 | */
|
---|
| 48 | class _OgreParticleFXExport LinearForceAffector : public ParticleAffector
|
---|
| 49 | {
|
---|
| 50 | public:
|
---|
| 51 | /** Command object for force vector (see ParamCommand).*/
|
---|
| 52 | class CmdForceVector : public ParamCommand
|
---|
| 53 | {
|
---|
| 54 | public:
|
---|
| 55 | String doGet(const void* target) const;
|
---|
| 56 | void doSet(void* target, const String& val);
|
---|
| 57 | };
|
---|
| 58 |
|
---|
| 59 | /** Command object for force application (see ParamCommand).*/
|
---|
| 60 | class CmdForceApp : public ParamCommand
|
---|
| 61 | {
|
---|
| 62 | public:
|
---|
| 63 | String doGet(const void* target) const;
|
---|
| 64 | void doSet(void* target, const String& val);
|
---|
| 65 | };
|
---|
| 66 | /// Choice of how to apply the force vector to particles
|
---|
| 67 | enum ForceApplication
|
---|
| 68 | {
|
---|
| 69 | /// Take the average of the force vector and the particle momentum
|
---|
| 70 | FA_AVERAGE,
|
---|
| 71 | /// Add the force vector to the particle momentum
|
---|
| 72 | FA_ADD
|
---|
| 73 | };
|
---|
| 74 | /// Default constructor
|
---|
| 75 | LinearForceAffector(ParticleSystem* psys);
|
---|
| 76 |
|
---|
| 77 | /** See ParticleAffector. */
|
---|
| 78 | void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | /** Sets the force vector to apply to the particles in a system. */
|
---|
| 82 | void setForceVector(const Vector3& force);
|
---|
| 83 |
|
---|
| 84 | /** Gets the force vector to apply to the particles in a system. */
|
---|
| 85 | Vector3 getForceVector(void) const;
|
---|
| 86 |
|
---|
| 87 | /** Sets how the force vector is applied to a particle.
|
---|
| 88 | @remarks
|
---|
| 89 | The default is FA_ADD.
|
---|
| 90 | @param fa A member of the ForceApplication enum.
|
---|
| 91 | */
|
---|
| 92 | void setForceApplication(ForceApplication fa);
|
---|
| 93 |
|
---|
| 94 | /** Retrieves how the force vector is applied to a particle.
|
---|
| 95 | @param fa A member of the ForceApplication enum.
|
---|
| 96 | */
|
---|
| 97 | ForceApplication getForceApplication(void) const;
|
---|
| 98 |
|
---|
| 99 | /// Command objects
|
---|
| 100 | static CmdForceVector msForceVectorCmd;
|
---|
| 101 | static CmdForceApp msForceAppCmd;
|
---|
| 102 |
|
---|
| 103 | protected:
|
---|
| 104 | /// Force vector
|
---|
| 105 | Vector3 mForceVector;
|
---|
| 106 |
|
---|
| 107 | /// How to apply force
|
---|
| 108 | ForceApplication mForceApplication;
|
---|
| 109 |
|
---|
| 110 | };
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | #endif
|
---|
| 117 |
|
---|