Playspace Location is almost done. Need to fix rotation. Maybe make face user location.
This commit is contained in:
parent
f1b647a1c5
commit
8a3786f4ce
|
|
@ -17,7 +17,7 @@ namespace VRDash
|
|||
{
|
||||
public static void Setup()
|
||||
{
|
||||
var configLoc = ProfileManager.ConfigDirectory + @"\Logs\VRDash.log";
|
||||
var configLoc = ProfileManager.ConfigDirectory + @"\Logs\VRDash_";
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(configLoc)))
|
||||
{
|
||||
|
|
@ -38,9 +38,10 @@ namespace VRDash
|
|||
roller.File = configLoc;
|
||||
roller.Layout = patternLayout;
|
||||
roller.MaxSizeRollBackups = 10;
|
||||
roller.MaximumFileSize = "10MB";
|
||||
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
|
||||
roller.StaticLogFileName = true;
|
||||
roller.MaximumFileSize = "1MB";
|
||||
roller.RollingStyle = RollingFileAppender.RollingMode.Date;
|
||||
roller.DatePattern = @"yyyyMMdd.lo\g";
|
||||
roller.StaticLogFileName = false;
|
||||
roller.ActivateOptions();
|
||||
hierarchy.Root.AddAppender(roller);
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Newtonsoft.Json;
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
@ -232,16 +233,63 @@ namespace VRDash
|
|||
|
||||
private void Window_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
//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();
|
||||
//}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
|
|
|
|||
|
|
@ -1,124 +1,179 @@
|
|||
//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(ControllerLocationEditor))]
|
||||
// public class PlayspaceLocation : IOverlayLocation
|
||||
// {
|
||||
// public ControllerHand Controller { get; set; } = ControllerHand.Left;
|
||||
namespace VRDash.Overlay.Config.OverlayLocation
|
||||
{
|
||||
[OverlayLocationInfo("Playspace", typeof(PlayspaceLocationEditor))]
|
||||
public class PlayspaceLocation : IOverlayLocation
|
||||
{
|
||||
|
||||
// [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;
|
||||
|
||||
// DateTime m_LastCheck = DateTime.MinValue;
|
||||
public float ScaleX { get; set; } = 1;
|
||||
public float ScaleY { get; set; } = 1;
|
||||
public float ScaleZ { get; set; } = 1;
|
||||
|
||||
// IOverlay m_Overlay = null;
|
||||
DateTime m_LastCheck = DateTime.MinValue;
|
||||
|
||||
// public OverlayHandles CreateOverlay(string key, string name, IOverlay overlay)
|
||||
// {
|
||||
// ulong overlayHandle = 0;
|
||||
// EVROverlayError err = OpenVR.Overlay.CreateOverlay(key, name, ref overlayHandle);
|
||||
[JsonIgnore]
|
||||
public IOverlay Overlay { get; internal set; } = null;
|
||||
|
||||
// if (err != EVROverlayError.None){
|
||||
// throw new Exception($"Error creating overlay: {err}");
|
||||
// }
|
||||
public OverlayHandles CreateOverlay(string key, string name, IOverlay overlay)
|
||||
{
|
||||
ulong overlayHandle = 0;
|
||||
EVROverlayError err = OpenVR.Overlay.CreateOverlay(key, name, ref overlayHandle);
|
||||
|
||||
// ETrackedDeviceClass type = OpenVR.System.GetTrackedDeviceClass(0);
|
||||
if (err != EVROverlayError.None)
|
||||
{
|
||||
throw new Exception($"Error creating overlay: {err}");
|
||||
}
|
||||
|
||||
// overlay.Update += Overlay_Update;
|
||||
ETrackedDeviceClass type = OpenVR.System.GetTrackedDeviceClass(0);
|
||||
|
||||
// m_Overlay = overlay;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
// return new OverlayHandles(overlayHandle, 0);
|
||||
// }
|
||||
|
||||
// public void SetLocationBasedOnController()
|
||||
// {
|
||||
// uint controllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
|
||||
// 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);
|
||||
|
||||
// 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;
|
||||
// }
|
||||
// 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);
|
||||
|
||||
// if(pose.eTrackingResult != ETrackingResult.Running_OK)
|
||||
// {
|
||||
// this.GetLogger(m_Overlay).Warn($"Unable to get reliable tracking: {pose.eTrackingResult}");
|
||||
// }
|
||||
pitch = MathHelper.RadiansToDegrees(pitch);
|
||||
yaw = MathHelper.RadiansToDegrees(yaw);
|
||||
roll = MathHelper.RadiansToDegrees(roll);
|
||||
|
||||
// var matrix = pose.mDeviceToAbsoluteTracking.ToOpenTKMatrix();
|
||||
|
||||
// matrix
|
||||
// }
|
||||
RotP = (float)pitch;
|
||||
RotY = (float)yaw;
|
||||
RotR = (float)roll;
|
||||
}
|
||||
|
||||
// private void Overlay_Update(object sender, EventArgs e)
|
||||
// {
|
||||
// if (DateTime.Now.Subtract(m_LastCheck).TotalSeconds >= 1)
|
||||
// {
|
||||
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)));
|
||||
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; }
|
||||
if (Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; }
|
||||
|
||||
// var matrix = Location.ToOpenVRMatrix();
|
||||
var matrix = Location.ToOpenVRMatrix();
|
||||
|
||||
// var err = OpenVR.Overlay.SetOverlayTransformAbsolute(m_Overlay.OverlayHandle, ETrackingUniverseOrigin.TrackingUniverseStanding, ref matrix);
|
||||
var err = OpenVR.Overlay.SetOverlayTransformAbsolute(Overlay.OverlayHandle, ETrackingUniverseOrigin.TrackingUniverseStanding, ref matrix);
|
||||
|
||||
// //var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
|
||||
//var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
|
||||
|
||||
// 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.");
|
||||
// }
|
||||
if (err != EVROverlayError.None)
|
||||
{
|
||||
this.GetLogger(Overlay).Warn($"Error setting overlay absolute location: {err}");
|
||||
}
|
||||
|
||||
// m_LastCheck = DateTime.Now;
|
||||
// }
|
||||
// }
|
||||
m_LastCheck = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
// public void ResetCheckTimer()
|
||||
// {
|
||||
// m_LastCheck = DateTime.MinValue;
|
||||
// }
|
||||
|
||||
// public enum ControllerHand
|
||||
// {
|
||||
// Left = 0,
|
||||
// Right = 1
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public void ResetCheckTimer()
|
||||
{
|
||||
m_LastCheck = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
<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>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<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>
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
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(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,9 @@
|
|||
<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>
|
||||
|
|
@ -141,6 +144,9 @@
|
|||
<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>
|
||||
|
|
@ -150,6 +156,9 @@
|
|||
<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>
|
||||
|
|
@ -203,6 +212,10 @@
|
|||
<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>
|
||||
|
|
@ -215,6 +228,10 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?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" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue