Ignore:
Timestamp:
07/17/15 13:34:28 (10 years ago)
Author:
epyon
Message:
  • mesh formats now support string loading via string_table
  • nmd string_table dump
  • fixes all around
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/formats/nmd_loader.cc

    r424 r425  
    4747{
    4848        data_channel_set* result = m_meshes[ index ];
    49 //      if ( m_strings ) data_channel_set_creator( result ).set_name( m_strings->get( m_mesh_names[ index ] ) );
    5049        m_meshes[ index ] = nullptr;
    5150        return result;
     
    6867{
    6968        for ( auto mesh : m_meshes ) if ( mesh ) delete mesh;
    70         if ( m_strings )   delete m_strings;
    7169        if ( m_node_data ) delete m_node_data;
    7270        m_meshes.clear();
    73 //      m_mesh_names.clear();
    74 //      m_node_names.clear();
    7571
    7672        m_node_data  = nullptr;
    7773        m_node_array = nullptr;
    78         m_strings    = nullptr;
    7974}
    8075
     
    9287bool nv::nmd_loader::load_strings( stream& source )
    9388{
    94         NV_ASSERT( m_strings == nullptr, "MULTIPLE STRING ENTRIES!" );
     89        if ( !m_strings ) return true;
    9590        // TODO: load strings optionally
    96         m_strings = new string_table( source );
     91        string_table* strings = new string_table( source );
     92        m_strings->insert( strings );
     93        delete strings;
    9794        return true;
    9895}
     
    110107                skip_attributes( source, element_header.attributes );
    111108                NV_ASSERT( element_header.type == nmd_type::NODE, "NODE expected!" );
    112 //              m_node_names.push_back( element_header.name );
    113                 load_node( source, &m_node_array[i], element_header );
     109                m_node_array[i].data = data_channel_set_creator::create_set( element_header.children );
     110                load_channel_set( source, m_node_array[i].data, element_header );
    114111        }
    115112        m_node_data = new mesh_nodes_data( e.name, e.children, m_node_array, animation_header.frame_rate, animation_header.duration, animation_header.flat );
    116         return true;
    117 }
    118 
    119 bool nv::nmd_loader::load_node( stream& source, mesh_node_data* data, const nmd_element_header& e )
    120 {
    121         data->data = data_channel_set_creator::create_set( e.children );
    122         if ( e.children > 0 )
    123         {
    124                 load_channel_set( source, data->data, e );
    125         }
    126         data_channel_set_creator access( data->data );
    127         access.set_name( e.name );
    128         access.set_parent_id( e.parent_id );
    129         access.set_transform( e.transform );
    130113        return true;
    131114}
     
    148131                load_channel( source, channel_set );
    149132        }
     133        data_channel_set_creator access( channel_set );
     134        access.set_name( e.name );
     135        access.set_parent_id( e.parent_id );
     136        access.set_transform( e.transform );
    150137        return true;
    151138}
     
    155142        if ( m_node_data )
    156143        {
    157 //              if ( m_strings )
    158 //              {
    159 //                      for ( uint32 i = 0; i < m_node_data->get_count(); ++i )
    160 //                      {
    161 //                              m_node_array[i].name = m_strings->get( m_node_names[i] );
    162 //                              m_node_array[i].name_hash = hash_string< uint64 >( m_strings->get( m_node_names[i] ) );
    163 //                      }
    164 //              }
    165144                mesh_nodes_data* result = m_node_data;
    166145                m_node_data = nullptr;
     
    203182        nmd_element_header eheader;
    204183        eheader.type = nmd_type::NODE;
    205         //              eheader.name     = strings->insert( node->name );
    206184        eheader.children   = static_cast<uint16>( chan_count );
    207185        eheader.size       = chan_size;
Note: See TracChangeset for help on using the changeset viewer.