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 ) 2002 Tels <http://bloodgate.com> Based on OgrreBoxEmitter 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 "OgreAreaEmitter.h" 00026 #include "OgreParticle.h" 00027 #include "OgreQuaternion.h" 00028 #include "OgreException.h" 00029 #include "OgreStringConverter.h" 00030 00031 00032 00033 namespace Ogre { 00034 00035 // Instatiate statics 00036 AreaEmitter::CmdWidth AreaEmitter::msWidthCmd; 00037 AreaEmitter::CmdHeight AreaEmitter::msHeightCmd; 00038 AreaEmitter::CmdDepth AreaEmitter::msDepthCmd; 00039 00040 //----------------------------------------------------------------------- 00041 bool AreaEmitter::initDefaults(const String& t) 00042 { 00043 // called by the constructor as initDefaults("Type") 00044 00045 // Defaults 00046 mDirection = Vector3::UNIT_Z; 00047 mUp = Vector3::UNIT_Z; 00048 setSize(100,100,100); 00049 mType = t; 00050 00051 // Set up parameters 00052 if (createParamDictionary(mType + "Emitter")) 00053 { 00054 00055 addBaseParameters(); 00056 ParamDictionary* dict = getParamDictionary(); 00057 00058 // Custom params 00059 dict->addParameter(ParameterDef("width", 00060 "Width of the shape in world coordinates.", 00061 PT_REAL),&msWidthCmd); 00062 dict->addParameter(ParameterDef("height", 00063 "Height of the shape in world coordinates.", 00064 PT_REAL),&msHeightCmd); 00065 dict->addParameter(ParameterDef("depth", 00066 "Depth of the shape in world coordinates.", 00067 PT_REAL),&msDepthCmd); 00068 return true; 00069 00070 } 00071 return false; 00072 } 00073 00074 //----------------------------------------------------------------------- 00075 unsigned short AreaEmitter::_getEmissionCount(Real timeElapsed) 00076 { 00077 // Use basic constant emission 00078 return genConstantEmissionCount(timeElapsed); 00079 } 00080 //----------------------------------------------------------------------- 00081 void AreaEmitter::setDirection( const Vector3& direction ) 00082 { 00083 ParticleEmitter::setDirection( direction ); 00084 00085 // Update the ranges 00086 genAreaAxes(); 00087 00088 00089 } 00090 //----------------------------------------------------------------------- 00091 void AreaEmitter::setSize(const Vector3& size) 00092 { 00093 mSize = size; 00094 genAreaAxes(); 00095 } 00096 //----------------------------------------------------------------------- 00097 void AreaEmitter::setSize(Real x, Real y, Real z) 00098 { 00099 mSize.x = x; 00100 mSize.y = y; 00101 mSize.z = z; 00102 genAreaAxes(); 00103 } 00104 //----------------------------------------------------------------------- 00105 void AreaEmitter::setWidth(Real width) 00106 { 00107 mSize.x = width; 00108 genAreaAxes(); 00109 } 00110 //----------------------------------------------------------------------- 00111 Real AreaEmitter::getWidth(void) const 00112 { 00113 return mSize.x; 00114 } 00115 //----------------------------------------------------------------------- 00116 void AreaEmitter::setHeight(Real height) 00117 { 00118 mSize.y = height; 00119 genAreaAxes(); 00120 } 00121 //----------------------------------------------------------------------- 00122 Real AreaEmitter::getHeight(void) const 00123 { 00124 return mSize.y; 00125 } 00126 //----------------------------------------------------------------------- 00127 void AreaEmitter::setDepth(Real depth) 00128 { 00129 mSize.z = depth; 00130 genAreaAxes(); 00131 } 00132 //----------------------------------------------------------------------- 00133 Real AreaEmitter::getDepth(void) const 00134 { 00135 return mSize.z; 00136 } 00137 //----------------------------------------------------------------------- 00138 void AreaEmitter::genAreaAxes(void) 00139 { 00140 Vector3 mLeft = mUp.crossProduct(mDirection); 00141 00142 mXRange = mLeft * (mSize.x * 0.5f); 00143 mYRange = mUp * (mSize.y * 0.5f); 00144 mZRange = mDirection * (mSize.z * 0.5f); 00145 } 00146 00147 //----------------------------------------------------------------------- 00148 // Command objects 00149 //----------------------------------------------------------------------- 00150 //----------------------------------------------------------------------- 00151 String AreaEmitter::CmdWidth::doGet(const void* target) const 00152 { 00153 return StringConverter::toString( 00154 static_cast<const AreaEmitter*>(target)->getWidth() ); 00155 } 00156 void AreaEmitter::CmdWidth::doSet(void* target, const String& val) 00157 { 00158 static_cast<AreaEmitter*>(target)->setWidth(StringConverter::parseReal(val)); 00159 } 00160 //----------------------------------------------------------------------- 00161 String AreaEmitter::CmdHeight::doGet(const void* target) const 00162 { 00163 return StringConverter::toString( 00164 static_cast<const AreaEmitter*>(target)->getHeight() ); 00165 } 00166 void AreaEmitter::CmdHeight::doSet(void* target, const String& val) 00167 { 00168 static_cast<AreaEmitter*>(target)->setHeight(StringConverter::parseReal(val)); 00169 } 00170 //----------------------------------------------------------------------- 00171 String AreaEmitter::CmdDepth::doGet(const void* target) const 00172 { 00173 return StringConverter::toString( 00174 static_cast<const AreaEmitter*>(target)->getDepth() ); 00175 } 00176 void AreaEmitter::CmdDepth::doSet(void* target, const String& val) 00177 { 00178 static_cast<AreaEmitter*>(target)->setDepth(StringConverter::parseReal(val)); 00179 } 00180 00181 00182 00183 } 00184 00185
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:14 2004