Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2005, 9:29:41 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/physics: merged with trunk - with command svn merge -r 3866:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/lib/graphics/importer/model.h

    r3801 r3953  
    88
    99#include "material.h"
     10#include "glincl.h"
    1011
    1112// FORWARD DEFINITION //
    1213class Array;
    1314class Vector;
     15template<class T> class tList;
    1416
    15 using namespace std;
     17//! an enumerator fot the different Model Types.
     18/**
     19   MODEL_DISPLAY_LIST means, that a DisplayList will be built out of the model. This model will be STATIC, meaning it cannot be changed after initialisation.
     20   MODEL_VERTEX_ARRAY means, that a VertexArray will be built out of the model. This moel will be DYNAMIX, meaning that one can change the properties from outside of the model.
     21*/
     22typedef enum MODEL_TYPE {MODEL_DISPLAY_LIST,
     23                         MODEL_VERTEX_ARRAY};
     24
    1625
    1726// definition of different modes for setting up Faces
     
    1928#define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
    2029#define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
     30//! an enumerator for VERTEX_FORMAT
     31typedef enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,
     32                    VERTEX_NORMAL = NORMAL,
     33                    VERTEX_TEXCOORD = TEXCOORD,
     34                    VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD};
    2135
    2236//! Class that handles 3D-Models. it can also read them in and display them.
    2337class Model
    2438{
    25  public:
    26   Model(void);
    27   Model(char* modelName);
    28   virtual ~Model(void);
    29 
    30   void setName(const char* name);
    31  
    32   void draw(void) const;
    33   void draw(int groupNumber) const;
    34   void draw(char* groupName) const;
    35   int getGroupCount() const;
    36 
    37  protected:
    38   char* name;            //!< This is the name of the Model.
    39   bool finalized;        //!< Sets the Object to be finalized.
    40  
     39 private:
     40  /////////////
     41  // structs //
     42  /////////////
    4143  //! This is the placeholder of one Vertex beloning to a Face.
    4244  struct FaceElement
     
    6466    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
    6567
    66     unsigned int listNumber;//!< The number of the GL-List this Group gets.
     68    GLubyte* indices;   //!< The indices of the Groups. Needed for vertex-arrays
     69    GLuint listNumber;  //!< The number of the GL-List this Group gets.
    6770    Face* firstFace;    //!< The first Face in this group.
    6871    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
     
    7376  };
    7477
     78  char* name;            //!< This is the name of the Model.
     79  MODEL_TYPE type;
     80  bool finalized;        //!< Sets the Object to be finalized.
    7581
    7682  Array* vertices;      //!< The Array that handles the Vertices.
     
    7985  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
    8086
    81  
    8287  Group* firstGroup;    //!< The first of all groups.
    8388  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
    8489  int groupCount;       //!< The Count of Groups.
    8590
    86   Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
    87   float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
     91  tList<Material>* materialList;
     92 
    8893
    89   bool initialize(void);
    9094  bool initGroup(Group* group);
    9195  bool initFace (Face* face);
     96
     97  bool buildVertexNormals(void);
     98
     99  bool importToDisplayList(void);
     100  bool addGLElement(FaceElement* elem);
     101
     102  bool importToVertexArray(void);
     103
     104  bool deleteArrays(void);
    92105  bool cleanup(void);
    93106  bool cleanupGroup(Group* group);
     
    95108  bool cleanupFaceElement(FaceElement* faceElem);
    96109
    97  public:
    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);
    102   bool addFace(const float faceElemCount, int type, ...);
    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);
    108   bool addUseMtl(Material* mtl);
    109   void finalize(void);
    110110
    111111 protected:
    112   bool importToGL(void);
    113   bool addGLElement(FaceElement* elem);
     112  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
    114113
    115   bool buildVertexNormals(void);
     114  Material* findMaterialByName(const char* materialName);
    116115
    117116  void cubeModel(void);
     117
     118 public:
     119  Model(const char* modelName = NULL, MODEL_TYPE type = MODEL_DISPLAY_LIST);
     120  virtual ~Model(void);
     121
     122  void setName(const char* name);
     123  inline const char* getName() {return this->name;}
     124 
     125  void draw(void) const;
     126  void draw(int groupNumber) const;
     127  void draw(char* groupName) const;
     128  int getGroupCount() const;
     129
     130  Material* addMaterial(Material* material);
     131  Material* addMaterial(const char* materialName);
     132
     133  bool addGroup(const char* groupString);
     134  bool addVertex(const char* vertexString);
     135  bool addVertex(float x, float y, float z);
     136  bool addFace(const char* faceString);
     137  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
     138  bool addVertexNormal(const char* normalString);
     139  bool addVertexNormal(float x, float y, float z);
     140  bool addVertexTexture(const char* vTextureString);
     141  bool addVertexTexture(float u, float v);
     142  bool setMaterial(const char* mtlString);
     143  bool setMaterial(Material* mtl);
     144  void finalize(void);
    118145};
    119146
Note: See TracChangeset for help on using the changeset viewer.