forked from speed-dreams/speed-dreams-code
update Sky code
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4763 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 729784c12b72dbb0c6d56363de36d4ede3666366 Former-commit-id: 5d7b0908b7ad06f958889f5af64c30130cca288a
This commit is contained in:
parent
fd7c89cd8b
commit
9c42b66c79
5 changed files with 31 additions and 31 deletions
|
@ -101,7 +101,7 @@ void cGrSky::build( double h_radius, double v_radius,
|
|||
moon = new cGrMoon;
|
||||
moon_transform ->addKid( moon->build( moon_size));
|
||||
moon->setMoonDist(moon_dist);
|
||||
|
||||
|
||||
planets = new cGrStars;
|
||||
stars_transform -> addKid( planets->build( nplanets, planet_data, h_radius ) );
|
||||
|
||||
|
@ -146,24 +146,23 @@ cGrSky::addCloud( ssgSimpleState *cloud_state, float span, float elevation, floa
|
|||
bool cGrSky::repositionFlat( sgVec3 view_pos, double spin, double dt )
|
||||
{
|
||||
int i;
|
||||
double angle;
|
||||
double rotation;
|
||||
double angle, angle2;
|
||||
double rotation, rotation2;
|
||||
sgCoord pos;
|
||||
|
||||
|
||||
sun->reposition( view_pos, 0 );
|
||||
moon->reposition( view_pos, 0 );
|
||||
sgCoord pos2;
|
||||
|
||||
// Calc angles for rise/set effects
|
||||
sun->reposition( view_pos, 0 );
|
||||
sun->getSunPosition ( &pos );
|
||||
calc_celestial_angles( pos.xyz, view_pos, angle, rotation );
|
||||
sun->setSunAngle( angle );
|
||||
sun->setSunRotation( rotation );
|
||||
|
||||
moon->getMoonPosition(&pos);
|
||||
calc_celestial_angles( pos.xyz, view_pos, angle, rotation );
|
||||
moon->setMoonAngle( angle );
|
||||
moon->setMoonRotation( rotation );
|
||||
moon->reposition( view_pos, 0 );
|
||||
moon->getMoonPosition(&pos2);
|
||||
calc_celestial_angles( pos2.xyz, view_pos, angle2, rotation2 );
|
||||
moon->setMoonAngle( angle2 );
|
||||
moon->setMoonRotation( rotation2 );
|
||||
|
||||
for ( i = 0; i < clouds.getNum (); i++ )
|
||||
{
|
||||
|
@ -175,11 +174,11 @@ bool cGrSky::repositionFlat( sgVec3 view_pos, double spin, double dt )
|
|||
|
||||
/*if ( sol_ref )
|
||||
{*/
|
||||
dome->repositionFlat( view_pos, sun->getSunRotation() );
|
||||
//dome->repositionFlat( view_pos, sun->getSunRotation() );
|
||||
/*}
|
||||
else
|
||||
{*/
|
||||
//dome->repositionFlat( view_pos, spin );
|
||||
dome->repositionFlat( view_pos, spin );
|
||||
//}
|
||||
|
||||
return true;
|
||||
|
@ -207,7 +206,7 @@ bool cGrSky::reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up, doub
|
|||
|
||||
|
||||
bool cGrSky::repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color, double sol_angle,
|
||||
int nplanets, sgdVec3 *planet_data,
|
||||
double moon_angle, int nplanets, sgdVec3 *planet_data,
|
||||
int nstars, sgdVec3 *star_data )
|
||||
{
|
||||
int i;
|
||||
|
@ -223,7 +222,7 @@ bool cGrSky::repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color, do
|
|||
clouds.get(i)->repaint( cloud_color );
|
||||
|
||||
sun->repaint( sol_angle, effective_visibility );
|
||||
moon->repaint( sol_angle );
|
||||
moon->repaint( moon_angle );
|
||||
planets->repaint( sol_angle, nplanets, planet_data );
|
||||
stars->repaint( sol_angle, nstars, star_data );
|
||||
}
|
||||
|
|
|
@ -289,7 +289,7 @@ public:
|
|||
double getSunDistance() { return sun_dist; }
|
||||
|
||||
// retrun the current color of the sun
|
||||
inline float *get_color() { return ihalo_cl->get( 0 ); }
|
||||
inline float *get_color() { return ohalo_cl->get( 0 ); }
|
||||
double effective_visibility;
|
||||
};
|
||||
|
||||
|
@ -400,7 +400,7 @@ public:
|
|||
bool repositionFlat( sgVec3 view_pos, double spin, double dt );
|
||||
bool reposition( sgVec3 view_pos, sgVec3 zero_elev, sgVec3 view_up, double lon, double lat, double alt, double spin, double gst, double dt );
|
||||
|
||||
bool repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color, double sol_angle,
|
||||
bool repaint( sgVec4 sky_color, sgVec4 fog_color, sgVec4 cloud_color, double sol_angle, double moon_angle,
|
||||
int nplanets, sgdVec3 *planet_data,
|
||||
int nstars, sgdVec3 *star_data );
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ ssgBranch * cGrSun::build( double sun_size )
|
|||
ihalo->setState( ihalo_state );
|
||||
|
||||
ohalo_state = new ssgSimpleState();
|
||||
ohalo_state->setTexture( "data/textures/halo.rgba" );
|
||||
ohalo_state->setTexture( "data/textures/halo.png" );
|
||||
ohalo_state->enable( GL_TEXTURE_2D );
|
||||
ohalo_state->disable( GL_LIGHTING );
|
||||
ohalo_state->setShadeModel( GL_SMOOTH );
|
||||
|
@ -212,10 +212,13 @@ bool cGrSun::repaint( double sun_angle, double new_visibility )
|
|||
{
|
||||
if ( visibility != new_visibility )
|
||||
{
|
||||
if (new_visibility < 100.0) new_visibility = 100.0;
|
||||
else if (new_visibility > 45000.0) new_visibility = 45000.0;
|
||||
visibility = new_visibility;
|
||||
|
||||
static const float sqrt_m_log01 = sqrt( -log( 0.01 ) );
|
||||
sun_exp2_punch_through = sqrt_m_log01 / ( visibility * 15 );
|
||||
//sun_exp2_punch_through = 2.0/log(visibility);
|
||||
}
|
||||
|
||||
if ( prev_sun_angle != sun_angle )
|
||||
|
@ -308,11 +311,9 @@ bool cGrSun::repaint( double sun_angle, double new_visibility )
|
|||
if ( o_halo_color[3] < 0 ) o_halo_color[3] = 0;
|
||||
else if ( o_halo_color[3] > 1) o_halo_color[3] = 1;
|
||||
|
||||
|
||||
grGammaCorrectRGB( sun_color );
|
||||
grGammaCorrectRGB( i_halo_color );
|
||||
grGammaCorrectRGB( o_halo_color );
|
||||
grGammaCorrectRGB( sun_color );
|
||||
|
||||
|
||||
float *ptr;
|
||||
ptr = sun_cl->get( 0 );
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <portability.h> // snprintf
|
||||
#include <glfeatures.h>
|
||||
|
||||
//#include <plib/ssgAux.h>
|
||||
#include <plib/ssgAux.h>
|
||||
|
||||
#include "grscene.h"
|
||||
#include "grloadac.h"
|
||||
|
@ -88,7 +88,7 @@ static bool grDynamicSkyDome = false;
|
|||
static int grBackgroundType = 0;
|
||||
static float grSunDeclination = 0.0f;
|
||||
static float grMoonDeclination = 0.0f;
|
||||
unsigned Visibility = 0;
|
||||
static double Visibility = 0.0f;
|
||||
|
||||
static ssgBranch *SunAnchor = NULL;
|
||||
|
||||
|
@ -105,7 +105,6 @@ static sgVec4 SkyColor;
|
|||
static sgVec4 BaseFogColor;
|
||||
static sgVec4 FogColor;
|
||||
static sgVec4 CloudsColor;
|
||||
static sgVec4 CloudsColor2;
|
||||
|
||||
static sgVec4 SceneAmbiant;
|
||||
static sgVec4 SceneDiffuse;
|
||||
|
@ -172,14 +171,14 @@ grInitBackground()
|
|||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/*if (!TheSun && grTrack->local.rain == 0)
|
||||
if (!TheSun && grTrack->local.rain == 0)
|
||||
{
|
||||
ssgaLensFlare *sun_obj = new ssgaLensFlare();
|
||||
TheSun = new ssgTransform;
|
||||
TheSun->setTransform(lightPosition);
|
||||
TheSun->addKid(sun_obj);
|
||||
SunAnchor->addKid(TheSun);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
// If realistic sky dome is requested,
|
||||
|
@ -1022,16 +1021,17 @@ void grUpdateLight( void )
|
|||
const float sol_angle = (float)TheSky->getSA();
|
||||
const float moon_angle = (float)TheSky->getMA();
|
||||
GfLogInfo(" Sun Angle = %f - Moon Angle = %f\n", sol_angle, moon_angle);
|
||||
const float sky_brightness = (float)(1.0 + cos(sol_angle)) / 2.0f;
|
||||
float sky_brightness = (float)(1.0 + cos(sol_angle)) / 2.0f;
|
||||
float scene_brightness = (float)pow(sky_brightness, 0.5f);
|
||||
|
||||
if (grTrack->local.rain > 0) // TODO: Different values for each rain strength value ?
|
||||
{
|
||||
BaseFogColor[0] = 0.42f;
|
||||
BaseFogColor[1] = 0.40f;
|
||||
BaseFogColor[1] = 0.44f;
|
||||
BaseFogColor[2] = 0.50f;
|
||||
|
||||
scene_brightness = scene_brightness / 2.0f;
|
||||
sky_brightness = (float)pow(sky_brightness, 0.1f);
|
||||
scene_brightness = scene_brightness / 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1079,7 +1079,7 @@ void grUpdateLight( void )
|
|||
grGammaCorrectRGB( CloudsColor );
|
||||
|
||||
// 3b) repaint the sky (simply update geometrical, color, ... state, no actual redraw)
|
||||
TheSky->repaint(SkyColor, FogColor, CloudsColor, sol_angle,
|
||||
TheSky->repaint(SkyColor, FogColor, CloudsColor, sol_angle, moon_angle,
|
||||
NPlanets, APlanetsData, NStars, AStarsData);
|
||||
|
||||
// 3c) update the main light position (it's at the sun position !)
|
||||
|
|
|
@ -42,7 +42,7 @@ extern void grDrawStaticBackground(class cGrCamera *cam, class cGrBackgroundCam
|
|||
extern void grShutdownBackground(void);
|
||||
|
||||
extern unsigned grSkyDomeDistance; // 0 means no sky dome (static background).
|
||||
extern unsigned Visibility;
|
||||
extern double Visibility;
|
||||
extern const tdble grSkyDomeNeutralFOVDistance;
|
||||
|
||||
#endif //_GRBACKGROUND_H_
|
||||
|
|
Loading…
Reference in a new issue