[4794] | 1 | /* |
---|
[4245] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
[4794] | 13 | co-programmer: |
---|
[4245] | 14 | */ |
---|
| 15 | |
---|
[4794] | 16 | /*! |
---|
[6021] | 17 | * @file model.h |
---|
| 18 | * Definition of an abstract model. |
---|
| 19 | * containing all needed for other models |
---|
[5435] | 20 | */ |
---|
[4245] | 21 | |
---|
[6021] | 22 | #ifndef _MODEL_H |
---|
| 23 | #define _MODEL_H |
---|
[4245] | 24 | |
---|
| 25 | #include "base_object.h" |
---|
[5672] | 26 | #include "vector.h" |
---|
[4245] | 27 | |
---|
| 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | //! holds the information about a triangle |
---|
| 32 | typedef struct |
---|
| 33 | { |
---|
[6308] | 34 | unsigned int indexToVertices[3]; //!< index to the vertices of the triangle |
---|
[4802] | 35 | unsigned int indexToNormals[3]; //!< index to the normals of the triangle |
---|
[4794] | 36 | unsigned int indexToTexCoor[3]; //!< index to the texture coordinates |
---|
| 37 | } sTriangleExt; |
---|
| 38 | |
---|
| 39 | |
---|
[5430] | 40 | //! Model Information definitions |
---|
[4804] | 41 | typedef struct |
---|
| 42 | { |
---|
[5430] | 43 | unsigned int numVertices; //!< number of Vertices in the Model |
---|
| 44 | unsigned int numTriangles; //!< number of triangles in the Model |
---|
| 45 | unsigned int numNormals; //!< how many Normals in the Model |
---|
[6008] | 46 | unsigned int numTexCoor; //!< how many Texture Coordinates in the Model |
---|
[4804] | 47 | |
---|
[7193] | 48 | const float* pVertices; //!< array of the Vertices |
---|
[5430] | 49 | sTriangleExt* pTriangles; //!< array of all triangles |
---|
| 50 | const float* pNormals; //!< array of the Normals |
---|
| 51 | const float* pTexCoor; //!< array of the Texture Coordinates |
---|
[4804] | 52 | |
---|
| 53 | } modelInfo; |
---|
| 54 | |
---|
| 55 | |
---|
[4245] | 56 | //! This class defines the basic components of a model |
---|
[7193] | 57 | class Model : virtual public BaseObject { |
---|
[4245] | 58 | |
---|
[4806] | 59 | public: |
---|
[6021] | 60 | virtual ~Model(); |
---|
[4806] | 61 | |
---|
[6033] | 62 | virtual void draw() const; |
---|
[6021] | 63 | |
---|
[6008] | 64 | inline const modelInfo* getModelInfo() const { return &this->pModelInfo; } |
---|
[4806] | 65 | |
---|
[6008] | 66 | /** @returns a Pointer to the Vertex-Array, if it was deleted it returns NULL */ |
---|
| 67 | inline const float* getVertexArray() const { return this->pModelInfo.pVertices; }; |
---|
| 68 | /** @returns the VertexCount of this Model */ |
---|
| 69 | inline unsigned int getVertexCount() const { return this->pModelInfo.numVertices; }; |
---|
[4806] | 70 | |
---|
[6008] | 71 | /** @returns a Pointer to the Normals-Array, if it was deleted it returns NULL */ |
---|
| 72 | inline const float* getNormalsArray() const { return this->pModelInfo.pNormals; }; |
---|
| 73 | /** @returns the NormalsCount of this Model */ |
---|
| 74 | inline unsigned int getNormalsCount() const { return this->pModelInfo.numNormals; }; |
---|
| 75 | |
---|
| 76 | /** @returns a Pointer to the TexCoord-Array, if it was deleted it returns NULL */ |
---|
| 77 | inline const float* getTexCoordArray() const { return this->pModelInfo.pTexCoor; }; |
---|
| 78 | /** @returns the TexCoord-Count of this Model */ |
---|
| 79 | inline unsigned int getTexCoordCount() const { return this->pModelInfo.numTexCoor; }; |
---|
| 80 | |
---|
| 81 | /** @returns the Array of triangles */ |
---|
| 82 | inline sTriangleExt* getTriangles() const { return this->pModelInfo.pTriangles; }; |
---|
| 83 | /** @returns the Count of Faces of this Model */ |
---|
[6308] | 84 | inline unsigned int getTriangleCount() const { return this->pModelInfo.numTriangles; }; |
---|
[6008] | 85 | |
---|
[7123] | 86 | protected: |
---|
| 87 | Model(); |
---|
[6009] | 88 | |
---|
[7123] | 89 | |
---|
[4806] | 90 | protected: |
---|
[6008] | 91 | modelInfo pModelInfo; //!< Reference to the modelInfo |
---|
[4245] | 92 | }; |
---|
| 93 | |
---|
[6021] | 94 | #endif /* _MODEL_H */ |
---|