X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2FCameraGroup.cxx;h=954a591e55d0c41ad761b2772d557aec8eda639b;hb=4be1661305609819703015360b79bbb7e4ae87d6;hp=2ff1bb16921b4ecdf66a8f575f94cb35ef812f8a;hpb=0603aba9ae0d9deb23bd9c00a5a3768b37f317d8;p=flightgear.git diff --git a/src/Main/CameraGroup.cxx b/src/Main/CameraGroup.cxx index 2ff1bb169..954a591e5 100644 --- a/src/Main/CameraGroup.cxx +++ b/src/Main/CameraGroup.cxx @@ -14,6 +14,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifdef HAVE_CONFIG_H +# include +#endif + #include "CameraGroup.hxx" #include "globals.hxx" @@ -23,6 +27,7 @@ #include "WindowSystemAdapter.hxx" #include #include +#include #include #include @@ -40,6 +45,7 @@ #include #include +#include namespace flightgear { @@ -100,14 +106,12 @@ void makeNewProjMat(Matrixd& oldProj, double znear, void installCullVisitor(Camera* camera) { -#if 0 // Not yet osgViewer::Renderer* renderer = static_cast(camera->getRenderer()); for (int i = 0; i < 2; ++i) { osgUtil::SceneView* sceneView = renderer->getSceneView(i); sceneView->setCullVisitor(new simgear::EffectCullVisitor); } -#endif } } @@ -198,7 +202,7 @@ void CameraGroup::update(const osg::Vec3d& position, camera->setProjectionMatrix(projectionMatrix); camera->setCullMask(camera->getCullMask() | simgear::BACKGROUND_BIT); - camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); farCamera->setNodeMask(0); } else { Matrix nearProj, farProj; @@ -219,9 +223,11 @@ void CameraGroup::update(const osg::Vec3d& position, void CameraGroup::setCameraParameters(float vfov, float aspectRatio) { - _viewer->getCamera()->setProjectionMatrixAsPerspective(vfov, - 1.0f / aspectRatio, - _zNear, _zFar); + if (vfov != 0.0f && aspectRatio != 0.0f) + _viewer->getCamera() + ->setProjectionMatrixAsPerspective(vfov, + 1.0f / aspectRatio, + _zNear, _zFar); } } @@ -296,7 +302,6 @@ CameraInfo* CameraGroup::buildCamera(SGPropertyNode* cameraNode) WindowBuilder *wBuild = WindowBuilder::getWindowBuilder(); const SGPropertyNode* windowNode = cameraNode->getNode("window"); GraphicsWindow* window = 0; - static int cameraNum = 0; int cameraFlags = DO_INTERSECTION_TEST; if (windowNode) { // New style window declaration / definition @@ -316,7 +321,11 @@ CameraInfo* CameraGroup::buildCamera(SGPropertyNode* cameraNode) | CullSettings::VIEW_FRUSTUM_CULLING); camera->setInheritanceMask(CullSettings::ALL_VARIABLES & ~(CullSettings::CULL_MASK - | CullSettings::CULLING_MODE)); + | CullSettings::CULLING_MODE +#if defined(HAVE_CULLSETTINGS_CLEAR_MASK) + | CullSettings::CLEAR_MASK +#endif + )); osg::Matrix pOff; osg::Matrix vOff; @@ -398,7 +407,6 @@ CameraInfo* CameraGroup::buildGUICamera(SGPropertyNode* cameraNode, const SGPropertyNode* windowNode = (cameraNode ? cameraNode->getNode("window") : 0); - static int cameraNum = 0; if (!window) { if (windowNode) { // New style window declaration / definition @@ -418,7 +426,11 @@ CameraInfo* CameraGroup::buildGUICamera(SGPropertyNode* cameraNode, camera->setClearMask(0); camera->setInheritanceMask(CullSettings::ALL_VARIABLES & ~(CullSettings::COMPUTE_NEAR_FAR_MODE - | CullSettings::CULLING_MODE)); + | CullSettings::CULLING_MODE +#if defined(HAVE_CULLSETTINGS_CLEAR_MASK) + | CullSettings::CLEAR_MASK +#endif + )); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera->setCullingMode(osg::CullSettings::NO_CULLING); camera->setProjectionResizePolicy(Camera::FIXED); @@ -450,7 +462,7 @@ CameraGroup* CameraGroup::buildCameraGroup(osgViewer::Viewer* viewer, cgroup->buildGUICamera(pNode); } } - bindMemberToNode(gnode, "znear", cgroup, &CameraGroup::_zNear, .4f); + bindMemberToNode(gnode, "znear", cgroup, &CameraGroup::_zNear, .1f); bindMemberToNode(gnode, "zfar", cgroup, &CameraGroup::_zFar, 120000.0f); bindMemberToNode(gnode, "near-field", cgroup, &CameraGroup::_nearField, 100.0f);