Ignore:
Timestamp:
07/10/14 20:58:27 (11 years ago)
Author:
epyon
Message:
  • Nova Model Data format loader added
  • keyframed mesh and skeletal mesh don't store time info anymore
  • NMD loader has a temporary utility class for fast usage
File:
1 edited

Legend:

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

    r282 r283  
    2323        , m_last_frame( 0 )
    2424        , m_next_frame( 0 )
    25         , m_time( 0 )
    2625        , m_fps( 0 )
    2726        , m_interpolation( 0.0f )
     
    5655        m_fps           = fps;
    5756        m_active        = count > 1;
    58         m_time          = 0;
    5957        m_last_frame    = start;
    6058        m_next_frame    = (count > 1 ? start + 1 : start );
     
    7068}
    7169
    72 void keyframed_mesh::update( uint32 ms )
     70void nv::keyframed_mesh::update_animation( animation_entry*, uint32 a_anim_time )
    7371{
    7472        if ( m_active )
    7573        {
    76                 m_time += ms;
    7774                uint32 f_diff = (m_stop_frame - m_start_frame);
    78                 float f_time = 1000 / (float)m_fps;
     75                float  f_time = 1000 / (float)m_fps;
    7976                float f_max   = ( m_looping ? ( f_diff + 1 ) : f_diff ) * f_time;
    80                 float f_pos   = m_time / f_time;
    81 
    82                 m_last_frame    = (uint32)glm::floor( f_pos ) + m_start_frame;
    83                 m_next_frame    = m_last_frame + 1;
    84                 if ( m_next_frame > m_stop_frame )
    85                 {
    86                         m_next_frame = m_start_frame;
    87                 }
    88 
    89                 if ( m_time >= f_max )
     77                uint32 time   = a_anim_time;
     78                if ( time >= f_max )
    9079                {
    9180                        if ( m_looping )
    9281                        {
    93                                 uint32 left = m_time - static_cast< uint32 >( f_max );
    94                                 m_time = 0;
    95                                 update( left );
     82                                time = time % static_cast< uint32 >( f_max );
    9683                        }
    9784                        else
     
    10289                        }
    10390                }
     91                float f_pos   = time / f_time;
     92
     93                m_last_frame    = (uint32)glm::floor( f_pos ) + m_start_frame;
     94                m_next_frame    = m_last_frame + 1;
     95                if ( m_next_frame > m_stop_frame ) m_next_frame = m_start_frame;
    10496                m_interpolation = f_pos - glm::floor( f_pos );
    10597        }
    10698}
     99
    107100
    108101void nv::keyframed_mesh::update( program* a_program ) const
     
    148141void nv::keyframed_mesh_gpu::update( uint32 ms )
    149142{
    150         keyframed_mesh::update( ms );
     143        animated_mesh::update( ms );
    151144
    152145        if ( m_gpu_last_frame != m_last_frame )
     
    181174void nv::keyframed_mesh_cpu::update( uint32 ms )
    182175{
    183         keyframed_mesh::update( ms );
     176        animated_mesh::update( ms );
    184177
    185178        const vertex_pn* data = m_mesh_data->get_channel_data<vertex_pn>();
Note: See TracChangeset for help on using the changeset viewer.