Adjust the layer span and amount of curving based on the eleveation of the layer

This commit is contained in:
ehofman
2003-08-19 12:04:15 +00:00
parent 1623aee1e0
commit 858a73e187
2 changed files with 18 additions and 7 deletions

View File

@@ -90,9 +90,16 @@ SGCloudLayer::getElevation_m () const
}
void
SGCloudLayer::setElevation_m (float elevation_m)
SGCloudLayer::setElevation_m (float elevation_m, bool set_span)
{
layer_asl = elevation_m;
if (set_span) {
if (elevation_m > 4000)
setSpan_m( elevation_m * 10 );
else
setSpan_m( 40000 );
}
}
float
@@ -187,6 +194,7 @@ SGCloudLayer::rebuild()
const float layer_scale = layer_span / scale;
const float mpi = SG_PI/4;
const float alt_diff = layer_asl * 1.5;
for (int i = 0; i < 4; i++)
{
@@ -200,7 +208,7 @@ SGCloudLayer::rebuild()
sgSetVec3( vertex, layer_span*(i-2)/2, -layer_span,
500 * (sin(i*mpi) - 2) );
alt_diff * (sin(i*mpi) - 2) );
sgSetVec2( tc, base[0] + layer_scale * i/4, base[1] );
@@ -213,7 +221,7 @@ SGCloudLayer::rebuild()
for (int j = 0; j < 4; j++)
{
sgSetVec3( vertex, layer_span*(i-1)/2, layer_span*(j-2)/2,
500 * (sin((i+1)*mpi) + sin(j*mpi) - 2) );
alt_diff * (sin((i+1)*mpi) + sin(j*mpi) - 2) );
sgSetVec2( tc, base[0] + layer_scale * (i+1)/4,
base[1] + layer_scale * j/4 );
@@ -228,7 +236,7 @@ SGCloudLayer::rebuild()
sgSetVec3( vertex, layer_span*(i-2)/2, layer_span*(j-1)/2,
500 * (sin(i*mpi) + sin((j+1)*mpi) - 2) );
alt_diff * (sin(i*mpi) + sin((j+1)*mpi) - 2) );
sgSetVec2( tc, base[0] + layer_scale * i/4,
base[1] + layer_scale * (j+1)/4 );
@@ -242,7 +250,7 @@ SGCloudLayer::rebuild()
}
sgSetVec3( vertex, layer_span*(i-1)/2, layer_span,
500 * (sin((i+1)*mpi) - 2) );
alt_diff * (sin((i+1)*mpi) - 2) );
sgSetVec2( tc, base[0] + layer_scale * (i+1)/4,
base[1] + layer_scale );
@@ -461,7 +469,9 @@ ssgSimpleState *sgCloudMakeState( const string &path ) {
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->setMaterial( GL_AMBIENT, 0.7, 0.7, 0.7, 1.0 );
state->setMaterial( GL_DIFFUSE, 0.9, 0.9, 0.9, 1.0 );
state->setMaterial( GL_SPECULAR, 1.0, 1.0, 1.0, 5.0 );
state->enable( GL_BLEND );
state->enable( GL_ALPHA_TEST );
state->setAlphaClamp( 0.01 );

View File

@@ -81,8 +81,9 @@ public:
* of the cloud layer. The elevation of the top of the layer is
* elevation_m + thickness_m.
* @param elevation_m the layer elevation in meters
* @param set_span defines whether it is allowed to adjust the span
*/
void setElevation_m (float elevation_m);
void setElevation_m (float elevation_m, bool set_span = true);
/** get the layer thickness */
float getThickness_m () const;