Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3369 was 3365, checked in by bensch, 20 years ago

orxonox/trunk: merged branches/parenting back to the.
merged with command:
svn merge branches/parenting trunk -r 3247:HEAD
resolved all conflicts in favor of parenting.

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 "array.h"
12#include "material.h"
13#include "vector.h"
14#include <fstream>
15
16using namespace std;
17
18
19
20//! Class that handles 3D-Models. it can also read them in and display them.
21class Model
22{
23 public:
24  Model ();
25  Model (char* fileName);
26  Model(char* fileName, float scaling);
27  ~Model ();
28 
29  void draw (void) const;
30  void draw (int groupNumber) const;
31  void draw (char* groupName) const;
32  int getGroupCount() const;
33
34 private:
35  //! This is the placeholder of one Vertex beloning to a Face.
36  struct FaceElement
37  {
38    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
39    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
40    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
41    FaceElement* next;   //!< Point to the next FaceElement in this List.
42  };
43
44  //! This is the placeholder of a Face belonging to a Group of Faces.
45  /**
46     \todo take Material to a call for itself.
47
48     This can also be a Material-Change switch.
49     That means if you want to change a Material inside of a group,
50     you can create an empty face and apply a material to it, and the Importer will cahnge Colors
51  */
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    GLuint 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  char* objPath;        //!< The Path wher the obj and mtl-file are located.
91  char* objFileName;    //!< The Name of the obj-file.
92  char* mtlFileName;    //!< The Name of the mtl-file (parsed out of the obj-file)
93
94  bool initialize (void);
95  bool initGroup(Group* group);
96  bool initFace (Face* face);
97  bool cleanup(void);
98  bool cleanupGroup(Group* group);
99  bool cleanupFace(Face* face);
100  bool cleanupFaceElement(FaceElement* faceElem);
101
102  ///// readin ///
103  bool importFile (char* fileName);
104  bool readFromObjFile (void);
105 
106  bool readGroup (char* groupString);
107  bool readVertex (char* vertexString);
108  bool readFace (char* faceString);
109  bool readVertexNormal (char* normalString);
110  bool readVertexTexture (char* vTextureString);
111  bool readMtlLib (char* matFile);
112  bool readUseMtl (char* mtlString);
113
114  bool importToGL (void);
115  bool addGLElement (FaceElement* elem);
116
117  bool buildVertexNormals ();
118
119  void BoxModel (void);
120};
121
122#endif
Note: See TracBrowser for help on using the repository browser.