material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
panelStateSet->setAttribute(material);
- panelStateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON);
panelStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
panelStateSet->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));
if ( _enable_depth_test )
state.apply();
FGLight *l = (FGLight *)(globals->get_subsystem("lighting"));
- sgCopyVec4( panel_color, l->scene_diffuse());
+ sgCopyVec4( panel_color, l->scene_diffuse().data());
if ( fgGetDouble("/systems/electrical/outputs/instrument-lights") > 1.0 ) {
if ( panel_color[0] < 0.7 ) panel_color[0] = 0.7;
if ( panel_color[1] < 0.2 ) panel_color[1] = 0.2;
osg::Light* light = static_cast<osg::Light*>(stateAttribute);
FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting"));
- SGVec4f ambient(l->scene_ambient());
- light->setAmbient(ambient.osg());
- SGVec4f diffuse(l->scene_diffuse());
- light->setDiffuse(diffuse.osg());
- SGVec4f specular(l->scene_specular());
- light->setSpecular(specular.osg());
+ light->setAmbient(l->scene_ambient().osg());
+ light->setDiffuse(l->scene_diffuse().osg());
+ light->setSpecular(l->scene_specular().osg());
SGVec4f position(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2], 0);
light->setPosition(position.osg());
-
- light->setDirection(osg::Vec3(0, 0, -1));
+ SGVec3f direction(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2]);
+ light->setDirection(direction.osg());
light->setSpotExponent(0);
light->setSpotCutoff(180);
light->setConstantAttenuation(1);
static SGSkyColor scolor;
- scolor.sky_color = SGVec3f(l->sky_color());
- scolor.fog_color = SGVec3f(l->adj_fog_color());
- scolor.cloud_color = SGVec3f(l->cloud_color());
+ scolor.sky_color = SGVec3f(l->sky_color().data());
+ scolor.fog_color = SGVec3f(l->adj_fog_color().data());
+ scolor.cloud_color = SGVec3f(l->cloud_color().data());
scolor.sun_angle = l->get_sun_angle();
scolor.moon_angle = l->get_moon_angle();
scolor.nplanets = globals->get_ephem()->getNumPlanets();
_diffuse_tbl( NULL ),
_specular_tbl( NULL ),
_sky_tbl( NULL ),
+ _sun_lon(0),
+ _sun_gc_lat(0),
+ _moon_lon(0),
+ _moon_gc_lat(0),
+ _sunpos(0, 0, 0),
+ _moonpos(0, 0, 0),
+ _sun_vec(0, 0, 0, 0),
+ _moon_vec(0, 0, 0, 0),
+ _sun_vec_inv(0, 0, 0, 0),
+ _moon_vec_inv(0, 0, 0, 0),
_sun_angle(0),
_moon_angle(0),
- _prev_sun_angle(-9999.0),
- _sun_rotation( 0.0 ),
- _dt_total( 0.0 )
+ _prev_sun_angle(0),
+ _sun_rotation(0),
+ _moon_rotation(0),
+ _scene_ambient(0, 0, 0, 0),
+ _scene_diffuse(0, 0, 0, 0),
+ _scene_specular(0, 0, 0, 0),
+ _sky_color(0, 0, 0, 0),
+ _fog_color(0, 0, 0, 0),
+ _cloud_color(0, 0, 0, 0),
+ _adj_fog_color(0, 0, 0, 0),
+ _adj_sky_color(0, 0, 0, 0),
+ _dt_total(0)
{
}
_sky_color[1] = base_sky_color[1] * sky_brightness;
_sky_color[2] = base_sky_color[2] * sky_brightness;
_sky_color[3] = base_sky_color[3];
- gamma_correct_rgb( _sky_color );
+ gamma_correct_rgb( _sky_color.data() );
// set cloud and fog color
_cloud_color[0] = _fog_color[0] = base_fog_color[0] * sky_brightness;
_cloud_color[1] = _fog_color[1] = base_fog_color[1] * sky_brightness;
_cloud_color[2] = _fog_color[2] = base_fog_color[2] * sky_brightness;
_cloud_color[3] = _fog_color[3] = base_fog_color[3];
- gamma_correct_rgb( _fog_color );
+ gamma_correct_rgb( _fog_color.data() );
// adjust the cloud colors for sunrise/sunset effects (darken them)
if (_sun_angle > 1.0) {
_cloud_color[1] /= sun2;
_cloud_color[2] /= sun2;
}
- gamma_correct_rgb( _cloud_color );
+ gamma_correct_rgb( _cloud_color.data() );
SGVec4f sun_color = thesky->get_sun_color();
//
SGVec4f sun_color = thesky->get_sun_color();
- gamma_restore_rgb( _fog_color );
+ gamma_restore_rgb( _fog_color.data() );
// Calculate the fog color in the direction of the sun for
// sunrise/sunset effects.
_adj_fog_color[0] = rf3 * _fog_color[0] + rf2 * s_red;
_adj_fog_color[1] = rf3 * _fog_color[1] + rf2 * s_green;
_adj_fog_color[2] = rf3 * _fog_color[2] + rf2 * s_blue;
- gamma_correct_rgb( _adj_fog_color );
+ gamma_correct_rgb( _adj_fog_color.data() );
// make sure the colors have their original value before they are being
// used by the rest of the program.
//
- gamma_correct_rgb( _fog_color );
+ gamma_correct_rgb( _fog_color.data() );
}
SGVec3d _sunpos, _moonpos;
// (in view coordinates)
- sgVec4 _sun_vec, _moon_vec;
+ SGVec4f _sun_vec, _moon_vec;
// inverse (in view coordinates)
- sgVec4 _sun_vec_inv, _moon_vec_inv;
+ SGVec4f _sun_vec_inv, _moon_vec_inv;
// the angle between the celestial object and the local horizontal
// (in radians)
*/
// ambient, diffuse and specular component
- GLfloat _scene_ambient[4];
- GLfloat _scene_diffuse[4];
- GLfloat _scene_specular[4];
+ SGVec4f _scene_ambient;
+ SGVec4f _scene_diffuse;
+ SGVec4f _scene_specular;
// clear sky, fog and cloud color
- GLfloat _sky_color[4];
- GLfloat _fog_color[4];
- GLfloat _cloud_color[4];
+ SGVec4f _sky_color;
+ SGVec4f _fog_color;
+ SGVec4f _cloud_color;
// clear sky and fog color adjusted for sunset effects
- GLfloat _adj_fog_color[4];
- GLfloat _adj_sky_color[4];
+ SGVec4f _adj_fog_color;
+ SGVec4f _adj_sky_color;
double _dt_total;
// Color related functions
- inline float *scene_ambient () const { return (float *)_scene_ambient; }
- inline float *scene_diffuse () const { return (float *)_scene_diffuse; }
- inline float *scene_specular () const { return (float *)_scene_specular; }
+ inline const SGVec4f& scene_ambient () const { return _scene_ambient; }
+ inline const SGVec4f& scene_diffuse () const { return _scene_diffuse; }
+ inline const SGVec4f& scene_specular () const { return _scene_specular; }
- inline float *sky_color () const { return (float *)_sky_color; }
- inline float *cloud_color () const { return (float *)_cloud_color; }
- inline float *adj_fog_color () const { return (float *)_adj_fog_color; }
+ inline const SGVec4f& sky_color () const { return _sky_color; }
+ inline const SGVec4f& cloud_color () const { return _cloud_color; }
+ inline const SGVec4f& adj_fog_color () const { return _adj_fog_color; }
// Sun related functions
inline const SGVec3d& get_sunpos () const { return _sunpos; }
inline void set_sunpos (const SGVec3d& p) { _sunpos = p; }
- inline float *sun_vec () const { return (float *)_sun_vec; }
- inline float *sun_vec_inv () const { return (float *)_sun_vec_inv; }
+ inline SGVec4f& sun_vec () { return _sun_vec; }
+ inline SGVec4f& sun_vec_inv () { return _sun_vec_inv; }
// Moon related functions
inline const SGVec3d& get_moonpos () const { return _moonpos; }
inline void set_moonpos (const SGVec3d& p) { _moonpos = p; }
- inline float *moon_vec () const { return (float *)_moon_vec; }
- inline float *moon_vec_inv () const { return (float *)_moon_vec_inv; }
+ inline const SGVec4f& moon_vec () const { return _moon_vec; }
+ inline const SGVec4f& moon_vec_inv () const { return _moon_vec_inv; }
};
#endif // _LIGHT_HXX
<< " Geocentric lat = " << l->get_sun_gc_lat() );
// update the sun light vector
- sgSetVec4( l->sun_vec(), l->get_sunpos().x(),
+ sgSetVec4( l->sun_vec().data(), l->get_sunpos().x(),
l->get_sunpos().y(), l->get_sunpos().z(), 0.0 );
- sgNormalizeVec4( l->sun_vec() );
- sgCopyVec4( l->sun_vec_inv(), l->sun_vec() );
- sgNegateVec4( l->sun_vec_inv() );
+ sgNormalizeVec4( l->sun_vec().data() );
+ sgCopyVec4( l->sun_vec_inv().data(), l->sun_vec().data() );
+ sgNegateVec4( l->sun_vec_inv().data() );
// make sure these are directional light sources only
l->sun_vec()[3] = l->sun_vec_inv()[3] = 0.0;