Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: mainly importer: doxygen Tags updated for real.

File size: 4.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 "stdincl.h"
10
11#include "array.h"
12#include "material.h"
13#include "vector.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  //! This is the placeholder of one Vertex beloning to a Face.
38  struct FaceElement
39  {
40    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
41    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
42    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
43    FaceElement* next;   //!< Point to the next FaceElement in this List.
44  };
45
46  //! This is the placeholder of a Face belonging to a Group of Faces.
47  /**
48     \todo take Material to a call for itself.
49
50     This can also be a Material-Change switch.
51     That means if you want to change a Material inside of a group,
52     you can create an empty face and apply a material to it, and the Importer will cahnge Colors
53  */
54  struct Face
55  {
56    int vertexCount;        //!< The Count of vertices this Face has.
57    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
58
59    char* materialString;   //!< The Name of the Material to which to Change.
60
61    Face* next;             //!< Pointer to the next Face.
62  }; 
63
64  //! Group to handle multiple Objects per obj-file.
65  struct Group
66  {
67    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
68
69    GLuint listNumber;  //!< The number of the GL-List this Group gets.
70    Face* firstFace;    //!< The first Face in this group.
71    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
72    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...
73    int faceCount;      //!< The Number of Faces this Group holds.
74
75    Group* next;        //!< Pointer to the next Group.
76  };
77
78
79  Array* vertices;      //!< The Array that handles the Vertices.
80  int verticesCount;    //!< A global Counter for vertices.
81  Array* normals;       //!< The Array that handles the Normals.
82  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
83
84 
85  Group* firstGroup;    //!< The first of all groups.
86  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
87  int groupCount;       //!< The Count of Groups.
88
89  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
90  float scaleFactor;    //!< The Factor with which the Object hould be scaled. \todo maybe one wants to scale the Object after Initialisation
91
92  char* objPath;        //!< The Path wher the obj and mtl-file are located.
93  char* objFileName;    //!< The Name of the obj-file.
94  char* mtlFileName;    //!< The Name of the mtl-file (parsed out of the obj-file)
95
96  bool initialize (void);
97  bool initGroup(Group* group);
98  bool initFace (Face* face);
99  bool cleanup(void);
100  bool cleanupGroup(Group* group);
101  bool cleanupFace(Face* face);
102  bool cleanupFaceElement(FaceElement* faceElem);
103
104  ///// readin ///
105  bool importFile (char* fileName);
106  bool readFromObjFile (void);
107 
108  bool readGroup (char* groupString);
109  bool readVertex (char* vertexString);
110  bool readFace (char* faceString);
111  bool readVertexNormal (char* normalString);
112  bool readVertexTexture (char* vTextureString);
113  bool readMtlLib (char* matFile);
114  bool readUseMtl (char* mtlString);
115
116  bool importToGL (void);
117  bool addGLElement (FaceElement* elem);
118
119  bool buildVertexNormals ();
120
121  void BoxObject (void);
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.