Changeset 519

Show
Ignore:
Timestamp:
02/25/08 00:34:47 (11 months ago)
Author:
phill
Message:

o Model data file generator function.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/morph-targets/libx42make/helpers.h

    r516 r519  
    156156} 
    157157 
     158template< typename T, typename Cmp > 
     159size_t index_of( const std::vector< T > &v, const T &val, Cmp cmp ) 
     160{ 
     161        std::vector< T >::const_iterator pos = 
     162                std::upper_bound( v.begin(), v.end(), val, cmp ); 
     163 
     164        if( pos == v.begin() ) 
     165                throw std::exception(); 
     166 
     167        pos--; 
     168 
     169        const T &vp = *pos; 
     170 
     171        if( !cmp( vp, val ) && !cmp( val, vp ) ) 
     172                //neither is less, they are "equal" 
     173                throw std::exception(); 
     174 
     175        return pos - v.begin(); 
     176} 
     177 
    158178}; 
    159179}; 
  • branches/morph-targets/libx42make/include/x42make-modelbuilder.h

    r518 r519  
    5858namespace _impl 
    5959{ 
    60         void intrusive_ptr_add_ref( ref_obj *r ); 
    61         void intrusive_ptr_release( ref_obj *r ); 
     60        void intrusive_ptr_add_ref( const ref_obj *r ); 
     61        void intrusive_ptr_release( const ref_obj *r ); 
     62 
     63        class model_data_builder; 
    6264}; 
    6365 
     
    7375 
    7476private: 
    75         size_t _ref_count; 
     77        mutable size_t _ref_count; 
    7678         
    77         friend void _impl::intrusive_ptr_add_ref( ref_obj *r ); 
    78         friend void _impl::intrusive_ptr_release( ref_obj *r ); 
     79        friend void _impl::intrusive_ptr_add_ref( const ref_obj *r ); 
     80        friend void _impl::intrusive_ptr_release( const ref_obj *r ); 
    7981}; 
    8082 
     
    256258        friend class animation_tracks; 
    257259        friend class model_builder; 
     260        friend class _impl::model_data_builder; 
    258261}; 
    259262 
     
    434437        size_t index_count() const { return indices.size(); } 
    435438 
     439        size_t count_max_influences_per_vert() const; 
     440 
    436441        bool is_valid() const; 
    437442 
     
    465470class lod : public ref_obj 
    466471{ 
    467 public: 
    468         uint                                            lod_number; 
     472public:  
    469473        std::vector< group_ptr >        groups; 
     474 
     475        uint lod_number() const { return _lod_number; } 
    470476 
    471477        group_ptr create_group( const std::string &surface_name = std::string(), 
     
    473479 
    474480private: 
     481        uint                                            _lod_number; 
     482 
    475483        model_builder                           *owner; 
    476         lod( model_builder *owner ) : owner( owner ) { } 
     484        lod( model_builder *owner, uint lod_number ) 
     485                : owner( owner ), _lod_number( lod_number ) 
     486        { } 
    477487 
    478488        friend class model_builder; 
     
    490500        std::vector< animation >                animations; 
    491501        std::vector< uint >                             pinned_frames; 
     502 
     503        ::x42::geom::aabb                               bounding_box; 
     504        ::x42::geom::sphere                             bounding_sphere; 
    492505 
    493506        animation_tolerances                    loose_tolerances; 
     
    558571        void remove_unused_bones(); 
    559572 
     573        model to_model( void ) const; 
     574 
    560575private: 
    561576        int _base_frame; 
  • branches/morph-targets/libx42make/libx42make.vcproj

    r515 r519  
    677677                </File> 
    678678                <File 
     679                        RelativePath=".\modelbuilder-write.cpp" 
     680                        > 
     681                </File> 
     682                <File 
    679683                        RelativePath=".\modelbuilder.cpp" 
    680684                        > 
  • branches/morph-targets/libx42make/modelbuilder-geometry.cpp

    r518 r519  
    381381} 
    382382 
     383size_t geometry::count_max_influences_per_vert() const 
     384{ 
     385        size_t ret = 0; 
     386 
     387        for( size_t i = 0; i < weights.size(); i++ ) 
     388        { 
     389                ret = max( ret, weights[i].count() ); 
     390        } 
     391} 
     392 
    383393void geometry::bake_vertices( const std::vector< ::x42::math::affine > &inf_mats, const influence_ptr &rebind_inf ) 
    384394{ 
  • branches/morph-targets/libx42make/modelbuilder.cpp

    r512 r519  
    3535{ 
    3636 
    37 void intrusive_ptr_add_ref( ref_obj *r ) 
     37void intrusive_ptr_add_ref( const ref_obj *r ) 
    3838{ 
    3939        r->_ref_count++; 
    4040} 
    4141 
    42 void intrusive_ptr_release( ref_obj *r ) 
     42void intrusive_ptr_release( const ref_obj *r ) 
    4343{ 
    4444        if( !--r->_ref_count ) 
     
    7373        for( size_t i = 0; i < lods.size(); i++ ) 
    7474        { 
    75                 if( lods[i]->lod_number == lod_number ) 
     75                if( lods[i]->_lod_number == lod_number ) 
    7676                        return lods[i]; 
    7777        } 
     
    8585        for( i = 0; i < lods.size(); i++ ) 
    8686        { 
    87                 if( lods[i]->lod_number == lod_number ) 
     87                if( lods[i]->_lod_number == lod_number ) 
    8888                        return lods[i]; 
    8989 
    90                 if( lods[i]->lod_number > lod_number ) 
     90                if( lods[i]->_lod_number > lod_number ) 
    9191                        break; 
    9292        } 
    9393 
    94         lod_ptr ret( new lod( this ) ); 
    95  
    96         ret->lod_number = lod_number; 
    97  
     94        lod_ptr ret( new lod( this, lod_number ) ); 
    9895        lods.insert( lods.begin() + i, ret ); 
    9996 
  • branches/morph-targets/libx42make/modeldata-write.cpp

    r506 r519  
    270270        { 
    271271                animGroups[i].name = _sb.intern_string( std::string( "" ) ); 
    272                 animGroups[i].beginBone = (u16)data.numFrames
     272                animGroups[i].beginBone = integer_traits< u16 >::max_val
    273273                animGroups[i].endBone = 0; 
    274274        }