Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/importer: Material now working.

File size: 2.1 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  bool importFile (char* fileName);
32  bool initialize (void);
33  bool finalize(void);
34  void draw (void) const;
35  void draw (int groupNumber) const;
36  void draw (char* groupName) const;
37  int getGroupCount() const;
38
39 private:
40  struct FaceElement
41  {
42    char* value;
43    FaceElement* next;
44  };
45
46  //! Face
47  struct Face
48  {
49    int vertexCount;
50
51    FaceElement* firstElem;
52
53    char* materialString;
54
55    Face* next;
56  };
57
58  //! Group to handle multiple Objects per obj-file
59  struct Group
60  {
61    char* name;
62
63    GLuint listNumber;
64    Face* firstFace;
65    Face* currentFace;
66    int faceMode;
67    int faceCount;
68
69    Group* next;
70  };
71
72
73  Array* vertices;
74  int verticesCount;
75  Array* colors;
76  Array* normals;
77  Array* vTexture;
78
79 
80  Group* firstGroup; //!< the first of all groups.
81  Group* currentGroup; //!< the currentGroup. this is the one we will work with.
82  int groupCount;
83
84  char* objFileName;
85  char* mtlFileName;
86
87  Material* material;
88  float scaleFactor;
89
90  char* objPath;
91  ifstream* OBJ_FILE;
92  ifstream* MTL_FILE;
93
94  bool initGroup(Group* group);
95  bool finalizeGroup (Group* group);
96
97
98  ///// readin ///
99  bool readFromObjFile (char* fileName);
100 
101  bool readVertex (char* vertexString);
102  bool readFace (char* faceString);
103  bool readVT (char* vtString);
104  bool readVertexNormal (char* normalString);
105  bool readVertexTexture (char* vTextureString);
106  bool readGroup (char* groupString);
107  bool readMtlLib (char* matFile);
108  bool readUseMtl (char* mtlString);
109
110  bool initFace (Face* face);
111  bool importToGL (void);
112  bool addGLElement (char* elementString);
113
114  void BoxObject (void);
115};
116
117#endif
Note: See TracBrowser for help on using the repository browser.