source: OGRE/trunk/ogrenew/PlugIns/ParticleFX/src/OgreScaleAffector.cpp @ 692

Revision 692, 3.9 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

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