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 "OgreStableHeaders.h" 00026 #include "OgreAnimation.h" 00027 #include "OgreKeyFrame.h" 00028 #include "OgreAnimationTrack.h" 00029 #include "OgreException.h" 00030 00031 namespace Ogre { 00032 00033 Animation::InterpolationMode Animation::msDefaultInterpolationMode = Animation::IM_LINEAR; 00034 //--------------------------------------------------------------------- 00035 Animation::Animation(const String& name, Real length) : mName(name), mLength(length) 00036 { 00037 mInterpolationMode = Animation::msDefaultInterpolationMode; 00038 } 00039 //--------------------------------------------------------------------- 00040 Animation::~Animation() 00041 { 00042 destroyAllTracks(); 00043 } 00044 //--------------------------------------------------------------------- 00045 Real Animation::getLength(void) const 00046 { 00047 return mLength; 00048 } 00049 //--------------------------------------------------------------------- 00050 AnimationTrack* Animation::createTrack(unsigned short handle) 00051 { 00052 AnimationTrack* ret; 00053 00054 ret = new AnimationTrack(this); 00055 00056 mTrackList[handle] = ret; 00057 return ret; 00058 } 00059 //--------------------------------------------------------------------- 00060 AnimationTrack* Animation::createTrack(unsigned short handle, Node* node) 00061 { 00062 AnimationTrack* ret = createTrack(handle); 00063 00064 ret->setAssociatedNode(node); 00065 00066 return ret; 00067 } 00068 //--------------------------------------------------------------------- 00069 unsigned short Animation::getNumTracks(void) const 00070 { 00071 return (unsigned short)mTrackList.size(); 00072 } 00073 //--------------------------------------------------------------------- 00074 AnimationTrack* Animation::getTrack(unsigned short handle) const 00075 { 00076 TrackList::const_iterator i = mTrackList.find(handle); 00077 00078 if (i == mTrackList.end()) 00079 { 00080 Except(Exception::ERR_ITEM_NOT_FOUND, 00081 "Cannot find track with the specified handle", 00082 "Animation::getTrackByHandle"); 00083 } 00084 00085 return i->second; 00086 00087 } 00088 //--------------------------------------------------------------------- 00089 void Animation::destroyTrack(unsigned short handle) 00090 { 00091 TrackList::iterator i = mTrackList.find(handle); 00092 00093 delete i->second; 00094 00095 mTrackList.erase(i); 00096 } 00097 //--------------------------------------------------------------------- 00098 void Animation::destroyAllTracks(void) 00099 { 00100 TrackList::iterator i; 00101 for (i = mTrackList.begin(); i != mTrackList.end(); ++i) 00102 { 00103 delete i->second; 00104 } 00105 mTrackList.clear(); 00106 } 00107 //--------------------------------------------------------------------- 00108 const String& Animation::getName(void) const 00109 { 00110 return mName; 00111 } 00112 //--------------------------------------------------------------------- 00113 void Animation::apply(Real timePos, Real weight, bool accumulate) 00114 { 00115 TrackList::iterator i; 00116 for (i = mTrackList.begin(); i != mTrackList.end(); ++i) 00117 { 00118 i->second->apply(timePos, weight, accumulate); 00119 } 00120 00121 00122 } 00123 //--------------------------------------------------------------------- 00124 void Animation::setInterpolationMode(InterpolationMode im) 00125 { 00126 mInterpolationMode = im; 00127 } 00128 //--------------------------------------------------------------------- 00129 Animation::InterpolationMode Animation::getInterpolationMode(void) const 00130 { 00131 return mInterpolationMode; 00132 } 00133 //--------------------------------------------------------------------- 00134 void Animation::setDefaultInterpolationMode(InterpolationMode im) 00135 { 00136 msDefaultInterpolationMode = im; 00137 } 00138 //--------------------------------------------------------------------- 00139 Animation::InterpolationMode Animation::getDefaultInterpolationMode(void) 00140 { 00141 return msDefaultInterpolationMode; 00142 } 00143 //--------------------------------------------------------------------- 00144 const Animation::TrackList& Animation::_getTrackList(void) const 00145 { 00146 return mTrackList; 00147 00148 } 00149 00150 } 00151 00152
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:01 2004