Shape3D.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //#ident "$Id: Shape3D.h,v 1.14 2003/05/27 11:53:25 rzr Exp $"
  2. /***************************************************************************
  3. Shape3D.h - description
  4. -------------------
  5. begin : Wed Jan 26 2000
  6. copyright : (C) 2000 by Henrik Enqvist
  7. email : henqvist@excite.com
  8. ***************************************************************************/
  9. #ifndef SHAPE3D_H
  10. #define SHAPE3D_H
  11. #define EM_SHAPE3D_HIDDEN 1
  12. #define EM_SHAPE3D_USE_TRANS 2
  13. #define EM_SHAPE3D_ALPHATEST 4
  14. #define EM_SHAPE3D_SPECULAR 8
  15. #define EM_SHAPE3D_BEHIND 16
  16. #define EM_SHAPE3D_BEHIND2 32
  17. #define EM_SHAPE3D_ALWAYSLIT 64
  18. //#define EM_SHAPE3D_FLAT 16
  19. //#define EM_SHAPE3D_DOUBLE 32
  20. #include <vector>
  21. #include <string>
  22. #include "TextureUtil.h"
  23. #include "EMath.h"
  24. class Group;
  25. class Polygon3D;
  26. /** A Shape3D represents the visual part of a object.
  27. * First vertices are added the the shape with the
  28. * 'add(x, y, z)' method. Then polygons separately created and added
  29. * with the 'add(Polygon*)' method. The Shape3D is finished off by calling
  30. * countNormals().
  31. * @see Polygon */
  32. class Shape3D {
  33. public:
  34. Shape3D(int v = 6, int p = 2);
  35. virtual ~Shape3D();
  36. /** Creates a new vertex and returns the index. The index is used when
  37. * creating polygons. @see Polygon */
  38. int add(float x, float y, float z);
  39. int add(float x, float y, float z, float r, float g, float b, float a, float u, float v);
  40. int addAt(int index, float x, float y, float z,
  41. float r, float g, float b, float a, float u, float v);
  42. /** Adds a polygon. @see Polygon */
  43. void add(Polygon3D*);
  44. /** Counts the polygon normals used for lightning. This must be called when
  45. * all vertices and polygons are added to the shape. */
  46. void countNormals();
  47. /** Sets the color of all polygons to rgba. */
  48. void setColor(float r, float g, float b, float a);
  49. /** Applies a a property to all polygons. See Polygon class for
  50. * properties. @see Polygon */
  51. void setPolygonProperty(int property);
  52. void unsetPolygonProperty(int property);
  53. void setProperty(int property);
  54. void unsetProperty(int property);
  55. int getProperties() { return m_iProperties; };
  56. void setTexture(EmTexture * tex);
  57. EmTexture * getTexture() { return m_Texture; };
  58. /** Gets the vertex at position index. It is a bit unsafe to reference pointers
  59. * to vertices as the adding new vertices may change allocation position of
  60. * vertex. */
  61. Vertex3D * getVertex3D(int index);
  62. /** Warning, this function is slow. */
  63. int getVertex3DIndex(Vertex3D * vtx);
  64. int getVertex3DIndex(TexCoord * tex);
  65. int getVertex3DSize();
  66. /** To be able to remove vertices they polygons first using them must be
  67. * removed. This function removes the vertex only if it is not used
  68. * by any polygon. */
  69. bool removeLooseVertex3D(int vtxindex);
  70. Polygon3D* getPolygon(int index);
  71. int getPolygonSize();
  72. /** Warning, this function is slow. */
  73. int getPolygonIndex(Polygon3D * poly);
  74. void removePolygon(Polygon3D * poly);
  75. int find(float x, float y, float z, float diff);
  76. float getCollisionSize();
  77. void setParent(Group*);
  78. Group * getParent() { return p_Parent; };
  79. Color * getColor(int index);
  80. void setColor(int index, float r, float g, float b, float a);
  81. TexCoord * getTexCoord(int index);
  82. void setTexCoord(int index, float u, float v);
  83. vector<Polygon3D*> m_vPolygon;
  84. vector<Vertex3D> m_vVtxSrc;
  85. vector<Vertex3D> m_vVtxTrans;
  86. vector<Vertex3D> m_vVtxAlign;
  87. vector<Vertex3D> m_vNmlSrc;
  88. vector<Vertex3D> m_vNmlTrans;
  89. vector<Vertex3D> m_vNmlAlign;
  90. vector<Color> m_vColor;
  91. vector<Color> m_vLitColor;
  92. vector<TexCoord> m_vTexCoord;
  93. vector<Color> m_vLight;
  94. vector<Color> m_vSpecular;
  95. EmTexture* m_Texture;
  96. Group* p_Parent;
  97. int m_iProperties;
  98. /// used for importing 3ds files //!rzr
  99. string m_sMaterialName;
  100. };
  101. #endif // SHAPE3D_H
  102. //EOF $Id: Shape3D.h,v 1.14 2003/05/27 11:53:25 rzr Exp $