// Use this for initialization
    void Start()
    {
        currentState.device        = DeviceState.Disconnected;
        currentState.hand          = HandState.None;
        currentState.leftHandIcon  = HandIconState.None;
        currentState.rightHandIcon = HandIconState.None;

        leapController = FindObjectOfType <LeapController>() as LeapController;

        leapMotionIcon        = GameObject.Find("LeapMotionIcon");
        leapMotionBlackSprite = Resources.Load <Sprite>("leap_motion_black");
        leapMotionGreenSprite = Resources.Load <Sprite>("leap_motion_green");

        leftHandIcon = GameObject.Find("LeftHandIcon");
        leftHandIcon.SetActive(false);

        rightHandIcon = GameObject.Find("RightHandIcon");
        rightHandIcon.SetActive(false);

        leftHandGraySprite  = Resources.Load <Sprite>("left_hand_gray");
        leftHandRedSprite   = Resources.Load <Sprite>("left_hand_red");
        leftHandGreenSprite = Resources.Load <Sprite>("left_hand_green");

        rightHandGraySprite  = Resources.Load <Sprite>("right_hand_gray");
        rightHandRedSprite   = Resources.Load <Sprite>("right_hand_red");
        rightHandGreenSprite = Resources.Load <Sprite>("right_hand_green");

        titleText = GameObject.Find("TitleText").GetComponent <Text>();
        timeText  = GameObject.Find("TimeText").GetComponent <Text>();
    }
 void Awake()
 {
     uiElement      = GetComponent <UIElement>();
     shipController = GetComponent <ShipController>();
     leapController = GetComponent <LeapController>();
     //keyboardController = GetComponent<KeyboardController>();
 }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     gameController  = FindObjectOfType <GameController>();
     leapController  = FindObjectOfType <LeapController>();
     didEnableScale  = false;
     initialDistance = 0.0f;
     initialScale    = Vector3.one;
 }
 public MyLeapListener(LeapController controller)
 {
     myLeapController = controller;
 }
Beispiel #5
0
 void Start()
 {
     leapController = (GameObject.Find("LeapManager")as GameObject).GetComponent(typeof(LeapController)) as LeapController;
 }
Beispiel #6
0
    public void UpdateStroke()
    {
        LeapController leapController = GameObject.Find("Leap").GetComponent <LeapController> ();

        //Indicate whether the left index is viewed and extended
        bool leftSingleCheck = false;

        //Indicate whether the right index is viewed and extended
        bool rightSingleCheck = false;

        //Indicate whether the left index and middle are connected
        bool leftDoubleCheck = false;

        //Indicate whether the right index and middle are connected
        bool rightDoubleCheck = false;

        foreach (LeapHand leapHand in leapController.getHandList())
        {
            Vector3 indexPos  = leapHand.getIndex().getPosition();
            Vector3 middlePos = leapHand.getMiddle().getPosition();

            Vector3 indexSpeed  = leapHand.getIndex().getSpeed();
            Vector3 middleSpeed = leapHand.getMiddle().getSpeed();

            Vector3 doubleFingerPos   = (indexPos + middlePos) / 2;
            Vector3 doubleFingerSpeed = (indexSpeed + middleSpeed) / 2;

            //Check the distance between the index and the middle
            float disDouble = Vector3.Distance(indexPos, middlePos);

            if (leapHand.getHand().IsLeft&& leapHand.getIndex().getFinger().IsExtended)
            {
                if (disDouble > indexMiddleThreshold)
                {
//					Debug.Log ("Left index");

                    //Add the index position to the stroke
                    leftSingleCheck = true;

                    if (leftSingleStroke.getStrokePoints().Count == 0)
                    {
                        leftSingleStroke.setStartTime(Time.time);
                    }

                    leftSingleStroke.getStrokePoints().Add(indexPos);
                    leftSingleStroke.getStrokeSpeeds().Add(indexSpeed);
                }
                else
                {
//					Debug.Log ("Left index middle");

                    //Add the center of the index and the middle to the stroke
                    leftDoubleCheck = true;

                    if (leftDoubleStroke.getStrokePoints().Count == 0)
                    {
                        leftDoubleStroke.setStartTime(Time.time);
                    }

                    leftDoubleStroke.getStrokePoints().Add(doubleFingerPos);
                    leftDoubleStroke.getStrokeSpeeds().Add(doubleFingerSpeed);
                }
            }

            if (leapHand.getHand().IsRight&& leapHand.getIndex().getFinger().IsExtended)
            {
                if (disDouble > indexMiddleThreshold)
                {
//					Debug.Log ("Right index");

                    //Add the index position to the stroke
                    rightSingleCheck = true;

                    if (rightSingleStroke.getStrokePoints().Count == 0)
                    {
                        rightSingleStroke.setStartTime(Time.time);
                    }

                    rightSingleStroke.getStrokePoints().Add(indexPos);
                    rightSingleStroke.getStrokeSpeeds().Add(indexSpeed);
                }
                else
                {
//					Debug.Log ("Right index middle");

                    //Add the center of the index and the middle to the stroke
                    rightDoubleCheck = true;

                    if (rightDoubleStroke.getStrokePoints().Count == 0)
                    {
                        rightDoubleStroke.setStartTime(Time.time);
                    }

                    rightDoubleStroke.getStrokePoints().Add(doubleFingerPos);
                    rightDoubleStroke.getStrokeSpeeds().Add(doubleFingerSpeed);
                }
            }
        }
        if (!leftSingleCheck)
        {
            leftSingleStroke = new Stroke();
            leftSingleStrokeList.Clear();
        }

        if (!rightSingleCheck)
        {
            rightSingleStroke = new Stroke();
            rightSingleStrokeList.Clear();
        }

        if (!leftDoubleCheck)
        {
            leftDoubleStroke = new Stroke();
            leftDoubleStrokeList.Clear();
        }

        if (!rightDoubleCheck)
        {
            rightDoubleStroke = new Stroke();
            rightDoubleStrokeList.Clear();
        }

        //Draw stroke
        DrawStroke();
    }
Beispiel #7
0
    void Start ()
    {
        image = GetComponent<Image>();
        leapController = GameObject.FindObjectOfType<LeapController>();
	}