00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef CL_VECTORS_TMPL_4_h
00031 #define CL_VECTORS_TMPL_4_h
00032
00033 #include "SugoiTools\cl_vectors_template.h"
00034
00035 #if SG_TLS_MEMORY_MANAGER
00036 #include "SugoiTools\debug_new.h"
00037 #endif
00038
00039
00040 namespace SGE{
00041
00042 template <typename TType> class CL_Vector4D_Base;
00043 template <typename TType> class CL_Color4;
00044
00045 typedef CL_Color4<float> CL_Color4f;
00046 typedef CL_Color4<int> CL_Color4i;
00047 typedef CL_Color4<double> CL_Color4d;
00048
00049 typedef CL_Vector4D_Base<float> CL_Vector4Df;
00050 typedef CL_Vector4D_Base<int> CL_Vector4Di;
00051 typedef CL_Vector4D_Base<double> CL_Vector4Dd;
00052
00053
00054
00055
00056
00057
00058
00066 template <typename TType> class CL_Vector4D_Base : public CLT_Vector<TType>
00067 {
00068 public :
00069
00070
00071 _SG_TLS_INLINE CL_Vector4D_Base();
00072 _SG_TLS_INLINE CL_Vector4D_Base(const CLT_Vector<TType> &_Vec);
00073
00074
00075
00076
00077
00078 _SG_TLS_INLINE ~CL_Vector4D_Base();
00079
00080
00081 _SG_TLS_INLINE void Set(const TType _a, const TType _b, const TType _c , const TType _d);
00082
00083 _SG_TLS_INLINE CL_Vector4D_Base<TType> & operator= (const CL_Vector4D_Base<TType> & _Vec2);
00084 _SG_TLS_INLINE CL_Vector4D_Base<TType> & operator= (const TType * _Val);
00085 _SG_TLS_INLINE CL_Vector4D_Base<TType> & operator= (const TType _Val);
00086
00087
00088 #if _SG_TLS_XML
00089 _SG_TLS_INLINE
00090 TiXmlElement*
00091 XMLLoad(TiXmlElement* XML_Elem,
00092 const std::string _name,
00093 const CL_Vector4D_Base<TType> &_defVal);
00094
00095 _SG_TLS_INLINE
00096 TiXmlElement*
00097 XMLLoad(TiXmlElement* XML_Elem,
00098 const std::string _name,
00099 TType _defVal = 0);
00100
00101 _SG_TLS_INLINE
00102 TiXmlElement*
00103 XMLLoad(TiXmlElement* XML_Elem,
00104 const std::string _name,
00105 std::string _type,
00106 const CL_Vector4D_Base<TType> &_defVal);
00107
00108 _SG_TLS_INLINE
00109 TiXmlElement*
00110 XMLLoad(TiXmlElement* XML_Elem,
00111 const std::string _name,
00112 std::string _type,
00113 TType _defVal = 0);
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 #endif
00126 };
00127
00128
00129
00130
00131
00132
00133
00134
00139 template <typename TType>
00140 CL_Vector4D_Base<TType>::CL_Vector4D_Base()
00141 : CLT_Vector<TType>(4, 0.)
00142 {}
00143
00148 template <typename TType>
00149 CL_Vector4D_Base<TType>::CL_Vector4D_Base(const CLT_Vector<TType> &_Vec)
00150 : CLT_Vector<TType>(_Vec)
00151 {}
00152
00157 template <typename TType> CL_Vector4D_Base<TType>::~CL_Vector4D_Base()
00158 {}
00159
00164 template <typename TType> void CL_Vector4D_Base<TType>::Set(const TType _a, const TType _b, const TType _c , const TType _d)
00165 {
00166 vec[0] = _a;
00167 vec[1] = _b;
00168 vec[2] = _c;
00169 vec[3] = _d;
00170 }
00171
00172 template <typename TType> CL_Vector4D_Base<TType> & CL_Vector4D_Base<TType>::operator= (const CL_Vector4D_Base<TType> & _Vec2)
00173 {
00174 VECTOR_OP_EQUAL(this, _Vec2.vec[i], , GetDim());
00175 return(*this);
00176 }
00177 template <typename TType> CL_Vector4D_Base<TType> & CL_Vector4D_Base<TType>::operator= (const TType * _Val)
00178 {
00179 SG_Assert(_Val, "Given Value is NULL");
00180 VECTOR_OP_EQUAL(this, _Val[i], , GetDim());
00181 return(*this);
00182 }
00183 template <typename TType> CL_Vector4D_Base<TType> & CL_Vector4D_Base<TType>::operator= (const TType _Val)
00184 {
00185 VECTOR_OP_EQUAL(this, _Val, , GetDim());
00186 return(*this);
00187 }
00188
00189
00190
00191 #if _SG_TLS_XML
00192 template <typename TType>
00193 TiXmlElement*
00194 CL_Vector4D_Base<TType>::XMLLoad(TiXmlElement* XML_Elem,
00195 const std::string _name,
00196 const CL_Vector4D_Base<TType> &_defVal = CL_Vector4D_Base<TType>())
00197 {
00198 TiXmlElement* XMLTag = CLT_Vector<TType>::XMLLoad(XML_Elem, _name);
00199 if (!XMLTag)
00200 (*this) = _defVal;
00201
00202 return XMLTag;
00203 }
00204
00205 template <typename TType>
00206 TiXmlElement*
00207 CL_Vector4D_Base<TType>::XMLLoad(TiXmlElement* XML_Elem,
00208 const std::string _name,
00209 TType _defVal = 0)
00210 {
00211 return CLT_Vector<TType>::XMLLoad(XML_Elem, _name, _defVal);
00212 }
00213
00214
00215
00216 template <typename TType>
00217 TiXmlElement*
00218 CL_Vector4D_Base<TType>::XMLLoad(TiXmlElement* XML_Elem,
00219 const std::string _name,
00220 std::string _type,
00221 const CL_Vector4D_Base<TType> &_defVal = CL_Vector4D_Base<TType>())
00222 {
00223 TiXmlElement* XMLTag = CLT_Vector<TType>::XMLLoad(XML_Elem, _name, _type);
00224 if (!XMLTag)
00225 (*this) = _defVal;
00226
00227 return XMLTag;
00228 }
00229
00230
00231 template <typename TType>
00232 TiXmlElement*
00233 CL_Vector4D_Base<TType>::XMLLoad(TiXmlElement* XML_Elem,
00234 const std::string _name,
00235 std::string _type,
00236 TType _defVal = 0)
00237 {
00238 return CLT_Vector<TType>::XMLLoad(XML_Elem, _name, _type, _defVal);
00239 }
00240 #endif
00241
00242
00243
00244
00245
00246
00247
00248 template <typename TType> class CL_Color4 : public CL_Vector4D_Base<TType>
00249 {
00250 public :
00252 TType &r;
00253 TType &g;
00254 TType &b;
00255 TType &a;
00256
00257
00258 _SG_TLS_INLINE
00259 CL_Color4()
00260 :CL_Vector4D_Base<TType>(),
00261 r(CL_Vector4D_Base<TType>::vec[0]),
00262 g(CL_Vector4D_Base<TType>::vec[1]),
00263 b(CL_Vector4D_Base<TType>::vec[2]),
00264 a(CL_Vector4D_Base<TType>::vec[3])
00265 {
00266 }
00267
00268 _SG_TLS_INLINE
00269 CL_Color4(CL_Color4 &_Col)
00270 :CL_Vector4D_Base<TType>(_Col),
00271 r(CL_Vector4D_Base<TType>::vec[0]),
00272 g(CL_Vector4D_Base<TType>::vec[1]),
00273 b(CL_Vector4D_Base<TType>::vec[2]),
00274 a(CL_Vector4D_Base<TType>::vec[3])
00275 {
00276 }
00277
00278
00279 _SG_TLS_INLINE
00280 CL_Color4(const TType _r, const TType _g,const TType _b, const TType _a)
00281 :CL_Vector4D_Base<TType>(),
00282 r(CL_Vector4D_Base<TType>::vec[0]),
00283 g(CL_Vector4D_Base<TType>::vec[1]),
00284 b(CL_Vector4D_Base<TType>::vec[2]),
00285 a(CL_Vector4D_Base<TType>::vec[3])
00286 {
00287 Set(_r, _g, _b, _a);
00288 }
00289
00290 _SG_TLS_INLINE
00291 ~CL_Color4()
00292 {}
00293
00294 _SG_TLS_INLINE
00295 void Draw()
00296 {
00297 glColor4f(r, g, b, a);
00298 }
00299
00300 _SG_TLS_INLINE
00301 CL_Color4<TType> &
00302 operator= (const CL_Vector4D_Base<TType> & _Vec2)
00303 {
00304 VECTOR_OP_EQUAL(this, _Vec2.vec[i], , GetDim());
00305 return (*this);
00306 }
00307
00308 _SG_TLS_INLINE
00309 CL_Color4<TType> &
00310 operator= (const TType * _Val)
00311 {
00312 return (*this) = CLT_Vector<TType>(4, _Val);
00313 }
00314
00315 _SG_TLS_INLINE
00316 CL_Color4<TType> &
00317 operator= (const TType _Val)
00318 {
00319 return(*this) = CLT_Vector<TType>(4,_Val);
00320 }
00321 };
00322
00323 };
00324
00325 #if SG_TLS_MEMORY_MANAGER
00326 #include "SugoiTools\debug_new_off.h"
00327 #endif
00328 #endif//CL_VECTORS_TMPL_4_h