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