Changeset 8532 in orxonox.OLD for branches/bsp_model/src/lib/graphics
- Timestamp:
- Jun 16, 2006, 3:10:18 PM (18 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/Makefile.am
r8490 r8532 34 34 md3/md3_model.cc \ 35 35 md3/md3_animation.cc \ 36 md3/md3_animation_cfg.cc \ 36 37 md3/md3_bone_frame.cc \ 37 38 md3/md3_mesh.cc \ … … 76 77 md3/md3_model.h \ 77 78 md3/md3_animation.h \ 79 md3/md3_animation_cfg.h \ 78 80 md3/md3_bone_frame.h \ 79 81 md3/md3_mesh.h \ -
branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.cc
r8526 r8532 17 17 #include "md3_animation_cfg.h" 18 18 19 19 #include "tokenizer.h" 20 21 #include "debug.h" 22 23 using namespace std; 20 24 21 25 namespace md3 … … 34 38 * @param line: the line to read from 35 39 */ 36 MD3AnimationCfg::MD3AnimationCfg(std::string line) 37 { 40 MD3AnimationCfg::MD3AnimationCfg(std::string filename) 41 { 42 this->dataStream.open(filename.c_str()); 43 44 if( !this->dataStream) { 45 PRINTF(1)("Error: file could not be opened: %s\n", filename.c_str()); 46 } 38 47 } 39 48 … … 44 53 MD3AnimationCfg::~MD3AnimationCfg() 45 54 {} 55 56 57 /** 58 * loads the configuration file 59 */ 60 void MD3AnimationCfg::loadConfig() 61 { 62 // BufferedReader bin=new BufferedReader(new InputStreamReader(in)); 63 64 int i = 0; //!< last read animation, animation order is hard coded! 65 int torsoOffset = -1; //!< torso offset 66 int firstTorsoFrame = -1; //!< first of the TORSO animation frames 67 bool inHeader = true; //!< are we still in the header of the .cfg file? 68 char buffer[1024]; //!< buffer to write stuff into 69 70 71 72 // parse file 73 this->dataStream.getline(buffer, 1024, '\n'); 74 std::string line(buffer); 75 PRINTF(0)("line = %s\n", line.c_str()); 76 while( !this->dataStream.eof()) { 77 78 //ignore empty lines and comments 79 if( line != "" && line.find("//") != 0) { 80 // find the sex section 81 if( inHeader && line.find("sex") == 0) { 82 //parse line: sex [m | f | ...] 83 // StringTokenizer st=new StringTokenizer(line, " \t\n\r\f/"); 84 std::vector<std::string> tokens; 85 Tokenizer::tokenize(line, tokens, " \t\n\r\f/"); 86 87 while( !tokens.empty()) 88 { 89 PRINTF(0)("tokens: %s\n", tokens.back()); 90 tokens.pop_back(); 91 } 92 return; 93 /* 94 st.nextToken(); //throw away first token 95 String sexStr=st.nextToken(); 96 if (sexStr.length()!=1) 97 //non-fatal error, don't thow exception 98 newAnimCfg.sex='?'; 99 else 100 newAnimCfg.sex=sexStr.charAt(0); 101 } 102 else if (IN_HEADER && line.startsWith("headoffset")) { 103 //parse line: headoffset X Y Z 104 StringTokenizer st=new StringTokenizer(line, " \t\n\r\f/"); 105 106 st.nextToken(); //throw away first token 107 108 newAnimCfg.headOffset= 109 new md3.util.Vec3(new Float(st.nextToken()).floatValue(), 110 new Float(st.nextToken()).floatValue(), 111 new Float(st.nextToken()).floatValue()); 112 } 113 else if (IN_HEADER && line.startsWith("footsteps")) { 114 //parse line: footsteps [normal | mech | ...] 115 StringTokenizer st=new StringTokenizer(line, " \t\n\r\f/"); 116 117 st.nextToken(); //throw away first token 118 newAnimCfg.footsteps=st.nextToken().trim(); 119 120 if (!(newAnimCfg.footsteps.toLowerCase().equals("default") || 121 newAnimCfg.footsteps.toLowerCase().equals("normal") || 122 newAnimCfg.footsteps.toLowerCase().equals("boot") || 123 newAnimCfg.footsteps.toLowerCase().equals("flesh") || 124 newAnimCfg.footsteps.toLowerCase().equals("mech") || 125 newAnimCfg.footsteps.toLowerCase().equals("energy") 126 )) 127 //don't throw an exception, non-fatal error 128 newAnimCfg.footsteps="illegal footsteps value (" + newAnimCfg.footsteps + ")"; 129 } 130 else { 131 //assume it's an animation line 132 IN_HEADER=false; //no longer in header 133 134 MD3Animation animation=MD3ModelFactory.getFactory().makeMD3Animation(line); 135 136 animation.name=animationNames[i]; 137 animation.type=animationTypes[i++]; 138 139 //workaround for strange numbering in animation.cfg: skip TORSO frames 140 //for LEGS animation lines... 141 if (animation.type==AnimationType.LEGS) { 142 //when first LEGS animation is found, calc # of TORSO frames 143 if (TORSO_OFFSET==-1) 144 TORSO_OFFSET=animation.first-firstTORSOFrame; 145 146 animation.first-=TORSO_OFFSET; 147 animation.offset=TORSO_OFFSET; 148 } 149 else if (animation.type==AnimationType.TORSO) 150 if (firstTORSOFrame==-1) 151 firstTORSOFrame=animation.first; 152 153 newAnimCfg.putAnimation(animation); 154 } 155 } 156 157 line=bin.readLine(); 158 } 159 catch (Exception e) { 160 throw new IOException(e.getMessage()); 161 }*/ 162 } 163 } 164 } 165 } 46 166 47 167 -
branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.h
r8526 r8532 13 13 #include <string> 14 14 #include <map> 15 16 #include <iostream> 17 #include <fstream> 18 15 19 16 20 … … 31 35 virtual ~MD3AnimationCfg(); 32 36 37 void loadConfig(); 33 38 34 39 std::string toString() { return std::string("Name: " + this->filename); } … … 42 47 std::string footsteps; //!< type of the footstep sounds associated with anumations (e.g. "mech", "default") 43 48 49 std::ifstream dataStream; //!< the data stream 50 44 51 std::map<std::string, MD3Animation*> animations; //!< mapping of animation names to MD3Animation objects. 45 52 };
Note: See TracChangeset
for help on using the changeset viewer.