#ifndef __GEOMETRY_H #define __GEOMETRY_H #include "common.h" #include "AxisAlignedBox3.h" #include "Triangle3.h" namespace CHCDemoEngine { class RenderState; /** Represents drawable geometry consisting of triangles. */ class Geometry { friend class ResourceManager; public: /** Constructs a geometry from the given data. The vertices are interpreted as triangles. If delData is true, the vertex / normal / texture is deleted when after it was transferred into a vbo */ Geometry(Vector3 *vertices, Vector3 *normals, Texcoord2 *texcoords, int numVertices, bool deleteData, Vector3 *tangents); /** Detructor destroying the opengl resources. */ ~Geometry(); /** Render the geometry */ void Render(RenderState *state); /** Return bounding box. */ const AxisAlignedBox3& GetBoundingBox() const; /** Returns the number of triangles in this geometry. */ inline int GetNumTriangles() const { return mNumVertices / 3; } /** Returns true if this geometry has a texture */ inline bool HasTexture() const { return mHasTexture; } ////////////// //-- these functions return the specified data //-- only if deleteData has not been switched on in the consruction Vector3 *GetVertices(int &numVertices) const; Vector3 *GetNormals(int &numNormals) const; Vector3 *GetTangents(int &numTangents) const; Texcoord2 *GetTexCoords(int &numTexCoords) const; protected: /** Calculates the bounding box from the vertices. */ void CalcBoundingBox(); /** Prepare vbos for rendering */ void Prepare(); ////////// Vector3 *mVertices; Vector3 *mNormals; Vector3 *mTangents; Texcoord2 *mTexCoords; unsigned int mVboId; int mNumVertices; AxisAlignedBox3 mBoundingBox; bool mHasTexture; bool mHasTangents; }; } #endif // GEOMETRY_H