Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4459 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jun 2, 2005, 12:14:27 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: md2model data/model seperation

Location:
orxonox/trunk/src
Files:
1 deleted
3 edited

Legend:

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

    r4357 r4459  
    2525using namespace std;
    2626
    27 
     27//! the model anorms
    2828sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = {
    2929 #include "anorms.h"
    3030};
    3131
     32//! anormal dots, no idea of how this shall work, but it does
    3233float MD2Model::anormsDots[SHADEDOT_QUANT][256] = {
    3334  #include "anormtab.h"
    3435};
    3536
     37//! again one of these strange id software parts
    3638static float *shadeDots = MD2Model::anormsDots[0];
    3739
     40//! the angle under which the model is viewd, used internaly
    3841float md2Angle = 0.0f;
    3942
    4043
     44//! list of all different animations a std md2model supports
    4145sAnim MD2Model::animationList[21] =
    4246  {
    4347 // begin, end, fps
    44     {   0,  39,  9 },   // STAND
    45     {  40,  45, 10 },   // RUN
    46     {  46,  53, 10 },   // ATTACK
    47     {  54,  57,  7 },   // PAIN_A
    48     {  58,  61,  7 },   // PAIN_B
    49     {  62,  65,  7 },   // PAIN_C
    50     {  66,  71,  7 },   // JUMP
    51     {  72,  83,  7 },   // FLIP
    52     {  84,  94,  7 },   // SALUTE
    53     {  95, 111, 10 },   // FALLBACK
    54     { 112, 122,  7 },   // WAVE
    55     { 123, 134,  6 },   // POINTT
    56     { 135, 153, 10 },   // CROUCH_STAND
    57     { 154, 159,  7 },   // CROUCH_WALK
    58     { 160, 168, 10 },   // CROUCH_ATTACK
    59     { 196, 172,  7 },   // CROUCH_PAIN
    60     { 173, 177,  5 },   // CROUCH_DEATH
    61     { 178, 183,  7 },   // DEATH_FALLBACK
    62     { 184, 189,  7 },   // DEATH_FALLFORWARD
    63     { 190, 197,  7 },   // DEATH_FALLBACKSLOW
    64     { 198, 198,  5 },   // BOOM
     48    {   0,  39,  9 },   //!< STAND
     49    {  40,  45, 10 },   //!< RUN
     50    {  46,  53, 10 },   //!< ATTACK
     51    {  54,  57,  7 },   //!< PAIN_A
     52    {  58,  61,  7 },   //!< PAIN_B
     53    {  62,  65,  7 },   //!< PAIN_C
     54    {  66,  71,  7 },   //!< JUMP
     55    {  72,  83,  7 },   //!< FLIP
     56    {  84,  94,  7 },   //!< SALUTE
     57    {  95, 111, 10 },   //!< FALLBACK
     58    { 112, 122,  7 },   //!< WAVE
     59    { 123, 134,  6 },   //!< POINTT
     60    { 135, 153, 10 },   //!< CROUCH_STAND
     61    { 154, 159,  7 },   //!< CROUCH_WALK
     62    { 160, 168, 10 },   //!< CROUCH_ATTACK
     63    { 196, 172,  7 },   //!< CROUCH_PAIN
     64    { 173, 177,  5 },   //!< CROUCH_DEATH
     65    { 178, 183,  7 },   //!< DEATH_FALLBACK
     66    { 184, 189,  7 },   //!< DEATH_FALLFORWARD
     67    { 190, 197,  7 },   //!< DEATH_FALLBACKSLOW
     68    { 198, 198,  5 },   //!< BOOM
    6569  };
    6670
     
    6872
    6973/********************************************************************************
    70  *   MD2Model                                                                   * ********************************************************************************/
     74 *   MD2Model                                                                   *
     75 ********************************************************************************/
    7176
    7277/*
    7378  \brief simple constructor initializing all variables
    7479*/
    75 MD2Model::MD2Model()
     80MD2Model::MD2Model(const char* modelFileName, const char* skinFileName)
    7681{
    7782  /* this creates the data container via ressource manager */
    78   this->data = new MD2Data();
     83  this->data = new MD2Data(modelFileName, skinFileName);
    7984  this->scaleFactor = this->data->scaleFactor;
    8085
     
    9095{
    9196
    92 }
    93 
    94 /*
    95   \brief load model
    96   \param name of the model file
    97   \return true if everything worked out smoothly
    98 */
    99 bool MD2Model::loadModel(const char* fileName)
    100 {
    101   return this->data->loadModel(fileName);
    102 }
    103 
    104 
    105 /*
    106   \brief load the skin as a material
    107   \param name of the texture file
    108   \return true if ok
    109 */
    110 bool MD2Model::loadSkin(const char* fileName)
    111 {
    112   return this->data->loadSkin(fileName);
    11397}
    11498
     
    116100/**
    117101   \brief initializes an array of vert with the current frame scaled vertices
     102   \param verticesList: the list of vertices to interpolate between
    118103
    119104   we won't use the pVertices array directly, since its much easier and we need
     
    139124/*
    140125  \brief sets the animation type
    141   \param animation type
     126  \param type: animation type
    142127
    143128  the animation types can be looked up in the animationType table
     
    163148/*
    164149  \brief sets the time in seconds passed since the last tick
    165   \param time in sec
     150  \param time: in sec
    166151*/
    167152void MD2Model::tick(float time)
     
    291276  \brief simple constructor
    292277*/
    293 MD2Data::MD2Data()
     278MD2Data::MD2Data(const char* modelFileName, const char* skinFileName)
    294279{
    295280  this->pVertices = NULL;
     
    302287 
    303288  this->scaleFactor = 1.0f;
     289
     290  this->loadModel(modelFileName);
     291  this->loadSkin(skinFileName);
    304292}
    305293
     
    321309/*
    322310  \brief this will load the whole model data (vertices, opengl command list, ...)
    323   \param name to the model file
     311  \param fileName to the model file
    324312  \return true if success
    325313*/
     
    391379/*
    392380  \brief loads the skin/material stuff
    393   \param name of the skin file
     381  \param fileName of the skin file
    394382  \return true if success
    395383*/
    396384bool MD2Data::loadSkin(const char* fileName)
    397385{
     386  if( fileName == NULL)
     387    {
     388      this->skinFileName = NULL;
     389      return false;
     390    }
     391
    398392  this->skinFileName = new char[strlen(fileName)+1];
    399393  strcpy(this->skinFileName, fileName);
  • orxonox/trunk/src/lib/graphics/importer/md2Model.h

    r4282 r4459  
    2525
    2626//! These are the needed defines for the max values when loading .MD2 files
    27 #define MD2_IDENT                       (('2'<<24) + ('P'<<16) + ('D'<<8) + 'I')
    28 #define MD2_VERSION                     8
    29 #define MD2_MAX_TRIANGLES               4096
    30 #define MD2_MAX_VERTICES                2048
    31 #define MD2_MAX_TEXCOORDS               2048
    32 #define MD2_MAX_FRAMES                  512
    33 #define MD2_MAX_SKINS                   32
    34 #define MD2_MAX_FRAMESIZE               (MD2_MAX_VERTICES * 4 + 128)
     27#define MD2_IDENT                       (('2'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md2 identifier tag in the bin file
     28#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
    3535
    36 #define NUM_VERTEX_NORMALS              162
     36#define NUM_VERTEX_NORMALS              162                                      //!<
    3737#define SHADEDOT_QUANT                  16
    3838
     
    6666
    6767
    68 
     68//! animation names enumeration
    6969typedef enum
    7070  {
     
    105105{
    106106 public:
    107   MD2Data();
     107  MD2Data(const char* modelFileName, const char* skinFileName);
    108108  virtual ~MD2Data();
    109109
     110 private:
    110111  bool loadModel(const char* fileName);
    111   bool loadSkin(const char* fileName);
     112  bool loadSkin(const char* fileName = NULL);
    112113
     114 public:
    113115  int numFrames;
    114116  int numVertices;
     
    133135
    134136public:
    135   MD2Model();
     137  MD2Model(const char* modelFileName, const char* skinFileName = NULL);
    136138  virtual ~MD2Model();
    137  
    138   bool loadModel(const char* filename);
    139   bool loadSkin(const char* filename);
    140  
     139   
    141140  void drawFrame(int frame);
    142141  void draw();
  • orxonox/trunk/src/world_entities/test_entity.cc

    r4397 r4459  
    2929
    3030  this->setClassID(CL_TEST_ENTITY, "TestEntity");
    31   this->md2Model = new MD2Model();
    32   this->md2Model->loadModel(ResourceManager::getFullName("models/tris.md2"));
    33   //  this->md2Model->loadSkin(ResourceManager::getFullName("models/tris.pcx"));
    34   this->md2Model->loadSkin("../data/models/tris.pcx");
    3531
    36 
     32  this->md2Model = new MD2Model("../data/models/tris.md2", "../data/models/tris.pcx");
    3733  this->md2Model->debug();
    3834}
Note: See TracChangeset for help on using the changeset viewer.