source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h @ 3293

Revision 3293, 1.9 KB checked in by mattausch, 16 years ago (diff)
Line 
1#ifndef __GEOMETRY_H
2#define __GEOMETRY_H
3
4#include "common.h"
5#include "AxisAlignedBox3.h"
6#include "Triangle3.h"
7
8
9namespace CHCDemoEngine
10{
11
12class RenderState;
13
14
15/** Represents drawable geometry consisting of triangles.
16*/
17class Geometry
18{
19        friend class ResourceManager;
20
21public:
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
26        */
27        Geometry(Vector3 *vertices,
28                     Vector3 *normals,
29                         Texcoord2 *texcoords,
30                         int numVertices,
31                         bool deleteData,
32                         Vector3 *tangents);
33        /** Detructor destroying the opengl resources.
34        */
35        ~Geometry();
36        /** Render the geometry
37        */
38        void Render(RenderState *state);
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        */
47        inline bool HasTexture() const { return mHasTexture; }
48       
49
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
63protected:
64
65        /** Calculates the bounding box from the vertices.
66        */
67        void CalcBoundingBox();
68        /** Prepare vbos for rendering
69        */
70        void Prepare();
71
72
73        //////////
74
75        Vector3 *mVertices;
76
77        Vector3 *mNormals;
78
79        Vector3 *mTangents;
80
81        Texcoord2 *mTexCoords;
82
83        unsigned int *mIndices;
84
85        unsigned int mVboId;
86        unsigned int mVboId2;
87
88        int mNumVertices;
89
90        AxisAlignedBox3 mBoundingBox;
91
92        bool mHasTexture;
93
94        bool mHasTangents;
95};
96
97
98}
99
100#endif // GEOMETRY_H
Note: See TracBrowser for help on using the repository browser.