Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/importer/model.h @ 3397

Last change on this file since 3397 was 3396, checked in by bensch, 20 years ago

orxonox/trunk: splitted obj-loader out of the model-class: this will enable different kinds of Filetypes to be included with the importer.
Althought there is a name-field error, the Model gets loaded and unloaded as good as previously

File size: 3.7 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 "array.h"
12#include "material.h"
13#include "vector.h"
14
15using namespace std;
16
17
18
19//! Class that handles 3D-Models. it can also read them in and display them.
20class Model
21{
22 public:
23  Model(void);
24  virtual ~Model(void);
25 
26  void draw(void) const;
27  void draw(int groupNumber) const;
28  void draw(char* groupName) const;
29  int getGroupCount() const;
30
31 protected:
32  char* name;            //!< This is the name of the Model;
33  //! This is the placeholder of one Vertex beloning to a Face.
34  struct FaceElement
35  {
36    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
37    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
38    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
39    FaceElement* next;   //!< Point to the next FaceElement in this List.
40  };
41
42  //! This is the placeholder of a Face belonging to a Group of Faces.
43  /**
44     \todo take Material to a call for itself.
45
46     This can also be a Material-Change switch.
47     That means if you want to change a Material inside of a group,
48     you can create an empty face and apply a material to it, and the Importer will cahnge Colors
49  */
50  struct Face
51  {
52    int vertexCount;        //!< The Count of vertices this Face has.
53    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
54
55    char* materialString;   //!< The Name of the Material to which to Change.
56
57    Face* next;             //!< Pointer to the next Face.
58  }; 
59
60  //! Group to handle multiple Models per obj-file.
61  struct Group
62  {
63    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
64
65    GLuint listNumber;  //!< The number of the GL-List this Group gets.
66    Face* firstFace;    //!< The first Face in this group.
67    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
68    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...
69    int faceCount;      //!< The Number of Faces this Group holds.
70
71    Group* next;        //!< Pointer to the next Group.
72  };
73
74
75  Array* vertices;      //!< The Array that handles the Vertices.
76  int verticesCount;    //!< A global Counter for vertices.
77  Array* normals;       //!< The Array that handles the Normals.
78  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
79
80 
81  Group* firstGroup;    //!< The first of all groups.
82  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
83  int groupCount;       //!< The Count of Groups.
84
85  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
86  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
87
88  bool initialize (void);
89  bool initGroup(Group* group);
90  bool initFace (Face* face);
91  bool cleanup(void);
92  bool cleanupGroup(Group* group);
93  bool cleanupFace(Face* face);
94  bool cleanupFaceElement(FaceElement* faceElem);
95
96  bool addGroup (char* groupString);
97  bool addVertex (char* vertexString);
98  bool addFace (char* faceString);
99  bool addVertexNormal (char* normalString);
100  bool addVertexTexture (char* vTextureString);
101  bool addUseMtl (char* mtlString);
102
103  bool importToGL (void);
104  bool addGLElement (FaceElement* elem);
105
106  bool buildVertexNormals ();
107
108  void BoxModel (void);
109};
110
111#endif
Note: See TracBrowser for help on using the repository browser.