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 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); }