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 CAMERA_ANIMATION_DATA_H_ 00026 #define CAMERA_ANIMATION_DATA_H_ 00027 00028 #include <Animation/System/AnimationData.h> 00029 #include <Animation/VectorInterpolator/VectorInterpolator.h> 00030 #include <Animation/RotationInterpolator/RotationInterpolator.h> 00031 00032 namespace Lamp{ 00033 00034 //------------------------------------------------------------------------------ 00035 /** 00036 * カメラアニメーションデータ 00037 */ 00038 class CameraAnimationData : public AnimationData{ 00039 friend class AnimationManager; 00040 protected: 00041 //-------------------------------------------------------------------------- 00042 /** 00043 * カメラシーケンス 00044 */ 00045 class CameraSequence : public Sequence{ 00046 public: 00047 /** 00048 * コンストラクタ 00049 */ 00050 CameraSequence() : Sequence(), 00051 rotation_(NULL), translation_(NULL){} 00052 00053 /** 00054 * デストラクタ 00055 */ 00056 virtual ~CameraSequence(){ 00057 SafeDelete(translation_); 00058 SafeDelete(rotation_); 00059 } 00060 00061 /** 00062 * 代入コピー 00063 * @param copy コピー元 00064 */ 00065 virtual void operator =(const CameraSequence& copy){ 00066 Sequence::operator=(copy); 00067 SafeDelete(translation_); 00068 SafeDelete(rotation_); 00069 if(copy.rotation_ != NULL){ 00070 rotation_ = copy.rotation_->duplicate(); 00071 } 00072 if(copy.translation_ != NULL){ 00073 translation_ = copy.translation_->duplicate(); 00074 } 00075 } 00076 00077 /** 00078 * 長さの計算 00079 */ 00080 virtual void calcLength(){ 00081 length_ = 0.f; 00082 if((rotation_ != NULL) && (rotation_->getLength() > length_)){ 00083 length_ = rotation_->getLength(); 00084 } 00085 if((translation_ != NULL) && 00086 (translation_->getLength() > length_)){ 00087 length_ = translation_->getLength(); 00088 } 00089 } 00090 00091 /// 回転 00092 RotationInterpolator* rotation_; 00093 /// 移動 00094 VectorInterpolator* translation_; 00095 00096 }; 00097 00098 public: 00099 //-------------------------------------------------------------------------- 00100 // コピー 00101 //-------------------------------------------------------------------------- 00102 /** 00103 * コピー 00104 * @return コピーされたアニメーションデータ 00105 */ 00106 virtual AnimationData* copy() const{ return copyCameraAnimationData(); } 00107 00108 /** 00109 * カメラアニメーションデータのコピー 00110 */ 00111 virtual CameraAnimationData* copyCameraAnimationData() const; 00112 00113 //-------------------------------------------------------------------------- 00114 // シーケンス 00115 //-------------------------------------------------------------------------- 00116 /** 00117 * シーケンス数の設定 00118 * @param sequenceCount シーケンス数 00119 */ 00120 virtual void setSequenceCount(int sequenceCount){ 00121 SafeArrayDelete(sequences_); 00122 sequenceCount_ = sequenceCount; 00123 if(sequenceCount_ == 0){ return; } 00124 sequences_ = new CameraSequence[sequenceCount_]; 00125 } 00126 00127 /** 00128 * シーケンス数の取得 00129 * @return シーケンス数 00130 */ 00131 virtual int getSequenceCount() const{ return sequenceCount_; } 00132 00133 //-------------------------------------------------------------------------- 00134 // 回転 00135 //-------------------------------------------------------------------------- 00136 /** 00137 * 回転の設定 00138 * @param sequence シーケンス 00139 * @param rotation 設定する回転 00140 */ 00141 virtual void setRotation(int sequence, RotationInterpolator* rotation){ 00142 Assert(sequence >= 0); 00143 Assert(sequence < sequenceCount_); 00144 CameraSequence& data = sequences_[sequence]; 00145 SafeDelete(data.rotation_); 00146 data.rotation_ = rotation; 00147 data.calcLength(); 00148 } 00149 00150 /** 00151 * 回転の取得 00152 * @param sequence シーケンス 00153 * @return 回転 00154 */ 00155 virtual RotationInterpolator* getRotation(int sequence) const{ 00156 Assert(sequence >= 0); 00157 Assert(sequence < sequenceCount_); 00158 return sequences_[sequence].rotation_; 00159 } 00160 00161 //-------------------------------------------------------------------------- 00162 // 移動 00163 //-------------------------------------------------------------------------- 00164 /** 00165 * 移動の設定 00166 * @param sequence シーケンス 00167 * @param translation 設定する移動 00168 */ 00169 virtual void setTranslation( 00170 int sequence, VectorInterpolator* translation){ 00171 Assert(sequence >= 0); 00172 Assert(sequence < sequenceCount_); 00173 CameraSequence& data = sequences_[sequence]; 00174 SafeDelete(data.translation_); 00175 data.translation_ = translation; 00176 data.calcLength(); 00177 } 00178 00179 /** 00180 * 移動の取得 00181 * @param sequence シーケンス 00182 * @return 移動 00183 */ 00184 virtual VectorInterpolator* getTranslation(int sequence) const{ 00185 Assert(sequence >= 0); 00186 Assert(sequence < sequenceCount_); 00187 return sequences_[sequence].translation_; 00188 } 00189 00190 //-------------------------------------------------------------------------- 00191 // RTTI 00192 //-------------------------------------------------------------------------- 00193 /** 00194 * カメラアニメーションデータかどうか 00195 * @return カメラアニメーションデータならtrue 00196 */ 00197 virtual bool isCameraAnimationData() const{ return true; } 00198 00199 //-------------------------------------------------------------------------- 00200 protected: 00201 /** 00202 * コンストラクタ 00203 * @param name 名前 00204 * @param manager アニメーションマネージャ 00205 */ 00206 CameraAnimationData(const String& name, AnimationManager* manager) : 00207 AnimationData(name, manager), sequenceCount_(0), sequences_(NULL){ 00208 } 00209 00210 /** 00211 * デストラクタ 00212 */ 00213 virtual ~CameraAnimationData(){ 00214 SafeArrayDelete(sequences_); 00215 } 00216 00217 //-------------------------------------------------------------------------- 00218 /** 00219 * シーケンスの取得 00220 * @param sequence シーケンス 00221 * @return シーケンス 00222 */ 00223 virtual Sequence* getSequence(int sequence){ 00224 Assert(sequence >= 0); 00225 Assert(sequence < sequenceCount_); 00226 return &sequences_[sequence]; 00227 } 00228 00229 /** 00230 * シーケンスの取得 00231 * @param sequence シーケンス 00232 * @return シーケンス 00233 */ 00234 virtual const Sequence* getSequence(int sequence) const{ 00235 Assert(sequence >= 0); 00236 Assert(sequence < sequenceCount_); 00237 return &sequences_[sequence]; 00238 } 00239 00240 //-------------------------------------------------------------------------- 00241 private: 00242 // シーケンス数 00243 int sequenceCount_; 00244 // シーケンス 00245 CameraSequence* sequences_; 00246 00247 }; 00248 00249 //------------------------------------------------------------------------------ 00250 } // End of namespace Lamp 00251 #endif // End of CAMERA_ANIMATION_DATA_H_ 00252 //------------------------------------------------------------------------------