Changeset 566

Show
Ignore:
Timestamp:
04/23/08 14:59:28 (9 months ago)
Author:
phill
Message:

o WIP.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/morph-targets/libx42make/include/x42make-modelbuilder.h

    r559 r566  
    630630{ 
    631631public: 
    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  
    637632        std::vector< animation >                animations; 
    638633        std::vector< uint >                             pinned_frames; 
     
    666661        uint frame_count() const { return _frame_count; } 
    667662        //sets the frame range and clears all animation data 
     663        void clear_animation_data(); 
    668664        void set_frame_range( uint frame_count, int base_frame = 0 ); 
    669665 
     
    729725        model to_model( void ) const; 
    730726 
    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 
     743private: 
     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 
    732749        int _base_frame; 
    733750        uint _frame_count; 
     
    739756        void validate_bone_prop( const bone_ptr &bone ) const; 
    740757 
    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 ); 
    745762        void validate_bones(); 
    746763        void sort_bones(); 
    747764 
    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 ); 
    750767        void validate_influences(); 
    751768        void erase_influence( const influence_ptr &influence ); 
    752769 
    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 ); 
    755772        void validate_tags(); 
    756773 
     
    761778        friend class influence; 
    762779        friend class tag; 
     780        friend class _impl::topological_group_split_context; 
     781        friend class group_enumerator; 
    763782}; 
    764783 
  • branches/morph-targets/libx42make/modelbuilder-animation.cpp

    r559 r566  
    525525        class model_builder 
    526526*/ 
     527void 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 
     535void 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 
    527546std::vector< uint > model_builder::get_critical_frames() const 
    528547{ 
  • branches/morph-targets/libx42make/modelbuilder-influences.cpp

    r559 r566  
    6767        validate_influence_bone( null, bone ); 
    6868 
    69         influence_ptr ret( new influence( this ) ); 
     69        influence_ptr ret( new ::x42::make::influence( this ) ); 
    7070 
    7171        ret->_bone = bone; 
     
    9191} 
    9292 
    93 void model_builder::validate_influence_bone( influence * /* influence */, const bone_ptr &new_bone ) const 
     93void model_builder::validate_influence_bone( ::x42::make::influence * /* influence */, const bone_ptr &new_bone ) const 
    9494{ 
    9595        if( _influence_update_count ) 
     
    9999} 
    100100 
    101 void model_builder::notify_influence_bone( influence * /* influence */ ) 
     101void model_builder::notify_influence_bone( ::x42::make::influence * /* influence */ ) 
    102102{ 
    103103} 
  • branches/morph-targets/libx42make/modelbuilder-skeleton.cpp

    r559 r566  
    129129        validate_bone_parent( null, parent ); 
    130130 
    131         bone_ptr ret( new bone( this ) ); 
     131        bone_ptr ret( new ::x42::make::bone( this ) ); 
    132132 
    133133        ret->_index = bones.size(); 
     
    143143} 
    144144 
    145 void model_builder::validate_bone_parent( bone *bone, const bone_ptr &new_parent ) const 
     145void model_builder::validate_bone_parent( ::x42::make::bone *bone, const bone_ptr &new_parent ) const 
    146146{ 
    147147        if( _bone_update_count ) 
     
    162162} 
    163163 
    164 void model_builder::validate_bone_anim_group( bone *bone, uint new_anim_group ) const 
     164void model_builder::validate_bone_anim_group( ::x42::make::bone *bone, uint new_anim_group ) const 
    165165{ 
    166166        if( _bone_update_count ) 
     
    171171} 
    172172 
    173 void model_builder::notify_bone_parent( bone * /* bone */ ) 
     173void model_builder::notify_bone_parent( ::x42::make::bone * /* bone */ ) 
    174174{ 
    175175        sort_bones(); 
    176176} 
    177 void model_builder::notify_bone_anim_group( bone * /* bone */ ) 
     177void model_builder::notify_bone_anim_group( ::x42::make::bone * /* bone */ ) 
    178178{ 
    179179        sort_bones(); 
     
    281281} 
    282282 
    283 void model_builder::validate_tag_bone( tag * /* tag */, const bone_ptr &new_bone ) 
     283void model_builder::validate_tag_bone( ::x42::make::tag * /* tag */, const bone_ptr &new_bone ) 
    284284{ 
    285285        if( _tag_update_count ) 
     
    289289} 
    290290 
    291 void model_builder::notify_tag_bone( tag * /* tag */ ) 
     291void model_builder::notify_tag_bone( ::x42::make::tag * /* tag */ ) 
    292292{ 
    293293} 
     
    303303        validate_tag_bone( null, bone ); 
    304304 
    305         tag_ptr ret( new tag( this ) ); 
     305        tag_ptr ret( new ::x42::make::tag( this ) ); 
    306306 
    307307        ret->_bone = bone; 
  • branches/morph-targets/libx42make/modelbuilder-write.cpp

    r559 r566  
    239239void model_data_builder::pack_bones( const model_builder &data ) 
    240240{ 
    241         if( !data.bones.size() ) 
     241        if( !data.bone_count() ) 
    242242                return; 
    243243 
    244         bones.resize( data.bones.size() ); 
    245         boneGroups.resize( data.bones.size() ); 
     244        bones.resize( data.bone_count() ); 
     245        boneGroups.resize( data.bone_count() ); 
    246246 
    247247        struct bone_trk 
     
    271271        }; 
    272272 
    273         std::vector< bone_trks > tracks( data.bones.size() ); 
     273        std::vector< bone_trks > tracks( data.bone_count() ); 
    274274 
    275275        uint maxAnimGroup = 0; 
    276         for( size_t i = 0; i < data.bones.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 ) )
    279279 
    280280                if( b->anim_group() > maxAnimGroup ) 
    281                         maxAnimGroup = data.bones[i]->anim_group(); 
     281                        maxAnimGroup = data.bone( i )->anim_group(); 
    282282 
    283283                boneGroups[i] = (u8)b->anim_group(); 
     
    302302        } 
    303303 
    304         for( size_t i = 0; i < data.bones.size(); i++ ) 
    305         { 
    306                 const_bone_ptr in = data.bones[i]
     304        for( size_t i = 0; i < data.bone_count(); i++ ) 
     305        { 
     306                const_bone_ptr in = data.bone( i )
    307307                x42bone_t &out = bones[i]; 
    308308                 
     
    409409void model_data_builder::pack_influences( const model_builder &data ) 
    410410{ 
    411         influences.resize( data.influences.size() ); 
     411        influences.resize( data.influence_count() ); 
    412412        for( uint i = 0; i < influences.size(); i++ ) 
    413413        { 
    414                 const_influence_ptr in = data.influences[i]
     414                const_influence_ptr in = data.influence( i )
    415415                x42influence_t &out = influences[i]; 
    416416 
     
    422422void model_data_builder::pack_tags( const model_builder &data ) 
    423423{ 
    424         tags.resize( data.tags.size() ); 
     424        tags.resize( data.tag_count() ); 
    425425        for( uint i = 0; i < tags.size(); i++ ) 
    426426        { 
    427                 const_tag_ptr in = data.tags[i]
     427                const_tag_ptr in = data.tag( i )
    428428                x42tag_t &out = tags[i]; 
    429429 
     
    451451        }; 
    452452 
    453         lods.resize( data.lods.size() ); 
     453        lods.resize( data.lod_count() ); 
    454454        for( size_t l = 0; l < lods.size(); l++ ) 
    455455        { 
    456                 const_lod_ptr inLod = data.lods[l]
     456                const_lod_ptr inLod = data.lod( l )
    457457                x42lodRange_t &outLod = lods[l]; 
    458458                                 
     
    571571        for( size_t l = 0; l < lods.size(); l++ ) 
    572572        { 
    573                 const_lod_ptr lod = data.lods[l]
     573                const_lod_ptr lod = data.lod( l )
    574574                 
    575575                for( size_t i = 0; i < lod->groups.size(); i++ ) 
  • branches/morph-targets/libx42make/modelbuilder.cpp

    r559 r566  
    9292        } 
    9393 
    94         lod_ptr ret( new lod( this, lod_number ) ); 
     94        lod_ptr ret( new ::x42::make::lod( this, lod_number ) ); 
    9595        lods.insert( lods.begin() + i, ret ); 
    9696 
  • branches/morph-targets/libx42pp/include/x42util.h

    r559 r566  
    2929{ 
    3030 
    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 
    3234 
    3335class bad_int_cast 
     
    116118}; 
    117119 
    118 #pragma warning( push ) 
    119 #pragma warning( disable : 4127 ) //constant conditional --by design 
    120  
    121120template< typename O, typename I > 
    122121inline O checked_int_cast( const I &in ) 
  • branches/morph-targets/x42info/main.cpp

    r559 r566  
    11#include <x42pp.h> 
     2#include <iostream> 
    23 
    34int main( int argc, const char **argv ) 
    45{ 
     6        argc; 
     7        argv; 
    58 
     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; 
    643} 
  • branches/morph-targets/x42maya/modelexporter-anim.cpp

    r558 r566  
    2525namespace x42 
    2626{ 
    27 namespace file_export 
     27namespace exporters 
    2828{ 
    2929namespace maya 
  • branches/morph-targets/x42maya/modelexporter-gather.cpp

    r565 r566  
    2525namespace x42 
    2626{ 
    27 namespace file_export 
     27namespace exporters 
    2828{ 
    2929namespace maya 
     
    5858        } 
    5959 
     60        MObject node_obj = path_node( p ); 
     61 
    6062        //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; 
    62120 
    63121} 
  • branches/morph-targets/x42maya/modelexporter.cpp

    r565 r566  
    268268 
    269269        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 ); 
    273273         
    274274        model.optimize_geometry( preferred_geometry_type ); 
  • branches/morph-targets/x42maya/modelexporter.h

    r565 r566  
    3131{ 
    3232 
    33 class maya_error : public std::exception 
     33class maya_error : public make::error 
    3434{ 
    3535private: 
     
    111111        float group_split_factor; 
    112112        make::geometry::optimize_type preferred_geometry_type; 
     113        make::group_split_limits split_limits; 
    113114 
    114115        bone_ptr import_bone( const MDagPath &path ); 
  • branches/morph-targets/x42maya/x42maya.vcproj

    r565 r566  
    663663                        > 
    664664                        <File 
     665                                RelativePath=".\modelexporter-anim.cpp" 
     666                                > 
     667                        </File> 
     668                        <File 
    665669                                RelativePath=".\modelexporter-gather.cpp" 
    666670                                > 
    667671                        </File> 
    668672                        <File 
     673                                RelativePath=".\modelexporter-translator.cpp" 
     674                                > 
     675                        </File> 
     676                        <File 
    669677                                RelativePath=".\modelexporter.cpp" 
    670678                                > 
    671679                        </File> 
    672680                        <File 
    673                                 RelativePath=".\translator.cpp" 
    674                                 > 
    675                         </File> 
    676                         <File 
    677                                 RelativePath=".\translator.h" 
     681                                RelativePath=".\modelexporter.h" 
    678682                                > 
    679683                        </File>