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_INTERPOLATOR_H_ 00026 #define ROTATION_INTERPOLATOR_H_ 00027 00028 namespace Lamp{ 00029 00030 class RotationConstantInterpolator; 00031 class EulerArrayInterpolator; 00032 class QuaternionArrayInterpolator; 00033 class QuaternionLinearInterpolator; 00034 00035 //------------------------------------------------------------------------------ 00036 /** 00037 * 回転補間 00038 * 00039 * サブクラスでコピーコンストラクタと代入演算子を実装する 00040 */ 00041 class RotationInterpolator{ 00042 public: 00043 //-------------------------------------------------------------------------- 00044 /** 00045 * デストラクタ 00046 */ 00047 virtual ~RotationInterpolator(){} 00048 00049 //-------------------------------------------------------------------------- 00050 /** 00051 * 複製 00052 * @return 複製された回転補間。呼び出し元でdeleteする必要がある 00053 */ 00054 virtual RotationInterpolator* duplicate() const = 0; 00055 00056 /** 00057 * 同じ値かどうか 00058 * @param target 比較対象 00059 * @return 同じ値ならtrueをかえす 00060 */ 00061 virtual bool equals(const RotationInterpolator& target) const = 0; 00062 00063 //-------------------------------------------------------------------------- 00064 /** 00065 * 長さの取得 00066 * @return 長さ 00067 */ 00068 virtual float getLength() const = 0; 00069 00070 //-------------------------------------------------------------------------- 00071 // オイラー補間 00072 //-------------------------------------------------------------------------- 00073 /** 00074 * オイラー補間かどうか 00075 * @return オイラー補間ならtrue 00076 */ 00077 virtual bool isEulerInterpolator() const = 0; 00078 00079 /** 00080 * オイラー補間 00081 * @param time 時間 00082 * @return 補間された回転 00083 */ 00084 virtual Vector3 eulerInterpolate(float time) = 0; 00085 00086 //-------------------------------------------------------------------------- 00087 // クォータニオン補間 00088 //-------------------------------------------------------------------------- 00089 /** 00090 * クォータニオン補間かどうか 00091 * @return クォータニオン補間ならtrue 00092 */ 00093 virtual bool isQuaternionInterpolator() const = 0; 00094 00095 /** 00096 * クォータニオン補間 00097 * @param time 時間 00098 * @return 補間された回転 00099 */ 00100 virtual Quaternion quaternionInterpolate(float time) = 0; 00101 00102 //-------------------------------------------------------------------------- 00103 // RTTI 00104 //-------------------------------------------------------------------------- 00105 /** 00106 * 回転定数補間かどうか 00107 * @return 回転定数補間ならtrue 00108 */ 00109 virtual bool isRotationConstantInterpolator() const{ return false; } 00110 00111 /** 00112 * 回転定数補間へのキャスト 00113 * @return 回転定数補間。型が違えばNULLを返す。 00114 */ 00115 virtual RotationConstantInterpolator* 00116 castRotationConstantInterpolator() const{ 00117 if(isRotationConstantInterpolator()){ 00118 return (RotationConstantInterpolator*)this; 00119 } 00120 return NULL; 00121 } 00122 00123 //-------------------------------------------------------------------------- 00124 /** 00125 * オイラー回転配列補間かどうか 00126 * @return オイラー回転配列補間ならtrue 00127 */ 00128 virtual bool isEulerArrayInterpolator() const{ return false; } 00129 00130 /** 00131 * オイラー回転配列補間へのキャスト 00132 * @return オイラー回転配列補間。型が違えばNULLを返す。 00133 */ 00134 virtual EulerArrayInterpolator* 00135 castEulerArrayInterpolator() const{ 00136 if(isEulerArrayInterpolator()){ 00137 return (EulerArrayInterpolator*)this; 00138 } 00139 return NULL; 00140 } 00141 00142 //-------------------------------------------------------------------------- 00143 /** 00144 * 四元数回転配列補間かどうか 00145 * @return 四元数回転配列補間ならtrue 00146 */ 00147 virtual bool isQuaternionArrayInterpolator() const{ return false; } 00148 00149 /** 00150 * 四元数回転配列補間へのキャスト 00151 * @return 四元数回転配列補間。型が違えばNULLを返す。 00152 */ 00153 virtual QuaternionArrayInterpolator* 00154 castQuaternionArrayInterpolator() const{ 00155 if(isQuaternionArrayInterpolator()){ 00156 return (QuaternionArrayInterpolator*)this; 00157 } 00158 return NULL; 00159 } 00160 00161 //-------------------------------------------------------------------------- 00162 /** 00163 * 四元数回転線形補間かどうか 00164 * @return 四元数回転線形補間ならtrue 00165 */ 00166 virtual bool isQuaternionLinearInterpolator() const{ return false; } 00167 00168 /** 00169 * 四元数回転線形補間へのキャスト 00170 * @return 四元数回転線形補間。型が違えばNULLを返す。 00171 */ 00172 virtual QuaternionLinearInterpolator* 00173 castQuaternionLinearInterpolator() const{ 00174 if(isQuaternionLinearInterpolator()){ 00175 return (QuaternionLinearInterpolator*)this; 00176 } 00177 return NULL; 00178 } 00179 00180 }; 00181 00182 //------------------------------------------------------------------------------ 00183 } // End of namespace Lamp 00184 #endif // End of ROTATION_INTERPOLATOR_H_ 00185 //------------------------------------------------------------------------------ 00186