Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: moved importer into the Trunk, now no merging is needed anymore.

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