Example #1
0
    public void NDrag(GestureEvent gEvent)
    {
        Debug.Log("NDrag called");

        float multiplier = 1.0f;

        Camera cam = Camera.main;

        float dX = gEvent.Values["drag_dx"]*multiplier;
        float dY = gEvent.Values["drag_dy"]*multiplier*Flipped;

        float screenX = gEvent.X;
        float screenY = cam.GetScreenHeight() - gEvent.Y;
        float screenZ = cam.WorldToScreenPoint(this.transform.position).z;

        Vector3 touchLocation = cam.ScreenToWorldPoint(new Vector3(screenX, screenY, screenZ));

        StartAffineTransform(touchLocation);

            Vector3 previousPosition = Camera.main.WorldToScreenPoint(AffineTransform.transform.position);
            Vector3 nextPosition = new Vector3(dX, dY, 0.0f);
            Vector3 newPosition = previousPosition + nextPosition;
            AffineTransform.transform.position = Camera.main.ScreenToWorldPoint(newPosition);

        EndAffineTransform();
    }
Example #2
0
    public void NScale(GestureEvent gEvent)
    {
        float multiplier = 0.5f;

        float scaleDX = gEvent.Values["scale_dsx"]*multiplier;
        float scaleDY = gEvent.Values["scale_dsy"]*multiplier;

        float cz = Mathf.Clamp(transform.position.z+(scaleDX+scaleDY)*Flipped, 0.1f, 4.5f);

        transform.position = new Vector3(transform.position.x, transform.position.y, cz);
    }
Example #3
0
    public void NScale(GestureEvent gEvent)
    {
        float multiplier = 0.5f;

        float scaleDX = gEvent.Values["scale_dsx"]*multiplier;
        float scaleDY = gEvent.Values["scale_dsy"]*multiplier;

        float cx = Mathf.Clamp(transform.localScale.x+scaleDX, 0.5f, 2f);
        float cy = Mathf.Clamp(transform.localScale.y+scaleDY, 0.5f, 2f);
        float cz = Mathf.Clamp(transform.localScale.z+scaleDY, 0.5f, 2f);

        transform.localScale = new Vector3(cx, cy, cz);
    }
Example #4
0
    public void NDrag(GestureEvent gEvent)
    {
        float multiplier = 0.001f;

        Camera cam = Camera.main;

        float dX = gEvent.Values["drag_dx"]*multiplier;
        float dY = gEvent.Values["drag_dy"]*multiplier;

        Vector3 previousPosition = cam.WorldToScreenPoint(transform.position);
        Vector3 nextPosition = new Vector3(dX, dY, 0.0f);

        Vector3 newPosition = previousPosition + nextPosition;

        float cx = Mathf.Clamp(cam.ScreenToWorldPoint(newPosition).x+dX, -2f, 2f);
        float cy = Mathf.Clamp(cam.ScreenToWorldPoint(newPosition).y+dY, 0f, 2f);

        transform.position = new Vector3(cx,cy,transform.position.z);
    }
Example #5
0
    public void NRotate(GestureEvent gEvent)
    {
        float multiplier = 1.0f;//0.5f;
        Camera cam = Camera.main;

        float dTheta = gEvent.Values["rotate_dtheta"]*multiplier;

        float screenX = gEvent.X;
        float screenY = cam.GetScreenHeight() - gEvent.Y;
        float screenZ = cam.WorldToScreenPoint(this.transform.position).z;

        Vector3 touchLocation = cam.ScreenToWorldPoint(new Vector3(screenX, screenY, screenZ));

        //StartAffineTransform(touchLocation);

            transform.Rotate(0, dTheta, 0);

        //EndAffineTransform();
    }
Example #6
0
    public void NScale(GestureEvent gEvent)
    {
        float multiplier = 1.0f;

        Camera cam = Camera.main;

        float scaleDX = gEvent.Values["scale_dsx"]*multiplier;
        float scaleDY = gEvent.Values["scale_dsy"]*multiplier;

        float screenX = gEvent.X;
        float screenY = cam.GetScreenHeight() - gEvent.Y;
        float screenZ = cam.WorldToScreenPoint(this.transform.position).z;

        Vector3 touchLocation = cam.ScreenToWorldPoint(new Vector3(screenX, screenY, screenZ));

        StartAffineTransform(touchLocation);

            AffineTransform.transform.localScale += new Vector3(scaleDX, scaleDY, scaleDY);

        EndAffineTransform();
    }
 public void NRotate(GestureEvent gEvent)
 {
     float dTheta = gEvent.Values["rotate_dtheta"];
     transform.Rotate(0, 0, dTheta);
     HourHand.transform.Rotate(0, 0, dTheta/12);
 }
Example #8
0
        /// <summary>
        /// Updates the position of the specified <see cref="TouchObject"/> to match that represented by the <see cref="GestureEvent"/> coordinates.
        /// </summary>
        /// <param name="touchObject">The <see cref="TouchObject"/> to rotate.</param>
        /// <param name="gesture">The <see cref="GestureEvent"/> containing the new position data.</param>
        private void HandleRotate(TouchObject touchObject, GestureEvent gesture)
        {
            //Since GestureWorks uses degrees, we have to convert to radians for XNA usage
            float theta = MathHelper.ToRadians(gesture.Values["rotate_dtheta"]);

            //Specify the rotation value of the GO
            touchObject.Rotation += theta;

            //Only update the position if there are two or more TouchPoints associated with the gesture
            if (gesture.N > 1)
            {
                //Rotate the TouchObject around the center of the Gesture, not the object
                touchObject.Position = RotateAboutCenter(touchObject.Position.X, touchObject.Position.Y, gesture.X, gesture.Y, theta);
            }
        }
        /// <summary>
        /// Creates and returns a new, fully initialized instance of a <see cref="GestureEvent"/> based off of the supplied <see cref="GestureEventIntermediate"/>.
        /// </summary>
        /// <param name="intermediateGestureEvent">The raw GestureEvent as received from GestureWorksCore that contains the "non-consumer" fields.</param>
        /// <returns>Consumable <see cref="GestureEvent"/> with only consumer-accessible fields.</returns>
        internal static GestureEvent CreateGestureEvent(GestureEventIntermediate intermediateGestureEvent)
        {
            GestureEvent gestureEvent = new GestureEvent();

            gestureEvent.EventID   = intermediateGestureEvent.GestureEventID;
            gestureEvent.GestureID = intermediateGestureEvent.GestureID;
            gestureEvent.Target    = intermediateGestureEvent.Target;
            gestureEvent.N         = intermediateGestureEvent.N;
            gestureEvent.X         = intermediateGestureEvent.X;
            gestureEvent.Y         = intermediateGestureEvent.Y;
            gestureEvent.Phase     = (GesturePhase)intermediateGestureEvent.Phase;
            gestureEvent.Timestamp = intermediateGestureEvent.Timestamp;
            gestureEvent.Values    = Utils.GetDictFromMapStruct(intermediateGestureEvent.values);

            //Here we populate the LockedPoints field of the new GestureEvent if "hold_in" in exists in the
            //Values property (which indicates this is a hold event). We can then populate the LockedPoints field from the
            //pointer to the integer array by using Marshal.Copy since the number of elements in that unmanaged array will be
            //equal to this hold_in value.
            float numElements = 0;
            gestureEvent.Values.TryGetValue("hold_n", out numElements);

            if (numElements > 0)
            {
                gestureEvent.LockedPoints = new Int32[(int)numElements];

                Marshal.Copy(intermediateGestureEvent.LockedPoints, gestureEvent.LockedPoints, 0, (int)numElements);

            }
            else
            {
                gestureEvent.LockedPoints = new Int32[0];
            }

            return gestureEvent;
        }
Example #10
0
    public void ThreeFingerTilt(GestureEvent gEvent)
    {
        float multiplier = 1.0f;

        Camera cam = Camera.main;

        float tiltDX = gEvent.Values["tilt_dx"]*multiplier;
        float tiltDY = gEvent.Values["tilt_dy"]*multiplier;

        float screenX = gEvent.X;
        float screenY = cam.GetScreenHeight() - gEvent.Y;
        float screenZ = cam.WorldToScreenPoint(this.transform.position).z;

        Vector3 touchLocation = cam.ScreenToWorldPoint(new Vector3(screenX, screenY, screenZ));

        StartAffineTransform(touchLocation);

            AffineTransform.transform.Rotate(Vector3.up * (tiltDX));
            AffineTransform.transform.Rotate(Vector3.right * tiltDY*-1);

        EndAffineTransform();
    }
Example #11
0
    public void ThreeFingerTilt(GestureEvent gEvent)
    {
        Camera cam = Camera.main;

        float tiltDX = gEvent.Values["tilt_dx"];
        float tiltDY = gEvent.Values["tilt_dy"]*-1;

        float screenX = gEvent.X;
        float screenY = cam.GetScreenHeight() - gEvent.Y;
        float screenZ = cam.WorldToScreenPoint(this.transform.position).z;

        Vector3 touchLocation = cam.ScreenToWorldPoint(new Vector3(screenX, screenY, screenZ));

        //StartAffineTransform(touchLocation);

            transform.Rotate(0,0 , tiltDX*Flipped);
            transform.Rotate(tiltDY,0 , 0);

        //EndAffineTransform();
    }
Example #12
0
 public void Tap(GestureEvent gEvent)
 {
     this.audio.Play();
 }