Frederic Bouvier:
Move the rendering stage for upper clouds from preDraw to drawUpperClouds. Rename postDraw to drawLowerClouds.
This commit is contained in:
+11
-10
@@ -168,15 +168,9 @@ bool SGSky::reposition( SGSkyState &st, double dt )
|
|||||||
|
|
||||||
// draw background portions of the sky ... do this before you draw the
|
// draw background portions of the sky ... do this before you draw the
|
||||||
// rest of your scene.
|
// rest of your scene.
|
||||||
void SGSky::preDraw( float alt, float fog_exp2_density ) {
|
void SGSky::preDraw( float alt ) {
|
||||||
ssgCullAndDraw( pre_root );
|
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
|
// if we are closer than this to a cloud layer, don't draw clouds
|
||||||
static const float slop = 5.0;
|
static const float slop = 5.0;
|
||||||
int i;
|
int i;
|
||||||
@@ -206,9 +200,17 @@ void SGSky::preDraw( float alt, float fog_exp2_density ) {
|
|||||||
{
|
{
|
||||||
++cur_layer_pos;
|
++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
|
// 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 ) {
|
if ( i != in_cloud ) {
|
||||||
cloud_layers[i]->draw();
|
cloud_layers[i]->draw();
|
||||||
}
|
}
|
||||||
@@ -218,10 +220,9 @@ void SGSky::preDraw( float alt, float fog_exp2_density ) {
|
|||||||
|
|
||||||
// draw translucent clouds ... do this after you've drawn all the
|
// draw translucent clouds ... do this after you've drawn all the
|
||||||
// oapaque elements of your scene.
|
// oapaque elements of your scene.
|
||||||
void SGSky::postDraw( float alt ) {
|
void SGSky::drawLowerClouds() {
|
||||||
|
|
||||||
// draw the cloud layers that are below us, bottom to top
|
// draw the cloud layers that are below us, bottom to top
|
||||||
|
|
||||||
for ( int i = 0; i < cur_layer_pos; ++i ) {
|
for ( int i = 0; i < cur_layer_pos; ++i ) {
|
||||||
if ( i != in_cloud ) {
|
if ( i != in_cloud ) {
|
||||||
cloud_layers[i]->draw();
|
cloud_layers[i]->draw();
|
||||||
|
|||||||
+26
-14
@@ -143,22 +143,27 @@ typedef struct {
|
|||||||
|
|
||||||
* Rendering the Sky
|
* 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
|
* renders the parts that form your back drop - the sky dome, the
|
||||||
* stars and planets, the sun, and the moon. These should be rendered
|
* stars and planets, the sun, and the moon. These should be rendered
|
||||||
* before the rest of your scene by calling the preDraw() method. The
|
* before the rest of your scene by calling the preDraw() method. The
|
||||||
* second stage renders the clouds which are likely to be translucent
|
* second stage renders the clouds that are above the viewer. This stage
|
||||||
* (depending on type) and should be drawn after your scene has been
|
* is done before translucent objects in the main scene are drawn. It
|
||||||
* rendered. Use the postDraw() method to draw the second stage of
|
* is seperated from the preDraw routine to enable to implement a
|
||||||
* the sky.
|
* 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:
|
* A typical application might do the following:
|
||||||
|
|
||||||
* <li> thesky->preDraw();
|
* <li> thesky->preDraw( my_altitude );
|
||||||
|
* <li> thesky->drawUpperClouds();
|
||||||
* <li> ssgCullAndDraw ( myscene ) ;
|
* <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
|
* so the clouds layers can be rendered correction from most distant
|
||||||
* to closest.
|
* to closest.
|
||||||
|
|
||||||
@@ -329,15 +334,22 @@ public:
|
|||||||
* class description.
|
* class description.
|
||||||
* @param alt current altitude
|
* @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
|
* Draw upper translucent clouds ... do this before you've drawn
|
||||||
* oapaque elements of your scene. See discussion in detailed
|
* all the translucent elements of your scene. See discussion in
|
||||||
* class description.
|
* detailed class description.
|
||||||
* @param alt current altitude
|
* @param fog_exp2_density fog density of the current cloud layer
|
||||||
*/
|
*/
|
||||||
void postDraw( float alt );
|
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.
|
||||||
|
*/
|
||||||
|
void drawLowerClouds();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the texture path (optional, defaults to current directory)
|
* Specify the texture path (optional, defaults to current directory)
|
||||||
|
|||||||
Reference in New Issue
Block a user