source:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h
@
3260
Revision 3260, 1.9 KB checked in by mattausch, 15 years ago (diff) |
---|
Rev | Line | |
---|---|---|
[2840] | 1 | #ifndef __GEOMETRY_H |
2 | #define __GEOMETRY_H | |
[2642] | 3 | |
[2752] | 4 | #include "common.h" |
5 | #include "AxisAlignedBox3.h" | |
[2755] | 6 | #include "Triangle3.h" |
[2751] | 7 | |
[2752] | 8 | |
[2776] | 9 | namespace CHCDemoEngine |
[2642] | 10 | { |
11 | ||
[2773] | 12 | class RenderState; |
13 | ||
[2980] | 14 | |
15 | /** Represents drawable geometry consisting of triangles. | |
[2642] | 16 | */ |
17 | class Geometry | |
18 | { | |
[2980] | 19 | friend class ResourceManager; |
[2823] | 20 | |
[2642] | 21 | public: |
[3126] | 22 | /** Constructs a geometry from the given data. The vertices are |
23 | interpreted as triangles. If delData is true, the | |
24 | vertex / normal / texture is deleted when after it was | |
25 | transferred into a vbo | |
[2751] | 26 | */ |
[2823] | 27 | Geometry(Vector3 *vertices, |
28 | Vector3 *normals, | |
[2980] | 29 | Texcoord2 *texcoords, |
[2823] | 30 | int numVertices, |
[3259] | 31 | bool deleteData, |
[3126] | 32 | Vector3 *tangents); |
33 | /** Detructor destroying the opengl resources. | |
34 | */ | |
[2781] | 35 | ~Geometry(); |
[2756] | 36 | /** Render the geometry |
37 | */ | |
[2773] | 38 | void Render(RenderState *state); |
[3126] | 39 | /** Return bounding box. |
40 | */ | |
41 | const AxisAlignedBox3& GetBoundingBox() const; | |
42 | /** Returns the number of triangles in this geometry. | |
43 | */ | |
44 | inline int GetNumTriangles() const { return mNumVertices / 3; } | |
45 | /** Returns true if this geometry has a texture | |
46 | */ | |
[2795] | 47 | inline bool HasTexture() const { return mHasTexture; } |
[2842] | 48 | |
[2755] | 49 | |
[3259] | 50 | ////////////// |
51 | //-- these functions return the specified data | |
52 | //-- only if deleteData has not been switched on in the consruction | |
53 | ||
54 | Vector3 *GetVertices(int &numVertices) const; | |
55 | ||
56 | Vector3 *GetNormals(int &numNormals) const; | |
57 | ||
58 | Vector3 *GetTangents(int &numTangents) const; | |
59 | ||
60 | Texcoord2 *GetTexCoords(int &numTexCoords) const; | |
61 | ||
62 | ||
[2751] | 63 | protected: |
[3260] | 64 | |
[3126] | 65 | /** Calculates the bounding box from the vertices. |
66 | */ | |
[2756] | 67 | void CalcBoundingBox(); |
68 | /** Prepare vbos for rendering | |
69 | */ | |
70 | void Prepare(); | |
[2751] | 71 | |
72 | ||
[2756] | 73 | ////////// |
[2755] | 74 | |
[2756] | 75 | Vector3 *mVertices; |
[2755] | 76 | |
[2756] | 77 | Vector3 *mNormals; |
[2746] | 78 | |
[3126] | 79 | Vector3 *mTangents; |
80 | ||
[2980] | 81 | Texcoord2 *mTexCoords; |
[2642] | 82 | |
[2793] | 83 | unsigned int mVboId; |
84 | ||
[2756] | 85 | int mNumVertices; |
86 | ||
[2751] | 87 | AxisAlignedBox3 mBoundingBox; |
[2795] | 88 | |
89 | bool mHasTexture; | |
[3126] | 90 | |
91 | bool mHasTangents; | |
[2642] | 92 | }; |
93 | ||
[2756] | 94 | |
[2751] | 95 | } |
[2752] | 96 | |
[2642] | 97 | #endif // GEOMETRY_H |
Note: See TracBrowser
for help on using the repository browser.