Use node masks to separate Scene and GUI

c++11
scrawl 10 years ago
parent c90125f936
commit 62847f0489

@ -41,6 +41,8 @@
#include "mwworld/player.hpp"
#include "mwworld/worldimp.hpp"
#include "mwrender/vismask.hpp"
#include "mwclass/classes.hpp"
#include "mwdialogue/dialoguemanagerimp.hpp"
@ -339,6 +341,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
std::string myguiResources = (mResDir / "mygui").string();
osg::ref_ptr<osg::Group> guiRoot = new osg::Group;
guiRoot->setNodeMask(MWRender::Mask_GUI);
rootNode->addChild(guiRoot);
MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem->getTextureManager(),
mCfgMgr.getLogPath().string() + std::string("/"), myguiResources,

@ -466,7 +466,7 @@ void RenderManager::initialise()
camera->addChild(geode.get());
mGuiRoot = camera;
//mSceneRoot->addChild(mGuiRoot.get());
mSceneRoot->addChild(mGuiRoot.get());
mViewer->addEventHandler(new ResizeHandler(this));
osg::ref_ptr<osg::Viewport> vp = mViewer->getCamera()->getViewport();

@ -23,6 +23,7 @@
#include "sky.hpp"
#include "effectmanager.hpp"
#include "vismask.hpp"
namespace MWRender
{
@ -87,8 +88,6 @@ namespace MWRender
mObjects.reset(new Objects(mResourceSystem, lightRoot));
mSky.reset(new SkyManager(mRootNode, resourceSystem->getSceneManager()));
mEffectManager.reset(new EffectManager(mRootNode, mResourceSystem));
mViewer.setLightingMode(osgViewer::View::NO_LIGHT);
@ -105,6 +104,10 @@ namespace MWRender
lightRoot->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON);
lightRoot->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
lightRoot->setNodeMask(Mask_Scene);
mSky.reset(new SkyManager(lightRoot, resourceSystem->getSceneManager()));
source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON);
mStateUpdater = new StateUpdater;
@ -128,6 +131,8 @@ namespace MWRender
zNear = 5.f;
zFar = mViewDistance;
mViewer.getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar);
mViewer.getCamera()->setCullMask(mViewer.getCamera()->getCullMask() & (~Mask_GUI));
}
RenderingManager::~RenderingManager()

@ -554,7 +554,6 @@ void SkyManager::create()
depth->setWriteMask(false);
mRootNode->getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON);
mRootNode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
mRootNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON);
mCreated = true;
}
@ -562,6 +561,11 @@ void SkyManager::create()
SkyManager::~SkyManager()
{
clearRain();
if (mRootNode)
{
mRootNode->getParent(0)->removeChild(mRootNode);
mRootNode = NULL;
}
}
int SkyManager::getMasserPhase() const

@ -9,7 +9,12 @@ namespace MWRender
{
Mask_UpdateVisitor = 0x1, // reserved for separating UpdateVisitors from CullVisitors
Mask_Effect = 0x2
// child of Scene
Mask_Effect = 0x2,
// top level masks
Mask_Scene = 0x10,
Mask_GUI = 0x20
};
}

Loading…
Cancel
Save