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

TexCoord1.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 TEX_COORD_1_H_
00026 #define TEX_COORD_1_H_
00027 
00028 #include <Core/System/Math.h>
00029 #include <Core/Primitive/String.h>
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 /**
00035  * 一次元テクスチャ座標
00036  *
00037  * このクラスは継承しないで下さい。
00038  */
00039 class TexCoord1{
00040 public:
00041     //--------------------------------------------------------------------------
00042     // メンバ変数
00043     //--------------------------------------------------------------------------
00044     /// メンバ変数
00045     union{
00046         /// 各要素
00047         struct{
00048             /// U値
00049             float u;
00050         };
00051 
00052         /// 配列
00053         float array[1];
00054     };
00055 
00056     //--------------------------------------------------------------------------
00057     // 定数
00058     //--------------------------------------------------------------------------
00059     /// ゼロ座標
00060     static const TexCoord1 zero;
00061 
00062     /// 単位座標
00063     static const TexCoord1 unit;
00064 
00065     /// U単位座標
00066     static const TexCoord1 unitU;
00067 
00068     //--------------------------------------------------------------------------
00069     // コンストラクタ
00070     //--------------------------------------------------------------------------
00071     /**
00072      * コンストラクタ
00073      *
00074      * このコンストラクタは初期値の設定を行わないため値は不定です。
00075      */
00076     inline TexCoord1(){}
00077 
00078     /**
00079      * コンストラクタ
00080      * @param sourceU Uの初期値
00081      */
00082     inline TexCoord1(float sourceU) : u(sourceU){}
00083 
00084     /**
00085      * コンストラクタ
00086      * @param source 初期値配列
00087      */
00088     inline explicit TexCoord1(const float* const source) : u(source[0]){}
00089 
00090     //--------------------------------------------------------------------------
00091     // 値の設定
00092     //--------------------------------------------------------------------------
00093     /**
00094      * 値の設定
00095      * @param sourceU Uの設定値
00096      */
00097     inline void set(float sourceU){ u = sourceU; }
00098 
00099     /**
00100      * 値の設定
00101      * @param source 設定値配列
00102      */
00103     inline void set(const float* const source){ u = source[0]; }
00104 
00105     //--------------------------------------------------------------------------
00106     // 演算
00107     //--------------------------------------------------------------------------
00108     /**
00109      * 加算
00110      * @param addCoord 加算する一次元テクスチャ座標
00111      * @return 加算された一次元テクスチャ座標
00112      */
00113     inline TexCoord1 operator +(const TexCoord1& addCoord) const{
00114         return TexCoord1(u + addCoord.u);
00115     }
00116 
00117     /**
00118      * 減算
00119      * @param subCoord 減算する一次元テクスチャ座標
00120      * @return 減算された一次元テクスチャ座標
00121      */
00122     inline TexCoord1 operator -(const TexCoord1& subCoord) const{
00123         return TexCoord1(u - subCoord.u);
00124     }
00125 
00126     /**
00127      * 乗算
00128      * @param mulValue 乗算する値
00129      * @return 乗算された一次元テクスチャ座標
00130      */
00131     inline TexCoord1 operator *(float mulValue) const{
00132         return TexCoord1(u * mulValue);
00133     }
00134 
00135     /**
00136      * 乗算
00137      * @param mulValue 乗算する値
00138      * @param mulCoord 乗算する一次元テクスチャ座標
00139      * @return 乗算された一次元テクスチャ座標
00140      */
00141     inline friend TexCoord1 operator *(
00142         float mulValue, const TexCoord1& mulCoord){
00143         return TexCoord1(mulCoord.u * mulValue);
00144     }
00145 
00146     /**
00147      * +演算子
00148      * @return 一次元テクスチャ座標のコピー
00149      */
00150     inline TexCoord1 operator +() const{ return *this; }
00151 
00152     /**
00153      * -演算子
00154      * @return 値の符号が反転した一次元テクスチャ座標
00155      */
00156     inline TexCoord1 operator -() const{ return TexCoord1(-u); }
00157 
00158     //--------------------------------------------------------------------------
00159     // 代入演算
00160     //--------------------------------------------------------------------------
00161     /**
00162      * 代入加算
00163      * @param addCoord 加算する一次元テクスチャ座標
00164      * @return 加算された一次元テクスチャ座標
00165      */
00166     inline TexCoord1& operator +=(const TexCoord1& addCoord){
00167         u += addCoord.u;
00168         return *this;
00169     }
00170 
00171     /**
00172      * 代入減算
00173      * @param subCoord 減算する一次元テクスチャ座標
00174      * @return 減算された一次元テクスチャ座標
00175      */
00176     inline TexCoord1& operator -=(const TexCoord1& subCoord){
00177         u -= subCoord.u;
00178         return *this;
00179     }
00180 
00181     /**
00182      * 代入乗算
00183      * @param mulValue 乗算する値
00184      * @return 乗算された一次元テクスチャ座標
00185      */
00186     inline TexCoord1& operator *=(float mulValue){
00187         u *= mulValue;
00188         return *this;
00189     }
00190 
00191     //--------------------------------------------------------------------------
00192     // 論理演算
00193     //--------------------------------------------------------------------------
00194     /**
00195      * 一次元テクスチャ座標が同じかどうか
00196      * @param target 比較する一次元テクスチャ座標
00197      * @return 同じ値であればtrueを返す
00198      */
00199     inline bool operator ==(const TexCoord1& target) const{
00200         return (u == target.u);
00201     }
00202 
00203     /**
00204      * 一次元テクスチャ座標が同じかどうか
00205      * @param target 比較する一次元テクスチャ座標
00206      * @param epsilon 誤差
00207      * @return 誤差の範囲内で同じ値であればtrueを返す
00208      */
00209     inline bool epsilonEquals(
00210         const TexCoord1& target, float epsilon) const{
00211         Assert(epsilon >= 0.f);
00212         return (Math::abs(u - target.u) <= epsilon);
00213     }
00214 
00215     /**
00216      * 一次元テクスチャ座標が同じでないかどうか
00217      * @param target 比較する一次元テクスチャ座標
00218      * @return 同じでない値であればtrueを返す
00219      */
00220     inline bool operator !=(const TexCoord1& target) const{
00221         return (u != target.u);
00222     }
00223 
00224     /**
00225      * 一次元テクスチャ座標が同じでないかどうか
00226      * @param target 比較する一次元テクスチャ座標
00227      * @param epsilon 誤差
00228      * @return 誤差の範囲内で同じでない値であればtrueを返す
00229      */
00230     inline bool notEpsilonEquals(
00231         const TexCoord1& target, float epsilon) const{
00232         Assert(epsilon >= 0.f);
00233         return (Math::abs(u - target.u) > epsilon);
00234     }
00235 
00236     //--------------------------------------------------------------------------
00237     // その他
00238     //--------------------------------------------------------------------------
00239     /**
00240      * 文字列化
00241      * @return 一次元テクスチャ座標の文字列表記
00242      */
00243     inline String toString() const{
00244         String returnString;
00245         returnString.format("( %.8f )", u);
00246         return returnString;
00247     }
00248 
00249     //--------------------------------------------------------------------------
00250 private:
00251 
00252 };
00253 
00254 //------------------------------------------------------------------------------
00255 } // End of namespace Lamp
00256 #endif // End of TEX_COORD_1_H_
00257 //------------------------------------------------------------------------------

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