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 BINARY_ANIMATION_SAVER_H_ 00026 #define BINARY_ANIMATION_SAVER_H_ 00027 00028 namespace Lamp{ 00029 00030 class BinaryWriter; 00031 class AnimationManager; 00032 class AnimationSet; 00033 class CameraAnimation; 00034 class CameraAnimationData; 00035 class SceneNodeAnimation; 00036 class SceneNodeAnimationData; 00037 class CharacterModelAnimation; 00038 class CharacterModelAnimationData; 00039 00040 class VectorInterpolator; 00041 class VectorConstantInterpolator; 00042 class VectorArrayInterpolator; 00043 class VectorLinearInterpolator; 00044 class RotationInterpolator; 00045 class RotationConstantInterpolator; 00046 class EulerArrayInterpolator; 00047 class QuaternionArrayInterpolator; 00048 class QuaternionLinearInterpolator; 00049 00050 //------------------------------------------------------------------------------ 00051 /** 00052 * バイナリアニメーションセーバ 00053 */ 00054 class BinaryAnimationSaver{ 00055 public: 00056 /** 00057 * コンストラクタ 00058 */ 00059 BinaryAnimationSaver(); 00060 00061 /** 00062 * デストラクタ 00063 */ 00064 virtual ~BinaryAnimationSaver(); 00065 00066 //-------------------------------------------------------------------------- 00067 // セーブ 00068 //-------------------------------------------------------------------------- 00069 /** 00070 * セーブ 00071 * @param filePath ファイルパス 00072 * @param manager セーブするアニメーションマネージャ 00073 */ 00074 virtual void save(const String& filePath, AnimationManager* manager); 00075 00076 /** 00077 * セーブ 00078 * @param binaryWriter バイナリライタ 00079 * @param manager セーブするアニメーションマネージャ 00080 */ 00081 virtual void save(BinaryWriter* binaryWriter, AnimationManager* manager); 00082 00083 protected: 00084 //-------------------------------------------------------------------------- 00085 /** 00086 * ヘッダの書き出し 00087 */ 00088 virtual void writeHeader(); 00089 00090 /** 00091 * オブジェクトのカウント 00092 * @return オブジェクト数 00093 */ 00094 virtual int countObjects(); 00095 00096 /** 00097 * オブジェクトカウンタのクリア 00098 */ 00099 virtual void clearObjectCount(){ 00100 animationCount_ = animationDataCount_ = animationSetCount_ = 00101 cameraCount_ = cameraDataCount_ = 00102 sceneNodeCount_ = sceneNodeDataCount_ = 00103 characterModelCount_ = characterModelDataCount_ = 0; 00104 } 00105 00106 //-------------------------------------------------------------------------- 00107 // アニメーションリスト 00108 //-------------------------------------------------------------------------- 00109 /** 00110 * アニメーションリストの書き出し 00111 */ 00112 virtual void writeAnimationList(); 00113 00114 //-------------------------------------------------------------------------- 00115 /** 00116 * アニメーションセットの書き出し 00117 * @param animation 書き出すアニメーションセット 00118 */ 00119 virtual void writeAnimationSet(AnimationSet* animation); 00120 00121 //-------------------------------------------------------------------------- 00122 /** 00123 * カメラアニメーションの書き出し 00124 * @param animation 書き出すカメラアニメーション 00125 */ 00126 virtual void writeCameraAnimation(CameraAnimation* animation); 00127 00128 /** 00129 * カメラアニメーションデータの書き出し 00130 * @param data 書き出すカメラアニメーションデータ 00131 */ 00132 virtual void writeCameraAnimationData(CameraAnimationData* data); 00133 00134 //-------------------------------------------------------------------------- 00135 /** 00136 * シーンノードアニメーションの書き出し 00137 * @param animation 書き出すシーンノードアニメーション 00138 */ 00139 virtual void writeSceneNodeAnimation(SceneNodeAnimation* animation); 00140 00141 /** 00142 * シーンノードアニメーションデータの書き出し 00143 * @param data 書き出すシーンノードアニメーションデータ 00144 */ 00145 virtual void writeSceneNodeAnimationData(SceneNodeAnimationData* data); 00146 00147 //-------------------------------------------------------------------------- 00148 /** 00149 * キャラクタモデルアニメーションの書き出し 00150 * @param animation 書き出すキャラクタモデルアニメーション 00151 */ 00152 virtual void writeCharacterModelAnimation( 00153 CharacterModelAnimation* animation); 00154 00155 /** 00156 * キャラクタモデルアニメーションデータの書き出し 00157 * @param data 書き出すキャラクタモデルアニメーションデータ 00158 */ 00159 virtual void writeCharacterModelAnimationData( 00160 CharacterModelAnimationData* data); 00161 00162 //-------------------------------------------------------------------------- 00163 // リンク 00164 //-------------------------------------------------------------------------- 00165 /** 00166 * リンクの書き出し 00167 */ 00168 virtual void writeLink(); 00169 00170 /** 00171 * アニメーションセットリンクの書き出し 00172 * @param animation リンクを書き出すアニメーションセット 00173 */ 00174 virtual void writeAnimationSetLink(AnimationSet* animation); 00175 00176 /** 00177 * カメラアニメーションリンクの書き出し 00178 * @param animation リンクを書き出すカメラアニメーション 00179 */ 00180 virtual void writeCameraAnimationLink(CameraAnimation* animation); 00181 00182 /** 00183 * シーンノードアニメーションリンクの書き出し 00184 * @param animation リンクを書き出すシーンノードアニメーション 00185 */ 00186 virtual void writeSceneNodeAnimationLink(SceneNodeAnimation* animation); 00187 00188 /** 00189 * キャラクタモデルアニメーションリンクの書き出し 00190 * @param animation リンクを書き出すキャラクタモデルアニメーション 00191 */ 00192 virtual void writeCharacterModelAnimationLink( 00193 CharacterModelAnimation* animation); 00194 00195 //-------------------------------------------------------------------------- 00196 // 値の書き出し 00197 //-------------------------------------------------------------------------- 00198 /** 00199 * 文字列の書き出し 00200 * @param string 文字列 00201 */ 00202 virtual void writeString(const String& string); 00203 00204 /** 00205 * 三次元ベクトルの書き出し 00206 * @param vector 三次元ベクトル 00207 */ 00208 virtual void writeVector3(const Vector3& vector); 00209 00210 /** 00211 * 四元数の書き出し 00212 * @param quaternion 四元数 00213 */ 00214 virtual void writeQuaternion(const Quaternion& quaternion); 00215 00216 //-------------------------------------------------------------------------- 00217 // ベクトル補間 00218 //-------------------------------------------------------------------------- 00219 /** 00220 * ベクトル補間の書き出し 00221 * @param interpolator ベクトル補間 00222 */ 00223 virtual void writeVectorInterpolator( 00224 VectorInterpolator* interpolator); 00225 00226 /** 00227 * ベクトル定数補間の書き出し 00228 * @param interpolator ベクトル定数補間 00229 */ 00230 virtual void writeVectorConstantInterpolator( 00231 VectorConstantInterpolator* interpolator); 00232 00233 /** 00234 * ベクトル配列補間の書き出し 00235 * @param interpolator ベクトル配列補間 00236 */ 00237 virtual void writeVectorArrayInterpolator( 00238 VectorArrayInterpolator* interpolator); 00239 00240 /** 00241 * ベクトル線形補間の書き出し 00242 * @param interpolator ベクトル線形補間 00243 */ 00244 virtual void writeVectorLinearInterpolator( 00245 VectorLinearInterpolator* interpolator); 00246 00247 //-------------------------------------------------------------------------- 00248 // 回転補間 00249 //-------------------------------------------------------------------------- 00250 /** 00251 * 回転補間の書き出し 00252 * @param interpolator 回転補間 00253 */ 00254 virtual void writeRotationInterpolator( 00255 RotationInterpolator* interpolator); 00256 00257 /** 00258 * 回転定数補間の書き出し 00259 * @param interpolator 回転定数補間 00260 */ 00261 virtual void writeRotationConstantInterpolator( 00262 RotationConstantInterpolator* interpolator); 00263 00264 /** 00265 * オイラー回転配列補間の書き出し 00266 * @param interpolator オイラー回転配列補間 00267 */ 00268 virtual void writeEulerArrayInterpolator( 00269 EulerArrayInterpolator* interpolator); 00270 00271 /** 00272 * 四元数回転配列補間の書き出し 00273 * @param interpolator 四元数回転配列補間 00274 */ 00275 virtual void writeQuaternionArrayInterpolator( 00276 QuaternionArrayInterpolator* interpolator); 00277 00278 /** 00279 * 四元数回転線形補間の書き出し 00280 * @param interpolator 四元数回転線形補間 00281 */ 00282 virtual void writeQuaternionLinearInterpolator( 00283 QuaternionLinearInterpolator* interpolator); 00284 00285 //-------------------------------------------------------------------------- 00286 // ユーティリティ 00287 //-------------------------------------------------------------------------- 00288 /** 00289 * アライメントを取る 00290 */ 00291 virtual void align(); 00292 00293 /** 00294 * ブロックの開始 00295 * @param blockName ブロック名 00296 * @return プロック開始位置 00297 */ 00298 virtual int startBlock(const String& blockName); 00299 00300 /** 00301 * ブロックの終了 00302 * @param blockStartAddress ブロック開始位置 00303 * @param objectCount オブジェクト数 00304 */ 00305 virtual void endBlock(int blockStartAddress, int objectCount); 00306 00307 //-------------------------------------------------------------------------- 00308 // メンバ 00309 //-------------------------------------------------------------------------- 00310 /// ライタ 00311 BinaryWriter* writer_; 00312 /// アニメーションマネージャ 00313 AnimationManager* manager_; 00314 00315 /// アニメーションカウント 00316 int animationCount_; 00317 /// アニメーションデータカウント 00318 int animationDataCount_; 00319 /// アニメーションセットカウント 00320 int animationSetCount_; 00321 /// カメラアニメーションカウント 00322 int cameraCount_; 00323 /// カメラアニメーションデータカウント 00324 int cameraDataCount_; 00325 /// シーンノードアニメーションカウント 00326 int sceneNodeCount_; 00327 /// シーンノードアニメーションデータカウント 00328 int sceneNodeDataCount_; 00329 /// キャラクタモデルアニメーションカウント 00330 int characterModelCount_; 00331 /// キャラクタモデルアニメーションデータカウント 00332 int characterModelDataCount_; 00333 00334 private: 00335 //-------------------------------------------------------------------------- 00336 // コピーコンストラクタの隠蔽 00337 BinaryAnimationSaver(const BinaryAnimationSaver& copy); 00338 00339 // 代入コピーの隠蔽 00340 void operator =(const BinaryAnimationSaver& copy); 00341 00342 }; 00343 00344 //------------------------------------------------------------------------------ 00345 } // End of namespace Lamp 00346 #endif // End of BINARY_ANIMATION_SAVER_H_ 00347 //------------------------------------------------------------------------------