Ignore:
Timestamp:
04/29/16 12:42:28 (9 years ago)
Author:
epyon
Message:
  • mass update (will try to do atomic from now)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine/material_manager.cc

    r486 r491  
    3939
    4040                // HACK
    41                 for ( uint32 i = 0; i < 5; ++i )
     41                for ( uint32 i = 0; i < 8; ++i )
    4242                        if ( result->textures[i].is_nil() )
    4343                                result->textures[i] = m_default;
     
    5959bool material_manager::load_resource( nv::lua::table_guard& table, nv::shash64 id )
    6060{
     61        c_file_system fs;
    6162        material* m = new material;
    62         m->paths[ TEX_DIFFUSE ]  = table.get_string128( "diffuse" );
    63         m->paths[ TEX_SPECULAR ] = table.get_string128( "specular" );
    64         m->paths[ TEX_NORMAL ]   = table.get_string128( "normal" );
    65         m->paths[ TEX_EMISSIVE ] = table.get_string128( "emissive" );
    66         m->paths[ TEX_GLOSS ]    = table.get_string128( "gloss" );
     63
     64        if ( table.is_string( "path" ) )
     65        {
     66                string128 path = table.get_string128( "path" );
     67                for ( uint32 i = 0; i < 5; ++i )
     68                        m->paths[i] = path;
     69                m->paths[TEX_DIFFUSE].append( "_diffuse.png" );
     70                m->paths[TEX_NORMAL].append( "_normal.png" );
     71                m->paths[TEX_METALLIC].append( "_metallic.png" );
     72                m->paths[TEX_ROUGHNESS].append( "_roughness.png" );
     73                m->paths[TEX_EMISSIVE].append( "_emissive.png" );
     74                for ( uint32 i = 0; i < 5; ++i )
     75                {
     76                        if ( !fs.exists( m->paths[i] ) )
     77                        {
     78                                if ( i != TEX_EMISSIVE )
     79                                        NV_LOG_ERROR( "Texture file not found! : ", m->paths[i] );
     80                                m->paths[i].clear();
     81                        }
     82                }
     83        }
     84        else
     85        {
     86                m->paths[ TEX_DIFFUSE ]  = table.get_string128( "diffuse" );
     87                m->paths[ TEX_NORMAL ]   = table.get_string128( "normal" );
     88                m->paths[ TEX_METALLIC]  = table.get_string128( "metallic" );
     89                m->paths[ TEX_ROUGHNESS] = table.get_string128( "roughness" );
     90                m->paths[ TEX_EMISSIVE ] = table.get_string128( "emissive" );
     91        }
    6792        add( id, m );
    6893        return true;
    6994}
     95
Note: See TracChangeset for help on using the changeset viewer.