Changeset 8597 in orxonox.OLD for branches/bsp_model/src/lib
- Timestamp:
- Jun 20, 2006, 1:22:54 AM (18 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer/md3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc
r8590 r8597 62 62 63 63 /** 64 * link a model at the specified tag position to this model. if the position is al lready64 * link a model at the specified tag position to this model. if the position is already 65 65 * occupied, the old submodel will be replaced 66 66 * … … 73 73 child->parentTagIndex = tagIndex; 74 74 } 75 76 77 78 /** 79 * Return the index of the tag with the given name for this model. 80 * 81 * This will return -1 if their is no such tag. 82 */ 83 int MD3Data::getTagIndexByName(std::string tagName) 84 { 85 int res = -1; 86 87 if( this->header->boneFrameNum > 0) { 88 MD3Tag** tags = this->boneFrames[0]->tags; 89 for( int i = 0; i < this->header->tagNum; i++) 90 if( tags[i]->name.find(tagName) == std::string::npos) 91 return i; 92 } 93 94 return res; 95 } 96 75 97 76 98 -
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h
r8566 r8597 77 77 78 78 void addLinkedModel(int tagIndex, MD3Data* child); 79 79 int getTagIndexByName(std::string name); 80 80 81 81 private: -
branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
r8592 r8597 102 102 if( lower != NULL) 103 103 { 104 PRINTF(0)("Loaded the %s model\n", nameLower.c_str()); 105 // this->md3Data->addLinkedModel(0, lower); 104 int tag = this->md3Data->getTagIndexByName("tag_lower"); 105 PRINTF(0)("Loaded the %s model on index %i\n", nameLower.c_str(), tag); 106 if( tag >= 0) 107 this->md3Data->addLinkedModel(tag, lower); 108 else 109 PRINTF(0)("Could not add %s\n", nameLower.c_str()); 106 110 } 107 111 … … 110 114 std::string nameHead(filename + "/head.md3"); 111 115 MD3Data* head = (MD3Data*)ResourceManager::getInstance()->load(nameHead, MD3, RP_GAME, nameLower, scaling); 112 if( lower != NULL) 113 { 114 PRINTF(0)("Loaded the %s model\n", nameHead.c_str()); 115 // this->md3Data->addLinkedModel(0, head); 116 } 117 118 119 120 121 // load torso 122 // name = FilenameUtils.getShortFilename(root.loadFilename); 123 // if( name.find("lower") == 0 && (tagIndex=root.getTagIndexByName("tag_torso")) != -1) { 124 // filename=searchForPath("upper" + FilenameUtils.getLODPostfix(name) + ".md3", false); 125 // root=attachModel(root, tagIndex, filename, getInputStreamForPath(filename)); 126 // } 127 128 // load head 129 // name=FilenameUtils.getShortFilename(root.loadFilename); 130 // if (name.toLowerCase().startsWith("upper") && (tagIndex=root.getTagIndexByName("tag_head")) != -1) { 131 // filename=searchForPath("head" + FilenameUtils.getLODPostfix(name) + ".md3", false); 132 // attachModel(root, tagIndex, filename, getInputStreamForPath(filename)); 133 // } 134 135 } 136 137 138 116 if( head != NULL) 117 { 118 int tag = this->md3Data->getTagIndexByName("tag_head"); 119 PRINTF(0)("Loaded the %s model on index %i\n", nameHead.c_str(), tag); 120 if( tag >= 0) 121 this->md3Data->addLinkedModel(tag, head); 122 else 123 PRINTF(0)("Could not add %s\n", nameHead.c_str()); 124 } 125 126 } 127 128 129 130 /** 131 * tick float 132 * @param time: time elapsed 133 */ 139 134 void MD3Model::tick(float time) 140 135 { … … 144 139 145 140 141 /** 142 * tick each data 143 */ 146 144 void MD3Model::tick(float time, MD3Data* data) 147 145 { … … 210 208 211 209 //build transformation array m from matrix, interpolate if necessary 212 float* m = new float[16];213 210 214 211 MD3Tag* currFrameTag = data->boneFrames[data->animationState.currentFrame]->tags[child->parentTagIndex]; … … 218 215 //we need to interpolate 219 216 MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex]; 220 m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i); 221 } 222 else { 223 //no interpolation needed, stay with last transformation 224 //OpenGL matrix is in column-major order 225 m[0] = currFrameTag->matrix[0][0]; 226 m[1] = currFrameTag->matrix[1][0]; 227 m[2] = currFrameTag->matrix[2][0]; 228 m[3] = 0.0f; 229 m[4] = currFrameTag->matrix[0][1]; 230 m[5] = currFrameTag->matrix[1][1]; 231 m[6] = currFrameTag->matrix[2][1]; 232 m[7] = 0.0f; 233 m[8] = currFrameTag->matrix[0][2]; 234 m[9] = currFrameTag->matrix[1][2]; 235 m[10]= currFrameTag->matrix[2][2]; 236 m[11]= 0.0f; 237 m[12] = currFrameTag->position.x; 238 m[13] = currFrameTag->position.y; 239 m[14] = currFrameTag->position.z; 240 m[15] = 1.0f; 241 } 242 243 //switch to child coord system 244 glPushMatrix(); 245 glMultMatrixf(m); 246 247 // and draw child 248 this->tick(time, child); 249 250 glPopMatrix(); 251 i++; 217 this->tmpMatrix[i] = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i); 218 } 219 else 220 { 221 //no interpolation needed, stay with last transformation 222 //OpenGL matrix is in column-major order 223 this->tmpMatrix[i][0] = currFrameTag->matrix[0][0]; 224 this->tmpMatrix[i][1] = currFrameTag->matrix[1][0]; 225 this->tmpMatrix[i][2] = currFrameTag->matrix[2][0]; 226 this->tmpMatrix[i][3] = 0.0f; 227 this->tmpMatrix[i][4] = currFrameTag->matrix[0][1]; 228 this->tmpMatrix[i][5] = currFrameTag->matrix[1][1]; 229 this->tmpMatrix[i][6] = currFrameTag->matrix[2][1]; 230 this->tmpMatrix[i][7] = 0.0f; 231 this->tmpMatrix[i][8] = currFrameTag->matrix[0][2]; 232 this->tmpMatrix[i][9] = currFrameTag->matrix[1][2]; 233 this->tmpMatrix[i][10]= currFrameTag->matrix[2][2]; 234 this->tmpMatrix[i][11]= 0.0f; 235 this->tmpMatrix[i][12] = currFrameTag->position.x; 236 this->tmpMatrix[i][13] = currFrameTag->position.y; 237 this->tmpMatrix[i][14] = currFrameTag->position.z; 238 this->tmpMatrix[i][15] = 1.0f; 239 } 240 241 // switch to child coord system 242 243 // and tick child 244 this->tick(time, child); 245 246 i++; 247 it++; 252 248 } 253 249 } … … 327 323 MD3Data* child = it->second; 328 324 329 //build transformation array m from matrix, interpolate if necessary330 float* m = new float[16];331 332 MD3Tag* currFrameTag = data->boneFrames[data->animationState.currentFrame]->tags[child->parentTagIndex];333 334 if( data->animationState.interpolationFraction != 0.0 &&335 data->animationState.currentFrame != data->animationState.nextFrame) {336 //we need to interpolate337 m = this->tmpMatrix[i];338 }339 else {340 //no interpolation needed, stay with last transformation341 //OpenGL matrix is in column-major order342 m[0] = currFrameTag->matrix[0][0];343 m[1] = currFrameTag->matrix[1][0];344 m[2] = currFrameTag->matrix[2][0];345 m[3] = 0.0f;346 m[4] = currFrameTag->matrix[0][1];347 m[5] = currFrameTag->matrix[1][1];348 m[6] = currFrameTag->matrix[2][1];349 m[7] = 0.0f;350 m[8] = currFrameTag->matrix[0][2];351 m[9] = currFrameTag->matrix[1][2];352 m[10]= currFrameTag->matrix[2][2];353 m[11]= 0.0f;354 m[12] = currFrameTag->position.x;355 m[13] = currFrameTag->position.y;356 m[14] = currFrameTag->position.z;357 m[15] = 1.0f;358 }359 360 325 //switch to child coord system 361 326 glPushMatrix(); 362 glMultMatrixf( m);327 glMultMatrixf(this->tmpMatrix[i]); 363 328 364 329 // and draw child … … 367 332 glPopMatrix(); 368 333 i++; 334 it++; 369 335 } 370 336 } -
branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
r8591 r8597 61 61 bool bDrawNormals; //!< draw the normals 62 62 63 MD3AnimationCfg* config; //!< the config file parsed 64 63 65 MD3BoneFrame* tmpBoneFrame; //!< a temporary bone frame 64 66 sVec3D** tmpMesh; //!< a temporary mesh frame … … 66 68 float** tmpMatrix; //!< a temporary matrix 67 69 68 MD3AnimationCfg* config; //!< the config file parsed69 70 }; 70 71
Note: See TracChangeset
for help on using the changeset viewer.