PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: AnimationInfo.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLRENDERER_ANIMATIONINFO_H__ 00024 #define __PLRENDERER_ANIMATIONINFO_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLRenderer/Animation/AnimationEvent.h" 00032 #include "PLRenderer/Animation/AnimationFrameInfo.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLRenderer { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Animation information 00047 */ 00048 class AnimationInfo { 00049 00050 00051 //[-------------------------------------------------------] 00052 //[ Public definitions ] 00053 //[-------------------------------------------------------] 00054 public: 00055 /** 00056 * @brief 00057 * Animation flags 00058 */ 00059 enum EFlags { 00060 Loop = 1<<0, /**< Loop animation */ 00061 PingPong = 1<<1 /**< Ping pong animation */ 00062 }; 00063 00064 00065 //[-------------------------------------------------------] 00066 //[ Public functions ] 00067 //[-------------------------------------------------------] 00068 public: 00069 /** 00070 * @brief 00071 * Constructor 00072 */ 00073 PLRENDERER_API AnimationInfo(); 00074 00075 /** 00076 * @brief 00077 * Destructor 00078 */ 00079 PLRENDERER_API virtual ~AnimationInfo(); 00080 00081 /** 00082 * @brief 00083 * Returns the type of the animation 00084 * 00085 * @return 00086 * Animation type (for instance 0=skeleton 1=vertex) 00087 */ 00088 inline PLCore::uint32 GetType() const; 00089 00090 /** 00091 * @brief 00092 * Sets the animation type 00093 * 00094 * @param[in] nType 00095 * Animation type (for instance 0=skeleton 1=vertex) 00096 */ 00097 inline void SetType(PLCore::uint32 nType = 0); 00098 00099 /** 00100 * @brief 00101 * Returns the animation start frame 00102 * 00103 * @return 00104 * Animation start frame 00105 */ 00106 inline PLCore::uint32 GetStartFrame() const; 00107 00108 /** 00109 * @brief 00110 * Sets the animation start frame 00111 * 00112 * @param[in] nStartFrame 00113 * Animation start frame 00114 */ 00115 PLRENDERER_API void SetStartFrame(PLCore::uint32 nStartFrame = 0); 00116 00117 /** 00118 * @brief 00119 * Returns the animation end frame 00120 * 00121 * @return 00122 * Animation end frame 00123 */ 00124 inline PLCore::uint32 GetEndFrame() const; 00125 00126 /** 00127 * @brief 00128 * Sets the animation end frame 00129 * 00130 * @param[in] nEndFrame 00131 * Animation end frame 00132 */ 00133 PLRENDERER_API void SetEndFrame(PLCore::uint32 nEndFrame = 0); 00134 00135 /** 00136 * @brief 00137 * Returns the number of animation frames 00138 * 00139 * @return 00140 * Number of animation frames (normally EndFrame-StartFrame+1) 00141 */ 00142 inline PLCore::uint32 GetNumOfFrames() const; 00143 00144 /** 00145 * @brief 00146 * Get the animation speed 00147 * 00148 * @return 00149 * Playback speed of the animation, if negative, the animation is played reversed 00150 */ 00151 inline float GetSpeed() const; 00152 00153 /** 00154 * @brief 00155 * Set the animation speed 00156 * 00157 * @param[in] fSpeed 00158 * New playback speed for the animation, if negative, the animation is played reversed 00159 */ 00160 inline void SetSpeed(float fSpeed = 24.0f); 00161 00162 /** 00163 * @brief 00164 * Get the animation information flags 00165 * 00166 * @return 00167 * Animation information flags (see EFlags) 00168 */ 00169 inline PLCore::uint32 GetFlags() const; 00170 00171 /** 00172 * @brief 00173 * Sets the animation information flags 00174 * 00175 * @param[in] nFlags 00176 * Animation information flags (see EFlags) 00177 */ 00178 inline void SetFlags(PLCore::uint32 nFlags = 0); 00179 00180 /** 00181 * @brief 00182 * Returns information about a frame 00183 * 00184 * @param[in] nIndex 00185 * Index of the frame the information should be returned 00186 * 00187 * @return 00188 * Frame information, a null pointer if there's an error 00189 */ 00190 inline AnimationFrameInfo *GetFrameInfo(PLCore::uint32 nIndex = 0) const; 00191 00192 /** 00193 * @brief 00194 * Returns the event manager 00195 * 00196 * @return 00197 * Event manager 00198 */ 00199 inline AnimationEventManager &GetEventManager(); 00200 inline const AnimationEventManager &GetEventManager() const; 00201 00202 00203 //[-------------------------------------------------------] 00204 //[ Public virtual AnimationInfo functions ] 00205 //[-------------------------------------------------------] 00206 public: 00207 /** 00208 * @brief 00209 * Copy operator 00210 * 00211 * @param[in] cSource 00212 * Source to copy from 00213 * 00214 * @note 00215 * - The animation name itself is copied but at the end a 00216 * number is added because each animation name must be unique! 00217 * 00218 * @return 00219 * Reference to this instance 00220 */ 00221 PLRENDERER_API virtual AnimationInfo &operator =(const AnimationInfo &cSource); 00222 00223 /** 00224 * @brief 00225 * Get the animation source name 00226 * 00227 * @return 00228 * Animation source name, empty on error 00229 * 00230 * @note 00231 * - If this is a skeleton animation, the source name is the name of a skeleton. 00232 * (SkeletonManager::Get(...)) 00233 * - If this is a vertex animation, the source name is the name of a morph target animation. 00234 * (pMyMesh->GetMorphTargetAnimationManager().Get(...)) 00235 */ 00236 PLRENDERER_API virtual PLCore::String GetSourceName() const; 00237 00238 00239 //[-------------------------------------------------------] 00240 //[ Private data ] 00241 //[-------------------------------------------------------] 00242 private: 00243 PLCore::uint32 m_nType; /**< Animation type (for instance 0=skeleton 1=vertex) */ 00244 PLCore::uint32 m_nStart; /**< Start frame of the animation */ 00245 PLCore::uint32 m_nEnd; /**< End frame of the animation */ 00246 float m_fSpeed; /**< Playback speed */ 00247 PLCore::uint32 m_nFlags; /**< Animation information flags */ 00248 00249 /** Frame information */ 00250 PLCore::Array<AnimationFrameInfo> m_lstFrameInfos; 00251 00252 /** Event manager */ 00253 AnimationEventManager m_cEventManager; 00254 00255 00256 }; 00257 00258 00259 //[-------------------------------------------------------] 00260 //[ Namespace ] 00261 //[-------------------------------------------------------] 00262 } // PLRenderer 00263 00264 00265 //[-------------------------------------------------------] 00266 //[ Implementation ] 00267 //[-------------------------------------------------------] 00268 #include "PLRenderer/Animation/AnimationInfo.inl" 00269 00270 00271 #endif // __PLRENDERER_ANIMATIONINFO_H__
|