1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-06-20 18:41:34 +00:00

wrist option

This commit is contained in:
Mads Buvik Sandvei 2020-11-28 19:41:09 +01:00
parent fde6cc231e
commit fde3ae1403
3 changed files with 127 additions and 120 deletions

View file

@ -20,6 +20,7 @@
#include <components/sceneutil/shadow.hpp> #include <components/sceneutil/shadow.hpp>
#include <components/myguiplatform/myguirendermanager.hpp> #include <components/myguiplatform/myguirendermanager.hpp>
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
#include <components/misc/stringops.hpp>
#include "../mwrender/util.hpp" #include "../mwrender/util.hpp"
#include "../mwrender/renderbin.hpp" #include "../mwrender/renderbin.hpp"
@ -441,23 +442,6 @@ namespace MWVR
VRGUIManager* mManager; VRGUIManager* mManager;
}; };
VRGUIManager::VRGUIManager(
osg::ref_ptr<osgViewer::Viewer> viewer)
: mOsgViewer(viewer)
{
mGUIGeometriesRoot->setName("VR GUI Geometry Root");
mGUIGeometriesRoot->setUpdateCallback(new VRGUIManagerUpdateCallback(this));
mGUICamerasRoot->setName("VR GUI Cameras Root");
auto* root = viewer->getSceneData();
root->asGroup()->addChild(mGUICamerasRoot);
root->asGroup()->addChild(mGUIGeometriesRoot);
}
VRGUIManager::~VRGUIManager(void)
{
}
static const LayerConfig createDefaultConfig(int priority, bool background = true, SizingMode sizingMode = SizingMode::Auto, std::string extraLayers = "Popup") static const LayerConfig createDefaultConfig(int priority, bool background = true, SizingMode sizingMode = SizingMode::Auto, std::string extraLayers = "Popup")
{ {
return LayerConfig{ return LayerConfig{
@ -476,21 +460,60 @@ namespace MWVR
false false
}; };
} }
LayerConfig gDefaultConfig = createDefaultConfig(1);
LayerConfig gVideoPlayerConfig = createDefaultConfig(1, true, SizingMode::Fixed);
LayerConfig gLoadingScreenConfig = createDefaultConfig(1, true, SizingMode::Fixed, "Menu");
LayerConfig gMainMenuConfig = createDefaultConfig(1, true);
LayerConfig gJournalBooksConfig = createDefaultConfig(2, false, SizingMode::Fixed);
LayerConfig gDefaultWindowsConfig = createDefaultConfig(3, true);
LayerConfig gMessageBoxConfig = createDefaultConfig(6, false, SizingMode::Auto);;
LayerConfig gNotificationConfig = createDefaultConfig(7, false, SizingMode::Fixed);
//LayerConfig gVirtualKeyboardConfig = createDefaultConfig(50); static const float sSideBySideRadius = 1.f;
LayerConfig gVirtualKeyboardConfig = LayerConfig{ static const float sSideBySideAzimuthInterval = -osg::PI_4;
static const LayerConfig createSideBySideConfig(int priority)
{
LayerConfig config = createDefaultConfig(priority, true, SizingMode::Fixed, "");
config.sideBySide = true;
config.offset = osg::Vec3(0.f, sSideBySideRadius, -.25f);
config.extent = radiusAngleWidth(sSideBySideRadius, sSideBySideAzimuthInterval);
config.myGUIViewSize = osg::Vec2(0.70f, 0.70f);
return config;
};
VRGUIManager::VRGUIManager(
osg::ref_ptr<osgViewer::Viewer> viewer)
: mOsgViewer(viewer)
{
mGUIGeometriesRoot->setName("VR GUI Geometry Root");
mGUIGeometriesRoot->setUpdateCallback(new VRGUIManagerUpdateCallback(this));
mGUICamerasRoot->setName("VR GUI Cameras Root");
auto* root = viewer->getSceneData();
root->asGroup()->addChild(mGUICamerasRoot);
root->asGroup()->addChild(mGUIGeometriesRoot);
LayerConfig defaultConfig = createDefaultConfig(1);
LayerConfig videoPlayerConfig = createDefaultConfig(1, true, SizingMode::Fixed);
LayerConfig loadingScreenConfig = createDefaultConfig(1, true, SizingMode::Fixed, "Menu");
LayerConfig mainMenuConfig = createDefaultConfig(1, true);
LayerConfig journalBooksConfig = createDefaultConfig(2, false, SizingMode::Fixed);
LayerConfig defaultWindowsConfig = createDefaultConfig(3, true);
LayerConfig messageBoxConfig = createDefaultConfig(6, false, SizingMode::Auto);;
LayerConfig notificationConfig = createDefaultConfig(7, false, SizingMode::Fixed);
LayerConfig statsWindowConfig = createSideBySideConfig(0);
LayerConfig inventoryWindowConfig = createSideBySideConfig(1);
LayerConfig spellWindowConfig = createSideBySideConfig(2);
LayerConfig mapWindowConfig = createSideBySideConfig(3);
LayerConfig inventoryCompanionWindowConfig = createSideBySideConfig(4);
LayerConfig dialogueWindowConfig = createSideBySideConfig(5);
osg::Vec3 leftHudOffset = osg::Vec3(0.025f, -.090f, -.033f);
std::string leftHudSetting = Settings::Manager::getString("left hand hud position", "VR");
if (Misc::StringUtils::ciEqual(leftHudSetting, "top"))
leftHudOffset = osg::Vec3(0.025f, -.05f, .066f);
osg::Vec3 vkeyboardOffset = leftHudOffset + osg::Vec3(0,0.0001,0);
LayerConfig virtualKeyboardConfig = LayerConfig{
10, 10,
false, false,
osg::Vec4{0.f,0.f,0.f,.75f}, osg::Vec4{0.f,0.f,0.f,.75f},
osg::Vec3(0.025f,-.0501f,.066f), // offset (meters) vkeyboardOffset, // offset (meters)
osg::Vec2(0.f,0.5f), // center (model space) osg::Vec2(0.f,0.5f), // center (model space)
osg::Vec2(.25f, .25f), // extent (meters) osg::Vec2(.25f, .25f), // extent (meters)
2048, // Spatial resolution (pixels per meter) 2048, // Spatial resolution (pixels per meter)
@ -501,53 +524,24 @@ namespace MWVR
"", "",
true true
}; };
LayerConfig statusHUDConfig = LayerConfig
static const float sSideBySideRadius = 1.f;
static const float sSideBySideAzimuthInterval = -osg::PI_4;
static const LayerConfig createSideBySideConfig(int priority)
{
return LayerConfig{
priority,
true, // side-by-side
gDefaultConfig.backgroundColor,
osg::Vec3(0.f,sSideBySideRadius,-.25f), // offset
gDefaultConfig.center,
radiusAngleWidth(sSideBySideRadius, sSideBySideAzimuthInterval), // extent (meters)
gDefaultConfig.spatialResolution,
gDefaultConfig.pixelResolution,
osg::Vec2(0.70f, 0.70f),
SizingMode::Fixed,
gDefaultConfig.trackingMode,
"",
false
};
};
LayerConfig gStatsWindowConfig = createSideBySideConfig(0);
LayerConfig gInventoryWindowConfig = createSideBySideConfig(1);
LayerConfig gSpellWindowConfig = createSideBySideConfig(2);
LayerConfig gMapWindowConfig = createSideBySideConfig(3);
LayerConfig gInventoryCompanionWindowConfig = createSideBySideConfig(4);
LayerConfig gDialogueWindowConfig = createSideBySideConfig(5);
LayerConfig gStatusHUDConfig = LayerConfig
{ {
0, 0,
false, // side-by-side false, // side-by-side
osg::Vec4{}, // background osg::Vec4{}, // background
osg::Vec3(0.025f,-.050f,.066f), // offset (meters) leftHudOffset, // offset (meters)
osg::Vec2(0.f,0.5f), // center (model space) osg::Vec2(0.f,0.5f), // center (model space)
osg::Vec2(.1f, .1f), // extent (meters) osg::Vec2(.1f, .1f), // extent (meters)
1024, // resolution (pixels per meter) 1024, // resolution (pixels per meter)
osg::Vec2i(1024,1024), osg::Vec2i(1024,1024),
gDefaultConfig.myGUIViewSize, defaultConfig.myGUIViewSize,
SizingMode::Auto, SizingMode::Auto,
TrackingMode::HudLeftHand, TrackingMode::HudLeftHand,
"", "",
false false
}; };
LayerConfig gPopupConfig = LayerConfig LayerConfig popupConfig = LayerConfig
{ {
0, 0,
false, // side-by-side false, // side-by-side
@ -557,7 +551,7 @@ namespace MWVR
osg::Vec2(.1f, .1f), // extent (meters) osg::Vec2(.1f, .1f), // extent (meters)
1024, // resolution (pixels per meter) 1024, // resolution (pixels per meter)
osg::Vec2i(2048,2048), osg::Vec2i(2048,2048),
gDefaultConfig.myGUIViewSize, defaultConfig.myGUIViewSize,
SizingMode::Auto, SizingMode::Auto,
TrackingMode::HudRightHand, TrackingMode::HudRightHand,
"", "",
@ -566,26 +560,32 @@ namespace MWVR
static std::map<std::string, LayerConfig&> gLayerConfigs = mLayerConfigs = std::map<std::string, LayerConfig>
{ {
{"StatusHUD", gStatusHUDConfig}, {"DefaultConfig", defaultConfig},
{"Tooltip", gPopupConfig}, {"StatusHUD", statusHUDConfig},
{"JournalBooks", gJournalBooksConfig}, {"Tooltip", popupConfig},
{"InventoryCompanionWindow", gInventoryCompanionWindowConfig}, {"JournalBooks", journalBooksConfig},
{"InventoryWindow", gInventoryWindowConfig}, {"InventoryCompanionWindow", inventoryCompanionWindowConfig},
{"SpellWindow", gSpellWindowConfig}, {"InventoryWindow", inventoryWindowConfig},
{"MapWindow", gMapWindowConfig}, {"SpellWindow", spellWindowConfig},
{"StatsWindow", gStatsWindowConfig}, {"MapWindow", mapWindowConfig},
{"DialogueWindow", gDialogueWindowConfig}, {"StatsWindow", statsWindowConfig},
{"MessageBox", gMessageBoxConfig}, {"DialogueWindow", dialogueWindowConfig},
{"Windows", gDefaultWindowsConfig}, {"MessageBox", messageBoxConfig},
{"MainMenu", gMainMenuConfig}, {"Windows", defaultWindowsConfig},
{"Notification", gNotificationConfig}, {"MainMenu", mainMenuConfig},
{"InputBlocker", gVideoPlayerConfig}, {"Notification", notificationConfig},
{"Menu", gVideoPlayerConfig}, {"InputBlocker", videoPlayerConfig},
{"LoadingScreen", gLoadingScreenConfig}, {"Menu", videoPlayerConfig},
{"VirtualKeyboard", gVirtualKeyboardConfig}, {"LoadingScreen", loadingScreenConfig},
{"VirtualKeyboard", virtualKeyboardConfig},
}; };
}
VRGUIManager::~VRGUIManager(void)
{
}
static std::set<std::string> layerBlacklist = static std::set<std::string> layerBlacklist =
{ {
@ -612,16 +612,17 @@ namespace MWVR
void VRGUIManager::insertLayer(MyGUI::ILayer* layer) void VRGUIManager::insertLayer(MyGUI::ILayer* layer)
{ {
LayerConfig config = gDefaultConfig; LayerConfig config{};
const auto& name = layer->getName(); const auto& name = layer->getName();
auto configIt = gLayerConfigs.find(name); auto configIt = mLayerConfigs.find(name);
if (configIt != gLayerConfigs.end()) if (configIt != mLayerConfigs.end())
{ {
config = configIt->second; config = configIt->second;
} }
else else
{ {
Log(Debug::Warning) << "Layer " << name << " has no configuration, using default"; Log(Debug::Warning) << "Layer " << name << " has no configuration, using default";
config = mLayerConfigs["DefaultConfig"];
} }
auto vrlayer = std::shared_ptr<VRGUILayer>(new VRGUILayer( auto vrlayer = std::shared_ptr<VRGUILayer>(new VRGUILayer(

View file

@ -201,6 +201,7 @@ namespace MWVR
MyGUI::Widget* mFocusWidget{ nullptr }; MyGUI::Widget* mFocusWidget{ nullptr };
MyGUI::Widget* mModalWindow{ nullptr }; MyGUI::Widget* mModalWindow{ nullptr };
osg::observer_ptr<osg::Camera> mCamera{ nullptr }; osg::observer_ptr<osg::Camera> mCamera{ nullptr };
std::map<std::string, LayerConfig> mLayerConfigs{};
}; };
} }

View file

@ -982,6 +982,11 @@ haptics enabled = true
# If true, movement direction is taken from the left hand tracker, instead of your head. # If true, movement direction is taken from the left hand tracker, instead of your head.
hand directed movement = false hand directed movement = false
# Position of the hud over the left hand
# Valid options are: top, wrist
left hand hud position = wrist
[VR Debug] [VR Debug]
# Openmw will sync with openxr at the beginning of this phase in the rendering pipeline. From early to late in the pipeline the options are update, cull, draw, and swap in that order. If you experience visual glitches such as frames jittering across your vision, try changing this to an earlier phase. # Openmw will sync with openxr at the beginning of this phase in the rendering pipeline. From early to late in the pipeline the options are update, cull, draw, and swap in that order. If you experience visual glitches such as frames jittering across your vision, try changing this to an earlier phase.
openxr sync phase = draw openxr sync phase = draw