#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
+#include <Objects/matlib.hxx>
+
#include "cloud.hxx"
// build the moon object
void SGCloudLayer::build( FGPath path, double s, double asl, double thickness,
- double transition )
+ double transition, SGCloudType type )
{
scale = 4000.0;
size = s;
last_lon = last_lat = -999.0f;
- // set up the cloud state
- path.append( "cloud.rgba" );
- layer_state = new ssgSimpleState();
- layer_state->setTexture( (char *)path.c_str() );
- layer_state->setShadeModel( GL_SMOOTH );
- layer_state->disable( GL_LIGHTING );
- layer_state->disable( GL_CULL_FACE );
- layer_state->enable( GL_TEXTURE_2D );
- layer_state->enable( GL_COLOR_MATERIAL );
- layer_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
- layer_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
- layer_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
- layer_state->enable( GL_BLEND );
- layer_state->enable( GL_ALPHA_TEST );
- layer_state->setAlphaClamp( 0.01 );
+ // look up the appropriate cloud state
+ FGNewMat *m;
+
+ switch ( type ) {
+ case SG_CLOUD_OVERCAST:
+ m = material_lib.find( "CloudOvercast" );
+ layer_state = m->get_state();
+ break;
+ case SG_CLOUD_MOSTLY_CLOUDY:
+ m = material_lib.find( "CloudMostlyCloudy" );
+ layer_state = m->get_state();
+ break;
+ case SG_CLOUD_MOSTLY_SUNNY:
+ m = material_lib.find( "CloudMostlySunny" );
+ layer_state = m->get_state();
+ break;
+ case SG_CLOUD_CIRRUS:
+ m = material_lib.find( "CloudCirrus" );
+ layer_state = m->get_state();
+ break;
+ }
cl = new ssgColourArray( 4 );
vl = new ssgVertexArray( 4 );
void SGCloudLayer::draw() {
ssgCullAndDraw( layer_root );
}
+
+
+// make an ssgSimpleState for a cloud layer given the named texture
+ssgSimpleState *SGCloudMakeState( const string &path ) {
+ ssgSimpleState *state = new ssgSimpleState();
+
+ state->setTexture( (char *)path.c_str() );
+ state->setShadeModel( GL_SMOOTH );
+ state->disable( GL_LIGHTING );
+ state->disable( GL_CULL_FACE );
+ state->enable( GL_TEXTURE_2D );
+ state->enable( GL_COLOR_MATERIAL );
+ state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
+ state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
+ state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
+ state->enable( GL_BLEND );
+ state->enable( GL_ALPHA_TEST );
+ state->setAlphaClamp( 0.01 );
+
+ return state;
+}
#include <simgear/misc/fgpath.hxx>
+enum SGCloudType {
+ SG_CLOUD_OVERCAST = 0,
+ SG_CLOUD_MOSTLY_CLOUDY,
+ SG_CLOUD_MOSTLY_SUNNY,
+ SG_CLOUD_CIRRUS,
+};
+
+
class SGCloudLayer {
+private:
+
ssgRoot *layer_root;
ssgTransform *layer_transform;
ssgSimpleState *layer_state;
// build the cloud object
void build( FGPath path, double size, double asl, double thickness,
- double transition );
+ double transition, SGCloudType type );
// repaint the cloud colors based on current value of sun_angle,
// sky, and fog colors. This updates the color arrays for
};
+// make an ssgSimpleState for a cloud layer given the named texture
+ssgSimpleState *SGCloudMakeState( const string &path );
+
+
#endif // _SG_CLOUD_HXX_
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
+#include <Objects/matlib.hxx>
+
#include "sky.hxx"
pre_root->addKid( pre_selector );
post_root->addKid( post_selector );
+
+ // add the cloud ssgStates to the material lib
+ FGPath cloud_path;
+ ssgSimpleState *cloud_state;
+
+ cloud_path.set( tex_path.str() );
+ cloud_path.append( "cirrus.rgba" );
+ cloud_state = SGCloudMakeState( cloud_path.str() );
+ material_lib.add_item( "CloudCirrus", cloud_state );
+
+ cloud_path.set( tex_path.str() );
+ cloud_path.append( "mostlycloudy.rgba" );
+ cloud_state = SGCloudMakeState( cloud_path.str() );
+ material_lib.add_item( "CloudMostlyCloudy", cloud_state );
+
+ cloud_path.set( tex_path.str() );
+ cloud_path.append( "mostlysunny.rgba" );
+ cloud_state = SGCloudMakeState( cloud_path.str() );
+ material_lib.add_item( "CloudMostlySunny", cloud_state );
+
+ cloud_path.set( tex_path.str() );
+ cloud_path.append( "overcast.rgb" );
+ cloud_state = SGCloudMakeState( cloud_path.str() );
+ material_lib.add_item( "CloudOvercast", cloud_state );
}
}
-void SGSky::add_cloud_layer( double asl, double thickness, double transition ) {
+void SGSky::add_cloud_layer( double asl, double thickness, double transition,
+ SGCloudType type ) {
SGCloudLayer *layer = new SGCloudLayer;
- layer->build(tex_path, 40000.0f, asl, thickness, transition);
+ layer->build(tex_path, 40000.0f, asl, thickness, transition, type );
layer_list_iterator current = cloud_layers.begin();
layer_list_iterator last = cloud_layers.end();