From: curt Date: Fri, 3 Nov 2000 20:21:43 +0000 (+0000) Subject: Support aliasing one material name to another. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7715f7d8723c1e66c2185e631e1af1aa80c2707e;p=flightgear.git Support aliasing one material name to another. --- diff --git a/src/Objects/matlib.cxx b/src/Objects/matlib.cxx index 104d32c16..d8d95b4ef 100644 --- a/src/Objects/matlib.cxx +++ b/src/Objects/matlib.cxx @@ -111,42 +111,53 @@ bool FGMaterialLib::load( const string& mpath ) { // after a failed >> operation. char token = 0; - in >> material_name >> token; - - if ( token == '{' ) { - FGNewMat m; - in >> m; - - // build the ssgSimpleState - FGPath tex_path( globals->get_options()->get_fg_root() ); - tex_path.append( "Textures.high" ); - - FGPath tmp_path = tex_path; - tmp_path.append( m.get_texture_name() ); - if ( ! local_file_exists(tmp_path.str()) - || general.get_glMaxTexSize() < 512 ) { - tex_path = FGPath( globals->get_options()->get_fg_root() ); - tex_path.append( "Textures" ); - } + in >> material_name; + + if ( material_name == "alias" ) { + string src_mat, dst_mat; + in >> dst_mat >> src_mat; + FG_LOG( FG_GENERAL, FG_INFO, " Material alias: " << dst_mat << + " mapped to " << src_mat ); + FGNewMat m = matlib[src_mat]; + matlib[dst_mat] = m; + } else { + in >> token; + + if ( token == '{' ) { + FGNewMat m; + in >> m; + + // build the ssgSimpleState + FGPath tex_path( globals->get_options()->get_fg_root() ); + tex_path.append( "Textures.high" ); + + FGPath tmp_path = tex_path; + tmp_path.append( m.get_texture_name() ); + if ( ! local_file_exists(tmp_path.str()) + || general.get_glMaxTexSize() < 512 ) { + tex_path = FGPath( globals->get_options()->get_fg_root() ); + tex_path.append( "Textures" ); + } - FG_LOG( FG_TERRAIN, FG_INFO, " Loading material " - << material_name << " (" << tex_path.c_str() << ")"); - - GLenum shade_model = GL_SMOOTH; - if ( globals->get_options()->get_shading() == 1 ) { - shade_model = GL_SMOOTH; - } else { - shade_model = GL_FLAT; - } + FG_LOG( FG_TERRAIN, FG_INFO, " Loading material " + << material_name << " (" << tex_path.c_str() << ")"); - m.build_ssg_state( tex_path.str(), shade_model, - globals->get_options()->get_textures() ); + GLenum shade_model = GL_SMOOTH; + if ( globals->get_options()->get_shading() == 1 ) { + shade_model = GL_SMOOTH; + } else { + shade_model = GL_FLAT; + } + + m.build_ssg_state( tex_path.str(), shade_model, + globals->get_options()->get_textures() ); #if EXTRA_DEBUG - m.dump_info(); + m.dump_info(); #endif - matlib[material_name] = m; + matlib[material_name] = m; + } } }