Changeset 230 for trunk/src/gfx/keyframed_mesh.cc
- Timestamp:
- 05/06/14 12:39:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r224 r230 15 15 using namespace nv; 16 16 17 keyframed_mesh::keyframed_mesh( context* a_context, mesh_data* a_data , program* a_program)18 : m_context( a_context )17 keyframed_mesh::keyframed_mesh( context* a_context, mesh_data* a_data ) 18 : animated_mesh( a_context ) 19 19 , m_data( a_data ) 20 , m_program( a_program )21 , m_va( nullptr )22 20 , m_start_frame( false ) 23 21 , m_stop_frame( false ) … … 38 36 } 39 37 40 mat4keyframed_mesh::get_tag( const std::string& tag ) const41 { 42 const std::vector< nv::mat4>& transforms = m_data->get_tag_map().at( tag );43 return glm::interpolate( transforms[ m_last_frame ], transforms[ m_next_frame ], m_interpolation );38 transform keyframed_mesh::get_tag( const std::string& tag ) const 39 { 40 const std::vector< transform >& transforms = m_data->get_tag_map().at( tag ); 41 return interpolate( transforms[ m_last_frame ], transforms[ m_next_frame ], m_interpolation ); 44 42 } 45 43 … … 101 99 } 102 100 103 void nv::keyframed_mesh::draw( render_state& rstate ) 104 { 105 m_program->set_opt_uniform( "nv_interpolate", m_interpolation ); 106 m_context->draw( nv::TRIANGLES, rstate, m_program, m_va, m_data->get_index_count() ); 101 void nv::keyframed_mesh::update( program* a_program ) 102 { 103 a_program->set_opt_uniform( "nv_interpolate", m_interpolation ); 107 104 } 108 105 … … 112 109 } 113 110 111 void nv::keyframed_mesh::run_animation( animation_entry* a_anim ) 112 { 113 keyframed_animation_entry * anim = down_cast<keyframed_animation_entry>(a_anim); 114 setup_animation( anim->m_start, anim->m_frames, anim->m_fps, anim->m_looping ); 115 } 116 114 117 keyframed_mesh_gpu::keyframed_mesh_gpu( context* a_context, mesh_data* a_data, program* a_program ) 115 : keyframed_mesh( a_context, a_data , a_program)118 : keyframed_mesh( a_context, a_data ) 116 119 , m_loc_next_position( 0 ) 117 120 , m_loc_next_normal( 0 ) … … 120 123 { 121 124 nv::vertex_buffer* vb; 122 m_loc_next_position = m_program->get_attribute( "nv_next_position" )->get_location();123 m_loc_next_normal = m_program->get_attribute( "nv_next_normal" )->get_location();125 m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location(); 126 m_loc_next_normal = a_program->get_attribute( "nv_next_normal" )->get_location(); 124 127 125 128 vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec3 ) * m_data->get_frame_count(), (void*)m_data->get_positions().data() ); … … 137 140 } 138 141 139 void nv::keyframed_mesh_gpu::draw( render_state& rstate ) 140 { 142 void nv::keyframed_mesh_gpu::update( uint32 ms ) 143 { 144 keyframed_mesh::update( ms ); 145 141 146 size_t vtx_count = m_data->get_vertex_count(); 142 147 if ( m_gpu_last_frame != m_last_frame ) … … 152 157 m_gpu_next_frame = m_next_frame; 153 158 } 154 keyframed_mesh::draw( rstate ); 155 } 156 157 158 nv::keyframed_mesh_cpu::keyframed_mesh_cpu( context* a_context, mesh_data* a_data, program* a_program ) 159 : keyframed_mesh( a_context, a_data, a_program ) 159 } 160 161 162 nv::keyframed_mesh_cpu::keyframed_mesh_cpu( context* a_context, mesh_data* a_data ) 163 : keyframed_mesh( a_context, a_data ) 160 164 { 161 165 m_vb_position = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec3 ), (void*)m_data->get_position_frame(0) );
Note: See TracChangeset
for help on using the changeset viewer.