Example #1
0
            /// @endcond

            private void CastRayFromGaze()
            {
                //Vector2 headPose = NormalizedCartesianToSpherical(GvrViewer.Instance.HeadPose.Orientation*Vector3.forward);

                if (pointerData == null)
                {
                    pointerData            = new VRPointerEventData(eventSystem);
                    pointerData.controller = m_Controller;
                    //lastHeadPose=headPose;
                }

                // Cast a ray into the scene
                pointerData.Reset();
                pointerData.position = new Vector2(hotspot.x * Screen.width, hotspot.y * Screen.height);
                //eventSystem.RaycastAll(pointerData,m_RaycastResultCache);
                VRRaycaster caster = VRRaycaster.TryRaycastAll(m_ControllerName, pointerData, m_RaycastResultCache);

                pointerData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
                m_RaycastResultCache.Clear();
                //
                if (caster != null)
                {
                    RaycastResult rr = pointerData.pointerCurrentRaycast;
                    if (rr.gameObject == null)
                    {
                        caster.SetLaserLineDepth(100f);
                    }
                    else
                    {
                        caster.SetLaserLineDepth(rr.distance);
                    }
                }
                //pointerData.delta=headPose-lastHeadPose;
                //lastHeadPose=headPose;
            }
 public void DeactivateModule()
 {
     DisableGazePointer();
     //base.DeactivateModule();
     if (pointerData != null)
     {
         HandlePendingClick();
         main.HandlePointerExitAndEnter(pointerData, null);
         pointerData = null;
     }
     eventSystem.SetSelectedGameObject(null, main.GetBaseEventData());
 }