public static NRPointerRaycaster GetRaycaster(ControllerHandEnum handEnum) { if (raycasterDict == null) { raycasterDict = new Dictionary <ControllerAnchorEnum, NRPointerRaycaster>(); NRPointerRaycaster _raycaster = NRInput.AnchorsHelper.GetAnchor(ControllerAnchorEnum.GazePoseTrackerAnchor).GetComponentInChildren <NRPointerRaycaster>(true); raycasterDict.Add(ControllerAnchorEnum.GazePoseTrackerAnchor, _raycaster); _raycaster = NRInput.AnchorsHelper.GetAnchor(ControllerAnchorEnum.RightLaserAnchor).GetComponentInChildren <NRPointerRaycaster>(true); raycasterDict.Add(ControllerAnchorEnum.RightLaserAnchor, _raycaster); _raycaster = NRInput.AnchorsHelper.GetAnchor(ControllerAnchorEnum.LeftLaserAnchor).GetComponentInChildren <NRPointerRaycaster>(true); raycasterDict.Add(ControllerAnchorEnum.LeftLaserAnchor, _raycaster); } NRPointerRaycaster raycaster = null; if (NRInput.RaycastMode == RaycastModeEnum.Gaze) { raycasterDict.TryGetValue(ControllerAnchorEnum.GazePoseTrackerAnchor, out raycaster); } else if (NRInput.DomainHand == ControllerHandEnum.Right) { raycasterDict.TryGetValue(ControllerAnchorEnum.RightLaserAnchor, out raycaster); } else if (NRInput.DomainHand == ControllerHandEnum.Left) { raycasterDict.TryGetValue(ControllerAnchorEnum.LeftLaserAnchor, out raycaster); } return(raycaster); }
protected void OnSelect() { dragRaycaster = interactiveItem.SelectingRaycaster; if (dragRaycaster) { flexLaserVisual = dragRaycaster.gameObject.GetComponentInChildren <FlexLaserVisual>(true); } if (flexLaserVisual) { flexLaserVisual.SelectedObject = transform; } originPos = transform.position; originRot = transform.rotation; originScale = transform.localScale; if (rigidbodyCmp == null) { InitRigidbody(); } initialControllerOrientation = ControlTransform.rotation; // Store inverse initial controller quaternion, for performance. inverseControllerOrientation = Quaternion.Inverse(initialControllerOrientation); // Perform the transformation relative to control. Vector3 vectorToObject = transform.position - ControlPosition; float d = vectorToObject.magnitude; controlTransformPosition = transform.position; objectStartRotation = transform.rotation; verifyRotation = Quaternion.identity; // If the distance vector cannot be normalized, use the look vector. if (d > NORMALIZATION_EPSILON) { normalizedForward = vectorToObject / d; } else { d = 0; normalizedForward = ControlForward; } // Reset distance interpolation values to current values. targetControlZDistance = controlZDistance = d; // Reset orientation interpolation values to 0. targetOrientationDelta = orientationDelta = Quaternion.identity; // Get the up vector for the object. Vector3 objectUp = transform.TransformDirection(Vector3.up); // Get the dot product of the object up vector and the world up vector. float dotUp = Vector3.Dot(objectUp, Vector3.up); // Mark whether the object is upside down or rightside up. objectInverted = dotUp < 0; lastStateChangeFrame = Time.frameCount; }
public void Selected(NRPointerRaycaster raycaster) { SelectingRaycaster = raycaster; if (OnSelected != null) { OnSelected(); } NRInputModule.Instance.enabled = false; NRInput.ReticleVisualActive = false; forceDeselectOnce = false; }
public void Deselected() { if (IsBeingSelected) { if (OnDeselected != null) { OnDeselected(); } m_DeselectFrame = Time.frameCount; SelectingRaycaster = null; NRInputModule.Instance.enabled = true; NRInput.ReticleVisualActive = true; } }
public static GameObject GetCurrentRaycastTarget() { NRPointerRaycaster raycaster = GetRaycaster(NRInput.DomainHand); if (raycaster == null) { return(null); } var result = raycaster.FirstRaycastResult(); if (!result.isValid) { return(null); } return(result.gameObject); }