Changeset 477 for trunk/src/gfx/skeletal_mesh.cc
- Timestamp:
- 10/23/15 19:35:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/skeletal_mesh.cc
r475 r477 13 13 #include "nv/core/logging.hh" 14 14 15 void nv::skeletal_animation_entry::update_skeleton( mat4*data, uint32 a_ms_time ) const15 void nv::skeletal_animation_entry::update_skeleton( skeleton_instance& data, uint32 a_ms_time ) const 16 16 { 17 17 float fframe = ( a_ms_time * 0.001f ) * m_fps; … … 38 38 } 39 39 40 m_data.animate( data, fframe ); 40 if ( data.size() == 0 ) 41 data.initialize( m_temp_anim->size() ); 42 data.animate( m_temp_anim, m_data, fframe ); 41 43 } 42 44 43 45 void nv::skeletal_animation_entry::prepare( const mesh_nodes_data* bones ) 44 46 { 45 m_data.prepare( bones);47 m_data.prepare( m_temp_anim, bones ? bones : m_temp_anim ); 46 48 } 47 49 48 50 nv::skeletal_mesh::skeletal_mesh( context* a_context, const data_channel_set* a_mesh, const mesh_nodes_data* a_bone_data ) 49 : m_ context( a_context ), m_bone_data( a_bone_data ), m_index_count( 0 ), m_transform( nullptr), m_parent_id(-1)51 : m_skeleton( a_bone_data ? a_bone_data->size() : 0 ), m_context( a_context ), m_bone_data( a_bone_data ), m_index_count( 0 ), m_parent_id(-1) 50 52 { 51 53 if ( a_mesh ) … … 55 57 m_parent_id = a_mesh->get_parent_id(); 56 58 } 57 if ( m_bone_data )58 {59 m_transform = new mat4[ m_bone_data->size() ];60 }61 59 } 62 60 63 void nv::skeletal_mesh::update_animation( animation_entry *a_anim, uint32 a_anim_time )61 void nv::skeletal_mesh::update_animation( animation_entry& a_anim, uint32 a_anim_time ) 64 62 { 65 if ( m_bone_data && a_anim ) 66 { 67 skeletal_animation_entry * anim = static_cast<skeletal_animation_entry*>( a_anim ); 68 anim->prepare( m_bone_data ); 69 anim->update_skeleton( m_transform, a_anim_time ); 70 } 63 skeletal_animation_entry& anim = static_cast<skeletal_animation_entry&>( a_anim ); 64 anim.prepare( m_bone_data ); 65 anim.update_skeleton( m_skeleton, a_anim_time ); 71 66 } 72 67 73 void nv::skeletal_mesh::update ( program a_program )68 void nv::skeletal_mesh::update_program( program a_program ) 74 69 { 75 if ( m_bone_data ) 76 m_context->get_device()->set_opt_uniform_array( a_program, "nv_m_bones", m_transform, m_bone_data->size() ); 70 m_context->get_device()->set_opt_uniform_array( a_program, "nv_m_bones", m_skeleton.transforms(), m_skeleton.size() ); 77 71 } 78 72 79 73 nv::transform nv::skeletal_mesh::get_node_transform( uint32 node_id ) const 80 74 { 81 return transform( m_transform[ node_id ]);75 return transform( get_node_matrix( node_id ) ); 82 76 } 83 77 84 78 nv::mat4 nv::skeletal_mesh::get_node_matrix( uint32 node_id ) const 85 79 { 86 return m_ transform[ node_id ];80 return m_skeleton.transforms()[ node_id ]; 87 81 }
Note: See TracChangeset
for help on using the changeset viewer.