Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4615 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Jun 13, 2005, 1:26:25 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: modified the cd subproject, so it loads an md2 file now. the polygons are rendered black, so the bounding box is not viewable! Must render them in another color:)

File:
1 edited

Legend:

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

    r4488 r4615  
    1 /*! 
     1/*!
    22    \file md2Model.h
    33    \brief Definition of an MD2 Model, a model format invented by ID Software.
    4    
     4
    55    We are deeply thankfull for all the wunderfull things id software made for us gamers!
    6    
     6
    77    The md2 file format is structured in a very simple way: it contains animations which are made out of
    88    frames (so called keyframes). Each frame is a complete draweable model in a specific position.
    99    A frame is a collection of vertex and its compagnions (normals, texture coordinates).
    10    
    11     A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently 
     10
     11    A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently
    1212    512 frames. The maximal vetices count is set to 2048 verteces, not enough?
    1313    You just have to change the MD2_MAX_* values if it doesn't fit your purposes...
    14    
     14
    1515    Surface Culling is fully implemented in md2 models: quake2 uses front face culling.
    1616*/
     
    2727#define MD2_IDENT                       (('2'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md2 identifier tag in the bin file
    2828#define MD2_VERSION                     8                                        //!< the md2 version in the header
    29 #define MD2_MAX_TRIANGLES               4096                                     //!< maximal triangles count
    30 #define MD2_MAX_VERTICES                2048                                     //!< maximal vertices count
    31 #define MD2_MAX_TEXCOORDS               2048                                     //!< maximal tex coordinates
    32 #define MD2_MAX_FRAMES                  512                                      //!< maximal frames
    33 #define MD2_MAX_SKINS                   32                                       //!< maximal skins
    34 #define MD2_MAX_FRAMESIZE               (MD2_MAX_VERTICES * 4 + 128)             //!< maximal framesize
     29#define MD2_MAX_TRIANGLES               4096                                     //!< maximal triangles count
     30#define MD2_MAX_VERTICES                2048                                     //!< maximal vertices count
     31#define MD2_MAX_TEXCOORDS               2048                                     //!< maximal tex coordinates
     32#define MD2_MAX_FRAMES                  512                                      //!< maximal frames
     33#define MD2_MAX_SKINS                   32                                       //!< maximal skins
     34#define MD2_MAX_FRAMESIZE               (MD2_MAX_VERTICES * 4 + 128)             //!< maximal framesize
    3535
    3636#define NUM_VERTEX_NORMALS              162                                      //!< number of vertex normals
     
    3838
    3939//! This stores the speed of the animation between each key frame - currently conflicting with the animation framework
    40 #define kAnimationSpeed                 12.0f                                    //!< animation speed
     40#define kAnimationSpeed                 12.0f                                    //!< animation speed
    4141
    4242//! This holds the header information that is read in at the beginning of the file: id software definition
    4343struct MD2Header
    44 { 
    45    int ident;                           //!< This is used to identify the file
    46    int version;                         //!< The version number of the file (Must be 8)
    47    
    48    int skinWidth;                       //!< The skin width in pixels
    49    int skinHeight;                      //!< The skin height in pixels
    50    int frameSize;                       //!< The size in bytes the frames are
    51    
    52    int numSkins;                        //!< The number of skins associated with the model
    53    int numVertices;                     //!< The number of vertices (constant for each frame)
    54    int numTexCoords;                    //!< The number of texture coordinates
    55    int numTriangles;                    //!< The number of faces (polygons)
    56    int numGlCommands;                   //!< The number of gl commands
    57    int numFrames;                       //!< The number of animation frames
    58    
    59    int offsetSkins;                     //!< The offset in the file for the skin data
    60    int offsetTexCoords;                 //!< The offset in the file for the texture data
    61    int offsetTriangles;                 //!< The offset in the file for the face data
    62    int offsetFrames;                    //!< The offset in the file for the frames data
    63    int offsetGlCommands;                //!< The offset in the file for the gl commands data
    64    int offsetEnd;                       //!< The end of the file offset
     44{
     45   int ident;                           //!< This is used to identify the file
     46   int version;                         //!< The version number of the file (Must be 8)
     47
     48   int skinWidth;                       //!< The skin width in pixels
     49   int skinHeight;                      //!< The skin height in pixels
     50   int frameSize;                       //!< The size in bytes the frames are
     51
     52   int numSkins;                        //!< The number of skins associated with the model
     53   int numVertices;                     //!< The number of vertices (constant for each frame)
     54   int numTexCoords;                    //!< The number of texture coordinates
     55   int numTriangles;                    //!< The number of faces (polygons)
     56   int numGlCommands;                   //!< The number of gl commands
     57   int numFrames;                       //!< The number of animation frames
     58
     59   int offsetSkins;                     //!< The offset in the file for the skin data
     60   int offsetTexCoords;                 //!< The offset in the file for the texture data
     61   int offsetTriangles;                 //!< The offset in the file for the face data
     62   int offsetFrames;                    //!< The offset in the file for the frames data
     63   int offsetGlCommands;                //!< The offset in the file for the gl commands data
     64   int offsetEnd;                       //!< The end of the file offset
    6565};
    6666
     
    8585    CROUCH_ATTACK,
    8686    CROUCH_PAIN,
    87     CROUCH_DEATH, 
     87    CROUCH_DEATH,
    8888    DEATH_FALLBACK,
    8989    DEATH_FALLFORWARD,
    9090    DEATH_FALLBACKSLOW,
    9191    BOOM,
    92  
     92
    9393    MAX_ANIMATIONS
    9494  };
     
    113113
    114114 public:
    115   int                numFrames;             //!< number of frames   
     115  int                numFrames;             //!< number of frames
    116116  int                numVertices;           //!< number of vertices
    117117  int                numTriangles;          //!< number of triangles
     
    125125  int*               pLightNormals;         //!< pointer to the light normals
    126126
    127   Material*          material;              //!< pointer to the material 
     127  Material*          material;              //!< pointer to the material
    128128  float              scaleFactor;           //!< the scale factor of the model, (global)
    129129};
     
    136136  MD2Model(const char* modelFileName, const char* skinFileName = NULL);
    137137  virtual ~MD2Model();
    138    
     138
    139139  void draw();
    140  
     140
    141141  void setAnim(int type);
    142142  /**
    143      \brief scales the current model 
     143     \brief scales the current model
    144144     \param scaleFactor: the factor [0..1] to use for scaling
    145145  */
     
    151151
    152152private:
    153   void animate(); 
     153  void animate();
    154154  void processLighting();
    155155  void interpolate(sVec3D* verticesList);
     
    162162  static sAnim        animationList[21];                //!< the anomation list
    163163
    164  private:
    165164  MD2Data*            data;                             //!< the md2 data pointer
    166165
     166 private:
    167167  float               scaleFactor;                      //!< the scale factor (individual)
    168168  sAnimState          animationState;                   //!< animation state of the model
Note: See TracChangeset for help on using the changeset viewer.