00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 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 00020 /** @file 00021 * キャラクタモデルアニメーションヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef CHARACTER_MODEL_ANIMATION_H_ 00026 #define CHARACTER_MODEL_ANIMATION_H_ 00027 00028 #include <Animation/System/ObjectAnimation.h> 00029 #include <Animation/Model/CharacterModelAnimationData.h> 00030 00031 namespace Lamp{ 00032 00033 class CharacterModel; 00034 class Bone; 00035 00036 //------------------------------------------------------------------------------ 00037 /** 00038 * キャラクタモデルアニメーション 00039 */ 00040 class CharacterModelAnimation : public ObjectAnimation{ 00041 friend class AnimationManager; 00042 public: 00043 //-------------------------------------------------------------------------- 00044 // アニメーションデータ 00045 //-------------------------------------------------------------------------- 00046 /** 00047 * アニメーションデータの取得 00048 * @return アニメーションデータ 00049 */ 00050 virtual AnimationData* getAnimationData(){ return animationData_; } 00051 00052 /** 00053 * アニメーションデータの取得 00054 * @return アニメーションデータ 00055 */ 00056 virtual const AnimationData* getAnimationData() const{ 00057 return animationData_; 00058 } 00059 00060 //-------------------------------------------------------------------------- 00061 // キャラクタモデルアニメーションデータ 00062 //-------------------------------------------------------------------------- 00063 /** 00064 * キャラクタモデルアニメーションデータの設定 00065 * @param animationData キャラクタモデルアニメーションデータ 00066 */ 00067 virtual void setCharacterModelAnimationData( 00068 CharacterModelAnimationData* animationData){ 00069 if(animationData_ != NULL){ animationData_->removeReference(); } 00070 animationData_ = animationData; 00071 if(animationData_ != NULL){ animationData_->addReference(); } 00072 } 00073 00074 /** 00075 * キャラクタモデルアニメーションデータの取得 00076 */ 00077 virtual CharacterModelAnimationData* getCharacterModelAnimationData(){ 00078 return animationData_; 00079 } 00080 00081 /** 00082 * キャラクタモデルアニメーションデータの取得 00083 */ 00084 virtual const CharacterModelAnimationData* 00085 getCharacterModelAnimationData() const{ 00086 return animationData_; 00087 } 00088 00089 //-------------------------------------------------------------------------- 00090 // バインド 00091 //-------------------------------------------------------------------------- 00092 /** 00093 * バインド 00094 * @param scene バインド対象シーン 00095 * @return 成功すればtrue 00096 */ 00097 virtual bool bind(Scene* scene); 00098 00099 /** 00100 * バインド 00101 * @param model バインド対象キャラクタモデル 00102 * @return 成功すればtrue 00103 */ 00104 virtual bool bind(CharacterModel* model); 00105 00106 /** 00107 * バインド解除 00108 */ 00109 virtual void unbind(){ 00110 target_ = NULL; 00111 for(int i = 0; i < boneCount_; i++){ targetBones_[i] = NULL; } 00112 } 00113 00114 /** 00115 * ターゲットの取得 00116 * @return ターゲット 00117 */ 00118 virtual CharacterModel* getTarget() const{ return target_; } 00119 00120 /** 00121 * ターゲットボーンの取得 00122 * @param index ターゲットボーンのインデックス 00123 */ 00124 virtual Bone* getTargetBone(int index) const{ 00125 Assert(index >= 0); 00126 Assert(index < boneCount_); 00127 return targetBones_[index]; 00128 } 00129 00130 //-------------------------------------------------------------------------- 00131 // ボーン 00132 //-------------------------------------------------------------------------- 00133 /** 00134 * ボーン数の設定 00135 * @param boneCount ボーン数 00136 */ 00137 virtual void setBoneCount(int boneCount){ 00138 boneCount_ = boneCount; 00139 SafeArrayDelete(targetBones_); 00140 SafeArrayDelete(boneNames_); 00141 if(boneCount_ != 0){ 00142 boneNames_ = new String[boneCount_]; 00143 targetBones_ = new Bone*[boneCount_]; 00144 for(int i = 0; i < boneCount_; i++){ targetBones_[i] = NULL; } 00145 } 00146 } 00147 00148 /** 00149 * ボーン数の取得 00150 * @return ボーン数 00151 */ 00152 virtual int getBoneCount() const{ return boneCount_; } 00153 00154 //-------------------------------------------------------------------------- 00155 /** 00156 * ボーン名の設定 00157 * @param index ボーンのインデックス 00158 * @param boneName ボーン名 00159 */ 00160 virtual void setBoneName(int index, const String& boneName){ 00161 Assert(index >= 0); 00162 Assert(index < boneCount_); 00163 boneNames_[index] = boneName; 00164 } 00165 00166 /** 00167 * ボーン名の取得 00168 * @param index ボーンのインデックス 00169 * @return ボーン名 00170 */ 00171 virtual const String& getBoneName(int index) const{ 00172 Assert(index >= 0); 00173 Assert(index < boneCount_); 00174 return boneNames_[index]; 00175 } 00176 00177 //-------------------------------------------------------------------------- 00178 // アニメーション 00179 //-------------------------------------------------------------------------- 00180 /** 00181 * アニメーション 00182 * @param deltaTime デルタタイム 00183 * @param mask アニメーションマスク 00184 * @return アニメーションが終了していればtrue 00185 */ 00186 virtual bool animate(float deltaTime, AnimationMask mask); 00187 00188 //-------------------------------------------------------------------------- 00189 // コピー 00190 //-------------------------------------------------------------------------- 00191 /** 00192 * コピー 00193 * @param dataCopyMask データコピーマスク 00194 * @return コピーされたアニメーション 00195 */ 00196 virtual Animation* copy(DataCopyMask dataCopyMask = copyNone) const{ 00197 return copyCharacterModelAnimation(dataCopyMask); 00198 } 00199 00200 /** 00201 * キャラクタモデルアニメーションのコピー 00202 * @param dataCopyMask データコピーマスク 00203 * @return コピーされたアニメーション 00204 */ 00205 virtual CharacterModelAnimation* copyCharacterModelAnimation( 00206 DataCopyMask dataCopyMask = copyNone) const; 00207 00208 //-------------------------------------------------------------------------- 00209 // RTTI 00210 //-------------------------------------------------------------------------- 00211 /** 00212 * キャラクタモデルアニメーションかどうか 00213 * @return キャラクタモデルアニメーションならtrue 00214 */ 00215 virtual bool isCharacterModelAnimation() const{ return true; } 00216 00217 //-------------------------------------------------------------------------- 00218 protected: 00219 /** 00220 * コンストラクタ 00221 * @param name 名前 00222 * @param manager アニメーションマネージャ 00223 */ 00224 CharacterModelAnimation(String name, AnimationManager* manager); 00225 00226 /** 00227 * デストラクタ 00228 */ 00229 virtual ~CharacterModelAnimation(); 00230 00231 private: 00232 // アニメーションデータ 00233 CharacterModelAnimationData* animationData_; 00234 // ターゲット 00235 CharacterModel* target_; 00236 // ボーン数 00237 int boneCount_; 00238 // ボーン名 00239 String* boneNames_; 00240 // ターゲットボーン 00241 Bone** targetBones_; 00242 00243 }; 00244 00245 //------------------------------------------------------------------------------ 00246 } // End of namespace Lamp 00247 #endif // End of CHARACTER_MODEL_ANIMATION_H_ 00248 //------------------------------------------------------------------------------ 00249