assert(dynamic_cast<osg::Switch*>(node));
osg::Switch* sw = static_cast<osg::Switch*>(node);
- double t = globals->get_sim_time_sec();
- bool enabled = 0 < t;
+ bool enabled = scenery_enabled;
sw->setValue(0, enabled);
if (!enabled)
return;
traverse(node, nv);
}
+
+ static bool scenery_enabled;
};
+bool FGScenerySwitchCallback::scenery_enabled = false;
+
// Sky structures
SGSky *thesky;
static osg::ref_ptr<osg::Group> mRoot = new osg::Group;
+#ifdef FG_JPEG_SERVER
+static void updateRenderer()
+{
+ globals->get_renderer()->update();
+}
+#endif
+
FGRenderer::FGRenderer()
{
#ifdef FG_JPEG_SERVER
- jpgRenderFrame = FGRenderer::update;
+ jpgRenderFrame = updateRenderer;
#endif
eventHandler = new FGEventHandler;
- _splash_screen_active = true;
}
FGRenderer::~FGRenderer()
_xsize = fgGetNode("/sim/startup/xsize", true);
_ysize = fgGetNode("/sim/startup/ysize", true);
+ _splash_alpha = fgGetNode("/sim/startup/splash-alpha", true);
_skyblend = fgGetNode("/sim/rendering/skyblend", true);
_point_sprites = fgGetNode("/sim/rendering/point-sprites", true);
_cloud_status = fgGetNode("/environment/clouds/status", true);
_visibility_m = fgGetNode("/environment/visibility-m", true);
+
+ bool use_point_sprites = _point_sprites->getBoolValue();
+ bool enhanced_lighting = _enhanced_lighting->getBoolValue();
+ bool distance_attenuation = _distance_attenuation->getBoolValue();
+ SGConfigureDirectionalLights( use_point_sprites, enhanced_lighting,
+ distance_attenuation );
+}
+
+void
+FGRenderer::setupView( void )
+{
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
osg::initNotifyLevel();
stateSet->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON);
}
-void
-FGRenderer::update()
-{
- globals->get_renderer()->update(true);
-}
-
// Update all Visuals (redraws anything graphics related)
void
-FGRenderer::update( bool refresh_camera_settings ) {
- if ((!_scenery_loaded.get())||
- !(_scenery_loaded->getBoolValue() ||
+FGRenderer::update( ) {
+ if (!(_scenery_loaded->getBoolValue() ||
_scenery_override->getBoolValue()))
{
- // alas, first "update" is being called before "init"...
- fgSetDouble("/sim/startup/splash-alpha", 1.0);
- _splash_screen_active = true;
+ _splash_alpha->setDoubleValue(1.0);
return;
}
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
- if (_splash_screen_active)
+ if (_splash_alpha->getDoubleValue()>0.0)
{
// Fade out the splash screen
- double sAlpha = SGMiscd::max(0, (2.5 - globals->get_sim_time_sec()) / 2.5);
- _splash_screen_active = (sAlpha > 0.0);
- fgSetDouble("/sim/startup/splash-alpha", sAlpha);
+ const double fade_time = 0.8;
+ const double fade_steps_per_sec = 20;
+ double delay_time = SGMiscd::min(fade_time/fade_steps_per_sec,
+ (SGTimeStamp::now() - _splash_time).toSecs());
+ _splash_time = SGTimeStamp::now();
+ double sAlpha = _splash_alpha->getDoubleValue();
+ sAlpha -= SGMiscd::max(0.0,delay_time/fade_time);
+ FGScenerySwitchCallback::scenery_enabled = (sAlpha<1.0);
+ _splash_alpha->setDoubleValue(sAlpha);
}
- bool skyblend = _skyblend->getBoolValue();
- bool use_point_sprites = _point_sprites->getBoolValue();
- bool enhanced_lighting = _enhanced_lighting->getBoolValue();
- bool distance_attenuation = _distance_attenuation->getBoolValue();
-
- // OSGFIXME
- SGConfigureDirectionalLights( use_point_sprites, enhanced_lighting,
- distance_attenuation );
+#if 0 // OSGFIXME
+ // OSGFIXME: features no longer available or no longer run-time configurable
+ {
+ bool use_point_sprites = _point_sprites->getBoolValue();
+ bool enhanced_lighting = _enhanced_lighting->getBoolValue();
+ bool distance_attenuation = _distance_attenuation->getBoolValue();
+
+ SGConfigureDirectionalLights( use_point_sprites, enhanced_lighting,
+ distance_attenuation );
+ }
+#endif
FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting"));
FGViewer *current__view = globals->get_current_view();
// Force update of center dependent values ...
current__view->set_dirty();
-
- if ( refresh_camera_settings ) {
- // update view port
- resize( _xsize->getIntValue(),
- _ysize->getIntValue() );
- }
+
osg::Camera *camera = viewer->getCamera();
+ bool skyblend = _skyblend->getBoolValue();
if ( skyblend ) {
if ( _textures->getBoolValue() ) {
CameraGroup::getDefault()->setCameraCullMasks(cullMask);
}
-
-
-// options.cxx needs to see this for toggle_panel()
-// Handle new window size or exposure
void
-FGRenderer::resize( int width, int height ) {
- int view_h;
-
- if ( (!_virtual_cockpit->getBoolValue())
- && fgPanelVisible() && idle_state == 1000 ) {
- view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
- globals->get_current_panel()->getYOffset()) / 768.0);
- } else {
- view_h = height;
- }
-
- static int lastwidth = 0;
- static int lastheight = 0;
- if (width != lastwidth)
- _xsize->setIntValue(lastwidth = width);
- if (height != lastheight)
- _ysize->setIntValue(lastheight = height);
-
- // for all views
- FGViewMgr *viewmgr = globals->get_viewmgr();
- if (viewmgr) {
- for ( int i = 0; i < viewmgr->size(); ++i ) {
- viewmgr->get_view(i)->
- set_aspect_ratio((float)view_h / (float)width);
- }
+FGRenderer::resize( int width, int height )
+{
+ int curWidth = _xsize->getIntValue(),
+ curHeight = _ysize->getIntValue();
+ if ((curHeight != height) || (curWidth != width)) {
+ // must guard setting these, or PLIB-PUI fails with too many live interfaces
+ _xsize->setIntValue(width);
+ _ysize->setIntValue(height);
}
}