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 void 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 box in world coordinates.", 00061 PT_REAL),&msWidthCmd); 00062 dict->addParameter(ParameterDef("height", 00063 "Height of the box in world coordinates.", 00064 PT_REAL),&msHeightCmd); 00065 dict->addParameter(ParameterDef("depth", 00066 "Depth of the box in world coordinates.", 00067 PT_REAL),&msDepthCmd); 00068 00069 } 00070 } 00071 00072 //----------------------------------------------------------------------- 00073 unsigned short AreaEmitter::_getEmissionCount(Real timeElapsed) 00074 { 00075 // Use basic constant emission 00076 return genConstantEmissionCount(timeElapsed); 00077 } 00078 //----------------------------------------------------------------------- 00079 void AreaEmitter::setDirection( const Vector3& direction ) 00080 { 00081 ParticleEmitter::setDirection( direction ); 00082 00083 // Update the ranges 00084 genAreaAxes(); 00085 00086 00087 } 00088 //----------------------------------------------------------------------- 00089 void AreaEmitter::setSize(const Vector3& size) 00090 { 00091 mSize = size; 00092 genAreaAxes(); 00093 } 00094 //----------------------------------------------------------------------- 00095 void AreaEmitter::setSize(Real x, Real y, Real z) 00096 { 00097 mSize.x = x; 00098 mSize.y = y; 00099 mSize.z = z; 00100 genAreaAxes(); 00101 } 00102 //----------------------------------------------------------------------- 00103 void AreaEmitter::setWidth(Real width) 00104 { 00105 mSize.x = width; 00106 genAreaAxes(); 00107 } 00108 //----------------------------------------------------------------------- 00109 Real AreaEmitter::getWidth(void) const 00110 { 00111 return mSize.x; 00112 } 00113 //----------------------------------------------------------------------- 00114 void AreaEmitter::setHeight(Real height) 00115 { 00116 mSize.y = height; 00117 genAreaAxes(); 00118 } 00119 //----------------------------------------------------------------------- 00120 Real AreaEmitter::getHeight(void) const 00121 { 00122 return mSize.y; 00123 } 00124 //----------------------------------------------------------------------- 00125 void AreaEmitter::setDepth(Real depth) 00126 { 00127 mSize.z = depth; 00128 genAreaAxes(); 00129 } 00130 //----------------------------------------------------------------------- 00131 Real AreaEmitter::getDepth(void) const 00132 { 00133 return mSize.z; 00134 } 00135 //----------------------------------------------------------------------- 00136 void AreaEmitter::genAreaAxes(void) 00137 { 00138 Vector3 mLeft = mUp.crossProduct(mDirection); 00139 00140 mXRange = mLeft * (mSize.x * 0.5f); 00141 mYRange = mUp * (mSize.y * 0.5f); 00142 mZRange = mDirection * (mSize.z * 0.5f); 00143 } 00144 00145 //----------------------------------------------------------------------- 00146 // Command objects 00147 //----------------------------------------------------------------------- 00148 //----------------------------------------------------------------------- 00149 String AreaEmitter::CmdWidth::doGet(const void* target) const 00150 { 00151 return StringConverter::toString( 00152 static_cast<const AreaEmitter*>(target)->getWidth() ); 00153 } 00154 void AreaEmitter::CmdWidth::doSet(void* target, const String& val) 00155 { 00156 static_cast<AreaEmitter*>(target)->setWidth(StringConverter::parseReal(val)); 00157 } 00158 //----------------------------------------------------------------------- 00159 String AreaEmitter::CmdHeight::doGet(const void* target) const 00160 { 00161 return StringConverter::toString( 00162 static_cast<const AreaEmitter*>(target)->getHeight() ); 00163 } 00164 void AreaEmitter::CmdHeight::doSet(void* target, const String& val) 00165 { 00166 static_cast<AreaEmitter*>(target)->setHeight(StringConverter::parseReal(val)); 00167 } 00168 //----------------------------------------------------------------------- 00169 String AreaEmitter::CmdDepth::doGet(const void* target) const 00170 { 00171 return StringConverter::toString( 00172 static_cast<const AreaEmitter*>(target)->getDepth() ); 00173 } 00174 void AreaEmitter::CmdDepth::doSet(void* target, const String& val) 00175 { 00176 static_cast<AreaEmitter*>(target)->setDepth(StringConverter::parseReal(val)); 00177 } 00178 00179 00180 00181 } 00182 00183
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:21:52 2004