Skip to content

Commit

Permalink
Update viewfinder graphics, make vertical indicator repeat every 45°,…
Browse files Browse the repository at this point in the history
… add indicator option
  • Loading branch information
BOLL7708 committed Aug 3, 2021
1 parent b67b5ee commit 64a8240
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 8 deletions.
3 changes: 3 additions & 0 deletions SuperScreenShotterVR/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
<setting name="LockHorizon" serializeAs="String">
<value>False</value>
</setting>
<setting name="IndicateDegrees" serializeAs="String">
<value>False</value>
</setting>
</SuperScreenShotterVR.Properties.Settings>
</userSettings>
<runtime>
Expand Down
24 changes: 18 additions & 6 deletions SuperScreenShotterVR/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private void UpdateOverlays()
{
// From settings and device values
var alpha = _settings.OverlayOpacity / 100f;
var alphaHalf = alpha / 2f;
var distance = _settings.OverlayDistance;
var fov = _screenshotFoV;
var width = (float)Math.Tan(fov / 2f * Math.PI / 180) * distance * 2;
Expand All @@ -327,8 +328,12 @@ private void UpdateOverlays()
var reticleSizeFactor = _settings.ReticleSize / 100;
var limitY = width * reticleSizeFactor / 2 / _reticleTextureSize.aspectRatio;

var pitchTransform = new HmdMatrix34_t();
float pitchY = (float)(distance * Math.Tan(-YPR.pitch));
HmdMatrix34_t pitchTransform;
double pitchYDeg = YPR.pitch * 180.0 / Math.PI;
var pitchYIsNegative = YPR.pitch < 0;
double pitchYDegMod = (Math.Abs(pitchYDeg) +22.5) % 45 - 22.5;
if (pitchYIsNegative) pitchYDegMod *= -1.0;
float pitchY = (float)(distance * Math.Tan(-(pitchYDegMod/180.0*Math.PI)));

if (_settings.RestrictToBox)
{
Expand All @@ -337,11 +342,11 @@ private void UpdateOverlays()
}
if (_settings.LockHorizon)
{
pitchTransform = overlayTransform.Translate(new HmdVector3_t() { v1 = pitchY });
pitchTransform = rollTransform.Translate(new HmdVector3_t() { v1 = pitchY });
}
else
{
pitchTransform = rollTransform.Translate(new HmdVector3_t() { v1 = pitchY });
pitchTransform = overlayTransform.Translate(new HmdVector3_t() { v1 = pitchY });
}

// Update
Expand All @@ -357,17 +362,24 @@ private void UpdateOverlays()
_ovr.SetOverlayTransform(_reticleOverlayHandle, overlayTransform, _trackedDeviceIndex);
_ovr.SetOverlayAlpha(_reticleOverlayHandle, alpha);
}

if (_ovr.FindOverlay(PITCH_INDICATOR_OVERLAY_UNIQUE_KEY) != 0)
{
var pitchNearLimit = 7.0;
var pitchNearDeg = Math.Abs(Math.Round(YPR.pitch * (180.0 * pitchNearLimit) / Math.PI)) % (45.0 * pitchNearLimit) == 0;
var pitchAlpha = (_settings.IndicateDegrees && !pitchNearDeg) ? alphaHalf : alpha;
_ovr.SetOverlayWidth(_pitchIndicatorOverlayHandle, width * reticleSizeFactor);
_ovr.SetOverlayTransform(_pitchIndicatorOverlayHandle, pitchTransform, _trackedDeviceIndex);
_ovr.SetOverlayAlpha(_pitchIndicatorOverlayHandle, alpha);
_ovr.SetOverlayAlpha(_pitchIndicatorOverlayHandle, pitchAlpha);
}
if (_ovr.FindOverlay(ROLL_INDICATOR_OVERLAY_UNIQUE_KEY) != 0)
{
var rollNearLimit = 2.0;
var rollNearDeg = Math.Abs(Math.Round(YPR.roll * (180.0 * rollNearLimit) / Math.PI)) % (45.0 * rollNearLimit) == 0;
var rollAlpha = (_settings.IndicateDegrees && !rollNearDeg) ? alphaHalf : alpha;
_ovr.SetOverlayWidth(_rollIndicatorOverlayHandle, width * reticleSizeFactor);
_ovr.SetOverlayTransform(_rollIndicatorOverlayHandle, rollTransform, _trackedDeviceIndex);
_ovr.SetOverlayAlpha(_rollIndicatorOverlayHandle, alpha);
_ovr.SetOverlayAlpha(_rollIndicatorOverlayHandle, rollAlpha);
}
} else
{
Expand Down
2 changes: 2 additions & 0 deletions SuperScreenShotterVR/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
<CheckBox x:Name="CheckBox_ViewFinder" Margin="5" Content="Enable viewfinder overlay in headset (binding)" Checked="CheckBox_ViewFinder_Checked" Unchecked="CheckBox_ViewFinder_Checked"/>
<CheckBox x:Name="CheckBox_RestrictToBox" Margin="5" Content="Lock vertical indicator to indicator box" Checked="CheckBox_RestrictToBox_Checked" Unchecked="CheckBox_RestrictToBox_Checked"/>
<CheckBox x:Name="CheckBox_LockHorizon" Margin="5" Content="Lock the angle of the vertical indicator to the horizon" Checked="CheckBox_LockHorizon_Checked" Unchecked="CheckBox_LockHorizon_Checked"/>
<CheckBox x:Name="CheckBox_IndicateDegrees" Margin="5" Content="Indicate every 45 degrees" Checked="CheckBox_IndicateDegrees_Checked" Unchecked="CheckBox_IndicateDegrees_Checked"/>

<DockPanel LastChildFill="True">
<Label Content="Distance: " Padding="5 5 0 5"/>
<Label x:Name="Label_OverlayDistance" Content="100m" Padding="0 5 5 5" MinWidth="40"/>
Expand Down
7 changes: 7 additions & 0 deletions SuperScreenShotterVR/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ private void InitSettings()
CheckBox_ViewFinder.IsChecked = _settings.ViewFinder;
CheckBox_RestrictToBox.IsChecked = _settings.RestrictToBox;
CheckBox_LockHorizon.IsChecked = _settings.LockHorizon;
CheckBox_IndicateDegrees.IsChecked = _settings.IndicateDegrees;
CheckBox_SaveRightImage.IsChecked = _settings.SaveRightImage;
CheckBox_CaptureTimer.IsChecked = _settings.CaptureTimer;
TextBox_TimerSeconds.Text = _settings.TimerSeconds.ToString();
Expand Down Expand Up @@ -294,6 +295,12 @@ private void CheckBox_LockHorizon_Checked(object sender, RoutedEventArgs e)
_settings.Save();
}

private void CheckBox_IndicateDegrees_Checked(object sender, RoutedEventArgs e)
{
_settings.IndicateDegrees = CheckboxValue(e);
_settings.Save();
}

private void CheckBox_CaptureTimer_Checked(object sender, RoutedEventArgs e)
{
var value = CheckboxValue(e);
Expand Down
2 changes: 1 addition & 1 deletion SuperScreenShotterVR/Properties/Resources.Designer.cs

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

2 changes: 1 addition & 1 deletion SuperScreenShotterVR/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@
<value>..\resources\logo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Version" xml:space="preserve">
<value>v0.56</value>
<value>v0.59</value>
</data>
</root>
12 changes: 12 additions & 0 deletions SuperScreenShotterVR/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions SuperScreenShotterVR/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,8 @@
<Setting Name="LockHorizon" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="IndicateDegrees" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
Binary file modified SuperScreenShotterVR/resources/pitchindicator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SuperScreenShotterVR/resources/reticle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SuperScreenShotterVR/resources/rollindicator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 64a8240

Please sign in to comment.