Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/PlugIns/ParticleFX/src/OgreScaleAffector.cpp @ 3

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

=update

File size: 3.9 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#include "OgreScaleAffector.h"
30#include "OgreParticleSystem.h"
31#include "OgreStringConverter.h"
32#include "OgreParticle.h"
33
34
35namespace Ogre {
36   
37    // init statics
38    ScaleAffector::CmdScaleAdjust ScaleAffector::msScaleCmd;
39
40    //-----------------------------------------------------------------------
41    ScaleAffector::ScaleAffector(ParticleSystem* psys)
42        :ParticleAffector(psys)
43    {
44        mScaleAdj = 0;
45        mType = "Scaler";
46
47        // Init parameters
48        if (createParamDictionary("ScaleAffector"))
49        {
50            ParamDictionary* dict = getParamDictionary();
51
52            dict->addParameter(ParameterDef("rate", 
53                "The amount by which to adjust the x and y scale components of particles per second.",
54                PT_REAL), &msScaleCmd);
55        }
56    }
57    //-----------------------------------------------------------------------
58    void ScaleAffector::_affectParticles(ParticleSystem* pSystem, Real timeElapsed)
59    {
60        ParticleIterator pi = pSystem->_getIterator();
61        Particle *p;
62        Real ds;
63
64        // Scale adjustments by time
65        ds = mScaleAdj * timeElapsed;
66
67                Real NewWide, NewHigh;
68
69        while (!pi.end())
70        {
71            p = pi.getNext();
72
73                        if( p->hasOwnDimensions() == false )
74                        {
75                NewWide = pSystem->getDefaultWidth() + ds;
76                    NewHigh = pSystem->getDefaultHeight() + ds;
77
78                        }
79                        else
80                        {
81                NewWide = p->getOwnWidth()  + ds;
82                NewHigh = p->getOwnHeight() + ds;
83                        }
84                        p->setDimensions( NewWide, NewHigh ); 
85        }
86
87    }
88    //-----------------------------------------------------------------------
89    void ScaleAffector::setAdjust( Real rate )
90    {
91        mScaleAdj = rate;
92    }
93    //-----------------------------------------------------------------------
94    Real ScaleAffector::getAdjust(void) const
95    {
96        return mScaleAdj;
97    }
98    //-----------------------------------------------------------------------
99
100    //-----------------------------------------------------------------------
101    //-----------------------------------------------------------------------
102    // Command objects
103    //-----------------------------------------------------------------------
104    //-----------------------------------------------------------------------
105    String ScaleAffector::CmdScaleAdjust::doGet(const void* target) const
106    {
107        return StringConverter::toString(
108            static_cast<const ScaleAffector*>(target)->getAdjust() );
109    }
110    void ScaleAffector::CmdScaleAdjust::doSet(void* target, const String& val)
111    {
112        static_cast<ScaleAffector*>(target)->setAdjust(
113            StringConverter::parseReal(val));
114    }
115
116}
117
118
119
Note: See TracBrowser for help on using the repository browser.