//This function will be implemented by you in the subclass files provided. //A simple example of highlighting targets when hovered over has been provided below //Note: targets is a dictionary that allows you to retrieve the corresponding target on screen //and manipulate its state and position, as well as hide/show it (see class defn. below). //It is indexed from 1, thus you can retrieve an individual target with the expression //targets[3], which would retrieve the target labeled "3" on screen. public virtual void processSkeletonFrame(SkeletonData skeleton, Dictionary <int, Target> targets) { /*Example implementation*/ foreach (var target in targets) { Target cur = target.Value; int targetID = cur.id; //ID in range [1..5] //Scale the joints to the size of the window Joint leftHand = skeleton.Joints[JointID.HandLeft].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale); Joint rightHand = skeleton.Joints[JointID.HandRight].ScaleTo(640, 480, window.k_xMaxJointScale, window.k_yMaxJointScale); //Calculate how far our left hand is from the target in both x and y directions double deltaX_left = Math.Abs(leftHand.Position.X - cur.getXPosition()); double deltaY_left = Math.Abs(leftHand.Position.Y - cur.getYPosition()); //Calculate how far our right hand is from the target in both x and y directions double deltaX_right = Math.Abs(rightHand.Position.X - cur.getXPosition()); double deltaY_right = Math.Abs(rightHand.Position.Y - cur.getYPosition()); //If we have a hit in a reasonable range, highlight the target if (deltaX_left < 15 && deltaY_left < 15 || deltaX_right < 15 && deltaY_right < 15) { cur.setTargetSelected(); } else { cur.setTargetUnselected(); } } }
protected void rightHandTimer_Elapsed(object sender, ElapsedEventArgs e) { rightHandTarget.Dispatch(new Action( delegate() { rightHandTarget.setTargetSelected(); })); }
private void handleTargetIntersected(Target t, double value) { int currentValue = Convert.ToInt16(t.getTargetText()); currentValue += (int)value; if (currentValue >= 100) { currentValue = 100; t.setTargetSelected(); } t.setTargetText(currentValue.ToString()); }