Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/PlugIns/ParticleFX/include/OgreLinearForceAffector.h @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

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