ephem->getPlanets(), 60000.0,
ephem->getNumStars(),
ephem->getStars(), 60000.0 );
- thesky->add_cloud_layer( 1000.0, 200.0, 50.0 );
- thesky->add_cloud_layer( 1800.0, 400.0, 100.0 );
- thesky->add_cloud_layer( 4000.0, 20.0, 10.0 );
+ thesky->add_cloud_layer( 1000.0, 200.0, 50.0, SG_CLOUD_MOSTLY_SUNNY );
+ thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST );
+ thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS );
// Terrain branch
terrain = new ssgBranch;
// Load a library of material properties
-bool FGMaterialLib::add_item ( const string &path )
+bool FGMaterialLib::add_item ( const string &tex_path )
{
- string material_name = path;
- int pos = path.rfind( "/" );
+ string material_name = tex_path;
+ int pos = tex_path.rfind( "/" );
material_name = material_name.substr( pos + 1 );
- FGNewMat m( material_name );
+ return add_item( material_name, tex_path );
+}
+
+
+// Load a library of material properties
+bool FGMaterialLib::add_item ( const string &mat_name, const string &full_path )
+{
+ int pos = full_path.rfind( "/" );
+ string tex_name = full_path.substr( pos + 1 );
+ string tex_path = full_path.substr( 0, pos );
- // build the ssgSimpleState
- FGPath tex_file( path );
+ FGNewMat m( mat_name, tex_name );
FG_LOG( FG_TERRAIN, FG_INFO, " Loading material "
- << material_name << " (" << tex_file.c_str() << ")");
+ << mat_name << " (" << tex_path << ")");
#if EXTRA_DEBUG
m.dump_info();
shade_model = GL_FLAT;
}
- m.build_ssg_state( path, shade_model, current_options.get_textures() );
+ m.build_ssg_state( tex_path, shade_model, current_options.get_textures() );
+
+ material_lib.matlib[mat_name] = m;
+
+ return true;
+}
+
+
+// Load a library of material properties
+bool FGMaterialLib::add_item ( const string &mat_name, ssgSimpleState *state )
+{
+ FGNewMat m( mat_name );
+ m.set_ssg_state( state );
+
+ FG_LOG( FG_TERRAIN, FG_INFO, " Loading material given a premade "
+ << "ssgSimpleState = " << mat_name );
+
+#if EXTRA_DEBUG
+ m.dump_info();
+#endif
- material_lib.matlib[material_name] = m;
+ material_lib.matlib[mat_name] = m;
return true;
}
bool load( const string& mpath );
// Add the named texture with default properties
- bool add_item( const string &name );
+ bool add_item( const string &tex_path );
+ bool add_item( const string &mat_name, const string &tex_path );
+ bool add_item( const string &mat_name, ssgSimpleState *state );
// find a material record by material name
FGNewMat *find( const string& material );
// Constructor
FGNewMat::FGNewMat ( const string &name )
{
- material_name = name;
- texture_name = name;
+ FGNewMat( name, name );
+}
+
+
+// Constructor
+FGNewMat::FGNewMat ( const string &mat_name, const string &tex_name )
+{
+ material_name = mat_name;
+ texture_name = tex_name;
xsize = ysize = 0;
alpha = 0;
ambient[0] = ambient[1] = ambient[2] = ambient[3] = 1.0;
}
+void FGNewMat::set_ssg_state( ssgSimpleState *s ) {
+ state = new ssgStateSelector(2);
+ textured = s;
+ nontextured = new ssgSimpleState();
+
+ // Set up the coloured state
+ nontextured->enable( GL_LIGHTING );
+ nontextured->setShadeModel( GL_FLAT );
+ nontextured->enable ( GL_CULL_FACE ) ;
+ nontextured->disable( GL_TEXTURE_2D );
+ nontextured->disable( GL_BLEND );
+ nontextured->disable( GL_ALPHA_TEST );
+ nontextured->disable( GL_COLOR_MATERIAL );
+
+ /* cout << "ambient = " << ambient[0] << "," << ambient[1]
+ << "," << ambient[2] << endl; */
+ nontextured->setMaterial ( GL_AMBIENT,
+ ambient[0], ambient[1],
+ ambient[2], ambient[3] ) ;
+ nontextured->setMaterial ( GL_DIFFUSE,
+ diffuse[0], diffuse[1],
+ diffuse[2], diffuse[3] ) ;
+ nontextured->setMaterial ( GL_SPECULAR,
+ specular[0], specular[1],
+ specular[2], specular[3] ) ;
+ nontextured->setMaterial ( GL_EMISSION,
+ emission[0], emission[1],
+ emission[2], emission[3] ) ;
+
+ state->setStep( 0, textured ); // textured
+ state->setStep( 1, nontextured ); // untextured
+
+ // Choose the appropriate starting state.
+ state->selectStep(0);
+}
+
+
void FGNewMat::dump_info () {
FG_LOG( FG_TERRAIN, FG_INFO, "{" << endl << " texture = "
<< texture_name );
// Constructor
FGNewMat ( void );
FGNewMat ( const string& name );
+ FGNewMat ( const string &mat_name, const string &tex_name );
// Destructor
~FGNewMat ( void );
// void load_texture( const string& root );
void build_ssg_state( const string& path,
GLenum shade_model, bool texture_default );
+ void set_ssg_state( ssgSimpleState *s );
inline string get_material_name() const { return material_name; }
inline void set_material_name( const string& n ) { material_name = n; }