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

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

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