Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3475 was 3454, checked in by bensch, 20 years ago

orxonox/trunk/importer: doxygen-tags

File size: 4.1 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
[3454]19//! Specification of different primitives the Model knows
[3398]20enum PRIMITIVE {PLANE, CUBE, SPHERE, CYLINDER};
[2842]21
[3360]22//! Class that handles 3D-Models. it can also read them in and display them.
23class Model
[2748]24{
25 public:
[3396]26  Model(void);
[3398]27  Model(PRIMITIVE type);
28  Model(char* modelName);
[3396]29  virtual ~Model(void);
[3398]30
31  void setName(const char* name);
[2748]32 
[3396]33  void draw(void) const;
34  void draw(int groupNumber) const;
35  void draw(char* groupName) const;
[3063]36  int getGroupCount() const;
[2767]37
[3396]38 protected:
[3398]39  char* name;            //!< This is the name of the Model.
40  bool finalized;        //!< Sets the Object to be finalized.
41 
[3186]42  //! This is the placeholder of one Vertex beloning to a Face.
[3396]43  struct FaceElement
[3063]44  {
[3186]45    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
46    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
47    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
48    FaceElement* next;   //!< Point to the next FaceElement in this List.
[3063]49  };
50
[3186]51  //! This is the placeholder of a Face belonging to a Group of Faces.
[3418]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
[3360]62  //! Group to handle multiple Models 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
[3427]67    unsigned int listNumber;//!< The number of the GL-List this Group gets.
[3186]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(..)
[3360]88  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
[2760]89
[3400]90  bool initialize(void);
[2850]91  bool initGroup(Group* group);
[3066]92  bool initFace (Face* face);
93  bool cleanup(void);
94  bool cleanupGroup(Group* group);
95  bool cleanupFace(Face* face);
[3068]96  bool cleanupFaceElement(FaceElement* faceElem);
[2850]97
[3398]98 public:
[3400]99  bool addGroup(char* groupString);
100  bool addVertex(char* vertexString);
101  bool addVertex(const float x, const float y, const float z);
102  bool addFace(char* faceString);
[3418]103  bool addFace(const float faceElemCount, int type, ...);
[3400]104  bool addVertexNormal(char* normalString);
105  bool addVertexNormal(const float x, const float y, const float z);
106  bool addVertexTexture(char* vTextureString);
107  bool addVertexTexture(const float u, const float v);
108  bool addUseMtl(char* mtlString);
[3398]109  void finalize(void);
[2754]110
[3398]111 protected:
[3400]112  bool importToGL(void);
113  bool addGLElement(FaceElement* elem);
[2821]114
[3400]115  bool buildVertexNormals(void);
[3075]116
[3400]117  void cubeModel(void);
[3418]118  void sphereModel(void);
[3400]119  void cylinderModel(void);
[2748]120};
[2773]121
122#endif
Note: See TracBrowser for help on using the repository browser.