Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/importer/object.h @ 3072

Last change on this file since 3072 was 3072, checked in by bensch, 19 years ago

orxonox/trunk/importer: improved FaceElement-Read-function. Now not strings, but ints are passed along

File size: 2.2 KB
Line 
1/*!
2  \file object.h
3  \brief Contains the Object Class that handles 3D-Objects
4*/
5
6#ifndef _OBJECT_H
7#define _OBJECT_H
8
9#include <GL/gl.h>
10#include <GL/glu.h>
11
12#include "array.h"
13#include "material.h"
14#include <fstream>
15
16using namespace std;
17
18extern int verbose; //!< Will be removed and added again as a verbose-class.
19
20
21
22//! Class that handles 3D-Objects. it can also read them in and display them.
23class Object
24{
25 public:
26  Object ();
27  Object (char* fileName);
28  Object(char* fileName, float scaling);
29  ~Object ();
30 
31  void draw (void) const;
32  void draw (int groupNumber) const;
33  void draw (char* groupName) const;
34  int getGroupCount() const;
35
36 private:
37  struct FaceElement
38  {
39    int vertexNumber;
40    int normalNumber;
41    int texCoordNumber;
42    FaceElement* next;
43  };
44
45  //! Face
46  struct Face
47  {
48    int vertexCount;
49    FaceElement* firstElem;
50
51    char* materialString;
52
53    Face* next;
54  };
55
56  //! Group to handle multiple Objects per obj-file
57  struct Group
58  {
59    char* name;
60
61    GLuint listNumber;
62    Face* firstFace;
63    Face* currentFace;
64    int faceMode;
65    int faceCount;
66
67    Group* next;
68  };
69
70
71  Array* vertices;
72  int verticesCount;
73  Array* colors;
74  Array* normals;
75  Array* vTexture;
76
77 
78  Group* firstGroup; //!< the first of all groups.
79  Group* currentGroup; //!< the currentGroup. this is the one we will work with.
80  int groupCount;
81
82  Material* material;
83  float scaleFactor;
84
85  char* objPath;
86  char* objFileName;
87  char* mtlFileName;
88  ifstream* OBJ_FILE;
89  ifstream* MTL_FILE;
90
91  bool initialize (void);
92  bool initGroup(Group* group);
93  bool initFace (Face* face);
94  bool cleanup(void);
95  bool cleanupGroup(Group* group);
96  bool cleanupFace(Face* face);
97  bool cleanupFaceElement(FaceElement* faceElem);
98
99  ///// readin ///
100  bool importFile (char* fileName);
101  bool readFromObjFile (char* fileName);
102 
103  bool readGroup (char* groupString);
104  bool readVertex (char* vertexString);
105  bool readFace (char* faceString);
106  bool readVertexNormal (char* normalString);
107  bool readVertexTexture (char* vTextureString);
108  bool readMtlLib (char* matFile);
109  bool readUseMtl (char* mtlString);
110
111  bool importToGL (void);
112  bool addGLElement (FaceElement* elem);
113
114  void BoxObject (void);
115};
116
117#endif
Note: See TracBrowser for help on using the repository browser.