Exemple #1
0
        private void Awake()
        {
            Instances.Add(this);

            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = this.GetComponentInChildren <NVRHead>();
            }
            Head.Initialize();

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();

            DetermineCurrentIntegration();

            if (CurrentIntegrationType == NVRSDKIntegrations.Oculus)
            {
                Integration = this.gameObject.AddComponent <NVROculusIntegration>();
            }
            else if (CurrentIntegrationType == NVRSDKIntegrations.SteamVR)
            {
                Integration = this.gameObject.AddComponent <NVRSteamVRIntegration>();
            }
            else if (CurrentIntegrationType == NVRSDKIntegrations.FallbackNonVR)
            {
                Debug.LogError("[NewtonVR] Fallback non-vr not yet implemented.");
                return;
            }
            else
            {
                Debug.LogError("[NewtonVR] Critical Error: Oculus / SteamVR not setup properly or no headset found.");
                return;
            }


            if (Hands == null || Hands.Length == 0)
            {
                Hands = new NVRHand[] { LeftHand, RightHand };

                for (int index = 0; index < Hands.Length; index++)
                {
                    Hands[index].PreInitialize(this);
                }
            }

            Integration.Initialize(this);

            if (OnInitialized != null)
            {
                OnInitialized.Invoke();
            }
        }
Exemple #2
0
        //

        private void Awake()
        {
            if (AutoSetFixedDeltaTime)
            {
                Time.fixedDeltaTime = NewtonVRExpectedDeltaTime;
            }

            Instances.Add(this);

            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = this.GetComponentInChildren <NVRHead>();
            }
            Head.Initialize();

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();

            SetupIntegration();

            if (Hands == null || Hands.Length == 0)
            {
                Hands = new NVRHand[] { LeftHand, RightHand };

                for (int index = 0; index < Hands.Length; index++)
                {
                    Hands[index].PreInitialize(this);
                }
            }

            if (Integration != null)
            {
                Integration.Initialize(this);
            }

            if (OnInitialized != null)
            {
                OnInitialized.Invoke();
            }

            //cdr
            //adjust rift player starting height
            if ("Oculus" == VRSettings.loadedDeviceName)
            {
                transform.position = new Vector3(transform.position.x, transform.position.y + yAdjustRift, transform.position.z);
            }
            //
        }
Exemple #3
0
        private void Awake()
        {
            if (HumanNaviConfig.Instance.configInfo.photonServerMachine || !this.GetComponent <PhotonView>().IsMine)
            {
                this.enabled = false;
                return;
            }

            if (AutoSetFixedDeltaTime)
            {
                Time.fixedDeltaTime = NewtonVRExpectedDeltaTime;
            }

            Instances.Add(this);

            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = this.GetComponentInChildren <NVRHead>();
            }
            Head.Initialize();

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();

            SetupIntegration();

            if (Hands == null || Hands.Length == 0)
            {
                Hands = new NVRHand[] { LeftHand, RightHand };

                for (int index = 0; index < Hands.Length; index++)
                {
                    Hands[index].PreInitialize(this);
                }
            }

            if (Integration != null)
            {
                Integration.Initialize(this);
            }

            if (OnInitialized != null)
            {
                OnInitialized.Invoke();
            }
        }
Exemple #4
0
        private void Awake()
        {
            Instance = this;
            NVRInteractables.Initialize();

            if (Head == null)
            {
                this.GetComponentInChildren <NVRHead>();
            }
            if (Hands == null || Hands.Length == 0)
            {
                this.GetComponentsInChildren <NVRHand>();
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();
        }
Exemple #5
0
        private 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 <Collider, float>();
            }

            if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false)
            {
                CurrentlyHoveringOver[interactable][collider] = Time.time;
            }
        }
Exemple #6
0
        protected virtual void OnTriggerStay(Collider collider)
        {
            NVRInteractable interactable = NVRInteractables.GetInteractable(collider);

            if (interactable == null || interactable.enabled == false || collider.tag.Equals("Ungrabbable"))
            {
                return;
            }

            if (CurrentlyHoveringOver.ContainsKey(interactable) == false)
            {
                CurrentlyHoveringOver[interactable] = new Dictionary <Collider, float>();
            }

            if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false)
            {
                CurrentlyHoveringOver[interactable][collider] = Time.time;
            }
        }
Exemple #7
0
        private void Awake()
        {
            Instances.Add(this);

            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = this.GetComponentInChildren <NVRHead>();
            }
            Head.Initialize();

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();

            SetupIntegration();

            if (Hands == null || Hands.Length == 0)
            {
                Hands = new NVRHand[] { LeftHand, RightHand };

                for (int index = 0; index < Hands.Length; index++)
                {
                    Hands[index].PreInitialize(this);
                }
            }

            if (Integration != null)
            {
                Integration.Initialize(this);
            }

            if (OnInitialized != null)
            {
                OnInitialized.Invoke();
            }
        }
Exemple #8
0
        private 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);
                    }
                }
            }
        }
Exemple #9
0
        protected virtual void OnTriggerExit(Collider collider)
        {
            NVRInteractable interactable = NVRInteractables.GetInteractable(collider);

            if (interactable == null || collider.tag.Equals("Ungrabbable"))
            {
                return;
            }

            if (CurrentlyHoveringOver.ContainsKey(interactable))
            {
                if (CurrentlyHoveringOver[interactable].ContainsKey(collider))
                {
                    CurrentlyHoveringOver[interactable].Remove(collider);
                    if (CurrentlyHoveringOver[interactable].Count == 0)
                    {
                        CurrentlyHoveringOver.Remove(interactable);
                    }
                }
            }
        }
Exemple #10
0
        private void Awake()
        {
            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = this.GetComponentInChildren <NVRHead>();
            }

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            if (Hands == null || Hands.Length == 0)
            {
                Hands = new NVRHand[] { LeftHand, RightHand };
            }

            LeftHand.player  = this;
            RightHand.player = this;
        }
Exemple #11
0
        private void Awake()
        {
            Instance = this;
            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = this.GetComponentInChildren <NVRHead>();
            }

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            if (Hands == null || Hands.Length == 0)
            {
                Hands = new NVRHand[] { LeftHand, RightHand };
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();
        }
 public virtual void RefreshColliders()
 {
     NVRInteractables.Deregister(this);
     Colliders = this.GetComponentsInChildren <Collider>();
     NVRInteractables.Register(this, Colliders);
 }
Exemple #13
0
        private void Awake()
        {
            if (AutoSetFixedDeltaTime)
            {
                Time.fixedDeltaTime = NewtonVRExpectedDeltaTime;
            }

            Instances.Add(this);

            NVRInteractables.Initialize();

            if (Head == null)
            {
                Head = GetComponentInChildren <NVRHead>();
            }
            Head.Initialize();

            if (LeftHand == null || RightHand == null)
            {
                Debug.LogError("[FATAL ERROR] Please set the left and right hand to a nvrhands.");
            }

            ColliderToHandMapping = new Dictionary <Collider, NVRHand>();

            SetupIntegration();

            if (Hands.Count == 0)
            {
                Hands = new List <NVRHand> {
                    LeftHand, RightHand
                };

                foreach (NVRHand hand in Hands)
                {
                    hand.PreInitialize(this);
                    NVRInputDevice dev = null;
                    switch (CurrentIntegrationType)
                    {
                    case NVRSDKIntegrations.Oculus:
                        dev = hand.gameObject.AddComponent <NVROculusInputDevice>();
                        break;

                    case NVRSDKIntegrations.SteamVR:
                        dev = hand.gameObject.AddComponent <NVRSteamVRInputDevice>();
                        break;

                    case NVRSDKIntegrations.FallbackNonVR:
                    case NVRSDKIntegrations.None:
                    default:
                        Debug.LogError("[NewtonVR] Error: NVRPlayer.CurrentIntegration not setup.");
                        break;
                    }

                    dev.Initialize(hand);
                    hand.SetupInputDevice(dev);
                }
            }

            if (Integration != null)
            {
                Integration.Initialize(this);
            }

            if (OnInitialized != null)
            {
                OnInitialized.Invoke();
            }
        }
Exemple #14
0
 public void Deregister()
 {
     NVRInteractables.Deregister(this);
 }
Exemple #15
0
 public virtual void UpdateColliders()
 {
     Colliders = this.GetComponentsInChildren <Collider>();
     NVRInteractables.Register(this, Colliders);
 }
Exemple #16
0
 protected virtual void OnDestroy()
 {
     ForceDetach();
     NVRInteractables.Deregister(this);
 }
Exemple #17
0
 protected virtual void Start()
 {
     NVRInteractables.Register(this, Colliders);
 }
Exemple #18
0
 public virtual void UpdateColliders(Collider[] newColliders)
 {
     Colliders = newColliders;
     NVRInteractables.Register(this, Colliders);
 }