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