Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreParticleAffector.h @ 1

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