Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8541 in orxonox.OLD


Ignore:
Timestamp:
Jun 16, 2006, 5:05:37 PM (18 years ago)
Author:
patrick
Message:

bsp: md3 config read almost finished

Location:
branches/bsp_model/src/lib/graphics/importer/md3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.h

    r8526 r8541  
    1111#include <string>
    1212
     13namespace md3
     14{
    1315
    1416typedef enum MD3AnimationType {
     
    4345    void init();
    4446
    45     std::string toString()
    46     {
    47       return std::string("Name: " + this->name);
    48     }
     47    std::string toString() { return std::string("Name: " + this->name); }
    4948
    5049
     
    6261};
    6362
    64 
     63}
    6564#endif /* _MD3_ANIMATION_H */
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.cc

    r8537 r8541  
    1717#include "md3_animation_cfg.h"
    1818
     19#include "md3_animation.h"
     20
    1921#include "tokenizer.h"
     22#include "helper_functions.h"
    2023
    2124#include "debug.h"
     
    2326#include <stdio.h>
    2427#include <stdlib.h>
     28
    2529
    2630using namespace std;
     
    6771    int      firstTorsoFrame = -1; //!< first of the TORSO animation frames
    6872    bool     inHeader = true;      //!< are we still in the header of the .cfg file?
    69     char     buffer[1024];         //!< buffer to write stuff into
    7073
    7174
     
    130133          Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
    131134
    132 //           newAnimCfg.footsteps=st.nextToken().trim();
    133 
     135          this->footsteps = tokens.back();
     136//           std::transform(this->footsteps.begin(), this->footsteps.end(), this->footsteps.begin(), std::tolower);
    134137
    135138           while( !tokens.empty())
     
    139142          }
    140143
    141 
    142 /*          if (!(newAnimCfg.footsteps.toLowerCase().equals("default") ||
    143                 newAnimCfg.footsteps.toLowerCase().equals("normal") ||
    144                 newAnimCfg.footsteps.toLowerCase().equals("boot") ||
    145                 newAnimCfg.footsteps.toLowerCase().equals("flesh") ||
    146                 newAnimCfg.footsteps.toLowerCase().equals("mech") ||
    147                 newAnimCfg.footsteps.toLowerCase().equals("energy")
    148                ))*/
    149             //don't throw an exception, non-fatal error
    150 //             newAnimCfg.footsteps="illegal footsteps value (" + newAnimCfg.footsteps + ")";
     144          //check if value is ok
     145          if (!(nocaseCmp(this->footsteps, "default")   ||
     146                nocaseCmp(this->footsteps, "normal")    ||
     147                nocaseCmp(this->footsteps, "boot")      ||
     148                nocaseCmp(this->footsteps, "flesh")     ||
     149                nocaseCmp(this->footsteps, "mech")      ||
     150                nocaseCmp(this->footsteps, "energy")) ) {
     151            this->footsteps="illegal footsteps value (" + this->footsteps + ")";
     152          }
     153          PRINTF(0)("got footsteps: %s\n", this->footsteps.c_str());
     154        }
     155        else {
     156          // assume it's an animation line
     157          inHeader = false;
     158
     159          MD3Animation* animation = new MD3Animation(line);
     160
     161          animation->name = MD3Animation::animationList[i].animationName;
     162          animation->type = MD3Animation::animationList[i].animationType;
     163
     164          // workaround for strange numbering in animation.cfg: skip TORSO frames
     165          // for LEGS animation lines...
     166          if (animation->type == LEGS) {
     167                                                //when first LEGS animation is found, calc # of TORSO frames
     168            if( torsoOffset == -1)
     169              torsoOffset = animation->first - firstTorsoFrame;
     170
     171            animation->first -= torsoOffset;
     172            animation->offset = torsoOffset;
     173          }
     174          else if (animation->type == TORSO)
     175            if( firstTorsoFrame == -1)
     176              firstTorsoFrame = animation->first;
     177
     178
     179          //newAnimCfg.putAnimation(animation);
    151180        }
    152181      }
     182
     183
    153184    }
    154     /*
    155         else {
    156                                         //assume it's an animation line
    157           IN_HEADER=false; //no longer in header
    158 
    159           MD3Animation animation=MD3ModelFactory.getFactory().makeMD3Animation(line);
    160 
    161           animation.name=animationNames[i];
    162           animation.type=animationTypes[i++];
    163 
    164                                         //workaround for strange numbering in animation.cfg: skip TORSO frames
    165                                         //for LEGS animation lines...
    166           if (animation.type==AnimationType.LEGS) {
    167                                                 //when first LEGS animation is found, calc # of TORSO frames
    168             if (TORSO_OFFSET==-1)
    169               TORSO_OFFSET=animation.first-firstTORSOFrame;
    170 
    171             animation.first-=TORSO_OFFSET;
    172             animation.offset=TORSO_OFFSET;
    173           }
    174           else if (animation.type==AnimationType.TORSO)
    175             if (firstTORSOFrame==-1)
    176               firstTORSOFrame=animation.first;
    177 
    178           newAnimCfg.putAnimation(animation);
    179         }
    180       }
    181 
    182       line=bin.readLine();
    183     }
    184     catch (Exception e) {
    185       throw new IOException(e.getMessage());
    186     }*/
    187 
    188   }
    189 
    190 
    191 
    192   /**
    193   * <p>Look up the animation data for the animation with the specified name.
     185
     186  }
     187
     188
     189
     190  /**
     191  * Look up the animation data for the animation with the specified name.
    194192  *
    195193  * @param name Name of the animation.
    196194  * @return The animation data associated with the name or null if no data was found.
    197195  */
    198   MD3Animation* getAnimation(std::string name)
     196  MD3Animation* MD3AnimationCfg::getAnimation(std::string name)
    199197  {
    200198//     return (MD3Animation)animations.get(name);
    201199  }
     200
     201
     202  /**
     203   * Add the specified animation to the list of known animations.
     204   */
     205   void MD3AnimationCfg::putAnimation(MD3Animation* anim)
     206   {
     207//        animations.put(anim.name, anim);
     208   }
     209
    202210
    203211}
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.h

    r8533 r8541  
    3737      void loadConfig(std::string filename);
    3838
     39      MD3Animation* getAnimation(std::string name);
     40      void putAnimation(MD3Animation* animation);
     41
    3942      std::string toString() { return std::string("Name: " + this->filename); }
    4043
Note: See TracChangeset for help on using the changeset viewer.