Compare commits

..

No commits in common. "8d5ec72de129e4a416c6c66cb49de0024f386f89" and "f1b647a1c503a962787ea31d3ff7117b0f832ccc" have entirely different histories.

11 changed files with 123 additions and 557 deletions

View File

@ -17,7 +17,7 @@ namespace VRDash
{
public static void Setup()
{
var configLoc = ProfileManager.ConfigDirectory + @"\Logs\VRDash_";
var configLoc = ProfileManager.ConfigDirectory + @"\Logs\VRDash.log";
if (!Directory.Exists(Path.GetDirectoryName(configLoc)))
{
@ -38,10 +38,9 @@ namespace VRDash
roller.File = configLoc;
roller.Layout = patternLayout;
roller.MaxSizeRollBackups = 10;
roller.MaximumFileSize = "1MB";
roller.RollingStyle = RollingFileAppender.RollingMode.Date;
roller.DatePattern = @"yyyyMMdd.lo\g";
roller.StaticLogFileName = false;
roller.MaximumFileSize = "10MB";
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.StaticLogFileName = true;
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
#endregion

View File

@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OpenTK;
using System;
using System.Collections.Generic;
using System.IO;
@ -61,6 +60,11 @@ namespace VRDash
{
ProfileManager.SaveProfile();
}
if(e.Key == Key.F6 || e.Key == Key.P)
{
var profile = ProfileManager.LoadProfile();
LoadProfile(profile);
}
};
try
@ -228,63 +232,16 @@ namespace VRDash
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F1)
{
//var quat = Quaternion.FromEulerAngles(MathHelper.DegreesToRadians(41), MathHelper.DegreesToRadians(44), MathHelper.DegreesToRadians(43));
//var matrix = Matrix3x4.Mult(Matrix3x4.CreateTranslation(11, 12, 13), Matrix3x4.Mult(Matrix3x4.CreateFromQuaternion(quat), Matrix3x4.CreateScale(4, 4, 4)));
//Vector3 transform = new Vector3(matrix.M14, matrix.M24, matrix.M34);
//Vector3 scaling = new Vector3((float)Math.Sqrt((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12) + (matrix.M13 * matrix.M13)),
// (float)Math.Sqrt((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22) + (matrix.M23 * matrix.M23)),
// (float)Math.Sqrt((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32) + (matrix.M33 * matrix.M33)));
//Matrix3 rotation = new Matrix3()
//{
// M11 = matrix.M11 / scaling.X, M12 = matrix.M12 / scaling.X, M13 = matrix.M13 / scaling.X,
// M21 = matrix.M21 / scaling.Y, M22 = matrix.M22 / scaling.Y, M23 = matrix.M23 / scaling.Y,
// M31 = matrix.M31 / scaling.Z, M32 = matrix.M32 / scaling.Z, M33 = matrix.M33 / scaling.Z
//};
//Quaternion quatRes = Quaternion.FromMatrix(rotation);
//var q = quatRes;
//double pitch = 0;
//double yaw = 0;
//double roll = 0;
//double sinr_cosp = +2.0 * (q.W * q.X + q.Y * q.Z);
//double cosr_cosp = +1.0 - 2.0 * (q.X * q.X + q.Y * q.Y);
//roll = Math.Atan2(sinr_cosp, cosr_cosp);
//// pitch (y-axis rotation)
//double sinp = +2.0 * (q.W * q.Y - q.Z * q.X);
//if ( Math.Abs(sinp) >= 1)
// pitch = C.math.copysign(MathHelper.Pi / 2, sinp); // use 90 degrees if out of range
//else
// pitch = Math.Asin(sinp);
//// yaw (z-axis rotation)
//double siny_cosp = +2.0 * (q.W * q.Z + q.X * q.Y);
//double cosy_cosp = +1.0 - 2.0 * (q.Y * q.Y + q.Z * q.Z);
//yaw = Math.Atan2(siny_cosp, cosy_cosp);
//pitch = MathHelper.RadiansToDegrees(pitch);
//yaw = MathHelper.RadiansToDegrees(yaw);
//roll = MathHelper.RadiansToDegrees(roll);
//var conf = new MonitorOverlayConfig();
//conf.Name = "Test Browser";
//conf.Key = "asdfasdf";
//conf.Location = new Overlay.Config.OverlayLocation.DashboardLocation();
//var overlay = new Overlay.BrowserOverlay(conf);
//overlay.Create();
//overlay.Show();
}
//if(e.Key == Key.F1)
//{
// var conf = new MonitorOverlayConfig();
// conf.Name = "Test Browser";
// conf.Key = "asdfasdf";
// conf.Location = new Overlay.Config.OverlayLocation.DashboardLocation();
// var overlay = new Overlay.BrowserOverlay(conf);
// overlay.Create();
// overlay.Show();
//}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)

View File

@ -102,12 +102,12 @@ namespace VRDash.Overlay
public void Destroy()
{
m_ScreenTexture?.Dispose();
m_Device.ImmediateContext?.ClearState();
m_Device.ImmediateContext?.Flush();
m_Device?.Dispose();
m_Adapter?.Dispose();
m_Factory?.Dispose();
m_ScreenTexture.Dispose();
m_Device.ImmediateContext.ClearState();
m_Device.ImmediateContext.Flush();
m_Device.Dispose();
m_Adapter.Dispose();
m_Factory.Dispose();
CurrentFPS = 0;
var err = OpenVR.Overlay.DestroyOverlay(m_OverlayHandle);

View File

@ -1,185 +1,124 @@
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;
//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("Playspace", typeof(PlayspaceLocationEditor))]
public class PlayspaceLocation : IOverlayLocation
{
//namespace VRDash.Overlay.Config.OverlayLocation
//{
// [OverlayLocationInfo("Playspace", typeof(ControllerLocationEditor))]
// public class PlayspaceLocation : IOverlayLocation
// {
// public ControllerHand Controller { get; 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));
// [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));
public float PosX { get; set; } = 0;
public float PosY { get; set; } = 0;
public float PosZ { get; set; } = 0;
// 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 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;
// public float ScaleX { get; set; } = 1;
// public float ScaleY { get; set; } = 1;
// public float ScaleZ { get; set; } = 1;
// DateTime m_LastCheck = DateTime.MinValue;
DateTime m_LastCheck = DateTime.MinValue;
// IOverlay m_Overlay = null;
[JsonIgnore]
public IOverlay Overlay { get; internal set; } = null;
// public OverlayHandles CreateOverlay(string key, string name, IOverlay overlay)
// {
// ulong overlayHandle = 0;
// EVROverlayError err = OpenVR.Overlay.CreateOverlay(key, name, ref overlayHandle);
public OverlayHandles CreateOverlay(string key, string name, IOverlay overlay)
{
ulong overlayHandle = 0;
EVROverlayError err = OpenVR.Overlay.CreateOverlay(key, name, ref overlayHandle);
// if (err != EVROverlayError.None){
// throw new Exception($"Error creating overlay: {err}");
// }
if (err != EVROverlayError.None)
{
throw new Exception($"Error creating overlay: {err}");
}
// ETrackedDeviceClass type = OpenVR.System.GetTrackedDeviceClass(0);
ETrackedDeviceClass type = OpenVR.System.GetTrackedDeviceClass(0);
// overlay.Update += Overlay_Update;
overlay.Update += Overlay_Update;
Overlay = overlay;
return new OverlayHandles(overlayHandle, 0);
}
public void SetLocationBasedOnController()
{
uint controllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
TrackedDevicePose_t pose = new TrackedDevicePose_t();
TrackedDevicePose_t gamePose = new TrackedDevicePose_t();
var err = OpenVR.Compositor.GetLastPoseForTrackedDeviceIndex(controllerIndex, ref pose, ref gamePose);
if (err != EVRCompositorError.None)
{
this.GetLogger(Overlay).Warn($"Unable to set location based on controller: {err}");
return;
}
if (pose.eTrackingResult != ETrackingResult.Running_OK)
{
this.GetLogger(Overlay).Warn($"Unable to get reliable tracking: {pose.eTrackingResult}");
}
var matrix = gamePose.mDeviceToAbsoluteTracking.ToOpenTKMatrix();
DecomposeMatrix(matrix);
}
private void DecomposeMatrix(Matrix3x4 matrix)
{
Vector3 transform = new Vector3(matrix.M14, matrix.M24, matrix.M34);
PosX = transform.X;
PosY = transform.Y;
PosZ = transform.Z;
Vector3 scaling = new Vector3((float)Math.Sqrt((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12) + (matrix.M13 * matrix.M13)),
(float)Math.Sqrt((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22) + (matrix.M23 * matrix.M23)),
(float)Math.Sqrt((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32) + (matrix.M33 * matrix.M33)));
//ScaleX = scaling.X;
//ScaleY = scaling.Y;
//ScaleZ = scaling.Z;
Matrix3 rotation = new Matrix3()
{
M11 = matrix.M11 / scaling.X,
M12 = matrix.M12 / scaling.X,
M13 = matrix.M13 / scaling.X,
M21 = matrix.M21 / scaling.Y,
M22 = matrix.M22 / scaling.Y,
M23 = matrix.M23 / scaling.Y,
M31 = matrix.M31 / scaling.Z,
M32 = matrix.M32 / scaling.Z,
M33 = matrix.M33 / scaling.Z
};
//Quaternion quatRes = Quaternion.FromMatrix(rotation);
// m_Overlay = overlay;
//Face center of playspace (hopefully)
Vector3 up = new Vector3(0, 1, 0);
// return new OverlayHandles(overlayHandle, 0);
// }
Quaternion quatRes = OpenTKExtensions.QuaternionLookRotation(new Vector3(0, 0, 0) - transform);
// public void SetLocationBasedOnController()
// {
// uint controllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
var q = quatRes;
// TrackedDevicePose_t pose = new TrackedDevicePose_t();
// TrackedDevicePose_t gamePose = new TrackedDevicePose_t();
// var err = OpenVR.Compositor.GetLastPoseForTrackedDeviceIndex(controllerIndex, ref pose, ref gamePose);
// if(err != EVRCompositorError.None)
// {
// this.GetLogger(m_Overlay).Warn($"Unable to set location based on controller: {err}");
// return;
// }
double pitch = 0;
double yaw = 0;
double roll = 0;
// if(pose.eTrackingResult != ETrackingResult.Running_OK)
// {
// this.GetLogger(m_Overlay).Warn($"Unable to get reliable tracking: {pose.eTrackingResult}");
// }
double sinr_cosp = +2.0 * (q.W * q.X + q.Y * q.Z);
double cosr_cosp = +1.0 - 2.0 * (q.X * q.X + q.Y * q.Y);
roll = Math.Atan2(sinr_cosp, cosr_cosp);
// var matrix = pose.mDeviceToAbsoluteTracking.ToOpenTKMatrix();
// matrix
// }
// private void Overlay_Update(object sender, EventArgs e)
// {
// if (DateTime.Now.Subtract(m_LastCheck).TotalSeconds >= 1)
// {
// 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)));
// if (m_Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; }
// pitch (y-axis rotation)
double sinp = +2.0 * (q.W * q.Y - q.Z * q.X);
if (Math.Abs(sinp) >= 1)
pitch = C.math.copysign(MathHelper.Pi / 2, sinp); // use 90 degrees if out of range
else
pitch = Math.Asin(sinp);
// var matrix = Location.ToOpenVRMatrix();
// yaw (z-axis rotation)
double siny_cosp = +2.0 * (q.W * q.Z + q.X * q.Y);
double cosy_cosp = +1.0 - 2.0 * (q.Y * q.Y + q.Z * q.Z);
yaw = Math.Atan2(siny_cosp, cosy_cosp);
// var err = OpenVR.Overlay.SetOverlayTransformAbsolute(m_Overlay.OverlayHandle, ETrackingUniverseOrigin.TrackingUniverseStanding, ref matrix);
pitch = MathHelper.RadiansToDegrees(pitch);
yaw = MathHelper.RadiansToDegrees(yaw);
roll = MathHelper.RadiansToDegrees(roll);
// //var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
//RotP = (float)pitch;
//RotY = (float)yaw;
//RotR = (float)roll;
}
// if (err != EVROverlayError.None)
// {
// this.GetLogger(m_Overlay).Warn($"Error setting tracked device relative to {Controller} hand: {err}");
// }
// else
// {
// this.GetLogger(m_Overlay).Info($"Controller index updated.");
// }
private void Overlay_Update(object sender, EventArgs e)
{
if (DateTime.Now.Subtract(m_LastCheck).TotalSeconds >= 1)
{
// m_LastCheck = DateTime.Now;
// }
// }
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)));
// public void ResetCheckTimer()
// {
// m_LastCheck = DateTime.MinValue;
// }
if (Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; }
var matrix = Location.ToOpenVRMatrix();
var err = OpenVR.Overlay.SetOverlayTransformAbsolute(Overlay.OverlayHandle, ETrackingUniverseOrigin.TrackingUniverseStanding, ref matrix);
//var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
if (err != EVROverlayError.None)
{
this.GetLogger(Overlay).Warn($"Error setting overlay absolute location: {err}");
}
m_LastCheck = DateTime.Now;
}
}
public void ResetCheckTimer()
{
m_LastCheck = DateTime.MinValue;
}
}
}
// public enum ControllerHand
// {
// Left = 0,
// Right = 1
// }
// }
//}

View File

@ -1,75 +0,0 @@
<UserControl x:Class="VRDash.UI.LocationEditors.PlayspaceLocationEditor"
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" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">Position:</TextBlock>
<DockPanel Grid.Row="1" Grid.Column="1" >
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">X:</TextBlock>
<TextBox Text="{Binding Location.PosX}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="1" Grid.Column="2" >
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">Y:</TextBlock>
<TextBox Text="{Binding Location.PosY}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="1" Grid.Column="3">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">Z:</TextBlock>
<TextBox Text="{Binding Location.PosZ}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">Rotation:</TextBlock>
<DockPanel Grid.Row="2" Grid.Column="1">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">P:</TextBlock>
<TextBox Text="{Binding Location.RotP}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="2" Grid.Column="2">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">Y:</TextBlock>
<TextBox Text="{Binding Location.RotY}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="2" Grid.Column="3">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">R:</TextBlock>
<TextBox Text="{Binding Location.RotR}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">Scale:</TextBlock>
<DockPanel Grid.Row="3" Grid.Column="1">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">X:</TextBlock>
<TextBox Text="{Binding Location.ScaleX}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="3" Grid.Column="2">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">Y:</TextBlock>
<TextBox Text="{Binding Location.ScaleY}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="3" Grid.Column="3">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0">Z:</TextBlock>
<TextBox Text="{Binding Location.ScaleZ}" Margin="5,5,5,5" TextChanged="TextBox_TextChanged" MinWidth="30"/>
</DockPanel>
<DockPanel Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4">
<Button x:Name="btnFromController" Click="btnFromController_Click">Set Using Controller...</Button>
</DockPanel>
</Grid>
</UserControl>

View File

@ -1,80 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
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 Valve.VR;
using VRDash.Overlay.Config.OverlayLocation;
namespace VRDash.UI.LocationEditors
{
/// <summary>
/// Interaction logic for ControllerLocationEditor.xaml
/// </summary>
public partial class PlayspaceLocationEditor : UserControl
{
public PlayspaceLocation Location { get; set; } = null;
public PlayspaceLocationEditor(PlayspaceLocation loction)
{
Location = loction;
InitializeComponent();
DataContext = this;
//We're still in overlay creation mode. Don't display the button for now
if (Location.Overlay == null)
{
btnFromController.Visibility = Visibility.Hidden;
}
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
Location.ResetCheckTimer();
}
public void RefreshUI()
{
Panel container = (Panel)this.Content;
UIElementCollection children = container.Children;
List<FrameworkElement> lstElement = children.Cast<FrameworkElement>().ToList();
var lstControl = lstElement.OfType<Control>();
//Lazy way of updating all of those text boxes.
foreach(var control in children)
{
if (control.GetType() == typeof(DockPanel))
{
var dockPanel = (DockPanel)control;
foreach (var dcChild in dockPanel.Children)
{
if(dcChild.GetType() == typeof(TextBox))
{
var tb = (TextBox)dcChild;
tb.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
}
}
}
}
}
private void btnFromController_Click(object sender, RoutedEventArgs e)
{
PlayspaceLocationSelector sel = new PlayspaceLocationSelector(Location);
sel.ShowDialog();
RefreshUI();
}
}
}

View File

@ -1,18 +0,0 @@
<Window x:Class="VRDash.UI.PlayspaceLocationSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VRDash.UI"
mc:Ignorable="d"
Title="PlayspaceLocationSelector" Height="250" Width="400" Padding="5" ContentRendered="Window_ContentRendered">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" TextWrapping="Wrap" TextAlignment="Center" Margin="20">Close the SteamVR menu. Position your left controller where you'd like the overlay to be positioned. Press the application menu button, (the menu button above the touchpad) to drop the overlay there. Press 'Close' when finished.</TextBlock>
<Button x:Name="btnClose" Grid.Row="1" Click="btnClose_Click" Margin="5">Close</Button>
</Grid>
</Window>

View File

@ -1,78 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
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.Shapes;
using Valve.VR;
using VRDash.Overlay.Config.OverlayLocation;
namespace VRDash.UI
{
/// <summary>
/// Interaction logic for PlayspaceLocationSelector.xaml
/// </summary>
public partial class PlayspaceLocationSelector : Window
{
PlayspaceLocation m_Location = null;
Task m_Task = null;
bool m_Running = true;
uint m_ControllerIndex = OpenVR.k_unTrackedDeviceIndexInvalid;
public PlayspaceLocationSelector(PlayspaceLocation location)
{
InitializeComponent();
m_Location = location;
}
void RunTask()
{
while (m_Running)
{
VREvent_t ev = new VREvent_t();
while (OpenVR.System.PollNextEvent(ref ev, (uint)Marshal.SizeOf(ev)))
{
//If this is a button press, tracked device is the left controller, and it is the application button
if(ev.eventType == (uint)EVREventType.VREvent_ButtonUnpress && ev.trackedDeviceIndex == m_ControllerIndex && ev.data.controller.button == (uint)EVRButtonId.k_EButton_ApplicationMenu)
{
m_Location.SetLocationBasedOnController();
this.GetLogger().Debug("Setting overlay pos to left controller.");
}
}
}
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
m_Running = false;
m_Task?.Wait();
Close();
}
bool m_Shown = false;
private void Window_ContentRendered(object sender, EventArgs e)
{
if (m_Shown) { return; }
m_Shown = true;
m_ControllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
if (m_ControllerIndex == OpenVR.k_unTrackedDeviceIndexInvalid)
{
MessageBox.Show("Unable to identify left controller. Is it connected?", "Controller Ident Error", MessageBoxButton.OK, MessageBoxImage.Warning);
Close();
return;
}
m_Task = Task.Factory.StartNew(() => { RunTask(); });
}
}
}

View File

@ -10,66 +10,6 @@ namespace VRDash.Utilities
{
public static class OpenTKExtensions
{
public static Quaternion QuaternionLookRotation(Vector3 forward)
{
Vector3 up = new Vector3(0, 1, 0);
forward.Normalize();
Vector3 vector = Vector3.Normalize(forward);
Vector3 vector2 = Vector3.Normalize(Vector3.Cross(up, vector));
Vector3 vector3 = Vector3.Cross(vector, vector2);
var m00 = vector2.X;
var m01 = vector2.Y;
var m02 = vector2.Z;
var m10 = vector3.X;
var m11 = vector3.Y;
var m12 = vector3.Z;
var m20 = vector.X;
var m21 = vector.Y;
var m22 = vector.Z;
float num8 = (m00 + m11) + m22;
var quaternion = new Quaternion();
if (num8 > 0f)
{
var num = (float)Math.Sqrt(num8 + 1f);
quaternion.W = num * 0.5f;
num = 0.5f / num;
quaternion.X = (m12 - m21) * num;
quaternion.Y = (m20 - m02) * num;
quaternion.Z = (m01 - m10) * num;
return quaternion;
}
if ((m00 >= m11) && (m00 >= m22))
{
var num7 = (float)Math.Sqrt(((1f + m00) - m11) - m22);
var num4 = 0.5f / num7;
quaternion.X = 0.5f * num7;
quaternion.Y = (m01 + m10) * num4;
quaternion.Z = (m02 + m20) * num4;
quaternion.W = (m12 - m21) * num4;
return quaternion;
}
if (m11 > m22)
{
var num6 = (float)Math.Sqrt(((1f + m11) - m00) - m22);
var num3 = 0.5f / num6;
quaternion.X = (m10 + m01) * num3;
quaternion.Y = 0.5f * num6;
quaternion.Z = (m21 + m12) * num3;
quaternion.W = (m20 - m02) * num3;
return quaternion;
}
var num5 = (float)Math.Sqrt(((1f + m22) - m00) - m11);
var num2 = 0.5f / num5;
quaternion.X = (m20 + m02) * num2;
quaternion.Y = (m21 + m12) * num2;
quaternion.Z = 0.5f * num5;
quaternion.W = (m01 - m10) * num2;
return quaternion;
}
public static HmdMatrix34_t ToOpenVRMatrix(this Matrix3x4 matrix)
{
var newmatrix = new HmdMatrix34_t();

View File

@ -61,9 +61,6 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="C.math, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\C.math.NET.1.1\lib\net20\C.math.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
</Reference>
@ -144,9 +141,6 @@
<Compile Include="UI\IOverlayEditor.cs" />
<Compile Include="UI\IOverlayListViewItem.cs" />
<Compile Include="UI\ISelectorEditor.cs" />
<Compile Include="UI\LocationEditors\PlayspaceLocationEditor.xaml.cs">
<DependentUpon>PlayspaceLocationEditor.xaml</DependentUpon>
</Compile>
<Compile Include="UI\LocationEditors\ControllerLocationEditor.xaml.cs">
<DependentUpon>ControllerLocationEditor.xaml</DependentUpon>
</Compile>
@ -156,9 +150,6 @@
<Compile Include="UI\OverlayEditor.xaml.cs">
<DependentUpon>OverlayEditor.xaml</DependentUpon>
</Compile>
<Compile Include="UI\PlayspaceLocationSelector.xaml.cs">
<DependentUpon>PlayspaceLocationSelector.xaml</DependentUpon>
</Compile>
<Compile Include="UI\SelectorEditors\ProcessSelectorEditor.xaml.cs">
<DependentUpon>ProcessSelectorEditor.xaml</DependentUpon>
</Compile>
@ -212,10 +203,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\LocationEditors\PlayspaceLocationEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UI\LocationEditors\ControllerLocationEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -228,10 +215,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\PlayspaceLocationSelector.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\SelectorEditors\ProcessSelectorEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="C.math.NET" version="1.1" targetFramework="net452" />
<package id="cef.redist.x64" version="73.1.13" targetFramework="net452" />
<package id="cef.redist.x86" version="73.1.13" targetFramework="net452" />
<package id="CefSharp.Common" version="73.1.130" targetFramework="net452" />