Fix VR gui material.

pull/615/head
madsbuvi 4 years ago
parent 66d2912fcd
commit 00d6dc3a86

@ -216,22 +216,10 @@ namespace MWVR
auto texture = menuTexture();
texture->setName("diffuseMap");
stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
// assign large value to effectively turn off fog
// shaders don't respect glDisable(GL_FOG)
osg::ref_ptr<osg::Fog> fog(new osg::Fog);
fog->setStart(10000000);
fog->setEnd(10000000);
stateSet->setAttributeAndModes(fog, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
osg::ref_ptr<osg::LightModel> lightmodel = new osg::LightModel;
lightmodel->setAmbientIntensity(osg::Vec4(1.0, 1.0, 1.0, 1.0));
stateSet->setAttributeAndModes(lightmodel, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
SceneUtil::ShadowManager::disableShadowsForStateSet(stateSet);
mGeometry->setStateSet(stateSet);
osg::ref_ptr<osg::Material> mat = new osg::Material;
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
stateSet->setAttribute(mat);
// Position in the game world
mTransform->setScale(osg::Vec3(extent_units.x(), 1.f, extent_units.y()));
@ -502,22 +490,55 @@ namespace MWVR
static osg::Vec3 gLeftHudOffsetTop = osg::Vec3(0.025f, -.05f, .066f);
static osg::Vec3 gLeftHudOffsetWrist = osg::Vec3(0.025f, -.090f, -.033f);
void VRGUIManager::setGeometryRoot(osg::Group* root)
{
mGeometriesRootNode->removeChild(mGeometries);
mGeometriesRootNode = root;
mGeometriesRootNode->addChild(mGeometries);
}
void VRGUIManager::setCameraRoot(osg::Group* root)
{
mGUICamerasRootNode->removeChild(mGUICameras);
mGUICamerasRootNode = root;
mGUICamerasRootNode->addChild(mGUICameras);
}
VRGUIManager::VRGUIManager(
osg::ref_ptr<osgViewer::Viewer> viewer,
Resource::ResourceSystem* resourceSystem,
osg::Group* rootNode)
: mOsgViewer(viewer)
, mResourceSystem(resourceSystem)
, mRootNode(rootNode)
, mGeometriesRootNode(rootNode)
, mGUICamerasRootNode(rootNode)
{
mGUIGeometriesRoot->setName("VR GUI Geometry Root");
mGUIGeometriesRoot->setUpdateCallback(new VRGUIManagerUpdateCallback(this));
mGUIGeometriesRoot->setNodeMask(MWRender::VisMask::Mask_3DGUI);
mGUICamerasRoot->setName("VR GUI Cameras Root");
mGUICamerasRoot->setNodeMask(MWRender::VisMask::Mask_3DGUI);
mRootNode->asGroup()->addChild(mGUICamerasRoot);
mRootNode->asGroup()->addChild(mGUIGeometriesRoot);
mGUIGeometriesRoot->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mGeometries->setName("VR GUI Geometry Root");
mGeometries->setUpdateCallback(new VRGUIManagerUpdateCallback(this));
mGeometries->setNodeMask(MWRender::VisMask::Mask_3DGUI);
mGeometriesRootNode->addChild(mGeometries);
auto stateSet = mGeometries->getOrCreateStateSet();
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
// assign large value to effectively turn off fog
// shaders don't respect glDisable(GL_FOG)
osg::ref_ptr<osg::Fog> fog(new osg::Fog);
fog->setStart(10000000);
fog->setEnd(10000000);
stateSet->setAttributeAndModes(fog, osg::StateAttribute::OFF);
osg::ref_ptr<osg::LightModel> lightmodel = new osg::LightModel;
lightmodel->setAmbientIntensity(osg::Vec4(1.0, 1.0, 1.0, 1.0));
stateSet->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
SceneUtil::ShadowManager::disableShadowsForStateSet(stateSet);
mGeometries->setStateSet(stateSet);
mGUICameras->setName("VR GUI Cameras Root");
mGUICameras->setNodeMask(MWRender::VisMask::Mask_3DGUI);
mGUICamerasRootNode->addChild(mGUICameras);
LayerConfig defaultConfig = createDefaultConfig(1);
LayerConfig loadingScreenConfig = createDefaultConfig(1, true, SizingMode::Fixed, "Menu");
@ -654,8 +675,8 @@ namespace MWVR
}
auto layer = std::shared_ptr<VRGUILayer>(new VRGUILayer(
mGUIGeometriesRoot,
mGUICamerasRoot,
mGeometries,
mGUICameras,
name,
config,
this

@ -179,6 +179,9 @@ namespace MWVR
static void setPick(MWGui::Layout* widget, bool pick);
void setGeometryRoot(osg::Group* root);
void setCameraRoot(osg::Group* root);
private:
void computeGuiCursor(osg::Vec3 hitPoint);
void updateSideBySideLayers();
@ -191,9 +194,10 @@ namespace MWVR
osg::ref_ptr<osgViewer::Viewer> mOsgViewer{ nullptr };
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<osg::Group> mRootNode{ nullptr };
osg::ref_ptr<osg::Group> mGUIGeometriesRoot{ new osg::Group };
osg::ref_ptr<osg::Group> mGUICamerasRoot{ new osg::Group };
osg::ref_ptr<osg::Group> mGeometriesRootNode{ nullptr };
osg::ref_ptr<osg::Group> mGeometries{ new osg::Group };
osg::ref_ptr<osg::Group> mGUICamerasRootNode{ nullptr };
osg::ref_ptr<osg::Group> mGUICameras{ new osg::Group };
std::map<std::string, std::shared_ptr<VRGUILayer>> mLayers;
std::vector<std::shared_ptr<VRGUILayer> > mSideBySideLayers;

Loading…
Cancel
Save