Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/importer/object.h @ 3302

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

orxonox/trunk/src/importer: how logging could be

File size: 4.1 KB
RevLine 
[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
[3196]9#include "../stdincl.h"
[2773]10
[2754]11#include "array.h"
[2776]12#include "material.h"
[3075]13#include "vector.h"
[2823]14#include <fstream>
[2748]15
[2823]16using namespace std;
[2804]17
[2842]18
19
[2823]20//! Class that handles 3D-Objects. it can also read them in and display them.
[2748]21class Object
22{
23 public:
24  Object ();
[2767]25  Object (char* fileName);
[2833]26  Object(char* fileName, float scaling);
[2748]27  ~Object ();
28 
[3063]29  void draw (void) const;
30  void draw (int groupNumber) const;
31  void draw (char* groupName) const;
32  int getGroupCount() const;
[2767]33
[2748]34 private:
[3186]35  //! This is the placeholder of one Vertex beloning to a Face.
36  struct FaceElement
[3063]37  {
[3186]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.
[3063]42  };
43
[3186]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
[3063]53  {
[3186]54    int vertexCount;        //!< The Count of vertices this Face has.
55    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
[3063]56
[3186]57    char* materialString;   //!< The Name of the Material to which to Change.
[3063]58
[3186]59    Face* next;             //!< Pointer to the next Face.
60  }; 
[3063]61
[3186]62  //! Group to handle multiple Objects per obj-file.
[2850]63  struct Group
64  {
[3186]65    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
[2850]66
[3186]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.
[2850]72
[3186]73    Group* next;        //!< Pointer to the next Group.
[3063]74  };
[2850]75
[3063]76
[3186]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.
[3063]81
[2850]82 
[3186]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.
[2850]86
[3186]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 Object hould be scaled. \todo maybe one wants to scale the Object after Initialisation
[2760]89
[3186]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)
[2850]93
[3066]94  bool initialize (void);
[2850]95  bool initGroup(Group* group);
[3066]96  bool initFace (Face* face);
97  bool cleanup(void);
98  bool cleanupGroup(Group* group);
99  bool cleanupFace(Face* face);
[3068]100  bool cleanupFaceElement(FaceElement* faceElem);
[2850]101
102  ///// readin ///
[3066]103  bool importFile (char* fileName);
[3140]104  bool readFromObjFile (void);
[2748]105 
[3066]106  bool readGroup (char* groupString);
[2767]107  bool readVertex (char* vertexString);
108  bool readFace (char* faceString);
[2794]109  bool readVertexNormal (char* normalString);
[2820]110  bool readVertexTexture (char* vTextureString);
[2776]111  bool readMtlLib (char* matFile);
112  bool readUseMtl (char* mtlString);
[2754]113
[3063]114  bool importToGL (void);
[3072]115  bool addGLElement (FaceElement* elem);
[2821]116
[3075]117  bool buildVertexNormals ();
118
[2821]119  void BoxObject (void);
[2748]120};
[2773]121
122#endif
Note: See TracBrowser for help on using the repository browser.