X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObjects%2Fmatlib.cxx;h=839fe721b63fbb5946ff314d3f11ff9936a4a59f;hb=7191e8b810bfd07eced4a07027bd0e35be2acde5;hp=104d32c160c29ed0953c4695e32c968b1e8f5f52;hpb=01c44cbb99691b2a38527b40721330b2b143e604;p=flightgear.git diff --git a/src/Objects/matlib.cxx b/src/Objects/matlib.cxx index 104d32c16..839fe721b 100644 --- a/src/Objects/matlib.cxx +++ b/src/Objects/matlib.cxx @@ -47,6 +47,7 @@ #include #include
+#include
#include #include "matlib.hxx" @@ -111,45 +112,73 @@ 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_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_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 ( fgGetBool("/sim/rendering/shading") ) { + shade_model = GL_SMOOTH; + } else { + shade_model = GL_FLAT; + } + + m.build_ssg_state( tex_path.str(), shade_model, + fgGetBool("/sim/rendering/textures") ); #if EXTRA_DEBUG - m.dump_info(); + m.dump_info(); #endif - matlib[material_name] = m; + matlib[material_name] = m; + } } } + // hard coded light state + ssgSimpleState *lights = new ssgSimpleState; + lights->ref(); + lights->disable( GL_TEXTURE_2D ); + lights->enable( GL_CULL_FACE ); + lights->enable( GL_COLOR_MATERIAL ); + lights->setColourMaterial( GL_AMBIENT_AND_DIFFUSE ); + lights->setMaterial( GL_EMISSION, 0, 0, 0, 1 ); + lights->setMaterial( GL_SPECULAR, 0, 0, 0, 1 ); + lights->enable( GL_BLEND ); + lights->disable( GL_ALPHA_TEST ); + lights->disable( GL_LIGHTING ); + + FGNewMat m; + m.set_ssg_state( lights ); + matlib["LIGHTS"] = m; + return true; } @@ -182,14 +211,14 @@ bool FGMaterialLib::add_item ( const string &mat_name, const string &full_path ) #endif GLenum shade_model = GL_SMOOTH; - if ( globals->get_options()->get_shading() == 1 ) { + if ( fgGetBool("/sim/rendering/shading") ) { shade_model = GL_SMOOTH; } else { shade_model = GL_FLAT; } m.build_ssg_state( tex_path, shade_model, - globals->get_options()->get_textures() ); + fgGetBool("/sim/rendering/textures") ); material_lib.matlib[mat_name] = m; @@ -246,3 +275,13 @@ void FGMaterialLib::set_step ( int step ) slot.get_state()->selectStep(step); } } + + + + + + + + + +