source:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h
@
3126
Revision 3126, 1.5 KB checked in by mattausch, 16 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; |
20 | friend class EntityMerger; | |
[2823] | 21 | |
[2642] | 22 | public: |
[3126] | 23 | /** Constructs a geometry from the given data. The vertices are |
24 | interpreted as triangles. If delData is true, the | |
25 | vertex / normal / texture is deleted when after it was | |
26 | transferred into a vbo | |
[2751] | 27 | */ |
[2823] | 28 | Geometry(Vector3 *vertices, |
29 | Vector3 *normals, | |
[2980] | 30 | Texcoord2 *texcoords, |
[2823] | 31 | int numVertices, |
[3126] | 32 | bool delData, |
33 | Vector3 *tangents); | |
34 | /** Detructor destroying the opengl resources. | |
35 | */ | |
[2781] | 36 | ~Geometry(); |
[2756] | 37 | /** Render the geometry |
38 | */ | |
[2773] | 39 | void Render(RenderState *state); |
[3126] | 40 | /** Return bounding box. |
41 | */ | |
42 | const AxisAlignedBox3& GetBoundingBox() const; | |
43 | /** Returns the number of triangles in this geometry. | |
44 | */ | |
45 | inline int GetNumTriangles() const { return mNumVertices / 3; } | |
46 | /** Returns true if this geometry has a texture | |
47 | */ | |
[2795] | 48 | inline bool HasTexture() const { return mHasTexture; } |
[2842] | 49 | |
[2755] | 50 | |
[2751] | 51 | protected: |
[3126] | 52 | /** Calculates the bounding box from the vertices. |
53 | */ | |
[2756] | 54 | void CalcBoundingBox(); |
55 | /** Prepare vbos for rendering | |
56 | */ | |
57 | void Prepare(); | |
[2751] | 58 | |
59 | ||
[2756] | 60 | ////////// |
[2755] | 61 | |
[2756] | 62 | Vector3 *mVertices; |
[2755] | 63 | |
[2756] | 64 | Vector3 *mNormals; |
[2746] | 65 | |
[3126] | 66 | Vector3 *mTangents; |
67 | ||
[2980] | 68 | Texcoord2 *mTexCoords; |
[2642] | 69 | |
[2793] | 70 | unsigned int mVboId; |
71 | ||
[2756] | 72 | int mNumVertices; |
73 | ||
[2751] | 74 | AxisAlignedBox3 mBoundingBox; |
[2795] | 75 | |
76 | bool mHasTexture; | |
[3126] | 77 | |
78 | bool mHasTangents; | |
[2642] | 79 | }; |
80 | ||
[2756] | 81 | |
[2751] | 82 | } |
[2752] | 83 | |
[2642] | 84 | #endif // GEOMETRY_H |
Note: See TracBrowser
for help on using the repository browser.