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