Changeset 566
- Timestamp:
- 04/23/08 14:59:28 (9 months ago)
- Files:
-
- branches/morph-targets/libx42make/include/x42make-modelbuilder.h (modified) (5 diffs)
- branches/morph-targets/libx42make/modelbuilder-animation.cpp (modified) (1 diff)
- branches/morph-targets/libx42make/modelbuilder-influences.cpp (modified) (3 diffs)
- branches/morph-targets/libx42make/modelbuilder-skeleton.cpp (modified) (7 diffs)
- branches/morph-targets/libx42make/modelbuilder-write.cpp (modified) (7 diffs)
- branches/morph-targets/libx42make/modelbuilder.cpp (modified) (1 diff)
- branches/morph-targets/libx42pp/include/x42util.h (modified) (2 diffs)
- branches/morph-targets/x42info/main.cpp (modified) (1 diff)
- branches/morph-targets/x42maya/modelexporter-anim.cpp (copied) (copied from branches/morph-targets/x42maya/modelexporter-anim.cpp) (1 diff)
- branches/morph-targets/x42maya/modelexporter-gather.cpp (modified) (2 diffs)
- branches/morph-targets/x42maya/modelexporter-translator.cpp (moved) (moved from branches/morph-targets/x42maya/translator.cpp)
- branches/morph-targets/x42maya/modelexporter.cpp (modified) (1 diff)
- branches/morph-targets/x42maya/modelexporter.h (moved) (moved from branches/morph-targets/x42maya/translator.h) (2 diffs)
- branches/morph-targets/x42maya/x42maya.vcproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/include/x42make-modelbuilder.h
r559 r566 630 630 { 631 631 public: 632 std::vector< lod_ptr > lods;633 std::vector< bone_ptr > bones;634 std::vector< influence_ptr > influences;635 std::vector< tag_ptr > tags;636 637 632 std::vector< animation > animations; 638 633 std::vector< uint > pinned_frames; … … 666 661 uint frame_count() const { return _frame_count; } 667 662 //sets the frame range and clears all animation data 663 void clear_animation_data(); 668 664 void set_frame_range( uint frame_count, int base_frame = 0 ); 669 665 … … 729 725 model to_model( void ) const; 730 726 731 private: 727 size_t bone_count() const { return bones.size(); } 728 bone_ptr bone( size_t i ) { return bones[i]; } 729 const_bone_ptr bone( size_t i ) const { return bones[i]; } 730 731 size_t influence_count() const { return influences.size(); } 732 influence_ptr influence( size_t i ) { return influences[i]; } 733 const_influence_ptr influence( size_t i ) const { return influences[i]; } 734 735 size_t tag_count() const { return tags.size(); } 736 tag_ptr tag( size_t i ) { return tags[i]; } 737 const_tag_ptr tag( size_t i ) const { return tags[i]; } 738 739 size_t lod_count() const { return lods.size(); } 740 lod_ptr lod( size_t i ) { return lods[i]; } 741 const_lod_ptr lod( size_t i ) const { return lods[i]; } 742 743 private: 744 std::vector< lod_ptr > lods; 745 std::vector< bone_ptr > bones; 746 std::vector< influence_ptr > influences; 747 std::vector< tag_ptr > tags; 748 732 749 int _base_frame; 733 750 uint _frame_count; … … 739 756 void validate_bone_prop( const bone_ptr &bone ) const; 740 757 741 void validate_bone_parent( bone *bone, const bone_ptr &new_parent ) const;742 void validate_bone_anim_group( bone *bone, uint new_anim_group ) const;743 void notify_bone_parent( bone *bone );744 void notify_bone_anim_group( bone *bone );758 void validate_bone_parent( ::x42::make::bone *bone, const bone_ptr &new_parent ) const; 759 void validate_bone_anim_group( ::x42::make::bone *bone, uint new_anim_group ) const; 760 void notify_bone_parent( ::x42::make::bone *bone ); 761 void notify_bone_anim_group( ::x42::make::bone *bone ); 745 762 void validate_bones(); 746 763 void sort_bones(); 747 764 748 void validate_influence_bone( influence *influence, const bone_ptr &new_bone ) const;749 void notify_influence_bone( influence *influence );765 void validate_influence_bone( ::x42::make::influence *influence, const bone_ptr &new_bone ) const; 766 void notify_influence_bone( ::x42::make::influence *influence ); 750 767 void validate_influences(); 751 768 void erase_influence( const influence_ptr &influence ); 752 769 753 void validate_tag_bone( tag *tag, const bone_ptr &new_bone );754 void notify_tag_bone( tag *tag );770 void validate_tag_bone( ::x42::make::tag *tag, const bone_ptr &new_bone ); 771 void notify_tag_bone( ::x42::make::tag *tag ); 755 772 void validate_tags(); 756 773 … … 761 778 friend class influence; 762 779 friend class tag; 780 friend class _impl::topological_group_split_context; 781 friend class group_enumerator; 763 782 }; 764 783 branches/morph-targets/libx42make/modelbuilder-animation.cpp
r559 r566 525 525 class model_builder 526 526 */ 527 void model_builder::clear_animation_data() 528 { 529 std::vector< anim_track_elem< affine > > empty; 530 531 for( size_t i = 0; i < bones.size(); i++ ) 532 bones[i]->anim_tracks.set_world_mats( empty ); 533 } 534 535 void model_builder::set_frame_range( uint frame_count, int base_frame ) 536 { 537 //validate valid ranges 538 frame_count = checked_int_cast< u16 >( frame_count ); 539 base_frame = checked_int_cast< s16 >( base_frame ); 540 541 clear_animation_data(); 542 _base_frame = base_frame; 543 _frame_count = frame_count; 544 } 545 527 546 std::vector< uint > model_builder::get_critical_frames() const 528 547 { branches/morph-targets/libx42make/modelbuilder-influences.cpp
r559 r566 67 67 validate_influence_bone( null, bone ); 68 68 69 influence_ptr ret( new influence( this ) );69 influence_ptr ret( new ::x42::make::influence( this ) ); 70 70 71 71 ret->_bone = bone; … … 91 91 } 92 92 93 void model_builder::validate_influence_bone( influence * /* influence */, const bone_ptr &new_bone ) const93 void model_builder::validate_influence_bone( ::x42::make::influence * /* influence */, const bone_ptr &new_bone ) const 94 94 { 95 95 if( _influence_update_count ) … … 99 99 } 100 100 101 void model_builder::notify_influence_bone( influence * /* influence */ )101 void model_builder::notify_influence_bone( ::x42::make::influence * /* influence */ ) 102 102 { 103 103 } branches/morph-targets/libx42make/modelbuilder-skeleton.cpp
r559 r566 129 129 validate_bone_parent( null, parent ); 130 130 131 bone_ptr ret( new bone( this ) );131 bone_ptr ret( new ::x42::make::bone( this ) ); 132 132 133 133 ret->_index = bones.size(); … … 143 143 } 144 144 145 void model_builder::validate_bone_parent( bone *bone, const bone_ptr &new_parent ) const145 void model_builder::validate_bone_parent( ::x42::make::bone *bone, const bone_ptr &new_parent ) const 146 146 { 147 147 if( _bone_update_count ) … … 162 162 } 163 163 164 void model_builder::validate_bone_anim_group( bone *bone, uint new_anim_group ) const164 void model_builder::validate_bone_anim_group( ::x42::make::bone *bone, uint new_anim_group ) const 165 165 { 166 166 if( _bone_update_count ) … … 171 171 } 172 172 173 void model_builder::notify_bone_parent( bone * /* bone */ )173 void model_builder::notify_bone_parent( ::x42::make::bone * /* bone */ ) 174 174 { 175 175 sort_bones(); 176 176 } 177 void model_builder::notify_bone_anim_group( bone * /* bone */ )177 void model_builder::notify_bone_anim_group( ::x42::make::bone * /* bone */ ) 178 178 { 179 179 sort_bones(); … … 281 281 } 282 282 283 void model_builder::validate_tag_bone( tag * /* tag */, const bone_ptr &new_bone )283 void model_builder::validate_tag_bone( ::x42::make::tag * /* tag */, const bone_ptr &new_bone ) 284 284 { 285 285 if( _tag_update_count ) … … 289 289 } 290 290 291 void model_builder::notify_tag_bone( tag * /* tag */ )291 void model_builder::notify_tag_bone( ::x42::make::tag * /* tag */ ) 292 292 { 293 293 } … … 303 303 validate_tag_bone( null, bone ); 304 304 305 tag_ptr ret( new tag( this ) );305 tag_ptr ret( new ::x42::make::tag( this ) ); 306 306 307 307 ret->_bone = bone; branches/morph-targets/libx42make/modelbuilder-write.cpp
r559 r566 239 239 void model_data_builder::pack_bones( const model_builder &data ) 240 240 { 241 if( !data.bone s.size() )241 if( !data.bone_count() ) 242 242 return; 243 243 244 bones.resize( data.bone s.size() );245 boneGroups.resize( data.bone s.size() );244 bones.resize( data.bone_count() ); 245 boneGroups.resize( data.bone_count() ); 246 246 247 247 struct bone_trk … … 271 271 }; 272 272 273 std::vector< bone_trks > tracks( data.bone s.size() );273 std::vector< bone_trks > tracks( data.bone_count() ); 274 274 275 275 uint maxAnimGroup = 0; 276 for( size_t i = 0; i < data.bone s.size(); i++ )277 { 278 bone_ptr b = data.bones[i];276 for( size_t i = 0; i < data.bone_count(); i++ ) 277 { 278 bone_ptr b = boost::const_pointer_cast< bone >( data.bone( i ) ); 279 279 280 280 if( b->anim_group() > maxAnimGroup ) 281 maxAnimGroup = data.bone s[i]->anim_group();281 maxAnimGroup = data.bone( i )->anim_group(); 282 282 283 283 boneGroups[i] = (u8)b->anim_group(); … … 302 302 } 303 303 304 for( size_t i = 0; i < data.bone s.size(); i++ )305 { 306 const_bone_ptr in = data.bone s[i];304 for( size_t i = 0; i < data.bone_count(); i++ ) 305 { 306 const_bone_ptr in = data.bone( i ); 307 307 x42bone_t &out = bones[i]; 308 308 … … 409 409 void model_data_builder::pack_influences( const model_builder &data ) 410 410 { 411 influences.resize( data.influence s.size() );411 influences.resize( data.influence_count() ); 412 412 for( uint i = 0; i < influences.size(); i++ ) 413 413 { 414 const_influence_ptr in = data.influence s[i];414 const_influence_ptr in = data.influence( i ); 415 415 x42influence_t &out = influences[i]; 416 416 … … 422 422 void model_data_builder::pack_tags( const model_builder &data ) 423 423 { 424 tags.resize( data.tag s.size() );424 tags.resize( data.tag_count() ); 425 425 for( uint i = 0; i < tags.size(); i++ ) 426 426 { 427 const_tag_ptr in = data.tag s[i];427 const_tag_ptr in = data.tag( i ); 428 428 x42tag_t &out = tags[i]; 429 429 … … 451 451 }; 452 452 453 lods.resize( data.lod s.size() );453 lods.resize( data.lod_count() ); 454 454 for( size_t l = 0; l < lods.size(); l++ ) 455 455 { 456 const_lod_ptr inLod = data.lod s[l];456 const_lod_ptr inLod = data.lod( l ); 457 457 x42lodRange_t &outLod = lods[l]; 458 458 … … 571 571 for( size_t l = 0; l < lods.size(); l++ ) 572 572 { 573 const_lod_ptr lod = data.lod s[l];573 const_lod_ptr lod = data.lod( l ); 574 574 575 575 for( size_t i = 0; i < lod->groups.size(); i++ ) branches/morph-targets/libx42make/modelbuilder.cpp
r559 r566 92 92 } 93 93 94 lod_ptr ret( new lod( this, lod_number ) );94 lod_ptr ret( new ::x42::make::lod( this, lod_number ) ); 95 95 lods.insert( lods.begin() + i, ret ); 96 96 branches/morph-targets/libx42pp/include/x42util.h
r559 r566 29 29 { 30 30 31 #pragma once 31 #pragma warning( push ) 32 #pragma warning( disable : 4127 ) //constant conditional --by design 33 #pragma warning( disable : 4310 ) //truncation of constant value 32 34 33 35 class bad_int_cast … … 116 118 }; 117 119 118 #pragma warning( push )119 #pragma warning( disable : 4127 ) //constant conditional --by design120 121 120 template< typename O, typename I > 122 121 inline O checked_int_cast( const I &in ) branches/morph-targets/x42info/main.cpp
r559 r566 1 1 #include <x42pp.h> 2 #include <iostream> 2 3 3 4 int main( int argc, const char **argv ) 4 5 { 6 argc; 7 argv; 5 8 9 #define PRINT_SIZE( type ) printf( "%4i - %s\n", sizeof( type ), #type ) 10 11 PRINT_SIZE( s8 ); 12 PRINT_SIZE( u8 ); 13 PRINT_SIZE( s16 ); 14 PRINT_SIZE( u16 ); 15 PRINT_SIZE( u32 ); 16 PRINT_SIZE( x42NameIndex_t ); 17 PRINT_SIZE( x42Index_t ); 18 PRINT_SIZE( f32 ); 19 PRINT_SIZE( vec2_t ); 20 PRINT_SIZE( vec3_t ); 21 PRINT_SIZE( vec4_t ); 22 PRINT_SIZE( quat_t ); 23 PRINT_SIZE( affine_t ); 24 PRINT_SIZE( rgba_t ); 25 PRINT_SIZE( shpere_t ); 26 PRINT_SIZE( aabb_t ); 27 PRINT_SIZE( x42Header_ident_t ); 28 PRINT_SIZE( x42Header_v5_t ); 29 PRINT_SIZE( x42Header_v6_t ); 30 PRINT_SIZE( x42PackHeader_v5_t ); 31 PRINT_SIZE( x42PackHeader_v6_t ); 32 PRINT_SIZE( x42KeyStreamEntry_v5_t ); 33 PRINT_SIZE( x42Animation_v5_t ); 34 PRINT_SIZE( x42AnimGroup_v5_t ); 35 PRINT_SIZE( x42Bone_v5_t ); 36 PRINT_SIZE( x42Influence_v5_t ); 37 PRINT_SIZE( x42Tag_v5_t ); 38 PRINT_SIZE( x42Group_v5_t ); 39 PRINT_SIZE( x42LodRange_v5_t ); 40 PRINT_SIZE( x42MorphTarget_v6_t ); 41 42 return 0; 6 43 } branches/morph-targets/x42maya/modelexporter-anim.cpp
r558 r566 25 25 namespace x42 26 26 { 27 namespace file_export27 namespace exporters 28 28 { 29 29 namespace maya branches/morph-targets/x42maya/modelexporter-gather.cpp
r565 r566 25 25 namespace x42 26 26 { 27 namespace file_export27 namespace exporters 28 28 { 29 29 namespace maya … … 58 58 } 59 59 60 MObject node_obj = path_node( p ); 61 60 62 //see if we already have this bone in the list 61 for( size_t i = 0; i < model.bone 63 for( size_t i = 0; i < model.bone_count(); i++ ) 64 { 65 if( path_node( dag_tag::get_value( model.bone( i )->user_tag ) ) == node_obj ) 66 return model.bone( i ); 67 } 68 69 //this is a new bone, add it to the list 70 71 MFnDependencyNode node( node_obj, &stat ); 72 check_status( stat ); 73 74 MString name = node.name( &stat ); 75 check_status( stat ); 76 77 MPlug inherit_plug = node.findPlug( "inheritsTransform", true, &stat ); 78 check_status( stat ); 79 80 bool inherits_transform; 81 stat = inherit_plug.getValue( inherits_transform ); 82 check_status( stat ); 83 84 bone_ptr parent( 0 ); 85 if( inherits_transform ) 86 { 87 MDagPath pp( p ); 88 89 stat = pp.pop(); 90 switch( stat ) 91 { 92 case MS::kSuccess: 93 parent = import_bone( pp ); 94 break; 95 96 case MS::kInvalidParameter: 97 break; 98 99 default: 100 throw maya_error( stat ); 101 } 102 } 103 104 static const char *const anim_attrs[] = 105 { 106 "shear", 107 "rotatePivot", 108 "rotatePivotTranslate", 109 "scalePivot", 110 "scalePivotTranslate", 111 "scale", 112 "rotateAxis", 113 "translate", 114 "rotateQuaternion", 115 "rotateOrder", 116 "rotate", 117 }; 118 119 bool static_anim = true; 62 120 63 121 } branches/morph-targets/x42maya/modelexporter.cpp
r565 r566 268 268 269 269 if( group_split_factor != do_not_split ) 270 model.split_groups_by_weight_count( group_split_factor );271 model.split_large_groups( );272 model.merge_small_groups( 0.25F );270 model.split_groups_by_weight_count( group_split_factor, split_limits ); 271 model.split_large_groups( split_limits ); 272 model.merge_small_groups( 0.25F, split_limits ); 273 273 274 274 model.optimize_geometry( preferred_geometry_type ); branches/morph-targets/x42maya/modelexporter.h
r565 r566 31 31 { 32 32 33 class maya_error : public std::exception33 class maya_error : public make::error 34 34 { 35 35 private: … … 111 111 float group_split_factor; 112 112 make::geometry::optimize_type preferred_geometry_type; 113 make::group_split_limits split_limits; 113 114 114 115 bone_ptr import_bone( const MDagPath &path ); branches/morph-targets/x42maya/x42maya.vcproj
r565 r566 663 663 > 664 664 <File 665 RelativePath=".\modelexporter-anim.cpp" 666 > 667 </File> 668 <File 665 669 RelativePath=".\modelexporter-gather.cpp" 666 670 > 667 671 </File> 668 672 <File 673 RelativePath=".\modelexporter-translator.cpp" 674 > 675 </File> 676 <File 669 677 RelativePath=".\modelexporter.cpp" 670 678 > 671 679 </File> 672 680 <File 673 RelativePath=".\translator.cpp" 674 > 675 </File> 676 <File 677 RelativePath=".\translator.h" 681 RelativePath=".\modelexporter.h" 678 682 > 679 683 </File>
