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/md2/md2Model.h

    r9235 r9869  
    2020
    2121#include "base_object.h"
     22#include "count_pointer.h"
    2223
    2324#include "interactive_model.h"
     
    4546struct MD2Header
    4647{
    47    int ident;                           //!< This is used to identify the file
    48    int version;                         //!< The version number of the file (Must be 8)
    49 
    50    int skinWidth;                       //!< The skin width in pixels
    51    int skinHeight;                      //!< The skin height in pixels
    52    int frameSize;                       //!< The size in bytes the frames are
    53 
    54    int numSkins;                        //!< The number of skins associated with the model
    55    int numVertices;                     //!< The number of vertices (constant for each frame)
    56    int numTexCoords;                    //!< The number of texture coordinates
    57    int numTriangles;                    //!< The number of faces (polygons)
    58    int numGlCommands;                   //!< The number of gl commands
    59    int numFrames;                       //!< The number of animation frames
    60 
    61    int offsetSkins;                     //!< The offset in the file for the skin data
    62    int offsetTexCoords;                 //!< The offset in the file for the texture data
    63    int offsetTriangles;                 //!< The offset in the file for the face data
    64    int offsetFrames;                    //!< The offset in the file for the frames data
    65    int offsetGlCommands;                //!< The offset in the file for the gl commands data
    66    int offsetEnd;                       //!< The end of the file offset
     48  int ident;                           //!< This is used to identify the file
     49  int version;                         //!< The version number of the file (Must be 8)
     50
     51  int skinWidth;                       //!< The skin width in pixels
     52  int skinHeight;                      //!< The skin height in pixels
     53  int frameSize;                       //!< The size in bytes the frames are
     54
     55  int numSkins;                        //!< The number of skins associated with the model
     56  int numVertices;                     //!< The number of vertices (constant for each frame)
     57  int numTexCoords;                    //!< The number of texture coordinates
     58  int numTriangles;                    //!< The number of faces (polygons)
     59  int numGlCommands;                   //!< The number of gl commands
     60  int numFrames;                       //!< The number of animation frames
     61
     62  int offsetSkins;                     //!< The offset in the file for the skin data
     63  int offsetTexCoords;                 //!< The offset in the file for the texture data
     64  int offsetTriangles;                 //!< The offset in the file for the face data
     65  int offsetFrames;                    //!< The offset in the file for the frames data
     66  int offsetGlCommands;                //!< The offset in the file for the gl commands data
     67  int offsetEnd;                       //!< The end of the file offset
    6768};
    6869
     
    7071//! animation names enumeration
    7172typedef enum MD2animType
    72   {
    73     STAND,                       //0
    74     RUN,                         //1
    75     ATTACK,                      //2
    76     PAIN_A,                      //3
    77     PAIN_B,                      //4
    78     PAIN_C,          //5
    79     JUMP,            //6
    80     FLIP,            //7
    81     SALUTE,          //8
    82     FALLBACK,        //9
    83     WAVE,            //10
    84     POINT,           //11
    85     CROUCH_STAND,
    86     CROUCH_WALK,
    87     CROUCH_ATTACK,
    88     CROUCH_PAIN,
    89     CROUCH_DEATH,
    90     DEATH_FALLBACK,
    91     DEATH_FALLFORWARD,
    92     DEATH_FALLBACKSLOW,
    93     BOOM,
    94     WALK,
    95 
    96     MAX_ANIMATIONS
    97   };
     73{
     74  STAND,                       //0
     75  RUN,                         //1
     76  ATTACK,                      //2
     77  PAIN_A,                      //3
     78  PAIN_B,                      //4
     79  PAIN_C,          //5
     80  JUMP,            //6
     81  FLIP,            //7
     82  SALUTE,          //8
     83  FALLBACK,        //9
     84  WAVE,            //10
     85  POINT,           //11
     86  CROUCH_STAND,
     87  CROUCH_WALK,
     88  CROUCH_ATTACK,
     89  CROUCH_PAIN,
     90  CROUCH_DEATH,
     91  DEATH_FALLBACK,
     92  DEATH_FALLFORWARD,
     93  DEATH_FALLBACKSLOW,
     94  BOOM,
     95  WALK,
     96
     97  MAX_ANIMATIONS
     98};
    9899
    99100
     
    116117class MD2Data : public BaseObject
    117118{
    118  public:
    119    MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
     119public:
     120  typedef CountPointer<MD2Data>    Pointer;
     121public:
     122  MD2Data();
     123  MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
    120124  virtual ~MD2Data();
    121125
    122  private:
    123    bool loadModel(const std::string& fileName);
    124    bool loadSkin(const std::string& fileName = "");
    125 
    126  public:
     126private:
     127  void init();
     128  bool loadModel(const std::string& fileName);
     129  bool loadSkin(const std::string& fileName = "");
     130
     131public:
    127132  int                numFrames;             //!< number of frames
    128133  int                numVertices;           //!< number of vertices
     
    148153
    149154//! This is a MD2 Model class
    150 class MD2Model : public InteractiveModel {
    151 
    152 public:
     155class MD2Model : public InteractiveModel
     156{
     157  ObjectListDeclaration(MD2Model);
     158public:
     159  MD2Model();
    153160  MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
     161  MD2Model(const MD2Model& model);
    154162  virtual ~MD2Model();
     163
     164  MD2Model& operator=(const MD2Model& md2model);
     165
     166  bool load(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
    155167
    156168  virtual void draw() const;
     
    160172  virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback);
    161173  /**  returns the current animation @returns animation type */
    162   inline int MD2Model::getAnimation() { return this->animationState.type; }
     174  inline int getAnimation() const { return this->animationState.type; }
    163175  virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
    164   virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
     176virtual bool isAnimationFinished() const { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
    165177  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
    166178  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
    167179
     180
     181  void acquireData(const MD2Data::Pointer& data) { this->data = data; rebuildInfo(); };
     182  const MD2Data::Pointer& dataPointer() const { return this->data; };
    168183  virtual void tick(float dtS);
    169184  void debug();
     
    171186
    172187private:
     188  void init();
     189  void rebuildInfo();
     190
    173191  void animate(float time);
    174192  void processLighting();
     
    177195
    178196
    179  public:
     197public:
    180198  /* these variables are static, because they are all the same for every model */
    181   static sVec3D       anorms[NUM_VERTEX_NORMALS];       //!< the anormals
    182   static float        anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
    183   static sAnim        animationList[22];                //!< the anomation list
    184    //! again one of these strange id software parts
    185   float*              shadeDots;
    186 
    187   MD2Data*            data;                             //!< the md2 data pointer
    188 
    189  private:
    190   float               scaleFactor;                      //!< the scale factor (individual)
    191   float               animationSpeed;                   //!< the speed of the animation (factor for the time)
    192   sAnimState          animationState;                   //!< animation state of the model
    193   sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
     199  static sVec3D         anorms[NUM_VERTEX_NORMALS];       //!< the anormals
     200  static float          anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
     201  static sAnim          animationList[22];                //!< the anomation list
     202  //! again one of these strange id software parts
     203  float*                shadeDots;
     204
     205  CountPointer<MD2Data> data;                           //!< the md2 data pointer
     206
     207private:
     208  float                 scaleFactor;                      //!< the scale factor (individual)
     209  float                 animationSpeed;                   //!< the speed of the animation (factor for the time)
     210  sAnimState            animationState;                   //!< animation state of the model
     211  sVec3D                verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
    194212};
    195213
Note: See TracChangeset for help on using the changeset viewer.