| 1 | /*! |
|---|
| 2 | * @file vertex_array_model.h |
|---|
| 3 | * @brief Contains the VertexArrayModel Class that handles 3D-Models rendered out of VertexArrays |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #ifndef _VERTEX_ARRAY_MODEL_H |
|---|
| 7 | #define _VERTEX_ARRAY_MODEL_H |
|---|
| 8 | |
|---|
| 9 | #include "model.h" |
|---|
| 10 | |
|---|
| 11 | #include "glincl.h" |
|---|
| 12 | #include "vector2D.h" |
|---|
| 13 | |
|---|
| 14 | #include <vector> |
|---|
| 15 | |
|---|
| 16 | /* Forward Declaration */ |
|---|
| 17 | class Material; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | ///////////// |
|---|
| 21 | /// MODEL /// |
|---|
| 22 | ///////////// |
|---|
| 23 | //! Class that handles 3D-Models. it can also read them in and display them. |
|---|
| 24 | /** |
|---|
| 25 | * this renders models with help of the OpenGL glVertexArray |
|---|
| 26 | */ |
|---|
| 27 | class VertexArrayModel : public Model |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | VertexArrayModel(); |
|---|
| 31 | VertexArrayModel(const Model& model); |
|---|
| 32 | virtual ~VertexArrayModel(); |
|---|
| 33 | |
|---|
| 34 | void draw() const; |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | void newStripe(); |
|---|
| 38 | |
|---|
| 39 | void addVertex(float x, float y, float z); |
|---|
| 40 | void addNormal(float x, float y, float z); |
|---|
| 41 | void addTexCoor(float u, float v); |
|---|
| 42 | void addColor(float r, float g, float b); |
|---|
| 43 | |
|---|
| 44 | void addIndice(GLuint indice); |
|---|
| 45 | |
|---|
| 46 | void finalize(); |
|---|
| 47 | |
|---|
| 48 | unsigned int vertexCount() const { return this->vertices.size(); }; |
|---|
| 49 | unsigned int normalCount() const { return this->normals.size(); }; |
|---|
| 50 | unsigned int texCoordCount() const { return this->texCoords.size(); }; |
|---|
| 51 | unsigned int colorCount() const { return this->colors.size(); }; |
|---|
| 52 | unsigned int indiceCount() const { return this->indices.size(); }; |
|---|
| 53 | |
|---|
| 54 | Vector& vertex(unsigned int i) { return this->vertices[i]; }; |
|---|
| 55 | Vector& normal(unsigned int i) { return this->normals[i]; }; |
|---|
| 56 | Vector2D& texCoord(unsigned int i) { return this->texCoords[i]; }; |
|---|
| 57 | Vector& color(unsigned int i) { return this->colors[i]; }; |
|---|
| 58 | GLuint index(unsigned int i) { return this->indices[i]; }; |
|---|
| 59 | // |
|---|
| 60 | void planeModel(float sizeX, float sizeY, unsigned int resolutionX, unsigned int resolutionY); |
|---|
| 61 | void spiralSphere(const float radius, const unsigned int loops, const unsigned int segmentsPerLoop); |
|---|
| 62 | |
|---|
| 63 | void debug() const; |
|---|
| 64 | |
|---|
| 65 | private: |
|---|
| 66 | void importToVertexArray(); |
|---|
| 67 | |
|---|
| 68 | private: |
|---|
| 69 | std::vector<Vector> vertices; //!< The Array that handles the Vertices. |
|---|
| 70 | std::vector<Vector> normals; //!< The Array that handles the Normals. |
|---|
| 71 | std::vector<Vector2D> texCoords; //!< The Array that handles the VertexTextureCoordinates. |
|---|
| 72 | std::vector<Vector> colors; //!< The Array that handles Colors. |
|---|
| 73 | |
|---|
| 74 | std::vector<GLuint> indices; //!< The Array that tells us what Vertex is connected to which other one. |
|---|
| 75 | |
|---|
| 76 | std::vector<GLuint> stripes; //!< A lsit of Stripes of this Model. |
|---|
| 77 | |
|---|
| 78 | }; |
|---|
| 79 | |
|---|
| 80 | #endif |
|---|