Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 23, 2006, 12:05:13 PM (17 years ago)
Author:
bensch
Message:

orxonox/trunk: ported the static_model to std::vectort.
Took me 90 minutes, and i hope everything is still working as it did before :)

File:
1 edited

Legend:

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

    r9869 r10141  
    2727};
    2828
    29 ////////////////////
    30 /// SUB-ELEMENTS ///
    31 ////////////////////
    32 //! This is the placeholder of one Vertex beloning to a Face.
    33 class ModelFaceElement
    34 {
    35 public:
    36   ModelFaceElement();
    37   ~ModelFaceElement();
    3829
    39   int                 vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
    40   int                 normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
    41   int                 texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
    42 
    43   ModelFaceElement*   next;                 //!< Point to the next FaceElement in this List.
    44 };
    45 
    46 //! This is the placeholder of a Face belonging to a Group of Faces.
    47 class ModelFace
    48 {
    49 public:
    50   ModelFace();
    51   ~ModelFace();
    52 
    53   unsigned int        vertexCount;     //!< The Count of vertices this Face has.
    54   ModelFaceElement*   firstElem;       //!< Points to the first Vertex (FaceElement) of this Face.
    55   Material*           material;        //!< The Material to use.
    56 
    57   ModelFace*          next;            //!< Pointer to the next Face.
    58 };
    59 
    60 //! Group to handle multiple Models per obj-file.
    61 class ModelGroup
    62 {
    63 public:
    64   ModelGroup();
    65   ~ModelGroup();
    66 
    67   void cleanup();
    68 
    69   std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
    70   GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
    71   GLuint       listNumber;     //!< The number of the GL-List this Group gets.
    72   ModelFace*   firstFace;      //!< The first Face in this group.
    73   ModelFace*   currentFace;    //!< The current Face in this Group (the one we are currently working with.)
    74   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...
    75   int          faceCount;      //!< The Number of Faces this Group holds.
    76 
    77   ModelGroup*  next;           //!< Pointer to the next Group.
    78 };
    79 
    80 struct ModelMaterial
    81 {
    82   Material* material;
    83   bool external;
    84 };
    8530
    8631/////////////
     
    9540{
    9641  ObjectListDeclaration(StaticModelData);
     42
     43private:
     44  ////////////////////
     45  /// SUB-ELEMENTS ///
     46  ////////////////////
     47  //! This is the placeholder of one Vertex beloning to a Face.
     48  class FaceElement
     49  {
    9750  public:
    98     typedef CountPointer<StaticModelData> Pointer;
     51    FaceElement();
     52
     53    int                 vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
     54    int                 normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
     55    int                 texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
     56  };
     57
     58  //! This is the placeholder of a Face belonging to a Group of Faces.
     59  class Face
     60  {
     61  public:
     62    Face();
     63
     64    std::vector<FaceElement>  _elements; //!< Elements of the Face.
     65    Material*                 _material;        //!< The Material to use.
     66  };
     67
     68  //! Group to handle multiple Models per obj-file.
     69  class Group
     70  {
     71  public:
     72    Group();
     73    ~Group();
     74
     75    //! Compares the name with the groups name.
     76    bool operator==(const std::string& name) const { return this->name == name; };
     77    void cleanup();
     78
     79    std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
     80    GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
     81    GLuint       listNumber;     //!< The number of the GL-List this Group gets.
     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
     84    std::vector<Face> _faces;    //!< Faces.
     85  };
    9986
    10087  public:
     88  typedef CountPointer<StaticModelData> Pointer;
     89
     90public:
    10191  StaticModelData(const std::string& modelName = "");
    10292  virtual ~StaticModelData();
    10393
    10494  void draw() const;
    105   void draw(int groupNumber) const;
     95  void draw(unsigned int groupNumber) const;
    10696  void draw(const std::string& groupName) const;
    10797
    10898  void rebuild();
    10999
    110   Material* addMaterial(Material* material);
     100  Material* addMaterial(const Material& material);
    111101  Material* addMaterial(const std::string& materialName);
    112102
     
    151141  bool buildTriangleList();
    152142
    153   bool addGLElement(ModelFaceElement* elem);
     143  bool addGLElement(const StaticModelData::FaceElement& elem);
    154144
    155145  bool cleanup();
     
    168158  std::vector<sTriangleExt>  triangles;       //!< The Triangles if built.
    169159
    170   ModelGroup*                firstGroup;      //!< The first of all groups.
    171   ModelGroup*                currentGroup;    //!< The currentGroup. this is the one we will work with.
    172   int                        groupCount;      //!< The Count of Groups.
    173160
    174   std::list<ModelMaterial*>  materialList;    //!< A list for all the Materials in this Model
     161  std::vector<Group>         _modelGroups;
     162
     163  std::list<Material>        materialList;    //!< A list for all the Materials in this Model
    175164};
    176165
Note: See TracChangeset for help on using the changeset viewer.