00001
00002
00003 #ifndef __RAS_TEXVERT
00004 #define __RAS_TEXVERT
00005
00006
00007 #include "MT_Point3.h"
00008 #include "MT_Point2.h"
00009 #include "MT_Transform.h"
00010
00011
00012 static MT_Point3 g_pt3;
00013 static MT_Point2 g_pt2;
00014
00015 class RAS_TexVert
00016 {
00017 float m_localxyz[3];
00018 float m_uv1[2];
00019 unsigned int m_rgba;
00020 short m_normal[3];
00021 short pad;
00022
00023
00024 public:
00025 RAS_TexVert()
00026 {}
00027 RAS_TexVert(const MT_Point3& xyz,const MT_Point2& uv,const unsigned int rgba,const short *normal)
00028 {
00029 xyz.getValue(m_localxyz);
00030 uv.getValue(m_uv1);
00031 SetRGBA(rgba);
00032 m_normal[0] = normal[0];
00033 m_normal[1] = normal[1];
00034 m_normal[2] = normal[2];
00035 };
00036 ~RAS_TexVert() {};
00037
00038
00039 const float* getUV1 () const {
00040 return m_uv1;
00041 };
00042
00043 const MT_Point3& xyz() { g_pt3.setValue(m_localxyz); return g_pt3; };
00044
00045 void SetXYZ(const MT_Point3& xyz) { xyz.getValue(m_localxyz);};
00046 void SetUV(const MT_Point2& uv) { uv.getValue(m_uv1); };
00047 inline void SetRGBA(const unsigned int rgba) {
00048 m_rgba = rgba;
00049 };
00050 void SetNormal(const MT_Vector3& normal) {
00051 m_normal[0] = short(normal.x()*32767.0);
00052 m_normal[1] = short(normal.y()*32767.0);
00053 m_normal[2] = short(normal.z()*32767.0);
00054 };
00055
00056 const short* getNormal() const {
00057 return m_normal;
00058 };
00059 const float* getLocalXYZ() const {
00060 return m_localxyz;
00061 };
00062 const unsigned int& getRGBA() const { return m_rgba;}
00063
00064 bool closeTo(const RAS_TexVert* other)
00065 {
00066 bool result =
00067 (MT_Vector3(m_localxyz) - MT_Vector3(other->m_localxyz)).fuzzyZero() &&
00068 (MT_Vector2(m_uv1) - MT_Vector2(other->m_uv1)).fuzzyZero() &&
00069 m_normal[0] == other->m_normal[0] &&
00070 m_normal[1] == other->m_normal[1] &&
00071 m_normal[2] == other->m_normal[2] &&
00072 m_rgba == other->m_rgba ;
00073 if (result)
00074 {
00075 int i=0;
00076 }
00077 return result;
00078
00079 }
00080
00081 };
00082
00083 #endif //__RAS_TEXVERT