Skip to content

Commit

Permalink
First working VR locator.
Browse files Browse the repository at this point in the history
Turned off server upload by default.
  • Loading branch information
TheCrankLarson committed Aug 6, 2020
1 parent 113f40c commit a67e39a
Show file tree
Hide file tree
Showing 11 changed files with 717 additions and 118 deletions.
8 changes: 4 additions & 4 deletions FormLocator.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 19 additions & 75 deletions FormLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,6 @@ public void UpdateTracking(EDLocation CurrentLocation =null)
UpdateVRLocatorImage();
}

private void textBoxLongitude_TextChanged(object sender, EventArgs e)
{
TrySetDestination();
}

private void textBoxLatitude_TextChanged(object sender, EventArgs e)
{
TrySetDestination();
}

private void textBoxAltitude_TextChanged(object sender, EventArgs e)
{
TrySetDestination();
}

private void TrySetDestination()
{
// This shouldn't ever be called cross-thread, so no need to check for invoke
Expand Down Expand Up @@ -425,18 +410,18 @@ private Bitmap LocatorBitmap()
graphics.FillRectangle(new SolidBrush(Color.Black), graphics.ClipBounds);

// Tracking target
Brush whiteBrush = new SolidBrush(Color.White);
Brush orangeBrush = new SolidBrush(Color.Orange);
Brush directionBrush = new SolidBrush(Color.White);
Brush targetBrush = new SolidBrush(Color.Orange);
Font font = new Font("Arial", 12);
graphics.DrawString(_trackingTarget, font, orangeBrush, new PointF(0,0));
graphics.DrawString(_trackingTarget, font, targetBrush, new PointF(0,0));

// Bearing
font = new Font("Arial", 24);
font = new Font("Arial", 14);
//SizeF textSize = graphics.MeasureString(labelHeading.Text, font);
graphics.DrawString(labelHeading.Text, font, whiteBrush, new PointF(20, 30));
graphics.DrawString(labelHeading.Text, font, directionBrush, new PointF(20, 30));

// Distance
graphics.DrawString(labelDistance.Text, font, whiteBrush, new PointF(80, 30));
graphics.DrawString(labelDistance.Text, font, directionBrush, new PointF(80, 30));

graphics.Save();
}
Expand All @@ -458,63 +443,19 @@ private void UpdateVRLocatorImage()

private static void InitVRMatrix()
{
/*
_vrMatrix = new HmdMatrix34_t();
_vrMatrix.m0 = 1.0F; // row 0 col 0
_vrMatrix.m1 = 0.0F; // row 0 col 1
_vrMatrix.m2 = 0.0F;
_vrMatrix.m3 = 0.0F;
_vrMatrix.m4 = 0.0F;
_vrMatrix.m5 = 1.0F;
_vrMatrix.m6 = 0.0F;
_vrMatrix.m7 = 1.0F;
_vrMatrix.m8 = 0.0F;
_vrMatrix.m9 = 0.0F;
_vrMatrix.m10 = 1.0F;
_vrMatrix.m11 = 0.0F;*/

_vrMatrix = new HmdMatrix34_t();
_vrMatrix.m0 = 1.0F; // row 0 col 0
_vrMatrix.m1 = 0.0F; // row 0 col 1
_vrMatrix.m2 = 0.0F;
_vrMatrix.m3 = 0.12F;

_vrMatrix.m4 = 0.0F;
_vrMatrix.m5 = 1.0F;
_vrMatrix.m6 = 0.0F;
_vrMatrix.m7 = 0.08F;

_vrMatrix.m8 = 0.0F;
_vrMatrix.m9 = 0.0F;
_vrMatrix.m10 = 1.0F;
_vrMatrix.m11 = -0.3F;

/*
transform.{
1.0f, 0.0f, 0.0f, 0.12f,
0.0f, 1.0f, 0.0f, 0.08f,
0.0f, 0.0f, 1.0f, -0.3f
};
*
_vrMatrix.m0 = 1.0F;
_vrMatrix.m0 = 1F;
_vrMatrix.m1 = 0.0F;
_vrMatrix.m2 = 0.0F;
_vrMatrix.m3 = 0.0F;
_vrMatrix.m4 = 0.0F;
_vrMatrix.m5 = 1.0F;
_vrMatrix.m6 = 0.0F;
_vrMatrix.m7 = 1.0F;
_vrMatrix.m8 = 0.0F;
_vrMatrix.m9 = 0.0F;
_vrMatrix.m3 = 0.32F;
_vrMatrix.m4 = 0F;
_vrMatrix.m5 = -0.2F;
_vrMatrix.m6 = 0F;
_vrMatrix.m7 = 0.78F;
_vrMatrix.m8 = 0F;
_vrMatrix.m9 = 0.5F;
_vrMatrix.m10 = 1.0F;
_vrMatrix.m11 = -2.0F;
* */
_vrMatrix.m11 = -0.2F;
}

private bool ShowVRLocator()
Expand Down Expand Up @@ -542,7 +483,10 @@ private bool ShowVRLocator()
var error = OpenVR.Overlay.ShowOverlay(_vrOverlayHandle);

OpenVR.Overlay.SetOverlayTransformAbsolute(_vrOverlayHandle, Valve.VR.ETrackingUniverseOrigin.TrackingUniverseStanding, ref _vrMatrix);

/*
FormVRMatrixTest formVRMatrixTest = new FormVRMatrixTest(_vrOverlayHandle);
formVRMatrixTest.SetMatrix(ref _vrMatrix);
formVRMatrixTest.Show();*/
return true;
}

Expand Down
6 changes: 5 additions & 1 deletion FormRoutePlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ private void buttonSetAsTarget_Click(object sender, EventArgs e)
// Set the selected waypoint as the current target
if ( _locatorForm == null || listBoxWaypoints.SelectedItem == null)
return;
_locatorForm.SetTarget(((EDWaypoint)listBoxWaypoints.SelectedItem).Location);
try
{
_locatorForm.SetTarget(_route.Waypoints[listBoxWaypoints.SelectedIndex].Location);
}
catch { }
}

private void UpdateButtons()
Expand Down
45 changes: 23 additions & 22 deletions FormStatusMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions FormStatusMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,4 @@
<metadata name="EventStatus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="EventName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="EventStatus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
2 changes: 0 additions & 2 deletions FormTracker.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a67e39a

Please sign in to comment.