Skip to content

Commit

Permalink
Added Spacebar Hotkey + other last minute fixes
Browse files Browse the repository at this point in the history
- Adds a Spacebar hotkey that toggles the Overlay On/Off.
- Changes to properly disable/enable the Overlay.
- Added extra Save calls to ensure everything gets saved.
- Fixed a bug where releasing the grabbing controller's trigger while
scaling improperly kept the Overlay attached as long as the scaling
trigger was still held.
- Fixed a bug where an Overlay wouldn't animate while seen from the
backside. This meant controller based overlays would stay scaled up
between views. The overlay now properly animates to it's "not gazed"
state even when it is being viewed from the backside.

Release v1.0.5 closes #18, closes #20, closes #23, closes #24, closes
#25.
  • Loading branch information
Hotrian committed Aug 10, 2016
1 parent f7bf60e commit 2c267c0
Show file tree
Hide file tree
Showing 28 changed files with 78 additions and 47 deletions.
Binary file modified Assets/HOTK/Example Content/Display.mat
Binary file not shown.
Binary file modified Assets/HOTK/Example Content/HOTK_DisplayMirror.unity
Binary file not shown.
9 changes: 6 additions & 3 deletions Assets/HOTK/HOTK_Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,12 @@ private void UpdateGaze(ref bool changed)
var hit = _lockGaze && _lockedGaze;
if (!_lockGaze && _hmdTracker != null && _hmdTracker.IsValid)
{
if (Vector3.Angle(_hmdTracker.transform.forward, _rotationTracker.transform.forward) > 90f) return;
var result = new IntersectionResults();
hit = ComputeIntersection(_hmdTracker.gameObject.transform.position, _hmdTracker.gameObject.transform.forward, ref result);
if (Vector3.Angle(_hmdTracker.transform.forward, _rotationTracker.transform.forward) <= 90f)
{
var result = new IntersectionResults();
hit = ComputeIntersection(_hmdTracker.gameObject.transform.position,
_hmdTracker.gameObject.transform.forward, ref result);
}
}
IsBeingGazed = hit;
HandleAnimateOnGaze(hit, ref changed);
Expand Down
100 changes: 62 additions & 38 deletions Assets/HOTK/Portal/DesktopPortalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public Color OutlineColorScaling
private static readonly float[] FramerateFractions = {
1f, 1f/2f, 1f/5f, 1f/10f, 1/15f, 1/24f, 1f/30f, 1f/60f, 1f/90f, 1f/120f
};

private bool _started;
#endregion

#region Unity Methods
Expand All @@ -214,14 +216,15 @@ public void OnEnable()
Debug.Log("Connected to: " + SteamVR.instance.hmd_TrackingSystemName); // Force SteamVR Plugin to Init
if (Overlay == null) return;
SaveLoad.Load();
Overlay.OverlayTexture = RenderTexture;
_started = true;
_bitmap = CaptureScreen.CaptureDesktop();
_texture = new Texture2D(_bitmap.Width, _bitmap.Height) {filterMode = FilterMode.Point};
_texture = new Texture2D(_bitmap.Width, _bitmap.Height) { filterMode = FilterMode.Point };

_stream = new MemoryStream();
_bitmap.Save(_stream, ImageFormat.Png);
_stream.Seek(0, SeekOrigin.Begin);

Overlay.OverlayTexture = RenderTexture;
DisplayQuad.GetComponent<Renderer>().material.mainTexture = _texture;
DisplayQuad.transform.localScale = new Vector3(_bitmap.Width, _bitmap.Height, 1f);

Expand All @@ -233,6 +236,12 @@ public void OnEnable()

StartCoroutine("UpdateEvery1Second");
StartCoroutine("UpdateEvery10Seconds");

if (_selectedWindow != IntPtr.Zero)
{
_currentWindowWidth = 0; // Tricks the system into recalculating the size of the Overlay before capturing.
StartCoroutine("CaptureWindow");
}
if (!_subscribed)
{
_subscribed = true;
Expand All @@ -251,9 +260,10 @@ public void OnEnable()

public void OnDisable()
{
SaveLoad.Save();
StopCoroutine("CaptureWindow");
_selectedWindow = IntPtr.Zero;
SelectedWindowTitle = "";
//_selectedWindow = IntPtr.Zero;
//SelectedWindowTitle = "";
Overlay.OverlayTexture = DefaultTexture;
if (DisplayQuad == null) return;
DisplayQuad.GetComponent<Renderer>().material.mainTexture = DefaultTexture;
Expand Down Expand Up @@ -318,13 +328,13 @@ public void OnDestroy()
/// </summary>
private void TouchOverlay(HOTK_Overlay o, HOTK_TrackedDevice tracker, HOTK_Overlay.IntersectionResults result)
{
if (!Overlay.gameObject.activeSelf) return;
if (_selectedWindow == IntPtr.Zero) return;
if (Overlay.AnchorDevice == HOTK_Overlay.AttachmentDevice.LeftController && tracker.Type == HOTK_TrackedDevice.EType.LeftController) return;
if (Overlay.AnchorDevice == HOTK_Overlay.AttachmentDevice.RightController && tracker.Type == HOTK_TrackedDevice.EType.RightController) return;
if (Overlay.AnchorDevice != HOTK_Overlay.AttachmentDevice.World) return;
if (_grabbingOverlay != null) return;
// Hide the cursor from when we were just aiming
HideCursor();
_didHitOverlay = false;
_touchingOverlay = tracker;
StartCoroutine("GoToTouchColor");
Expand All @@ -343,6 +353,7 @@ private void UnTouchOverlay(HOTK_Overlay o, HOTK_TrackedDevice tracker)
/// </summary>
private void AimAtApplication(HOTK_Overlay o, HOTK_TrackedDevice tracker, HOTK_Overlay.IntersectionResults result)
{
if (!Overlay.gameObject.activeSelf) return;
if (_selectedWindow == IntPtr.Zero) return;
if (SelectedWindowSettings.interactionMode == MouseInteractionMode.Disabled) return;
if (Overlay.AnchorDevice == HOTK_Overlay.AttachmentDevice.LeftController && tracker.Type == HOTK_TrackedDevice.EType.LeftController) return;
Expand Down Expand Up @@ -388,7 +399,6 @@ private void AimAtApplication(HOTK_Overlay o, HOTK_TrackedDevice tracker, HOTK_O
}
else
{
HideCursor();
StartCoroutine("GoToDefaultColor");
}
}
Expand Down Expand Up @@ -473,31 +483,39 @@ private void TriggerUp(HOTK_TrackedDevice tracker)
{
ScaleField.InputField.text = Overlay.Scale.ToString(CultureInfo.InvariantCulture);
}
StartCoroutine("GoToTouchColor");
if (tracker == _grabbingOverlay)
{
DetachOverlayGrab();
}else StartCoroutine("GoToTouchColor");
}
else if (_grabbingOverlay != null)
{
_grabbingOverlay = null;
_touchingOverlay = null;
Overlay.gameObject.transform.parent = _lastOverlayParent;
_lastOverlayParent = null;

OffsetX.InputField.text = Overlay.AnchorOffset.x.ToString(CultureInfo.InvariantCulture);
OffsetY.InputField.text = Overlay.AnchorOffset.y.ToString(CultureInfo.InvariantCulture);
OffsetZ.InputField.text = Overlay.AnchorOffset.z.ToString(CultureInfo.InvariantCulture);
OffsetX.OnOffsetChanged();
OffsetY.OnOffsetChanged();
OffsetZ.OnOffsetChanged();
var dx = Overlay.gameObject.transform.rotation.eulerAngles.x;
var dy = Overlay.gameObject.transform.rotation.eulerAngles.y;
var dz = Overlay.gameObject.transform.rotation.eulerAngles.z;
OffsetRx.Slider.value = dx;
OffsetRy.Slider.value = dy;
OffsetRz.Slider.value = dz;

if (!_didHitOverlay) StartCoroutine("GoToDefaultColor");
DetachOverlayGrab();
}
}

private void DetachOverlayGrab()
{
_grabbingOverlay = null;
_touchingOverlay = null;
Overlay.gameObject.transform.parent = _lastOverlayParent;
_lastOverlayParent = null;

OffsetX.InputField.text = Overlay.AnchorOffset.x.ToString(CultureInfo.InvariantCulture);
OffsetY.InputField.text = Overlay.AnchorOffset.y.ToString(CultureInfo.InvariantCulture);
OffsetZ.InputField.text = Overlay.AnchorOffset.z.ToString(CultureInfo.InvariantCulture);
OffsetX.OnOffsetChanged();
OffsetY.OnOffsetChanged();
OffsetZ.OnOffsetChanged();
var dx = Overlay.gameObject.transform.rotation.eulerAngles.x;
var dy = Overlay.gameObject.transform.rotation.eulerAngles.y;
var dz = Overlay.gameObject.transform.rotation.eulerAngles.z;
OffsetRx.Slider.value = dx;
OffsetRy.Slider.value = dy;
OffsetRz.Slider.value = dz;

if (!_didHitOverlay) StartCoroutine("GoToDefaultColor");
}
/// <summary>
/// Occurs when a touchpad has been pressed down
/// </summary>
Expand Down Expand Up @@ -632,7 +650,7 @@ private IEnumerator FadeInCursor()
{
StopCoroutine("FadeOutCursor");
var t = CursorRenderer.color.a;
CursorGameObject.SetActive(true);
ShowCursor();
while (t < 1f)
{
t += 0.25f;
Expand All @@ -650,7 +668,7 @@ private IEnumerator FadeOutCursor()
if (CursorRenderer != null) CursorRenderer.color = new Color(CursorRenderer.color.r, CursorRenderer.color.g, CursorRenderer.color.b, t);
yield return new WaitForSeconds(0.025f);
}
CursorGameObject.SetActive(false);
HideCursor();
}

private IEnumerator UpdateEvery1Second()
Expand Down Expand Up @@ -842,10 +860,12 @@ public void EnableFpsCounter()

public void StopRefreshing()
{
if (!Overlay.gameObject.activeSelf) return;
StopCoroutine("UpdateEvery10Seconds");
}
public void StartRefreshing()
{
if (!Overlay.gameObject.activeSelf) return;
StopCoroutine("UpdateEvery10Seconds");
StartCoroutine("UpdateEvery10Seconds");
}
Expand Down Expand Up @@ -974,6 +994,7 @@ public void OptionChanged()
_currentCaptureHeight = r.Height;
OffsetWidthField.text = r.Width.ToString();
OffsetHeightField.text = r.Height.ToString();
if (!Overlay.gameObject.activeSelf) return;
StartCoroutine("CaptureWindow");
}
else
Expand All @@ -987,22 +1008,25 @@ public void ToggleSizeLocked()
if (_selectedWindow == IntPtr.Zero) return;
SelectedWindowSettings.windowSizeLocked = !SelectedWindowSettings.windowSizeLocked;
SizeLockSprite.sprite = SelectedWindowSettings.windowSizeLocked ? LockSprite : UnlockSprite;
if (!SelectedWindowSettings.windowSizeLocked) return;
int v;
if (int.TryParse(OffsetWidthField.text, out v))
if (SelectedWindowSettings.windowSizeLocked)
{
if (v > 0)
int v;
if (int.TryParse(OffsetWidthField.text, out v))
{
SelectedWindowSettings.offsetWidth = v;
if (v > 0)
{
SelectedWindowSettings.offsetWidth = v;
}
}
}
if (int.TryParse(OffsetHeightField.text, out v))
{
if (v > 0)
if (int.TryParse(OffsetHeightField.text, out v))
{
SelectedWindowSettings.offsetHeight = v;
if (v > 0)
{
SelectedWindowSettings.offsetHeight = v;
}
}
}
SaveLoad.Save();
}

public void WindowSettingConfirmed(string setting)
Expand Down
10 changes: 10 additions & 0 deletions Assets/HotkeyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public class HotkeyController : MonoBehaviour
{
public InputField NewSaveInputField;

public HOTK_Overlay Overlay;
public GameObject DisabledText;

public Button XNegButton;
public Button XPosButton;
public Button YNegButton;
Expand All @@ -19,6 +22,7 @@ public class HotkeyController : MonoBehaviour
public Button RYPosButton;
public Button RZNegButton;
public Button RZPosButton;

void Update ()
{
if (!NewSaveInputField.isFocused)
Expand Down Expand Up @@ -72,6 +76,12 @@ void Update ()
{
RZPosButton.onClick.Invoke();
}

if (Input.GetKeyDown(KeyCode.Space))
{
Overlay.gameObject.SetActive(!Overlay.gameObject.activeSelf);
DisabledText.SetActive(!Overlay.gameObject.activeSelf);
}
}
}
}
Empty file added Library/CrashedAssetImports.txt
Empty file.
Binary file modified Library/CurrentLayout.dwlt
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp-Editor.dll
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp-Editor.dll.mdb
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll.mdb
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp.dll
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Library/assetDatabase3
Binary file not shown.
Binary file modified Library/expandedItems
Binary file not shown.
Binary file modified Library/metadata/00/00000000000000004000000000000000
Binary file not shown.
Binary file modified Library/metadata/00/00000000000000006100000000000000
Binary file not shown.
Binary file modified Library/metadata/48/48b5bcc676d3b6b48aa4f2d01cb6b7e0
Binary file not shown.
Binary file modified Library/metadata/89/89651f47f29678549a9fa0eb1af24d38
Binary file not shown.
Binary file modified Library/metadata/a4/a431335dbaf22e64c9860247b3a4d0ac
Binary file not shown.
3 changes: 0 additions & 3 deletions Library/shadercompiler-UnityShaderCompiler.exe1.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
Base path: C:/Program Files/Unity 5.3.5f1/Editor/Data
Cmd: getPlatforms
Unhandled exception: Protocol error - failed to read correct magic number

Quitting shader compiler process
3 changes: 0 additions & 3 deletions Library/shadercompiler-UnityShaderCompiler.exe2.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
Base path: C:/Program Files/Unity 5.3.5f1/Editor/Data
Cmd: getPlatforms
Unhandled exception: Protocol error - failed to read correct magic number

Quitting shader compiler process

0 comments on commit 2c267c0

Please sign in to comment.