source: OGRE/trunk/ogrenew/PlugIns/ParticleFX/include/OgreColourFaderAffector.h @ 690

Revision 690, 6.0 KB checked in by mattausch, 18 years ago (diff)

added ogre 1.07 main

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 __ColourFaderAffector_H__
26#define __ColourFaderAffector_H__
27
28#include "OgreParticleFXPrerequisites.h"
29#include "OgreParticleAffector.h"
30#include "OgreStringInterface.h"
31
32namespace Ogre {
33
34
35    /** This plugin subclass of ParticleAffector allows you to alter the colour of particles.
36    @remarks
37        This class supplies the ParticleAffector implementation required to modify the colour of
38        particle in mid-flight.
39    */
40    class _OgreParticleFXExport ColourFaderAffector : public ParticleAffector
41    {
42    public:
43
44        /** Command object for red adjust (see ParamCommand).*/
45        class CmdRedAdjust : public ParamCommand
46        {
47        public:
48            String doGet(const void* target) const;
49            void doSet(void* target, const String& val);
50        };
51
52        /** Command object for green adjust (see ParamCommand).*/
53        class CmdGreenAdjust : public ParamCommand
54        {
55        public:
56            String doGet(const void* target) const;
57            void doSet(void* target, const String& val);
58        };
59
60        /** Command object for blue adjust (see ParamCommand).*/
61        class CmdBlueAdjust : public ParamCommand
62        {
63        public:
64            String doGet(const void* target) const;
65            void doSet(void* target, const String& val);
66        };
67
68        /** Command object for alpha adjust (see ParamCommand).*/
69        class CmdAlphaAdjust : public ParamCommand
70        {
71        public:
72            String doGet(const void* target) const;
73            void doSet(void* target, const String& val);
74        };
75
76
77        /** Default constructor. */
78        ColourFaderAffector(ParticleSystem* psys);
79
80        /** See ParticleAffector. */
81        void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);
82
83        /** Sets the colour adjustment to be made per second to particles.
84        @param red, green, blue, alpha
85            Sets the adjustment to be made to each of the colour components per second. These
86            values will be added to the colour of all particles every second, scaled over each frame
87            for a smooth adjustment.
88        */
89        void setAdjust(float red, float green, float blue, float alpha = 0.0);
90        /** Sets the red adjustment to be made per second to particles.
91        @param red
92            The adjustment to be made to the colour component per second. This
93            value will be added to the colour of all particles every second, scaled over each frame
94            for a smooth adjustment.
95        */
96        void setRedAdjust(float red);
97
98        /** Gets the red adjustment to be made per second to particles. */
99        float getRedAdjust(void) const;
100
101        /** Sets the green adjustment to be made per second to particles.
102        @param green
103            The adjustment to be made to the colour component per second. This
104            value will be added to the colour of all particles every second, scaled over each frame
105            for a smooth adjustment.
106        */
107        void setGreenAdjust(float green);
108        /** Gets the green adjustment to be made per second to particles. */
109        float getGreenAdjust(void) const;
110        /** Sets the blue adjustment to be made per second to particles.
111        @param blue
112            The adjustment to be made to the colour component per second. This
113            value will be added to the colour of all particles every second, scaled over each frame
114            for a smooth adjustment.
115        */
116        void setBlueAdjust(float blue);
117        /** Gets the blue adjustment to be made per second to particles. */
118        float getBlueAdjust(void) const;
119
120        /** Sets the alpha adjustment to be made per second to particles.
121        @param alpha
122            The adjustment to be made to the colour component per second. This
123            value will be added to the colour of all particles every second, scaled over each frame
124            for a smooth adjustment.
125        */
126        void setAlphaAdjust(float alpha);
127        /** Gets the alpha adjustment to be made per second to particles. */
128        float getAlphaAdjust(void) const;
129
130        static CmdRedAdjust msRedCmd;
131        static CmdGreenAdjust msGreenCmd;
132        static CmdBlueAdjust msBlueCmd;
133        static CmdAlphaAdjust msAlphaCmd;
134
135    protected:
136        float mRedAdj;
137        float mGreenAdj;
138        float mBlueAdj;
139        float mAlphaAdj;
140
141        /** Internal method for adjusting while clamping to [0,1] */
142        inline void applyAdjustWithClamp(float* pComponent, float adjust)
143        {
144            *pComponent += adjust;
145            // Limit to 0
146            if (*pComponent < 0.0)
147            {
148                *pComponent = 0.0f;
149            }
150            // Limit to 1
151            else if (*pComponent > 1.0)
152            {
153                *pComponent = 1.0f;
154            }
155        }
156
157    };
158
159
160}
161
162
163#endif
164
Note: See TracBrowser for help on using the repository browser.