Updates to cloud code to add different basic cloud types. This isn't the
final list of cloud types, but servers as an example / template for someone who wants to tweak this out and do it right.
This commit is contained in:
parent
33bfe7587d
commit
4c72f1df98
5 changed files with 90 additions and 15 deletions
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
// build the ssgSimpleState
|
||||
FGPath tex_file( 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 );
|
||||
|
||||
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[material_name] = m;
|
||||
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[mat_name] = m;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Add table
Reference in a new issue