Polygon.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /***************************************************************************
  2. Polygon.h - description
  3. -------------------
  4. begin : Wed Jan 26 2000
  5. copyright : (C) 2000 by Henrik Enqvist
  6. email : henqvist@excite.com
  7. ***************************************************************************/
  8. #ifndef POLYGON_H
  9. #define POLYGON_H
  10. //#define EM_POLY_FLAT 1
  11. //#define EM_POLY_SMOOTH 2
  12. //#define EM_POLY_HIDDEN 4
  13. //#define EM_WIREFRAME 8
  14. //#define EM_ALLWAYS_LIT 16
  15. //#define EM_POLY_DOUBLE 32
  16. #define EM_POLY_TRANS 64
  17. //#define EM_POLY_CCW_VIEW 128
  18. using namespace std;
  19. #include <vector>
  20. #include "EMath.h"
  21. class Shape3D;
  22. /**
  23. * Polygons are part of Shape3Ds. Polygons are built by first creating
  24. * a Polygon object and then adding the vertices which define the polygon.
  25. *
  26. * Look out i can be a bit confusing to handle two types of indices. Will
  27. * call the vertex index in the shape for shindex and the index for the edge in the
  28. * polygon for polyindex. A polyindex edge always has a connection to one shindex vertex.
  29. * A shindex vertex may be refered by several polygons ie. polyindex edges.
  30. * @see Shape3D
  31. */
  32. class Polygon3D {
  33. public:
  34. Polygon3D(Shape3D* s, int size = 3);
  35. ~Polygon3D();
  36. void copy(Polygon3D * poly);
  37. /** Add add a shape vertex into this polygon- */
  38. void add(int shindex);
  39. /** Returns the polyindex if the vertex is included. Else -1. */
  40. int includes(int shindex);
  41. void setProperty(int p);
  42. void unsetProperty(int p);
  43. int getProperties();
  44. /** Get shape vertex index for edge in polygon. */
  45. int getIndex(int polyindex);
  46. int getIndexSize();
  47. void setColor(float r, float g, float b, float a);
  48. Color * getColor(int polyindex);
  49. void setColor(int polyindex, float r, float g, float b, float a);
  50. TexCoord * getTexCoord(int polyindex);
  51. void setTexCoord(int polyindex, float u, float v);
  52. Shape3D * getShape3D() { return p_Shape3D; };
  53. void countNormal();
  54. void decrement(int shindex);
  55. /** Move vertex at index one step up in polygon order. */
  56. void moveUp(int polyindex);
  57. void moveDown(int polyindex);
  58. /** Are the vertices follow each other in this polygon. */
  59. bool connected(int shindexA, int shindexB);
  60. /* private:
  61. friend class Shape3D;
  62. friend class RendererVisitor;
  63. friend class PNormalVisitor;
  64. friend class PointLightVisitor;
  65. friend class NCollisionVisitor;
  66. friend class GLightVisitor;
  67. friend class NestedBounds;
  68. friend class ClipperVisitor;
  69. friend class PaintersSorter;
  70. friend class OpenGLVisitor;*/
  71. Vertex3D m_nmlSrc;
  72. Vertex3D m_nmlTrans;
  73. Color m_colFlatLight;
  74. vector<int> m_vIndex;
  75. int m_iProperties;
  76. Shape3D* p_Shape3D;
  77. };
  78. #endif // POLYGON_H