Changeset 593
- Timestamp:
- 07/03/08 17:12:32 (5 months ago)
- Files:
-
- branches/morph-targets/libx42/anim-skin.c (modified) (3 diffs)
- branches/morph-targets/libx42/anim.c (modified) (1 diff)
- branches/morph-targets/libx42/include/x42.h (modified) (3 diffs)
- branches/morph-targets/libx42/local.h (modified) (1 diff)
- branches/morph-targets/libx42/platform/x86-64/anim-skin.c (modified) (3 diffs)
- branches/morph-targets/libx42/pose.c (modified) (3 diffs)
- branches/morph-targets/libx42/write.c (modified) (1 diff)
- branches/morph-targets/x42maya/modelexporter-gather.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42/anim-skin.c
r500 r593 191 191 const x42data_t *x42, uint groupNum, const affine_t *boneMats ) 192 192 { 193 uint i ;193 uint i, maxInfs; 194 194 const x42group_t *grp; 195 195 affine_t infs[X42_MAX_INFLUENCES_PER_BATCH_V5]; … … 206 206 affine_cpy( infs + i, &inf->meshToBone ); 207 207 } 208 209 maxInfs = grp->maxVertInfluences > 0 ? grp->maxVertInfluences : 1; 208 210 209 211 if( oTan || oBin || !x42->vertNorm ) … … 223 225 oTan = &nullStream; 224 226 225 skin_verts_pntb( infs, grp->numInfluences, grp->maxVertInfluences,227 skin_verts_pntb( infs, grp->numInfluences, maxInfs, 226 228 iPos, x42->vertPos + grp->firstVert, iTan, grp->numVerts, oPos, oNorm, oTan, oBin ); 227 229 } 228 230 else if( oNorm ) 229 231 { 230 skin_verts_pn( infs, grp->numInfluences, grp->maxVertInfluences,232 skin_verts_pn( infs, grp->numInfluences, maxInfs, 231 233 iPos, x42->vertPos + grp->firstVert, iNorm, grp->numVerts, oPos, oNorm ); 232 234 } 233 235 else 234 236 { 235 skin_verts_p( infs, grp->numInfluences, grp->maxVertInfluences,237 skin_verts_p( infs, grp->numInfluences, maxInfs, 236 238 iPos, x42->vertPos + grp->firstVert, grp->numVerts, oPos ); 237 239 } branches/morph-targets/libx42/anim.c
r501 r593 127 127 grp = x42->groups + groupNum; 128 128 129 copy_verts = !boneMats || grp->maxVertInfluences == 0;129 copy_verts = !boneMats || (grp->maxVertInfluences == 0 && (x42->header.runFlags & X42_RF_ROOT_MATRIX_BAKED)); 130 130 applied_opts = opts ? x42_ApplyOpts( opts ) : false; 131 131 branches/morph-targets/libx42/include/x42.h
r563 r593 132 132 x42tag_t *tags; //may be null 133 133 134 affine_t rootMatrix; //usually identity, X42_RF_ROOT_MATRIX will be set otherwise 135 134 136 /* 135 137 Geometry data. … … 341 343 X42_EXPORT x42data_t* X42_CALL x42_LoadDataFromStream( void *out_buffer, const x42header_t *h, uint persist_flags, x42inStream_t *file_stream ); 342 344 345 /* 346 Apply a runtime root offset to the model. This stores a matrix in the x42data_t struct 347 to append onto the root of all animation heirarchies and (optionally) bakes the matrix 348 into the vertices of any static animation groups. 349 350 Leave bake_into_static_verts set to true unless you're going to manually skin the vertices 351 with their (identity) influence. 352 */ 353 X42_EXPORT bool X42_CALL x42_ApplyRootOffset( x42data_t *x42, const affine_t *rootMatrix, bool bake_into_static_verts ); 354 343 355 /*********************************** 344 356 … … 435 447 436 448 X42_EXPORT affine_t* X42_CALL x42_GetAnimBoneMatrices( void *out_buffer, const x42data_t *x42, 437 const x42animLerp_t *lerp, const affine_t *rootMatrix,x42opts_t *opts );449 const x42animLerp_t *lerp, x42opts_t *opts ); 438 450 X42_EXPORT affine_t* X42_CALL x42_GetAnimTagMatrices( void *out_buffer, const x42data_t *x42, 439 451 const affine_t *boneMats, x42opts_t *opts ); branches/morph-targets/libx42/local.h
r560 r593 43 43 44 44 #define X42_RF_LOAD_SWAPPED 0x0001 45 #define X42_RF_ROOT_MATRIX 0x1000 46 #define X42_RF_ROOT_MATRIX_BAKED 0x2000 45 47 46 48 #ifdef __cplusplus branches/morph-targets/libx42/platform/x86-64/anim-skin.c
r500 r593 759 759 const x42data_t *x42, uint groupNum, const affine_t *boneMats, x42opts_t *opts ) 760 760 { 761 uint i ;761 uint i, maxInfs; 762 762 x42group_t *g; 763 763 … … 784 784 g = x42->groups + groupNum; 785 785 786 if( !g->maxVertInfluences ) 787 //bother with a fast path for this? 788 return false; 786 maxInfs = g->maxVertInfluences > 0 ? g->maxVertInfluences : 1; 789 787 790 788 for( i = 0; i < g->numInfluences; i++ ) … … 826 824 oNorm = &nullStream; 827 825 828 opt_skin_verts_pntb( infs, g->maxVertInfluences, iPos, x42->vertPos + g->firstVert,826 opt_skin_verts_pntb( infs, maxInfs, iPos, x42->vertPos + g->firstVert, 829 827 iTan, g->numVerts, oPos, oNorm, oTan, oBin ); 830 828 } 831 829 else if( oNorm ) 832 830 { 833 switch( g->maxVertInfluences )831 switch( maxInfs ) 834 832 { 835 833 case 1: branches/morph-targets/libx42/pose.c
r563 r593 504 504 */ 505 505 506 X42_EXPORT bool X42_CALL x42_ApplyRootOffset( x42data_t *x42, const affine_t *rootMatrix, bool bake_into_static_verts ) 507 { 508 #ifndef LIBX42_NO_PARAM_VALIDATION 509 demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" ); 510 demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" ); 511 demand_rf( rootMatrix != NULL, X42_ERR_BADPTR, "rootMatrix is NULL" ); 512 513 if( x42->header.runFlags & X42_RF_ROOT_MATRIX ) 514 { 515 demand_rf( bake_into_static_verts ? true : false == 516 (x42->header.runFlags & X42_RF_ROOT_MATRIX_BAKED) ? true : false , X42_ERR_INVALIDOP, "cannot mix baked/unbaked root offsets" ); 517 } 518 #endif 519 520 //from the left 521 if( (x42->header.runFlags & X42_RF_ROOT_MATRIX) == 0 ) 522 { 523 affine_cpy( &x42->rootMatrix, rootMatrix ); 524 x42->header.runFlags |= X42_RF_ROOT_MATRIX; 525 } 526 else 527 { 528 affine_mul( &x42->rootMatrix, rootMatrix, &x42->rootMatrix ); 529 } 530 531 if( bake_into_static_verts ) 532 { 533 uint g, v, lv; 534 535 x42->header.runFlags |= X42_RF_ROOT_MATRIX_BAKED; 536 537 for( g = 0; g < x42->header.numVerts; g++ ) 538 { 539 const x42group_t *grp = x42->groups + g; 540 541 if( grp->maxVertInfluences ) 542 //not static 543 continue; 544 545 lv = grp->firstVert + grp->numVerts; 546 for( v = grp->firstVert; v < lv; v++ ) 547 affine_mul_pos( x42->vertPos[v].pos, rootMatrix, x42->vertPos[v].pos ); 548 549 if( x42->vertNorm ) 550 { 551 for( v = grp->firstVert; v < lv; v++ ) 552 affine_mul_vec( x42->vertNorm[v].norm, rootMatrix, x42->vertNorm[v].norm ); 553 } 554 555 if( x42->vertTan ) 556 { 557 for( v = grp->firstVert; v < lv; v++ ) 558 { 559 affine_mul_vec( x42->vertTan[v].tan, rootMatrix, x42->vertTan[v].tan ); 560 affine_mul_vec( x42->vertTan[v].bit, rootMatrix, x42->vertTan[v].bit ); 561 } 562 } 563 } 564 565 for( g = 0; g < x42->header.numMorphTargets; g++ ) 566 { 567 const x42morphTarget_t *tar = x42->morphTargets + g; 568 569 if( x42->groups[tar->targetGroup].maxVertInfluences ) 570 //not static 571 continue; 572 573 lv = tar->numDeltas; 574 575 for( v = tar->firstDelta; v < lv; v++ ) 576 affine_mul_vec( x42->morphPos[v], rootMatrix, x42->morphPos[v] ); 577 578 if( x42->morphNorm ) 579 { 580 for( v = tar->firstDelta; v < lv; v++ ) 581 affine_mul_vec( x42->morphNorm[v].norm, rootMatrix, x42->morphNorm[v].norm ); 582 } 583 584 if( x42->morphTan ) 585 { 586 for( v = tar->firstDelta; v < lv; v++ ) 587 { 588 affine_mul_vec( x42->morphTan[v].tan, rootMatrix, x42->morphTan[v].tan ); 589 affine_mul_vec( x42->morphTan[v].bit, rootMatrix, x42->morphTan[v].bit ); 590 } 591 } 592 } 593 } 594 595 return true; 596 } 597 506 598 X42_EXPORT size_t X42_CALL x42_GetAnimBoneMatricesSize( const x42data_t *x42 ) 507 599 { … … 515 607 516 608 X42_EXPORT affine_t* X42_CALL x42_GetAnimBoneMatrices( void *out_buffer, const x42data_t *x42, 517 const x42animLerp_t *lerp, const affine_t *rootMatrix,x42opts_t *opts )609 const x42animLerp_t *lerp, x42opts_t *opts ) 518 610 { 519 611 uint i; … … 583 675 if( b->parentIdx != X42_MODEL_BONE ) 584 676 affine_mul( ret + i, ret + b->parentIdx, ret + i ); 585 else if( rootMatrix)586 affine_mul( ret + i, rootMatrix, ret + i );677 else if( x42->header.runFlags & X42_RF_ROOT_MATRIX ) 678 affine_mul( ret + i, &x42->rootMatrix, ret + i ); 587 679 } 588 680 branches/morph-targets/libx42/write.c
r502 r593 218 218 get_stream_bounds( bounds, 3, (float*)x42->scaleValues, h->numScaleValues, sizeof( vec3_t ) ); 219 219 220 pack->animScalePack[0] = min ( bounds[0][0], bounds[1][0] );221 pack->animScalePack[1] = max ( bounds[0][1], bounds[1][1] );220 pack->animScalePack[0] = min3( bounds[0][0], bounds[1][0], bounds[2][0] ); 221 pack->animScalePack[1] = max3( bounds[0][1], bounds[1][1], bounds[2][1] ); 222 222 223 223 get_stream_bounds( pack->vertPosPack, 3, (float*)&x42->vertPos[0].pos, h->numVerts, sizeof( x42vertAnim_t ) ); branches/morph-targets/x42maya/modelexporter-gather.cpp
r568 r593 359 359 } 360 360 361 std::vector< m esh_partmodel_exporter::import_mesh_geometry( MObject &mesh_obj )361 std::vector< model_exporter::mesh_part > model_exporter::import_mesh_geometry( MObject &mesh_obj ) 362 362 { 363 363 MStatus stat;
