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 VECTOR_CONSTANT_INTERPOLATOR_H_ 00026 #define VECTOR_CONSTANT_INTERPOLATOR_H_ 00027 00028 #include <Animation/VectorInterpolator/VectorInterpolator.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * ベクトル定数補間 00035 */ 00036 class VectorConstantInterpolator : public VectorInterpolator{ 00037 public: 00038 //-------------------------------------------------------------------------- 00039 /** 00040 * コンストラクタ 00041 */ 00042 VectorConstantInterpolator() : value_(Vector3::zero), length_(0.f){} 00043 00044 /** 00045 * デストラクタ 00046 */ 00047 virtual ~VectorConstantInterpolator(){} 00048 00049 /** 00050 * コピーコンストラクタ 00051 * @param copy コピー元 00052 */ 00053 explicit VectorConstantInterpolator( 00054 const VectorConstantInterpolator& copy){ 00055 value_ = copy.value_; 00056 length_ = copy.length_; 00057 } 00058 00059 /** 00060 * 代入演算子 00061 * @param copy 代入元 00062 */ 00063 virtual VectorConstantInterpolator& operator =( 00064 const VectorConstantInterpolator& copy){ 00065 // 自分自身ならリターン 00066 if(this == ©){ return *this; } 00067 value_ = copy.value_; 00068 length_ = copy.length_; 00069 return *this; 00070 } 00071 00072 //-------------------------------------------------------------------------- 00073 /** 00074 * 複製 00075 * @return 複製されたベクトル補間。呼び出し元でdeleteする必要がある 00076 */ 00077 virtual VectorInterpolator* duplicate() const{ 00078 VectorInterpolator* result = new VectorConstantInterpolator(*this); 00079 return result; 00080 } 00081 00082 //-------------------------------------------------------------------------- 00083 /** 00084 * 同じ値かどうか 00085 * @param target 比較対象 00086 * @return 同じ値ならtrueをかえす 00087 */ 00088 virtual bool equals(const VectorInterpolator& target) const{ 00089 VectorConstantInterpolator* interpolator = 00090 target.castVectorConstantInterpolator(); 00091 if(interpolator == NULL){ return false; } 00092 return ((value_ == interpolator->value_) && 00093 (length_ == interpolator->length_)); 00094 } 00095 00096 //-------------------------------------------------------------------------- 00097 // 長さ 00098 //-------------------------------------------------------------------------- 00099 /** 00100 * 長さの取得 00101 * @return 長さ 00102 */ 00103 virtual float getLength() const{ return length_; } 00104 00105 /** 00106 * 長さの設定 00107 * @param length 長さ 00108 */ 00109 virtual void setLength(float length){ 00110 Assert(length >= 0.f); 00111 length_ = length; 00112 } 00113 00114 //-------------------------------------------------------------------------- 00115 // バウンディング 00116 //-------------------------------------------------------------------------- 00117 /** 00118 * バウンディングボックスの取得 00119 * @return バウンディングボックス 00120 */ 00121 virtual AxisAlignedBox getBoundingBox() const{ 00122 AxisAlignedBox result; 00123 result.set(value_, value_); 00124 return result; 00125 } 00126 00127 //-------------------------------------------------------------------------- 00128 // 補間 00129 //-------------------------------------------------------------------------- 00130 /** 00131 * 補間 00132 * @param time 時間 00133 * @return 補間されたベクトル 00134 */ 00135 virtual Vector3 interpolate(float time){ return value_; } 00136 00137 //-------------------------------------------------------------------------- 00138 // 値 00139 //-------------------------------------------------------------------------- 00140 /** 00141 * 値の設定 00142 * @param value 設定する値 00143 */ 00144 virtual void setValue(const Vector3& value){ value_ = value; } 00145 00146 /** 00147 * 値の取得 00148 * @return 取得した値 00149 */ 00150 virtual Vector3 getValue() const{ return value_; } 00151 00152 //-------------------------------------------------------------------------- 00153 /** 00154 * ベクトル定数補間かどうか 00155 * @return ベクトル定数補間ならtrue 00156 */ 00157 virtual bool isVectorConstantInterpolator() const{ return true; } 00158 00159 //-------------------------------------------------------------------------- 00160 private: 00161 // 定数 00162 Vector3 value_; 00163 // 長さ 00164 float length_; 00165 00166 }; 00167 00168 //------------------------------------------------------------------------------ 00169 } // End of namespace Lamp 00170 #endif // End of VECTOR_CONSTANT_INTERPOLATOR_H_ 00171 //------------------------------------------------------------------------------ 00172