source: GTP/trunk/Lib/Geom/OgreStuff/include/OgreParticleAffector.h @ 1809

Revision 1809, 5.2 KB checked in by gumbau, 18 years ago (diff)
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-2005 The OGRE Team
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-----------------------------------------------------------------------------
24*/
25#ifndef __ParticleAffector_H__
26#define __ParticleAffector_H__
27
28#include "OgrePrerequisites.h"
29#include "OgreString.h"
30#include "OgreStringInterface.h"
31
32
33namespace Ogre {
34
35    /** Abstract class defining the interface to be implemented by particle affectors.
36    @remarks
37        Particle affectors modify particles in a particle system over their lifetime. They can be
38        grouped into types, e.g. 'vector force' affectors, 'fader' affectors etc; each type will
39        modify particles in a different way, using different parameters.
40    @par
41        Because there are so many types of affectors you could use, OGRE chooses not to dictate
42        the available types. It comes with some in-built, but allows plugins or applications to extend the affector types available.
43        This is done by subclassing ParticleAffector to have the appropriate emission behaviour you want,
44        and also creating a subclass of ParticleAffectorFactory which is responsible for creating instances
45        of your new affector type. You register this factory with the ParticleSystemManager using
46        addAffectorFactory, and from then on affectors of this type can be created either from code or through
47        text particle scripts by naming the type.
48    @par
49        This same approach is used for ParticleEmitters (which are the source of particles in a system).
50        This means that OGRE is particularly flexible when it comes to creating particle system effects,
51        with literally infinite combinations of affector and affector types, and paramters within those
52        types.
53    */
54    class _OgreExport ParticleAffector : public StringInterface
55    {
56    protected:
57        /// Name of the type of affector, MUST be initialised by subclasses
58        String mType;
59
60        /** Internal method for setting up the basic parameter definitions for a subclass.
61        @remarks
62            Because StringInterface holds a dictionary of parameters per class, subclasses need to
63            call this to ask the base class to add it's parameters to their dictionary as well.
64            Can't do this in the constructor because that runs in a non-virtual context.
65        @par
66            The subclass must have called it's own createParamDictionary before calling this method.
67        */
68        void addBaseParameters(void) { /* actually do nothing - for future possible use */ }
69
70        ParticleSystem* mParent;
71    public:
72        ParticleAffector(ParticleSystem* parent): mParent(parent) {}
73
74        /** Virtual destructor essential. */
75        virtual ~ParticleAffector();
76
77        /** Method called to allow the affector to initialize all newly created particles in the system.
78        @remarks
79            This is where the affector gets the chance to initialize it's effects to the particles of a system.
80            The affector is expected to initialize some or all of the particles in the system
81            passed to it, depending on the affector's approach.
82        @param
83            pParticle Pointer to a Particle to initialize.
84        */
85                virtual void _initParticle(Particle* pParticle) { /* by default do nothing */ }
86
87        /** Method called to allow the affector to 'do it's stuff' on all active particles in the system.
88        @remarks
89            This is where the affector gets the chance to apply it's effects to the particles of a system.
90            The affector is expected to apply it's effect to some or all of the particles in the system
91            passed to it, depending on the affector's approach.
92        @param
93            pSystem Pointer to a ParticleSystem to affect.
94        @param
95            timeElapsed The number of seconds which have elapsed since the last call.
96        */
97        virtual void _affectParticles(ParticleSystem* pSystem, Real timeElapsed) = 0;
98
99        /** Returns the name of the type of affector.
100        @remarks
101            This property is useful for determining the type of affector procedurally so another
102            can be created.
103        */
104        const String &getType(void) const { return mType; }
105
106    };
107
108}
109
110
111#endif
112
Note: See TracBrowser for help on using the repository browser.