protected void DetectRotation()
        {
            if (LeapHands.IsGrabbing(leapHands.hand))
            {
                return;
            }
            if (leapHands.HasTwoHands())
            {
                return;
            }
            if (isRotated)
            {
                return;
            }

            /// Pitch Block
            if (LeapHands.IsPitchingDown(leapHands.hand))
            {
                GetBlockController().PitchBlock(DirectViaCamera(Vector3.forward));
                isRotated = true;
                return;
            }
            else if (LeapHands.IsPitchingUp(leapHands.hand))
            {
                GetBlockController().PitchBlock(DirectViaCamera(Vector3.back));
                isRotated = true;
                return;
            }

            /// Yaw Block
            if (LeapHands.IsYawingRight(leapHands.hand))
            {
                GetBlockController().YawBlock(Vector3.right);
                isRotated = true;
                return;
            }
            else if (LeapHands.IsYawingLeft(leapHands.hand))
            {
                GetBlockController().YawBlock(Vector3.left);
                isRotated = true;
                return;
            }

            /// Roll Block
            if (LeapHands.IsRollingRight(leapHands.hand))
            {
                GetBlockController().RollBlock(DirectViaCamera(Vector3.right));
                isRotated = true;
                return;
            }
            else if (LeapHands.IsRollingLeft(leapHands.hand))
            {
                GetBlockController().RollBlock(DirectViaCamera(Vector3.left));
                isRotated = true;
                return;
            }
        }
        protected void InitPerFrame()
        {
            if (leapHands == null || leapHands.hand == null)
            {
                return;
            }

            // horizontal hand
            if (LeapHands.IsHorizontal(leapHands.hand))
            {
                isRotated = false;
            }
        }
Beispiel #3
0
    void Start()
    {
        hands = GetComponent <LeapHands>();
        debug = GetComponent <LiveDebug>();

        knobs   = GameObject.Find("interactables").GetComponent <Knobs>();
        letters = GameObject.Find("letters").GetComponent <Letters>();

        debug.Log("knobs and letters: " + knobs + ", " + letters);

        knobArranger = new KnobArranger(letters, knobs);
        knobArranger.Arrange(0f);

        grabStrategy = new GrabStrategy(knobs, knobArranger, debug);

        hands.OnHandUpdate += OnHandUpdate;
    }
        protected void DetectDropMotion()
        {
            if (leapHands.HasTwoHands())
            {
                return;
            }
            if (!LeapHands.IsGrabbing(leapHands.hand))
            {
                return;
            }
            // const float rotateScale = 15;
            //if (!LeapHands.IsHorizontal(leapHands.hand, rotateScale)) return;

            // Drop Block with grabbed hand
            float velocityY = leapHands.hand.PalmVelocity.y;

            if (velocityY < -400)
            {
                GetBlockController().DropBlock();
            }
        }
        protected void DetectMotion()
        {
            if (leapHands.HasTwoHands())
            {
                return;
            }
            if (LeapHands.IsGrabbing(leapHands.hand))
            {
                return;
            }

            // int MOVING_DETECT_RANGE = 60;
            // // move block with opened hand in x-axis
            // float handX = leapHands.hand.PalmPosition.x;
            // if (handX > MOVING_DETECT_RANGE) {
            //  GetBlockController().MoveBlock( DirectViaCamera(Vector3.right) * moveSpeed );
            // } else if (handX < -MOVING_DETECT_RANGE) {
            //  GetBlockController().MoveBlock( DirectViaCamera(Vector3.left) * moveSpeed );
            // }
            //
            // // move block with opened hand in z-axis
            // float handZ = -leapHands.hand.PalmPosition.z;
            // if (handZ > MOVING_DETECT_RANGE) {
            //  GetBlockController().MoveBlock( DirectViaCamera(Vector3.forward) * moveSpeed );
            // } else if (handZ < -MOVING_DETECT_RANGE) {
            //  GetBlockController().MoveBlock( DirectViaCamera(Vector3.back) * moveSpeed );
            // }

            // hand position
            Vector3 handPos = VectorUtil.ToVector3(leapHands.hand.PalmPosition);

            handPos.z *= -1;
            handPos.y  = 0;
            handPos   /= 2;

            GetBlockController().MoveBlockSmoothly(DirectViaCamera(handPos), moveSpeed);
        }
 void Awake()
 {
     leapHands = GameObject.Find("LeapHands").GetComponent<LeapHands>();
 }
Beispiel #7
0
 /// check if the hand is horizontal
 public static bool IsHorizontal(Hand hand)
 {
     return(LeapHands.IsHorizontal(hand, rotateScale));
 }
Beispiel #8
0
 public LeapHand(LeapHands hands, LiveDebug debug)
 {
     this.debug = debug;
     this.hands = hands;
 }
 void Awake()
 {
     leapHands = GameObject.Find("LeapHands").GetComponent <LeapHands>();
 }