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

RotationConstantInterpolator.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 ROTATION_CONSTANT_INTERPOLATOR_H_
00026 #define ROTATION_CONSTANT_INTERPOLATOR_H_
00027 
00028 #include <Animation/RotationInterpolator/RotationInterpolator.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * 回転定数補間
00035  */
00036 class RotationConstantInterpolator : public RotationInterpolator{
00037 public:
00038     //--------------------------------------------------------------------------
00039     /**
00040      * コンストラクタ
00041      */
00042     RotationConstantInterpolator() : euler_(Vector3::zero),
00043         quaternion_(Quaternion::identity), length_(0.f){}
00044 
00045     /**
00046      * デストラクタ
00047      */
00048     virtual ~RotationConstantInterpolator(){}
00049 
00050     //--------------------------------------------------------------------------
00051     /**
00052      * 複製
00053      * @return 複製された回転補間。呼び出し元でdeleteする必要がある
00054      */
00055     virtual RotationInterpolator* duplicate() const{
00056         RotationInterpolator* result = new RotationConstantInterpolator(*this);
00057         return result;
00058     }
00059 
00060     //--------------------------------------------------------------------------
00061     /**
00062      * 同じ値かどうか
00063      * @param target 比較対象
00064      * @return 同じ値ならtrueをかえす
00065      */
00066     virtual bool equals(const RotationInterpolator& target) const{
00067         RotationConstantInterpolator* interpolator =
00068             target.castRotationConstantInterpolator();
00069         if(interpolator == NULL){ return false; }
00070         return ((euler_ == interpolator->euler_) &&
00071             (quaternion_ == interpolator->quaternion_) &&
00072             (length_ == interpolator->length_));
00073     }
00074 
00075     //--------------------------------------------------------------------------
00076     // 長さ
00077     //--------------------------------------------------------------------------
00078     /**
00079      * 長さの設定
00080      * @param length 長さ
00081      */
00082     virtual void setLength(float length){
00083         Assert(length >= 0.f);
00084         length_ = length;
00085     }
00086 
00087     /**
00088      * 長さの取得
00089      * @return 長さ
00090      */
00091     virtual float getLength() const{ return length_; }
00092 
00093     //--------------------------------------------------------------------------
00094     // オイラー補間
00095     //--------------------------------------------------------------------------
00096     /**
00097      * オイラー補間かどうか
00098      * @return オイラー補間ならtrue
00099      */
00100     virtual bool isEulerInterpolator() const{ return true; }
00101 
00102     /**
00103      * オイラー補間
00104      * @param time 時間
00105      * @return 補間された回転
00106      */
00107     virtual Vector3 eulerInterpolate(float time){ return euler_; }
00108 
00109     //--------------------------------------------------------------------------
00110     // 四元数補間
00111     //--------------------------------------------------------------------------
00112     /**
00113      * 四元数補間かどうか
00114      * @return 四元数補間ならtrue
00115      */
00116     virtual bool isQuaternionInterpolator() const{ return true; }
00117 
00118     /**
00119      * 四元数補間
00120      * @param time 時間
00121      * @return 補間された回転
00122      */
00123     virtual Quaternion quaternionInterpolate(float time){ return quaternion_; }
00124 
00125     //--------------------------------------------------------------------------
00126     // 値
00127     //--------------------------------------------------------------------------
00128     /**
00129      * XYZ回転の設定
00130      * @param euler 設定するXYZ回転
00131      */
00132     virtual void setEuler(const Vector3& euler){
00133         euler_ = euler;
00134         quaternion_.setRotationXYZ(euler_);
00135     }
00136 
00137     /**
00138      * XYZ回転の取得
00139      * @return 取得したXYZ回転
00140      */
00141     virtual Vector3 getEuler(){ return euler_; }
00142 
00143     //--------------------------------------------------------------------------
00144     /**
00145      * 四元数回転の設定
00146      * @param quaternion 設定する四元数回転
00147      */
00148     virtual void setQuaternion(const Quaternion& quaternion){
00149         quaternion_ = quaternion;
00150         quaternion_.getRotationXYZ(&euler_);
00151     }
00152 
00153     /**
00154      * 四元数回転の取得
00155      * @return 取得した四元数回転
00156      */
00157     virtual Quaternion getQuaternion(){ return quaternion_; }
00158 
00159     //--------------------------------------------------------------------------
00160     // RTTI
00161     //--------------------------------------------------------------------------
00162     /**
00163      * 回転定数補間かどうか
00164      * @return 回転定数補間ならtrue
00165      */
00166     virtual bool isRotationConstantInterpolator() const{ return true; }
00167 
00168     //--------------------------------------------------------------------------
00169 private:
00170     // オイラー
00171     Vector3 euler_;
00172     // 四元数
00173     Quaternion quaternion_;
00174     // 長さ
00175     float length_;
00176 
00177 };
00178 
00179 //------------------------------------------------------------------------------
00180 } // End of namespace Lamp
00181 #endif // End of ROTATION_CONSTANT_INTERPOLATOR_H_
00182 //------------------------------------------------------------------------------
00183 

Generated on Wed Mar 16 10:29:34 2005 for Lamp by doxygen 1.3.2