00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreScaleAffector.h" 00026 #include "OgreParticleSystem.h" 00027 #include "OgreStringConverter.h" 00028 #include "OgreParticle.h" 00029 00030 00031 namespace Ogre { 00032 00033 // init statics 00034 ScaleAffector::CmdScaleAdjust ScaleAffector::msScaleCmd; 00035 00036 //----------------------------------------------------------------------- 00037 ScaleAffector::ScaleAffector() 00038 { 00039 mScaleAdj = 0; 00040 mType = "Scaler"; 00041 00042 // Init parameters 00043 if (createParamDictionary("ScaleAffector")) 00044 { 00045 ParamDictionary* dict = getParamDictionary(); 00046 00047 dict->addParameter(ParameterDef("rate", 00048 "The amount by which to adjust the x and y scale components of particles per second.", 00049 PT_REAL), &msScaleCmd); 00050 } 00051 } 00052 //----------------------------------------------------------------------- 00053 void ScaleAffector::_affectParticles(ParticleSystem* pSystem, Real timeElapsed) 00054 { 00055 ParticleIterator pi = pSystem->_getIterator(); 00056 Particle *p; 00057 Real ds; 00058 00059 // Scale adjustments by time 00060 ds = mScaleAdj * timeElapsed; 00061 00062 Real NewWide, NewHigh; 00063 00064 while (!pi.end()) 00065 { 00066 p = pi.getNext(); 00067 00068 if( p->hasOwnDimensions() == false ){ 00069 p->setDimensions( pSystem->getDefaultWidth() , pSystem->getDefaultHeight() ); 00070 } 00071 else{ 00072 NewWide = p->getOwnWidth() + ds; 00073 NewHigh = p->getOwnHeight() + ds; 00074 00075 p->setDimensions( NewWide, NewHigh ); 00076 } 00077 } 00078 00079 } 00080 //----------------------------------------------------------------------- 00081 void ScaleAffector::setAdjust( Real rate ) 00082 { 00083 mScaleAdj = rate; 00084 } 00085 //----------------------------------------------------------------------- 00086 Real ScaleAffector::getAdjust(void) const 00087 { 00088 return mScaleAdj; 00089 } 00090 //----------------------------------------------------------------------- 00091 00092 //----------------------------------------------------------------------- 00093 //----------------------------------------------------------------------- 00094 // Command objects 00095 //----------------------------------------------------------------------- 00096 //----------------------------------------------------------------------- 00097 String ScaleAffector::CmdScaleAdjust::doGet(const void* target) const 00098 { 00099 return StringConverter::toString( 00100 static_cast<const ScaleAffector*>(target)->getAdjust() ); 00101 } 00102 void ScaleAffector::CmdScaleAdjust::doSet(void* target, const String& val) 00103 { 00104 static_cast<ScaleAffector*>(target)->setAdjust( 00105 StringConverter::parseReal(val)); 00106 } 00107 00108 } 00109 00110 00111
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:43 2004