////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public LeapInputSide(bool pIsLeft, LeapInputSettings pSettings) {
			IsLeft = pIsLeft;
			vSettings = pSettings;

			vMenu = new LeapInputMenu(IsLeft);
			vCursor = new LeapInputCursor(IsLeft);
		}
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public LeapInputSide(bool pIsLeft, LeapInputSettings pSettings)
        {
            IsLeft    = pIsLeft;
            vSettings = pSettings;

            vMenu   = new LeapInputMenu(IsLeft);
            vCursor = new LeapInputCursor(IsLeft);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public virtual void Awake() {
			vHandControl = gameObject.GetComponent<HandController>();

			if ( vHandControl == null ) {
				throw new Exception("The HovercastLeapInputProvider component must be added to the "+
					"same GameObject that contains the Leap Motion HandController component.");
			}

			vSettings = new LeapInputSettings();
			UpdateSettings();

			vSideL = new LeapInputSide(true, vSettings);
			vSideR = new LeapInputSide(false, vSettings);
		}
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public virtual void Awake()
        {
            vHandControl = gameObject.GetComponent <HandController>();

            if (vHandControl == null)
            {
                throw new Exception("The HovercastLeapInputProvider component must be added to the " +
                                    "same GameObject that contains the Leap Motion HandController component.");
            }

            vSettings = new LeapInputSettings();
            UpdateSettings();

            vSideL = new LeapInputSide(true, vSettings);
            vSideR = new LeapInputSide(false, vSettings);
        }
예제 #5
0
        /*--------------------------------------------------------------------------------------------*/
        internal void Rebuild(Hand pLeapHand, LeapInputSettings pSettings)
        {
            if (pLeapHand == null)
            {
                IsAvailable          = false;
                Position             = Vector3.zero;
                Rotation             = Quaternion.identity;
                Radius               = 0;
                NavigateBackStrength = 0;
                DisplayStrength      = 0;
                return;
            }

            IsAvailable = true;
            Position    = pLeapHand.PalmPosition.ToUnityScaled();
            Rotation    = CalcQuaternion(pLeapHand.Basis);
            Radius      = 0.01f;

            var cursor = new LeapInputCursor(IsLeft);

            foreach (Finger leapFinger in pLeapHand.Fingers)
            {
                if (leapFinger == null || !leapFinger.IsValid)
                {
                    continue;
                }

                cursor.Rebuild(leapFinger);

                Rotation = Quaternion.Slerp(Rotation, cursor.Rotation, 0.1f);
                Radius   = Math.Max(Radius, (cursor.Position - Position).sqrMagnitude);
            }

            Radius = (float)Math.Sqrt(Radius);

            NavigateBackStrength = pLeapHand.GrabStrength / pSettings.NavBackGrabThreshold;
            NavigateBackStrength = Mathf.Clamp(NavigateBackStrength, 0, 1);

            DisplayStrength = Vector3.Dot(pLeapHand.PalmNormal.ToUnity(), pSettings.PalmDirection);
            DisplayStrength = Mathf.Clamp((DisplayStrength - 0.7f) / 0.25f, 0, 1);
        }
		/*--------------------------------------------------------------------------------------------*/
		internal void Rebuild(Hand pLeapHand, LeapInputSettings pSettings) {
			if ( pLeapHand == null ) {
				IsAvailable = false;
				Position = Vector3.zero;
				Rotation = Quaternion.identity;
				Radius = 0;
				NavigateBackStrength = 0;
				DisplayStrength = 0;
				return;
			}

			IsAvailable = true;
			Position = pLeapHand.PalmPosition.ToUnityScaled();
			Rotation = CalcQuaternion(pLeapHand.Basis);
			Radius = 0.01f;

			var cursor = new LeapInputCursor(IsLeft);

			foreach ( Finger leapFinger in pLeapHand.Fingers ) {
				if ( leapFinger == null || !leapFinger.IsValid ) {
					continue;
				}

				cursor.Rebuild(leapFinger);

				Rotation = Quaternion.Slerp(Rotation, cursor.Rotation, 0.1f);
				Radius = Math.Max(Radius, (cursor.Position-Position).sqrMagnitude);
			}

			Radius = (float)Math.Sqrt(Radius);

			NavigateBackStrength = pLeapHand.GrabStrength/pSettings.NavBackGrabThreshold;
			NavigateBackStrength = Mathf.Clamp(NavigateBackStrength, 0, 1);

			DisplayStrength = Vector3.Dot(pLeapHand.PalmNormal.ToUnity(), pSettings.PalmDirection);
			DisplayStrength = Mathf.Clamp((DisplayStrength-0.7f)/0.25f, 0, 1);
		}