Beispiel #1
0
        /*void processPinch ()
         * {
         *      if (Input.touchCount == 2)
         *      {
         *              //Store inputs
         *              Touch fing1 = Input.GetTouch (0);
         *              Touch fing2 = Input.GetTouch (1);
         *
         *              if (fing1.phase == TouchPhase.Moved || fing2.phase == TouchPhase.Moved)	//If either finger has moved since the last frame
         *              {
         *                      //Get previous positions
         *                      Vector2 fing1Prev = fing1.position - fing1.deltaPosition;
         *                      Vector2 fing2Prev = fing2.position - fing2.deltaPosition;
         *
         *                      //Find vector magnitude between touches in each frame
         *                      float prevTouchDeltaMag = (fing1Prev - fing2Prev).magnitude;
         *                      float touchDeltaMag = (fing1.position - fing2.position).magnitude;
         *
         *                      //Find difference in distances
         *                      float deltaDistance = prevTouchDeltaMag - touchDeltaMag;
         *
         *                      //Create appropriate vector
         *                      float scaleChange = ((this.transform.localScale.x - deltaDistance) * zoomSpeed);
         *
         *                      //Scale object
         *                      this.transform.localScale = new Vector3 (scaleChange, scaleChange, scaleChange);
         *              }
         *      }
         * }*/

        /*void processDrag()
         * {
         *      if (Input.touchCount == 1)
         *      {
         *              //Store input
         *              Touch fing = Input.GetTouch (0);
         *
         *              if(fing.phase == TouchPhase.Moved)	//If the finger has moved since the last frame
         *              {
         *                      //Find the amount the finger has moved, and apply a rotation to this gameobject based on that amount
         *                      Vector2 fingMove = fing.deltaPosition;
         *                      //float deltaX = (fingMove.y * moveSpeed * -1);
         *                      float deltaY = (fingMove.x * moveSpeed * -1);
         *
         *                      this.transform.Rotate (deltaX, deltaY, 0);
         *              }
         *      }
         * }*/

        void processTap()
        {
            if (Input.touchCount == 1)
            {
                //Store input
                Touch fing = Input.GetTouch(0);

                if (fing.phase == TouchPhase.Began)                                  //If the finger started touching the screen this frame
                {
                    if (!EventSystem.current.IsPointerOverGameObject(fing.fingerId)) //And the finger on the screen is not currently touching an object
                    {
                        startPos = fing.position;                                    //Get the screen position of the finger when it hit the screen
                    }
                }
                else if (fing.phase == TouchPhase.Ended)                              //If the finger stopped touching the screen this frame
                {
                    endPos = fing.position;                                           //Get the screen position of the finger when it left the screen

                    if (Mathf.Abs(endPos.magnitude - startPos.magnitude) < roughDiff) //Calculate how far away the finger was from its starting point when it left the screen, and if it left the screen roughly where it started, it's a tap
                    {
                        if (_kudanTracker.CurrentTrackingMethod == _markerlessTracking)
                        {
                            Vector3    position;
                            Quaternion orientation;

                            _kudanTracker.FloorPlaceGetPose(out position, out orientation);
                            _kudanTracker.ArbiTrackStart(position, orientation);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void PlaceClick()
        {
            Vector3    position;
            Quaternion orientation;

            _kudantracker.FloorPlaceGetPose(out position, out orientation);
            _kudantracker.ArbiTrackStart(position, orientation);
        }
        void processTap()
        {
            if (!_kudanTracker.ArbiTrackIsTracking())
            {
                // from the floor placer.
                Vector3    floorPosition;                                                 // The current position in 3D space of the floor
                Quaternion floorOrientation;                                              // The current orientation of the floor in 3D space, relative to the device

                _kudanTracker.FloorPlaceGetPose(out floorPosition, out floorOrientation); // Gets the position and orientation of the floor and assigns the referenced Vector3 and Quaternion those values
                _kudanTracker.ArbiTrackStart(floorPosition, floorOrientation);            // Starts markerless tracking based upon the given floor position and orientations
            }
            else
            {
                _kudanTracker.ArbiTrackStop();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Checks for tap controls.
        /// </summary>
        void processTap()
        {
            if (Input.touchCount == 1)
            {
                //Store input
                Touch fing = Input.GetTouch(0);

                if (fing.phase == TouchPhase.Began)                                  //If the finger started touching the screen this frame
                {
                    if (!EventSystem.current.IsPointerOverGameObject(fing.fingerId)) //And the finger on the screen is not currently touching an object
                    {
                        startPos = fing.position;                                    //Get the screen position of the finger when it hit the screen
                    }
                }
                else if (fing.phase == TouchPhase.Ended)                              //If the finger stopped touching the screen this frame
                {
                    endPos = fing.position;                                           //Get the screen position of the finger when it left the screen

                    if (Mathf.Abs(endPos.magnitude - startPos.magnitude) < roughDiff) //Calculate how far away the finger was from its starting point when it left the screen
                    {
                        tap = true;                                                   //And if it left the screen roughly where it started, it's a tap
                    }
                }
            }

            if (tap && !tracker.ArbiTrackIsTracking())
            {
                Vector3    floorPos;
                Quaternion floorRot;

                tracker.FloorPlaceGetPose(out floorPos, out floorRot);
                tracker.ArbiTrackStart(floorPos, floorRot);

                tap = false;
            }
        }