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 ANIMATION_DATA_H_ 00026 #define ANIMATION_DATA_H_ 00027 00028 namespace Lamp{ 00029 00030 class CameraAnimationData; 00031 class SceneNodeAnimationData; 00032 class CharacterModelAnimationData; 00033 00034 //------------------------------------------------------------------------------ 00035 /** 00036 * アニメーションデータ 00037 */ 00038 class AnimationData{ 00039 friend class AnimationManager; 00040 protected: 00041 //-------------------------------------------------------------------------- 00042 /** 00043 * シーケンス 00044 */ 00045 class Sequence{ 00046 public: 00047 /** 00048 * コンストラクタ 00049 */ 00050 Sequence() : length_(0.f), looped_(false){} 00051 00052 /** 00053 * デストラクタ 00054 */ 00055 virtual ~Sequence(){} 00056 00057 /** 00058 * 代入コピー 00059 * @param copy コピー元 00060 */ 00061 virtual void operator =(const Sequence& copy){ 00062 length_ = copy.length_; 00063 looped_ = copy.looped_; 00064 } 00065 00066 /// 長さ 00067 float length_; 00068 /// ループ 00069 bool looped_; 00070 00071 private: 00072 // コピーコンストラクタの隠蔽 00073 Sequence(const Sequence& copy); 00074 00075 }; 00076 00077 public: 00078 //-------------------------------------------------------------------------- 00079 // コピー 00080 //-------------------------------------------------------------------------- 00081 /** 00082 * コピー 00083 * @return コピーされたアニメーションデータ 00084 */ 00085 virtual AnimationData* copy() const = 0; 00086 00087 //-------------------------------------------------------------------------- 00088 // シーケンス数 00089 //-------------------------------------------------------------------------- 00090 /** 00091 * シーケンス数の設定 00092 * @param sequenceCount シーケンス数 00093 */ 00094 virtual void setSequenceCount(int sequenceCount) = 0; 00095 00096 /** 00097 * シーケンス数の取得 00098 * @return シーケンス数 00099 */ 00100 virtual int getSequenceCount() const = 0; 00101 00102 //-------------------------------------------------------------------------- 00103 // 長さ 00104 //-------------------------------------------------------------------------- 00105 /** 00106 * 長さの設定 00107 * @param sequence シーケンス 00108 * @param length 長さ 00109 */ 00110 virtual void setLength(int sequence, float length){ 00111 getSequence(sequence)->length_ = length; 00112 } 00113 00114 /** 00115 * 長さの取得 00116 * @param sequence シーケンス 00117 * @return 長さ 00118 */ 00119 virtual float getLength(int sequence) const{ 00120 return getSequence(sequence)->length_; 00121 } 00122 00123 //-------------------------------------------------------------------------- 00124 // ループ 00125 //-------------------------------------------------------------------------- 00126 /** 00127 * ループの設定 00128 * @param sequence シーケンス 00129 * @param looped 設定するループフラグ 00130 */ 00131 virtual void setLooped(int sequence, bool looped){ 00132 getSequence(sequence)->looped_ = looped; 00133 } 00134 00135 /** 00136 * ループの取得 00137 * @param sequence シーケンス 00138 * @return ループするならtrue 00139 */ 00140 virtual bool isLooped(int sequence) const{ 00141 return getSequence(sequence)->looped_; 00142 } 00143 00144 //-------------------------------------------------------------------------- 00145 // 名前 00146 //-------------------------------------------------------------------------- 00147 /** 00148 * 名前の取得 00149 * @return 名前 00150 */ 00151 virtual const String& getName() const{ return name_; } 00152 00153 //-------------------------------------------------------------------------- 00154 // マネージャ 00155 //-------------------------------------------------------------------------- 00156 /** 00157 * マネージャの取得 00158 * @return マネージャ 00159 */ 00160 virtual AnimationManager* getManager() const{ return manager_; } 00161 00162 //-------------------------------------------------------------------------- 00163 // リファレンスカウンタ 00164 //-------------------------------------------------------------------------- 00165 /** 00166 * リファレンスの追加 00167 * @return リファレンスカウント 00168 */ 00169 int addReference(){ 00170 referenceCount_++; 00171 return referenceCount_; 00172 } 00173 00174 /** 00175 * リファレンスの削除 00176 * @return リファレンスカウント 00177 */ 00178 int removeReference(){ 00179 referenceCount_--; 00180 return referenceCount_; 00181 } 00182 00183 /** 00184 * リファレンスカウントの取得 00185 * @return リファレンスカウント 00186 */ 00187 int getReferenceCount() const{ return referenceCount_; } 00188 00189 //-------------------------------------------------------------------------- 00190 // RTTI 00191 //-------------------------------------------------------------------------- 00192 /** 00193 * カメラアニメーションデータかどうか 00194 * @return カメラアニメーションデータならtrue 00195 */ 00196 virtual bool isCameraAnimationData() const{ return false; } 00197 00198 /** 00199 * カメラアニメーションデータへのキャスト 00200 * @return カメラアニメーションデータ。型が違えばNULLを返す。 00201 */ 00202 virtual CameraAnimationData* castCameraAnimationData() const{ 00203 if(isCameraAnimationData()){ return (CameraAnimationData*)this; } 00204 return NULL; 00205 } 00206 00207 //-------------------------------------------------------------------------- 00208 /** 00209 * シーンノードアニメーションデータかどうか 00210 * @return シーンノードアニメーションデータならtrue 00211 */ 00212 virtual bool isSceneNodeAnimationData() const{ return false; } 00213 00214 /** 00215 * シーンノードアニメーションデータへのキャスト 00216 * @return シーンノードアニメーションデータ。型が違えばNULLを返す。 00217 */ 00218 virtual SceneNodeAnimationData* castSceneNodeAnimationData() const{ 00219 if(isSceneNodeAnimationData()){ return (SceneNodeAnimationData*)this; } 00220 return NULL; 00221 } 00222 00223 //-------------------------------------------------------------------------- 00224 /** 00225 * キャラクタモデルアニメーションデータかどうか 00226 * @return キャラクタモデルアニメーションデータならtrue 00227 */ 00228 virtual bool isCharacterModelAnimationData() const{ return false; } 00229 00230 /** 00231 * キャラクタモデルアニメーションデータへのキャスト 00232 * @return キャラクタモデルアニメーションデータ。型が違えばNULLを返す。 00233 */ 00234 virtual CharacterModelAnimationData* 00235 castCharacterModelAnimationData() const{ 00236 if(isCharacterModelAnimationData()){ 00237 return (CharacterModelAnimationData*)this; 00238 } 00239 return NULL; 00240 } 00241 00242 //-------------------------------------------------------------------------- 00243 protected: 00244 /** 00245 * コンストラクタ 00246 * @param name 名前 00247 * @param manager アニメーションマネージャ 00248 */ 00249 AnimationData(const String& name, AnimationManager* manager) : 00250 name_(name), manager_(manager), referenceCount_(0){} 00251 00252 /** 00253 * デストラクタ 00254 */ 00255 virtual ~AnimationData(){} 00256 00257 /** 00258 * シーケンスの取得 00259 * @param sequence シーケンス 00260 * @return シーケンス 00261 */ 00262 virtual Sequence* getSequence(int sequence) = 0; 00263 00264 /** 00265 * シーケンスの取得 00266 * @param sequence シーケンス 00267 * @return シーケンス 00268 */ 00269 virtual const Sequence* getSequence(int sequence) const = 0; 00270 00271 //-------------------------------------------------------------------------- 00272 private: 00273 // コピーコンストラクタの隠蔽 00274 AnimationData(const AnimationData& copy); 00275 00276 // 代入コピーの隠蔽 00277 void operator =(const AnimationData& copy); 00278 00279 // 名前 00280 String name_; 00281 // アニメーションマネージャ 00282 AnimationManager* manager_; 00283 // リファレンスカウント 00284 int referenceCount_; 00285 }; 00286 00287 //------------------------------------------------------------------------------ 00288 } // End of namespace Lamp 00289 #endif // End of ANIMATION_DATA_H_ 00290 //------------------------------------------------------------------------------