示例#1
0
    void Update()
    {
        //Gets the current gesture
        System.Collections.Generic.List <Leap.Hand> hands = gestureRecogniser.getFrameHands();
        string current_gesture = gestureRecogniser.Recognise(hands[0]);

        if (current_gesture == "UI" && created_ui == null)
        {
            createUI(hands[0], (hands[0].PalmPosition.ToVector3() - hands[1].PalmPosition.ToVector3()).normalized);
        }
        else if (current_gesture == "UI")
        {
            created_ui.transform.rotation = camera_.transform.rotation;
            created_ui.transform.LookAt(camera_);
            if (initialAlpha < 1.0f)
            {
                increaseMyAlpha();
            }
        }
        else
        {
            DestroyImmediate(created_ui);
            created_ui = null;
        }
    }
示例#2
0
    void flight()
    {
        System.Collections.Generic.List <Leap.Hand> hands = gestureRecogniser.getFrameHands();
        if (hands.Count == 2)
        {
            string    current_gesture = gestureRecogniser.Recognise(hands[1]);
            string    for_ui          = gestureRecogniser.Recognise(hands[0]);
            string    slow_down       = gestureRecogniser.Recognise(hands [1]);
            Leap.Hand r_hand          = hands [1];

            if (for_ui == "FIST")
            {
                topSpeed     = nitrosSpeed;
                acceleration = .6f;
            }
            else if (for_ui == "UI")
            {
                damper       = .6f;
                acceleration = .07f;
            }
            else
            {
                topSpeed = currentMaxSpeed;
                damper   = .99f;
            }
            if (r_hand != null)
            {
                float RollAngle  = r_hand.PalmNormal.Roll;
                float PitchAngle = r_hand.Direction.Pitch;
                Tilt(RollAngle);
                Rise(PitchAngle);
            }
            if (speed <= topSpeed)
            {
                speed        += acceleration;
                acceleration += .008f;
            }
        }

        vehicle.transform.position += velocity;
        speed   *= damper;
        velocity = (velocity.normalized * 2.0f + (vehicle.transform.forward)).normalized * speed * Time.deltaTime;


        speedometer.fillAmount = speed / topSpeed;
    }
 // Update is called once per frame
 void Update()
 {
     System.Collections.Generic.List <Leap.Hand> hands = gestureRecogniser.getFrameHands();
     if (hands.Count >= 1)
     {
         string current_gesture = gestureRecogniser.Recognise(hands [0]);
         if (current_gesture == "FIST")
         {
             Firing fire = gun.GetComponent <Firing> ();
             fire.Fire();
         }
     }
 }
示例#4
0
    void Update()
    {
        System.Collections.Generic.List <Leap.Hand> hands = gestureRecogniser.getFrameHands();
        if (hands.Count == 2)
        {
            string    current_gesture = gestureRecogniser.Recognise(hands[1]);
            string    for_ui          = gestureRecogniser.Recognise(hands[0]);
            Leap.Hand r_hand          = hands [1];

            if (for_ui == "FIST")
            {
                topSpeed = nitrosSpeed;
            }
            else
            {
                topSpeed = currentMaxSpeed;
            }
            if (r_hand != null)
            {
                float RollAngle  = r_hand.PalmNormal.Roll;
                float PitchAngle = r_hand.Direction.Pitch;
                Tilt(RollAngle);
                Rise(PitchAngle);
            }

            //Added slipperiness to flight, to make it more natural
            velocity = (velocity.normalized + (vehicle.transform.forward) / (handling * 1.5f)) * speed * Time.deltaTime;
        }

        vehicle.transform.position += velocity;
        speed *= .99f;
        if (speed <= topSpeed)
        {
            Debug.Log("Making it to increase speed");
            speed += acceleration;
        }
    }
示例#5
0
    void ShipControls()
    {
        //Gets The Current Hands In Frame
        System.Collections.Generic.List <Leap.Hand> hands = gestureRecogniser.getFrameHands();
        if (hands.Count == 2)
        {
            //Gets current gestures of each hand
            string    left_hand_gesture = gestureRecogniser.Recognise(hands [0]);
            Leap.Hand r_hand            = hands [1];
            Leap.Hand l_hand            = hands [0];
            //Shoot if right hand is in a fist
            if (left_hand_gesture == "FIST")
            {
                vehicle.transform.FindChild("MyGuns").gameObject.GetComponent <Firing> ().fire = true;
            }

            //If there is a right hand
            if (r_hand != null)
            {
                //Get angles required and pass them into their respective functions
                float RollAngle  = r_hand.PalmNormal.Roll;
                float PitchAngle = r_hand.Direction.Pitch;
                Tilt(RollAngle);
                Rise(PitchAngle);
            }

            //Cap the speed at the top speed
            if (speed <= topSpeed)
            {
                speed        += acceleration;
                acceleration += .001f;
            }


            //Added slipperiness to flight, to make it more natural
            velocity = (velocity.normalized + (vehicle.transform.forward) / (handling * 1.5f)) * speed * Time.deltaTime;
        }
        else
        {
            //Dampen speed and acceleration
            speed        *= .99f;
            acceleration *= .99f;
        }

        //Move vehicle by velocity
        vehicle.transform.position += velocity;
    }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            previousMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (currentPath != null)
            {
                Destroy(currentPath.gameObject);
                Destroy(tempPath.gameObject);
                currentPath = null;
            }
        }

        if (Input.GetMouseButtonUp(0) && drawing)
        {
            StrokePath path       = currentPath.GetStrokePath();
            StrokePath recognised = gesture.Recognise(path);

            // RESULT OF GESTURE RECOGNITION HERE
            // EG create circle/line etc

            drawing = false;


            // draws points to test
            // DRAWS RECOGNISE RESULT
            // Delete section once proper recognition working
            List <Vector2> points = recognised.Points();

            for (int i = 0; i < points.Count; i++)
            {
                points[i] = new Vector2(points[i].x + Screen.width / 2, points[i].y + Screen.height / 2);
            }

            tempPath = Instantiate(drawnPathPrefab, gameObject.transform).GetComponent <DrawnPath>();
            tempPath.Initialize(Camera.main.ScreenToWorldPoint(points[0]), Camera.main.ScreenToWorldPoint(points[1]));

            for (int i = 2; i < points.Count; i++)
            {
                tempPath.AddPoint(Camera.main.ScreenToWorldPoint(points[i]));
            }
        }

        if (Input.GetMouseButton(0))
        {
            Vector2 currentMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            if (Vector2.Distance(previousMousePos, currentMousePos) > mouseMoveThreshold)
            {
                if (!drawing)
                {
                    currentPath = Instantiate(drawnPathPrefab, gameObject.transform).GetComponent <DrawnPath>();
                    currentPath.Initialize(previousMousePos, currentMousePos);
                    drawing          = true;
                    previousMousePos = currentMousePos;
                }
                else
                {
                    currentPath.AddPoint(currentMousePos);
                    previousMousePos = currentMousePos;
                }
            }
        }
        else
        {
            drawing = false;
        }
    }