]> git.mxchange.org Git - flightgear.git/commitdiff
Updates to cloud code to add different basic cloud types. This isn't the
authorcurt <curt>
Fri, 23 Jun 2000 04:55:55 +0000 (04:55 +0000)
committercurt <curt>
Fri, 23 Jun 2000 04:55:55 +0000 (04:55 +0000)
final list of cloud types, but servers as an example / template for someone
who wants to tweak this out and do it right.

src/Main/main.cxx
src/Objects/matlib.cxx
src/Objects/matlib.hxx
src/Objects/newmat.cxx
src/Objects/newmat.hxx

index bdb26e28f7acf35f5354e5249d4f9d46594547be..e37ba954207384c31c9992f0f263f26385a420e6 100644 (file)
@@ -1355,9 +1355,9 @@ int main( int argc, char **argv ) {
                   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;
index ea2dc2ae660b8a5929abaa869468a52c8c414c72..5c3f72727488356cd0dd0a8f7d480840cdcd7cfd 100644 (file)
@@ -125,19 +125,27 @@ bool FGMaterialLib::load( const string& mpath ) {
 
 
 // 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();
@@ -150,9 +158,28 @@ bool FGMaterialLib::add_item ( const string &path )
        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;
 }
index bb48a7e2ca2da67c07244721fcf63bbc40fe34a8..b97e64388ba21d665e1fd1e1bc830008a75cb123 100644 (file)
@@ -112,7 +112,9 @@ public:
     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 );
index 2aa4e33a091c07c7f5dabbc3f21b0f48bd725da3..17489498bd14aefac1c0b93578bf08eda88be057 100644 (file)
@@ -46,8 +46,15 @@ FGNewMat::FGNewMat ( void ) {
 // 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;
@@ -115,6 +122,43 @@ void FGNewMat::build_ssg_state( const string& path,
 }
 
 
+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 );
index 20bbc481d8eb7a6048e01443c88a50517fad3000..c5eecac033c7c0170ece04d197dbe97574327fde 100644 (file)
@@ -81,6 +81,7 @@ public:
     // Constructor
     FGNewMat ( void );
     FGNewMat ( const string& name );
+    FGNewMat ( const string &mat_name, const string &tex_name );
 
     // Destructor
     ~FGNewMat ( void );
@@ -90,6 +91,7 @@ public:
     // 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; }