1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __ColourFaderAffector2_H__
|
---|
26 | #define __ColourFaderAffector2_H__
|
---|
27 |
|
---|
28 | #include "OgreParticleFXPrerequisites.h"
|
---|
29 | #include "OgreParticleAffector.h"
|
---|
30 | #include "OgreStringInterface.h"
|
---|
31 |
|
---|
32 | namespace 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 ColourFaderAffector2 : public ParticleAffector
|
---|
41 | {
|
---|
42 | public:
|
---|
43 |
|
---|
44 | /** Command object for red adjust (see ParamCommand).*/
|
---|
45 | class CmdRedAdjust1 : 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 CmdGreenAdjust1 : 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 CmdBlueAdjust1 : 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 CmdAlphaAdjust1 : public ParamCommand
|
---|
70 | {
|
---|
71 | public:
|
---|
72 | String doGet(const void* target) const;
|
---|
73 | void doSet(void* target, const String& val);
|
---|
74 | };
|
---|
75 |
|
---|
76 | /** Command object for red adjust (see ParamCommand).*/
|
---|
77 | class CmdRedAdjust2 : public ParamCommand
|
---|
78 | {
|
---|
79 | public:
|
---|
80 | String doGet(const void* target) const;
|
---|
81 | void doSet(void* target, const String& val);
|
---|
82 | };
|
---|
83 |
|
---|
84 | /** Command object for green adjust (see ParamCommand).*/
|
---|
85 | class CmdGreenAdjust2 : public ParamCommand
|
---|
86 | {
|
---|
87 | public:
|
---|
88 | String doGet(const void* target) const;
|
---|
89 | void doSet(void* target, const String& val);
|
---|
90 | };
|
---|
91 |
|
---|
92 | /** Command object for blue adjust (see ParamCommand).*/
|
---|
93 | class CmdBlueAdjust2 : public ParamCommand
|
---|
94 | {
|
---|
95 | public:
|
---|
96 | String doGet(const void* target) const;
|
---|
97 | void doSet(void* target, const String& val);
|
---|
98 | };
|
---|
99 |
|
---|
100 | /** Command object for alpha adjust (see ParamCommand).*/
|
---|
101 | class CmdAlphaAdjust2 : public ParamCommand
|
---|
102 | {
|
---|
103 | public:
|
---|
104 | String doGet(const void* target) const;
|
---|
105 | void doSet(void* target, const String& val);
|
---|
106 | };
|
---|
107 |
|
---|
108 | /** Command object for alpha adjust (see ParamCommand).*/
|
---|
109 | class CmdStateChange : public ParamCommand
|
---|
110 | {
|
---|
111 | public:
|
---|
112 | String doGet(const void* target) const;
|
---|
113 | void doSet(void* target, const String& val);
|
---|
114 | };
|
---|
115 |
|
---|
116 |
|
---|
117 | /** Default constructor. */
|
---|
118 | ColourFaderAffector2(ParticleSystem* psys);
|
---|
119 |
|
---|
120 | /** See ParticleAffector. */
|
---|
121 | void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);
|
---|
122 |
|
---|
123 | /** Sets the colour adjustment to be made per second to particles.
|
---|
124 | @param red, green, blue, alpha
|
---|
125 | Sets the adjustment to be made to each of the colour components per second. These
|
---|
126 | values will be added to the colour of all particles every second, scaled over each frame
|
---|
127 | for a smooth adjustment.
|
---|
128 | */
|
---|
129 | void setAdjust1(float red, float green, float blue, float alpha = 0.0);
|
---|
130 | void setAdjust2(float red, float green, float blue, float alpha = 0.0);
|
---|
131 | /** Sets the red adjustment to be made per second to particles.
|
---|
132 | @param red
|
---|
133 | The adjustment to be made to the colour component per second. This
|
---|
134 | value will be added to the colour of all particles every second, scaled over each frame
|
---|
135 | for a smooth adjustment.
|
---|
136 | */
|
---|
137 | void setRedAdjust1(float red);
|
---|
138 | void setRedAdjust2(float red);
|
---|
139 |
|
---|
140 | /** Gets the red adjustment to be made per second to particles. */
|
---|
141 | float getRedAdjust1(void) const;
|
---|
142 | float getRedAdjust2(void) const;
|
---|
143 |
|
---|
144 | /** Sets the green adjustment to be made per second to particles.
|
---|
145 | @param green
|
---|
146 | The adjustment to be made to the colour component per second. This
|
---|
147 | value will be added to the colour of all particles every second, scaled over each frame
|
---|
148 | for a smooth adjustment.
|
---|
149 | */
|
---|
150 | void setGreenAdjust1(float green);
|
---|
151 | void setGreenAdjust2(float green);
|
---|
152 | /** Gets the green adjustment to be made per second to particles. */
|
---|
153 | float getGreenAdjust1(void) const;
|
---|
154 | float getGreenAdjust2(void) const;
|
---|
155 | /** Sets the blue adjustment to be made per second to particles.
|
---|
156 | @param blue
|
---|
157 | The adjustment to be made to the colour component per second. This
|
---|
158 | value will be added to the colour of all particles every second, scaled over each frame
|
---|
159 | for a smooth adjustment.
|
---|
160 | */
|
---|
161 | void setBlueAdjust1(float blue);
|
---|
162 | void setBlueAdjust2(float blue);
|
---|
163 | /** Gets the blue adjustment to be made per second to particles. */
|
---|
164 | float getBlueAdjust1(void) const;
|
---|
165 | float getBlueAdjust2(void) const;
|
---|
166 |
|
---|
167 | /** Sets the alpha adjustment to be made per second to particles.
|
---|
168 | @param alpha
|
---|
169 | The adjustment to be made to the colour component per second. This
|
---|
170 | value will be added to the colour of all particles every second, scaled over each frame
|
---|
171 | for a smooth adjustment.
|
---|
172 | */
|
---|
173 | void setAlphaAdjust1(float alpha);
|
---|
174 | void setAlphaAdjust2(float alpha);
|
---|
175 | /** Gets the alpha adjustment to be made per second to particles. */
|
---|
176 | float getAlphaAdjust1(void) const;
|
---|
177 | float getAlphaAdjust2(void) const;
|
---|
178 |
|
---|
179 |
|
---|
180 | void setStateChange(Real NewValue );
|
---|
181 | Real getStateChange(void) const;
|
---|
182 |
|
---|
183 | static CmdRedAdjust1 msRedCmd1;
|
---|
184 | static CmdRedAdjust2 msRedCmd2;
|
---|
185 | static CmdGreenAdjust1 msGreenCmd1;
|
---|
186 | static CmdGreenAdjust2 msGreenCmd2;
|
---|
187 | static CmdBlueAdjust1 msBlueCmd1;
|
---|
188 | static CmdBlueAdjust2 msBlueCmd2;
|
---|
189 | static CmdAlphaAdjust1 msAlphaCmd1;
|
---|
190 | static CmdAlphaAdjust2 msAlphaCmd2;
|
---|
191 | static CmdStateChange msStateCmd;
|
---|
192 |
|
---|
193 | protected:
|
---|
194 | float mRedAdj1, mRedAdj2;
|
---|
195 | float mGreenAdj1, mGreenAdj2;
|
---|
196 | float mBlueAdj1, mBlueAdj2;
|
---|
197 | float mAlphaAdj1, mAlphaAdj2;
|
---|
198 | Real StateChangeVal;
|
---|
199 |
|
---|
200 | /** Internal method for adjusting while clamping to [0,1] */
|
---|
201 | inline void applyAdjustWithClamp(float* pComponent, float adjust)
|
---|
202 | {
|
---|
203 | *pComponent += adjust;
|
---|
204 | // Limit to 0
|
---|
205 | if (*pComponent < 0.0)
|
---|
206 | {
|
---|
207 | *pComponent = 0.0f;
|
---|
208 | }
|
---|
209 | // Limit to 1
|
---|
210 | else if (*pComponent > 1.0)
|
---|
211 | {
|
---|
212 | *pComponent = 1.0f;
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | };
|
---|
217 |
|
---|
218 |
|
---|
219 | }
|
---|
220 |
|
---|
221 |
|
---|
222 | #endif
|
---|
223 |
|
---|