PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: JointAni.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 __PLMESH_JOINTANI_H__ 00024 #define __PLMESH_JOINTANI_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLRenderer/Animation/AnimationBase.h> 00032 #include "PLMesh/PLMesh.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLMesh { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class JointHandler; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Joint animation class 00053 * 00054 * @remarks 00055 * This class manages the predefined joint animation data which is sometimes 00056 * also called 'offline animation'. 00057 */ 00058 class JointAni : public PLRenderer::AnimationBase { 00059 00060 00061 //[-------------------------------------------------------] 00062 //[ Public definitions ] 00063 //[-------------------------------------------------------] 00064 public: 00065 /** 00066 * @brief 00067 * Tell which attribute the track modify 00068 */ 00069 enum EAttribute { 00070 AX = 1<<0, /**< The x component of the position is modified */ 00071 AY = 1<<1, /**< The y component of the position is modified */ 00072 AZ = 1<<2, /**< The z component of the position is modified */ 00073 AYaw = 1<<3, /**< The yaw component of the rotation is modified */ 00074 APitch = 1<<4, /**< The pitch component of the rotation is modified */ 00075 ARoll = 1<<5, /**< The roll component of the rotation is modified */ 00076 AW = 1<<6 /**< The w component of the rotation is modified */ 00077 }; 00078 00079 00080 //[-------------------------------------------------------] 00081 //[ Public structures ] 00082 //[-------------------------------------------------------] 00083 public: 00084 /** 00085 * @brief 00086 * Holds information about which joint components are animated 00087 */ 00088 class AniJoint { 00089 00090 00091 //[-------------------------------------------------------] 00092 //[ Public data ] 00093 //[-------------------------------------------------------] 00094 public: 00095 char nAnimatedComponents; /**< X, Y, Z, Yaw, Pitch, Roll, W, see EAttribute */ 00096 00097 00098 //[-------------------------------------------------------] 00099 //[ Public functions ] 00100 //[-------------------------------------------------------] 00101 public: 00102 PLMESH_API AniJoint() : 00103 nAnimatedComponents(0) 00104 { 00105 } 00106 00107 PLMESH_API ~AniJoint() 00108 { 00109 } 00110 00111 PLMESH_API bool operator ==(const AniJoint &cAniJoint) const 00112 { 00113 return nAnimatedComponents == cAniJoint.nAnimatedComponents; 00114 } 00115 00116 00117 }; 00118 00119 00120 //[-------------------------------------------------------] 00121 //[ Public functions ] 00122 //[-------------------------------------------------------] 00123 public: 00124 /** 00125 * @brief 00126 * Constructor 00127 */ 00128 PLMESH_API JointAni(); 00129 00130 /** 00131 * @brief 00132 * Destructor 00133 */ 00134 PLMESH_API virtual ~JointAni(); 00135 00136 /** 00137 * @brief 00138 * Returns the animation joints 00139 * 00140 * @return 00141 * Skeleton animation joints 00142 */ 00143 PLMESH_API PLCore::Array<AniJoint> &GetJoints(); 00144 00145 /** 00146 * @brief 00147 * Applies the joint states from the given joint animation frame 00148 * to the given joint states 00149 * 00150 * @param[out] lstJointHandlers 00151 * Joint handlers to manipulate 00152 * @param[in] nFrame 00153 * Joint animation frame 00154 * @param[in] fWeight 00155 * Weight (0.0-1.0) 00156 * 00157 * @return 00158 * 'true' if all went fine, else 'false' (maybe no skeleton set?) 00159 */ 00160 PLMESH_API bool ApplyJointStates(PLCore::Array<JointHandler> &lstJointHandlers, PLCore::uint32 nFrame, float fWeight = 1.0f) const; 00161 00162 /** 00163 * @brief 00164 * Applies the blended joint states from the given joint animation frames 00165 * to the given joint states 00166 * 00167 * @param[out] lstJointHandlers 00168 * Joint handlers to manipulate 00169 * @param[in] nFrame1 00170 * Joint animation frame 1 00171 * @param[in] nFrame2 00172 * Joint animation frame 2 00173 * @param[in] fTime 00174 * Joint animation time (0.0-1.0) 00175 * @param[in] fWeight 00176 * Weight (0.0-1.0) 00177 * 00178 * @return 00179 * 'true' if all went fine, else 'false' (maybe no skeleton set?) 00180 */ 00181 PLMESH_API bool ApplyJointStates(PLCore::Array<JointHandler> &lstJointHandlers, PLCore::uint32 nFrame1, PLCore::uint32 nFrame2, float fTime, float fWeight = 1.0f) const; 00182 00183 00184 //[-------------------------------------------------------] 00185 //[ Private data ] 00186 //[-------------------------------------------------------] 00187 private: 00188 PLCore::Array<AniJoint> m_lstAniJoints; /**< The animation joints */ 00189 00190 00191 //[-------------------------------------------------------] 00192 //[ Public virtual AnimationInfo functions ] 00193 //[-------------------------------------------------------] 00194 public: 00195 PLMESH_API virtual JointAni &operator =(const JointAni &cSource); 00196 00197 00198 }; 00199 00200 00201 //[-------------------------------------------------------] 00202 //[ Namespace ] 00203 //[-------------------------------------------------------] 00204 } // PLMesh 00205 00206 00207 #endif // __PLMESH_JOINTANI_H__
|