private Point ProcessHandLocation(Dictionary<JointType, Point> aJoints) { //get normalized hand Point normalizedHandLocation = NormalizeHandPosition(aJoints, this.TrackingLeftHand); //scaled up hand location Point scaledHandLocation = new Point(normalizedHandLocation.X * this.HandCoordRangeX, normalizedHandLocation.Y * this.HandCoordRangeY); Point filteredScaledHandLocation = scaledHandLocation; //check for valid location if (!double.IsNaN(scaledHandLocation.X) && !double.IsNaN(scaledHandLocation.Y)) { //filter filteredScaledHandLocation = _scaledHandLocationFilter.Next(scaledHandLocation); //send event HandLocationEvent movedEvent = new HandLocationEvent(filteredScaledHandLocation); this.NotifyHandLocationListenersOfEvent(movedEvent); } return filteredScaledHandLocation; }
public void InjectScaledHandLocation(Point aLocation) { //filter Point filteredScaledHandLocation = _scaledHandLocationFilter.Next(aLocation); //check for valid location if (!double.IsNaN(filteredScaledHandLocation.X) && !double.IsNaN(filteredScaledHandLocation.Y)) { //send event HandLocationEvent movedEvent = new HandLocationEvent(filteredScaledHandLocation); this.NotifyHandLocationListenersOfEvent(movedEvent); } }
private void NotifyHandLocationListenersOfEvent(HandLocationEvent aEvent) { //notify the system listener of an interaction this._kinectManager.InteractionListener.SystemDidRecieveInteraction(); Point attachPoint = new Point(); bool isAttaching = false; lock (_handLocationListenerLock) { foreach (HandLocationListener currentListener in this._handLocationListeners) { bool result = currentListener.KinectHandManagerDidGetHandLocation(this, aEvent); if (this.ShouldAttachToControls && result) { if (currentListener.HandShouldAttach()) { attachPoint = currentListener.AttachLocation(); isAttaching = true; } } } } if (this.Cursor != null) { Point handPos; if (isAttaching) { handPos = attachPoint; } else { handPos = aEvent.HandPosition; } this.Cursor.SetCursorPosition(handPos); } }
public void InjectNormalizedHandLocation(Point aLocation) { //scaled up hand location Point scaledHandLocation = new Point(aLocation.X * this.HandCoordRangeX, aLocation.Y * this.HandCoordRangeY); //filter Point filteredScaledHandLocation = _scaledHandLocationFilter.Next(scaledHandLocation); //check for valid location if (!double.IsNaN(filteredScaledHandLocation.X) && !double.IsNaN(filteredScaledHandLocation.Y)) { //send event HandLocationEvent movedEvent = new HandLocationEvent(filteredScaledHandLocation); this.NotifyHandLocationListenersOfEvent(movedEvent); } }