Blender  V2.59
RAS_Polygon.h
Go to the documentation of this file.
00001 /*
00002  * $Id: RAS_Polygon.h 35072 2011-02-22 12:42:55Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #ifndef __RAS_POLYGON
00035 #define __RAS_POLYGON
00036 
00037 #include "RAS_TexVert.h"
00038 #include "RAS_MaterialBucket.h"
00039 
00040 #include <vector>
00041 using namespace std;
00042 
00043 #ifdef WITH_CXX_GUARDEDALLOC
00044 #include "MEM_guardedalloc.h"
00045 #endif
00046 
00047 /* polygon flags */
00048 
00049 class RAS_Polygon
00050 {
00051         /* location */
00052         RAS_MaterialBucket*                     m_bucket;
00053         RAS_DisplayArray*                       m_darray;
00054         unsigned short                          m_offset[4];
00055         unsigned short                          m_numvert;
00056 
00057         /* flags */
00058 #if 1
00059         unsigned short                  m_polyflags;
00060 #else
00061         unsigned char                           m_edgecode;
00062         unsigned char                           m_polyflags;
00063 #endif
00064         
00065 public:
00066         enum {
00067                 VISIBLE = 1,
00068                 COLLIDER = 2,
00069                 TWOSIDE = 4
00070         };
00071 
00072         RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray* darray, int numvert);
00073         virtual ~RAS_Polygon() {};
00074         
00075         int                                     VertexCount();
00076         RAS_TexVert*            GetVertex(int i);
00077 
00078         void                            SetVertexOffset(int i, unsigned short offset);
00079         int                                     GetVertexOffset(int i);
00080         int                                     GetVertexOffsetAbs(RAS_MeshObject *mesh, int i); /* accounts for quad and tri arrays, slower, for python */
00081         
00082         // each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
00083         // - Not used yet!
00084 /*      int                                     GetEdgeCode();
00085         void                            SetEdgeCode(int edgecode); */
00086         
00087         bool                            IsVisible();
00088         void                            SetVisible(bool visible);
00089 
00090         bool                            IsCollider();
00091         void                            SetCollider(bool collider);
00092 
00093         bool                            IsTwoside();
00094         void                            SetTwoside(bool twoside);
00095 
00096         RAS_MaterialBucket*     GetMaterial();
00097         RAS_DisplayArray*       GetDisplayArray();
00098         
00099 #ifdef WITH_CXX_GUARDEDALLOC
00100 public:
00101         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Polygon"); }
00102         void operator delete( void *mem ) { MEM_freeN(mem); }
00103 #endif
00104 };
00105 
00106 #endif
00107