Ejemplo n.º 1
0
 /// <summary>
 /// On Hold start event for attaching objects if it's the correct option
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="eventArgs"></param>
 protected void OnHoldStarted(InteractionManager.InteractionEventArgs eventArgs)
 {
     if (m_InteractionType == AttachInteractionEnum.PressAndHold && m_InteractingFocus == null)
     {
         AttachObject(eventArgs.Focuser);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// On Completed hold
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="eventArgs"></param>
 protected void OnHoldCompleted(InteractionManager.InteractionEventArgs eventArgs)
 {
     if (m_InteractionType == AttachInteractionEnum.PressAndHold && m_bAttached && m_InteractingFocus == eventArgs.Focuser)
     {
         DetachObject();
     }
 }
        protected override void OnManipulationUpdated(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
        {
            base.OnManipulationUpdated(obj, eventArgs);

            if (!acceptInput)
            {
                return;
            }

            if (target == null)
            {
                return;
            }

            if (!manipulatingNow)
            {
                return;
            }

            Vector3 eventPos = eventArgs.Position;

            // Transform the direction if necessary
            if (eventArgs.IsPosRelative)
            {
                eventPos = Veil.Instance.HeadTransform.TransformDirection(eventPos);
            }
            // See how much our position has changed
            navigateVelocity = lastNavigatePos - eventPos;
            lastNavigatePos  = eventPos;
            smoothVelocity   = Vector3.Lerp(smoothVelocity, navigateVelocity, 0.5f);
        }
 private void OnHoldCompleted(InteractionManager.InteractionEventArgs e)
 {
     if (m_Targted)
     {
         this.Triggered();
         m_Targted = false;
     }
 }
 private void OnHoldCompleted(InteractionManager.InteractionEventArgs e)
 {
     if (m_Targted)
     {
         StartCoroutine(StartTransition());
         m_Targted = false;
     }
 }
Ejemplo n.º 6
0
        protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
        {
            if (Time.time < lastTimeTapped + coolDownTime)
            {
                return;
            }

            lastTimeTapped = Time.time;

            base.OnTapped(obj, eventArgs);

            switch (obj.name)
            {
            case "Remove":
                // Destroy the target object
                GameObject.Destroy(boundingBox.Target);
                // Set our bounding box to null so we'll disappear
                boundingBox = null;
                break;

            case "Adjust":
                // Make the bounding box active so users can manipulate it
                State = AppBarStateEnum.Manipulation;
                break;

            case "Hide":
                // Make the bounding box inactive and invisible
                State = AppBarStateEnum.Hidden;
                break;

            case "Show":
                State = AppBarStateEnum.Default;
                break;

            case "Done":
                State = AppBarStateEnum.Default;
                break;

            // Customization
            case "Ready":
                Debug.Log("Ready");
                Destroy(this.gameObject);
                Destroy(GameObject.Find("Drag"));
                Destroy(GameObject.Find("BoundingBoxShell(Clone)"));
                Destroy(GameObject.Find("BoundingBoxTransformHelper"));
                game.ChangeStateTo(Game.State.SearchingCube);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// On double tapped if double tapped interaction type then attach or detach
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="eventArgs"></param>
 protected void OnDoubleTapped(InteractionManager.InteractionEventArgs eventArgs)
 {
     if (m_InteractionType == AttachInteractionEnum.DoubleTapped)
     {
         if (m_bAttached && m_InteractingFocus == eventArgs.Focuser)
         {
             m_InteractingFocus.ReleaseFocus();
             DetachObject();
         }
         else if (m_InteractingFocus == null)
         {
             eventArgs.Focuser.LockFocus();
             AttachObject(eventArgs.Focuser);
         }
     }
 }
Ejemplo n.º 8
0
        protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
        {
            if (Time.time < lastTimeTapped + coolDownTime)
            {
                return;
            }

            lastTimeTapped = Time.time;
            lastFocusExit  = Time.time;

            base.OnTapped(obj, eventArgs);

            switch (obj.name)
            {
            case "Remove":
                // Destroy the target object
                GameObject.Destroy(boundingBox.Target);
                // Set our bounding box to null so we'll disappear
                boundingBox = null;
                break;

            case "Adjust":
                // Make the bounding box active so users can manipulate it
                State = AppBarStateEnum.Manipulation;
                break;

            case "Hide":
                // Make the bounding box inactive and invisible
                State = AppBarStateEnum.Hidden;
                break;

            case "Show":
                State = AppBarStateEnum.Default;
                break;

            case "Done":
                State = AppBarStateEnum.Default;
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Chooses our manipulation handle so we know how to interpret future input events
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="eventArgs"></param>
        protected override void OnManipulationStarted(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
        {
            base.OnManipulationStarted(obj, eventArgs);
            TryToSetHandle(obj, eventArgs.Position, eventArgs.Focuser);

            // Compute a vector as a reference for determining the amount of rotation.
            // In order to operate with the vertical and horizontal movements of the hand,
            // the reference vector is assumed to be the coordinate axis of the BoundingBox projected on the screen
            if (CurrentOperation == OperationEnum.RotateX || CurrentOperation == OperationEnum.RotateY || CurrentOperation == OperationEnum.RotateZ)
            {
                Vector3 axisVect = Vector3.ProjectOnPlane(
                    CurrentOperation == OperationEnum.RotateX ? transform.right :
                    CurrentOperation == OperationEnum.RotateY ? transform.up :
                    transform.forward,
                    Camera.main.transform.forward);

                orthogonalVect = Vector3.Cross(Camera.main.transform.forward, axisVect);
                orthogonalVect.Normalize();
            }
        }
Ejemplo n.º 10
0
        private void OnHoldStarted(InteractionManager.InteractionEventArgs e)
        {
            // Get the location of the cursor on the sphere collider
            AFocuser focuser = e.Focuser;

            RaycastHit hitInfo;

            UnityEngine.Ray gazeRay = new UnityEngine.Ray(focuser.TargetOrigin, focuser.TargetDirection);

            if (Physics.Raycast(gazeRay, out hitInfo))
            {
                handPos = InputSources.Instance.hands.GetWorldPosition(0);

                Vector3 hitPos     = hitInfo.point;
                Vector3 handOffset = Vector3.Normalize(hitPos - transform.position);
                float   val        = 1.0f / sensitivity;

                handOffset.Scale(new Vector3(val, val, val));
                handPivot = handPos + handOffset;
            }

            bSelected = true;
        }
 private void OnHoldStarted(InteractionManager.InteractionEventArgs e)
 {
     m_DisplacementCheckCoroutine = StartCoroutine(DisplacementCheck());
 }
 protected override void OnManipulationCompleted(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
 {
     ManipulatingNow = false;
     base.OnManipulationCompleted(obj, eventArgs);
 }
 private void OnHoldCanceled(InteractionManager.InteractionEventArgs e)
 {
     bSelected = false;
 }
 private void OnHoldStarted(InteractionManager.InteractionEventArgs e)
 {
     handOrigin = InputSources.Instance.hands.GetWorldPosition(InputSourceHands.FirstHandIndex);
     bSelected  = true;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Chooses our manipulation handle so we know how to interpret future input events
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="eventArgs"></param>
 protected override void OnManipulationStarted(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
 {
     base.OnManipulationStarted(obj, eventArgs);
     TryToSetHandle(obj, eventArgs.Position, eventArgs.Focuser);
 }
        //protected override void OnSelectStarted(GameObject selectedObject)
        //{
        //    StartCoroutine("StartTransition");
        //}

        protected void OnHoldStarted(InteractionManager.InteractionEventArgs args)
        {
            m_Targted = true;
        }
 private void OnTap(InteractionManager.InteractionEventArgs e)
 {
     StartCoroutine(StartTransition());
 }
 private void OnHoldCanceled(InteractionManager.InteractionEventArgs e)
 {
     StopCoroutine(m_DisplacementCheckCoroutine);
 }
 protected void OnTapped(InteractionManager.InteractionEventArgs args)
 {
     this.Triggered();
 }