Ignore:
Timestamp:
07/23/14 20:36:44 (11 years ago)
Author:
epyon
Message:
  • merged md5 animation loader into md5_loader
  • all animation now handled through the node system
  • much cleanups
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gfx/skeletal_mesh.cc

    r288 r289  
    1818        m_pntdata.assign( (const md5_vtx_pnt*)pnt_chan->data, pnt_chan->count );
    1919        m_bone_offset.resize( bones->get_count() );
     20        m_transform.resize( bones->get_count() );
     21
    2022        for ( uint32 i = 0; i < bones->get_count(); ++i )
    2123        {
     
    3234        {
    3335                skeletal_animation_entry * anim = (skeletal_animation_entry*)a_anim;
    34                 float frame_duration = 1000.f / (float)anim->get_frame_rate();
    35                 float anim_duration = frame_duration * anim->get_duration();
    36                 float new_time = fmodf( (float)a_anim_time, anim_duration );
    37                 anim->update_skeleton( m_transform.data(), new_time * 0.001f );
    38 
    39                 //m_mesh_data->apply( m_transform.data() );
     36                anim->update_skeleton( m_transform.data(), (float)a_anim_time );
    4037                {
    4138                        size_t skeleton_size = m_bone_offset.size();
     
    7269}
    7370
     71
     72void nv::skeletal_animation_entry::update_skeleton( transform* skeleton, float time ) const
     73{
     74        float frame_duration = 1000.f / (float)m_node_data->get_frame_rate();
     75        float anim_duration = frame_duration * m_node_data->get_duration();
     76        float new_time = fmodf( time, anim_duration ) * 0.001f;
     77
     78        float frame_num = new_time * m_node_data->get_frame_rate();
     79        for ( size_t i = 0; i < m_node_data->get_count(); ++i )
     80        {
     81                skeleton[i] = m_node_data->get_node(i)->data->get_transform( frame_num );
     82        }
     83}
     84
     85
     86
    7487nv::skeletal_mesh::~skeletal_mesh()
    7588{
     
    8194        if ( a_anim != nullptr )
    8295        {
    83                 skeletal_animation_entry * anim = (skeletal_animation_entry*)(a_anim);
    84                 m_transform.resize( anim->get_num_joints() );
    8596                update_animation( a_anim, 0 );
    8697        }
Note: See TracChangeset for help on using the changeset viewer.