Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 13, 2005, 3:40:23 PM (19 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: reimplemente the whole md2_loader to make it more performant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/importer/abstract_model.h

    r4159 r4172  
    3030using namespace std;
    3131
    32 //template<class T> class tList;
    33 ;
     32
     33
     34//! this is a small and performant 3D vector
     35typedef float sVec3D[3];
     36
     37//! small and performant 2D vector
     38typedef float sVec2D[2];
     39
     40//! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
     41typedef struct
     42{
     43  byte v[3];
     44  unsigned char lightNormalIndex;
     45} sVertex;
     46
     47//! compressed texture offset data: coords scaled by the texture size. Only for loading
     48typedef struct
     49{
     50  short s,t;
     51} sTexCoor;
     52
     53
     54//! holds tha informations about a md2 frame
     55typedef struct
     56{
     57  sVec3D scale;                        //!< scales values of the model
     58  sVec3D translate;                    //!< translates the model
     59  char name[16];                       //!< frame name: something like "run32"
     60  sVertex pVertices[1];                //!< first vertex of thes frame
     61} sFrame;
     62
     63
     64//! holds the information about a triangle
     65typedef struct
     66{
     67  short indexToVertices[3];             //!< index to the verteces of the triangle
     68  short indexToTexCoor[3];              //!< index to the texture coordinates
     69} sTriangle;
     70
     71
     72//! a md2 animation definition
     73typedef struct
     74{
     75  int firstFrame;                       //!< first frame of the animation
     76  int lastFrame;                        //!< last frame of the animation
     77  int fps;                              //!< speed: number of frames per second
     78} sAnim;
     79
     80//! animation state definition
     81typedef struct
     82{
     83  int startFrame;
     84  int endFrame;
     85  int fps;
     86
     87  float localTime;
     88  float lastTime;
     89  float interpolationState;            //!< the state of the animation [0..1]
     90 
     91  int type;                            //!< animation type
     92
     93  int currentFrame;
     94  int nextFrame;
     95} sAnimState;
     96
    3497
    3598//! This is our 3D point class.  CONFLICTING with Vector.cc
    3699class CVector3
    37100{
    38 public:
    39         float x, y, z;
     101 public:
     102  float x, y, z;
    40103};
    41104
     
    43106class CVector2
    44107{
    45 public:
    46         float x, y;
     108 public:
     109  float x, y;
    47110};
    48111
     
    50113struct tFace
    51114{
    52         int vertIndex[3];                       // indicies for the verts that make up this triangle
    53         int coordIndex[3];                      // indicies for the tex coords to texture this face
     115  int vertIndex[3];                     // indicies for the verts that make up this triangle
     116  int coordIndex[3];                    // indicies for the tex coords to texture this face
    54117};
    55118
     
    57120struct tMaterialInfo
    58121{
    59         char  strName[255];                     // The texture name
    60         char  strFile[255];                     // The texture file name (If this is set it's a texture map)
    61         byte  color[3]; // The color of the object (R, G, B)
    62         int   texureId;                         // the texture ID
    63         float uTile;                            // u tiling of texture 
    64         float vTile;                            // v tiling of texture 
    65         float uOffset;                      // u offset of texture
    66         float vOffset;                          // v offset of texture
     122  char  strName[255];                   // The texture name
     123  char  strFile[255];                   // The texture file name (If this is set it's a texture map)
     124  byte  color[3];       // The color of the object (R, G, B)
     125  int   texureId;                               // the texture ID
     126  float uTile;                          // u tiling of texture 
     127  float vTile;                          // v tiling of texture 
     128  float uOffset;                                // u offset of texture
     129  float vOffset;                                // v offset of texture
    67130} ;
    68131
     
    70133struct t3DObject
    71134{
    72         int  numOfVerts;                        // The number of verts in the model
    73         int  numOfFaces;                        // The number of faces in the model
    74         int  numTexVertex;                      // The number of texture coordinates
    75         int  materialID;                        // The texture ID to use, which is the index into our texture array
    76         bool bHasTexture;                       // This is TRUE if there is a texture map for this object
    77         char strName[255];                      // The name of the object
    78         CVector3  *pVerts;                      // The object's vertices
    79         CVector3  *pNormals;                    // The object's normals
    80         CVector2  *pTexVerts;                   // The texture's UV coordinates
    81         tFace *pFaces;                          // The faces information of the object
     135  int  numOfVerts;                      // The number of verts in the model
     136  int  numOfFaces;                      // The number of faces in the model
     137  int  numTexVertex;                    // The number of texture coordinates
     138  int  materialID;                      // The texture ID to use, which is the index into our texture array
     139  bool bHasTexture;                     // This is TRUE if there is a texture map for this object
     140  char strName[255];                    // The name of the object
     141  CVector3  *pVerts;                    // The object's vertices
     142  CVector3  *pNormals;                  // The object's normals
     143  CVector2  *pTexVerts;                 // The texture's UV coordinates
     144  tFace *pFaces;                                // The faces information of the object
    82145};
    83146
     
    85148struct tAnimationInfo
    86149{
    87         char strName[255];                      // This stores the name of the animation (Jump, Pain, etc..)
    88         int startFrame;                         // This stores the first frame number for this animation
    89         int endFrame;                           // This stores the last frame number for this animation
     150  char strName[255];                    // This stores the name of the animation (Jump, Pain, etc..)
     151  int startFrame;                               // This stores the first frame number for this animation
     152  int endFrame;                         // This stores the last frame number for this animation
    90153};
    91154
     
    93156struct t3DModel
    94157{
    95         int numOfObjects;                                       // The number of objects in the model
    96         int numOfMaterials;                                     // The number of materials for the model
    97         int numOfAnimations;                            // The number of animations in this model (NEW)
    98         int currentAnim;                                        // The current index into pAnimations list (NEW)
    99         int currentFrame;                                       // The current frame of the current animation (NEW)
    100         vector<tAnimationInfo> animationList; // The list of animations (NEW)
    101         vector<tMaterialInfo> materialList;     // The list of material information (Textures and colors)
    102         vector<t3DObject> objectList;                   // The object list for our model
     158  int numOfObjects;                                     // The number of objects in the model
     159  int numOfMaterials;                                   // The number of materials for the model
     160  int numOfAnimations;                          // The number of animations in this model (NEW)
     161  int currentAnim;                                      // The current index into pAnimations list (NEW)
     162  int currentFrame;                                     // The current frame of the current animation (NEW)
     163  vector<tAnimationInfo> animationList; // The list of animations (NEW)
     164  vector<tMaterialInfo> materialList;   // The list of material information (Textures and colors)
     165  vector<t3DObject> objectList;                 // The object list for our model
    103166};
    104167
Note: See TracChangeset for help on using the changeset viewer.