From 5b2c3051bfbfc1db483416666d385c6e4dfdb787 Mon Sep 17 00:00:00 2001 From: John Luxford Date: Sun, 8 Jan 2017 19:38:29 -0600 Subject: [PATCH 01/29] Added NVRVirtualHand and NVRVirtualInputDevice to use with NPC and remote users You can control the hand via 3 new methods on NVRVirtualHand: - `Hold()` begins holding the closest interactable - `Release()` releases the current interactable - `Use()` triggers `UseButtonDown()` on the current interactable --- Assets/NewtonVR/NVRHand.cs | 30 ++--- Assets/NewtonVR/NVRVirtualHand.cs | 130 +++++++++++++++++++ Assets/NewtonVR/NVRVirtualInputDevice.cs | 152 +++++++++++++++++++++++ 3 files changed, 297 insertions(+), 15 deletions(-) create mode 100644 Assets/NewtonVR/NVRVirtualHand.cs create mode 100644 Assets/NewtonVR/NVRVirtualInputDevice.cs diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index 705d33d8..2cb73e62 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -40,13 +40,13 @@ public class NVRHand : MonoBehaviour [HideInInspector] public GameObject CustomPhysicalColliders; - private VisibilityLevel CurrentVisibility = VisibilityLevel.Visible; - private bool VisibilityLocked = false; + protected VisibilityLevel CurrentVisibility = VisibilityLevel.Visible; + protected bool VisibilityLocked = false; [HideInInspector] public HandState CurrentHandState = HandState.Uninitialized; - private Dictionary> CurrentlyHoveringOver; + protected Dictionary> CurrentlyHoveringOver; public NVRInteractable CurrentlyInteracting; @@ -56,21 +56,21 @@ public class NVRInteractableEvent : UnityEvent { } public NVRInteractableEvent OnBeginInteraction = new NVRInteractableEvent(); public NVRInteractableEvent OnEndInteraction = new NVRInteractableEvent(); - private int EstimationSampleIndex; - private Vector3[] LastPositions; - private Quaternion[] LastRotations; - private float[] LastDeltas; - private int EstimationSamples = 5; + protected int EstimationSampleIndex; + protected Vector3[] LastPositions; + protected Quaternion[] LastRotations; + protected float[] LastDeltas; + protected int EstimationSamples = 5; [HideInInspector] public NVRPhysicalController PhysicalController; - private Collider[] GhostColliders; - private Renderer[] GhostRenderers; + protected Collider[] GhostColliders; + protected Renderer[] GhostRenderers; - private NVRInputDevice InputDevice; + protected NVRInputDevice InputDevice; - private GameObject RenderModel; + protected GameObject RenderModel; public bool IsHovering { @@ -348,7 +348,7 @@ protected void UpdateInteractions() } } - private void UpdateVisibilityAndColliders() + protected void UpdateVisibilityAndColliders() { if (Player.PhysicalHands == true) { @@ -587,7 +587,7 @@ public virtual void EndInteraction(NVRInteractable item) } } - private bool PickupClosest() + protected bool PickupClosest() { NVRInteractable closest = null; float closestDistance = float.MaxValue; @@ -771,7 +771,7 @@ protected void InitializeRenderModel() } } - public void Initialize() + public virtual void Initialize() { Rigidbody = this.GetComponent(); if (Rigidbody == null) diff --git a/Assets/NewtonVR/NVRVirtualHand.cs b/Assets/NewtonVR/NVRVirtualHand.cs new file mode 100644 index 00000000..f8f321c2 --- /dev/null +++ b/Assets/NewtonVR/NVRVirtualHand.cs @@ -0,0 +1,130 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace NewtonVR +{ + public class NVRVirtualHand : NVRHand + { + public enum Handedness + { + Left, + Right + } + + public Handedness Hand; + + void Start () + { + PreInitialize(null); + } + + public override void PreInitialize(NVRPlayer player) + { + IsLeft = Hand == Handedness.Left; + IsRight = Hand == Handedness.Right; + + Player = NVRPlayer.Instance; + + CurrentInteractionStyle = InterationStyle.Hold; + + CurrentlyHoveringOver = new Dictionary>(); + + LastPositions = new Vector3[EstimationSamples]; + LastRotations = new Quaternion[EstimationSamples]; + LastDeltas = new float[EstimationSamples]; + EstimationSampleIndex = 0; + + VisibilityLocked = false; + + Inputs = new Dictionary(new NVRButtonsComparer()); + for (int buttonIndex = 0; buttonIndex < NVRButtonsHelper.Array.Length; buttonIndex++) + { + if (Inputs.ContainsKey(NVRButtonsHelper.Array[buttonIndex]) == false) + { + Inputs.Add(NVRButtonsHelper.Array[buttonIndex], new NVRButtonInputs()); + } + } + + InputDevice = this.gameObject.AddComponent (); + InputDevice.Initialize (this); + + InitializeRenderModel(); + } + + protected override void Update() + { + if (CurrentHandState == HandState.Uninitialized) + { + if (InputDevice == null || InputDevice.ReadyToInitialize() == false) + { + return; + } + else + { + Initialize(); + return; + } + } + + UpdateHovering(); + + UpdateVisibilityAndColliders(); + } + + public void Hold () + { + PickupClosest (); + if (IsInteracting) + { + CurrentHandState = HandState.GripToggleOnInteracting; + } + } + + public void Release () + { + if (CurrentlyInteracting != null) + { + EndInteraction (null); + } + } + + public void Use () + { + if (CurrentlyInteracting != null) + { + CurrentlyInteracting.UseButtonDown (); + } + } + + public override void Initialize() + { + Rigidbody = this.GetComponent(); + if (Rigidbody == null) + Rigidbody = this.gameObject.AddComponent(); + Rigidbody.isKinematic = true; + Rigidbody.maxAngularVelocity = float.MaxValue; + Rigidbody.useGravity = false; + + Collider[] colliders = null; + + colliders = InputDevice.SetupDefaultColliders(); + + if (PhysicalController != null) + { + PhysicalController.Kill(); + } + + PhysicalController = this.gameObject.AddComponent(); + PhysicalController.Initialize(this, false); + + if (colliders != null) + { + GhostColliders = colliders; + } + + CurrentVisibility = VisibilityLevel.Visible; + + CurrentHandState = HandState.Idle; + } + } +} \ No newline at end of file diff --git a/Assets/NewtonVR/NVRVirtualInputDevice.cs b/Assets/NewtonVR/NVRVirtualInputDevice.cs new file mode 100644 index 00000000..3017cd25 --- /dev/null +++ b/Assets/NewtonVR/NVRVirtualInputDevice.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using UnityEngine; + +namespace NewtonVR +{ + public class NVRVirtualInputDevice : NVRInputDevice + { + private GameObject RenderModel; + + public override void Initialize(NVRHand hand) + { + base.Initialize(hand); + } + + public override float GetAxis1D(NVRButtons button) + { + // Do nothing + return 0f; + } + + public override Vector2 GetAxis2D(NVRButtons button) + { + // Do nothing + return Vector2.zero; + } + + public override bool GetPressDown(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetPressUp(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetPress(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetTouchDown(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetTouchUp(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetTouch(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetNearTouchDown(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetNearTouchUp(NVRButtons button) + { + // Do nothing + return false; + } + + public override bool GetNearTouch(NVRButtons button) + { + // Do nothing + return false; + } + + public override void TriggerHapticPulse(ushort durationMicroSec = 500, NVRButtons button = NVRButtons.Touchpad) + { + // Do nothing + } + + public override bool IsCurrentlyTracked + { + get + { + return true; + } + } + + + public override GameObject SetupDefaultRenderModel() + { + RenderModel = Hand.gameObject; + + return RenderModel; + } + + public override bool ReadyToInitialize() + { + return true; + } + + public override string GetDeviceName() + { + if (Hand.HasCustomModel == true) + { + return "Custom"; + } + else if (Hand.IsLeft) + { + return "VirtualLeft"; + } else + { + return "VirtualRight"; + } + } + + public override Collider[] SetupDefaultPhysicalColliders(Transform ModelParent) + { + Collider[] Colliders = null; + + SphereCollider Collider = GetComponent(); + + Colliders = new Collider[] { Collider }; + + return Colliders; + } + + public override Collider[] SetupDefaultColliders() + { + Collider[] Colliders = null; + + SphereCollider Collider = RenderModel.AddComponent(); + Collider.isTrigger = true; + Collider.radius = 0.15f; + + Colliders = new Collider[] { Collider }; + + return Colliders; + } + + } +} From 721befa2d9a92f9bb670cf700d4c8a94fc90e90a Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 9 Jan 2017 10:12:29 -0600 Subject: [PATCH 02/29] Added OnUseInteraction event to capture Use() calls for sending to remote users --- Assets/NewtonVR/NVRVirtualHand.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Assets/NewtonVR/NVRVirtualHand.cs b/Assets/NewtonVR/NVRVirtualHand.cs index f8f321c2..20234080 100644 --- a/Assets/NewtonVR/NVRVirtualHand.cs +++ b/Assets/NewtonVR/NVRVirtualHand.cs @@ -3,7 +3,7 @@ namespace NewtonVR { - public class NVRVirtualHand : NVRHand + public class NVRVirtualHand : NVRHand { public enum Handedness { @@ -12,6 +12,8 @@ public enum Handedness } public Handedness Hand; + + public NVRInteractableEvent OnUseInteraction = new NVRInteractableEvent (); void Start () { @@ -93,6 +95,11 @@ public void Use () if (CurrentlyInteracting != null) { CurrentlyInteracting.UseButtonDown (); + + if (OnUseInteraction != null) + { + OnUseInteraction.Invoke(CurrentlyInteracting); + } } } @@ -127,4 +134,4 @@ public override void Initialize() CurrentHandState = HandState.Idle; } } -} \ No newline at end of file +} From 893aef314b54841f86774e34198f18dd3a2561eb Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 9 Jan 2017 11:56:59 -0600 Subject: [PATCH 03/29] Removed OnUseInteraction event, moving this to NVRHand for capture in both directions --- Assets/NewtonVR/NVRVirtualHand.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Assets/NewtonVR/NVRVirtualHand.cs b/Assets/NewtonVR/NVRVirtualHand.cs index 20234080..ea4f213f 100644 --- a/Assets/NewtonVR/NVRVirtualHand.cs +++ b/Assets/NewtonVR/NVRVirtualHand.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; using System.Collections.Generic; namespace NewtonVR @@ -12,8 +12,6 @@ public enum Handedness } public Handedness Hand; - - public NVRInteractableEvent OnUseInteraction = new NVRInteractableEvent (); void Start () { @@ -95,11 +93,6 @@ public void Use () if (CurrentlyInteracting != null) { CurrentlyInteracting.UseButtonDown (); - - if (OnUseInteraction != null) - { - OnUseInteraction.Invoke(CurrentlyInteracting); - } } } From 9bdb610427054ebe4feb38eb407434bf75ed93f6 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 9 Jan 2017 11:59:10 -0600 Subject: [PATCH 04/29] Added OnBeginUseInteraction and OnEndUseInteraction events to respond to trigger down and up --- Assets/NewtonVR/NVRHand.cs | 1720 ++++++++++++++++++------------------ 1 file changed, 861 insertions(+), 859 deletions(-) diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index 2cb73e62..c4aeb69b 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -1,573 +1,575 @@ -using UnityEngine; -using UnityEngine.Events; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace NewtonVR -{ - public class NVRHand : MonoBehaviour - { - public NVRButtons HoldButton = NVRButtons.Grip; - public bool HoldButtonDown { get { return Inputs[HoldButton].PressDown; } } - public bool HoldButtonUp { get { return Inputs[HoldButton].PressUp; } } - public bool HoldButtonPressed { get { return Inputs[HoldButton].IsPressed; } } - public float HoldButtonAxis { get { return Inputs[HoldButton].SingleAxis; } } - - public NVRButtons UseButton = NVRButtons.Trigger; - public bool UseButtonDown { get { return Inputs[UseButton].PressDown; } } - public bool UseButtonUp { get { return Inputs[UseButton].PressUp; } } - public bool UseButtonPressed { get { return Inputs[UseButton].IsPressed; } } - public float UseButtonAxis { get { return Inputs[UseButton].SingleAxis; } } - - [HideInInspector] - public bool IsRight; - [HideInInspector] - public bool IsLeft; - [HideInInspector] - public NVRPlayer Player; - - public Dictionary Inputs; - - [HideInInspector] - public InterationStyle CurrentInteractionStyle; - - public Rigidbody Rigidbody; - - [HideInInspector] - public GameObject CustomModel; - [HideInInspector] - public GameObject CustomPhysicalColliders; - - protected VisibilityLevel CurrentVisibility = VisibilityLevel.Visible; - protected bool VisibilityLocked = false; - - [HideInInspector] - public HandState CurrentHandState = HandState.Uninitialized; - - protected Dictionary> CurrentlyHoveringOver; - +using UnityEngine; +using UnityEngine.Events; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace NewtonVR +{ + public class NVRHand : MonoBehaviour + { + public NVRButtons HoldButton = NVRButtons.Grip; + public bool HoldButtonDown { get { return Inputs[HoldButton].PressDown; } } + public bool HoldButtonUp { get { return Inputs[HoldButton].PressUp; } } + public bool HoldButtonPressed { get { return Inputs[HoldButton].IsPressed; } } + public float HoldButtonAxis { get { return Inputs[HoldButton].SingleAxis; } } + + public NVRButtons UseButton = NVRButtons.Trigger; + public bool UseButtonDown { get { return Inputs[UseButton].PressDown; } } + public bool UseButtonUp { get { return Inputs[UseButton].PressUp; } } + public bool UseButtonPressed { get { return Inputs[UseButton].IsPressed; } } + public float UseButtonAxis { get { return Inputs[UseButton].SingleAxis; } } + + [HideInInspector] + public bool IsRight; + [HideInInspector] + public bool IsLeft; + [HideInInspector] + public NVRPlayer Player; + + public Dictionary Inputs; + + [HideInInspector] + public InterationStyle CurrentInteractionStyle; + + public Rigidbody Rigidbody; + + [HideInInspector] + public GameObject CustomModel; + [HideInInspector] + public GameObject CustomPhysicalColliders; + + protected VisibilityLevel CurrentVisibility = VisibilityLevel.Visible; + protected bool VisibilityLocked = false; + + [HideInInspector] + public HandState CurrentHandState = HandState.Uninitialized; + + protected Dictionary> CurrentlyHoveringOver; + public NVRInteractable CurrentlyInteracting; [Serializable] - public class NVRInteractableEvent : UnityEvent { } - - public NVRInteractableEvent OnBeginInteraction = new NVRInteractableEvent(); - public NVRInteractableEvent OnEndInteraction = new NVRInteractableEvent(); - - protected int EstimationSampleIndex; - protected Vector3[] LastPositions; - protected Quaternion[] LastRotations; - protected float[] LastDeltas; - protected int EstimationSamples = 5; - - [HideInInspector] - public NVRPhysicalController PhysicalController; - - protected Collider[] GhostColliders; - protected Renderer[] GhostRenderers; - - protected NVRInputDevice InputDevice; - - protected GameObject RenderModel; - - public bool IsHovering - { - get - { - return CurrentlyHoveringOver.Any(kvp => kvp.Value.Count > 0); - } - } - public bool IsInteracting - { - get - { - return CurrentlyInteracting != null; - } - } - public bool HasCustomModel - { - get - { - return CustomModel != null; - } - } - public bool IsCurrentlyTracked - { - get - { - if (InputDevice != null) - { - return InputDevice.IsCurrentlyTracked; - } - - return false; - } - } - public Vector3 CurrentForward - { - get - { - if (PhysicalController != null && PhysicalController.State == true) - { - return PhysicalController.PhysicalController.transform.forward; - } - else - { - return this.transform.forward; - } - } - } - public Vector3 CurrentPosition - { - get - { - if (PhysicalController != null && PhysicalController.State == true) - { - return PhysicalController.PhysicalController.transform.position; - } - else - { - return this.transform.position; - } - } - } - - - public virtual void PreInitialize(NVRPlayer player) - { - Player = player; - - IsRight = Player.RightHand == this; - IsLeft = Player.LeftHand == this; - - CurrentInteractionStyle = Player.InteractionStyle; - - CurrentlyHoveringOver = new Dictionary>(); - - LastPositions = new Vector3[EstimationSamples]; - LastRotations = new Quaternion[EstimationSamples]; - LastDeltas = new float[EstimationSamples]; - EstimationSampleIndex = 0; - + public class NVRInteractableEvent : UnityEvent { } + + public NVRInteractableEvent OnBeginInteraction = new NVRInteractableEvent(); + public NVRInteractableEvent OnEndInteraction = new NVRInteractableEvent(); + public NVRInteractableEvent OnBeginUseInteraction = new NVRInteractableEvent (); + public NVRInteractableEvent OnEndUseInteraction = new NVRInteractableEvent (); + + protected int EstimationSampleIndex; + protected Vector3[] LastPositions; + protected Quaternion[] LastRotations; + protected float[] LastDeltas; + protected int EstimationSamples = 5; + + [HideInInspector] + public NVRPhysicalController PhysicalController; + + protected Collider[] GhostColliders; + protected Renderer[] GhostRenderers; + + protected NVRInputDevice InputDevice; + + protected GameObject RenderModel; + + public bool IsHovering + { + get + { + return CurrentlyHoveringOver.Any(kvp => kvp.Value.Count > 0); + } + } + public bool IsInteracting + { + get + { + return CurrentlyInteracting != null; + } + } + public bool HasCustomModel + { + get + { + return CustomModel != null; + } + } + public bool IsCurrentlyTracked + { + get + { + if (InputDevice != null) + { + return InputDevice.IsCurrentlyTracked; + } + + return false; + } + } + public Vector3 CurrentForward + { + get + { + if (PhysicalController != null && PhysicalController.State == true) + { + return PhysicalController.PhysicalController.transform.forward; + } + else + { + return this.transform.forward; + } + } + } + public Vector3 CurrentPosition + { + get + { + if (PhysicalController != null && PhysicalController.State == true) + { + return PhysicalController.PhysicalController.transform.position; + } + else + { + return this.transform.position; + } + } + } + + + public virtual void PreInitialize(NVRPlayer player) + { + Player = player; + + IsRight = Player.RightHand == this; + IsLeft = Player.LeftHand == this; + + CurrentInteractionStyle = Player.InteractionStyle; + + CurrentlyHoveringOver = new Dictionary>(); + + LastPositions = new Vector3[EstimationSamples]; + LastRotations = new Quaternion[EstimationSamples]; + LastDeltas = new float[EstimationSamples]; + EstimationSampleIndex = 0; + VisibilityLocked = false; - Inputs = new Dictionary(new NVRButtonsComparer()); - for (int buttonIndex = 0; buttonIndex < NVRButtonsHelper.Array.Length; buttonIndex++) - { + Inputs = new Dictionary(new NVRButtonsComparer()); + for (int buttonIndex = 0; buttonIndex < NVRButtonsHelper.Array.Length; buttonIndex++) + { if (Inputs.ContainsKey(NVRButtonsHelper.Array[buttonIndex]) == false) - { - Inputs.Add(NVRButtonsHelper.Array[buttonIndex], new NVRButtonInputs()); - } - } - - if (Player.CurrentIntegrationType == NVRSDKIntegrations.Oculus) - { - InputDevice = this.gameObject.AddComponent(); - - if (Player.OverrideOculus == true) - { - if (IsLeft) - { - CustomModel = Player.OverrideOculusLeftHand; - CustomPhysicalColliders = Player.OverrideOculusLeftHandPhysicalColliders; - } - else if (IsRight) - { - CustomModel = Player.OverrideOculusRightHand; - CustomPhysicalColliders = Player.OverrideOculusRightHandPhysicalColliders; - } - else - { - Debug.LogError("[NewtonVR] Error: Unknown hand for oculus model override."); - } - } - } - else if (Player.CurrentIntegrationType == NVRSDKIntegrations.SteamVR) - { - InputDevice = this.gameObject.AddComponent(); - - if (Player.OverrideSteamVR == true) - { - if (IsLeft) - { - CustomModel = Player.OverrideSteamVRLeftHand; - CustomPhysicalColliders = Player.OverrideSteamVRLeftHandPhysicalColliders; - } - else if (IsRight) - { - CustomModel = Player.OverrideSteamVRRightHand; - CustomPhysicalColliders = Player.OverrideSteamVRRightHandPhysicalColliders; - } - else - { - Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); - } - } - } - else - { - //Debug.LogError("[NewtonVR] Critical Error: NVRPlayer.CurrentIntegration not setup."); - return; - } - - if (Player.OverrideAll) - { - - if (IsLeft) - { - CustomModel = Player.OverrideAllLeftHand; - CustomPhysicalColliders = Player.OverrideAllLeftHandPhysicalColliders; - } - else if (IsRight) - { - CustomModel = Player.OverrideAllRightHand; - CustomPhysicalColliders = Player.OverrideAllRightHandPhysicalColliders; - } - else - { - Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); - return; - } - } - - - InputDevice.Initialize(this); - InitializeRenderModel(); - } - - protected virtual void Update() - { - if (CurrentHandState == HandState.Uninitialized) - { - if (InputDevice == null || InputDevice.ReadyToInitialize() == false) - { - return; - } - else - { - Initialize(); - return; - } - } - - UpdateButtonStates(); - - UpdateInteractions(); - - UpdateHovering(); - - UpdateVisibilityAndColliders(); - } - - protected void UpdateHovering() - { - if (CurrentHandState == HandState.Idle) - { - var hoveringEnumerator = CurrentlyHoveringOver.GetEnumerator(); - while (hoveringEnumerator.MoveNext()) - { - var hoveringOver = hoveringEnumerator.Current; - if (hoveringOver.Value.Count > 0) - { - hoveringOver.Key.HoveringUpdate(this, Time.time - hoveringOver.Value.OrderBy(colliderTime => colliderTime.Value).First().Value); - } - } - } - } - - protected void UpdateButtonStates() - { - for (int index = 0; index < NVRButtonsHelper.Array.Length; index++) - { - NVRButtons nvrbutton = NVRButtonsHelper.Array[index]; + { + Inputs.Add(NVRButtonsHelper.Array[buttonIndex], new NVRButtonInputs()); + } + } + + if (Player.CurrentIntegrationType == NVRSDKIntegrations.Oculus) + { + InputDevice = this.gameObject.AddComponent(); + + if (Player.OverrideOculus == true) + { + if (IsLeft) + { + CustomModel = Player.OverrideOculusLeftHand; + CustomPhysicalColliders = Player.OverrideOculusLeftHandPhysicalColliders; + } + else if (IsRight) + { + CustomModel = Player.OverrideOculusRightHand; + CustomPhysicalColliders = Player.OverrideOculusRightHandPhysicalColliders; + } + else + { + Debug.LogError("[NewtonVR] Error: Unknown hand for oculus model override."); + } + } + } + else if (Player.CurrentIntegrationType == NVRSDKIntegrations.SteamVR) + { + InputDevice = this.gameObject.AddComponent(); + + if (Player.OverrideSteamVR == true) + { + if (IsLeft) + { + CustomModel = Player.OverrideSteamVRLeftHand; + CustomPhysicalColliders = Player.OverrideSteamVRLeftHandPhysicalColliders; + } + else if (IsRight) + { + CustomModel = Player.OverrideSteamVRRightHand; + CustomPhysicalColliders = Player.OverrideSteamVRRightHandPhysicalColliders; + } + else + { + Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); + } + } + } + else + { + //Debug.LogError("[NewtonVR] Critical Error: NVRPlayer.CurrentIntegration not setup."); + return; + } + + if (Player.OverrideAll) + { + + if (IsLeft) + { + CustomModel = Player.OverrideAllLeftHand; + CustomPhysicalColliders = Player.OverrideAllLeftHandPhysicalColliders; + } + else if (IsRight) + { + CustomModel = Player.OverrideAllRightHand; + CustomPhysicalColliders = Player.OverrideAllRightHandPhysicalColliders; + } + else + { + Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); + return; + } + } + + + InputDevice.Initialize(this); + InitializeRenderModel(); + } + + protected virtual void Update() + { + if (CurrentHandState == HandState.Uninitialized) + { + if (InputDevice == null || InputDevice.ReadyToInitialize() == false) + { + return; + } + else + { + Initialize(); + return; + } + } + + UpdateButtonStates(); + + UpdateInteractions(); + + UpdateHovering(); + + UpdateVisibilityAndColliders(); + } + + protected void UpdateHovering() + { + if (CurrentHandState == HandState.Idle) + { + var hoveringEnumerator = CurrentlyHoveringOver.GetEnumerator(); + while (hoveringEnumerator.MoveNext()) + { + var hoveringOver = hoveringEnumerator.Current; + if (hoveringOver.Value.Count > 0) + { + hoveringOver.Key.HoveringUpdate(this, Time.time - hoveringOver.Value.OrderBy(colliderTime => colliderTime.Value).First().Value); + } + } + } + } + + protected void UpdateButtonStates() + { + for (int index = 0; index < NVRButtonsHelper.Array.Length; index++) + { + NVRButtons nvrbutton = NVRButtonsHelper.Array[index]; NVRButtonInputs button = Inputs[nvrbutton]; - button.FrameReset(InputDevice, nvrbutton); - } - } - - protected void UpdateInteractions() - { - if (CurrentInteractionStyle == InterationStyle.Hold) - { - if (HoldButtonUp == true) - { - VisibilityLocked = false; - } - - if (HoldButtonDown == true) - { - if (CurrentlyInteracting == null) - { - PickupClosest(); - } - } - else if (HoldButtonUp == true && CurrentlyInteracting != null) - { - EndInteraction(null); - } - } - else if (CurrentInteractionStyle == InterationStyle.Toggle) - { - if (HoldButtonDown == true) - { - if (CurrentHandState == HandState.Idle) - { - PickupClosest(); - if (IsInteracting) - { - CurrentHandState = HandState.GripToggleOnInteracting; - } - else if (Player.PhysicalHands == true) - { - CurrentHandState = HandState.GripToggleOnNotInteracting; - } - } - else if (CurrentHandState == HandState.GripToggleOnInteracting) - { - CurrentHandState = HandState.Idle; - VisibilityLocked = false; - EndInteraction(null); - } - else if (CurrentHandState == HandState.GripToggleOnNotInteracting) - { - CurrentHandState = HandState.Idle; - VisibilityLocked = false; - } - } - } - else if (CurrentInteractionStyle == InterationStyle.ByScript) - { - //this is handled by user customized scripts. - } - - if (IsInteracting == true) - { - CurrentlyInteracting.InteractingUpdate(this); - } - } - - protected void UpdateVisibilityAndColliders() - { - if (Player.PhysicalHands == true) - { - if (CurrentInteractionStyle == InterationStyle.Hold) - { - if (HoldButtonPressed == true && IsInteracting == false) - { - if (CurrentHandState != HandState.GripDownNotInteracting && VisibilityLocked == false) - { - VisibilityLocked = true; - SetVisibility(VisibilityLevel.Visible); - CurrentHandState = HandState.GripDownNotInteracting; - } - } - else if (HoldButtonDown == true && IsInteracting == true) - { - if (CurrentHandState != HandState.GripDownInteracting && VisibilityLocked == false) - { - VisibilityLocked = true; - if (Player.MakeControllerInvisibleOnInteraction == true) - { - SetVisibility(VisibilityLevel.Invisible); - } - else - { - SetVisibility(VisibilityLevel.Ghost); - } - CurrentHandState = HandState.GripDownInteracting; - } - } - else if (IsInteracting == false) - { - if (CurrentHandState != HandState.Idle && VisibilityLocked == false) - { - SetVisibility(VisibilityLevel.Ghost); - CurrentHandState = HandState.Idle; - } - } - } - else if (CurrentInteractionStyle == InterationStyle.Toggle) - { - if (CurrentHandState == HandState.Idle) - { - if (VisibilityLocked == false && CurrentVisibility != VisibilityLevel.Ghost) - { - SetVisibility(VisibilityLevel.Ghost); - } - else - { - VisibilityLocked = false; - } - - } - else if (CurrentHandState == HandState.GripToggleOnInteracting) - { - if (VisibilityLocked == false) - { - VisibilityLocked = true; - SetVisibility(VisibilityLevel.Ghost); - } - } - else if (CurrentHandState == HandState.GripToggleOnNotInteracting) - { - if (VisibilityLocked == false) - { - VisibilityLocked = true; - SetVisibility(VisibilityLevel.Visible); - } - } - } - } - else if (Player.PhysicalHands == false && Player.MakeControllerInvisibleOnInteraction == true) - { - if (IsInteracting == true) - { - SetVisibility(VisibilityLevel.Invisible); - } - else if (IsInteracting == false) - { - SetVisibility(VisibilityLevel.Ghost); - } - } - } - - public void TriggerHapticPulse(ushort durationMicroSec = 500, NVRButtons button = NVRButtons.Grip) - { - if (InputDevice != null) - { - if (durationMicroSec < 3000) - { - InputDevice.TriggerHapticPulse(durationMicroSec, button); - } - else - { - Debug.LogWarning("You're trying to pulse for over 3000 microseconds, you probably don't want to do that. If you do, use NVRHand.LongHapticPulse(float seconds)"); - } - } - } - - public void LongHapticPulse(float seconds, NVRButtons button = NVRButtons.Grip) - { - StartCoroutine(DoLongHapticPulse(seconds, button)); - } - - private IEnumerator DoLongHapticPulse(float seconds, NVRButtons button) - { - float startTime = Time.time; - float endTime = startTime + seconds; - while (Time.time < endTime) - { - TriggerHapticPulse(100, button); - yield return null; - } - } - - public Vector3 GetVelocityEstimation() - { - float delta = LastDeltas.Sum(); - Vector3 distance = Vector3.zero; - - for (int index = 0; index < LastPositions.Length - 1; index++) - { - Vector3 diff = LastPositions[index + 1] - LastPositions[index]; - distance += diff; - } - - return distance / delta; - } - - public Vector3 GetAngularVelocityEstimation() - { - float delta = LastDeltas.Sum(); - float angleDegrees = 0.0f; - Vector3 unitAxis = Vector3.zero; - Quaternion rotation = Quaternion.identity; - - rotation = LastRotations[LastRotations.Length - 1] * Quaternion.Inverse(LastRotations[LastRotations.Length - 2]); - - //Error: the incorrect rotation is sometimes returned - rotation.ToAngleAxis(out angleDegrees, out unitAxis); - return unitAxis * ((angleDegrees * Mathf.Deg2Rad) / delta); - } - - public Vector3 GetPositionDelta() - { - int last = EstimationSampleIndex - 1; - int secondToLast = EstimationSampleIndex - 2; - - if (last < 0) - last += EstimationSamples; - if (secondToLast < 0) - secondToLast += EstimationSamples; - - return LastPositions[last] - LastPositions[secondToLast]; - } - - public Quaternion GetRotationDelta() - { - int last = EstimationSampleIndex - 1; - int secondToLast = EstimationSampleIndex - 2; - - if (last < 0) - last += EstimationSamples; - if (secondToLast < 0) - secondToLast += EstimationSamples; - - return LastRotations[last] * Quaternion.Inverse(LastRotations[secondToLast]); - } - - protected virtual void FixedUpdate() - { - if (CurrentHandState == HandState.Uninitialized) - { - return; - } - - LastPositions[EstimationSampleIndex] = this.transform.position; - LastRotations[EstimationSampleIndex] = this.transform.rotation; - LastDeltas[EstimationSampleIndex] = Time.deltaTime; - EstimationSampleIndex++; - - if (EstimationSampleIndex >= LastPositions.Length) - EstimationSampleIndex = 0; - - if (InputDevice != null && IsInteracting == false && IsHovering == true) - { - if (Player.VibrateOnHover == true) - { - InputDevice.TriggerHapticPulse(100); - } - } - } - - public virtual void BeginInteraction(NVRInteractable interactable) - { - if (interactable.CanAttach == true) - { - if (interactable.AttachedHand != null) - { - interactable.AttachedHand.EndInteraction(null); - } - - CurrentlyInteracting = interactable; + button.FrameReset(InputDevice, nvrbutton); + } + } + + protected void UpdateInteractions() + { + if (CurrentInteractionStyle == InterationStyle.Hold) + { + if (HoldButtonUp == true) + { + VisibilityLocked = false; + } + + if (HoldButtonDown == true) + { + if (CurrentlyInteracting == null) + { + PickupClosest(); + } + } + else if (HoldButtonUp == true && CurrentlyInteracting != null) + { + EndInteraction(null); + } + } + else if (CurrentInteractionStyle == InterationStyle.Toggle) + { + if (HoldButtonDown == true) + { + if (CurrentHandState == HandState.Idle) + { + PickupClosest(); + if (IsInteracting) + { + CurrentHandState = HandState.GripToggleOnInteracting; + } + else if (Player.PhysicalHands == true) + { + CurrentHandState = HandState.GripToggleOnNotInteracting; + } + } + else if (CurrentHandState == HandState.GripToggleOnInteracting) + { + CurrentHandState = HandState.Idle; + VisibilityLocked = false; + EndInteraction(null); + } + else if (CurrentHandState == HandState.GripToggleOnNotInteracting) + { + CurrentHandState = HandState.Idle; + VisibilityLocked = false; + } + } + } + else if (CurrentInteractionStyle == InterationStyle.ByScript) + { + //this is handled by user customized scripts. + } + + if (IsInteracting == true) + { + CurrentlyInteracting.InteractingUpdate(this); + } + } + + protected void UpdateVisibilityAndColliders() + { + if (Player.PhysicalHands == true) + { + if (CurrentInteractionStyle == InterationStyle.Hold) + { + if (HoldButtonPressed == true && IsInteracting == false) + { + if (CurrentHandState != HandState.GripDownNotInteracting && VisibilityLocked == false) + { + VisibilityLocked = true; + SetVisibility(VisibilityLevel.Visible); + CurrentHandState = HandState.GripDownNotInteracting; + } + } + else if (HoldButtonDown == true && IsInteracting == true) + { + if (CurrentHandState != HandState.GripDownInteracting && VisibilityLocked == false) + { + VisibilityLocked = true; + if (Player.MakeControllerInvisibleOnInteraction == true) + { + SetVisibility(VisibilityLevel.Invisible); + } + else + { + SetVisibility(VisibilityLevel.Ghost); + } + CurrentHandState = HandState.GripDownInteracting; + } + } + else if (IsInteracting == false) + { + if (CurrentHandState != HandState.Idle && VisibilityLocked == false) + { + SetVisibility(VisibilityLevel.Ghost); + CurrentHandState = HandState.Idle; + } + } + } + else if (CurrentInteractionStyle == InterationStyle.Toggle) + { + if (CurrentHandState == HandState.Idle) + { + if (VisibilityLocked == false && CurrentVisibility != VisibilityLevel.Ghost) + { + SetVisibility(VisibilityLevel.Ghost); + } + else + { + VisibilityLocked = false; + } + + } + else if (CurrentHandState == HandState.GripToggleOnInteracting) + { + if (VisibilityLocked == false) + { + VisibilityLocked = true; + SetVisibility(VisibilityLevel.Ghost); + } + } + else if (CurrentHandState == HandState.GripToggleOnNotInteracting) + { + if (VisibilityLocked == false) + { + VisibilityLocked = true; + SetVisibility(VisibilityLevel.Visible); + } + } + } + } + else if (Player.PhysicalHands == false && Player.MakeControllerInvisibleOnInteraction == true) + { + if (IsInteracting == true) + { + SetVisibility(VisibilityLevel.Invisible); + } + else if (IsInteracting == false) + { + SetVisibility(VisibilityLevel.Ghost); + } + } + } + + public void TriggerHapticPulse(ushort durationMicroSec = 500, NVRButtons button = NVRButtons.Grip) + { + if (InputDevice != null) + { + if (durationMicroSec < 3000) + { + InputDevice.TriggerHapticPulse(durationMicroSec, button); + } + else + { + Debug.LogWarning("You're trying to pulse for over 3000 microseconds, you probably don't want to do that. If you do, use NVRHand.LongHapticPulse(float seconds)"); + } + } + } + + public void LongHapticPulse(float seconds, NVRButtons button = NVRButtons.Grip) + { + StartCoroutine(DoLongHapticPulse(seconds, button)); + } + + private IEnumerator DoLongHapticPulse(float seconds, NVRButtons button) + { + float startTime = Time.time; + float endTime = startTime + seconds; + while (Time.time < endTime) + { + TriggerHapticPulse(100, button); + yield return null; + } + } + + public Vector3 GetVelocityEstimation() + { + float delta = LastDeltas.Sum(); + Vector3 distance = Vector3.zero; + + for (int index = 0; index < LastPositions.Length - 1; index++) + { + Vector3 diff = LastPositions[index + 1] - LastPositions[index]; + distance += diff; + } + + return distance / delta; + } + + public Vector3 GetAngularVelocityEstimation() + { + float delta = LastDeltas.Sum(); + float angleDegrees = 0.0f; + Vector3 unitAxis = Vector3.zero; + Quaternion rotation = Quaternion.identity; + + rotation = LastRotations[LastRotations.Length - 1] * Quaternion.Inverse(LastRotations[LastRotations.Length - 2]); + + //Error: the incorrect rotation is sometimes returned + rotation.ToAngleAxis(out angleDegrees, out unitAxis); + return unitAxis * ((angleDegrees * Mathf.Deg2Rad) / delta); + } + + public Vector3 GetPositionDelta() + { + int last = EstimationSampleIndex - 1; + int secondToLast = EstimationSampleIndex - 2; + + if (last < 0) + last += EstimationSamples; + if (secondToLast < 0) + secondToLast += EstimationSamples; + + return LastPositions[last] - LastPositions[secondToLast]; + } + + public Quaternion GetRotationDelta() + { + int last = EstimationSampleIndex - 1; + int secondToLast = EstimationSampleIndex - 2; + + if (last < 0) + last += EstimationSamples; + if (secondToLast < 0) + secondToLast += EstimationSamples; + + return LastRotations[last] * Quaternion.Inverse(LastRotations[secondToLast]); + } + + protected virtual void FixedUpdate() + { + if (CurrentHandState == HandState.Uninitialized) + { + return; + } + + LastPositions[EstimationSampleIndex] = this.transform.position; + LastRotations[EstimationSampleIndex] = this.transform.rotation; + LastDeltas[EstimationSampleIndex] = Time.deltaTime; + EstimationSampleIndex++; + + if (EstimationSampleIndex >= LastPositions.Length) + EstimationSampleIndex = 0; + + if (InputDevice != null && IsInteracting == false && IsHovering == true) + { + if (Player.VibrateOnHover == true) + { + InputDevice.TriggerHapticPulse(100); + } + } + } + + public virtual void BeginInteraction(NVRInteractable interactable) + { + if (interactable.CanAttach == true) + { + if (interactable.AttachedHand != null) + { + interactable.AttachedHand.EndInteraction(null); + } + + CurrentlyInteracting = interactable; CurrentlyInteracting.BeginInteraction(this); if (OnBeginInteraction != null) { OnBeginInteraction.Invoke(interactable); - } - } - } - - public virtual void EndInteraction(NVRInteractable item) - { - if (item != null && CurrentlyHoveringOver.ContainsKey(item) == true) - CurrentlyHoveringOver.Remove(item); - - if (CurrentlyInteracting != null) - { + } + } + } + + public virtual void EndInteraction(NVRInteractable item) + { + if (item != null && CurrentlyHoveringOver.ContainsKey(item) == true) + CurrentlyHoveringOver.Remove(item); + + if (CurrentlyInteracting != null) + { CurrentlyInteracting.EndInteraction(); if (OnEndInteraction != null) @@ -575,307 +577,307 @@ public virtual void EndInteraction(NVRInteractable item) OnEndInteraction.Invoke(CurrentlyInteracting); } - CurrentlyInteracting = null; - } - - if (CurrentInteractionStyle == InterationStyle.Toggle) - { - if (CurrentHandState != HandState.Idle) - { - CurrentHandState = HandState.Idle; - } - } - } - - protected bool PickupClosest() - { - NVRInteractable closest = null; - float closestDistance = float.MaxValue; - - foreach (var hovering in CurrentlyHoveringOver) - { - if (hovering.Key == null) - continue; - - float distance = Vector3.Distance(this.transform.position, hovering.Key.transform.position); - if (distance < closestDistance) - { - closestDistance = distance; - closest = hovering.Key; - } - } - - if (closest != null) - { - BeginInteraction(closest); - return true; - } - else - { - return false; - } - } - - protected virtual void OnTriggerEnter(Collider collider) - { - NVRInteractable interactable = NVRInteractables.GetInteractable(collider); - if (interactable == null || interactable.enabled == false) - return; - - if (CurrentlyHoveringOver.ContainsKey(interactable) == false) - CurrentlyHoveringOver[interactable] = new Dictionary(); - - if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false) - CurrentlyHoveringOver[interactable][collider] = Time.time; - } - - protected virtual void OnTriggerStay(Collider collider) - { - NVRInteractable interactable = NVRInteractables.GetInteractable(collider); - if (interactable == null || interactable.enabled == false) - return; - - if (CurrentlyHoveringOver.ContainsKey(interactable) == false) - CurrentlyHoveringOver[interactable] = new Dictionary(); - - if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false) - CurrentlyHoveringOver[interactable][collider] = Time.time; - } - - protected virtual void OnTriggerExit(Collider collider) - { - NVRInteractable interactable = NVRInteractables.GetInteractable(collider); - if (interactable == null) - return; - - if (CurrentlyHoveringOver.ContainsKey(interactable) == true) - { - if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == true) - { - CurrentlyHoveringOver[interactable].Remove(collider); - if (CurrentlyHoveringOver[interactable].Count == 0) - { - CurrentlyHoveringOver.Remove(interactable); - } - } - } - } - - public string GetDeviceName() - { - if (InputDevice != null) - return InputDevice.GetDeviceName(); - else - return null; - } - - public Collider[] SetupDefaultPhysicalColliders(Transform ModelParent) - { - return InputDevice.SetupDefaultPhysicalColliders(ModelParent); - } - - public void DeregisterInteractable(NVRInteractable interactable) - { - if (CurrentlyInteracting == interactable) - CurrentlyInteracting = null; - - if (CurrentlyHoveringOver != null && CurrentlyHoveringOver.ContainsKey(interactable)) - CurrentlyHoveringOver.Remove(interactable); - } - - private void SetVisibility(VisibilityLevel visibility) - { - if (CurrentVisibility != visibility) - { - if (visibility == VisibilityLevel.Invisible) - { - if (PhysicalController != null) - { - PhysicalController.Off(); - } - - if (Player.AutomaticallySetControllerTransparency == true) - { - for (int index = 0; index < GhostRenderers.Length; index++) - { - GhostRenderers[index].enabled = false; - } - - for (int index = 0; index < GhostColliders.Length; index++) - { - GhostColliders[index].enabled = false; - } - } - } - - if (visibility == VisibilityLevel.Ghost) - { - if (PhysicalController != null) - { - PhysicalController.Off(); - } - - if (Player.AutomaticallySetControllerTransparency == true) - { - for (int index = 0; index < GhostRenderers.Length; index++) - { - GhostRenderers[index].enabled = true; - } - - for (int index = 0; index < GhostColliders.Length; index++) - { - GhostColliders[index].enabled = true; - } - } - } - - if (visibility == VisibilityLevel.Visible) - { - if (PhysicalController != null) - { - PhysicalController.On(); - } - - if (Player.AutomaticallySetControllerTransparency == true) - { - for (int index = 0; index < GhostRenderers.Length; index++) - { - GhostRenderers[index].enabled = false; - } - - for (int index = 0; index < GhostColliders.Length; index++) - { - GhostColliders[index].enabled = false; - } - } - } - } - - CurrentVisibility = visibility; - } - - protected void InitializeRenderModel() - { - if (CustomModel == null) - { - RenderModel = InputDevice.SetupDefaultRenderModel(); - } - else - { - RenderModel = GameObject.Instantiate(CustomModel); - - RenderModel.transform.parent = this.transform; - RenderModel.transform.localScale = RenderModel.transform.localScale; - RenderModel.transform.localPosition = Vector3.zero; - RenderModel.transform.localRotation = Quaternion.identity; - } - } - - public virtual void Initialize() - { - Rigidbody = this.GetComponent(); - if (Rigidbody == null) - Rigidbody = this.gameObject.AddComponent(); - Rigidbody.isKinematic = true; - Rigidbody.maxAngularVelocity = float.MaxValue; - Rigidbody.useGravity = false; - - Collider[] colliders = null; - - if (CustomModel == null) - { - colliders = InputDevice.SetupDefaultColliders(); - } - else - { - colliders = RenderModel.GetComponentsInChildren(); //note: these should be trigger colliders - } - - Player.RegisterHand(this); - - if (Player.PhysicalHands == true) - { - if (PhysicalController != null) - { - PhysicalController.Kill(); - } - - PhysicalController = this.gameObject.AddComponent(); - PhysicalController.Initialize(this, false); - - if (Player.AutomaticallySetControllerTransparency == true) - { - Color transparentcolor = Color.white; - transparentcolor.a = (float)VisibilityLevel.Ghost / 100f; - - GhostRenderers = this.GetComponentsInChildren(); - for (int rendererIndex = 0; rendererIndex < GhostRenderers.Length; rendererIndex++) - { - NVRHelpers.SetTransparent(GhostRenderers[rendererIndex].material, transparentcolor); - } - } - - if (colliders != null) - { - GhostColliders = colliders; - } - - CurrentVisibility = VisibilityLevel.Ghost; - } - else - { - if (Player.AutomaticallySetControllerTransparency == true) - { - Color transparentcolor = Color.white; - transparentcolor.a = (float)VisibilityLevel.Ghost / 100f; - - GhostRenderers = this.GetComponentsInChildren(); - for (int rendererIndex = 0; rendererIndex < GhostRenderers.Length; rendererIndex++) - { - NVRHelpers.SetTransparent(GhostRenderers[rendererIndex].material, transparentcolor); - } - } - - if (colliders != null) - { - GhostColliders = colliders; - } - - CurrentVisibility = VisibilityLevel.Ghost; - } - - CurrentHandState = HandState.Idle; - } - - public void ForceGhost() - { - SetVisibility(VisibilityLevel.Ghost); - PhysicalController.Off(); - } + CurrentlyInteracting = null; + } + + if (CurrentInteractionStyle == InterationStyle.Toggle) + { + if (CurrentHandState != HandState.Idle) + { + CurrentHandState = HandState.Idle; + } + } + } + + protected bool PickupClosest() + { + NVRInteractable closest = null; + float closestDistance = float.MaxValue; + + foreach (var hovering in CurrentlyHoveringOver) + { + if (hovering.Key == null) + continue; + + float distance = Vector3.Distance(this.transform.position, hovering.Key.transform.position); + if (distance < closestDistance) + { + closestDistance = distance; + closest = hovering.Key; + } + } + + if (closest != null) + { + BeginInteraction(closest); + return true; + } + else + { + return false; + } + } + + protected virtual void OnTriggerEnter(Collider collider) + { + NVRInteractable interactable = NVRInteractables.GetInteractable(collider); + if (interactable == null || interactable.enabled == false) + return; + + if (CurrentlyHoveringOver.ContainsKey(interactable) == false) + CurrentlyHoveringOver[interactable] = new Dictionary(); + + if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false) + CurrentlyHoveringOver[interactable][collider] = Time.time; + } + + protected virtual void OnTriggerStay(Collider collider) + { + NVRInteractable interactable = NVRInteractables.GetInteractable(collider); + if (interactable == null || interactable.enabled == false) + return; + + if (CurrentlyHoveringOver.ContainsKey(interactable) == false) + CurrentlyHoveringOver[interactable] = new Dictionary(); + + if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false) + CurrentlyHoveringOver[interactable][collider] = Time.time; + } + + protected virtual void OnTriggerExit(Collider collider) + { + NVRInteractable interactable = NVRInteractables.GetInteractable(collider); + if (interactable == null) + return; + + if (CurrentlyHoveringOver.ContainsKey(interactable) == true) + { + if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == true) + { + CurrentlyHoveringOver[interactable].Remove(collider); + if (CurrentlyHoveringOver[interactable].Count == 0) + { + CurrentlyHoveringOver.Remove(interactable); + } + } + } + } + + public string GetDeviceName() + { + if (InputDevice != null) + return InputDevice.GetDeviceName(); + else + return null; + } + + public Collider[] SetupDefaultPhysicalColliders(Transform ModelParent) + { + return InputDevice.SetupDefaultPhysicalColliders(ModelParent); + } + + public void DeregisterInteractable(NVRInteractable interactable) + { + if (CurrentlyInteracting == interactable) + CurrentlyInteracting = null; + + if (CurrentlyHoveringOver != null && CurrentlyHoveringOver.ContainsKey(interactable)) + CurrentlyHoveringOver.Remove(interactable); + } + + private void SetVisibility(VisibilityLevel visibility) + { + if (CurrentVisibility != visibility) + { + if (visibility == VisibilityLevel.Invisible) + { + if (PhysicalController != null) + { + PhysicalController.Off(); + } + + if (Player.AutomaticallySetControllerTransparency == true) + { + for (int index = 0; index < GhostRenderers.Length; index++) + { + GhostRenderers[index].enabled = false; + } + + for (int index = 0; index < GhostColliders.Length; index++) + { + GhostColliders[index].enabled = false; + } + } + } + + if (visibility == VisibilityLevel.Ghost) + { + if (PhysicalController != null) + { + PhysicalController.Off(); + } + + if (Player.AutomaticallySetControllerTransparency == true) + { + for (int index = 0; index < GhostRenderers.Length; index++) + { + GhostRenderers[index].enabled = true; + } + + for (int index = 0; index < GhostColliders.Length; index++) + { + GhostColliders[index].enabled = true; + } + } + } + + if (visibility == VisibilityLevel.Visible) + { + if (PhysicalController != null) + { + PhysicalController.On(); + } + + if (Player.AutomaticallySetControllerTransparency == true) + { + for (int index = 0; index < GhostRenderers.Length; index++) + { + GhostRenderers[index].enabled = false; + } + + for (int index = 0; index < GhostColliders.Length; index++) + { + GhostColliders[index].enabled = false; + } + } + } + } + + CurrentVisibility = visibility; + } + + protected void InitializeRenderModel() + { + if (CustomModel == null) + { + RenderModel = InputDevice.SetupDefaultRenderModel(); + } + else + { + RenderModel = GameObject.Instantiate(CustomModel); + + RenderModel.transform.parent = this.transform; + RenderModel.transform.localScale = RenderModel.transform.localScale; + RenderModel.transform.localPosition = Vector3.zero; + RenderModel.transform.localRotation = Quaternion.identity; + } + } + + public virtual void Initialize() + { + Rigidbody = this.GetComponent(); + if (Rigidbody == null) + Rigidbody = this.gameObject.AddComponent(); + Rigidbody.isKinematic = true; + Rigidbody.maxAngularVelocity = float.MaxValue; + Rigidbody.useGravity = false; + + Collider[] colliders = null; + + if (CustomModel == null) + { + colliders = InputDevice.SetupDefaultColliders(); + } + else + { + colliders = RenderModel.GetComponentsInChildren(); //note: these should be trigger colliders + } + + Player.RegisterHand(this); + + if (Player.PhysicalHands == true) + { + if (PhysicalController != null) + { + PhysicalController.Kill(); + } + + PhysicalController = this.gameObject.AddComponent(); + PhysicalController.Initialize(this, false); + + if (Player.AutomaticallySetControllerTransparency == true) + { + Color transparentcolor = Color.white; + transparentcolor.a = (float)VisibilityLevel.Ghost / 100f; + + GhostRenderers = this.GetComponentsInChildren(); + for (int rendererIndex = 0; rendererIndex < GhostRenderers.Length; rendererIndex++) + { + NVRHelpers.SetTransparent(GhostRenderers[rendererIndex].material, transparentcolor); + } + } + + if (colliders != null) + { + GhostColliders = colliders; + } + + CurrentVisibility = VisibilityLevel.Ghost; + } + else + { + if (Player.AutomaticallySetControllerTransparency == true) + { + Color transparentcolor = Color.white; + transparentcolor.a = (float)VisibilityLevel.Ghost / 100f; + + GhostRenderers = this.GetComponentsInChildren(); + for (int rendererIndex = 0; rendererIndex < GhostRenderers.Length; rendererIndex++) + { + NVRHelpers.SetTransparent(GhostRenderers[rendererIndex].material, transparentcolor); + } + } + + if (colliders != null) + { + GhostColliders = colliders; + } + + CurrentVisibility = VisibilityLevel.Ghost; + } + + CurrentHandState = HandState.Idle; + } + + public void ForceGhost() + { + SetVisibility(VisibilityLevel.Ghost); + PhysicalController.Off(); + } + } + + public enum VisibilityLevel + { + Invisible = 0, + Ghost = 70, + Visible = 100, } - public enum VisibilityLevel - { - Invisible = 0, - Ghost = 70, - Visible = 100, - } - - public enum HandState - { + public enum HandState + { Uninitialized, - Idle, - GripDownNotInteracting, - GripDownInteracting, - GripToggleOnNotInteracting, - GripToggleOnInteracting, - GripToggleOff - } - - public enum InterationStyle - { - Hold, - Toggle, - ByScript, - } -} \ No newline at end of file + Idle, + GripDownNotInteracting, + GripDownInteracting, + GripToggleOnNotInteracting, + GripToggleOnInteracting, + GripToggleOff + } + + public enum InterationStyle + { + Hold, + Toggle, + ByScript, + } +} From 8469acadc2ecc6c0fadc238324f741e861e69e9d Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 9 Jan 2017 12:04:15 -0600 Subject: [PATCH 05/29] Trigger OnBeginUseInteraction and OnEndUseInteraction on NVRHand via NVRInteractable --- Assets/NewtonVR/NVRInteractable.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Assets/NewtonVR/NVRInteractable.cs b/Assets/NewtonVR/NVRInteractable.cs index 50f5df0f..493aabe1 100644 --- a/Assets/NewtonVR/NVRInteractable.cs +++ b/Assets/NewtonVR/NVRInteractable.cs @@ -113,11 +113,21 @@ public virtual void InteractingUpdate(NVRHand hand) if (hand.UseButtonUp == true) { UseButtonUp(); + + if (hand.OnEndUseInteraction != null) + { + hand.OnEndUseInteraction.Invoke(this); + } } if (hand.UseButtonDown == true) { UseButtonDown(); + + if (hand.OnBeginUseInteraction != null) + { + hand.OnBeginUseInteraction.Invoke(this); + } } } From ee82220ca1c278c6874a7f6286f2297147a6f7e4 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 16 Jan 2017 10:30:34 -0600 Subject: [PATCH 06/29] Added PickupByName(objectID) to ensure NVRVirtualHand can pick up the correct object --- Assets/NewtonVR/NVRHand.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index c4aeb69b..6375fa25 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -617,6 +617,36 @@ protected bool PickupClosest() return false; } } + + protected bool PickupByName(string withName) + { + NVRInteractable closest = null; + float closestDistance = float.MaxValue; + + + foreach (var hovering in CurrentlyHoveringOver) + { + if (hovering.Key == null) + continue; + + float distance = Vector3.Distance(this.transform.position, hovering.Key.transform.position); + if (distance < closestDistance && hovering.Key.name==withName) + { + closestDistance = distance; + closest = hovering.Key; + } + } + + if (closest != null) + { + BeginInteraction(closest); + return true; + } + else + { + return false; + } + } protected virtual void OnTriggerEnter(Collider collider) { From f21e21565ccac36823d0954b6a4b456abdabf56b Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 16 Jan 2017 10:34:31 -0600 Subject: [PATCH 07/29] Added Hold(objectID) to NVRVirtualHand to improve multiplayer accuracy This should help ensure virtual hands pick up the same object as the remote player. Note that I also kept the original `Hold()` method for use as an NPC hand controller too. --- Assets/NewtonVR/NVRVirtualHand.cs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Assets/NewtonVR/NVRVirtualHand.cs b/Assets/NewtonVR/NVRVirtualHand.cs index ea4f213f..a5de837e 100644 --- a/Assets/NewtonVR/NVRVirtualHand.cs +++ b/Assets/NewtonVR/NVRVirtualHand.cs @@ -71,14 +71,25 @@ protected override void Update() UpdateVisibilityAndColliders(); } - public void Hold () - { - PickupClosest (); - if (IsInteracting) + public void Hold () + { + PickupClosest(); + + if (IsInteracting) { CurrentHandState = HandState.GripToggleOnInteracting; } - } + } + + public void Hold (string withID) + { + PickupByName(withID); + + if (IsInteracting) + { + CurrentHandState = HandState.GripToggleOnInteracting; + } + } public void Release () { From b3dcd8c28449a04b13a29890ed4f8904cfbe29fd Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 16 Jan 2017 10:36:33 -0600 Subject: [PATCH 08/29] Increased collider radius on virtual hands to compensate for remote movements being out of sync This isn't as ideal as client-side prediction and synchronization, but will help ensure objects are still successfully picked up, and those techniques can be built on top of this work later on. --- Assets/NewtonVR/NVRVirtualInputDevice.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/NewtonVR/NVRVirtualInputDevice.cs b/Assets/NewtonVR/NVRVirtualInputDevice.cs index 3017cd25..c670b3d3 100644 --- a/Assets/NewtonVR/NVRVirtualInputDevice.cs +++ b/Assets/NewtonVR/NVRVirtualInputDevice.cs @@ -141,7 +141,7 @@ public override Collider[] SetupDefaultColliders() SphereCollider Collider = RenderModel.AddComponent(); Collider.isTrigger = true; - Collider.radius = 0.15f; + Collider.radius = 0.5f; Colliders = new Collider[] { Collider }; From e84c1fc35118aa135afb85aefdfa376da14e3348 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 27 Feb 2017 14:07:04 -0600 Subject: [PATCH 09/29] Added EndUse() to virtualize releasing the use trigger --- Assets/NewtonVR/NVRVirtualHand.cs | 40 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/Assets/NewtonVR/NVRVirtualHand.cs b/Assets/NewtonVR/NVRVirtualHand.cs index a5de837e..9a982c2e 100644 --- a/Assets/NewtonVR/NVRVirtualHand.cs +++ b/Assets/NewtonVR/NVRVirtualHand.cs @@ -71,7 +71,7 @@ protected override void Update() UpdateVisibilityAndColliders(); } - public void Hold () + public void Hold() { PickupClosest(); @@ -81,7 +81,7 @@ public void Hold () } } - public void Hold (string withID) + public void Hold(string withID) { PickupByName(withID); @@ -91,21 +91,29 @@ public void Hold (string withID) } } - public void Release () - { - if (CurrentlyInteracting != null) - { - EndInteraction (null); - } - } + public void Release() + { + if (CurrentlyInteracting != null) + { + EndInteraction (null); + } + } - public void Use () - { - if (CurrentlyInteracting != null) - { - CurrentlyInteracting.UseButtonDown (); - } - } + public void Use() + { + if (CurrentlyInteracting != null) + { + CurrentlyInteracting.UseButtonDown (); + } + } + + public void EndUse() + { + if (CurrentlyInteracting != null) + { + CurrentlyInteracting.UseButtonUp(); + } + } public override void Initialize() { From 11eca22a05841cbd001ea9334d5021061ec84c12 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 27 Feb 2017 15:58:24 -0600 Subject: [PATCH 10/29] Corrected method names in debug outputs --- Assets/NewtonVR/NVRInteractables.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/NewtonVR/NVRInteractables.cs b/Assets/NewtonVR/NVRInteractables.cs index dd426401..ecff0792 100644 --- a/Assets/NewtonVR/NVRInteractables.cs +++ b/Assets/NewtonVR/NVRInteractables.cs @@ -39,7 +39,7 @@ public static void Deregister(NVRInteractable interactable) { if (Initialized == false) { - Debug.LogError("[NewtonVR] Error: NVRInteractables.Register called before initialization."); + Debug.LogError("[NewtonVR] Error: NVRInteractables.Deregister called before initialization."); } NVRPlayer.DeregisterInteractable(interactable); @@ -52,7 +52,7 @@ public static NVRInteractable GetInteractable(Collider collider) { if (Initialized == false) { - Debug.LogError("[NewtonVR] Error: NVRInteractables.Register called before initialization."); + Debug.LogError("[NewtonVR] Error: NVRInteractables.GetInteractable called before initialization."); } NVRInteractable interactable; @@ -60,4 +60,4 @@ public static NVRInteractable GetInteractable(Collider collider) return interactable; } } -} \ No newline at end of file +} From f66e1de482853f43e93baa7bc18b7c7e05a51425 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Mon, 27 Feb 2017 16:17:52 -0600 Subject: [PATCH 11/29] Fix for crash on launch if interactables try to register themselves too soon Our user testing has found the following periodic crash on launch: ``` [NewtonVR] Error: NVRInteractables.Register called before initialization. (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) NullReferenceException: Object reference not set to an instance of an object at NewtonVR.NVRInteractables.Register (NewtonVR.NVRInteractable interactable, UnityEngine.Collider[] colliders) [0x00000] in :0 at NewtonVR.NVRInteractable.UpdateColliders () [0x00000] in :0 at NewtonVR.NVRInteractableItem.UpdateColliders () [0x00000] in :0 at NewtonVR.NVRInteractable.Start () [0x00000] in :0 at NewtonVR.NVRInteractableItem.Start () [0x00000] in :0 (Filename: Line: -1) NullReferenceException: Object reference not set to an instance of an object at Flipside.Loader.SetAppMode (AppMode newMode) [0x00000] in :0 at Flipside.Loader+c__Iterator36.MoveNext () [0x00000] in :0 at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0 (Filename: Line: -1) ``` --- Assets/NewtonVR/NVRInteractables.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Assets/NewtonVR/NVRInteractables.cs b/Assets/NewtonVR/NVRInteractables.cs index ecff0792..12269267 100644 --- a/Assets/NewtonVR/NVRInteractables.cs +++ b/Assets/NewtonVR/NVRInteractables.cs @@ -14,9 +14,12 @@ public class NVRInteractables : MonoBehaviour public static void Initialize() { - ColliderMapping = new Dictionary(); - NVRInteractableMapping = new Dictionary(); - + if (! Initialized) + { + ColliderMapping = new Dictionary(); + NVRInteractableMapping = new Dictionary(); + } + Initialized = true; } @@ -24,7 +27,8 @@ public static void Register(NVRInteractable interactable, Collider[] colliders) { if (Initialized == false) { - Debug.LogError("[NewtonVR] Error: NVRInteractables.Register called before initialization."); + Debug.LogWarning("[NewtonVR] Warning: NVRInteractables.Register called before initialization."); + Initialize(); } NVRInteractableMapping[interactable] = colliders; @@ -39,7 +43,8 @@ public static void Deregister(NVRInteractable interactable) { if (Initialized == false) { - Debug.LogError("[NewtonVR] Error: NVRInteractables.Deregister called before initialization."); + Debug.LogWarning("[NewtonVR] Warning: NVRInteractables.Deregister called before initialization."); + Initialize(); } NVRPlayer.DeregisterInteractable(interactable); @@ -52,7 +57,8 @@ public static NVRInteractable GetInteractable(Collider collider) { if (Initialized == false) { - Debug.LogError("[NewtonVR] Error: NVRInteractables.GetInteractable called before initialization."); + Debug.LogWarning("[NewtonVR] Warning: NVRInteractables.GetInteractable called before initialization."); + Initialize(); } NVRInteractable interactable; From 3caa1e1869c8184d9be2037f36bb845bf4c97633 Mon Sep 17 00:00:00 2001 From: John Luxford Date: Tue, 21 Mar 2017 16:51:52 -0500 Subject: [PATCH 12/29] Added null checks which allows buttons to work when NVRVirtualHand is present --- Assets/NewtonVR/NVRButtonInput.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Assets/NewtonVR/NVRButtonInput.cs b/Assets/NewtonVR/NVRButtonInput.cs index f9e40eb7..ec3d934f 100644 --- a/Assets/NewtonVR/NVRButtonInput.cs +++ b/Assets/NewtonVR/NVRButtonInput.cs @@ -14,7 +14,7 @@ public bool PressDown { if (PressDownExpired) { - PressDownCached = InputDevice.GetPressDown(nvrbutton); + PressDownCached = (InputDevice != null) ? InputDevice.GetPressDown(nvrbutton) : false; PressDownExpired = false; } return PressDownCached; @@ -31,7 +31,7 @@ public bool PressUp { if (PressUpExpired) { - PressUpCached = InputDevice.GetPressUp(nvrbutton); + PressUpCached = (InputDevice != null) ? InputDevice.GetPressUp(nvrbutton) : false; PressUpExpired = false; } return PressUpCached; @@ -48,7 +48,7 @@ public bool IsPressed { if (IsPressedExpired) { - IsPressedCached = InputDevice.GetPress(nvrbutton); + IsPressedCached = (InputDevice != null) ? InputDevice.GetPress(nvrbutton) : false; IsPressedExpired = false; } return IsPressedCached; @@ -65,7 +65,7 @@ public bool TouchDown { if (TouchDownExpired) { - TouchDownCached = InputDevice.GetTouchDown(nvrbutton); + TouchDownCached = (InputDevice != null) ? InputDevice.GetTouchDown(nvrbutton) : false; TouchDownExpired = false; } return TouchDownCached; @@ -82,7 +82,7 @@ public bool TouchUp { if (TouchUpExpired) { - TouchUpCached = InputDevice.GetTouchUp(nvrbutton); + TouchUpCached = (InputDevice != null) ? InputDevice.GetTouchUp(nvrbutton) : false; TouchUpExpired = false; } return TouchUpCached; @@ -99,7 +99,7 @@ public bool IsTouched { if (IsTouchedExpired) { - IsTouchedCached = InputDevice.GetTouch(nvrbutton); + IsTouchedCached = (InputDevice != null) ? InputDevice.GetTouch(nvrbutton) : false; IsTouchedExpired = false; } return IsTouchedCached; @@ -116,7 +116,7 @@ public bool NearTouchDown { if (NearTouchDownExpired) { - NearTouchDownCached = InputDevice.GetNearTouchDown(nvrbutton); + NearTouchDownCached = (InputDevice != null) ? InputDevice.GetNearTouchDown(nvrbutton) : false; NearTouchDownExpired = false; } return NearTouchDownCached; @@ -133,7 +133,7 @@ public bool NearTouchUp { if (NearTouchUpExpired) { - NearTouchUpCached = InputDevice.GetNearTouchUp(nvrbutton); + NearTouchUpCached = (InputDevice != null) ? InputDevice.GetNearTouchUp(nvrbutton) : false; NearTouchUpExpired = false; } return NearTouchUpCached; @@ -150,7 +150,7 @@ public bool IsNearTouched { if (IsNearTouchedExpired) { - IsNearTouchedCached = InputDevice.GetNearTouch(nvrbutton); + IsNearTouchedCached = (InputDevice != null) ? InputDevice.GetNearTouch(nvrbutton) : false; IsNearTouchedExpired = false; } return IsNearTouchedCached; @@ -167,7 +167,7 @@ public Vector2 Axis { if (AxisExpired) { - AxisCached = InputDevice.GetAxis2D(nvrbutton); + AxisCached = (InputDevice != null) ? InputDevice.GetAxis2D(nvrbutton) : Vector2.zero; AxisExpired = false; } return AxisCached; @@ -184,7 +184,7 @@ public float SingleAxis { if (SingleAxisExpired) { - SingleAxisCached = InputDevice.GetAxis1D(nvrbutton); + SingleAxisCached = (InputDevice != null) ? InputDevice.GetAxis1D(nvrbutton) : 0f; SingleAxisExpired = false; } return SingleAxisCached; From 6d4753ba56e6b4e8be48d6ea0d19823865f35211 Mon Sep 17 00:00:00 2001 From: John Luxford Date: Thu, 6 Apr 2017 14:50:50 -0500 Subject: [PATCH 13/29] Added NVRHandedInteractableItem for different interaction points from handedness branch --- Assets/NewtonVR/NVRHandedInteractableItem.cs | 26 +++++++++++++++++++ .../NVRHandedInteractableItem.cs.meta | 12 +++++++++ Assets/NewtonVR/NVRVirtualHand.cs.meta | 12 +++++++++ Assets/NewtonVR/NVRVirtualInputDevice.cs.meta | 12 +++++++++ 4 files changed, 62 insertions(+) create mode 100644 Assets/NewtonVR/NVRHandedInteractableItem.cs create mode 100644 Assets/NewtonVR/NVRHandedInteractableItem.cs.meta create mode 100644 Assets/NewtonVR/NVRVirtualHand.cs.meta create mode 100644 Assets/NewtonVR/NVRVirtualInputDevice.cs.meta diff --git a/Assets/NewtonVR/NVRHandedInteractableItem.cs b/Assets/NewtonVR/NVRHandedInteractableItem.cs new file mode 100644 index 00000000..df05d97f --- /dev/null +++ b/Assets/NewtonVR/NVRHandedInteractableItem.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using System.Collections; +using NewtonVR; + +public class NVRHandedInteractableItem : NVRInteractableItem +{ + [SerializeField] + Transform LeftHandInteractionPoint; + + [SerializeField] + Transform RightHandInteractionPoint; + + public override void BeginInteraction (NVRHand hand) + { + if (hand.IsLeft) + { + InteractionPoint = LeftHandInteractionPoint; + } + else + { + InteractionPoint = RightHandInteractionPoint; + } + + base.BeginInteraction (hand); + } +} \ No newline at end of file diff --git a/Assets/NewtonVR/NVRHandedInteractableItem.cs.meta b/Assets/NewtonVR/NVRHandedInteractableItem.cs.meta new file mode 100644 index 00000000..3fec7674 --- /dev/null +++ b/Assets/NewtonVR/NVRHandedInteractableItem.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e437aa8a24f2b1b4d8e42563c9e9bc66 +timeCreated: 1491508195 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/NewtonVR/NVRVirtualHand.cs.meta b/Assets/NewtonVR/NVRVirtualHand.cs.meta new file mode 100644 index 00000000..da2a8782 --- /dev/null +++ b/Assets/NewtonVR/NVRVirtualHand.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1a83e007c2b15534398d66a2ae8c006d +timeCreated: 1490298892 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/NewtonVR/NVRVirtualInputDevice.cs.meta b/Assets/NewtonVR/NVRVirtualInputDevice.cs.meta new file mode 100644 index 00000000..d031db69 --- /dev/null +++ b/Assets/NewtonVR/NVRVirtualInputDevice.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 03f297ad42d9f784492134e2059ffb2b +timeCreated: 1490298892 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 8e0bdda8e7e62f6a90c5c210152ab6499001d18f Mon Sep 17 00:00:00 2001 From: John Luxford Date: Fri, 14 Apr 2017 13:44:27 -0500 Subject: [PATCH 14/29] Destroy children of newly-cloned physical hand Elements added for custom avatars were being duplicated into the physical hand if the Vive controllers weren't turned on before the avatar was assigned. --- Assets/NewtonVR/NVRPhysicalController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/NewtonVR/NVRPhysicalController.cs b/Assets/NewtonVR/NVRPhysicalController.cs index dddf4cca..eb0cec51 100644 --- a/Assets/NewtonVR/NVRPhysicalController.cs +++ b/Assets/NewtonVR/NVRPhysicalController.cs @@ -47,6 +47,11 @@ public void Initialize(NVRHand trackingHand, bool initialState) } } + foreach (Transform child in PhysicalController.transform) + { + Destroy(child.gameObject); + } + PhysicalController.transform.parent = Hand.transform.parent; PhysicalController.transform.position = Hand.transform.position; PhysicalController.transform.rotation = Hand.transform.rotation; From bdcf77bae530a19d8308cfe027be3308fe7abcf0 Mon Sep 17 00:00:00 2001 From: John Luxford Date: Wed, 12 Jul 2017 15:50:11 -0500 Subject: [PATCH 15/29] Added folders for dependencies to gitignore --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index e31b6a51..db9aeb7e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,11 @@ # Unity3D Generated File On Crash Reports sysinfo.txt + +Assets/Plugins.meta +Assets/Plugins/ +Assets/OVR.meta +Assets/OVR/ +Assets/SteamVR.meta +Assets/SteamVR/ + From 9968a74b33f0e872dcb983d7d9b9d00cdcea9f57 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Fri, 28 Jul 2017 11:45:17 -0500 Subject: [PATCH 16/29] Add CanvasRenderer to list of KeepTypes to fix exception at DestroyImmediate() on initialization --- Assets/NewtonVR/NVRPhysicalController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/NewtonVR/NVRPhysicalController.cs b/Assets/NewtonVR/NVRPhysicalController.cs index eb0cec51..2b8402a2 100644 --- a/Assets/NewtonVR/NVRPhysicalController.cs +++ b/Assets/NewtonVR/NVRPhysicalController.cs @@ -23,7 +23,7 @@ public class NVRPhysicalController : MonoBehaviour protected float AttachedRotationMagic = 20f; protected float AttachedPositionMagic = 3000f; - private Type[] KeepTypes = new Type[] {typeof(MeshFilter), typeof(Renderer), typeof(Transform), typeof(Rigidbody)}; + private Type[] KeepTypes = new Type[] {typeof(MeshFilter), typeof(Renderer), typeof(Transform), typeof(Rigidbody), typeof(CanvasRenderer)}; public void Initialize(NVRHand trackingHand, bool initialState) { @@ -214,4 +214,4 @@ protected void SetupCustomModel() Colliders = customCollidersTransform.GetComponentsInChildren(); } } -} \ No newline at end of file +} From 72655531be7a81b31336244d0062b2b714af3903 Mon Sep 17 00:00:00 2001 From: John Luxford Date: Fri, 11 Aug 2017 15:29:46 -0500 Subject: [PATCH 17/29] Added ability to set a custom collider radius for virtual hands --- Assets/NewtonVR/NVRVirtualHand.cs | 6 +++++- Assets/NewtonVR/NVRVirtualInputDevice.cs | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Assets/NewtonVR/NVRVirtualHand.cs b/Assets/NewtonVR/NVRVirtualHand.cs index 9a982c2e..e6f76f2d 100644 --- a/Assets/NewtonVR/NVRVirtualHand.cs +++ b/Assets/NewtonVR/NVRVirtualHand.cs @@ -12,6 +12,8 @@ public enum Handedness } public Handedness Hand; + + public float radius = 0.5f; void Start () { @@ -45,7 +47,9 @@ public override void PreInitialize(NVRPlayer player) } } - InputDevice = this.gameObject.AddComponent (); + var virtualInputDevice = this.gameObject.AddComponent (); + virtualInputDevice.radius = radius; + InputDevice = virtualInputDevice; InputDevice.Initialize (this); InitializeRenderModel(); diff --git a/Assets/NewtonVR/NVRVirtualInputDevice.cs b/Assets/NewtonVR/NVRVirtualInputDevice.cs index c670b3d3..4389e1d5 100644 --- a/Assets/NewtonVR/NVRVirtualInputDevice.cs +++ b/Assets/NewtonVR/NVRVirtualInputDevice.cs @@ -12,9 +12,11 @@ public class NVRVirtualInputDevice : NVRInputDevice { private GameObject RenderModel; + public float radius = 0.5f; + public override void Initialize(NVRHand hand) { - base.Initialize(hand); + base.Initialize(hand); } public override float GetAxis1D(NVRButtons button) @@ -141,7 +143,7 @@ public override Collider[] SetupDefaultColliders() SphereCollider Collider = RenderModel.AddComponent(); Collider.isTrigger = true; - Collider.radius = 0.5f; + Collider.radius = radius; Colliders = new Collider[] { Collider }; From 9056e14216b4f2d5dc78d9b7aecfcbad446883c6 Mon Sep 17 00:00:00 2001 From: John Luxford Date: Mon, 11 Sep 2017 15:33:38 -0500 Subject: [PATCH 18/29] Added NVRSnappingInteractableItem for items that should snap to a grid and to degrees --- .../NewtonVR/NVRSnappingInteractableItem.cs | 88 +++++++++++++++++++ .../NVRSnappingInteractableItem.cs.meta | 12 +++ 2 files changed, 100 insertions(+) create mode 100644 Assets/NewtonVR/NVRSnappingInteractableItem.cs create mode 100644 Assets/NewtonVR/NVRSnappingInteractableItem.cs.meta diff --git a/Assets/NewtonVR/NVRSnappingInteractableItem.cs b/Assets/NewtonVR/NVRSnappingInteractableItem.cs new file mode 100644 index 00000000..ebec1e6f --- /dev/null +++ b/Assets/NewtonVR/NVRSnappingInteractableItem.cs @@ -0,0 +1,88 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace NewtonVR { + + public class NVRSnappingInteractableItem : NVRInteractableItem { + public float snapToMeters = 0.05f; + public float snapToDegrees = 45f; + + private bool snap = false; + + protected override void UpdateVelocities () { + foreach (var hand in AttachedHands) { + if (hand.UseButtonDown) { + snap = !snap; + break; + } + } + + if (!snap) { + base.UpdateVelocities (); + return; + } + + Vector3 targetItemPosition; + Quaternion targetItemRotation; + + Vector3 targetHandPosition; + Quaternion targetHandRotation; + + GetTargetValues (out targetHandPosition, out targetHandRotation, out targetItemPosition, out targetItemRotation); + + float velocityMagic = VelocityMagic / (Time.deltaTime / NVRPlayer.NewtonVRExpectedDeltaTime); + float angularVelocityMagic = AngularVelocityMagic / (Time.deltaTime / NVRPlayer.NewtonVRExpectedDeltaTime); + + Vector3 positionDelta; + Quaternion rotationDelta; + + float angle; + Vector3 axis; + + // Snap to nearest meters + targetHandPosition.x = Mathf.Round (targetHandPosition.x / snapToMeters) * snapToMeters; + targetHandPosition.y = Mathf.Round (targetHandPosition.y / snapToMeters) * snapToMeters; + targetHandPosition.z = Mathf.Round (targetHandPosition.z / snapToMeters) * snapToMeters; + + positionDelta = (targetHandPosition - targetItemPosition); + + // Snap to nearest degrees + var rounded = targetHandRotation.eulerAngles; + rounded.x = Mathf.Round (rounded.x / snapToDegrees) * snapToDegrees; + rounded.y = Mathf.Round (rounded.y / snapToDegrees) * snapToDegrees; + rounded.z = Mathf.Round (rounded.z / snapToDegrees) * snapToDegrees; + targetHandRotation.eulerAngles = rounded; + + rotationDelta = targetHandRotation * Quaternion.Inverse (targetItemRotation); + + Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.deltaTime; + if (float.IsNaN (velocityTarget.x) == false) { + this.Rigidbody.velocity = Vector3.MoveTowards (this.Rigidbody.velocity, velocityTarget, MaxVelocityChange); + } + + rotationDelta.ToAngleAxis (out angle, out axis); + + if (angle > 180) + angle -= 360; + + if (angle != 0) { + Vector3 angularTarget = angle * axis; + if (float.IsNaN (angularTarget.x) == false) { + angularTarget = (angularTarget * angularVelocityMagic) * Time.deltaTime; + this.Rigidbody.angularVelocity = Vector3.MoveTowards (this.Rigidbody.angularVelocity, angularTarget, MaxAngularVelocityChange); + } + } + + if (VelocityHistory != null) { + CurrentVelocityHistoryStep++; + if (CurrentVelocityHistoryStep >= VelocityHistory.Length) { + CurrentVelocityHistoryStep = 0; + } + + VelocityHistory[CurrentVelocityHistoryStep] = this.Rigidbody.velocity; + AngularVelocityHistory[CurrentVelocityHistoryStep] = this.Rigidbody.angularVelocity; + } + } + } +} \ No newline at end of file diff --git a/Assets/NewtonVR/NVRSnappingInteractableItem.cs.meta b/Assets/NewtonVR/NVRSnappingInteractableItem.cs.meta new file mode 100644 index 00000000..397f9ee7 --- /dev/null +++ b/Assets/NewtonVR/NVRSnappingInteractableItem.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ac411f032831fc84aa17b9aa14dff341 +timeCreated: 1505161948 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 1fbc9ce1bc1e3dfa0da9865ee476e575577abdaa Mon Sep 17 00:00:00 2001 From: John Luxford Date: Tue, 12 Sep 2017 13:22:41 -0500 Subject: [PATCH 19/29] Added weights to make snapping more smooth Compares the last snapped position and rotation and the current one and applies a small weight before rounding so you need to move slightly past 50% before it will snap to the next position or rotation. This way, it doesn't snap back and forth at the 50% points between snapped positions. --- .../NewtonVR/NVRSnappingInteractableItem.cs | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/Assets/NewtonVR/NVRSnappingInteractableItem.cs b/Assets/NewtonVR/NVRSnappingInteractableItem.cs index ebec1e6f..537ec6a2 100644 --- a/Assets/NewtonVR/NVRSnappingInteractableItem.cs +++ b/Assets/NewtonVR/NVRSnappingInteractableItem.cs @@ -9,6 +9,46 @@ public class NVRSnappingInteractableItem : NVRInteractableItem { public float snapToDegrees = 45f; private bool snap = false; + private bool set = false; + private Vector3 lastSnappedPosition; + private Vector3 lastSnappedRotation; + + private Vector3 SnapPosition (Vector3 pos) { + if (set) { + var weighted = snapToMeters / 5f; + pos.x = (pos.x >= lastSnappedPosition.x) ? pos.x -= weighted : pos.x += weighted; + pos.y = (pos.y >= lastSnappedPosition.y) ? pos.y -= weighted : pos.y += weighted; + pos.z = (pos.z >= lastSnappedPosition.z) ? pos.z -= weighted : pos.z += weighted; + } + + pos.x = Mathf.Round (pos.x / snapToMeters) * snapToMeters; + pos.y = Mathf.Round (pos.y / snapToMeters) * snapToMeters; + pos.z = Mathf.Round (pos.z / snapToMeters) * snapToMeters; + + lastSnappedPosition = pos; + set = true; + return pos; + } + + private Quaternion SnapRotation (Quaternion rot) { + var rounded = rot.eulerAngles; + + if (set) { + var weighted = snapToDegrees / 10f; + rounded.x = (rounded.x >= lastSnappedRotation.x) ? rounded.x -= weighted : rounded.x += weighted; + rounded.y = (rounded.y >= lastSnappedRotation.y) ? rounded.y -= weighted : rounded.y += weighted; + rounded.z = (rounded.z >= lastSnappedRotation.z) ? rounded.z -= weighted : rounded.z += weighted; + } + + rounded.x = Mathf.Round (rounded.x / snapToDegrees) * snapToDegrees; + rounded.y = Mathf.Round (rounded.y / snapToDegrees) * snapToDegrees; + rounded.z = Mathf.Round (rounded.z / snapToDegrees) * snapToDegrees; + rot.eulerAngles = rounded; + + lastSnappedRotation = rounded; + //set = true; + return rot; + } protected override void UpdateVelocities () { foreach (var hand in AttachedHands) { @@ -41,18 +81,12 @@ protected override void UpdateVelocities () { Vector3 axis; // Snap to nearest meters - targetHandPosition.x = Mathf.Round (targetHandPosition.x / snapToMeters) * snapToMeters; - targetHandPosition.y = Mathf.Round (targetHandPosition.y / snapToMeters) * snapToMeters; - targetHandPosition.z = Mathf.Round (targetHandPosition.z / snapToMeters) * snapToMeters; + targetHandPosition = SnapPosition (targetHandPosition); positionDelta = (targetHandPosition - targetItemPosition); // Snap to nearest degrees - var rounded = targetHandRotation.eulerAngles; - rounded.x = Mathf.Round (rounded.x / snapToDegrees) * snapToDegrees; - rounded.y = Mathf.Round (rounded.y / snapToDegrees) * snapToDegrees; - rounded.z = Mathf.Round (rounded.z / snapToDegrees) * snapToDegrees; - targetHandRotation.eulerAngles = rounded; + targetHandRotation = SnapRotation (targetHandRotation); rotationDelta = targetHandRotation * Quaternion.Inverse (targetItemRotation); From d45a5b2de444635d31838397fb19664860f79cfc Mon Sep 17 00:00:00 2001 From: John Luxford Date: Tue, 12 Sep 2017 16:21:24 -0500 Subject: [PATCH 20/29] Reset snapping state on each interaction --- Assets/NewtonVR/NVRSnappingInteractableItem.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/NewtonVR/NVRSnappingInteractableItem.cs b/Assets/NewtonVR/NVRSnappingInteractableItem.cs index 537ec6a2..540a8812 100644 --- a/Assets/NewtonVR/NVRSnappingInteractableItem.cs +++ b/Assets/NewtonVR/NVRSnappingInteractableItem.cs @@ -118,5 +118,10 @@ protected override void UpdateVelocities () { AngularVelocityHistory[CurrentVelocityHistoryStep] = this.Rigidbody.angularVelocity; } } + + public override void BeginInteraction (NVRHand hand) { + snap = false; + base.BeginInteraction (hand); + } } } \ No newline at end of file From 7f72934f2ab5078de06a8b747c5fba0523190576 Mon Sep 17 00:00:00 2001 From: Johnny Broadway Date: Tue, 19 Sep 2017 09:33:26 -0500 Subject: [PATCH 21/29] Decreased the size of the collider on Oculus Touch controllers --- Assets/NewtonVR/Oculus/NVROculusInputDevice.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs b/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs index 9595fc47..c2cf5663 100644 --- a/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs +++ b/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs @@ -272,7 +272,7 @@ public override Collider[] SetupDefaultColliders() SphereCollider OculusCollider = RenderModel.AddComponent(); OculusCollider.isTrigger = true; - OculusCollider.radius = 0.15f; + OculusCollider.radius = 0.05f; Colliders = new Collider[] { OculusCollider }; From 7ec0b918575a67bca2416601095f9c60d303dd4a Mon Sep 17 00:00:00 2001 From: morgash1989 Date: Tue, 29 Aug 2017 11:29:00 +0200 Subject: [PATCH 22/29] add missing button added line : ButtonMapping.Add (NVRButtons.ApplicationMenu, OVRInput.Button.Start); To get the button working on the left controller, The sibling button on the right controller is reserved and trigger oculus menu. --- Assets/NewtonVR/Oculus/NVROculusInputDevice.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs b/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs index 9595fc47..5a8bec0a 100644 --- a/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs +++ b/Assets/NewtonVR/Oculus/NVROculusInputDevice.cs @@ -52,7 +52,8 @@ protected virtual void SetupButtonMapping() ButtonMapping.Add(NVRButtons.Trigger, OVRInput.Button.PrimaryIndexTrigger); ButtonMapping.Add(NVRButtons.Grip, OVRInput.Button.PrimaryHandTrigger); ButtonMapping.Add(NVRButtons.System, OVRInput.Button.Back); - + ButtonMapping.Add(NVRButtons.ApplicationMenu, OVRInput.Button.Start); + TouchMapping.Add(NVRButtons.A, OVRInput.Touch.One); TouchMapping.Add(NVRButtons.B, OVRInput.Touch.Two); TouchMapping.Add(NVRButtons.X, OVRInput.Touch.One); From 35bad7e5be6912c38a5c3db2a0fac5a23b0a41c0 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 10 Oct 2017 15:56:02 -0500 Subject: [PATCH 23/29] Won't pick up disabled objects. --- Assets/NewtonVR/NVRHand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index 8e519ca1..293e4ba5 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -603,6 +603,9 @@ protected bool PickupClosest() { if (hovering.Key == null) continue; + + if (!hovering.Key.gameObject.activeInHierarchy) + continue; float distance = Vector3.Distance(collider.transform.position, hovering.Key.transform.position); if (distance < closestDistance) From 1a1d84c23fe71592bcec7c23a6bac44ee880596b Mon Sep 17 00:00:00 2001 From: John Luxford Date: Thu, 19 Oct 2017 12:50:47 -0500 Subject: [PATCH 24/29] Formatting fix --- Assets/NewtonVR/NVRHand.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index 293e4ba5..74791d90 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -604,8 +604,8 @@ protected bool PickupClosest() if (hovering.Key == null) continue; - if (!hovering.Key.gameObject.activeInHierarchy) - continue; + if (!hovering.Key.gameObject.activeInHierarchy) + continue; float distance = Vector3.Distance(collider.transform.position, hovering.Key.transform.position); if (distance < closestDistance) @@ -625,7 +625,7 @@ protected bool PickupClosest() { return false; } - } + } protected bool PickupByName(string withName) { @@ -655,7 +655,7 @@ protected bool PickupByName(string withName) { return false; } - } + } protected virtual void OnTriggerEnter(Collider collider) { @@ -740,7 +740,7 @@ private void SetVisibility(VisibilityLevel visibility) for (int index = 0; index < GhostRenderers.Length; index++) { GhostRenderers[index].enabled = false; - } + } } } From 32fa7c688cb1fc2caaad3bbf894b9ea4cccb23b4 Mon Sep 17 00:00:00 2001 From: Cameron Penner Date: Thu, 19 Oct 2017 13:13:40 -0500 Subject: [PATCH 25/29] Update project to Unity 2017 --- Assets/NewtonVR/NVRPlayer.cs | 4 +- ProjectSettings/ProjectSettings.asset | 501 +++++++++++++-------- ProjectSettings/ProjectVersion.txt | 3 +- ProjectSettings/UnityAdsSettings.asset | 11 - ProjectSettings/UnityConnectSettings.asset | 20 + UnityPackageManager/manifest.json | 4 + 6 files changed, 346 insertions(+), 197 deletions(-) delete mode 100644 ProjectSettings/UnityAdsSettings.asset create mode 100644 UnityPackageManager/manifest.json diff --git a/Assets/NewtonVR/NVRPlayer.cs b/Assets/NewtonVR/NVRPlayer.cs index ec60cc22..26b1e6b5 100644 --- a/Assets/NewtonVR/NVRPlayer.cs +++ b/Assets/NewtonVR/NVRPlayer.cs @@ -233,9 +233,9 @@ private NVRSDKIntegrations DetermineCurrentIntegration(bool logOutput = true) NVRSDKIntegrations currentIntegration = NVRSDKIntegrations.None; string resultLog = "[NewtonVR] Version : " + NewtonVRVersion + ". "; - if (VRDevice.isPresent == true) + if (UnityEngine.XR.XRDevice.isPresent == true) { - resultLog += "Found VRDevice: " + VRDevice.model + ". "; + resultLog += "Found VRDevice: " + UnityEngine.XR.XRDevice.model + ". "; #if !NVR_Oculus && !NVR_SteamVR string warning = "Neither SteamVR or Oculus SDK is enabled in the NVRPlayer. Please check the \"Enable SteamVR\" or \"Enable Oculus SDK\" checkbox in the NVRPlayer script in the NVRPlayer GameObject."; diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 4ab5a7c6..e8b26732 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,9 +3,10 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 13 productGUID: e9ed52372c08aa34999d9d2e74c31cbf AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -14,21 +15,43 @@ PlayerSettings: productName: NewtonVR defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} - m_SplashScreenStyle: 0 + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} m_ShowUnitySplashScreen: 0 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1024 defaultScreenHeight: 768 defaultScreenWidthWeb: 960 defaultScreenHeightWeb: 600 - m_RenderingPath: 1 - m_MobileRenderingPath: 1 + m_StereoRenderingPath: 1 m_ActiveColorSpace: 1 m_MTRendering: 1 - m_MobileMTRendering: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 + tizenShowActivityIndicatorOnLoading: -1 iosAppInBackgroundBehavior: 0 displayResolutionDialog: 2 iosAllowHTTPDownload: 1 @@ -39,18 +62,22 @@ PlayerSettings: useOSAutorotation: 1 use32BitDisplayBuffer: 1 disableDepthAndStencilBuffers: 0 + androidBlitType: 0 defaultIsFullScreen: 0 defaultIsNativeResolution: 1 + macRetinaSupport: 1 runInBackground: 1 captureSingleScreen: 0 - Override IPod Music: 0 + muteOtherAudioSources: 0 Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 submitAnalytics: 1 usePlayerLog: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 resizableWindow: 1 useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games gpuSkinning: 1 graphicsJobs: 1 xboxPIXTextureCapture: 0 @@ -60,6 +87,7 @@ PlayerSettings: xboxEnableFitness: 0 visibleInBackground: 1 allowFullscreenSwitch: 1 + graphicsJobMode: 0 macFullscreenMode: 2 d3d9FullscreenMode: 1 d3d11FullscreenMode: 1 @@ -67,15 +95,16 @@ PlayerSettings: xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 n3dsDisableStereoscopicView: 0 n3dsEnableSharedListOpt: 1 n3dsEnableVSync: 0 - uiUse16BitDepthBuffer: 0 ignoreAlphaClear: 0 xboxOneResolution: 0 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 - ps3SplashScreen: {fileID: 0} + xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 videoMemoryForVertexBuffers: 0 psp2PowerMode: 0 psp2AcquireBGM: 1 @@ -94,36 +123,60 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleIdentifier: com.oculus.UnitySample bundleVersion: 1.0 preloadedAssets: [] - metroEnableIndependentInputSource: 0 + metroInputSource: 0 + m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 - singlePassStereoRendering: 1 + xboxOneEnable7thCore: 0 + vrSettings: + cardboard: + depthFormat: 0 + enableTransitionView: 0 + daydream: + depthFormat: 0 + useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + hololens: + depthFormat: 1 protectGraphicsMemory: 0 + useHDRDisplay: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 0 + resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: + Android: com.oculus.UnitySample + Standalone: unity.Tomorrow Today Labs.NewtonVR + Tizen: com.oculus.UnitySample + iOS: com.oculus.UnitySample + tvOS: com.oculus.UnitySample + buildNumber: + iOS: 0 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 9 + AndroidMinSdkVersion: 16 + AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: - apiCompatibilityLevel: 2 stripEngineCode: 1 iPhoneStrippingLevel: 0 iPhoneScriptCallOptimization: 0 - iPhoneBuildNumber: 0 ForceInternetPermission: 0 ForceSDCardPermission: 0 CreateWallpaper: 0 APKExpansionFiles: 0 - preloadShaders: 0 + keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 VertexChannelCompressionMask: serializedVersion: 2 m_Bits: 238 iPhoneSdkVersion: 988 - iPhoneTargetOSVersion: 22 + iOSTargetOSVersionString: 7.0 tvOSSdkVersion: 0 - tvOSTargetOSVersion: 900 tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 9.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 @@ -144,6 +197,7 @@ PlayerSettings: tvOSSmallIconLayers: [] tvOSLargeIconLayers: [] tvOSTopShelfImageLayers: [] + tvOSTopShelfImageWideLayers: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -163,7 +217,15 @@ PlayerSettings: iOSLaunchScreeniPadCustomXibPath: iOSDeviceRequirements: [] iOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 1 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 1 appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + appleEnableAutomaticSigning: 0 AndroidTargetDevice: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} @@ -171,7 +233,9 @@ PlayerSettings: AndroidKeyaliasName: AndroidTVCompatibility: 1 AndroidIsGame: 1 + AndroidEnableTango: 0 androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 m_AndroidBanners: - width: 320 height: 180 @@ -185,10 +249,72 @@ PlayerSettings: m_Icon: {fileID: 0} m_Width: 128 m_Height: 128 + m_Kind: 0 m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: [] - webPlayerTemplate: APPLICATION:Default + m_BuildTargetVRSettings: + - m_BuildTarget: Android + m_Enabled: 0 + m_Devices: + - Oculus + - m_BuildTarget: Metro + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: N3DS + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: PS3 + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: PS4 + m_Enabled: 0 + m_Devices: + - PlayStationVR + - m_BuildTarget: PSM + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: PSP2 + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: SamsungTV + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: Standalone + m_Enabled: 1 + m_Devices: + - Oculus + - OpenVR + - m_BuildTarget: Tizen + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: WebGL + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: WebPlayer + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: WiiU + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: Xbox360 + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: XboxOne + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: iOS + m_Enabled: 0 + m_Devices: [] + - m_BuildTarget: tvOS + m_Enabled: 0 + m_Devices: [] + m_BuildTargetEnableVuforiaSettings: [] + openGLRequireES31: 0 + openGLRequireES31AEP: 0 m_TemplateCustomTags: {} + mobileMTRendering: + iPhone: 1 + tvOS: 1 wiiUTitleID: 0005000011000000 wiiUGroupID: 00010000 wiiUCommonSaveSize: 4096 @@ -207,6 +333,7 @@ PlayerSettings: wiiUGamePadStartupScreen: {fileID: 0} wiiUDrcBufferDisabled: 0 wiiUProfilerLibPath: + playModeTestRunnerEnabled: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -214,34 +341,116 @@ PlayerSettings: cameraUsageDescription: locationUsageDescription: microphoneUsageDescription: - XboxTitleId: - XboxImageXexPath: - XboxSpaPath: - XboxGenerateSpa: 0 - XboxDeployKinectResources: 0 - XboxSplashScreen: {fileID: 0} - xboxEnableSpeech: 0 - xboxAdditionalTitleMemorySize: 0 - xboxDeployKinectHeadOrientation: 0 - xboxDeployKinectHeadPosition: 0 - ps3TitleConfigPath: - ps3DLCConfigPath: - ps3ThumbnailPath: - ps3BackgroundPath: - ps3SoundPath: - ps3NPAgeRating: 12 - ps3TrophyCommId: - ps3NpCommunicationPassphrase: - ps3TrophyPackagePath: - ps3BootCheckMaxSaveGameSizeKB: 128 - ps3TrophyCommSig: - ps3SaveGameSlots: 1 - ps3TrialMode: 0 - ps3VideoMemoryForAudio: 0 - ps3EnableVerboseMemoryStats: 0 - ps3UseSPUForUmbra: 0 - ps3EnableMoveSupport: 1 - ps3DisableDolbyEncoding: 0 + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchTouchScreenUsage: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchDataLossConfirmation: 0 + switchSupportedNpadStyles: 3 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -254,6 +463,7 @@ PlayerSettings: ps4ParamSfxPath: ps4VideoOutPixelFormat: 0 ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 ps4VideoOutReprojectionRate: 120 ps4PronunciationXMLPath: ps4PronunciationSIGPath: @@ -276,15 +486,15 @@ PlayerSettings: ps4ApplicationParam4: 0 ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ - ps4UseDebugIl2cppLibs: 0 ps4pnSessions: 1 ps4pnPresence: 1 ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 - ps4UseResolutionFallback: 0 restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 ps4UseAudio3dBackend: 0 ps4SocialScreenEnabled: 0 @@ -301,6 +511,9 @@ PlayerSettings: ps4attribShareSupport: 0 ps4attribExclusiveVR: 0 ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] monoEnv: psp2Splashimage: {fileID: 0} @@ -349,11 +562,42 @@ PlayerSettings: psp2UseLibLocation: 0 psp2InfoBarOnStartup: 0 psp2InfoBarColor: 0 - psp2UseDebugIl2cppLibs: 0 + psp2ScriptOptimizationLevel: 0 psmSplashimage: {fileID: 0} + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} spritePackerPolicy: + webGLMemorySize: 256 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLDataCaching: 0 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLUseWasm: 0 + webGLCompressionFormat: 1 scriptingDefineSymbols: 1: + platformArchitecture: + iOS: 2 + scriptingBackend: + Android: 0 + Metro: 2 + Standalone: 0 + WP8: 2 + WebGL: 1 + WebPlayer: 0 + iOS: 1 + incrementalIl2cppBuild: + iOS: 0 + additionalIl2CppArgs: + scriptingRuntimeVersion: 0 + apiCompatibilityLevelPerPlatform: {} + m_RenderingPath: 1 + m_MobileRenderingPath: 1 metroPackageName: CocaineMountain metroPackageVersion: metroCertificatePath: @@ -384,7 +628,9 @@ PlayerSettings: tizenSigningProfileName: tizenGPSPermissions: 0 tizenMicrophonePermissions: 0 - tizenMinOSVersion: 0 + tizenDeploymentTarget: + tizenDeploymentTargetType: -1 + tizenMinOSVersion: 1 n3dsUseExtSaveData: 0 n3dsCompressStaticMem: 1 n3dsExtSaveDataNumber: 0x12345 @@ -414,145 +660,36 @@ PlayerSettings: XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} XboxOneIsContentPackage: 0 XboxOneEnableGPUVariability: 0 XboxOneSockets: {} XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 - intPropertyNames: - - Android::ScriptingBackend - - Metro::ScriptingBackend - - Standalone::ScriptingBackend - - WP8::ScriptingBackend - - WebGL::ScriptingBackend - - WebGL::audioCompressionFormat - - WebGL::exceptionSupport - - WebGL::memorySize - - WebPlayer::ScriptingBackend - - iOS::Architecture - - iOS::EnableIncrementalBuildSupportForIl2cpp - - iOS::ScriptingBackend - Android::ScriptingBackend: 0 - Metro::ScriptingBackend: 2 - Standalone::ScriptingBackend: 0 - WP8::ScriptingBackend: 2 - WebGL::ScriptingBackend: 1 - WebGL::audioCompressionFormat: 4 - WebGL::exceptionSupport: 1 - WebGL::memorySize: 256 - WebPlayer::ScriptingBackend: 0 - iOS::Architecture: 2 - iOS::EnableIncrementalBuildSupportForIl2cpp: 0 - iOS::ScriptingBackend: 1 - boolPropertyNames: - - Android::VR::enable - - Metro::VR::enable - - N3DS::VR::enable - - PS3::VR::enable - - PS4::VR::enable - - PSM::VR::enable - - PSP2::VR::enable - - SamsungTV::VR::enable - - Standalone::VR::enable - - Tizen::VR::enable - - WebGL::VR::enable - - WebGL::analyzeBuildSize - - WebGL::dataCaching - - WebGL::useEmbeddedResources - - WebPlayer::VR::enable - - WiiU::VR::enable - - Xbox360::VR::enable - - XboxOne::VR::enable - - XboxOne::enus - - iOS::VR::enable - - tvOS::VR::enable - Android::VR::enable: 0 - Metro::VR::enable: 0 - N3DS::VR::enable: 0 - PS3::VR::enable: 0 - PS4::VR::enable: 0 - PSM::VR::enable: 0 - PSP2::VR::enable: 0 - SamsungTV::VR::enable: 0 - Standalone::VR::enable: 1 - Tizen::VR::enable: 0 - WebGL::VR::enable: 0 - WebGL::analyzeBuildSize: 0 - WebGL::dataCaching: 0 - WebGL::useEmbeddedResources: 0 - WebPlayer::VR::enable: 0 - WiiU::VR::enable: 0 - Xbox360::VR::enable: 0 - XboxOne::VR::enable: 0 - XboxOne::enus: 1 - iOS::VR::enable: 0 - tvOS::VR::enable: 0 - stringPropertyNames: - - Analytics_ServiceEnabled::Analytics_ServiceEnabled - - Build_ServiceEnabled::Build_ServiceEnabled - - Collab_ServiceEnabled::Collab_ServiceEnabled - - ErrorHub_ServiceEnabled::ErrorHub_ServiceEnabled - - Game_Performance_ServiceEnabled::Game_Performance_ServiceEnabled - - Hub_ServiceEnabled::Hub_ServiceEnabled - - Purchasing_ServiceEnabled::Purchasing_ServiceEnabled - - UNet_ServiceEnabled::UNet_ServiceEnabled - - Unity_Ads_ServiceEnabled::Unity_Ads_ServiceEnabled - - WebGL::emscriptenArgs - - WebGL::template - - additionalIl2CppArgs::additionalIl2CppArgs - Analytics_ServiceEnabled::Analytics_ServiceEnabled: False - Build_ServiceEnabled::Build_ServiceEnabled: False - Collab_ServiceEnabled::Collab_ServiceEnabled: False - ErrorHub_ServiceEnabled::ErrorHub_ServiceEnabled: False - Game_Performance_ServiceEnabled::Game_Performance_ServiceEnabled: False - Hub_ServiceEnabled::Hub_ServiceEnabled: False - Purchasing_ServiceEnabled::Purchasing_ServiceEnabled: False - UNet_ServiceEnabled::UNet_ServiceEnabled: False - Unity_Ads_ServiceEnabled::Unity_Ads_ServiceEnabled: False - WebGL::emscriptenArgs: - WebGL::template: APPLICATION:Default - additionalIl2CppArgs::additionalIl2CppArgs: - vectorPropertyNames: - - Android::VR::enabledDevices - - Metro::VR::enabledDevices - - N3DS::VR::enabledDevices - - PS3::VR::enabledDevices - - PS4::VR::enabledDevices - - PSM::VR::enabledDevices - - PSP2::VR::enabledDevices - - SamsungTV::VR::enabledDevices - - Standalone::VR::enabledDevices - - Tizen::VR::enabledDevices - - WebGL::VR::enabledDevices - - WebPlayer::VR::enabledDevices - - WiiU::VR::enabledDevices - - Xbox360::VR::enabledDevices - - XboxOne::VR::enabledDevices - - iOS::VR::enabledDevices - - tvOS::VR::enabledDevices - Android::VR::enabledDevices: - - Oculus - Metro::VR::enabledDevices: [] - N3DS::VR::enabledDevices: [] - PS3::VR::enabledDevices: [] - PS4::VR::enabledDevices: - - PlayStationVR - PSM::VR::enabledDevices: [] - PSP2::VR::enabledDevices: [] - SamsungTV::VR::enabledDevices: [] - Standalone::VR::enabledDevices: - - Oculus - - OpenVR - Tizen::VR::enabledDevices: [] - WebGL::VR::enabledDevices: [] - WebPlayer::VR::enabledDevices: [] - WiiU::VR::enabledDevices: [] - Xbox360::VR::enabledDevices: [] - XboxOne::VR::enabledDevices: [] - iOS::VR::enabledDevices: [] - tvOS::VR::enabledDevices: [] + xboxOneScriptCompiler: 0 + vrEditorSettings: + daydream: + daydreamIconForeground: {fileID: 0} + daydreamIconBackground: {fileID: 0} + cloudServicesEnabled: + Analytics: 0 + Build: 0 + Collab: 0 + ErrorHub: 0 + Game_Performance: 0 + Hub: 0 + Purchasing: 0 + UNet: 0 + Unity_Ads: 0 + facebookSdkVersion: 7.9.4 + apiCompatibilityLevel: 2 cloudProjectId: projectName: organizationId: cloudEnabled: 0 + enableNativePlatformBackendsForNewInputSystem: 0 + disableOldInputManagerSupport: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index ae41cb69..7a6fffb8 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1 @@ -m_EditorVersion: 5.4.2f2 -m_StandardAssetsVersion: 0 +m_EditorVersion: 2017.2.0f3 diff --git a/ProjectSettings/UnityAdsSettings.asset b/ProjectSettings/UnityAdsSettings.asset deleted file mode 100644 index 224050ce..00000000 --- a/ProjectSettings/UnityAdsSettings.asset +++ /dev/null @@ -1,11 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!292 &1 -UnityAdsSettings: - m_ObjectHideFlags: 0 - m_Enabled: 0 - m_InitializeOnStartup: 1 - m_TestMode: 0 - m_EnabledPlatforms: 4294967295 - m_IosGameId: - m_AndroidGameId: diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset index 9b7a5783..3da14d5b 100644 --- a/ProjectSettings/UnityConnectSettings.asset +++ b/ProjectSettings/UnityConnectSettings.asset @@ -3,6 +3,16 @@ --- !u!310 &1 UnityConnectSettings: m_ObjectHideFlags: 0 + m_Enabled: 0 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate + m_Enabled: 0 + m_CaptureEditorExceptions: 1 UnityPurchasingSettings: m_Enabled: 0 m_TestMode: 0 @@ -12,3 +22,13 @@ UnityConnectSettings: m_TestMode: 0 m_TestEventUrl: m_TestConfigUrl: + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 diff --git a/UnityPackageManager/manifest.json b/UnityPackageManager/manifest.json new file mode 100644 index 00000000..526aca60 --- /dev/null +++ b/UnityPackageManager/manifest.json @@ -0,0 +1,4 @@ +{ + "dependencies": { + } +} From ff3dadfed354e6ea3c9cecdd2b3ec2093215f9a5 Mon Sep 17 00:00:00 2001 From: Cameron Penner Date: Thu, 19 Oct 2017 13:12:51 -0500 Subject: [PATCH 26/29] NVRInteractableItemSnappable allows items to snap to things --- .../NewtonVR/NVRInteractableItemSnappable.cs | 153 ++++++++++++++++++ .../NVRInteractableItemSnappable.cs.meta | 13 ++ Assets/NewtonVR/Snappable.meta | 10 ++ Assets/NewtonVR/Snappable/NVRAlignment.cs | 37 +++++ .../NewtonVR/Snappable/NVRAlignment.cs.meta | 12 ++ Assets/NewtonVR/Snappable/NVRSnappable.cs | 104 ++++++++++++ .../NewtonVR/Snappable/NVRSnappable.cs.meta | 12 ++ 7 files changed, 341 insertions(+) create mode 100644 Assets/NewtonVR/NVRInteractableItemSnappable.cs create mode 100644 Assets/NewtonVR/NVRInteractableItemSnappable.cs.meta create mode 100644 Assets/NewtonVR/Snappable.meta create mode 100644 Assets/NewtonVR/Snappable/NVRAlignment.cs create mode 100644 Assets/NewtonVR/Snappable/NVRAlignment.cs.meta create mode 100644 Assets/NewtonVR/Snappable/NVRSnappable.cs create mode 100644 Assets/NewtonVR/Snappable/NVRSnappable.cs.meta diff --git a/Assets/NewtonVR/NVRInteractableItemSnappable.cs b/Assets/NewtonVR/NVRInteractableItemSnappable.cs new file mode 100644 index 00000000..54c852dc --- /dev/null +++ b/Assets/NewtonVR/NVRInteractableItemSnappable.cs @@ -0,0 +1,153 @@ +using UnityEngine; + +namespace NewtonVR { + + public class NVRInteractableItemSnappable : NVRInteractableItem { + public float snapToMeters = 0.05f; + public float snapToAngle = 15f; + + private bool snap = false; + private bool set = false; + private Vector3 lastSnappedPosition; + private Vector3 lastSnappedRotation; + + [SerializeField] + private positionalSnapping snappingType = positionalSnapping.objects; + + private enum positionalSnapping { + grid, + objects + } + + private NVRSnappable snappable; + + protected override void Start () { + base.Start (); + + if (!(GetComponent ())) { + snappable = gameObject.AddComponent (); + OnBeginInteraction.AddListener (snappable.StartSnapping); + OnEndInteraction.AddListener (snappable.StopSnapping); + } + } + + private Vector3 SnapPosition (Vector3 pos) { + if (set) { + var weighted = snapToMeters / 5f; + pos.x = (pos.x >= lastSnappedPosition.x) ? pos.x -= weighted : pos.x += weighted; + pos.y = (pos.y >= lastSnappedPosition.y) ? pos.y -= weighted : pos.y += weighted; + pos.z = (pos.z >= lastSnappedPosition.z) ? pos.z -= weighted : pos.z += weighted; + } + + pos.x = Mathf.Round (pos.x / snapToMeters) * snapToMeters; + pos.y = Mathf.Round (pos.y / snapToMeters) * snapToMeters; + pos.z = Mathf.Round (pos.z / snapToMeters) * snapToMeters; + + lastSnappedPosition = pos; + set = true; + return pos; + } + + private Quaternion SnapRotation (Quaternion rot) { + var rounded = rot.eulerAngles; + + if (set) { + var weighted = snapToAngle / 10f; + rounded.x = (rounded.x >= lastSnappedRotation.x) ? rounded.x -= weighted : rounded.x += weighted; + rounded.y = (rounded.y >= lastSnappedRotation.y) ? rounded.y -= weighted : rounded.y += weighted; + rounded.z = (rounded.z >= lastSnappedRotation.z) ? rounded.z -= weighted : rounded.z += weighted; + } + + rounded.x = Mathf.Round (rounded.x / snapToAngle) * snapToAngle; + rounded.y = Mathf.Round (rounded.y / snapToAngle) * snapToAngle; + rounded.z = Mathf.Round (rounded.z / snapToAngle) * snapToAngle; + rot.eulerAngles = rounded; + + lastSnappedRotation = rounded; + //set = true; + return rot; + } + + protected override void UpdateVelocities () { + foreach (var hand in AttachedHands) { + if (hand.UseButtonDown) { + snap = !snap; + break; + } + } + + Vector3 targetItemPosition; + Quaternion targetItemRotation; + + Vector3 targetHandPosition; + Quaternion targetHandRotation; + + GetTargetValues (out targetHandPosition, out targetHandRotation, out targetItemPosition, out targetItemRotation); + + float velocityMagic = VelocityMagic / (Time.deltaTime / NVRPlayer.NewtonVRExpectedDeltaTime); + float angularVelocityMagic = AngularVelocityMagic / (Time.deltaTime / NVRPlayer.NewtonVRExpectedDeltaTime); + + // Snap position + if (snappingType == positionalSnapping.objects) { + NVRAlignment targetAlignment = snappable.SnapToNearest (targetHandPosition, .1f); + if (targetAlignment == null) { + return; + } + + targetHandPosition = targetAlignment.position; + + Vector3 positionDelta = (targetHandPosition - targetItemPosition); + Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.deltaTime; + if (float.IsNaN (velocityTarget.x) == false) { + this.Rigidbody.velocity = Vector3.MoveTowards (this.Rigidbody.velocity, velocityTarget, MaxVelocityChange); + } + } + + if (snappingType == positionalSnapping.grid && snap) { + targetHandPosition = SnapPosition (targetHandPosition); + + Vector3 positionDelta = (targetHandPosition - targetItemPosition); + Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.deltaTime; + if (float.IsNaN (velocityTarget.x) == false) { + this.Rigidbody.velocity = Vector3.MoveTowards (this.Rigidbody.velocity, velocityTarget, MaxVelocityChange); + } + } + + // Snap to nearest degrees + if (snap) { + targetHandRotation = SnapRotation (targetHandRotation); + } + Quaternion rotationDelta = targetHandRotation * Quaternion.Inverse (targetItemRotation); + + float angle; + Vector3 axis; + rotationDelta.ToAngleAxis (out angle, out axis); + + if (angle > 180) + angle -= 360; + + if (angle != 0) { + Vector3 angularTarget = angle * axis; + if (float.IsNaN (angularTarget.x) == false) { + angularTarget = (angularTarget * angularVelocityMagic) * Time.deltaTime; + this.Rigidbody.angularVelocity = Vector3.MoveTowards (this.Rigidbody.angularVelocity, angularTarget, MaxAngularVelocityChange); + } + } + + if (VelocityHistory != null) { + CurrentVelocityHistoryStep++; + if (CurrentVelocityHistoryStep >= VelocityHistory.Length) { + CurrentVelocityHistoryStep = 0; + } + + VelocityHistory[CurrentVelocityHistoryStep] = this.Rigidbody.velocity; + AngularVelocityHistory[CurrentVelocityHistoryStep] = this.Rigidbody.angularVelocity; + } + } + + public override void BeginInteraction (NVRHand hand) { + snap = false; + base.BeginInteraction (hand); + } + } +} \ No newline at end of file diff --git a/Assets/NewtonVR/NVRInteractableItemSnappable.cs.meta b/Assets/NewtonVR/NVRInteractableItemSnappable.cs.meta new file mode 100644 index 00000000..304951ea --- /dev/null +++ b/Assets/NewtonVR/NVRInteractableItemSnappable.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 246b26fc3b34a5b45b261916d4a69997 +timeCreated: 1508436376 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/NewtonVR/Snappable.meta b/Assets/NewtonVR/Snappable.meta new file mode 100644 index 00000000..e4eaba77 --- /dev/null +++ b/Assets/NewtonVR/Snappable.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: af5159f5c50305a4690120e6bf031030 +folderAsset: yes +timeCreated: 1508436376 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/NewtonVR/Snappable/NVRAlignment.cs b/Assets/NewtonVR/Snappable/NVRAlignment.cs new file mode 100644 index 00000000..350f5925 --- /dev/null +++ b/Assets/NewtonVR/Snappable/NVRAlignment.cs @@ -0,0 +1,37 @@ +using UnityEngine; + +namespace NewtonVR { + + /// + /// Structure used for passing simple transformation data + /// + public class NVRAlignment { + public Vector3 position; + public Quaternion rotation; + public Vector3 scale; + + public NVRAlignment (Transform transform) { + position = transform.position; + rotation = transform.rotation; + scale = transform.localScale; + } + + public NVRAlignment (Vector3 position, Quaternion rotation, Vector3 scale) { + this.position = position; + this.rotation = rotation; + this.scale = scale; + } + + public float Distance (Transform transform) { + return (Distance (new NVRAlignment (transform.position, transform.rotation, transform.localScale))); + } + + public float Distance (NVRAlignment alignment) { + float distance = 0; + distance += Vector3.Distance (position, alignment.position); + distance += (Quaternion.Angle (rotation, alignment.rotation) / 90) * scale.x; + + return distance; + } + } +} \ No newline at end of file diff --git a/Assets/NewtonVR/Snappable/NVRAlignment.cs.meta b/Assets/NewtonVR/Snappable/NVRAlignment.cs.meta new file mode 100644 index 00000000..607fb45e --- /dev/null +++ b/Assets/NewtonVR/Snappable/NVRAlignment.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5b3ca1b57b53855479a72a83d3144290 +timeCreated: 1507735833 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/NewtonVR/Snappable/NVRSnappable.cs b/Assets/NewtonVR/Snappable/NVRSnappable.cs new file mode 100644 index 00000000..41a6c543 --- /dev/null +++ b/Assets/NewtonVR/Snappable/NVRSnappable.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace NewtonVR { + + public class NVRSnappable : MonoBehaviour { + + /// + /// Shared list of add snappable objects + /// + public static List snappables; + + public Collider[] colliders; + public bool snapping = false; + + /// + /// Clears snappables + /// + public static void ClearSnappables () { + snappables.Clear (); + } + + public void StartSnapping () { + snapping = true; + } + + public void StopSnapping () { + snapping = false; + } + + public NVRAlignment SnapToNearest (Vector3 position, float maxSnapDistance) { + NVRAlignment startingAlignment = new NVRAlignment (position, transform.rotation, transform.localScale); + NVRAlignment newAlignment = startingAlignment; + + float bestAlignmentDistance = float.MaxValue; + + Bounds ourBounds = GetBounds (); + + foreach (NVRSnappable snappable in snappables) { + if (snappable != this) { + Bounds snapToBounds = snappable.GetBounds (); + NVRAlignment alignment = SnapToBounds (position, snapToBounds); + + Vector3 bottomOfSnappable = new Vector3 (position.x, ourBounds.min.y, position.z); + + float alignmentDistance = Mathf.Max (Vector3.Distance (bottomOfSnappable, snapToBounds.ClosestPoint (bottomOfSnappable)), startingAlignment.Distance (alignment)); + + if (alignmentDistance < bestAlignmentDistance && alignmentDistance <= maxSnapDistance) { + newAlignment = alignment; + bestAlignmentDistance = alignmentDistance; + } + } + } + + return newAlignment; + } + + public NVRAlignment SnapToBounds (Vector3 position, Bounds snappingBounds) { + NVRAlignment alignment = new NVRAlignment (position, transform.rotation, transform.localScale); + Bounds mybounds = GetBounds (); + + Vector3 boundsOffset = transform.position - mybounds.center; + alignment.position.y = snappingBounds.center.y + snappingBounds.extents.y + mybounds.extents.y + boundsOffset.y; + return alignment; + } + + public Bounds GetBounds () { //this could be cached for objects that aren't moving + Bounds bounds = colliders[0].bounds; + for (int i = 1; i < colliders.Length; i++) { + bounds.Encapsulate (colliders[1].bounds); + } + return bounds; + } + + private void Start () { + colliders = GetComponentsInChildren (); + } + + private void OnEnable () { + TrackSelf (); + } + + private void OnDestroy () { + ClearSelf (); + } + + private void OnDisable () { + ClearSelf (); + } + + private void TrackSelf () { + if (snappables == null) { + snappables = new List (); + } + + snappables.Add (this); + } + + private void ClearSelf () { + snappables.Remove (this); + StopSnapping (); + } + } +} \ No newline at end of file diff --git a/Assets/NewtonVR/Snappable/NVRSnappable.cs.meta b/Assets/NewtonVR/Snappable/NVRSnappable.cs.meta new file mode 100644 index 00000000..f0e63279 --- /dev/null +++ b/Assets/NewtonVR/Snappable/NVRSnappable.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 90044591e14c9cb428bf74dd2e3ff52b +timeCreated: 1507734616 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From a25397500a6999dee7c05df6251c7cba129299cc Mon Sep 17 00:00:00 2001 From: ryancampfire Date: Tue, 21 Nov 2017 16:09:57 -0600 Subject: [PATCH 27/29] Update NVRInteractable.cs --- Assets/NewtonVR/NVRInteractable.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Assets/NewtonVR/NVRInteractable.cs b/Assets/NewtonVR/NVRInteractable.cs index 38da9aca..3c111293 100644 --- a/Assets/NewtonVR/NVRInteractable.cs +++ b/Assets/NewtonVR/NVRInteractable.cs @@ -170,17 +170,17 @@ public void ForceDetach(NVRHand hand = null) public virtual void EndInteraction(NVRHand hand) { AttachedHands.Remove(hand); - ClosestHeldPoint = Vector3.zero; + if (AttachedHands.Count == 0) { + ClosestHeldPoint = Vector3.zero; - if (EnableKinematicOnDetach == true) - { - Rigidbody.isKinematic = true; - } + if (EnableKinematicOnDetach == true) { + Rigidbody.isKinematic = true; + } - if (EnableGravityOnDetach == true) - { - Rigidbody.useGravity = true; - } + if (EnableGravityOnDetach == true) { + Rigidbody.useGravity = true; + } + } } protected virtual void DroppedBecauseOfDistance(NVRHand hand) From c7e663886ae3e85f9aa259e4992364d4af3eaa4b Mon Sep 17 00:00:00 2001 From: John Luxford Date: Mon, 27 Nov 2017 18:51:08 -0600 Subject: [PATCH 28/29] Checks if CurrentlyHoveringOver is null --- Assets/NewtonVR/NVRHand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index 74791d90..699a3cae 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -662,6 +662,9 @@ protected virtual void OnTriggerEnter(Collider collider) NVRInteractable interactable = NVRInteractables.GetInteractable(collider); if (interactable == null || interactable.enabled == false) return; + + if (CurrentlyHoveringOver == null) + CurrentlyHoveringOver = new Dictionary> (); if (CurrentlyHoveringOver.ContainsKey(interactable) == false) CurrentlyHoveringOver[interactable] = new Dictionary(); From a423cc243776a488a68585e73ddcaab5ca323ef4 Mon Sep 17 00:00:00 2001 From: ryancampfire Date: Wed, 1 Aug 2018 16:19:40 -0500 Subject: [PATCH 29/29] Update NVRHand.cs --- Assets/NewtonVR/NVRHand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/NewtonVR/NVRHand.cs b/Assets/NewtonVR/NVRHand.cs index 699a3cae..ff41ccbe 100644 --- a/Assets/NewtonVR/NVRHand.cs +++ b/Assets/NewtonVR/NVRHand.cs @@ -606,6 +606,11 @@ protected bool PickupClosest() if (!hovering.Key.gameObject.activeInHierarchy) continue; + + var itemColliders = hovering.Value; + + itemColliders.Where (item => !item.Key.gameObject.activeInHierarchy).ToList ().ForEach (item => itemColliders.Remove (item.Key)); + float distance = Vector3.Distance(collider.transform.position, hovering.Key.transform.position); if (distance < closestDistance)