Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# SceneNodeAnimationData.h

Go to the documentation of this file.

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