Changeset 241 for trunk/src/gfx
- Timestamp:
- 05/22/14 01:19:08 (11 years ago)
- Location:
- trunk/src/gfx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r239 r241 44 44 { 45 45 NV_ASSERT( m_tag_map, "TAGMAP FAIL" ); 46 const std::vector< transform >* transforms = m_tag_map->get_tag( tag );46 const transform_vector* transforms = m_tag_map->get_tag( tag ); 47 47 NV_ASSERT( transforms, "TAG FAIL" ); 48 return interpolate( (*transforms)[ m_last_frame ], (*transforms)[ m_next_frame ], m_interpolation);48 return interpolate( transforms->get( m_last_frame ), transforms->get( m_next_frame ), m_interpolation ); 49 49 } 50 50 -
trunk/src/gfx/skeletal_mesh.cc
r240 r241 13 13 nv::skeletal_mesh::skeletal_mesh( context* a_context, md5_mesh_data* a_mesh_data ) 14 14 : animated_mesh() 15 , m_mesh_data( a_mesh_data)15 , m_mesh_data( nullptr ) 16 16 , m_animation( nullptr ) 17 , m_animation_time( 0 ) 17 18 { 18 m_va = a_context->get_device()->create_vertex_array( a_mesh_data, nv::STREAM_DRAW ); 19 m_mesh_data = a_mesh_data->spawn(); 20 m_va = a_context->get_device()->create_vertex_array( a_mesh_data, nv::STREAM_DRAW ); 19 21 } 20 22 … … 22 24 void nv::skeletal_mesh::setup_animation( md5_animation* a_anim ) 23 25 { 24 if ( m_animation ) m_animation->reset_animation(); 25 m_animation = a_anim; 26 // TODO : INSTANCE! 27 m_animation->reset_animation(); 26 m_animation = a_anim; 27 m_animation_time = 0; 28 if ( m_animation ) 29 { 30 m_transform.resize( m_animation->get_num_joints() ); 31 update( 0 ); 32 } 28 33 } 29 34 30 35 void nv::skeletal_mesh::update( uint32 ms ) 31 36 { 32 if ( m_animation != nullptr)37 if ( m_animation ) 33 38 { 34 m_animation->update( ms * 0.001f ); 35 m_mesh_data->apply( *m_animation ); 39 m_animation_time += ms; 40 float frame_duration = 1000.f / (float)m_animation->get_frame_rate(); 41 uint32 anim_duration = uint32( frame_duration * (float)m_animation->get_frame_count() ); 42 while ( m_animation_time >= anim_duration ) m_animation_time -= anim_duration; 43 m_animation->update_skeleton( m_transform, (float)m_animation_time * 0.001f ); 44 m_mesh_data->apply( m_transform ); 36 45 vertex_buffer* vb = m_va->find_buffer( nv::POSITION ); 37 const mesh_raw_channel* pch = m_mesh_data->get_channel_data()[0];38 46 vb->bind(); 39 vb->update( (const void*)pch->data, 0, pch->size);47 vb->update( m_mesh_data->data(), 0, m_mesh_data->size() ); 40 48 vb->unbind(); 41 49 } … … 45 53 { 46 54 delete m_va; 47 // TODO : INSTANCE! 48 // delete m_mesh_data; 55 delete m_mesh_data; 49 56 } 50 57 … … 52 59 { 53 60 skeletal_animation_entry * anim = down_cast<skeletal_animation_entry>(a_anim); 54 // TODO : INSTANCE!55 61 setup_animation( anim->m_animation ); 56 62 }
Note: See TracChangeset
for help on using the changeset viewer.