Changeset 284 for trunk/src/formats/nmd_loader.cc
- Timestamp:
- 07/20/14 23:45:56 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/nmd_loader.cc
r283 r284 22 22 switch ( element_header.type ) 23 23 { 24 case nmd_type::MESH : load_mesh( source, element_header .children); break;25 case nmd_type::ANIMATION : load_animation( source, element_header .children); break;26 case nmd_type::BONE_ARRAY : load_bones( source, element_header .children); break;24 case nmd_type::MESH : load_mesh( source, element_header ); break; 25 case nmd_type::ANIMATION : load_animation( source, element_header ); break; 26 case nmd_type::BONE_ARRAY : load_bones( source, element_header ); break; 27 27 case nmd_type::STRING_TABLE : load_strings( source ); break; 28 28 default: NV_ASSERT( false, "UNKNOWN NMD ELEMENT!" ); break; … … 32 32 } 33 33 34 bool nv::nmd_loader::load_mesh( stream& source, uint32 children)34 bool nv::nmd_loader::load_mesh( stream& source, const nmd_element_header& e ) 35 35 { 36 36 mesh_data* mesh = new mesh_data(); 37 for ( uint32 s = 0; s < children; ++s )37 for ( uint32 s = 0; s < e.children; ++s ) 38 38 { 39 39 nmd_element_header element_header; … … 82 82 } 83 83 84 bool nv::nmd_loader::load_bones( stream& source, uint32 children)84 bool nv::nmd_loader::load_bones( stream& source, const nmd_element_header& e ) 85 85 { 86 86 NV_ASSERT( m_bone_data == nullptr, "MULTIPLE BONE ENTRIES!" ); 87 87 m_bone_data = new nmd_bone_data; 88 m_bone_data->bones = new nmd_bone[ children ];89 m_bone_data->count = (uint16) children;90 source.read( m_bone_data->bones, sizeof( nmd_bone ), children );88 m_bone_data->bones = new nmd_bone[ e.children ]; 89 m_bone_data->count = (uint16)e.children; 90 source.read( m_bone_data->bones, sizeof( nmd_bone ), e.children ); 91 91 return true; 92 92 } … … 114 114 115 115 116 bool nv::nmd_loader::load_animation( stream& source, uint32 children)116 bool nv::nmd_loader::load_animation( stream& source, const nmd_element_header& e ) 117 117 { 118 118 NV_ASSERT( m_animation == nullptr, "MULTIPLE ANIMATION ENTRIES!" ); … … 123 123 m_animation->duration = header.duration; 124 124 m_animation->flat = header.flat; 125 m_animation->node_count = (uint16) children;126 m_animation->nodes = new nmd_node[ children ];127 for ( uint32 i = 0; i < children; ++i )125 m_animation->node_count = (uint16)e.children; 126 m_animation->nodes = new nmd_node[ e.children ]; 127 for ( uint32 i = 0; i < e.children; ++i ) 128 128 { 129 129 nmd_element_header element_header; 130 130 source.read( &element_header, sizeof( element_header ), 1 ); 131 131 NV_ASSERT( element_header.type == nmd_type::ANIMATION_NODE, "ANIMATION_NODE expected!" ); 132 m_animation->nodes[i].name = element_header.name; 132 133 133 134 uint16 ch_count = element_header.children; … … 135 136 nmd_animation_node_header node_header; 136 137 source.read( &node_header, sizeof( node_header ), 1 ); 137 m_animation->nodes[i].name = node_header.name;138 138 m_animation->nodes[i].parent_id = node_header.parent_id; 139 139 m_animation->nodes[i].transform = node_header.transform;
Note: See TracChangeset
for help on using the changeset viewer.