Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/PlugIns/ParticleFX/include/OgreColourFaderAffector.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 6.2 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 __ColourFaderAffector_H__
30#define __ColourFaderAffector_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 ColourFaderAffector : public ParticleAffector
45    {
46    public:
47
48        /** Command object for red adjust (see ParamCommand).*/
49        class CmdRedAdjust : 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 CmdGreenAdjust : 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 CmdBlueAdjust : 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 CmdAlphaAdjust : public ParamCommand
74        {
75        public:
76            String doGet(const void* target) const;
77            void doSet(void* target, const String& val);
78        };
79
80
81        /** Default constructor. */
82        ColourFaderAffector(ParticleSystem* psys);
83
84        /** See ParticleAffector. */
85        void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);
86
87        /** Sets the colour adjustment to be made per second to particles.
88        @param red, green, blue, alpha
89            Sets the adjustment to be made to each of the colour components per second. These
90            values will be added to the colour of all particles every second, scaled over each frame
91            for a smooth adjustment.
92        */
93        void setAdjust(float red, float green, float blue, float alpha = 0.0);
94        /** Sets the red adjustment to be made per second to particles.
95        @param red
96            The adjustment to be made to the colour component per second. This
97            value will be added to the colour of all particles every second, scaled over each frame
98            for a smooth adjustment.
99        */
100        void setRedAdjust(float red);
101
102        /** Gets the red adjustment to be made per second to particles. */
103        float getRedAdjust(void) const;
104
105        /** Sets the green adjustment to be made per second to particles.
106        @param green
107            The adjustment to be made to the colour component per second. This
108            value will be added to the colour of all particles every second, scaled over each frame
109            for a smooth adjustment.
110        */
111        void setGreenAdjust(float green);
112        /** Gets the green adjustment to be made per second to particles. */
113        float getGreenAdjust(void) const;
114        /** Sets the blue adjustment to be made per second to particles.
115        @param blue
116            The adjustment to be made to the colour component per second. This
117            value will be added to the colour of all particles every second, scaled over each frame
118            for a smooth adjustment.
119        */
120        void setBlueAdjust(float blue);
121        /** Gets the blue adjustment to be made per second to particles. */
122        float getBlueAdjust(void) const;
123
124        /** Sets the alpha adjustment to be made per second to particles.
125        @param alpha
126            The adjustment to be made to the colour component per second. This
127            value will be added to the colour of all particles every second, scaled over each frame
128            for a smooth adjustment.
129        */
130        void setAlphaAdjust(float alpha);
131        /** Gets the alpha adjustment to be made per second to particles. */
132        float getAlphaAdjust(void) const;
133
134        static CmdRedAdjust msRedCmd;
135        static CmdGreenAdjust msGreenCmd;
136        static CmdBlueAdjust msBlueCmd;
137        static CmdAlphaAdjust msAlphaCmd;
138
139    protected:
140        float mRedAdj;
141        float mGreenAdj;
142        float mBlueAdj;
143        float mAlphaAdj;
144
145        /** Internal method for adjusting while clamping to [0,1] */
146        inline void applyAdjustWithClamp(float* pComponent, float adjust)
147        {
148            *pComponent += adjust;
149            // Limit to 0
150            if (*pComponent < 0.0)
151            {
152                *pComponent = 0.0f;
153            }
154            // Limit to 1
155            else if (*pComponent > 1.0)
156            {
157                *pComponent = 1.0f;
158            }
159        }
160
161    };
162
163
164}
165
166
167#endif
168
Note: See TracBrowser for help on using the repository browser.