Additionial positionining/locations for overlays.
This commit is contained in:
parent
91e5abe425
commit
5713d22935
|
|
@ -0,0 +1,25 @@
|
|||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
||||
|
|
@ -1,18 +1,39 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Valve.VR;
|
||||
using VRDash.UI.LocationEditors;
|
||||
using VRDash.Utilities;
|
||||
|
||||
namespace VRDash.Overlay.Config.OverlayLocation
|
||||
{
|
||||
[OverlayLocationInfo("Controller", typeof(ControllerLocationEditor))]
|
||||
public class ControllerLocation : IOverlayLocation
|
||||
{
|
||||
public ControllerHand Controller { get; private set; } = ControllerHand.Left;
|
||||
|
||||
[JsonIgnore]
|
||||
public Matrix3x4 Location { get; private set; } = new Matrix3x4(new Vector4(1, 0, 0, 0),
|
||||
new Vector4(0, 1, 0, 0),
|
||||
new Vector4(0, 0, 1, 0));
|
||||
|
||||
ulong m_ControllerIndex = OpenVR.k_unTrackedDeviceIndexInvalid;
|
||||
public float PosX { get; set; } = 0;
|
||||
public float PosY { get; set; } = 0;
|
||||
public float PosZ { get; set; } = 0;
|
||||
|
||||
public float RotP { get; set; } = 0;
|
||||
public float RotY { get; set; } = 0;
|
||||
public float RotR { get; set; } = 0;
|
||||
|
||||
public float ScaleX { get; set; } = 1;
|
||||
public float ScaleY { get; set; } = 1;
|
||||
public float ScaleZ { get; set; } = 1;
|
||||
|
||||
uint m_ControllerIndex = OpenVR.k_unTrackedDeviceIndexInvalid;
|
||||
DateTime m_LastCheck = DateTime.MinValue;
|
||||
|
||||
IOverlay m_Overlay = null;
|
||||
|
|
@ -32,29 +53,60 @@ namespace VRDash.Overlay.Config.OverlayLocation
|
|||
|
||||
m_Overlay = overlay;
|
||||
|
||||
|
||||
return new OverlayHandles(overlayHandle, 0);
|
||||
}
|
||||
|
||||
private void Overlay_Update(object sender, EventArgs e)
|
||||
{
|
||||
//Check if handle is invalid or if we should just refresh just in case.
|
||||
if(m_ControllerIndex == OpenVR.k_unTrackedDeviceIndexInvalid || DateTime.Now.Subtract(m_LastCheck).TotalSeconds >= 10)
|
||||
if(m_ControllerIndex == OpenVR.k_unTrackedDeviceIndexInvalid || DateTime.Now.Subtract(m_LastCheck).TotalSeconds >= 1)
|
||||
{
|
||||
//Get proper hand
|
||||
ETrackedControllerRole role = Controller == ControllerHand.Left ? ETrackedControllerRole.LeftHand : ETrackedControllerRole.RightHand;
|
||||
|
||||
var controllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(role);
|
||||
uint controllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(role);
|
||||
|
||||
MathHelper.DegreesToRadians(RotP);
|
||||
var quat = Quaternion.FromEulerAngles(MathHelper.DegreesToRadians(RotP), MathHelper.DegreesToRadians(RotY), MathHelper.DegreesToRadians(RotR));
|
||||
Location = Matrix3x4.Mult(Matrix3x4.CreateTranslation(PosX, PosY, PosZ), Matrix3x4.Mult(Matrix3x4.CreateFromQuaternion(quat), Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ)));
|
||||
|
||||
|
||||
//Location = Matrix3x4.CreateTranslation(PosX, PosY, PosZ);
|
||||
//Location = Matrix3x4.Add(Matrix3x4.CreateFromQuaternion(quat), Location);
|
||||
//Location = Matrix3x4.Add(Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ), Location);
|
||||
|
||||
|
||||
|
||||
//Index changed, need to update the overlay
|
||||
if (controllerIndex != m_ControllerIndex)
|
||||
{
|
||||
m_ControllerIndex = controllerIndex;
|
||||
HmdMatrix34_t matrix = new HmdMatrix34_t();
|
||||
var err = OpenVR.Overlay.SetOverlayTransformOverlayRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
|
||||
|
||||
var matrix = Location.ToOpenVRMatrix();
|
||||
|
||||
var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
|
||||
|
||||
if (err != EVROverlayError.None)
|
||||
{
|
||||
this.GetLogger().Warn($"Error setting tracked device relative to {Controller} hand: {err}");
|
||||
this.GetLogger().Warn($"[{m_Overlay.OverlayConfig.Name}] Error setting tracked device relative to {Controller} hand: {err}");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.GetLogger().Info($"[{m_Overlay.OverlayConfig.Name}] Controller index updated.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Update the location
|
||||
var matrix = Location.ToOpenVRMatrix();
|
||||
|
||||
var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
|
||||
|
||||
if (err != EVROverlayError.None)
|
||||
{
|
||||
this.GetLogger().Warn($"[{m_Overlay.OverlayConfig.Name}] Error setting tracked device relative to {Controller} hand: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
m_LastCheck = DateTime.Now;
|
||||
|
|
|
|||
|
|
@ -125,10 +125,10 @@ namespace VRDash.Overlay
|
|||
var overlay = OpenVR.Overlay;
|
||||
|
||||
Config.OverlayLocation.OverlayHandles overlayHandles = Config.Location.CreateOverlay(Config.Key, Config.Name, this);
|
||||
|
||||
m_OverlayHandle = overlayHandles.OverlayHandle;
|
||||
m_ThumbnailIcon = overlayHandles.ThumbnailHandle;
|
||||
|
||||
var tempError = OpenVR.Overlay.ShowOverlay(m_OverlayHandle);
|
||||
//EVROverlayError err = overlay.CreateDashboardOverlay(Config.Key, Config.Name, ref m_OverlayHandle, ref m_ThumbnailIcon);
|
||||
|
||||
//if (err != EVROverlayError.None)
|
||||
|
|
@ -187,14 +187,15 @@ namespace VRDash.Overlay
|
|||
//#endregion
|
||||
|
||||
//Skip rendering if overlay isn't visible
|
||||
//#if !DEBUG
|
||||
if ((m_OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) || overlay == null || (!overlay.IsOverlayVisible(m_OverlayHandle)))
|
||||
//#if !DEBUG
|
||||
bool isVisible = overlay.IsOverlayVisible(m_OverlayHandle);
|
||||
if ((m_OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) || overlay == null || (!isVisible))
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
CurrentFPS = 0;
|
||||
continue;
|
||||
}
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace VRDash.Overlay
|
|||
|
||||
m_OverlayHandle = overlayHandles.OverlayHandle;
|
||||
m_ThumbnailIcon = overlayHandles.ThumbnailHandle;
|
||||
|
||||
OpenVR.Overlay.ShowOverlay(m_OverlayHandle);
|
||||
|
||||
m_Running = true;
|
||||
m_EventPumpTask = Task.Factory.StartNew(() => { EventPump(); });
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
<UserControl x:Class="VRDash.UI.LocationEditors.ControllerLocationEditor"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:VRDash.UI.LocationEditors"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40" />
|
||||
<ColumnDefinition Width="40" />
|
||||
<ColumnDefinition Width="40" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox Grid.Row="0" Grid.Column="0" Text="{Binding Location.PosX}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Location.PosY}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="2" Text="{Binding Location.PosZ}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
|
||||
<TextBox Grid.Row="1" Grid.Column="0" Text="{Binding Location.RotP}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Location.RotY}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Location.RotR}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
|
||||
<TextBox Grid.Row="2" Grid.Column="0" Text="{Binding Location.ScaleX}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Location.ScaleY}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding Location.ScaleZ}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using VRDash.Overlay.Config.OverlayLocation;
|
||||
|
||||
namespace VRDash.UI.LocationEditors
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ControllerLocationEditor.xaml
|
||||
/// </summary>
|
||||
public partial class ControllerLocationEditor : UserControl
|
||||
{
|
||||
public ControllerLocation Location { get; set; } = null;
|
||||
public ControllerLocationEditor(ControllerLocation loction)
|
||||
{
|
||||
Location = loction;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
Location.ResetCheckTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ namespace VRDash.UI
|
|||
OverlayLocationInfo locationInfo = overlayLocationAttributes.Single(x => x.OverlayLocationType == Config.Location.GetType()).Info;
|
||||
if (locationInfo.LocationEditorType != null)
|
||||
{
|
||||
UserControl locationEditor = (UserControl)Activator.CreateInstance(locationInfo.LocationEditorType);
|
||||
UserControl locationEditor = (UserControl)Activator.CreateInstance(locationInfo.LocationEditorType, new object[] { Config.Location });
|
||||
bdrLocationEditor.Child = locationEditor;
|
||||
}
|
||||
#if DEBUG
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Valve.VR;
|
||||
|
||||
namespace VRDash.Utilities
|
||||
{
|
||||
public static class OpenTKExtensions
|
||||
{
|
||||
public static HmdMatrix34_t ToOpenVRMatrix(this Matrix3x4 matrix)
|
||||
{
|
||||
var newmatrix = new HmdMatrix34_t();
|
||||
|
||||
newmatrix.m0 = matrix.M11;
|
||||
newmatrix.m1 = matrix.M12;
|
||||
newmatrix.m2 = matrix.M13;
|
||||
newmatrix.m3 = matrix.M14;
|
||||
|
||||
newmatrix.m4 = matrix.M21;
|
||||
newmatrix.m5 = matrix.M22;
|
||||
newmatrix.m6 = matrix.M23;
|
||||
newmatrix.m7 = matrix.M24;
|
||||
|
||||
newmatrix.m8 = matrix.M31;
|
||||
newmatrix.m9 = matrix.M32;
|
||||
newmatrix.m10 = matrix.M33;
|
||||
newmatrix.m11 = matrix.M34;
|
||||
|
||||
return newmatrix;
|
||||
}
|
||||
|
||||
public static Matrix3x4 ToOpenVRMatrix(this HmdMatrix34_t matrix)
|
||||
{
|
||||
Matrix3x4 newmatrix = new Matrix3x4();
|
||||
|
||||
newmatrix.M11 = matrix.m0;
|
||||
newmatrix.M12 = matrix.m1;
|
||||
newmatrix.M13 = matrix.m2;
|
||||
newmatrix.M14 = matrix.m3;
|
||||
|
||||
newmatrix.M21 = matrix.m4;
|
||||
newmatrix.M22 = matrix.m5;
|
||||
newmatrix.M23 = matrix.m6;
|
||||
newmatrix.M24 = matrix.m7;
|
||||
|
||||
newmatrix.M31 = matrix.m8;
|
||||
newmatrix.M32 = matrix.m9;
|
||||
newmatrix.M33 = matrix.m10;
|
||||
newmatrix.M34 = matrix.m11;
|
||||
|
||||
return newmatrix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -60,6 +60,9 @@
|
|||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenTK.3.0.1\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -120,6 +123,9 @@
|
|||
<Compile Include="UI\IOverlayEditor.cs" />
|
||||
<Compile Include="UI\IOverlayListViewItem.cs" />
|
||||
<Compile Include="UI\ISelectorEditor.cs" />
|
||||
<Compile Include="UI\LocationEditors\ControllerLocationEditor.xaml.cs">
|
||||
<DependentUpon>ControllerLocationEditor.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\MonitorOverlayEditor.xaml.cs">
|
||||
<DependentUpon>MonitorOverlayEditor.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -141,6 +147,7 @@
|
|||
<Compile Include="UI\WindowSelectorEditor.xaml.cs">
|
||||
<DependentUpon>WindowSelectorEditor.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\OpenTKExtensions.cs" />
|
||||
<Compile Include="Utilities\User32.cs" />
|
||||
<Compile Include="WindowSelectors\FromProcessName.cs" />
|
||||
<Compile Include="WindowSelectors\FromWindowTitle.cs" />
|
||||
|
|
@ -166,6 +173,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UI\LocationEditors\ControllerLocationEditor.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UI\MonitorOverlayEditor.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
|
@ -215,6 +226,7 @@
|
|||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<package id="JsonNet.PrivateSettersContractResolvers.Source" version="0.1.0" targetFramework="net45" developmentDependency="true" />
|
||||
<package id="log4net" version="2.0.8" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net45" />
|
||||
<package id="OpenTK" version="3.0.1" targetFramework="net45" />
|
||||
<package id="SharpDX" version="4.2.0" targetFramework="net45" />
|
||||
<package id="SharpDX.Direct3D11" version="4.2.0" targetFramework="net45" />
|
||||
<package id="SharpDX.DXGI" version="4.2.0" targetFramework="net45" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue