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 #ifndef SG_TLS_CL_POS_H
00029 #define SG_TLS_CL_POS_H
00030
00031
00032 #include "SugoiTools\xml.h"
00033 #include "SugoiTools\cl_vector2.h"
00034 #include "SugoiTools\cl_vector3.h"
00035 #include "SugoiTools\cl_vector4.h"
00036
00037
00038 #include <gl\glut.h>
00039 #include <gl\gl.h>
00040 #pragma comment(lib ,"glut32.lib")
00041 #pragma comment(lib ,"opengl32.lib")
00042
00043 namespace SGE{
00044
00045 _SG_TLS_EXPORT _SG_TLS_INLINE void glTranslate (const CL_Vector2Df &_Vec);
00046 _SG_TLS_EXPORT _SG_TLS_INLINE void glRotate (const CL_Vector2Df &_Vec);
00047 _SG_TLS_EXPORT _SG_TLS_INLINE void glScale (const CL_Vector2Df &_Vec);
00048
00049 _SG_TLS_EXPORT _SG_TLS_INLINE void glTranslate(const CL_Vector3Df &_Vec);
00050 _SG_TLS_EXPORT _SG_TLS_INLINE void glRotate (const CL_Vector3Df &_Vec);
00051 _SG_TLS_EXPORT _SG_TLS_INLINE void glScale (const CL_Vector3Df &_Vec);
00052 _SG_TLS_EXPORT _SG_TLS_INLINE void glVertex (const CL_Vector3Df &_Vec);
00053
00054
00055 _SG_TLS_EXPORT _SG_TLS_INLINE void glScissor(const CL_Vector2Di &_Pos, const CL_Vector2Di &_Size);
00056
00057 _SG_TLS_EXPORT _SG_TLS_INLINE void glViewport(const CL_Vector2Di &_Pos, const CL_Vector2Di &_Size);
00058
00059
00060
00061
00062
00068 template <class VectorType> class CLT_POS
00069 :public CL_XML_OBJ
00070 {
00071 public:
00072 VectorType Pos;
00073 VectorType Rot;
00074 VectorType Scale;
00075
00079 _SG_TLS_INLINE
00080 CLT_POS()
00081 :CL_XML_OBJ("pos")
00082 {
00083 Clear();
00084 }
00085
00089 _SG_TLS_INLINE CLT_POS(CLT_POS & _Pos)
00090 :CL_XML_OBJ("pos")
00091 {
00092 this->Pos = _Pos.Pos;
00093 this->Rot = _Pos.Rot;
00094 this->Scale = _Pos.Scale;
00095 };
00096
00100 _SG_TLS_INLINE
00101 ~CLT_POS()
00102 {}
00103
00104
00108 _SG_TLS_INLINE
00109 void Clear()
00110 {
00111 Scale = 1;
00112 Pos.Clear();
00113 Rot.Clear();
00114 }
00115
00116
00117
00121 _SG_TLS_INLINE
00122 void DoTranslate()
00123 {glTranslate(Pos);}
00124
00128 _SG_TLS_INLINE void DoRotate()
00129 {glRotate(Rot);}
00130
00134 _SG_TLS_INLINE void DoScale()
00135 {glScale(Scale);}
00136
00141 _SG_TLS_INLINE void SetScale(VectorType _v)
00142 {Scale = _v;}
00147 _SG_TLS_INLINE void SetRot(VectorType _v)
00148 {Rot = _v;}
00153 _SG_TLS_INLINE void SetPos(VectorType _v)
00154 {Pos = _v;}
00155
00156
00157 #if _SG_TLS_XML
00158
00163 _SG_TLS_INLINE
00164 TiXmlElement*
00165 XMLLoad(TiXmlElement* XML_ROOT)
00166 {
00167 TiXmlElement* XML_Elm = CL_XML_OBJ::XMLLoad(XML_ROOT);
00168 Clear();
00169 Pos.XMLLoad (XML_Elm, "pos");
00170 Rot.XMLLoad (XML_Elm, "rot");
00171 Scale.XMLLoad (XML_Elm, "scale", 1);
00172 return XML_Elm;
00173 }
00174
00180 _SG_TLS_INLINE
00181 TiXmlElement*
00182 XMLSave(TiXmlElement* XML_ROOT)
00183 {
00184 TiXmlElement* XML_Elm = CL_XML_OBJ::XMLSave(XML_ROOT);
00185 SG_Assert(XML_ROOT, "CLT_POS::XMLSave() => XML root element empty");
00186 Pos.XMLSave (XML_Elm, "pos");
00187 Rot.XMLSave (XML_Elm, "rot");
00188 Scale.XMLSave (XML_Elm, "scale", 1);
00189 return XML_Elm;
00190 }
00191 #endif
00192
00196 _SG_TLS_INLINE CLT_POS &operator= (const CLT_POS &_Pos)
00197 {
00198 this->Pos = _Pos.Pos;
00199 this->Rot = _Pos.Rot;
00200 this->Scale = _Pos.Scale;
00201 return (*this);
00202 }
00203
00209 _SG_TLS_INLINE bool operator== (const CLT_POS &_Pos)
00210 {
00211 if (!(this->Pos == _Pos.Pos))
00212 return false;
00213 if (!(this->Rot == _Pos.Rot))
00214 return false;
00215 if (!(this->Scale == _Pos.Scale))
00216 return false;
00217 return true;
00218 }
00219 private:
00220 };
00221
00222
00223
00224 class _SG_TLS_EXPORT CL_VERTEX
00225 {
00226 public:
00227 CL_Color4f Color;
00228 CL_Vector2Df TexCoord;
00229 CL_Vector3Df Pos;
00230
00231 CL_VERTEX();
00232 ~CL_VERTEX();
00233 void Draw(bool _textured, bool _colored = true);
00234 #if _SG_TLS_XML
00235 _SG_TLS_INLINE TiXmlElement* XMLLoad(TiXmlElement* _XML_ROOT);
00236 _SG_TLS_INLINE TiXmlElement* XMLSave(TiXmlElement* _XML_ROOT);
00237 #endif
00238 };
00239
00240
00241 #define CL_POS3Df CLT_POS<CL_Vector3Df>
00242 #define CL_POS2Df CLT_POS<CL_Vector2Df>
00243
00244
00245 };
00246 #endif //SG_TLS_CL_POS_H