RAS_Polygon.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. /** \file gameengine/Rasterizer/RAS_Polygon.cpp
  28. * \ingroup bgerast
  29. */
  30. #ifdef _MSC_VER
  31. # pragma warning (disable:4786)
  32. #endif
  33. #include "RAS_Polygon.h"
  34. #include "RAS_MaterialBucket.h"
  35. RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
  36. {
  37. m_bucket = bucket;
  38. m_darray = darray;
  39. m_offset[0] = m_offset[1] = m_offset[2] = m_offset[3] = 0;
  40. m_numvert = numvert;
  41. // m_edgecode = 255;
  42. m_polyflags = 0;
  43. }
  44. int RAS_Polygon::VertexCount()
  45. {
  46. return m_numvert;
  47. }
  48. void RAS_Polygon::SetVertexOffset(int i, unsigned short offset)
  49. {
  50. m_offset[i] = offset;
  51. }
  52. RAS_TexVert *RAS_Polygon::GetVertex(int i)
  53. {
  54. return &m_darray->m_vertex[m_offset[i]];
  55. }
  56. unsigned int RAS_Polygon::GetVertexOffsetAbsolute(unsigned short i)
  57. {
  58. return m_offset[i] + m_darray->m_offset;
  59. }
  60. /*
  61. int RAS_Polygon::GetEdgeCode()
  62. {
  63. return m_edgecode;
  64. }
  65. void RAS_Polygon::SetEdgeCode(int edgecode)
  66. {
  67. m_edgecode = edgecode;
  68. }*/
  69. bool RAS_Polygon::IsVisible()
  70. {
  71. return (m_polyflags & VISIBLE) != 0;
  72. }
  73. void RAS_Polygon::SetVisible(bool visible)
  74. {
  75. if (visible) m_polyflags |= VISIBLE;
  76. else m_polyflags &= ~VISIBLE;
  77. }
  78. bool RAS_Polygon::IsCollider()
  79. {
  80. return (m_polyflags & COLLIDER) != 0;
  81. }
  82. void RAS_Polygon::SetCollider(bool visible)
  83. {
  84. if (visible) m_polyflags |= COLLIDER;
  85. else m_polyflags &= ~COLLIDER;
  86. }
  87. bool RAS_Polygon::IsTwoside()
  88. {
  89. return (m_polyflags & TWOSIDE) != 0;
  90. }
  91. void RAS_Polygon::SetTwoside(bool twoside)
  92. {
  93. if (twoside) m_polyflags |= TWOSIDE;
  94. else m_polyflags &= ~TWOSIDE;
  95. }
  96. RAS_MaterialBucket* RAS_Polygon::GetMaterial()
  97. {
  98. return m_bucket;
  99. }
  100. RAS_DisplayArray* RAS_Polygon::GetDisplayArray()
  101. {
  102. return m_darray;
  103. }