Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/object.h @ 3193

Last change on this file since 3193 was 3193, checked in by bensch, 21 years ago

orxonox/trunk/src: merged importer into src again

File size: 4.2 KB
RevLine 
[2835]1/*!
[2853]2  \file object.h
3  \brief Contains the Object Class that handles 3D-Objects
[2835]4*/
5
6#ifndef _OBJECT_H
7#define _OBJECT_H
8
[3185]9#include "stdincl.h"
[2835]10
11#include "array.h"
12#include "material.h"
[3185]13#include "vector.h"
[2835]14#include <fstream>
15
16using namespace std;
17
[3185]18extern int verbose; //!< Will be removed and added again as a verbose-class.
[2853]19
20
[2935]21
[2835]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 
[3185]31  void draw (void) const;
32  void draw (int groupNumber) const;
33  void draw (char* groupName) const;
34  int getGroupCount() const;
[2835]35
[2853]36 private:
[3193]37  //! This is the placeholder of one Vertex beloning to a Face.
38  struct FaceElement
[3185]39  {
[3193]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.
[3185]44  };
45
[3193]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
[3185]55  {
[3193]56    int vertexCount;        //!< The Count of vertices this Face has.
57    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
[3185]58
[3193]59    char* materialString;   //!< The Name of the Material to which to Change.
[3185]60
[3193]61    Face* next;             //!< Pointer to the next Face.
62  }; 
[3185]63
[3193]64  //! Group to handle multiple Objects per obj-file.
[2853]65  struct Group
66  {
[3193]67    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
[2835]68
[3193]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.
[2835]74
[3193]75    Group* next;        //!< Pointer to the next Group.
[3185]76  };
[2853]77
[3185]78
[3193]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.
[3185]83
[2853]84 
[3193]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.
[2853]88
[3193]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
[2853]91
[3193]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)
[2853]95
[3185]96  bool initialize (void);
[2853]97  bool initGroup(Group* group);
[3185]98  bool initFace (Face* face);
99  bool cleanup(void);
[2866]100  bool cleanupGroup(Group* group);
[3185]101  bool cleanupFace(Face* face);
102  bool cleanupFaceElement(FaceElement* faceElem);
[2853]103
104  ///// readin ///
[3185]105  bool importFile (char* fileName);
106  bool readFromObjFile (void);
[2835]107 
[3185]108  bool readGroup (char* groupString);
[2835]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
[3185]116  bool importToGL (void);
117  bool addGLElement (FaceElement* elem);
[2835]118
[3185]119  bool buildVertexNormals ();
120
[2835]121  void BoxObject (void);
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.