1 | /* |
---|
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 |
---|
13 | co-programmer: |
---|
14 | */ |
---|
15 | |
---|
16 | /*! |
---|
17 | * @file model.h |
---|
18 | * Definition of an abstract model. |
---|
19 | * containing all needed for other models |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _MODEL_H |
---|
23 | #define _MODEL_H |
---|
24 | |
---|
25 | #include "base_object.h" |
---|
26 | #include "vector.h" |
---|
27 | |
---|
28 | using namespace std; |
---|
29 | |
---|
30 | |
---|
31 | //! holds the information about a triangle |
---|
32 | typedef struct |
---|
33 | { |
---|
34 | unsigned int indexToVertices[3]; //!< index to the vertices of the triangle |
---|
35 | unsigned int indexToNormals[3]; //!< index to the normals of the triangle |
---|
36 | unsigned int indexToTexCoor[3]; //!< index to the texture coordinates |
---|
37 | } sTriangleExt; |
---|
38 | |
---|
39 | |
---|
40 | //! Model Information definitions |
---|
41 | typedef struct |
---|
42 | { |
---|
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 |
---|
46 | unsigned int numTexCoor; //!< how many Texture Coordinates in the Model |
---|
47 | |
---|
48 | const float* pVertices; //!< array of the Vertives |
---|
49 | sTriangleExt* pTriangles; //!< array of all triangles |
---|
50 | const float* pNormals; //!< array of the Normals |
---|
51 | const float* pTexCoor; //!< array of the Texture Coordinates |
---|
52 | |
---|
53 | } modelInfo; |
---|
54 | |
---|
55 | |
---|
56 | //! This class defines the basic components of a model |
---|
57 | class Model : public BaseObject { |
---|
58 | |
---|
59 | public: |
---|
60 | Model(); |
---|
61 | virtual ~Model(); |
---|
62 | |
---|
63 | virtual void draw() const; |
---|
64 | |
---|
65 | inline const modelInfo* getModelInfo() const { return &this->pModelInfo; } |
---|
66 | |
---|
67 | /** @returns a Pointer to the Vertex-Array, if it was deleted it returns NULL */ |
---|
68 | inline const float* getVertexArray() const { return this->pModelInfo.pVertices; }; |
---|
69 | /** @returns the VertexCount of this Model */ |
---|
70 | inline unsigned int getVertexCount() const { return this->pModelInfo.numVertices; }; |
---|
71 | |
---|
72 | /** @returns a Pointer to the Normals-Array, if it was deleted it returns NULL */ |
---|
73 | inline const float* getNormalsArray() const { return this->pModelInfo.pNormals; }; |
---|
74 | /** @returns the NormalsCount of this Model */ |
---|
75 | inline unsigned int getNormalsCount() const { return this->pModelInfo.numNormals; }; |
---|
76 | |
---|
77 | /** @returns a Pointer to the TexCoord-Array, if it was deleted it returns NULL */ |
---|
78 | inline const float* getTexCoordArray() const { return this->pModelInfo.pTexCoor; }; |
---|
79 | /** @returns the TexCoord-Count of this Model */ |
---|
80 | inline unsigned int getTexCoordCount() const { return this->pModelInfo.numTexCoor; }; |
---|
81 | |
---|
82 | /** @returns the Array of triangles */ |
---|
83 | inline sTriangleExt* getTriangles() const { return this->pModelInfo.pTriangles; }; |
---|
84 | /** @returns the Count of Faces of this Model */ |
---|
85 | inline unsigned int getTriangleCount() const { return this->pModelInfo.numTriangles; }; |
---|
86 | |
---|
87 | |
---|
88 | protected: |
---|
89 | modelInfo pModelInfo; //!< Reference to the modelInfo |
---|
90 | }; |
---|
91 | |
---|
92 | #endif /* _MODEL_H */ |
---|