Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8546 in orxonox.OLD for branches/bsp_model/src/lib/graphics


Ignore:
Timestamp:
Jun 16, 2006, 6:03:42 PM (18 years ago)
Author:
patrick
Message:

bsp: the model animation informations get parsed correctly and loaded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.cc

    r8545 r8546  
    7373
    7474
    75     //this->dataStream.open(filename.c_str());
    7675    FILE* pFile;
    7776    char* cLine;
     
    8887
    8988    // parse file
    90 //     this->dataStream.getline(buffer, 1024, '\n');
    91 //     std::string line(buffer);
    9289    while( (read = getline(&cLine, &len, pFile)) != -1) { /*( !this->dataStream.eof()) {*/
    9390      std::string line(cLine);
    9491
    95       PRINTF(0)("size = %i, line = |%s|\n", read, line.c_str());
     92//       PRINTF(0)("size = %i, line = |%s|\n", read, line.c_str());
    9693
    9794      //ignore empty lines and comments
    98       if( line != "" && line.find("//") != 0) {
    99         // find the sex section
     95      if( line.length() > 2 && line.find("//") != 0) {
     96
     97        // find the gender section
    10098        if( inHeader && line.find("sex") == 0) {
    10199          //parse line: sex [m | f | ...]
     
    115113          PRINTF(0)("sex of the md3 model: %c\n", this->sex);
    116114        }
    117         else if (inHeader && line.find("headoffset") == 0) {
     115        else if( inHeader && line.find("headoffset") == 0) {
    118116          // parse line: headoffset X Y Z
    119117          std::vector<std::string> tokens;
     
    128126          PRINTF(0)("got head offset: %f, %f, %f\n", x, y, z);
    129127        }
    130         else if (inHeader && line.find("footsteps") == 0) {
     128        else if( inHeader && line.find("footsteps") == 0) {
    131129          //parse line: footsteps [normal | mech | ...]
    132130          std::vector<std::string> tokens;
     
    153151          this->loadAnimation(animation, line);
    154152
    155           animation->name = MD3Animation::animationList[i].animationName;
    156           animation->type = MD3Animation::animationList[i].animationType;
     153          if( i < 25)
     154          {
     155            animation->name = MD3Animation::animationList[i].animationName;
     156            animation->type = MD3Animation::animationList[i++].animationType;
     157          }
    157158
    158159          // workaround for strange numbering in animation.cfg: skip TORSO frames
     
    187188    Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
    188189
    189 
    190     while( !tokens.empty())
     190/*    while( !tokens.empty())
    191191    {
    192       PRINTF(0)("tokens: %s\n", tokens.back().c_str());
     192      PRINTF(5)("token: %s\n", tokens.back().c_str());
    193193      tokens.pop_back();
    194     }
    195   }
    196 // //parse line:
    197 //                 //first frame, num frames, looping frames, frames per second
    198 //   try {
    199 //     StringTokenizer st=new StringTokenizer(line, " \t\n\r\f/");
    200 //
    201 //     newAnimation.first=new Integer(st.nextToken()).intValue();
    202 //     newAnimation.num=new Integer(st.nextToken()).intValue();
    203 //     newAnimation.looping=new Integer(st.nextToken()).intValue();
    204 //     newAnimation.fps=new Integer(st.nextToken()).intValue();
    205 //   } catch (Exception e) {
    206 //     throw new IOException("corrupt animation line");
    207 //   }
     194    }*/
     195    anim->fps = atoi(tokens.back().c_str()); tokens.pop_back();
     196    anim->numLoopFrames = atoi(tokens.back().c_str()); tokens.pop_back();
     197    anim->numFrames = atoi(tokens.back().c_str()); tokens.pop_back();
     198    anim->first = atoi(tokens.back().c_str()); tokens.pop_back();
     199
     200    PRINTF(0)("Animation: first frame: %i, num frames: %i, num loops: %i, fps: %i\n", anim->first, anim->numFrames, anim->numLoopFrames, anim->fps);
     201  }
    208202
    209203
Note: See TracChangeset for help on using the changeset viewer.