Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

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

    r7221 r9869  
    1010
    1111#include "material.h"
    12 #include "glincl.h"
    1312#include <vector>
    14 #include <list>
    15 
    16 // definition of different modes for setting up Faces
    17 #define VERTEX 0       //!< If Faces are created WITH Vertex-Coordinate
    18 #define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
    19 #define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
    20 
    21 //! an enumerator for VERTEX_FORMAT
    22 typedef enum VERTEX_FORMAT {
    23   VERTEX_ONLY = VERTEX,
    24   VERTEX_NORMAL = NORMAL,
    25   VERTEX_TEXCOORD = TEXCOORD,
    26   VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD
    27 };
    28 
    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();
    38 
    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 };
     13#include "static_model_data.h"
    8514
    8615/////////////
     
    9423class StaticModel : public Model
    9524{
    96  public:
     25  ObjectListDeclaration(StaticModel);
     26public:
    9727  StaticModel(const std::string& modelName = "");
     28  StaticModel(const StaticModel& staticModel);
    9829  virtual ~StaticModel();
    9930
    100   virtual void draw() const;
    101   void draw(int groupNumber) const;
    102   void draw(const std::string& groupName) const;
     31  StaticModel& operator=(const StaticModel& model);
    10332
    104   void rebuild();
     33  virtual void draw() const { data->draw(); };
     34  void draw(int groupNumber) const { data->draw(groupNumber); };
     35  void draw(const std::string& groupName) const { data->draw(groupName); };
    10536
    106   Material* addMaterial(Material* material);
    107   Material* addMaterial(const std::string& materialName);
     37  void rebuild() { data->rebuild(); };
    10838
    109   bool addGroup(const std::string& groupString);
     39  Material* addMaterial(Material* material) { return data->addMaterial(material); };
     40  Material* addMaterial(const std::string& materialName) { return data->addMaterial(materialName); };
    11041
    111   bool addVertex(const std::string& vertexString);
    112   bool addVertex(float x, float y, float z);
     42  bool addGroup(const std::string& groupString) { return data->addGroup(groupString); };
    11343
    114   bool addFace(const std::string& faceString);
     44  bool addVertex(const std::string& vertexString) { return data->addVertex(vertexString); };
     45  bool addVertex(float x, float y, float z) { return data->addVertex(x, y, z); };
     46
     47  bool addFace(const std::string& faceString) { return data->addFace(faceString); };
    11548  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
    11649
    117   bool addVertexNormal(const std::string& normalString);
    118   bool addVertexNormal(float x, float y, float z);
     50  bool addVertexNormal(const std::string& normalString) { return this->data->addVertexNormal(normalString); };
     51  bool addVertexNormal(float x, float y, float z) { return this->data->addVertexNormal(x,y,z); };
    11952
    120   bool addVertexTexture(const std::string& vTextureString);
    121   bool addVertexTexture(float u, float v);
     53  bool addVertexTexture(const std::string& vTextureString) { return this->data->addVertexTexture(vTextureString); };
     54  bool addVertexTexture(float u, float v) { return this->data->addVertexTexture(u, v); };
    12255
    123   bool setMaterial(const std::string& mtlString);
    124   bool setMaterial(Material* mtl);
     56  bool setMaterial(const std::string& mtlString) { return data->setMaterial(mtlString); };
     57  bool setMaterial(Material* mtl) { return data->setMaterial(mtl);};
    12558
    12659  void finalize();
    12760
     61  void acquireData(const StaticModelData::Pointer& data);
     62  const StaticModelData::Pointer& dataPointer() const { return this->data; };
    12863
    129  protected:
     64  inline void setScaleFactor(float scaleFactor) { this->data->setScaleFactor(scaleFactor); };
     65  float getScaleFactor() const { return data->getScaleFactor(); }
     66
     67protected:
    13068  void cubeModel();
    13169
    132   Material* findMaterialByName(const std::string& materialName);
    133 
    134  protected:
    135   float            scaleFactor;     //!< The Factor with which the Model should be scaled. @todo maybe one wants to scale the Model after Initialisation
    136 
    137  private:
    138   bool buildVertexNormals();
    139 
    140   bool importToDisplayList();
    141   bool buildTriangleList();
    142 
    143   bool addGLElement(ModelFaceElement* elem);
    144 
    145   bool cleanup();
    146 
    147  private:
    148   bool                       finalized;       //!< Sets the Object to be finalized.
    149 
    150   unsigned int               faceCount;       //!< A modelwide Counter for the faces
    151 
    152   std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
    153   std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
    154   std::vector<GLfloat>       vTexture;        //!< The Array that handles the VertexTextureCoordinates.
    155 
    156   ModelGroup*                firstGroup;      //!< The first of all groups.
    157   ModelGroup*                currentGroup;    //!< The currentGroup. this is the one we will work with.
    158   int                        groupCount;      //!< The Count of Groups.
    159 
    160   std::list<ModelMaterial*>  materialList;    //!< A list for all the Materials in this Model
     70private:
     71  void updateBase();
     72private:
     73  StaticModelData::Pointer         data;
    16174};
    16275
Note: See TracChangeset for help on using the changeset viewer.