Changeset 239 for trunk/src/gfx/skeletal_mesh.cc
- Timestamp:
- 05/17/14 02:35:19 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/skeletal_mesh.cc
r237 r239 11 11 12 12 13 nv::skeletal_mesh::skeletal_mesh( context* a_context, md5_ loader* a_loader)13 nv::skeletal_mesh::skeletal_mesh( context* a_context, md5_mesh_data* a_mesh_data ) 14 14 : animated_mesh() 15 , m_ data( a_loader)15 , m_mesh_data( a_mesh_data ) 16 16 , m_animation( nullptr ) 17 17 { 18 nv::uint32 vcount = a_loader->get_vertex_count(0);19 m_va = a_context->get_device()->create_vertex_array(); 18 m_va = a_context->get_device()->create_vertex_array( a_mesh_data, nv::STREAM_DRAW ); 19 } 20 20 21 m_vb_position = a_context->get_device()->create_vertex_buffer( nv::STREAM_DRAW, vcount * sizeof( nv::vec3 ), (const void*)a_loader->get_positions(0).data() );22 m_va->add_vertex_buffer( nv::slot::POSITION, m_vb_position, nv::FLOAT, 3, 0, 0, false );23 m_vb_normal = a_context->get_device()->create_vertex_buffer( nv::STREAM_DRAW, vcount * sizeof( nv::vec3 ), (const void*)a_loader->get_normals(0).data() );24 m_va->add_vertex_buffer( nv::slot::NORMAL, m_vb_normal, nv::FLOAT, 3, 0, 0, false );25 m_vb_tangent = a_context->get_device()->create_vertex_buffer( nv::STREAM_DRAW, vcount * sizeof( nv::vec3 ), (const void*)a_loader->get_tangents(0).data() );26 m_va->add_vertex_buffer( nv::slot::TANGENT, m_vb_tangent, nv::FLOAT, 3, 0, 0, false );27 28 nv::vertex_buffer* vb = a_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, vcount * sizeof( nv::vec2 ), (const void*)a_loader->get_texcoords(0).data() );29 m_va->add_vertex_buffer( nv::slot::TEXCOORD, vb, nv::FLOAT, 2 );30 nv::index_buffer* ib = a_context->get_device()->create_index_buffer( nv::STATIC_DRAW, a_loader->get_index_count(0) * sizeof( nv::uint32 ), (const void*)a_loader->get_indices(0).data() );31 m_va->set_index_buffer( ib, nv::UINT, true );32 }33 21 34 22 void nv::skeletal_mesh::setup_animation( md5_animation* a_anim ) … … 45 33 { 46 34 m_animation->update( ms * 0.001f ); 47 m_data->apply( *m_animation ); 35 m_mesh_data->apply( *m_animation ); 36 vertex_buffer* vb = m_va->find_buffer( nv::POSITION ); 37 const mesh_raw_channel* pch = m_mesh_data->get_channel_data()[0]; 38 vb->bind(); 39 vb->update( (const void*)pch->data, 0, pch->size ); 40 vb->unbind(); 48 41 } 49 50 nv::uint32 usize = m_data->get_vertex_count(0) * sizeof( nv::vec3 );51 m_vb_position->bind();52 m_vb_position->update( (const void*)m_data->get_positions(0).data(), 0, usize );53 m_vb_normal ->bind();54 m_vb_normal ->update( (const void*)m_data->get_normals(0).data(), 0, usize );55 m_vb_tangent ->bind();56 m_vb_tangent ->update( (const void*)m_data->get_tangents(0).data(), 0, usize );57 58 // Technically this is not needed, because the va is just a fake class,59 // but if it's real it will be needed?60 // m_va->update_vertex_buffer( nv::slot::POSITION, m_vb_position, false );61 // m_va->update_vertex_buffer( nv::slot::NORMAL, m_vb_normal, false );62 // m_va->update_vertex_buffer( nv::slot::TANGENT, m_vb_tangent, false );63 // TODO: answer is - probably not64 42 } 65 43 … … 67 45 { 68 46 delete m_va; 47 delete m_mesh_data; 69 48 } 70 49
Note: See TracChangeset
for help on using the changeset viewer.