- Timestamp:
- 05/06/14 12:39:51 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/md3_loader.cc
r224 r230 328 328 */ 329 329 330 void nv::md3_loader::load_tags( std::vector< mat4>& t, const std::string& tag )330 void nv::md3_loader::load_tags( std::vector<transform>& t, const std::string& tag ) 331 331 { 332 332 md3_t* md3 = (md3_t*)m_md3; … … 340 340 if (rname == tag) 341 341 { 342 vec 4 axisx = vec4( md3_vec3( rtag.axis[0] ), 0.0);343 vec 4 axisz = vec4( md3_vec3( rtag.axis[1] ), 0.0);344 vec 4 axisy = vec4( md3_vec3( rtag.axis[2] ), 0.0);345 vec 4 origin = vec4( md3_vec3( rtag.origin ), 1.0);346 t.emplace_back( axisx, axisy, axisz, origin);342 vec3 axisx ( md3_vec3( rtag.axis[0] ) ); 343 vec3 axisz ( md3_vec3( rtag.axis[1] ) ); 344 vec3 axisy ( md3_vec3( rtag.axis[2] ) ); 345 vec3 origin ( md3_vec3( rtag.origin ) ); 346 t.emplace_back( origin, quat( mat3( axisx, axisy, axisz ) ) ); 347 347 } 348 348 } … … 406 406 } 407 407 408 mat4md3_loader::get_tag( sint32 frame, const std::string& name ) const408 transform md3_loader::get_tag( sint32 frame, const std::string& name ) const 409 409 { 410 410 md3_t* md3 = (md3_t*)m_md3; … … 415 415 if (rname == name) 416 416 { 417 vec 4 axisx = vec4( md3_vec3( rtag.axis[0] ), 0.0);418 vec 4 axisz = vec4( md3_vec3( rtag.axis[1] ), 0.0);419 vec 4 axisy = vec4( md3_vec3( rtag.axis[2] ), 0.0);420 vec 4 origin = vec4( md3_vec3( rtag.origin ), 1.0);421 return glm::mat4( axisx, axisy, axisz, origin);422 } 423 } 424 return glm::mat4();417 vec3 axisx ( md3_vec3( rtag.axis[0] ) ); 418 vec3 axisz ( md3_vec3( rtag.axis[1] ) ); 419 vec3 axisy ( md3_vec3( rtag.axis[2] ) ); 420 vec3 origin( md3_vec3( rtag.origin ) ); 421 return transform( origin, quat( mat3( axisx, axisy, axisz ) ) ); 422 } 423 } 424 return transform(); 425 425 } 426 426 -
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) ); -
trunk/src/gfx/skeletal_mesh.cc
r227 r230 11 11 12 12 13 nv::skeletal_mesh::skeletal_mesh( context* a_context, program* a_program, md5_loader* a_loader ) 14 : m_context( a_context ) 15 , m_program( a_program ) 16 , m_va( nullptr ) 13 nv::skeletal_mesh::skeletal_mesh( context* a_context, md5_loader* a_loader ) 14 : animated_mesh( a_context ) 17 15 , m_data( a_loader ) 18 16 , m_animation( nullptr ) … … 38 36 if ( m_animation ) m_animation->reset_animation(); 39 37 m_animation = a_anim; 38 // TODO : INSTANCE! 40 39 m_animation->reset_animation(); 41 40 } … … 64 63 } 65 64 66 void nv::skeletal_mesh::draw( render_state& rstate )67 {68 m_context->draw( nv::TRIANGLES, rstate, m_program, m_va, m_data->get_index_count(0) );69 }70 71 65 nv::skeletal_mesh::~skeletal_mesh() 72 66 { 73 67 delete m_va; 74 68 } 69 70 void nv::skeletal_mesh::run_animation( animation_entry* a_anim ) 71 { 72 skeletal_animation_entry * anim = down_cast<skeletal_animation_entry>(a_anim); 73 // TODO : INSTANCE! 74 setup_animation( anim->m_animation ); 75 }
Note: See TracChangeset
for help on using the changeset viewer.