Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/importer/model.h @ 3433

Last change on this file since 3433 was 3427, checked in by bensch, 20 years ago

orxonox/trunk/importer: cleaned up the includes, while watching some Monty Python

File size: 4.0 KB
RevLine 
[2823]1/*!
[3360]2  \file model.h
3  \brief Contains the Model Class that handles 3D-Models
[2823]4*/
5
[3360]6#ifndef _MODEL_H
7#define _MODEL_H
[2773]8
[3427]9//#include "../stdincl.h"
[2773]10
[2776]11#include "material.h"
[2748]12
[3427]13// FORWARD DEFINITION //
14class Array;
15class Vector;
16
[2823]17using namespace std;
[2804]18
[3398]19enum PRIMITIVE {PLANE, CUBE, SPHERE, CYLINDER};
[2842]20
[3360]21//! Class that handles 3D-Models. it can also read them in and display them.
22class Model
[2748]23{
24 public:
[3396]25  Model(void);
[3398]26  Model(PRIMITIVE type);
27  Model(char* modelName);
[3396]28  virtual ~Model(void);
[3398]29
30  void setName(const char* name);
[2748]31 
[3396]32  void draw(void) const;
33  void draw(int groupNumber) const;
34  void draw(char* groupName) const;
[3063]35  int getGroupCount() const;
[2767]36
[3396]37 protected:
[3398]38  char* name;            //!< This is the name of the Model.
39  bool finalized;        //!< Sets the Object to be finalized.
40 
[3186]41  //! This is the placeholder of one Vertex beloning to a Face.
[3396]42  struct FaceElement
[3063]43  {
[3186]44    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
45    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
46    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
47    FaceElement* next;   //!< Point to the next FaceElement in this List.
[3063]48  };
49
[3186]50  //! This is the placeholder of a Face belonging to a Group of Faces.
[3418]51  struct Face
[3063]52  {
[3186]53    int vertexCount;        //!< The Count of vertices this Face has.
54    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
[3063]55
[3186]56    char* materialString;   //!< The Name of the Material to which to Change.
[3063]57
[3186]58    Face* next;             //!< Pointer to the next Face.
59  }; 
[3063]60
[3360]61  //! Group to handle multiple Models per obj-file.
[2850]62  struct Group
63  {
[3186]64    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
[2850]65
[3427]66    unsigned int listNumber;//!< The number of the GL-List this Group gets.
[3186]67    Face* firstFace;    //!< The first Face in this group.
68    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
69    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...
70    int faceCount;      //!< The Number of Faces this Group holds.
[2850]71
[3186]72    Group* next;        //!< Pointer to the next Group.
[3063]73  };
[2850]74
[3063]75
[3186]76  Array* vertices;      //!< The Array that handles the Vertices.
77  int verticesCount;    //!< A global Counter for vertices.
78  Array* normals;       //!< The Array that handles the Normals.
79  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
[3063]80
[2850]81 
[3186]82  Group* firstGroup;    //!< The first of all groups.
83  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
84  int groupCount;       //!< The Count of Groups.
[2850]85
[3186]86  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
[3360]87  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
[2760]88
[3400]89  bool initialize(void);
[2850]90  bool initGroup(Group* group);
[3066]91  bool initFace (Face* face);
92  bool cleanup(void);
93  bool cleanupGroup(Group* group);
94  bool cleanupFace(Face* face);
[3068]95  bool cleanupFaceElement(FaceElement* faceElem);
[2850]96
[3398]97 public:
[3400]98  bool addGroup(char* groupString);
99  bool addVertex(char* vertexString);
100  bool addVertex(const float x, const float y, const float z);
101  bool addFace(char* faceString);
[3418]102  bool addFace(const float faceElemCount, int type, ...);
[3400]103  bool addVertexNormal(char* normalString);
104  bool addVertexNormal(const float x, const float y, const float z);
105  bool addVertexTexture(char* vTextureString);
106  bool addVertexTexture(const float u, const float v);
107  bool addUseMtl(char* mtlString);
[3398]108  void finalize(void);
[2754]109
[3398]110 protected:
[3400]111  bool importToGL(void);
112  bool addGLElement(FaceElement* elem);
[2821]113
[3400]114  bool buildVertexNormals(void);
[3075]115
[3400]116  void cubeModel(void);
[3418]117  void sphereModel(void);
[3400]118  void cylinderModel(void);
[2748]119};
[2773]120
121#endif
Note: See TracBrowser for help on using the repository browser.