Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/PlugIns/ParticleFX/include/OgreColourFaderAffector2.h @ 6

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

=hoffentlich gehts jetzt

File size: 8.1 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 __ColourFaderAffector2_H__
30#define __ColourFaderAffector2_H__
31
32#include "OgreParticleFXPrerequisites.h"
33#include "OgreParticleAffector.h"
34#include "OgreStringInterface.h"
35
36namespace Ogre {
37
38
39    /** This plugin subclass of ParticleAffector allows you to alter the colour of particles.
40    @remarks
41        This class supplies the ParticleAffector implementation required to modify the colour of
42        particle in mid-flight.
43    */
44    class _OgreParticleFXExport ColourFaderAffector2 : public ParticleAffector
45    {
46    public:
47
48        /** Command object for red adjust (see ParamCommand).*/
49        class CmdRedAdjust1 : public ParamCommand
50        {
51        public:
52            String doGet(const void* target) const;
53            void doSet(void* target, const String& val);
54        };
55
56        /** Command object for green adjust (see ParamCommand).*/
57        class CmdGreenAdjust1 : public ParamCommand
58        {
59        public:
60            String doGet(const void* target) const;
61            void doSet(void* target, const String& val);
62        };
63
64        /** Command object for blue adjust (see ParamCommand).*/
65        class CmdBlueAdjust1 : public ParamCommand
66        {
67        public:
68            String doGet(const void* target) const;
69            void doSet(void* target, const String& val);
70        };
71
72        /** Command object for alpha adjust (see ParamCommand).*/
73        class CmdAlphaAdjust1 : public ParamCommand
74        {
75        public:
76            String doGet(const void* target) const;
77            void doSet(void* target, const String& val);
78        };
79
80        /** Command object for red adjust (see ParamCommand).*/
81        class CmdRedAdjust2 : public ParamCommand
82        {
83        public:
84            String doGet(const void* target) const;
85            void doSet(void* target, const String& val);
86        };
87
88        /** Command object for green adjust (see ParamCommand).*/
89        class CmdGreenAdjust2 : public ParamCommand
90        {
91        public:
92            String doGet(const void* target) const;
93            void doSet(void* target, const String& val);
94        };
95
96        /** Command object for blue adjust (see ParamCommand).*/
97        class CmdBlueAdjust2 : public ParamCommand
98        {
99        public:
100            String doGet(const void* target) const;
101            void doSet(void* target, const String& val);
102        };
103
104        /** Command object for alpha adjust (see ParamCommand).*/
105        class CmdAlphaAdjust2 : public ParamCommand
106        {
107        public:
108            String doGet(const void* target) const;
109            void doSet(void* target, const String& val);
110        };
111
112        /** Command object for alpha adjust (see ParamCommand).*/
113        class CmdStateChange : public ParamCommand
114        {
115        public:
116            String doGet(const void* target) const;
117            void doSet(void* target, const String& val);
118        };
119
120
121        /** Default constructor. */
122        ColourFaderAffector2(ParticleSystem* psys);
123
124        /** See ParticleAffector. */
125        void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);
126
127        /** Sets the colour adjustment to be made per second to particles.
128        @param red, green, blue, alpha
129            Sets the adjustment to be made to each of the colour components per second. These
130            values will be added to the colour of all particles every second, scaled over each frame
131            for a smooth adjustment.
132        */
133        void setAdjust1(float red, float green, float blue, float alpha = 0.0);
134                void setAdjust2(float red, float green, float blue, float alpha = 0.0);
135        /** Sets the red adjustment to be made per second to particles.
136        @param red
137            The adjustment to be made to the colour component per second. This
138            value will be added to the colour of all particles every second, scaled over each frame
139            for a smooth adjustment.
140        */
141        void setRedAdjust1(float red);
142                void setRedAdjust2(float red);
143
144        /** Gets the red adjustment to be made per second to particles. */
145        float getRedAdjust1(void) const;
146                float getRedAdjust2(void) const;
147
148        /** Sets the green adjustment to be made per second to particles.
149        @param green
150            The adjustment to be made to the colour component per second. This
151            value will be added to the colour of all particles every second, scaled over each frame
152            for a smooth adjustment.
153        */
154        void setGreenAdjust1(float green);
155                void setGreenAdjust2(float green);
156        /** Gets the green adjustment to be made per second to particles. */
157        float getGreenAdjust1(void) const;
158                float getGreenAdjust2(void) const;
159        /** Sets the blue adjustment to be made per second to particles.
160        @param blue
161            The adjustment to be made to the colour component per second. This
162            value will be added to the colour of all particles every second, scaled over each frame
163            for a smooth adjustment.
164        */
165        void setBlueAdjust1(float blue);
166                void setBlueAdjust2(float blue);
167        /** Gets the blue adjustment to be made per second to particles. */
168        float getBlueAdjust1(void) const;
169                float getBlueAdjust2(void) const;
170
171        /** Sets the alpha adjustment to be made per second to particles.
172        @param alpha
173            The adjustment to be made to the colour component per second. This
174            value will be added to the colour of all particles every second, scaled over each frame
175            for a smooth adjustment.
176        */
177        void setAlphaAdjust1(float alpha);
178                void setAlphaAdjust2(float alpha);
179        /** Gets the alpha adjustment to be made per second to particles. */
180        float getAlphaAdjust1(void) const;
181                float getAlphaAdjust2(void) const;
182
183
184        void setStateChange(Real NewValue );
185        Real getStateChange(void) const;
186
187        static CmdRedAdjust1 msRedCmd1;
188                static CmdRedAdjust2 msRedCmd2;
189        static CmdGreenAdjust1 msGreenCmd1;
190                static CmdGreenAdjust2 msGreenCmd2;
191        static CmdBlueAdjust1 msBlueCmd1;
192                static CmdBlueAdjust2 msBlueCmd2;
193        static CmdAlphaAdjust1 msAlphaCmd1;
194                static CmdAlphaAdjust2 msAlphaCmd2;
195        static CmdStateChange msStateCmd;
196
197    protected:
198        float mRedAdj1, mRedAdj2;
199        float mGreenAdj1,  mGreenAdj2;
200        float mBlueAdj1, mBlueAdj2;
201        float mAlphaAdj1, mAlphaAdj2;
202                Real StateChangeVal;
203
204        /** Internal method for adjusting while clamping to [0,1] */
205        inline void applyAdjustWithClamp(float* pComponent, float adjust)
206        {
207            *pComponent += adjust;
208            // Limit to 0
209            if (*pComponent < 0.0)
210            {
211                *pComponent = 0.0f;
212            }
213            // Limit to 1
214            else if (*pComponent > 1.0)
215            {
216                *pComponent = 1.0f;
217            }
218        }
219
220    };
221
222
223}
224
225
226#endif
227
Note: See TracBrowser for help on using the repository browser.