예제 #1
0
    void OnGUI()
    {
        GUI.backgroundColor = new Color(0, 0, 0, 0);

        if (Input.GetAxis("Mouse X") != 0)
        {
            prevTimeButtonAppeared = DateTime.Now;
        }

        if (DateTime.Now.Subtract(prevTimeButtonAppeared).TotalMilliseconds < 1500)
        {
            if (GUI.Button(new Rect(Screen.width * 0.9f, Screen.height * 0.05f, 128, 128), enableMouse ? enableMouseButtonTexute : disableMouseButtonTexute))
            {
                enableMouse = !enableMouse;
                InterpolateKeys.OnEnableMouse(enableMouse);
            }
        }
        if (showQuitButton)
        {
            if (GUI.Button(new Rect((Screen.width) / 2 - 64, 3 * (Screen.height) / 4, 128, 128), quitButton))
            {
                Application.Quit();
            }
        }

        Event e = Event.current;

        if (e.isKey)
        {
            CameraTargetPos = Camera.main.transform.position;
            if (e.keyCode == KeyCode.RightArrow)
            {
                AssemblyCSharp.Tools.ShiftView(AssemblyCSharp.Tools.Direction.Right);
            }
            else if (e.keyCode == KeyCode.LeftArrow)
            {
                AssemblyCSharp.Tools.ShiftView(AssemblyCSharp.Tools.Direction.Left);
            }
            //Debug.Log ("###############################################");
            //Debug.Log ("Move HandController to: " + HandController.HandTargetPosition);
            //Debug.Log ("Move Camera to: " + Camera.main.transform.position);
            //Debug.Log ("###############################################/n/n");
        }
    }
예제 #2
0
    private void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                  HandList leap_hands,
                                  HandModel left_model, HandModel right_model)
    {
        List <int> ids_to_check = new List <int>(all_hands.Keys);

        // Go through all the active hands and update them.
        int num_hands = leap_hands.Count;

        if (num_hands == 0)
        {
            RightMostHandPosition = LeftMostHandPosition = 0;
        }
        for (int h = 0; h < num_hands; ++h)
        {
            Hand leap_hand = leap_hands[h];

            HandModel model = leap_hand.IsLeft? left_model : right_model;

            // Only create or update if the hand is enabled.
            if (model != null)
            {
                ids_to_check.Remove(leap_hand.Id);

                // Create the hand and initialized it if it doesn't exist yet.
                if (!all_hands.ContainsKey(leap_hand.Id))
                {
                    HandModel new_hand = CreateHand(model);
                    new_hand.SetLeapHand(leap_hand);
                    new_hand.SetController(this);

                    // Set scaling based on reference hand.
                    float hand_scale = leap_hand.PalmWidth / MODEL_PALM_WIDTH;
                    new_hand.transform.localScale = hand_scale * transform.localScale;

                    new_hand.InitHand();
                    new_hand.UpdateHand();
                    all_hands[leap_hand.Id] = new_hand;
                    model = new_hand;
                }
                else
                {
                    // Make sure we update the Leap Hand reference.
                    HandModel hand_model = all_hands[leap_hand.Id];
                    hand_model.SetLeapHand(leap_hand);

                    // Set scaling based on reference hand.
                    float hand_scale = leap_hand.PalmWidth / MODEL_PALM_WIDTH;
                    hand_model.transform.localScale = hand_scale * transform.localScale;

                    hand_model.UpdateHand();
                    model = hand_model;
                }
                if (h == 0)
                {
                    RightMostHandPosition = LeftMostHandPosition = model.GetPalmPosition().x;
                }
                RightMostHandPosition = model.GetPalmPosition().x > RightMostHandPosition?model.GetPalmPosition().x : RightMostHandPosition;

                LeftMostHandPosition = model.GetPalmPosition().x < LeftMostHandPosition?model.GetPalmPosition().x : LeftMostHandPosition;
            }
        }
        InterpolateKeys.UpdateHands(num_hands);
        // Destroy all hands with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i)
        {
            Destroy(all_hands[ids_to_check[i]].gameObject);
            all_hands.Remove(ids_to_check[i]);
        }

        if (DateTime.Now.Subtract(prevLogTime).TotalSeconds >= 1)
        {
            prevLogTime = DateTime.Now;
            if (LeftMostHandPosition < LeftBorder && RightMostHandPosition > RightBorder)
            {
                return;
            }

            Main.CameraTargetPos = Camera.main.transform.position;

            if (LeftMostHandPosition < LeftBorder)
            {
                Tools.ShiftView(Tools.Direction.Left);
            }
            if (RightMostHandPosition > RightBorder)
            {
                Tools.ShiftView(Tools.Direction.Right);
            }
        }
    }