private void HandleHandPointerData(long timeStamp, UserInfo userInfo, int userIndex, InteractionHandPointer handPointer) { //var parameters = this.KinectSensor.CoordinateMapper.ColorToDepthRelationalParameters; //byte[] mapper = new byte[parameters.Count]; //parameters.CopyTo(mapper, 0); var interactionData = new InteractionFrameData { TimeStampOfLastUpdate = timeStamp, TrackingId = userInfo.SkeletonTrackingId, PlayerIndex = userIndex, HandType = EnumHelper.ConvertHandType(handPointer.HandType), IsTracked = handPointer.IsTracked, IsActive = handPointer.IsActive, IsInteractive = handPointer.IsInteractive, IsPressed = handPointer.IsPressed, //IsPrimaryHandOfUser = handPointer.IsPrimaryForUser, IsPrimaryHandOfUser = false, IsPrimaryUser = (userInfo.SkeletonTrackingId == this.PrimaryUserTrackingId) && (userInfo.SkeletonTrackingId != KinectPrimaryUserTracker.InvalidUserTrackingId), HandEventType = EnumHelper.ConvertHandEventType(handPointer.HandEventType), X = handPointer.X, Y = handPointer.Y, Z = handPointer.PressExtent }; this.kinectAdapter.HandleHandPointerData(interactionData); }
/// <summary> /// Function that takes the state of the core interaction components /// and translates it to RoutedEvents. Also updates hand pointer states. /// </summary> /// <param name="data">Data directly from the core interaction components</param> public void HandleHandPointerData(InteractionFrameData data) { Debug.Assert(this.IsInInteractionFrame, "Call to HandleHandPointerData made without call to BeginInteractionFrame"); if (this.isClearRequestPending) { // We don't care about new hand pointer data if client requested to clear // all hand pointers while in the middle of interaction frame processing. return; } var id = new Tuple <int, HandType>(data.TrackingId, data.HandType); HandPointer handPointer; if (!this.handPointers.TryGetValue(id, out handPointer)) { handPointer = new HandPointer { TrackingId = data.TrackingId, PlayerIndex = data.PlayerIndex, HandType = data.HandType, Owner = this, }; this.handPointers[id] = handPointer; } handPointer.Updated = true; handPointer.TimestampOfLastUpdate = data.TimeStampOfLastUpdate; handPointer.HandEventType = data.HandEventType; bool pressedChanged = handPointer.IsPressed != data.IsPressed; handPointer.IsPressed = data.IsPressed; handPointer.IsTracked = data.IsTracked; handPointer.IsActive = data.IsActive; handPointer.IsInteractive = data.IsInteractive; bool primaryHandOfPrimaryUserChanged = handPointer.IsPrimaryHandOfPrimaryUser != (data.IsPrimaryHandOfUser && data.IsPrimaryUser); handPointer.IsPrimaryHandOfUser = data.IsPrimaryHandOfUser; handPointer.IsPrimaryUser = data.IsPrimaryUser; double newX; double newY; //InteractionZoneDefinition.InteractionZoneToUserInterface(data.X, data.Y, data.Z, this.InteractionRootElement.ActualWidth, this.InteractionRootElement.ActualHeight, mapperParameters, out newX, out newY); InteractionZoneDefinition.InteractionZoneToUserInterface(data.X, data.Y, this.InteractionRootElement.ActualWidth, this.InteractionRootElement.ActualHeight, out newX, out newY); bool positionChanged = !InteractionZoneDefinition.AreUserInterfaceValuesClose(newX, handPointer.X) || !InteractionZoneDefinition.AreUserInterfaceValuesClose(newY, handPointer.Y) || !InteractionZoneDefinition.AreUserInterfaceValuesClose(data.Z, handPointer.PressExtent); handPointer.X = newX; handPointer.Y = newY; handPointer.PressExtent = data.Z; this.HandleHandPointerChanges(handPointer, pressedChanged, positionChanged, primaryHandOfPrimaryUserChanged, false); }
private void HandleHandPointerData(long timeStamp, UserInfo userInfo, int userIndex, InteractionHandPointer handPointer) { var interactionData = new InteractionFrameData { TimeStampOfLastUpdate = timeStamp, TrackingId = userInfo.SkeletonTrackingId, PlayerIndex = userIndex, HandType = EnumHelper.ConvertHandType(handPointer.HandType), IsTracked = handPointer.IsTracked, IsActive = handPointer.IsActive, IsInteractive = handPointer.IsInteractive, IsPressed = handPointer.IsPressed, IsPrimaryHandOfUser = handPointer.IsPrimaryForUser, IsPrimaryUser = (userInfo.SkeletonTrackingId == this.PrimaryUserTrackingId) && (userInfo.SkeletonTrackingId != KinectPrimaryUserTracker.InvalidUserTrackingId), HandEventType = EnumHelper.ConvertHandEventType(handPointer.HandEventType), X = handPointer.X, Y = handPointer.Y, Z = handPointer.PressExtent }; this.kinectAdapter.HandleHandPointerData(interactionData); }
/// <summary> /// Function that takes the state of the core interaction components /// and translates it to RoutedEvents. Also updates hand pointer states. /// </summary> /// <param name="data">Data directly from the core interaction components</param> public void HandleHandPointerData(InteractionFrameData data) { Debug.Assert(this.IsInInteractionFrame, "Call to HandleHandPointerData made without call to BeginInteractionFrame"); if (this.isClearRequestPending) { // We don't care about new hand pointer data if client requested to clear // all hand pointers while in the middle of interaction frame processing. return; } var id = new Tuple<int, HandType>(data.TrackingId, data.HandType); HandPointer handPointer; if (!this.handPointers.TryGetValue(id, out handPointer)) { handPointer = new HandPointer { TrackingId = data.TrackingId, PlayerIndex = data.PlayerIndex, HandType = data.HandType, Owner = this, }; this.handPointers[id] = handPointer; } handPointer.Updated = true; handPointer.TimestampOfLastUpdate = data.TimeStampOfLastUpdate; handPointer.HandEventType = data.HandEventType; bool pressedChanged = handPointer.IsPressed != data.IsPressed; handPointer.IsPressed = data.IsPressed; handPointer.IsTracked = data.IsTracked; handPointer.IsActive = data.IsActive; handPointer.IsInteractive = data.IsInteractive; bool primaryHandOfPrimaryUserChanged = handPointer.IsPrimaryHandOfPrimaryUser != (data.IsPrimaryHandOfUser && data.IsPrimaryUser); handPointer.IsPrimaryHandOfUser = data.IsPrimaryHandOfUser; handPointer.IsPrimaryUser = data.IsPrimaryUser; double newX; double newY; InteractionZoneDefinition.InteractionZoneToUserInterface(data.X, data.Y, this.InteractionRootElement.ActualWidth, this.InteractionRootElement.ActualHeight, out newX, out newY); bool positionChanged = !InteractionZoneDefinition.AreUserInterfaceValuesClose(newX, handPointer.X) || !InteractionZoneDefinition.AreUserInterfaceValuesClose(newY, handPointer.Y) || !InteractionZoneDefinition.AreUserInterfaceValuesClose(data.Z, handPointer.PressExtent); handPointer.X = newX; handPointer.Y = newY; handPointer.PressExtent = data.Z; this.HandleHandPointerChanges(handPointer, pressedChanged, positionChanged, primaryHandOfPrimaryUserChanged, false); }