Blender V2.61 - r43446

RAS_Polygon.cpp

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 
00033 #if defined(WIN32) && !defined(FREE_WINDOWS)
00034 #pragma warning (disable:4786)
00035 #endif
00036 
00037 #include "RAS_Polygon.h"
00038 #include "RAS_MeshObject.h" /* only for GetVertexOffsetAbs */
00039 
00040 RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
00041 {
00042     m_bucket = bucket;
00043     m_darray = darray;
00044     m_offset[0]= m_offset[1]= m_offset[2]= m_offset[3]= 0;
00045     m_numvert = numvert;
00046 
00047 //  m_edgecode = 255;
00048     m_polyflags = 0;
00049 }
00050 
00051 int RAS_Polygon::VertexCount()
00052 {
00053     return m_numvert;
00054 }
00055 
00056 void RAS_Polygon::SetVertexOffset(int i, unsigned short offset)
00057 {
00058     m_offset[i] = offset;
00059 }
00060 
00061 RAS_TexVert *RAS_Polygon::GetVertex(int i)
00062 {
00063     return &m_darray->m_vertex[m_offset[i]];
00064 }
00065 
00066 int RAS_Polygon::GetVertexOffset(int i)
00067 {
00068     return m_offset[i];
00069 }
00070 
00071 int RAS_Polygon::GetVertexOffsetAbs(RAS_MeshObject *mesh, int i)
00072 {
00073     /* hack that only works because there can only ever be 2 different
00074      * GetDisplayArray's per mesh. if this uses a different display array to the first
00075      * then its incices are offset.
00076      * if support for edges is added back this would need to be changed. */
00077     RAS_DisplayArray* darray= mesh->GetPolygon(0)->GetDisplayArray();
00078     
00079     if(m_darray != darray)
00080         return m_offset[i] + darray->m_vertex.size();
00081     
00082     return m_offset[i];
00083 }
00084 
00085 /*
00086 int RAS_Polygon::GetEdgeCode()
00087 {
00088     return m_edgecode;
00089 }
00090 
00091 void RAS_Polygon::SetEdgeCode(int edgecode)
00092 {
00093     m_edgecode = edgecode;
00094 }*/
00095 
00096     
00097 bool RAS_Polygon::IsVisible()
00098 {
00099     return (m_polyflags & VISIBLE) != 0;
00100 }
00101 
00102 void RAS_Polygon::SetVisible(bool visible)
00103 {
00104     if(visible) m_polyflags |= VISIBLE;
00105     else m_polyflags &= ~VISIBLE;
00106 }
00107 
00108 bool RAS_Polygon::IsCollider()
00109 {
00110     return (m_polyflags & COLLIDER) != 0;
00111 }
00112 
00113 void RAS_Polygon::SetCollider(bool visible)
00114 {
00115     if(visible) m_polyflags |= COLLIDER;
00116     else m_polyflags &= ~COLLIDER;
00117 }
00118 
00119 bool RAS_Polygon::IsTwoside()
00120 {
00121     return (m_polyflags & TWOSIDE) != 0;
00122 }
00123 
00124 void RAS_Polygon::SetTwoside(bool twoside)
00125 {
00126     if(twoside) m_polyflags |= TWOSIDE;
00127     else m_polyflags &= ~TWOSIDE;
00128 }
00129 
00130 RAS_MaterialBucket* RAS_Polygon::GetMaterial()
00131 {
00132     return m_bucket;
00133 }
00134 
00135 RAS_DisplayArray* RAS_Polygon::GetDisplayArray()
00136 {
00137     return m_darray;
00138 }