// draw background portions of the sky ... do this before you draw the
// rest of your scene.
-void SGSky::preDraw( float alt, float fog_exp2_density ) {
+void SGSky::preDraw( float alt ) {
ssgCullAndDraw( pre_root );
- // FIXME: This should not be needed, but at this time (08/15/2003)
- // certain NVidia drivers don't seem to implement
- // glPushAttrib(FG_FOG_BIT) properly. The result is that
- // there is not fog when looking at the sun.
- glFogf ( GL_FOG_DENSITY, fog_exp2_density );
-
// if we are closer than this to a cloud layer, don't draw clouds
static const float slop = 5.0;
int i;
{
++cur_layer_pos;
}
+}
+
+void SGSky::drawUpperClouds( float fog_exp2_density ) {
+ // FIXME: This should not be needed, but at this time (08/15/2003)
+ // certain NVidia drivers don't seem to implement
+ // glPushAttrib(FG_FOG_BIT) properly. The result is that
+ // there is not fog when looking at the sun.
+ glFogf ( GL_FOG_DENSITY, fog_exp2_density );
// draw the cloud layers that are above us, top to bottom
- for ( i = (int)cloud_layers.size() - 1; i >= cur_layer_pos; --i ) {
+ for ( int i = (int)cloud_layers.size() - 1; i >= cur_layer_pos; --i ) {
if ( i != in_cloud ) {
cloud_layers[i]->draw();
}
// draw translucent clouds ... do this after you've drawn all the
// oapaque elements of your scene.
-void SGSky::postDraw( float alt ) {
+void SGSky::drawLowerClouds() {
// draw the cloud layers that are below us, bottom to top
-
for ( int i = 0; i < cur_layer_pos; ++i ) {
if ( i != in_cloud ) {
cloud_layers[i]->draw();
* Rendering the Sky
- * The sky is designed to be rendered in two stages. The first stage
+ * The sky is designed to be rendered in three stages. The first stage
* renders the parts that form your back drop - the sky dome, the
* stars and planets, the sun, and the moon. These should be rendered
* before the rest of your scene by calling the preDraw() method. The
- * second stage renders the clouds which are likely to be translucent
- * (depending on type) and should be drawn after your scene has been
- * rendered. Use the postDraw() method to draw the second stage of
- * the sky.
+ * second stage renders the clouds that are above the viewer. This stage
+ * is done before translucent objects in the main scene are drawn. It
+ * is seperated from the preDraw routine to enable to implement a
+ * multi passes technique and is located in the drawUpperClouds() method.
+ * The third stage renders the clouds that are below the viewer an which
+ * are likely to be translucent (depending on type) and should be drawn
+ * after your scene has been rendered. Use the drawLowerClouds() method
+ * to draw the second stage of the sky.
* A typical application might do the following:
- * <li> thesky->preDraw();
+ * <li> thesky->preDraw( my_altitude );
+ * <li> thesky->drawUpperClouds();
* <li> ssgCullAndDraw ( myscene ) ;
- * <li> thesky->postDraw( my_altitude );
+ * <li> thesky->drawLowerClouds();
- * The current altitude in meters is passed to the postDraw() method
+ * The current altitude in meters is passed to the preDraw() method
* so the clouds layers can be rendered correction from most distant
* to closest.
* class description.
* @param alt current altitude
*/
- void preDraw( float alt, float fog_exp2_density );
+ void preDraw( float alt );
/**
- * Draw translucent clouds ... do this after you've drawn all the
- * oapaque elements of your scene. See discussion in detailed
+ * Draw upper translucent clouds ... do this before you've drawn
+ * all the translucent elements of your scene. See discussion in
+ * detailed class description.
+ * @param fog_exp2_density fog density of the current cloud layer
+ */
+ void drawUpperClouds( float fog_exp2_density );
+
+ /**
+ * Draw lower translucent clouds ... do this after you've drawn
+ * all the opaque elements of your scene. See discussion in detailed
* class description.
- * @param alt current altitude
*/
- void postDraw( float alt );
+ void drawLowerClouds();
/**
* Specify the texture path (optional, defaults to current directory)