Changeset 515

Show
Ignore:
Timestamp:
02/22/08 12:55:54 (11 months ago)
Author:
phill
Message:

o Animation algorithms.

Files:

Legend:

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

    r514 r515  
    122122}; 
    123123 
    124 typedef anim_track_elem< ::x42::math::vec3 > vec3_track_elem; 
    125 typedef anim_track_elem< ::x42::math::quat > quat_track_elem; 
    126 typedef anim_track_elem< ::x42::math::affine > affine_track_elem; 
    127  
    128 class animation_tracks 
    129 { 
    130 public: 
    131         std::vector< vec3_track_elem >          position; 
    132         std::vector< quat_track_elem >          rotation; 
    133         std::vector< vec3_track_elem >          scale; 
    134  
    135         std::vector< affine_track_elem >        world_matrices; 
    136         std::vector< affine_track_elem >        local_matrices; 
    137 }; 
    138  
    139124struct animation_tolerances 
    140125{ 
     
    171156}; 
    172157 
     158typedef anim_track_elem< ::x42::math::vec3 > vec3_track_elem; 
     159typedef anim_track_elem< ::x42::math::quat > quat_track_elem; 
     160typedef anim_track_elem< ::x42::math::affine > affine_track_elem; 
     161 
     162class animation_tracks 
     163{ 
     164public: 
     165        std::vector< vec3_track_elem >          position; 
     166        std::vector< quat_track_elem >          rotation; 
     167        std::vector< vec3_track_elem >          scale; 
     168 
     169        std::vector< affine_track_elem >        world_matrices; 
     170 
     171        std::vector< affine_track_elem >        local_matrices; 
     172 
     173        void require_tracks(); 
     174        void require_local(); 
     175        void require_world(); 
     176 
     177        void clean_tracks(); 
     178 
     179private: 
     180        bone *owner; 
     181 
     182        animation_tracks() 
     183        { 
     184        } 
     185 
     186        void set_tracks( const std::vector< vec3_track_elem > &pos, 
     187                const std::vector< quat_track_elem > &rot, 
     188                const std::vector< vec3_track_elem > &scale ); 
     189        void set_world_mats( const std::vector< affine_track_elem > &world_mats ); 
     190        void set_local_mats( const std::vector< affine_track_elem > &local_mats ); 
     191 
     192        void make_tracks_from_local(); 
     193        void make_local_from_tracks(); 
     194        void make_local_from_world(); 
     195        void make_world_from_local(); 
     196 
     197        friend class bone; 
     198        friend class model_builder; 
     199}; 
     200 
    173201class bone : public ref_obj 
    174202{ 
     
    181209        animation_tolerances    tight_tolerances; 
    182210 
     211        bool                                    static_bone_hint; 
     212 
    183213        bone_ptr                                parent() const { return _parent; } 
    184214        void                                    parent( const bone_ptr &new_parent ); 
     
    195225        uint                                    _anim_group; 
    196226        bone_ptr                                _parent; 
    197          
     227 
    198228        float                                   extent;                         //computed value 
    199229        animation_tracks                anim_tracks; 
     
    202232                : owner( owner ), _anim_group( 0 ), extent( 0 ), 
    203233                loose_tolerances( animation_tolerances::inherit_defaults() ), 
    204                 tight_tolerances( animation_tolerances::inherit_defaults() ) 
    205         { 
    206         } 
    207  
     234                tight_tolerances( animation_tolerances::inherit_defaults() ), 
     235                static_bone_hint( false ) 
     236        { 
     237                anim_tracks.owner = this; 
     238        } 
     239 
     240        friend class animation_tracks; 
    208241        friend class model_builder; 
    209242}; 
     
    426459        std::vector< tag_ptr >                  tags; 
    427460 
     461        std::vector< animation >                animations; 
     462        std::vector< uint >                             pinned_frames; 
     463 
    428464        animation_tolerances                    loose_tolerances; 
    429465        animation_tolerances                    tight_tolerances; 
     
    432468                : loose_tolerances( animation_tolerances::loose_defaults() ), 
    433469                tight_tolerances( animation_tolerances::tight_defaults() ), 
    434                 _bone_update_count( 0 ), _influence_update_count( 0 ), _tag_update_count( 0 ) 
     470                _bone_update_count( 0 ), _influence_update_count( 0 ), _tag_update_count( 0 ), 
     471                _base_frame( 0 ), _frame_count( 0 ) 
    435472        { 
    436473        } 
     
    444481 
    445482        void optimize_geometry( geometry::optimize_type opt_type = geometry::optimize_type::match_current ); 
     483 
     484        //all anim_track_elem frame values are relative to this value 
     485        int base_frame() const { return _base_frame; } 
     486        uint frame_count() const { return _frame_count; } 
     487        //sets the frame range and clears all animation data 
     488        void set_frame_range( uint frame_count, int base_frame = 0 ); 
    446489 
    447490        void begin_bone_update(); //suspends bone validation and sorting 
     
    477520 
    478521private: 
     522        int _base_frame; 
     523        uint _frame_count; 
     524 
    479525        int _bone_update_count; 
    480526        int _influence_update_count; 
     
    499545        void validate_tags(); 
    500546 
     547        std::vector< uint > get_critical_frames() const; 
     548 
    501549        friend class bone; 
     550        friend class animation_tracks; 
    502551        friend class influence; 
    503552        friend class tag; 
  • branches/morph-targets/libx42make/include/x42make.h

    r509 r515  
    3333#include "x42make-modeldata.h" 
    3434#include "x42make-modelbuilder.h" 
    35 #include "x42make-helpers.h" 
    3635 
    3736#endif 
  • branches/morph-targets/libx42make/libx42make.vcproj

    r512 r515  
    492492                        > 
    493493                        <File 
    494                                 RelativePath=".\include\x42make-helpers.h" 
    495                                 > 
    496                         </File> 
    497                         <File 
    498494                                RelativePath=".\include\x42make-modelbuilder.h" 
    499495                                > 
     
    585581                </Filter> 
    586582                <File 
     583                        RelativePath=".\helpers.h" 
     584                        > 
     585                </File> 
     586                <File 
    587587                        RelativePath=".\local.h" 
    588588                        > 
     
    655655                                /> 
    656656                        </FileConfiguration> 
     657                </File> 
     658                <File 
     659                        RelativePath=".\modelbuilder-animation.cpp" 
     660                        > 
    657661                </File> 
    658662                <File 
  • branches/morph-targets/libx42make/local.h

    r511 r515  
    4747 
    4848#include "batcher.h" 
     49#include "helpers.h" 
    4950 
    5051#define null NULL