hint->setMode(GL_DONT_CARE);
}
private:
- SGSharedPtr<SGPropertyNode> mConfigNode;
+ SGPropertyNode_ptr mConfigNode;
};
class FGWireFrameModeUpdateCallback : public osg::StateAttribute::Callback {
public:
FGWireFrameModeUpdateCallback() :
- mWireframe(fgGetNode("/sim/rendering/wireframe"))
+ mWireframe(fgGetNode("/sim/rendering/wireframe", true))
{ }
virtual void operator()(osg::StateAttribute* stateAttribute,
osg::NodeVisitor*)
osg::PolygonMode::FILL);
}
private:
- SGSharedPtr<SGPropertyNode> mWireframe;
+ SGPropertyNode_ptr mWireframe;
};
class FGLightModelUpdateCallback : public osg::StateAttribute::Callback {
public:
FGLightModelUpdateCallback() :
- mHighlights(fgGetNode("/sim/rendering/specular-highlight"))
+ mHighlights(fgGetNode("/sim/rendering/specular-highlight", true))
{ }
virtual void operator()(osg::StateAttribute* stateAttribute,
osg::NodeVisitor*)
}
}
private:
- SGSharedPtr<SGPropertyNode> mHighlights;
+ SGPropertyNode_ptr mHighlights;
};
class FGFogEnableUpdateCallback : public osg::StateSet::Callback {
public:
FGFogEnableUpdateCallback() :
- mFogEnabled(fgGetNode("/sim/rendering/fog"))
+ mFogEnabled(fgGetNode("/sim/rendering/fog", true))
{ }
virtual void operator()(osg::StateSet* stateSet, osg::NodeVisitor*)
{
}
}
private:
- SGSharedPtr<SGPropertyNode> mFogEnabled;
+ SGPropertyNode_ptr mFogEnabled;
};
class FGFogUpdateCallback : public osg::StateAttribute::Callback {
jpgRenderFrame = FGRenderer::update;
#endif
eventHandler = new FGEventHandler;
+ _splash_screen_active = true;
}
FGRenderer::~FGRenderer()
// visitor automatically.
mUpdateVisitor->setFrameStamp(mFrameStamp.get());
viewer->setUpdateVisitor(mUpdateVisitor.get());
+ fgSetDouble("/sim/startup/splash-alpha", 1.0);
}
void
FGRenderer::init( void )
{
+ _scenery_loaded = fgGetNode("/sim/sceneryloaded", true);
+ _scenery_override = fgGetNode("/sim/sceneryloaded-override", true);
+ _panel_hotspots = fgGetNode("/sim/panel-hotspots", true);
+ _virtual_cockpit = fgGetNode("/sim/virtual-cockpit", true);
+
+ _sim_delta_sec = fgGetNode("/sim/time/delta-sec", true);
+
+ _xsize = fgGetNode("/sim/startup/xsize", true);
+ _ysize = fgGetNode("/sim/startup/ysize", true);
+
+ _skyblend = fgGetNode("/sim/rendering/skyblend", true);
+ _point_sprites = fgGetNode("/sim/rendering/point-sprites", true);
+ _enhanced_lighting = fgGetNode("/sim/rendering/enhanced-lighting", true);
+ _distance_attenuation = fgGetNode("/sim/rendering/distance-attenuation", true);
+ _horizon_effect = fgGetNode("/sim/rendering/horizon-effect", true);
+ _textures = fgGetNode("/sim/rendering/textures", true);
+
+ _altitude_ft = fgGetNode("/position/altitude-ft", true);
+
+ _cloud_status = fgGetNode("/environment/clouds/status", true);
+ _visibility_m = fgGetNode("/environment/visibility-m", true);
+
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 ) {
- bool scenery_loaded = fgGetBool("sim/sceneryloaded", false)
- || fgGetBool("sim/sceneryloaded-override");
+ if ((!_scenery_loaded.get())||
+ !(_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;
+ return;
+ }
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
- if (!scenery_loaded) {
- fgSetDouble("/sim/startup/splash-alpha", 1.0);
- return;
+
+ if (_splash_screen_active)
+ {
+ // 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);
}
- // Fade out the splash screen over the first three seconds.
- double sAlpha = SGMiscd::max(0, (2.5 - globals->get_sim_time_sec()) / 2.5);
- fgSetDouble("/sim/startup/splash-alpha", sAlpha);
+ bool skyblend = _skyblend->getBoolValue();
+ bool use_point_sprites = _point_sprites->getBoolValue();
+ bool enhanced_lighting = _enhanced_lighting->getBoolValue();
+ bool distance_attenuation = _distance_attenuation->getBoolValue();
- bool skyblend = fgGetBool("/sim/rendering/skyblend");
- bool use_point_sprites = fgGetBool("/sim/rendering/point-sprites");
- bool enhanced_lighting = fgGetBool("/sim/rendering/enhanced-lighting");
- bool distance_attenuation
- = fgGetBool("/sim/rendering/distance-attenuation");
// OSGFIXME
SGConfigureDirectionalLights( use_point_sprites, enhanced_lighting,
distance_attenuation );
// update fog params
double actual_visibility;
- if (fgGetBool("/environment/clouds/status")) {
+ if (_cloud_status->getBoolValue()) {
actual_visibility = thesky->get_visibility();
} else {
- actual_visibility = fgGetDouble("/environment/visibility-m");
+ actual_visibility = _visibility_m->getDoubleValue();
}
// idle_state is now 1000 meaning we've finished all our
if ( refresh_camera_settings ) {
// update view port
- resize( fgGetInt("/sim/startup/xsize"),
- fgGetInt("/sim/startup/ysize") );
+ resize( _xsize->getIntValue(),
+ _ysize->getIntValue() );
}
osg::Camera *camera = viewer->getCamera();
if ( skyblend ) {
- if ( fgGetBool("/sim/rendering/textures") ) {
+ if ( _textures->getBoolValue() ) {
SGVec4f clearColor(l->adj_fog_color());
camera->setClearColor(toOsg(clearColor));
}
}
// update fog params if visibility has changed
- double visibility_meters = fgGetDouble("/environment/visibility-m");
+ double visibility_meters = _visibility_m->getDoubleValue();
thesky->set_visibility(visibility_meters);
- double altitude_m = fgGetDouble("/position/altitude-ft") * SG_FEET_TO_METER;
+ double altitude_m = _altitude_ft->getDoubleValue() * SG_FEET_TO_METER;
thesky->modify_vis( altitude_m, 0.0 /* time factor, now unused */);
// update the sky dome
// Sun distance: 150,000,000 kilometers
double sun_horiz_eff, moon_horiz_eff;
- if (fgGetBool("/sim/rendering/horizon-effect")) {
+ if (_horizon_effect->getBoolValue()) {
sun_horiz_eff
= 0.67 + pow(osg::clampAbove(0.5 + cos(l->get_sun_angle()),
0.0),
scolor.sun_angle = l->get_sun_angle();
scolor.moon_angle = l->get_moon_angle();
- double delta_time_sec = fgGetDouble("/sim/time/delta-sec");
+ double delta_time_sec = _sim_delta_sec->getDoubleValue();
thesky->reposition( sstate, *globals->get_ephem(), delta_time_sec );
thesky->repaint( scolor, *globals->get_ephem() );
l->get_sun_angle()*SGD_RADIANS_TO_DEGREES);
mUpdateVisitor->setVisibility(actual_visibility);
simgear::GroundLightManager::instance()->update(mUpdateVisitor.get());
- bool hotspots = fgGetBool("/sim/panel-hotspots");
osg::Node::NodeMask cullMask = ~simgear::LIGHTS_BITS & ~simgear::PICK_BIT;
cullMask |= simgear::GroundLightManager::instance()
->getLightNodeMask(mUpdateVisitor.get());
- if (hotspots)
+ if (_panel_hotspots->getBoolValue())
cullMask |= simgear::PICK_BIT;
CameraGroup::getDefault()->setCameraCullMasks(cullMask);
}
FGRenderer::resize( int width, int height ) {
int view_h;
- if ( (!fgGetBool("/sim/virtual-cockpit"))
+ if ( (!_virtual_cockpit->getBoolValue())
&& fgPanelVisible() && idle_state == 1000 ) {
view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
globals->get_current_panel()->getYOffset()) / 768.0);
static int lastwidth = 0;
static int lastheight = 0;
if (width != lastwidth)
- fgSetInt("/sim/startup/xsize", lastwidth = width);
+ _xsize->setIntValue(lastwidth = width);
if (height != lastheight)
- fgSetInt("/sim/startup/ysize", lastheight = height);
+ _ysize->setIntValue(lastheight = height);
// for all views
FGViewMgr *viewmgr = globals->get_viewmgr();
#define __FG_RENDERER_HXX 1
#include <simgear/scene/util/SGPickCallback.hxx>
+#include <simgear/props/props.hxx>
#include <osg/ref_ptr>
void splashinit();
void init();
- static void resize(int width, int height );
+ void resize(int width, int height );
// calling update( refresh_camera_settings = false ) will not
// touch window or camera settings. This is useful for the tiled
// renderer which needs to set the view frustum itself.
- static void update( bool refresh_camera_settings );
- inline static void update() { update( true ); }
+ void update( bool refresh_camera_settings);
+ static void update();
/** Just pick into the scene and return the pick callbacks on the way ...
*/
- static bool pick( std::vector<SGSceneryPick>& pickList,
- const osgGA::GUIEventAdapter* ea );
+ bool pick( std::vector<SGSceneryPick>& pickList,
+ const osgGA::GUIEventAdapter* ea );
/** Get and set the OSG Viewer object, if any.
*/
protected:
osg::ref_ptr<osgViewer::Viewer> viewer;
osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
+ SGPropertyNode_ptr _scenery_loaded,_scenery_override;
+ SGPropertyNode_ptr _skyblend;
+ SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
+ SGPropertyNode_ptr _textures;
+ SGPropertyNode_ptr _cloud_status, _visibility_m;
+ SGPropertyNode_ptr _xsize, _ysize;
+ SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
+ SGPropertyNode_ptr _virtual_cockpit;
+ bool _splash_screen_active;
};
bool fgDumpSceneGraphToFile(const char* filename);