![[]](/images/special/trans.gif)
LibN2L-4 Library Code ReferenceClassesCompounds Files Members Method Index Full Reference cGuiSEModelOrbit.cppGo to the documentation of this file.00001 /************************************************************************ 00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library 00003 Copyright (C) 2002 Aaron Cameron 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 A copy of the GNU Lesser General Public License has been provided with 00020 this library in the file 'COPYING'. 00021 00022 Contact information for the author of this library has been provided 00023 with this library in the file 'AUTHOR'. 00024 ************************************************************************/ 00025 #include "gui/cGuiSEModelOrbit.h" 00026 #include "gui/cGuiModelView.h" 00027 namespace n2l 00028 { 00029 /**************************************************************************/ 00030 cGuiSEModelOrbit::cGuiSEModelOrbit() 00031 { 00032 init(); 00033 } 00034 00035 /**************************************************************************/ 00036 cGuiSEModelOrbit::cGuiSEModelOrbit( const cDynVar &iDef ) 00037 { 00038 init(); 00039 load( iDef ); 00040 } 00041 00042 /**************************************************************************/ 00043 cGuiSEModelOrbit::cGuiSEModelOrbit( const tString &iName, 00044 const tVector3f &iDPS, const tVector3f &iStartOffset, 00045 const tUint iLifespan ) : 00046 cGuiSEInt( iName ) 00047 { 00048 init(); 00049 mDps = iDPS; 00050 mDegrees = iStartOffset; 00051 lifespan( iLifespan ); 00052 } 00053 00054 /**************************************************************************/ 00055 cGuiSEModelOrbit::~cGuiSEModelOrbit() 00056 { 00057 } 00058 00059 /**************************************************************************/ 00060 void cGuiSEModelOrbit::load( const cDynVar &iDef ) 00061 { 00062 cGuiSEInt::load( iDef ); 00063 00064 if (iDef.keyExistsAsArray("dps")) 00065 mDps = asVector3f( iDef["dps"] ); 00066 00067 if (iDef.keyExistsAsArray("offset")) 00068 mDegrees = asVector3f( iDef["offset"] ); 00069 00070 if (iDef.keyExistsAsArray("startOffset")) 00071 mDegrees = asVector3f( iDef["startOffset"] ); 00072 00073 lifespan( iDef["lifespan"] ); 00074 } 00075 00076 /**************************************************************************/ 00077 void cGuiSEModelOrbit::lifespan( const tUint &iLifespan ) 00078 { 00079 if (iLifespan) mTimed = true; 00080 else mTimed = false; 00081 mLifespan = iLifespan; 00082 } 00083 00084 /**************************************************************************/ 00085 const tBool cGuiSEModelOrbit::actOn( cGuiElement *const i_ioElement, 00086 const tUint iTimePassed ) 00087 { 00088 if (!alive()) return false; 00089 mLifespan -= n2lMin( mLifespan, iTimePassed ); 00090 const tFloat Seconds = iTimePassed/1000.0f; 00091 mDegrees += mDps*Seconds; 00092 00093 cGuiModelView *tmp = dynamic_cast<cGuiModelView *>(i_ioElement); 00094 if (!tmp) throw cBadDataUseException( "cGuiSEModelOrbit::actOn", 00095 "Special effect attached to incompatible element, slick." ); 00096 00097 tMatrix44f tmpTrans; 00098 tmpTrans.eulerRotD( mDegrees ); 00099 tmp->meshTrans(tmpTrans); 00100 00101 if (mTimed) return alive(mLifespan); 00102 return alive(true); 00103 } 00104 00105 /**************************************************************************/ 00106 const cAutoPtr<cGuiSEInt> cGuiSEModelOrbit::clone() const 00107 { 00108 cAutoPtr<cGuiSEModelOrbit> tmp = new cGuiSEModelOrbit; 00109 cloneInto( tmp ); 00110 return tmp; 00111 } 00112 00113 /**************************************************************************/ 00114 void cGuiSEModelOrbit::cloneInto( 00115 const cAutoPtr<cGuiSEModelOrbit> &ioElement ) const 00116 { 00117 cGuiSEInt::cloneInto( ioElement ); 00118 00119 ioElement->mDps = mDps; 00120 ioElement->mDegrees = mDegrees; 00121 00122 ioElement->mTimed = mTimed; 00123 ioElement->mLifespan = mLifespan; 00124 } 00125 00126 /**************************************************************************/ 00127 void cGuiSEModelOrbit::init() 00128 { 00129 mDps.set(0.0f, 45.0f, 0.0f); 00130 mDegrees.set(-33.3f, -245.0f, 0.0f); 00131 00132 mLifespan = 0; 00133 mTimed = false; 00134 } 00135 00136 } // namespace n2l |