Make Compositor default
- Removed the ENABLE_COMPOSITOR CMake flag. - Removed /sim/version/compositor-support. - Removed miscellaneous branching to check if the Compositor is enabled. - Removed custom resource loader since Compositor Effects are now located in $FG_ROOT/Effects. - Removed splash screen warning. - Only use the Compositor versions of CameraGroup and FGRenderer. - Fix redout/blackout not appearing under certain circumstances.
This commit is contained in:
parent
1c923ea1d0
commit
255d193bc8
19 changed files with 432 additions and 4502 deletions
|
@ -191,7 +191,6 @@ option(ENABLE_FGQCANVAS "Set to ON to build the Qt-based remote canvas applicat
|
|||
option(ENABLE_DEMCONVERT "Set to ON to build the dem conversion tool (default)" ON)
|
||||
option(ENABLE_HID_INPUT "Set to ON to build HID-based input code" ${EVENT_INPUT_DEFAULT})
|
||||
option(ENABLE_PLIB_JOYSTICK "Set to ON to enable legacy joystick code (default)" ON)
|
||||
option(ENABLE_COMPOSITOR "Set to ON to enable the Compositor-based Viewer" OFF)
|
||||
option(ENABLE_SWIFT "Set to ON to build the swift module" ON)
|
||||
|
||||
|
||||
|
|
|
@ -125,11 +125,7 @@ LauncherMainWindow::LauncherMainWindow(bool inSimMode) : QQuickView()
|
|||
ctx->setContextProperty("_addOns", addOnsCtl);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_COMPOSITOR)
|
||||
ctx->setContextProperty("_haveCompositor", true);
|
||||
#else
|
||||
ctx->setContextProperty("_haveCompositor", false);
|
||||
#endif
|
||||
|
||||
auto weatherScenariosModel = new flightgear::WeatherScenariosModel(this);
|
||||
ctx->setContextProperty("_weatherScenarios", weatherScenariosModel);
|
||||
|
|
|
@ -69,8 +69,6 @@
|
|||
|
||||
#cmakedefine HAVE_QRC_TRANSLATIONS
|
||||
|
||||
#cmakedefine ENABLE_COMPOSITOR
|
||||
|
||||
#cmakedefine ENABLE_SWIFT
|
||||
|
||||
#cmakedefine HAVE_SENTRY
|
||||
|
|
|
@ -134,17 +134,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class CompositorEffectsProvider : public simgear::ResourceProvider {
|
||||
public:
|
||||
CompositorEffectsProvider() :
|
||||
simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_NORMAL) {
|
||||
}
|
||||
SGPath resolve(const std::string &aResource, SGPath&) const override {
|
||||
const SGPath p = globals->get_fg_root() / "Compositor" / aResource;
|
||||
return p.exists() ? p : SGPath();
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of FGGlobals.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -176,9 +165,6 @@ FGGlobals::FGGlobals() :
|
|||
resMgr->addProvider(new AircraftResourceProvider());
|
||||
resMgr->addProvider(new CurrentAircraftDirProvider());
|
||||
resMgr->addProvider(new flightgear::addons::ResourceProvider());
|
||||
#ifdef ENABLE_COMPOSITOR
|
||||
resMgr->addProvider(new CompositorEffectsProvider());
|
||||
#endif
|
||||
initProperties();
|
||||
}
|
||||
|
||||
|
|
|
@ -250,12 +250,6 @@ void fgSetDefaults ()
|
|||
v->setValueReadOnly("build-id", JENKINS_BUILD_ID);
|
||||
v->setValueReadOnly("hla-support", bool(FG_HAVE_HLA));
|
||||
v->setValueReadOnly("build-type", FG_BUILD_TYPE);
|
||||
#ifdef ENABLE_COMPOSITOR
|
||||
static constexpr bool compositor_support = true;
|
||||
#else
|
||||
static constexpr bool compositor_support = false;
|
||||
#endif
|
||||
v->setValueReadOnly("compositor-support", compositor_support);
|
||||
|
||||
char* envp = ::getenv( "http_proxy" );
|
||||
if( envp != nullptr )
|
||||
|
|
|
@ -81,6 +81,7 @@ osg::Node* FGCreateRedoutNode()
|
|||
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
|
||||
stateSet->setAttribute(new osg::Depth(osg::Depth::ALWAYS, 0, 1, false));
|
||||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
stateSet->setRenderBinDetails(1000, "RenderBin");
|
||||
|
||||
osg::Vec3Array* vertexArray = new osg::Vec3Array;
|
||||
vertexArray->push_back(osg::Vec3(-1, -1, 0));
|
||||
|
@ -101,7 +102,7 @@ osg::Node* FGCreateRedoutNode()
|
|||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
camera->setProjectionMatrix(osg::Matrix::ortho2D(-1, 1, -1, 1));
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
camera->setRenderOrder(osg::Camera::POST_RENDER, 99);
|
||||
camera->setRenderOrder(osg::Camera::NESTED_RENDER);
|
||||
camera->setClearMask(0);
|
||||
camera->setAllowEventFocus(false);
|
||||
camera->setCullingActive(false);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
include(FlightGearComponent)
|
||||
|
||||
set(SOURCES
|
||||
CameraGroup.cxx
|
||||
FGEventHandler.cxx
|
||||
WindowBuilder.cxx
|
||||
WindowSystemAdapter.cxx
|
||||
fg_os_osgviewer.cxx
|
||||
fgviewer.cxx
|
||||
ViewPropertyEvaluator.cxx
|
||||
renderer.cxx
|
||||
splash.cxx
|
||||
view.cxx
|
||||
viewmgr.cxx
|
||||
|
@ -36,12 +38,4 @@ if (YES)
|
|||
list(APPEND SOURCES PUICamera.cxx)
|
||||
endif()
|
||||
|
||||
if (ENABLE_COMPOSITOR)
|
||||
list(APPEND SOURCES CameraGroup_compositor.cxx renderer_compositor.cxx)
|
||||
list(APPEND HEADERS CameraGroup_compositor.hxx renderer_compositor.hxx)
|
||||
else ()
|
||||
list(APPEND SOURCES CameraGroup_legacy.cxx renderer_legacy.cxx renderingpipeline.cxx)
|
||||
list(APPEND HEADERS CameraGroup_legacy.hxx renderer_legacy.hxx renderingpipeline.hxx)
|
||||
endif()
|
||||
|
||||
flightgear_component(Viewer "${SOURCES}" "${HEADERS}")
|
||||
|
|
|
@ -1,14 +1,241 @@
|
|||
#ifndef COMMON_CAMERAGROUP_HXX
|
||||
#define COMMON_CAMERAGROUP_HXX
|
||||
// Copyright (C) 2008 Tim Moore
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#ifndef CAMERAGROUP_HXX
|
||||
#define CAMERAGROUP_HXX 1
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <osg/Matrix>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Referenced>
|
||||
#include <osg/Node>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexGen>
|
||||
#include <osgUtil/RenderBin>
|
||||
|
||||
#include <simgear/scene/viewer/Compositor.hxx>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Camera;
|
||||
}
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
class SGPropertyNode;
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
|
||||
class CameraGroupListener;
|
||||
class GraphicsWindow;
|
||||
|
||||
/** A wrapper around osg::Camera that contains some extra information.
|
||||
*/
|
||||
struct CameraInfo : public osg::Referenced
|
||||
{
|
||||
/** properties of a camera.
|
||||
*/
|
||||
enum Flags
|
||||
{
|
||||
VIEW_ABSOLUTE = 0x1, /**< The camera view is absolute, not
|
||||
relative to the master camera. */
|
||||
PROJECTION_ABSOLUTE = 0x2, /**< The projection is absolute. */
|
||||
ORTHO = 0x4, /**< The projection is orthographic */
|
||||
GUI = 0x8, /**< Camera draws the GUI. */
|
||||
DO_INTERSECTION_TEST = 0x10,/**< scene intersection tests this
|
||||
camera. */
|
||||
FIXED_NEAR_FAR = 0x20, /**< take the near far values in the
|
||||
projection for real. */
|
||||
ENABLE_MASTER_ZOOM = 0x40 /**< Can apply the zoom algorithm. */
|
||||
};
|
||||
|
||||
CameraInfo(unsigned flags_) :
|
||||
flags(flags_),
|
||||
physicalWidth(0), physicalHeight(0), bezelHeightTop(0),
|
||||
bezelHeightBottom(0), bezelWidthLeft(0), bezelWidthRight(0),
|
||||
relativeCameraParent(0) { }
|
||||
/** The name as given in the config file.
|
||||
*/
|
||||
std::string name;
|
||||
/** Properties of the camera. @see CameraGroup::Flags.
|
||||
*/
|
||||
unsigned flags;
|
||||
/** Physical size parameters.
|
||||
*/
|
||||
double physicalWidth;
|
||||
double physicalHeight;
|
||||
double bezelHeightTop;
|
||||
double bezelHeightBottom;
|
||||
double bezelWidthLeft;
|
||||
double bezelWidthRight;
|
||||
/** Non-owning reference to the parent camera for relative camera
|
||||
* configurations.
|
||||
*/
|
||||
const CameraInfo *relativeCameraParent;
|
||||
/** The reference points in the parents projection space.
|
||||
*/
|
||||
osg::Vec2d parentReference[2];
|
||||
/** The reference points in the current projection space.
|
||||
*/
|
||||
osg::Vec2d thisReference[2];
|
||||
/** View offset from the viewer master camera.
|
||||
*/
|
||||
osg::Matrix viewOffset;
|
||||
/** Projection offset from the viewer master camera.
|
||||
*/
|
||||
osg::Matrix projOffset;
|
||||
/** Current view and projection matrices for this camera.
|
||||
* They are only used by other child cameras through relativeCameraParent
|
||||
* so they can avoid recalculating them.
|
||||
*/
|
||||
osg::Matrix viewMatrix, projMatrix;
|
||||
/** The Compositor used to manage the pipeline of this camera.
|
||||
*/
|
||||
osg::ref_ptr<simgear::compositor::Compositor> compositor;
|
||||
};
|
||||
|
||||
class CameraGroup : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
/** Create a camera group associated with an osgViewer::Viewer.
|
||||
* @param viewer the viewer
|
||||
*/
|
||||
CameraGroup(osgViewer::Viewer* viewer);
|
||||
virtual ~CameraGroup();
|
||||
|
||||
/** Set the default CameraGroup, which is the only one that
|
||||
* matters at this time.
|
||||
* @param group the group to set.
|
||||
*/
|
||||
static void buildDefaultGroup(osgViewer::Viewer* viewer);
|
||||
static void setDefault(CameraGroup* group) { _defaultGroup = group; }
|
||||
/** Get the default CameraGroup.
|
||||
* @return the default camera group.
|
||||
*/
|
||||
static CameraGroup* getDefault() { return _defaultGroup.get(); }
|
||||
/** Get the camera group's Viewer.
|
||||
* @return the viewer
|
||||
*/
|
||||
osgViewer::Viewer* getViewer() { return _viewer.get(); }
|
||||
/** Create an osg::Camera from a property node and add it to the
|
||||
* camera group.
|
||||
* @param cameraNode the property node.
|
||||
* @return a CameraInfo object for the camera.
|
||||
*/
|
||||
void buildCamera(SGPropertyNode* cameraNode);
|
||||
/** Create a camera from properties that will draw the GUI and add
|
||||
* it to the camera group.
|
||||
* @param cameraNode the property node. This can be 0, in which
|
||||
* case a default GUI camera is created.
|
||||
* @param window the GraphicsWindow to use for the GUI camera. If
|
||||
* this is 0, the window is determined from the property node.
|
||||
* @return a CameraInfo object for the GUI camera.
|
||||
*/
|
||||
void buildGUICamera(SGPropertyNode* cameraNode,
|
||||
GraphicsWindow* window = 0);
|
||||
/** Update the view for the camera group.
|
||||
* @param position the world position of the view
|
||||
* @param orientation the world orientation of the view.
|
||||
*/
|
||||
void update(const osg::Vec3d& position,
|
||||
const osg::Quat& orientation);
|
||||
/** Set the parameters of the viewer's master camera. This won't
|
||||
* affect cameras that have CameraFlags::PROJECTION_ABSOLUTE set.
|
||||
* XXX Should znear and zfar be settable?
|
||||
* @param vfov the vertical field of view angle
|
||||
* @param aspectRatio the master camera's aspect ratio. This
|
||||
* doesn't actually change the viewport, but should reflect the
|
||||
* current viewport.
|
||||
*/
|
||||
void setCameraParameters(float vfov, float aspectRatio);
|
||||
/** Update camera properties after a resize event.
|
||||
*/
|
||||
void resized();
|
||||
|
||||
void buildDistortionCamera(const SGPropertyNode* psNode,
|
||||
osg::Camera* camera);
|
||||
/**
|
||||
* get aspect ratio of master camera's viewport
|
||||
*/
|
||||
double getMasterAspectRatio() const;
|
||||
|
||||
CameraInfo *getGUICamera() const;
|
||||
|
||||
protected:
|
||||
friend CameraGroupListener;
|
||||
friend bool computeIntersections(const CameraGroup* cgroup,
|
||||
const osg::Vec2d& windowPos,
|
||||
osgUtil::LineSegmentIntersector::Intersections&
|
||||
intersections);
|
||||
|
||||
typedef std::vector<osg::ref_ptr<CameraInfo>> CameraList;
|
||||
CameraList _cameras;
|
||||
osg::ref_ptr<osgViewer::Viewer> _viewer;
|
||||
static osg::ref_ptr<CameraGroup> _defaultGroup;
|
||||
std::unique_ptr<CameraGroupListener> _listener;
|
||||
|
||||
// Near, far for the master camera if used.
|
||||
float _zNear;
|
||||
float _zFar;
|
||||
float _nearField;
|
||||
|
||||
/** Build a complete CameraGroup from a property node.
|
||||
* @param viewer the viewer associated with this camera group.
|
||||
* @param wbuilder the window builder to be used for this camera group.
|
||||
* @param the camera group property node.
|
||||
*/
|
||||
static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
|
||||
SGPropertyNode* node);
|
||||
};
|
||||
|
||||
/** Get the osg::Camera that draws the GUI, if any, from a camera
|
||||
* group.
|
||||
* @param cgroup the camera group
|
||||
* @return the GUI camera or 0
|
||||
*/
|
||||
osg::Camera* getGUICamera(CameraGroup* cgroup);
|
||||
/** Choose a camera using an event and do intersection testing on its
|
||||
* view of the scene. Only cameras with the DO_INTERSECTION_TEST flag
|
||||
* set are considered.
|
||||
* @param cgroup the CameraGroup
|
||||
* @param ea the event containing a window and mouse coordinates
|
||||
* @param intersections container for the result of intersection
|
||||
* testing.
|
||||
* @return true if any intersections are found
|
||||
*/
|
||||
bool computeIntersections(const CameraGroup* cgroup,
|
||||
const osg::Vec2d& windowPos,
|
||||
osgUtil::LineSegmentIntersector::Intersections&
|
||||
intersections);
|
||||
/** Warp the pointer to coordinates in the GUI camera of a camera group.
|
||||
* @param cgroup the camera group
|
||||
* @param x x window coordinate of pointer
|
||||
* @param y y window coordinate of pointer, in "y down" coordinates.
|
||||
*/
|
||||
void warpGUIPointer(CameraGroup* cgroup, int x, int y);
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COMPOSITOR
|
||||
# include "CameraGroup_compositor.hxx"
|
||||
#else
|
||||
# include "CameraGroup_legacy.hxx"
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_CAMERAGROUP_HXX */
|
||||
|
|
|
@ -1,241 +0,0 @@
|
|||
// Copyright (C) 2008 Tim Moore
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#ifndef CAMERAGROUP_HXX
|
||||
#define CAMERAGROUP_HXX 1
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <osg/Matrix>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Referenced>
|
||||
#include <osg/Node>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexGen>
|
||||
#include <osgUtil/RenderBin>
|
||||
|
||||
#include <simgear/scene/viewer/Compositor.hxx>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Camera;
|
||||
}
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
class SGPropertyNode;
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
|
||||
class CameraGroupListener;
|
||||
class GraphicsWindow;
|
||||
|
||||
/** A wrapper around osg::Camera that contains some extra information.
|
||||
*/
|
||||
struct CameraInfo : public osg::Referenced
|
||||
{
|
||||
/** properties of a camera.
|
||||
*/
|
||||
enum Flags
|
||||
{
|
||||
VIEW_ABSOLUTE = 0x1, /**< The camera view is absolute, not
|
||||
relative to the master camera. */
|
||||
PROJECTION_ABSOLUTE = 0x2, /**< The projection is absolute. */
|
||||
ORTHO = 0x4, /**< The projection is orthographic */
|
||||
GUI = 0x8, /**< Camera draws the GUI. */
|
||||
DO_INTERSECTION_TEST = 0x10,/**< scene intersection tests this
|
||||
camera. */
|
||||
FIXED_NEAR_FAR = 0x20, /**< take the near far values in the
|
||||
projection for real. */
|
||||
ENABLE_MASTER_ZOOM = 0x40 /**< Can apply the zoom algorithm. */
|
||||
};
|
||||
|
||||
CameraInfo(unsigned flags_) :
|
||||
flags(flags_),
|
||||
physicalWidth(0), physicalHeight(0), bezelHeightTop(0),
|
||||
bezelHeightBottom(0), bezelWidthLeft(0), bezelWidthRight(0),
|
||||
relativeCameraParent(0) { }
|
||||
/** The name as given in the config file.
|
||||
*/
|
||||
std::string name;
|
||||
/** Properties of the camera. @see CameraGroup::Flags.
|
||||
*/
|
||||
unsigned flags;
|
||||
/** Physical size parameters.
|
||||
*/
|
||||
double physicalWidth;
|
||||
double physicalHeight;
|
||||
double bezelHeightTop;
|
||||
double bezelHeightBottom;
|
||||
double bezelWidthLeft;
|
||||
double bezelWidthRight;
|
||||
/** Non-owning reference to the parent camera for relative camera
|
||||
* configurations.
|
||||
*/
|
||||
const CameraInfo *relativeCameraParent;
|
||||
/** The reference points in the parents projection space.
|
||||
*/
|
||||
osg::Vec2d parentReference[2];
|
||||
/** The reference points in the current projection space.
|
||||
*/
|
||||
osg::Vec2d thisReference[2];
|
||||
/** View offset from the viewer master camera.
|
||||
*/
|
||||
osg::Matrix viewOffset;
|
||||
/** Projection offset from the viewer master camera.
|
||||
*/
|
||||
osg::Matrix projOffset;
|
||||
/** Current view and projection matrices for this camera.
|
||||
* They are only used by other child cameras through relativeCameraParent
|
||||
* so they can avoid recalculating them.
|
||||
*/
|
||||
osg::Matrix viewMatrix, projMatrix;
|
||||
/** The Compositor used to manage the pipeline of this camera.
|
||||
*/
|
||||
osg::ref_ptr<simgear::compositor::Compositor> compositor;
|
||||
};
|
||||
|
||||
class CameraGroup : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
/** Create a camera group associated with an osgViewer::Viewer.
|
||||
* @param viewer the viewer
|
||||
*/
|
||||
CameraGroup(osgViewer::Viewer* viewer);
|
||||
virtual ~CameraGroup();
|
||||
|
||||
/** Set the default CameraGroup, which is the only one that
|
||||
* matters at this time.
|
||||
* @param group the group to set.
|
||||
*/
|
||||
static void buildDefaultGroup(osgViewer::Viewer* viewer);
|
||||
static void setDefault(CameraGroup* group) { _defaultGroup = group; }
|
||||
/** Get the default CameraGroup.
|
||||
* @return the default camera group.
|
||||
*/
|
||||
static CameraGroup* getDefault() { return _defaultGroup.get(); }
|
||||
/** Get the camera group's Viewer.
|
||||
* @return the viewer
|
||||
*/
|
||||
osgViewer::Viewer* getViewer() { return _viewer.get(); }
|
||||
/** Create an osg::Camera from a property node and add it to the
|
||||
* camera group.
|
||||
* @param cameraNode the property node.
|
||||
* @return a CameraInfo object for the camera.
|
||||
*/
|
||||
void buildCamera(SGPropertyNode* cameraNode);
|
||||
/** Create a camera from properties that will draw the GUI and add
|
||||
* it to the camera group.
|
||||
* @param cameraNode the property node. This can be 0, in which
|
||||
* case a default GUI camera is created.
|
||||
* @param window the GraphicsWindow to use for the GUI camera. If
|
||||
* this is 0, the window is determined from the property node.
|
||||
* @return a CameraInfo object for the GUI camera.
|
||||
*/
|
||||
void buildGUICamera(SGPropertyNode* cameraNode,
|
||||
GraphicsWindow* window = 0);
|
||||
/** Update the view for the camera group.
|
||||
* @param position the world position of the view
|
||||
* @param orientation the world orientation of the view.
|
||||
*/
|
||||
void update(const osg::Vec3d& position,
|
||||
const osg::Quat& orientation);
|
||||
/** Set the parameters of the viewer's master camera. This won't
|
||||
* affect cameras that have CameraFlags::PROJECTION_ABSOLUTE set.
|
||||
* XXX Should znear and zfar be settable?
|
||||
* @param vfov the vertical field of view angle
|
||||
* @param aspectRatio the master camera's aspect ratio. This
|
||||
* doesn't actually change the viewport, but should reflect the
|
||||
* current viewport.
|
||||
*/
|
||||
void setCameraParameters(float vfov, float aspectRatio);
|
||||
/** Update camera properties after a resize event.
|
||||
*/
|
||||
void resized();
|
||||
|
||||
void buildDistortionCamera(const SGPropertyNode* psNode,
|
||||
osg::Camera* camera);
|
||||
/**
|
||||
* get aspect ratio of master camera's viewport
|
||||
*/
|
||||
double getMasterAspectRatio() const;
|
||||
|
||||
CameraInfo *getGUICamera() const;
|
||||
|
||||
protected:
|
||||
friend CameraGroupListener;
|
||||
friend bool computeIntersections(const CameraGroup* cgroup,
|
||||
const osg::Vec2d& windowPos,
|
||||
osgUtil::LineSegmentIntersector::Intersections&
|
||||
intersections);
|
||||
|
||||
typedef std::vector<osg::ref_ptr<CameraInfo>> CameraList;
|
||||
CameraList _cameras;
|
||||
osg::ref_ptr<osgViewer::Viewer> _viewer;
|
||||
static osg::ref_ptr<CameraGroup> _defaultGroup;
|
||||
std::unique_ptr<CameraGroupListener> _listener;
|
||||
|
||||
// Near, far for the master camera if used.
|
||||
float _zNear;
|
||||
float _zFar;
|
||||
float _nearField;
|
||||
|
||||
/** Build a complete CameraGroup from a property node.
|
||||
* @param viewer the viewer associated with this camera group.
|
||||
* @param wbuilder the window builder to be used for this camera group.
|
||||
* @param the camera group property node.
|
||||
*/
|
||||
static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
|
||||
SGPropertyNode* node);
|
||||
};
|
||||
|
||||
/** Get the osg::Camera that draws the GUI, if any, from a camera
|
||||
* group.
|
||||
* @param cgroup the camera group
|
||||
* @return the GUI camera or 0
|
||||
*/
|
||||
osg::Camera* getGUICamera(CameraGroup* cgroup);
|
||||
/** Choose a camera using an event and do intersection testing on its
|
||||
* view of the scene. Only cameras with the DO_INTERSECTION_TEST flag
|
||||
* set are considered.
|
||||
* @param cgroup the CameraGroup
|
||||
* @param ea the event containing a window and mouse coordinates
|
||||
* @param intersections container for the result of intersection
|
||||
* testing.
|
||||
* @return true if any intersections are found
|
||||
*/
|
||||
bool computeIntersections(const CameraGroup* cgroup,
|
||||
const osg::Vec2d& windowPos,
|
||||
osgUtil::LineSegmentIntersector::Intersections&
|
||||
intersections);
|
||||
/** Warp the pointer to coordinates in the GUI camera of a camera group.
|
||||
* @param cgroup the camera group
|
||||
* @param x x window coordinate of pointer
|
||||
* @param y y window coordinate of pointer, in "y down" coordinates.
|
||||
*/
|
||||
void warpGUIPointer(CameraGroup* cgroup, int x, int y);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,343 +0,0 @@
|
|||
// Copyright (C) 2008 Tim Moore
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#ifndef CAMERAGROUP_HXX
|
||||
#define CAMERAGROUP_HXX 1
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <osg/Matrix>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Referenced>
|
||||
#include <osg/Node>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexGen>
|
||||
#include <osgUtil/RenderBin>
|
||||
|
||||
// For osgUtil::LineSegmentIntersector::Intersections, which is a typedef.
|
||||
#include <osgUtil/LineSegmentIntersector>
|
||||
namespace osg
|
||||
{
|
||||
class Camera;
|
||||
}
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
class SGPropertyNode;
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
|
||||
class GraphicsWindow;
|
||||
class CameraViewportListener;
|
||||
class CameraGroupListener;
|
||||
|
||||
struct RenderBufferInfo {
|
||||
RenderBufferInfo(osg::Texture2D* t = 0, float s = 1.0 ) : texture(t), scaleFactor(s) {}
|
||||
osg::ref_ptr<osg::Texture2D> texture;
|
||||
float scaleFactor;
|
||||
};
|
||||
typedef std::map<std::string,RenderBufferInfo> RenderBufferMap;
|
||||
typedef std::map<osg::Camera::BufferComponent,std::string> AttachmentMap;
|
||||
|
||||
struct RenderStageInfo {
|
||||
RenderStageInfo(osg::Camera* camera_ = 0, int si = -1, bool fs = false)
|
||||
: camera(camera_), slaveIndex(si), scaleFactor(1.0f), fullscreen(fs)
|
||||
, resizable(true)
|
||||
{
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Camera> camera;
|
||||
AttachmentMap buffers;
|
||||
int slaveIndex;
|
||||
float scaleFactor;
|
||||
bool fullscreen;
|
||||
bool resizable;
|
||||
};
|
||||
|
||||
extern const char* MAIN_CAMERA;
|
||||
extern const char* FAR_CAMERA;
|
||||
extern const char* GEOMETRY_CAMERA;
|
||||
extern const char* SHADOW_CAMERA;
|
||||
extern const char* LIGHTING_CAMERA;
|
||||
extern const char* DISPLAY_CAMERA;
|
||||
|
||||
typedef std::map<std::string,RenderStageInfo> CameraMap;
|
||||
|
||||
/** A wrapper around osg::Camera that contains some extra information.
|
||||
*/
|
||||
struct CameraInfo : public osg::Referenced
|
||||
{
|
||||
CameraInfo(unsigned flags_)
|
||||
: flags(flags_),
|
||||
x(0.0), y(0.0), width(0.0), height(0.0),
|
||||
physicalWidth(0), physicalHeight(0), bezelHeightTop(0),
|
||||
bezelHeightBottom(0), bezelWidthLeft(0), bezelWidthRight(0),
|
||||
relativeCameraParent(~0u),
|
||||
bufferSize( new osg::Uniform("fg_BufferSize", osg::Vec2f() ) ),
|
||||
projInverse( new osg::Uniform( "fg_ProjectionMatrixInverse", osg::Matrixf() ) ),
|
||||
viewInverse( new osg::Uniform( "fg_ViewMatrixInverse",osg::Matrixf() ) ),
|
||||
view( new osg::Uniform( "fg_ViewMatrix",osg::Matrixf() ) ),
|
||||
worldPosCart( new osg::Uniform( "fg_CameraPositionCart", osg::Vec3f() ) ),
|
||||
worldPosGeod( new osg::Uniform( "fg_CameraPositionGeod", osg::Vec3f() ) ),
|
||||
du( new osg::Uniform( "fg_du",osg::Vec4() ) ),
|
||||
dv( new osg::Uniform( "fg_dv",osg::Vec4() ) ),
|
||||
viewportListener(NULL)
|
||||
{
|
||||
shadowMatrix[0] = new osg::Uniform("fg_ShadowMatrix_0", osg::Matrixf());
|
||||
shadowMatrix[1] = new osg::Uniform("fg_ShadowMatrix_1", osg::Matrixf());
|
||||
shadowMatrix[2] = new osg::Uniform("fg_ShadowMatrix_2", osg::Matrixf());
|
||||
shadowMatrix[3] = new osg::Uniform("fg_ShadowMatrix_3", osg::Matrixf());
|
||||
}
|
||||
|
||||
~CameraInfo();
|
||||
|
||||
/** Update and resize cameras
|
||||
*/
|
||||
void updateCameras();
|
||||
void resized(double w, double h);
|
||||
|
||||
/** The name as given in the config file.
|
||||
*/
|
||||
std::string name;
|
||||
/** Properties of the camera. @see CameraGroup::Flags.
|
||||
*/
|
||||
unsigned flags;
|
||||
|
||||
/** Viewport parameters.
|
||||
*/
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
/** Physical size parameters.
|
||||
*/
|
||||
double physicalWidth;
|
||||
double physicalHeight;
|
||||
double bezelHeightTop;
|
||||
double bezelHeightBottom;
|
||||
double bezelWidthLeft;
|
||||
double bezelWidthRight;
|
||||
/** The parent camera for relative camera configurations.
|
||||
*/
|
||||
unsigned relativeCameraParent;
|
||||
|
||||
/** the camera objects
|
||||
*/
|
||||
CameraMap cameras;
|
||||
void addCamera( const std::string& k, osg::Camera* c, int si = -1, bool fs = false ) { cameras[k].camera = c; cameras[k].slaveIndex = si; cameras[k].fullscreen = fs; }
|
||||
void addCamera( const std::string& k, osg::Camera* c, bool fs ) { cameras[k].camera = c; cameras[k].fullscreen = fs; }
|
||||
void addCamera( const std::string& k, osg::Camera* c, float s, bool fs = false ) { cameras[k].camera = c; cameras[k].scaleFactor = s; cameras[k].fullscreen = fs; }
|
||||
osg::Camera* getCamera(const std::string& k) const;
|
||||
int getMainSlaveIndex() const;
|
||||
RenderStageInfo& getRenderStageInfo( const std::string& k ) { return cameras[k]; }
|
||||
|
||||
/** the buffer objects
|
||||
*/
|
||||
RenderBufferMap buffers;
|
||||
void addBuffer(const std::string& k, osg::Texture2D* tex, float scale = 1.0 ) { buffers[k] = RenderBufferInfo(tex,scale); }
|
||||
osg::Texture2D* getBuffer(const std::string& k) const;
|
||||
|
||||
osg::ref_ptr<osg::Uniform> bufferSize;
|
||||
osg::ref_ptr<osg::Uniform> projInverse;
|
||||
osg::ref_ptr<osg::Uniform> viewInverse;
|
||||
osg::ref_ptr<osg::Uniform> view;
|
||||
osg::ref_ptr<osg::Uniform> worldPosCart;
|
||||
osg::ref_ptr<osg::Uniform> worldPosGeod;
|
||||
osg::ref_ptr<osg::Uniform> du;
|
||||
osg::ref_ptr<osg::Uniform> dv;
|
||||
osg::ref_ptr<osg::Uniform> shadowMatrix[4];
|
||||
|
||||
CameraViewportListener* viewportListener;
|
||||
|
||||
void setMatrices( osg::Camera* c );
|
||||
|
||||
osgUtil::RenderBin::RenderBinList savedTransparentBins;
|
||||
/** The reference points in the parents projection space.
|
||||
*/
|
||||
osg::Vec2d parentReference[2];
|
||||
/** The reference points in the current projection space.
|
||||
*/
|
||||
osg::Vec2d thisReference[2];
|
||||
};
|
||||
|
||||
class CameraGroup : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
/** properties of a camera.
|
||||
*/
|
||||
enum Flags
|
||||
{
|
||||
VIEW_ABSOLUTE = 0x1, /**< The camera view is absolute, not
|
||||
relative to the master camera. */
|
||||
PROJECTION_ABSOLUTE = 0x2, /**< The projection is absolute. */
|
||||
ORTHO = 0x4, /**< The projection is orthographic */
|
||||
GUI = 0x8, /**< Camera draws the GUI. */
|
||||
DO_INTERSECTION_TEST = 0x10,/**< scene intersection tests this
|
||||
camera. */
|
||||
FIXED_NEAR_FAR = 0x20, /**< take the near far values in the
|
||||
projection for real. */
|
||||
ENABLE_MASTER_ZOOM = 0x40 /**< Can apply the zoom algorithm. */
|
||||
};
|
||||
/** Create a camera group associated with an osgViewer::Viewer.
|
||||
* @param viewer the viewer
|
||||
*/
|
||||
CameraGroup(osgViewer::Viewer* viewer);
|
||||
|
||||
~CameraGroup();
|
||||
|
||||
/** Get the camera group's Viewer.
|
||||
* @return the viewer
|
||||
*/
|
||||
osgViewer::Viewer* getViewer() { return _viewer.get(); }
|
||||
/** Create an osg::Camera from a property node and add it to the
|
||||
* camera group.
|
||||
* @param cameraNode the property node.
|
||||
* @return a CameraInfo object for the camera.
|
||||
*/
|
||||
CameraInfo* buildCamera(SGPropertyNode* cameraNode);
|
||||
/** Create a camera from properties that will draw the GUI and add
|
||||
* it to the camera group.
|
||||
* @param cameraNode the property node. This can be 0, in which
|
||||
* case a default GUI camera is created.
|
||||
* @param window the GraphicsWindow to use for the GUI camera. If
|
||||
* this is 0, the window is determined from the property node.
|
||||
* @return a CameraInfo object for the GUI camera.
|
||||
*/
|
||||
CameraInfo* buildGUICamera(SGPropertyNode* cameraNode,
|
||||
GraphicsWindow* window = 0);
|
||||
/** Update the view for the camera group.
|
||||
* @param position the world position of the view
|
||||
* @param orientation the world orientation of the view.
|
||||
*/
|
||||
void update(const osg::Vec3d& position, const osg::Quat& orientation);
|
||||
/** Set the parameters of the viewer's master camera. This won't
|
||||
* affect cameras that have CameraFlags::PROJECTION_ABSOLUTE set.
|
||||
* XXX Should znear and zfar be settable?
|
||||
* @param vfov the vertical field of view angle
|
||||
* @param aspectRatio the master camera's aspect ratio. This
|
||||
* doesn't actually change the viewport, but should reflect the
|
||||
* current viewport.
|
||||
*/
|
||||
void setCameraParameters(float vfov, float aspectRatio);
|
||||
/** Set the default CameraGroup, which is the only one that
|
||||
* matters at this time.
|
||||
* @param group the group to set.
|
||||
*/
|
||||
|
||||
static void buildDefaultGroup(osgViewer::Viewer* viewer);
|
||||
|
||||
static void setDefault(CameraGroup* group) { _defaultGroup = group; }
|
||||
/** Get the default CameraGroup.
|
||||
* @return the default camera group.
|
||||
*/
|
||||
static CameraGroup* getDefault() { return _defaultGroup.get(); }
|
||||
|
||||
typedef std::vector<osg::ref_ptr<CameraInfo> > CameraList;
|
||||
typedef CameraList::iterator CameraIterator;
|
||||
typedef CameraList::const_iterator ConstCameraIterator;
|
||||
/** Get iterator for camera vector. The iterator's value is a ref_ptr.
|
||||
*/
|
||||
CameraIterator camerasBegin() { return _cameras.begin(); }
|
||||
/** Get iteator pointing to the end of the camera list.
|
||||
*/
|
||||
CameraIterator camerasEnd() { return _cameras.end(); }
|
||||
ConstCameraIterator camerasBegin() const { return _cameras.begin(); }
|
||||
ConstCameraIterator camerasEnd() const { return _cameras.end(); }
|
||||
void addCamera(CameraInfo* info) { _cameras.push_back(info); }
|
||||
/** Set the cull mask on all non-GUI cameras
|
||||
*/
|
||||
void setCameraCullMasks(osg::Node::NodeMask nm);
|
||||
/** Update camera properties after a resize event.
|
||||
*/
|
||||
void resized();
|
||||
|
||||
void buildDistortionCamera(const SGPropertyNode* psNode,
|
||||
osg::Camera* camera);
|
||||
|
||||
/**
|
||||
* get aspect ratio of master camera's viewport
|
||||
*/
|
||||
double getMasterAspectRatio() const;
|
||||
|
||||
/**
|
||||
* find the GUI camera if one is defined
|
||||
*/
|
||||
const CameraInfo* getGUICamera() const;
|
||||
|
||||
void setZNear(float f) { _zNear = f; }
|
||||
void setZFar(float f) { _zFar = f; }
|
||||
void setNearField(float f) { _nearField = f; }
|
||||
protected:
|
||||
CameraList _cameras;
|
||||
osg::ref_ptr<osgViewer::Viewer> _viewer;
|
||||
static osg::ref_ptr<CameraGroup> _defaultGroup;
|
||||
std::unique_ptr<CameraGroupListener> _listener;
|
||||
|
||||
// Near, far for the master camera if used.
|
||||
float _zNear;
|
||||
float _zFar;
|
||||
float _nearField;
|
||||
|
||||
typedef std::map<std::string, osg::ref_ptr<osg::TextureRectangle> > TextureMap;
|
||||
TextureMap _textureTargets;
|
||||
|
||||
/** Build a complete CameraGroup from a property node.
|
||||
* @param viewer the viewer associated with this camera group.
|
||||
* @param the camera group property node.
|
||||
*/
|
||||
static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
|
||||
SGPropertyNode* node);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
/** Get the osg::Camera that draws the GUI, if any, from a camera
|
||||
* group.
|
||||
* @param cgroup the camera group
|
||||
* @return the GUI camera or 0
|
||||
*/
|
||||
osg::Camera* getGUICamera(CameraGroup* cgroup);
|
||||
/** Choose a camera using an event and do intersection testing on its
|
||||
* view of the scene. Only cameras with the DO_INTERSECTION_TEST flag
|
||||
* set are considered.
|
||||
* @param cgroup the CameraGroup
|
||||
* @param ea the event containing a window and mouse coordinates
|
||||
* @param intersections container for the result of intersection
|
||||
* testing.
|
||||
* @return true if any intersections are found
|
||||
*/
|
||||
bool computeIntersections(const CameraGroup* cgroup,
|
||||
const osg::Vec2d& windowPos,
|
||||
osgUtil::LineSegmentIntersector::Intersections&
|
||||
intersections);
|
||||
/** Warp the pointer to coordinates in the GUI camera of a camera group.
|
||||
* @param cgroup the camera group
|
||||
* @param x x window coordinate of pointer
|
||||
* @param y y window coordinate of pointer, in "y down" coordinates.
|
||||
*/
|
||||
void warpGUIPointer(CameraGroup* cgroup, int x, int y);
|
||||
}
|
||||
#endif
|
|
@ -34,7 +34,7 @@
|
|||
#include <Scenery/scenery.hxx>
|
||||
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
#include <Viewer/renderer_compositor.hxx>
|
||||
#include <Viewer/renderer.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
|
|
@ -343,7 +343,8 @@ public:
|
|||
bool FGScenerySwitchCallback::scenery_enabled = false;
|
||||
|
||||
FGRenderer::FGRenderer() :
|
||||
_sky(NULL)
|
||||
_sky(NULL),
|
||||
MaximumTextureSize(0)
|
||||
{
|
||||
_root = new osg::Group;
|
||||
_root->setName("fakeRoot");
|
||||
|
@ -352,6 +353,11 @@ FGRenderer::FGRenderer() :
|
|||
|
||||
FGRenderer::~FGRenderer()
|
||||
{
|
||||
SGPropertyChangeListenerVec::iterator i = _listeners.begin();
|
||||
for (; i != _listeners.end(); ++i) {
|
||||
delete *i;
|
||||
}
|
||||
|
||||
// replace the viewer's scene completely
|
||||
if (getViewer()) {
|
||||
getViewer()->setSceneData(new osg::Group);
|
||||
|
@ -360,6 +366,37 @@ FGRenderer::~FGRenderer()
|
|||
delete _sky;
|
||||
}
|
||||
|
||||
class PointSpriteListener : public SGPropertyChangeListener {
|
||||
public:
|
||||
virtual void valueChanged(SGPropertyNode* node) {
|
||||
static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
|
||||
sceneFeatures->setEnablePointSpriteLights(node->getIntValue());
|
||||
}
|
||||
};
|
||||
|
||||
class DistanceAttenuationListener : public SGPropertyChangeListener {
|
||||
public:
|
||||
virtual void valueChanged(SGPropertyNode* node) {
|
||||
static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
|
||||
sceneFeatures->setEnableDistanceAttenuationLights(node->getIntValue());
|
||||
}
|
||||
};
|
||||
|
||||
class DirectionalLightsListener : public SGPropertyChangeListener {
|
||||
public:
|
||||
virtual void valueChanged(SGPropertyNode* node) {
|
||||
static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
|
||||
sceneFeatures->setEnableTriangleDirectionalLights(node->getIntValue());
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
FGRenderer::addChangeListener(SGPropertyChangeListener* l, const char* path)
|
||||
{
|
||||
_listeners.push_back(l);
|
||||
fgAddChangeListener(l, path);
|
||||
}
|
||||
|
||||
// Initialize various GL/view parameters
|
||||
void
|
||||
FGRenderer::preinit( void )
|
||||
|
@ -411,9 +448,6 @@ FGRenderer::init( void )
|
|||
_ysize = fgGetNode("/sim/startup/ysize", true);
|
||||
_splash_alpha = fgGetNode("/sim/startup/splash-alpha", true);
|
||||
|
||||
_point_sprites = fgGetNode("/sim/rendering/point-sprites", true);
|
||||
_triangle_directional_lights = fgGetNode("/sim/rendering/triangle-directional-lights", true);
|
||||
_distance_attenuation = fgGetNode("/sim/rendering/distance-attenuation", true);
|
||||
_horizon_effect = fgGetNode("/sim/rendering/horizon-effect", true);
|
||||
|
||||
_altitude_ft = fgGetNode("/position/altitude-ft", true);
|
||||
|
@ -421,11 +455,15 @@ FGRenderer::init( void )
|
|||
_cloud_status = fgGetNode("/environment/clouds/status", true);
|
||||
_visibility_m = fgGetNode("/environment/visibility-m", true);
|
||||
|
||||
bool use_point_sprites = _point_sprites->getBoolValue();
|
||||
bool distance_attenuation = _distance_attenuation->getBoolValue();
|
||||
bool triangles = _triangle_directional_lights->getBoolValue();
|
||||
// configure the lighting related parameters and add change listeners.
|
||||
bool use_point_sprites = fgGetBool("/sim/rendering/point-sprites", true);
|
||||
bool distance_attenuation = fgGetBool("/sim/rendering/distance-attenuation", false);
|
||||
bool triangles = fgGetBool("/sim/rendering/triangle-directional-lights", true);
|
||||
SGConfigureDirectionalLights(use_point_sprites, distance_attenuation, triangles);
|
||||
|
||||
SGConfigureDirectionalLights( use_point_sprites, distance_attenuation, triangles );
|
||||
addChangeListener(new PointSpriteListener, "/sim/rendering/point-sprites");
|
||||
addChangeListener(new DistanceAttenuationListener, "/sim/rendering/distance-attenuation");
|
||||
addChangeListener(new DirectionalLightsListener, "/sim/rendering/triangle-directional-lights");
|
||||
|
||||
if (const char* tc = fgGetString("/sim/rendering/texture-compression", NULL)) {
|
||||
if (strcmp(tc, "false") == 0 || strcmp(tc, "off") == 0 ||
|
||||
|
@ -654,13 +692,18 @@ FGRenderer::update( ) {
|
|||
{
|
||||
_splash_alpha->setDoubleValue(1.0);
|
||||
|
||||
GLint max_texture_size;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
// abritrary range change as sometimes during init the device reports somewhat dubious values, so
|
||||
// we know that the size must be greater than size and that probably 9999999 is unreasonably large
|
||||
if (max_texture_size > 0 && max_texture_size < 9999999)
|
||||
SGSceneFeatures::instance()->setMaxTextureSize(max_texture_size);
|
||||
|
||||
if (!MaximumTextureSize) {
|
||||
osg::Camera* guiCamera = getGUICamera(CameraGroup::getDefault());
|
||||
if (guiCamera) {
|
||||
GraphicsContext *gc = guiCamera->getGraphicsContext();
|
||||
osg::GLExtensions* gl2ext = gc->getState()->get<osg::GLExtensions>();
|
||||
if (gl2ext) {
|
||||
MaximumTextureSize = gl2ext->maxTextureSize;
|
||||
SGSceneFeatures::instance()->setMaxTextureSize(MaximumTextureSize);
|
||||
SG_LOG(SG_VIEW, SG_INFO, "FGRenderer:: Maximum texture size " << MaximumTextureSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
|
||||
|
@ -676,12 +719,13 @@ FGRenderer::update( ) {
|
|||
double sAlpha = _splash_alpha->getDoubleValue();
|
||||
sAlpha -= SGMiscd::max(0.0,delay_time/fade_time);
|
||||
FGScenerySwitchCallback::scenery_enabled = (sAlpha<1.0);
|
||||
_splash_alpha->setDoubleValue((sAlpha < 0) ? 0.0 : sAlpha);
|
||||
|
||||
if (sAlpha <= 0.0) {
|
||||
flightgear::addSentryBreadcrumb("splash-screen fade out complete", "info");
|
||||
}
|
||||
|
||||
_splash_alpha->setDoubleValue((sAlpha < 0) ? 0.0 : sAlpha);
|
||||
|
||||
syncPausePopupState();
|
||||
fgSetBool("/sim/menubar/overlap-hide", false);
|
||||
}
|
|
@ -1,14 +1,130 @@
|
|||
#ifndef COMMON_RENDERER_HXX
|
||||
#define COMMON_RENDERER_HXX
|
||||
#ifndef __FG_RENDERER_HXX
|
||||
#define __FG_RENDERER_HXX 1
|
||||
|
||||
#include <simgear/scene/util/SGPickCallback.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Camera;
|
||||
class Group;
|
||||
class GraphicsContext;
|
||||
class FrameStamp;
|
||||
}
|
||||
|
||||
namespace osgGA
|
||||
{
|
||||
class GUIEventAdapter;
|
||||
}
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
class FGEventHandler;
|
||||
class CameraGroup;
|
||||
class PUICamera;
|
||||
}
|
||||
|
||||
class SGSky;
|
||||
class SGUpdateVisitor;
|
||||
class SplashScreen;
|
||||
class QQuickDrawable;
|
||||
|
||||
typedef std::vector<SGSceneryPick> PickList;
|
||||
|
||||
class FGRenderer {
|
||||
|
||||
public:
|
||||
|
||||
FGRenderer();
|
||||
~FGRenderer();
|
||||
|
||||
void preinit();
|
||||
void init();
|
||||
|
||||
void setupView();
|
||||
|
||||
void resize(int width, int height );
|
||||
|
||||
void update();
|
||||
|
||||
/** Just pick into the scene and return the pick callbacks on the way ...
|
||||
*/
|
||||
PickList pick(const osg::Vec2& windowPos);
|
||||
|
||||
/** Get and set the OSG Viewer object, if any.
|
||||
*/
|
||||
osgViewer::Viewer* getViewer() { return viewer.get(); }
|
||||
const osgViewer::Viewer* getViewer() const { return viewer.get(); }
|
||||
void setViewer(osgViewer::Viewer* viewer);
|
||||
/** Get and set the manipulator object, if any.
|
||||
*/
|
||||
flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
|
||||
const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
|
||||
void setEventHandler(flightgear::FGEventHandler* manipulator);
|
||||
|
||||
/** Add a top level camera.
|
||||
*/
|
||||
void addCamera(osg::Camera* camera, bool useSceneData);
|
||||
|
||||
void removeCamera(osg::Camera* camera);
|
||||
|
||||
SGSky* getSky() const { return _sky; }
|
||||
|
||||
void setPlanes( double zNear, double zFar );
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<osgViewer::Viewer> viewer;
|
||||
osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
osg::ref_ptr<SGUpdateVisitor> _updateVisitor;
|
||||
osg::ref_ptr<osg::Group> _viewerSceneRoot;
|
||||
osg::ref_ptr<osg::Group> _root;
|
||||
|
||||
SGPropertyNode_ptr _scenery_loaded, _position_finalized;
|
||||
|
||||
SGPropertyNode_ptr _splash_alpha;
|
||||
SGPropertyNode_ptr _enhanced_lighting;
|
||||
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;
|
||||
SGTimeStamp _splash_time;
|
||||
SGSky* _sky;
|
||||
int MaximumTextureSize;
|
||||
|
||||
typedef std::vector<SGPropertyChangeListener*> SGPropertyChangeListenerVec;
|
||||
SGPropertyChangeListenerVec _listeners;
|
||||
|
||||
void addChangeListener(SGPropertyChangeListener* l, const char* path);
|
||||
|
||||
void updateSky();
|
||||
|
||||
void setupRoot();
|
||||
|
||||
SplashScreen* _splash;
|
||||
QQuickDrawable* _quickDrawable = nullptr;
|
||||
flightgear::PUICamera* _puiCamera = nullptr;
|
||||
};
|
||||
|
||||
bool fgDumpSceneGraphToFile(const char* filename);
|
||||
bool fgDumpTerrainBranchToFile(const char* filename);
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
bool printVisibleSceneInfo(FGRenderer* renderer);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COMPOSITOR
|
||||
# include "renderer_compositor.hxx"
|
||||
#else
|
||||
# include "renderer_legacy.hxx"
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_RENDERER_HXX */
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
#ifndef __FG_RENDERER_HXX
|
||||
#define __FG_RENDERER_HXX 1
|
||||
|
||||
#include <simgear/scene/util/SGPickCallback.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Camera;
|
||||
class Group;
|
||||
class GraphicsContext;
|
||||
class FrameStamp;
|
||||
}
|
||||
|
||||
namespace osgGA
|
||||
{
|
||||
class GUIEventAdapter;
|
||||
}
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
class FGEventHandler;
|
||||
class CameraGroup;
|
||||
class PUICamera;
|
||||
}
|
||||
|
||||
class SGSky;
|
||||
class SGUpdateVisitor;
|
||||
class SplashScreen;
|
||||
class QQuickDrawable;
|
||||
|
||||
typedef std::vector<SGSceneryPick> PickList;
|
||||
|
||||
class FGRenderer {
|
||||
|
||||
public:
|
||||
|
||||
FGRenderer();
|
||||
~FGRenderer();
|
||||
|
||||
void preinit();
|
||||
void init();
|
||||
|
||||
void setupView();
|
||||
|
||||
void resize(int width, int height );
|
||||
|
||||
void update();
|
||||
|
||||
/** Just pick into the scene and return the pick callbacks on the way ...
|
||||
*/
|
||||
PickList pick(const osg::Vec2& windowPos);
|
||||
|
||||
/** Get and set the OSG Viewer object, if any.
|
||||
*/
|
||||
osgViewer::Viewer* getViewer() { return viewer.get(); }
|
||||
const osgViewer::Viewer* getViewer() const { return viewer.get(); }
|
||||
void setViewer(osgViewer::Viewer* viewer);
|
||||
/** Get and set the manipulator object, if any.
|
||||
*/
|
||||
flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
|
||||
const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
|
||||
void setEventHandler(flightgear::FGEventHandler* manipulator);
|
||||
|
||||
/** Add a top level camera.
|
||||
*/
|
||||
void addCamera(osg::Camera* camera, bool useSceneData);
|
||||
|
||||
void removeCamera(osg::Camera* camera);
|
||||
|
||||
SGSky* getSky() const { return _sky; }
|
||||
|
||||
void setPlanes( double zNear, double zFar );
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<osgViewer::Viewer> viewer;
|
||||
osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
osg::ref_ptr<SGUpdateVisitor> _updateVisitor;
|
||||
osg::ref_ptr<osg::Group> _viewerSceneRoot;
|
||||
osg::ref_ptr<osg::Group> _root;
|
||||
|
||||
SGPropertyNode_ptr _scenery_loaded, _position_finalized;
|
||||
|
||||
SGPropertyNode_ptr _splash_alpha;
|
||||
SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation, _triangle_directional_lights;
|
||||
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;
|
||||
SGTimeStamp _splash_time;
|
||||
SGSky* _sky;
|
||||
|
||||
void updateSky();
|
||||
|
||||
void setupRoot();
|
||||
|
||||
SplashScreen* _splash;
|
||||
QQuickDrawable* _quickDrawable;
|
||||
flightgear::PUICamera* _puiCamera = nullptr;
|
||||
};
|
||||
|
||||
bool fgDumpSceneGraphToFile(const char* filename);
|
||||
bool fgDumpTerrainBranchToFile(const char* filename);
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
bool printVisibleSceneInfo(FGRenderer* renderer);
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,209 +0,0 @@
|
|||
|
||||
#ifndef __FG_RENDERER_HXX
|
||||
#define __FG_RENDERER_HXX 1
|
||||
|
||||
#include <simgear/scene/util/SGPickCallback.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include "renderingpipeline.hxx"
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Camera;
|
||||
class Group;
|
||||
class GraphicsContext;
|
||||
}
|
||||
|
||||
namespace osgGA
|
||||
{
|
||||
class GUIEventAdapter;
|
||||
}
|
||||
|
||||
namespace osgShadow
|
||||
{
|
||||
class ShadowedScene;
|
||||
}
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
class FGEventHandler;
|
||||
struct CameraInfo;
|
||||
class CameraGroup;
|
||||
class PUICamera;
|
||||
}
|
||||
|
||||
class SGSky;
|
||||
class SGUpdateVisitor;
|
||||
class SplashScreen;
|
||||
class QQuickDrawable;
|
||||
|
||||
typedef std::vector<SGSceneryPick> PickList;
|
||||
|
||||
class FGRenderer {
|
||||
|
||||
public:
|
||||
|
||||
FGRenderer();
|
||||
~FGRenderer();
|
||||
|
||||
void preinit();
|
||||
void init();
|
||||
|
||||
void setupView();
|
||||
|
||||
void resize(int width, int height );
|
||||
|
||||
void update();
|
||||
|
||||
/** Just pick into the scene and return the pick callbacks on the way ...
|
||||
*/
|
||||
PickList pick(const osg::Vec2& windowPos);
|
||||
|
||||
/** Get and set the OSG Viewer object, if any.
|
||||
*/
|
||||
osgViewer::Viewer* getViewer() { return viewer.get(); }
|
||||
const osgViewer::Viewer* getViewer() const { return viewer.get(); }
|
||||
void setViewer(osgViewer::Viewer* viewer);
|
||||
/** Get and set the manipulator object, if any.
|
||||
*/
|
||||
flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
|
||||
const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
|
||||
void setEventHandler(flightgear::FGEventHandler* manipulator);
|
||||
|
||||
/** Add a top level camera.
|
||||
*/
|
||||
void addCamera(osg::Camera* camera, bool useSceneData);
|
||||
|
||||
void removeCamera(osg::Camera* camera);
|
||||
|
||||
/** Add a camera to the group. The camera is added to the viewer
|
||||
* as a slave. See osgViewer::Viewer::addSlave.
|
||||
* @param flags properties of the camera; see CameraGroup::Flags
|
||||
* @param projection slave projection matrix
|
||||
* @param view slave view matrix
|
||||
* @param useMasterSceneData whether the camera displays the
|
||||
* viewer's scene data.
|
||||
* @return a CameraInfo object for the camera.
|
||||
*/
|
||||
flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
||||
const osg::Matrix& view,
|
||||
const osg::Matrix& projection,
|
||||
osg::GraphicsContext* gc,
|
||||
bool useMasterSceneData);
|
||||
|
||||
/**
|
||||
*/
|
||||
flightgear::CameraInfo* buildClassicalPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
||||
const osg::Matrix& view,
|
||||
const osg::Matrix& projection,
|
||||
bool useMasterSceneData);
|
||||
|
||||
/**
|
||||
*/
|
||||
flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
||||
const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
|
||||
|
||||
void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
|
||||
void updateShadowMapSize(int mapSize);
|
||||
void enableShadows(bool enabled);
|
||||
void updateCascadeFar(int index, float far_m);
|
||||
void updateCascadeNumber(size_t num);
|
||||
|
||||
SGSky* getSky() const { return _sky; }
|
||||
|
||||
void setPlanes( double zNear, double zFar );
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<osgViewer::Viewer> viewer;
|
||||
osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
osg::ref_ptr<SGUpdateVisitor> _updateVisitor;
|
||||
osg::ref_ptr<osg::Group> _viewerSceneRoot;
|
||||
osg::ref_ptr<osg::Group> _deferredRealRoot;
|
||||
osg::ref_ptr<osg::Group> _root;
|
||||
|
||||
SGPropertyNode_ptr _scenery_loaded, _position_finalized;
|
||||
|
||||
|
||||
SGPropertyNode_ptr _splash_alpha;
|
||||
SGPropertyNode_ptr _enhanced_lighting;
|
||||
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;
|
||||
SGTimeStamp _splash_time;
|
||||
SGSky* _sky;
|
||||
bool _classicalRenderer;
|
||||
std::string _renderer;
|
||||
int _shadowMapSize;
|
||||
size_t _numCascades;
|
||||
float _cascadeFar[4];
|
||||
bool _useColorForDepth;
|
||||
int MaximumTextureSize;
|
||||
|
||||
typedef std::vector<SGPropertyChangeListener*> SGPropertyChangeListenerVec;
|
||||
SGPropertyChangeListenerVec _listeners;
|
||||
|
||||
flightgear::CameraInfo* buildCameraFromRenderingPipeline(FGRenderingPipeline* rpipe, flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
||||
const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
|
||||
|
||||
void buildBuffers(FGRenderingPipeline* rpipe, flightgear::CameraInfo* info);
|
||||
void buildStage(flightgear::CameraInfo* info, FGRenderingPipeline::Stage* stage, flightgear::CameraGroup* cgroup, osg::Camera* mainCamera, const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
|
||||
osg::Node* buildPass(flightgear::CameraInfo* info, FGRenderingPipeline::Pass* pass);
|
||||
osg::Node* buildLightingSkyCloudsPass(FGRenderingPipeline::Pass* pass);
|
||||
osg::Node* buildLightingLightsPass(flightgear::CameraInfo* info, FGRenderingPipeline::Pass* pass);
|
||||
|
||||
osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::string& name, const FGRenderingPipeline::AttachmentList& attachments );
|
||||
osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::string& name, const FGRenderingPipeline::AttachmentList& attachments );
|
||||
osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const FGRenderingPipeline::Stage* stage );
|
||||
osg::Camera* buildDeferredFullscreenCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const FGRenderingPipeline::Stage* stage );
|
||||
osg::Camera* buildDeferredFullscreenCamera( flightgear::CameraInfo* info, const FGRenderingPipeline::Pass* pass );
|
||||
void buildDeferredDisplayCamera( osg::Camera* camera, flightgear::CameraInfo* info, const FGRenderingPipeline::Stage* stage, osg::GraphicsContext* gc );
|
||||
|
||||
void updateShadowCascade(const flightgear::CameraInfo* info, osg::Camera* camera, osg::Group* grp, int idx, double left, double right, double bottom, double top, double zNear, double f1, double f2);
|
||||
osg::Vec3 getSunDirection() const;
|
||||
osg::ref_ptr<osg::Uniform> _ambientFactor;
|
||||
osg::ref_ptr<osg::Uniform> _sunDiffuse;
|
||||
osg::ref_ptr<osg::Uniform> _sunSpecular;
|
||||
osg::ref_ptr<osg::Uniform> _sunDirection;
|
||||
osg::ref_ptr<osg::Uniform> _planes;
|
||||
osg::ref_ptr<osg::Uniform> _fogColor;
|
||||
osg::ref_ptr<osg::Uniform> _fogDensity;
|
||||
osg::ref_ptr<osg::Uniform> _shadowNumber;
|
||||
osg::ref_ptr<osg::Uniform> _shadowDistances;
|
||||
osg::ref_ptr<osg::Uniform> _depthInColor;
|
||||
|
||||
osg::ref_ptr<FGRenderingPipeline> _pipeline;
|
||||
|
||||
void addChangeListener(SGPropertyChangeListener* l, const char* path);
|
||||
|
||||
void updateSky();
|
||||
|
||||
void setupRoot();
|
||||
|
||||
SplashScreen* _splash;
|
||||
QQuickDrawable* _quickDrawable = nullptr;
|
||||
flightgear::PUICamera* _puiCamera = nullptr;
|
||||
};
|
||||
|
||||
bool fgDumpSceneGraphToFile(const char* filename);
|
||||
bool fgDumpTerrainBranchToFile(const char* filename);
|
||||
|
||||
namespace flightgear
|
||||
{
|
||||
bool printVisibleSceneInfo(FGRenderer* renderer);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -204,14 +204,6 @@ void SplashScreen::createNodes()
|
|||
nullptr, -1.0, osg::Vec4(1.0, 0.0, 0.0, 1.0));
|
||||
}
|
||||
|
||||
#if defined(ENABLE_COMPOSITOR)
|
||||
auto compositorText = globals->get_locale()->getLocalizedString("compositor-enabled", "sys", "Compositor");
|
||||
addText(geode, osg::Vec2(0.5f, 0.55f), 0.03,
|
||||
compositorText,
|
||||
osgText::Text::CENTER_CENTER,
|
||||
nullptr, -1.0, osg::Vec4(1.0, 0.0, 0.0, 1.0));
|
||||
#endif
|
||||
|
||||
|
||||
///////////
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue