# include <config.h>
#endif
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
#include <simgear/compiler.h>
#include <osg/ref_ptr>
#include <osg/LightModel>
#include <osg/LightSource>
#include <osg/Material>
+#include <osg/Math>
#include <osg/NodeCallback>
#include <osg/Notify>
#include <osg/PolygonMode>
#include <osg/PolygonOffset>
-#include <osg/ShadeModel>
#include <osg/Version>
#include <osg/TexEnv>
-#include <osgUtil/SceneView>
-#include <osgUtil/UpdateVisitor>
-#include <osgUtil/IntersectVisitor>
#include <osgUtil/LineSegmentIntersector>
#include <osg/io_utils>
#include <osgDB/WriteFile>
-#include <osgDB/ReadFile>
-#include <sstream>
#include <simgear/math/SGMath.hxx>
#include <simgear/screen/extensions.hxx>
#include "renderer.hxx"
#include "main.hxx"
#include "CameraGroup.hxx"
-#include "ViewPartitionNode.hxx"
+#include "FGEventHandler.hxx"
// XXX Make this go away when OSG 2.2 is released.
#if (FG_OSG_VERSION >= 21004)
#define UPDATE_VISITOR_IN_VIEWER 1
#endif
+using namespace osg;
+using namespace simgear;
using namespace flightgear;
class FGHintUpdateCallback : public osg::StateAttribute::Callback {
static osg::ref_ptr<osg::Group> mRoot = new osg::Group;
-static osg::ref_ptr<ViewPartitionNode> viewPartition = new ViewPartitionNode;
-
FGRenderer::FGRenderer()
{
#ifdef FG_JPEG_SERVER
jpgRenderFrame = FGRenderer::update;
#endif
- manipulator = new FGManipulator;
+ eventHandler = new FGEventHandler;
}
FGRenderer::~FGRenderer()
//sceneGroup->addChild(thesky->getCloudRoot());
stateSet = sceneGroup->getOrCreateStateSet();
- stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
// need to update the light on every frame
mRoot->addChild(lightSource);
stateSet = globals->get_scenery()->get_scene_graph()->getOrCreateStateSet();
- stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
osg::Switch* sw = new osg::Switch;
sw->setUpdateCallback(new FGScenerySwitchCallback);
sw->addChild(mRoot.get());
- viewPartition->addChild(sw);
- viewPartition->addChild(thesky->getCloudRoot());
-
- mRealRoot->addChild(viewPartition.get());
+ mRealRoot->addChild(sw);
+ mRealRoot->addChild(thesky->getCloudRoot());
mRealRoot->addChild(FGCreateRedoutNode());
}
// update view port
resize( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") );
-#if 0
- SGVec3d position = current__view->getViewPosition();
- SGQuatd attitude = current__view->getViewOrientation();
-
- FGManipulator *manipulator = globals->get_renderer()->getManipulator();
- manipulator->setPosition(position.osg());
- manipulator->setAttitude(attitude.osg());
-#endif
}
osg::Camera *camera = viewer->getCamera();
double sun_horiz_eff, moon_horiz_eff;
if (fgGetBool("/sim/rendering/horizon-effect")) {
- sun_horiz_eff = 0.67+pow(0.5+cos(l->get_sun_angle())*2/2, 0.33)/3;
- moon_horiz_eff = 0.67+pow(0.5+cos(l->get_moon_angle())*2/2, 0.33)/3;
+ sun_horiz_eff
+ = 0.67 + pow(osg::clampAbove(0.5 + cos(l->get_sun_angle()),
+ 0.0),
+ 0.33) / 3.0;
+ moon_horiz_eff
+ = 0.67 + pow(osg::clampAbove(0.5 + cos(l->get_moon_angle()),
+ 0.0),
+ 0.33)/3.0;
} else {
sun_horiz_eff = moon_horiz_eff = 1.0;
}
}
// sgEnviro.setLight(l->adj_fog_color());
-#if 0
- double agl = current__view->getAltitudeASL_ft()*SG_FEET_TO_METER
- - current__view->getSGLocation()->get_cur_elev_m();
-
- float scene_nearplane, scene_farplane;
- // XXX Given that the own airplane model is part of the scene
- // graph, should this business be ripped out? The near plane is
- // ignored by setCameraParameters.
- if ( agl > 10.0 ) {
- scene_nearplane = 10.0f;
- scene_farplane = 120000.0f;
- } else {
- scene_nearplane = groundlevel_nearplane->getDoubleValue();
- scene_farplane = 120000.0f;
- }
- setCameraParameters(current__view->get_v_fov(),
- current__view->get_aspect_ratio(),
- scene_nearplane, scene_farplane);
-#endif
// sgEnviro.startOfFrame(current__view->get_view_pos(),
// current__view->get_world_up(),
// current__view->getLongitude_deg(),
l->adj_fog_color(),
l->get_sun_angle()*SGD_RADIANS_TO_DEGREES);
mUpdateVisitor->setVisibility(actual_visibility);
- viewPartition->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
- & ~simgear::BACKGROUND_BIT);
+ osg::Node::NodeMask cullMask = ~simgear::LIGHTS_BITS & ~simgear::PICK_BIT;
cullMask |= simgear::GroundLightManager::instance()
->getLightNodeMask(mUpdateVisitor.get());
if (hotspots)
cullMask |= simgear::PICK_BIT;
- camera->setCullMask(cullMask);
- // XXX
- for (int i = 0; i < viewer->getNumSlaves(); ++i)
- viewer->getSlave(i)._camera->setCullMask(cullMask);
+ CameraGroup::getDefault()->setCameraCullMasks(cullMask);
}
return !pickList.empty();
}
+void
+FGRenderer::setViewer(osgViewer::Viewer* viewer_)
+{
+ viewer = viewer_;
+}
+
+void
+FGRenderer::setEventHandler(FGEventHandler* eventHandler_)
+{
+ eventHandler = eventHandler_;
+}
+
void
FGRenderer::addCamera(osg::Camera* camera, bool useSceneData)
{