Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2005, 1:35:22 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Model-Class is now more dynamic (all subelements are now classes too, i hope, that atilla was right about classes being as fast as structs

File:
1 edited

Legend:

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

    r3917 r4022  
    3434                    VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD};
    3535
     36////////////////////
     37/// SUB-ELEMENTS ///
     38////////////////////
     39//! This is the placeholder of one Vertex beloning to a Face.
     40class ModelFaceElement
     41{
     42 public:
     43  ModelFaceElement();
     44  ~ModelFaceElement();
     45
     46  int vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
     47  int normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
     48  int texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
     49  ModelFaceElement* next;   //!< Point to the next FaceElement in this List.
     50};
     51
     52//! This is the placeholder of a Face belonging to a Group of Faces.
     53class ModelFace
     54{
     55 public:
     56  ModelFace();
     57  ~ModelFace();
     58
     59  int vertexCount;                //!< The Count of vertices this Face has.
     60  ModelFaceElement* firstElem;    //!< Points to the first Vertex (FaceElement) of this Face.
     61 
     62  Material* material;             //!< The Material to use.
     63 
     64  ModelFace* next;                //!< Pointer to the next Face.
     65};
     66
     67//! Group to handle multiple Models per obj-file.
     68class ModelGroup
     69{
     70 public:
     71  ModelGroup();
     72  ~ModelGroup();
     73
     74  void cleanup();
     75
     76  char* name;                 //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
     77 
     78  GLubyte* indices;           //!< The indices of the Groups. Needed for vertex-arrays
     79  GLuint listNumber;          //!< The number of the GL-List this Group gets.
     80  ModelFace* firstFace;       //!< The first Face in this group.
     81  ModelFace* currentFace;     //!< The current Face in this Group (the one we are currently working with.)
     82  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...
     83  int faceCount;              //!< The Number of Faces this Group holds.
     84 
     85  ModelGroup* next;           //!< Pointer to the next Group.
     86};
     87
     88/////////////
     89/// MODEL ///
     90/////////////
     91
    3692//! Class that handles 3D-Models. it can also read them in and display them.
    3793class Model
    3894{
    3995 private:
    40   /////////////
    41   // structs //
    42   /////////////
    43   //! This is the placeholder of one Vertex beloning to a Face.
    44   struct FaceElement
    45   {
    46     int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
    47     int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
    48     int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
    49     FaceElement* next;   //!< Point to the next FaceElement in this List.
    50   };
    5196
    52   //! This is the placeholder of a Face belonging to a Group of Faces.
    53   struct Face
    54   {
    55     int vertexCount;        //!< The Count of vertices this Face has.
    56     FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
     97  char* name;                 //!< This is the name of the Model.
     98  MODEL_TYPE type;
     99  bool finalized;             //!< Sets the Object to be finalized.
    57100
    58     Material* material;     //!< The Material to use.
     101  Array* vertices;            //!< The Array that handles the Vertices.
     102  int verticesCount;          //!< A global Counter for vertices.
     103  Array* normals;             //!< The Array that handles the Normals.
     104  Array* vTexture;            //!< The Array that handles the VertexTextureCoordinates.
    59105
    60     Face* next;             //!< Pointer to the next Face.
    61   };
     106  ModelGroup* firstGroup;     //!< The first of all groups.
     107  ModelGroup* currentGroup;   //!< The currentGroup. this is the one we will work with.
     108  int groupCount;             //!< The Count of Groups.
    62109
    63   //! Group to handle multiple Models per obj-file.
    64   struct Group
    65   {
    66     char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
    67 
    68     GLubyte* indices;   //!< The indices of the Groups. Needed for vertex-arrays
    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.
    74 
    75     Group* next;        //!< Pointer to the next Group.
    76   };
    77 
    78   char* name;            //!< This is the name of the Model.
    79   MODEL_TYPE type;
    80   bool finalized;        //!< Sets the Object to be finalized.
    81 
    82   Array* vertices;      //!< The Array that handles the Vertices.
    83   int verticesCount;    //!< A global Counter for vertices.
    84   Array* normals;       //!< The Array that handles the Normals.
    85   Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
    86 
    87   Group* firstGroup;    //!< The first of all groups.
    88   Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
    89   int groupCount;       //!< The Count of Groups.
    90 
    91   tList<Material>* materialList;
     110  tList<Material>* materialList;//!< A list for all the Materials in this Model
    92111 
    93 
    94   bool initGroup(Group* group);
    95   bool initFace (Face* face);
    96 
    97112  bool buildVertexNormals(void);
    98113
    99114  bool importToDisplayList(void);
    100   bool addGLElement(FaceElement* elem);
     115  bool addGLElement(ModelFaceElement* elem);
    101116
    102117  bool importToVertexArray(void);
     
    104119  bool deleteArrays(void);
    105120  bool cleanup(void);
    106   bool cleanupGroup(Group* group);
    107   bool cleanupFace(Face* face);
    108   bool cleanupFaceElement(FaceElement* faceElem);
    109121
    110122
Note: See TracChangeset for help on using the changeset viewer.