- Timestamp:
- 11/03/15 19:06:23 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r475 r480 462 462 } 463 463 464 mesh_data_pack* nv::assimp_loader::release_mesh_data_pack()465 {466 if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr;467 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );468 bool has_bones = false;469 data_channel_set* meshes = data_channel_set_creator::create_set_array( m_mesh_count, 2 );470 for ( size_t m = 0; m < m_mesh_count; ++m )471 {472 const aiMesh* mesh = scene->mMeshes[ m ];473 data_channel_set_creator( &meshes[m] ).set_name( make_name( static_cast<const char*>( mesh->mName.data ) ) );474 if ( mesh->mNumBones > 0 ) has_bones = true;475 load_mesh_data(&meshes[m],m);476 }477 478 mesh_nodes_data* nodes = ( has_bones ? release_merged_bones( meshes ) : release_mesh_nodes_data(0) );479 return new mesh_data_pack( m_mesh_count, meshes, nodes );480 }464 // mesh_data_pack* nv::assimp_loader::release_mesh_data_pack() 465 // { 466 // if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr; 467 // const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 468 // bool has_bones = false; 469 // data_channel_set* meshes = data_channel_set_creator::create_set_array( m_mesh_count, 2 ); 470 // for ( size_t m = 0; m < m_mesh_count; ++m ) 471 // { 472 // const aiMesh* mesh = scene->mMeshes[ m ]; 473 // data_channel_set_creator( &meshes[m] ).set_name( make_name( static_cast<const char*>( mesh->mName.data ) ) ); 474 // if ( mesh->mNumBones > 0 ) has_bones = true; 475 // load_mesh_data(&meshes[m],m); 476 // } 477 // 478 // mesh_nodes_data* nodes = ( has_bones ? release_merged_bones( meshes ) : release_mesh_nodes_data(0) ); 479 // return new mesh_data_pack( m_mesh_count, meshes, nodes ); 480 // } 481 481 482 482 nv::size_t nv::assimp_loader::get_nodes_data_count() const -
trunk/src/formats/nmd_loader.cc
r475 r480 50 50 } 51 51 52 mesh_data_pack* nv::nmd_loader::release_mesh_data_pack()53 {54 uint32 size = m_meshes.size();55 data_channel_set* meshes = data_channel_set_creator::create_set_array( size, 0 );56 for ( uint32 i = 0; i < size; ++i )57 {58 meshes[i] = move( *m_meshes[i] );59 delete m_meshes[i];60 }61 m_meshes.clear();62 return new mesh_data_pack( size, meshes, release_mesh_nodes_data() );63 }64 65 52 void nv::nmd_loader::reset() 66 53 { … … 240 227 } 241 228 242 void nv::nmd_dump( stream& stream_out, const mesh_data_pack* model, const string_table* strings, uint64 name)229 void nv::nmd_dump( stream& stream_out, array_view< data_channel_set* > meshes, const mesh_nodes_data* nodes, const string_table* strings /*= nullptr*/, uint64 name /*= 0 */ ) 243 230 { 244 231 uint32 elements = ( strings ? 1 : 0 ) // +1 string array 245 + m odel->get_count() // meshes246 + ( model->get_node_count() > 0 ? 1 : 0 ); // nodes232 + meshes.size() // meshes 233 + ( nodes && nodes->size() > 0 ? 1 : 0 ); // nodes 247 234 nmd_dump_header( stream_out, elements, name ); 248 235 249 for ( uint32 i = 0; i < model->get_count(); ++i ) 250 { 251 nmd_dump_element( stream_out, *model->get_mesh( i ), nv::nmd_type::MESH ); 252 } 253 254 if ( model->get_node_count() > 0 ) 255 { 256 nmd_dump_nodes( stream_out, *model->get_nodes() ); 236 for ( uint32 i = 0; i < meshes.size(); ++i ) 237 { 238 NV_ASSERT( meshes[i], "mesh is null!" ); 239 nmd_dump_element( stream_out, *meshes[i], nv::nmd_type::MESH ); 240 } 241 242 if ( nodes && nodes->size() > 0 ) 243 { 244 nmd_dump_nodes( stream_out, *nodes ); 257 245 } 258 246 … … 262 250 } 263 251 } 252 253 void nv::nmd_dump( stream& stream_out, const mesh_nodes_data& animation, const string_table* strings, uint64 name ) 254 { 255 uint32 elements = ( strings ? 1 : 0 ) // +1 string array 256 + ( animation.size() > 0 ? 1 : 0 ); // nodes 257 nmd_dump_header( stream_out, elements, name ); 258 259 if ( animation.size() > 0 ) 260 { 261 nmd_dump_nodes( stream_out, animation ); 262 } 263 264 if ( strings ) 265 { 266 nmd_dump_strings( stream_out, *strings ); 267 } 268 } -
trunk/src/formats/obj_loader.cc
r454 r480 357 357 } 358 358 359 mesh_data_pack* nv::obj_loader::release_mesh_data_pack()360 {361 uint32 size = m_meshes.size();362 data_channel_set* meshes = data_channel_set_creator::create_set_array( size, 1 );363 for ( uint32 i = 0; i < size; ++i )364 {365 meshes[i] = move( *m_meshes[i] );366 delete m_meshes[i];367 }368 m_meshes.clear();369 return new mesh_data_pack( size, meshes );370 } -
trunk/src/gfx/mesh_creator.cc
r471 r480 157 157 } 158 158 } 159 }160 161 nv::mesh_data_creator::mesh_data_creator( data_channel_set* data ) : m_data( data )162 {163 initialize();164 159 } 165 160 … … 656 651 } 657 652 658 void nv::mesh_creator::delete_mesh( uint32 index )659 {660 if ( index < m_pack->get_count() )661 {662 663 m_pack->m_meshes[index] = move( m_pack->m_meshes[m_pack->m_count - 1] );664 m_pack->m_count--;665 }666 } -
trunk/src/gfx/skeleton_instance.cc
r477 r480 6 6 7 7 #include "nv/gfx/skeleton_instance.hh" 8 9 #include "nv/core/profiler.hh" 8 10 9 11 void nv::skeleton_binding::prepare( const mesh_nodes_data* node_data, const mesh_nodes_data* bone_data ) … … 62 64 for ( uint32 n = 0; n < node_data->size(); ++n ) 63 65 if ( ( *node_data )[n]->get_parent_id() == -1 ) 64 animate_rec( node_data, binding, frame, n, mat4() );66 animate_rec( node_data, binding, frame, n, transform() ); 65 67 } 66 68 } 67 69 } 68 70 69 void nv::skeleton_instance::animate_rec( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame, uint32 id, const mat4& parent )71 void nv::skeleton_instance::animate_rec( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame, uint32 id, const transform& parent ) 70 72 { 71 73 // TODO: fix transforms, which are now embedded, 72 74 // see note in assimp_loader.cc:load_node 73 75 const data_channel_set* node = ( *node_data )[id]; 74 mat4node_mat( node->get_transform() );76 transform node_mat( node->get_transform() ); 75 77 76 78 if ( node->size() > 0 ) 77 79 { 78 80 raw_channel_interpolator interpolator( node, binding.m_key ); 79 node_mat = interpolator.get< mat4>( frame );81 node_mat = interpolator.get< transform >( frame ); 80 82 } 81 83 82 mat4global_mat = parent * node_mat;84 transform global_mat = parent * node_mat; 83 85 84 86 sint16 bone_id = binding.m_indices[id]; 85 87 if ( bone_id >= 0 ) 86 88 { 87 m_transform[bone_id] = global_mat * binding.m_offsets[bone_id];89 m_transform[bone_id] = global_mat.extract() * binding.m_offsets[bone_id]; 88 90 } 89 91
Note: See TracChangeset
for help on using the changeset viewer.