Blender V2.61 - r43446

RAS_TexVert.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef __RAS_TEXVERT
00033 #define __RAS_TEXVERT
00034 
00035 
00036 #include "MT_Point3.h"
00037 #include "MT_Point2.h"
00038 #include "MT_Transform.h"
00039 
00040 #ifdef WITH_CXX_GUARDEDALLOC
00041 #include "MEM_guardedalloc.h"
00042 #endif
00043 
00044 static MT_Point3 g_pt3;
00045 static MT_Point2 g_pt2;
00046 
00047 class RAS_TexVert
00048 {
00049     
00050     float           m_localxyz[3];  // 3*4 = 12
00051     float           m_uv1[2];       // 2*4 =  8
00052     float           m_uv2[2];       // 2*4 =  8
00053     unsigned int    m_rgba;         //        4
00054     float           m_tangent[4];   // 4*4 =  16
00055     float           m_normal[3];    // 3*4 =  12
00056     short           m_flag;         //        2
00057     short           m_softBodyIndex;        //2
00058     unsigned int    m_unit;         //        4
00059     unsigned int    m_origindex;        //    4
00060                                     //---------
00061                                     //       56+6+8+2=72
00062     // 32 bytes total size, fits nice = 56 = not fit nice.
00063 
00064 public:
00065     enum {
00066         FLAT = 1,
00067         SECOND_UV = 2,
00068         MAX_UNIT = 8
00069     };
00070 
00071     short getFlag() const;
00072     unsigned int getUnit() const;
00073     
00074     RAS_TexVert()// :m_xyz(0,0,0),m_uv(0,0),m_rgba(0)
00075     {}
00076     RAS_TexVert(const MT_Point3& xyz,
00077                 const MT_Point2& uv,
00078                 const MT_Point2& uv2,
00079                 const MT_Vector4& tangent,
00080                 const unsigned int rgba,
00081                 const MT_Vector3& normal,
00082                 const bool flat,
00083                 const unsigned int origindex);
00084     ~RAS_TexVert() {};
00085 
00086     const float* getUV1 () const { 
00087         return m_uv1;
00088     };
00089 
00090     const float* getUV2 () const { 
00091         return m_uv2;
00092     };
00093 
00094     const float* getXYZ() const { 
00095         return m_localxyz;
00096     };
00097     
00098     const float* getNormal() const {
00099         return m_normal;
00100     }
00101     
00102     short int getSoftBodyIndex() const
00103     {
00104         return m_softBodyIndex;
00105     }
00106     
00107     void    setSoftBodyIndex(short int sbIndex)
00108     {
00109         m_softBodyIndex = sbIndex;
00110     }
00111 
00112     const float* getTangent() const {
00113         return m_tangent;
00114     }
00115 
00116     const unsigned char* getRGBA() const {
00117         return (unsigned char *) &m_rgba;
00118     }
00119 
00120     unsigned int getOrigIndex() const {
00121         return m_origindex;
00122     }
00123 
00124     void                SetXYZ(const MT_Point3& xyz);
00125     void                SetXYZ(const float *xyz);
00126     void                SetUV(const MT_Point2& uv);
00127     void                SetUV2(const MT_Point2& uv);
00128 
00129     void                SetRGBA(const unsigned int rgba);
00130     void                SetNormal(const MT_Vector3& normal);
00131     void                SetTangent(const MT_Vector3& tangent);
00132     void                SetFlag(const short flag);
00133     void                SetUnit(const unsigned u);
00134     
00135     void                SetRGBA(const MT_Vector4& rgba);
00136     const MT_Point3&    xyz();
00137 
00138     void                Transform(const class MT_Matrix4x4& mat,
00139                                   const class MT_Matrix4x4& nmat);
00140 
00141     // compare two vertices, to test if they can be shared, used for
00142     // splitting up based on uv's, colors, etc
00143     bool                closeTo(const RAS_TexVert* other);
00144     
00145 #ifdef WITH_CXX_GUARDEDALLOC
00146 public:
00147     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_TexVert"); }
00148     void operator delete( void *mem ) { MEM_freeN(mem); }
00149 #endif
00150 };
00151 
00152 #endif //__RAS_TEXVERT
00153