Changeset 427 for trunk/src/formats/md5_loader.cc
- Timestamp:
- 07/20/15 13:25:20 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/md5_loader.cc
r425 r427 46 46 std_stream sstream( &source ); 47 47 std::string command; 48 mesh_node_data* nodes = nullptr;49 48 size_t num_joints = 0; 50 49 … … 111 110 assert( m_type == MESH ); 112 111 assert( m_nodes == nullptr ); 113 nodes = new mesh_node_data[ num_joints ]; 114 m_nodes = new mesh_nodes_data( make_name( "md5_bones"), num_joints, nodes ); 112 m_nodes = new mesh_nodes_data( make_name( "md5_bones") ); 115 113 discard( sstream, "{" ); 116 114 for ( size_t i = 0; i < m_nodes->get_count(); ++i ) … … 128 126 unit_quat_w( orient ); 129 127 remove_quotes( name ); 130 nodes[i].data= data_channel_set_creator::create_set( 0 );131 data_channel_set_creator access( nodes[i].data);128 data_channel_set* set = data_channel_set_creator::create_set( 0 ); 129 data_channel_set_creator access( set ); 132 130 access.set_parent_id( parent_id ); 133 131 access.set_transform( transform( pos, orient ).inverse().extract() ); 134 132 access.set_name( make_name( name.c_str() ) ); 135 133 next_line( sstream ); 134 m_nodes->push_back( set ); 136 135 } 137 136 discard( sstream, "}" ); … … 233 232 } 234 233 235 prepare_mesh( nodes, weight_info.size(), mesh, weights.data(), weight_info.data() );234 prepare_mesh( m_nodes, weight_info.size(), mesh, weights.data(), weight_info.data() ); 236 235 237 236 m_meshes[ num_meshes ] = mesh; … … 241 240 { 242 241 assert( m_type == ANIMATION ); 243 assert( nodes == nullptr ); 244 nodes = new mesh_node_data[ num_joints ]; 245 m_nodes = new mesh_nodes_data( make_name( "md5_animation" ), num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true ); 242 assert( m_nodes == nullptr ); 243 m_nodes = new mesh_nodes_data( make_name( "md5_animation" ), static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true ); 246 244 joint_infos.resize( num_joints ); 247 245 … … 253 251 sstream >> name >> parent_id >> joint_infos[i].flags >> joint_infos[i].start_index; 254 252 remove_quotes( name ); 255 nodes[i].data= data_channel_set_creator::create_set( 1 );256 data_channel_set_creator access( nodes[i].data);253 data_channel_set* set = data_channel_set_creator::create_set( 1 ); 254 data_channel_set_creator access( set ); 257 255 access.add_channel< md5_key_t >( num_frames ); 258 256 access.set_name( make_name( name.c_str() ) ); 259 257 access.set_parent_id( parent_id ); 258 m_nodes->push_back( set ); 260 259 next_line( sstream ); 261 260 } … … 322 321 } 323 322 324 build_frame_skeleton( nodes, frame_id, joint_infos, base_frames, frame );323 build_frame_skeleton( m_nodes, frame_id, joint_infos, base_frames, frame ); 325 324 326 325 discard( sstream, "}" ); … … 334 333 } 335 334 336 bool md5_loader::prepare_mesh( mesh_node _data* nodes, uint32 vtx_count, data_channel_set* mdata, md5_weight* weights, md5_weight_info* weight_info )335 bool md5_loader::prepare_mesh( mesh_nodes_data* nodes, uint32 vtx_count, data_channel_set* mdata, md5_weight* weights, md5_weight_info* weight_info ) 337 336 { 338 337 assert( m_type == MESH ); … … 389 388 if ( j < weight_count ) 390 389 { 391 md5_weight& weight = weights[start_weight + j];392 const mesh_node_data& joint = nodes[weight.joint_id];393 const transform tr = transform( joint .data->get_transform() ).inverse();390 md5_weight& weight = weights[start_weight + j]; 391 const data_channel_set* joint = (*nodes)[weight.joint_id]; 392 const transform tr = transform( joint->get_transform() ).inverse(); 394 393 vec3 rot_pos = tr.get_orientation() * weight.pos; 395 394 … … 453 452 for ( int j = 0; j < 4; ++j ) 454 453 { 455 const mesh_node_data& joint = nodes[vdata.boneindex[j]];456 const transform tr = transform( joint .data->get_transform() ).inverse();454 const data_channel_set* joint = ( *nodes )[vdata.boneindex[j]]; 455 const transform tr = transform( joint->get_transform() ).inverse(); 457 456 vdata.normal += ( normal * tr.get_orientation() ) * vdata.boneweight[j]; 458 457 vdata.tangent += ( tangent * tr.get_orientation() ) * vdata.boneweight[j]; … … 463 462 } 464 463 465 void md5_loader::build_frame_skeleton( mesh_node _data* nodes, uint32 index, const array_view<md5_joint_info>& joint_infos, const array_view<transform>& base_frames, const array_view<float>& frame_data )464 void md5_loader::build_frame_skeleton( mesh_nodes_data* nodes, uint32 index, const array_view<md5_joint_info>& joint_infos, const array_view<transform>& base_frames, const array_view<float>& frame_data ) 466 465 { 467 466 assert( m_type == ANIMATION ); … … 471 470 472 471 const md5_joint_info& jinfo = joint_infos[i]; 473 mesh_node_data& joint = nodes[i];474 int parent_id = joint .data->get_parent_id();472 const data_channel_set* joint = (*nodes)[i]; 473 int parent_id = joint->get_parent_id(); 475 474 476 475 vec3 pos = base_frames[i].get_position(); … … 486 485 if ( parent_id >= 0 ) // Has a parent joint 487 486 { 488 const mesh_node_data& pjoint = nodes[parent_id];489 const transform* ptv = reinterpret_cast< const transform* >( pjoint .data->get_channel(0)->raw_data() );487 const data_channel_set* pjoint = ( *nodes )[i]; 488 const transform* ptv = reinterpret_cast< const transform* >( pjoint->get_channel(0)->raw_data() ); 490 489 transform ptr; 491 if ( pjoint .data->get_channel(0)->size() > index ) ptr = ptv[ index ];490 if ( pjoint->get_channel(0)->size() > index ) ptr = ptv[ index ]; 492 491 vec3 rot_pos = ptr.get_orientation() * pos; 493 492 … … 498 497 } 499 498 500 reinterpret_cast< transform* >( const_cast< uint8* >( joint .data->get_channel(0)->raw_data() ) )[index] = transform( pos, orient );499 reinterpret_cast< transform* >( const_cast< uint8* >( joint->get_channel(0)->raw_data() ) )[index] = transform( pos, orient ); 501 500 } 502 501 }
Note: See TracChangeset
for help on using the changeset viewer.