Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/importer/model.h @ 3519

Last change on this file since 3519 was 3454, checked in by bensch, 20 years ago

orxonox/trunk/importer: doxygen-tags

File size: 4.1 KB
Line 
1/*!
2  \file model.h
3  \brief Contains the Model Class that handles 3D-Models
4*/
5
6#ifndef _MODEL_H
7#define _MODEL_H
8
9//#include "../stdincl.h"
10
11#include "material.h"
12
13// FORWARD DEFINITION //
14class Array;
15class Vector;
16
17using namespace std;
18
19//! Specification of different primitives the Model knows
20enum PRIMITIVE {PLANE, CUBE, SPHERE, CYLINDER};
21
22//! Class that handles 3D-Models. it can also read them in and display them.
23class Model
24{
25 public:
26  Model(void);
27  Model(PRIMITIVE type);
28  Model(char* modelName);
29  virtual ~Model(void);
30
31  void setName(const char* name);
32 
33  void draw(void) const;
34  void draw(int groupNumber) const;
35  void draw(char* groupName) const;
36  int getGroupCount() const;
37
38 protected:
39  char* name;            //!< This is the name of the Model.
40  bool finalized;        //!< Sets the Object to be finalized.
41 
42  //! This is the placeholder of one Vertex beloning to a Face.
43  struct FaceElement
44  {
45    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
46    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
47    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
48    FaceElement* next;   //!< Point to the next FaceElement in this List.
49  };
50
51  //! This is the placeholder of a Face belonging to a Group of Faces.
52  struct Face
53  {
54    int vertexCount;        //!< The Count of vertices this Face has.
55    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
56
57    char* materialString;   //!< The Name of the Material to which to Change.
58
59    Face* next;             //!< Pointer to the next Face.
60  }; 
61
62  //! Group to handle multiple Models per obj-file.
63  struct Group
64  {
65    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
66
67    unsigned int listNumber;//!< The number of the GL-List this Group gets.
68    Face* firstFace;    //!< The first Face in this group.
69    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
70    int faceMode;       //!< The Mode the Face is in: initially -1, 0 for FaceList opened, 1 for Material,  3 for triangle, 4 for Quad, 5+ for Poly \todo ENUM...
71    int faceCount;      //!< The Number of Faces this Group holds.
72
73    Group* next;        //!< Pointer to the next Group.
74  };
75
76
77  Array* vertices;      //!< The Array that handles the Vertices.
78  int verticesCount;    //!< A global Counter for vertices.
79  Array* normals;       //!< The Array that handles the Normals.
80  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
81
82 
83  Group* firstGroup;    //!< The first of all groups.
84  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
85  int groupCount;       //!< The Count of Groups.
86
87  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
88  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
89
90  bool initialize(void);
91  bool initGroup(Group* group);
92  bool initFace (Face* face);
93  bool cleanup(void);
94  bool cleanupGroup(Group* group);
95  bool cleanupFace(Face* face);
96  bool cleanupFaceElement(FaceElement* faceElem);
97
98 public:
99  bool addGroup(char* groupString);
100  bool addVertex(char* vertexString);
101  bool addVertex(const float x, const float y, const float z);
102  bool addFace(char* faceString);
103  bool addFace(const float faceElemCount, int type, ...);
104  bool addVertexNormal(char* normalString);
105  bool addVertexNormal(const float x, const float y, const float z);
106  bool addVertexTexture(char* vTextureString);
107  bool addVertexTexture(const float u, const float v);
108  bool addUseMtl(char* mtlString);
109  void finalize(void);
110
111 protected:
112  bool importToGL(void);
113  bool addGLElement(FaceElement* elem);
114
115  bool buildVertexNormals(void);
116
117  void cubeModel(void);
118  void sphereModel(void);
119  void cylinderModel(void);
120};
121
122#endif
Note: See TracBrowser for help on using the repository browser.