First commit for sending out to Reddit testers.

This commit is contained in:
jrhodnik 2019-06-06 19:46:30 -04:00
parent a3d464197d
commit e3d8fa8094
6 changed files with 170 additions and 9 deletions

View File

@ -54,7 +54,15 @@ namespace VRDash.Overlay
Config = config; Config = config;
InitializeComponent(); InitializeComponent();
this.Show(); this.Show();
Width = Config.Width;
Height = Config.Height;
Config.SizeUpdated += Config_SizeUpdated;
}
private void Config_SizeUpdated(object sender, EventArgs e)
{
Width = Config.Width;
Height = Config.Height;
} }
Factory1 m_Factory = null; Factory1 m_Factory = null;

View File

@ -16,6 +16,30 @@ namespace VRDash.Overlay.Config
public string Content { get; set; } public string Content { get; set; }
public BrowserOverlayContentType ContentType { get; set; } public BrowserOverlayContentType ContentType { get; set; }
public event EventHandler SizeUpdated;
private int m_Width = 600;
public int Width
{
get { return m_Width; }
set
{
m_Width = value;
SizeUpdated?.Invoke(this, null);
}
}
private int m_Height = 600;
public int Height
{
get { return m_Height; }
set
{
m_Height = value;
SizeUpdated?.Invoke(this, null);
}
}
public void Initialize(IOverlay overlay) public void Initialize(IOverlay overlay)
{ {
//Nothing needs to be done here //Nothing needs to be done here

View File

@ -72,10 +72,6 @@ namespace VRDash.Overlay.Config.OverlayLocation
Location = Matrix3x4.Mult(Matrix3x4.CreateTranslation(PosX, PosY, PosZ), Matrix3x4.Mult(Matrix3x4.CreateFromQuaternion(quat), Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ))); 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);
if (m_Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; } if (m_Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; }
//Index changed, need to update the overlay //Index changed, need to update the overlay

View File

@ -0,0 +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;
//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));
// 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;
// DateTime m_LastCheck = DateTime.MinValue;
// IOverlay m_Overlay = null;
// 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}");
// }
// ETrackedDeviceClass type = OpenVR.System.GetTrackedDeviceClass(0);
// overlay.Update += Overlay_Update;
// m_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(m_Overlay).Warn($"Unable to set location based on controller: {err}");
// return;
// }
// if(pose.eTrackingResult != ETrackingResult.Running_OK)
// {
// this.GetLogger(m_Overlay).Warn($"Unable to get reliable tracking: {pose.eTrackingResult}");
// }
// 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; }
// var matrix = Location.ToOpenVRMatrix();
// var err = OpenVR.Overlay.SetOverlayTransformAbsolute(m_Overlay.OverlayHandle, ETrackingUniverseOrigin.TrackingUniverseStanding, 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.");
// }
// m_LastCheck = DateTime.Now;
// }
// }
// public void ResetCheckTimer()
// {
// m_LastCheck = DateTime.MinValue;
// }
// public enum ControllerHand
// {
// Left = 0,
// Right = 1
// }
// }
//}

View File

@ -8,6 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -23,7 +24,15 @@
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" >Content Type:</TextBlock> <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" >Content Type:</TextBlock>
<ComboBox x:Name="cbContentType" Grid.Row="1" Grid.Column="1" SelectedItem="{Binding Config.ContentType}" Margin="5,5,5,5" SelectionChanged="cbContentType_SelectionChanged"/> <ComboBox x:Name="cbContentType" Grid.Row="1" Grid.Column="1" SelectedItem="{Binding Config.ContentType}" Margin="5,5,5,5" SelectionChanged="cbContentType_SelectionChanged"/>
<TextBlock x:Name="lblContent" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,5,0">Content:</TextBlock> <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,0,5">Size:</TextBlock>
<TextBox x:Name="tbContent" Grid.Row="2" Grid.Column="1" Text="{Binding Config.Content}" TextWrapping="Wrap" AcceptsReturn="True" Height="Auto" Margin="5,0,5,0" /> <StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" Margin="5,0,0,5">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0">Width:</TextBlock>
<TextBox x:Name="tbWidth" Width="40" Text="{Binding Config.Width}"/>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,0">Height:</TextBlock>
<TextBox x:Name="tbHeight" Width="40" Text="{Binding Config.Height}"/>
</StackPanel>
<TextBlock x:Name="lblContent" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,5,0">Content:</TextBlock>
<TextBox x:Name="tbContent" Grid.Row="3" Grid.Column="1" Text="{Binding Config.Content}" TextWrapping="Wrap" AcceptsReturn="True" Height="Auto" Margin="5,0,5,0" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -32,7 +32,7 @@ namespace VRDash.Utilities
return newmatrix; return newmatrix;
} }
public static Matrix3x4 ToOpenVRMatrix(this HmdMatrix34_t matrix) public static Matrix3x4 ToOpenTKMatrix(this HmdMatrix34_t matrix)
{ {
Matrix3x4 newmatrix = new Matrix3x4(); Matrix3x4 newmatrix = new Matrix3x4();