3 * ***** BEGIN GPL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20 * All rights reserved.
22 * The Original Code is: all of this file.
24 * Contributor(s): none yet.
26 * ***** END GPL LICENSE BLOCK *****
29 #if defined(WIN32) && !defined(FREE_WINDOWS)
30 #pragma warning (disable:4786)
33 #include "RAS_Polygon.h"
34 #include "RAS_MeshObject.h" /* only for GetVertexOffsetAbs */
36 RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
40 m_offset[0]= m_offset[1]= m_offset[2]= m_offset[3]= 0;
47 int RAS_Polygon::VertexCount()
52 void RAS_Polygon::SetVertexOffset(int i, unsigned short offset)
57 RAS_TexVert *RAS_Polygon::GetVertex(int i)
59 return &m_darray->m_vertex[m_offset[i]];
62 int RAS_Polygon::GetVertexOffset(int i)
67 int RAS_Polygon::GetVertexOffsetAbs(RAS_MeshObject *mesh, int i)
69 /* hack that only works because there can only ever be 2 different
70 * GetDisplayArray's per mesh. if this uses a different display array to the first
71 * then its incices are offset.
72 * if support for edges is added back this would need to be changed. */
73 RAS_DisplayArray* darray= mesh->GetPolygon(0)->GetDisplayArray();
75 if(m_darray != darray)
76 return m_offset[i] + darray->m_vertex.size();
82 int RAS_Polygon::GetEdgeCode()
87 void RAS_Polygon::SetEdgeCode(int edgecode)
89 m_edgecode = edgecode;
93 bool RAS_Polygon::IsVisible()
95 return (m_polyflags & VISIBLE) != 0;
98 void RAS_Polygon::SetVisible(bool visible)
100 if(visible) m_polyflags |= VISIBLE;
101 else m_polyflags &= ~VISIBLE;
104 bool RAS_Polygon::IsCollider()
106 return (m_polyflags & COLLIDER) != 0;
109 void RAS_Polygon::SetCollider(bool visible)
111 if(visible) m_polyflags |= COLLIDER;
112 else m_polyflags &= ~COLLIDER;
115 bool RAS_Polygon::IsTwoside()
117 return (m_polyflags & TWOSIDE) != 0;
120 void RAS_Polygon::SetTwoside(bool twoside)
122 if(twoside) m_polyflags |= TWOSIDE;
123 else m_polyflags &= ~TWOSIDE;
126 RAS_MaterialBucket* RAS_Polygon::GetMaterial()
131 RAS_DisplayArray* RAS_Polygon::GetDisplayArray()