public positionMessages(indivJoint myJoint) { register = myJoint.posReg; //sender = msend; StringBuilder addressRoot = new StringBuilder(); addressRoot.Append("/"); addressRoot.Append(myJoint.type.ToString()); addressRoot.Append("/"); String root = addressRoot.ToString(); StringBuilder xAddress = new StringBuilder(root); StringBuilder yAddress = new StringBuilder(root); StringBuilder zAddress = new StringBuilder(root); xAddress.Append("x"); yAddress.Append("y"); zAddress.Append("z"); x_OSC = new OscMessage(xAddress.ToString(), (float)myJoint.loc.X); y_OSC = new OscMessage(yAddress.ToString(), (float)myJoint.loc.Y); z_OSC = new OscMessage(zAddress.ToString(), (float)myJoint.loc.Z); }
/// Event handler for Kinect sensor's SkeletonFrameReady event /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { Skeleton[] skeletons = new Skeleton[0]; using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } } using (DrawingContext dc = this.drawingGroup.Open()) { // Draw a transparent background to set the render size dc.DrawRectangle(backgroundBrush, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight)); if (skeletons.Length != 0) { foreach (Skeleton skel in skeletons) { RenderClippedEdges(skel, dc); if (skel.TrackingState == SkeletonTrackingState.Tracked) { this.DrawBonesAndJoints(skel, dc); // if (jOn[0]) { indivJoint joint1 = new indivJoint(skel, j_values[0], "joint1"); positionMessages j1_messages = new positionMessages(joint1); joint1.posReg.copy(jReg[0]); for (int i = 0; i < numSenders; i++) { if (j_IP[0, i]) { j1_messages.sendMessages(UDPs[i]); } } } if (jOn[1]) { indivJoint joint2 = new indivJoint(skel, j_values[1], "joint2"); positionMessages j2_messages = new positionMessages(joint2); joint2.posReg.copy(jReg[1]); for (int i = 0; i < numSenders; i++) { if (j_IP[1, i]) { j2_messages.sendMessages(UDPs[i]); } } } if (jOn[2]) { indivJoint joint3 = new indivJoint(skel, j_values[2], "joint3"); positionMessages j3_messages = new positionMessages(joint3); joint3.posReg.copy(jReg[2]); for (int i = 0; i < numSenders; i++) { if (j_IP[2, i]) { j3_messages.sendMessages(UDPs[i]); } } } if (jOn[3]) { indivJoint joint4 = new indivJoint(skel, j_values[3], "joint4"); positionMessages j4_messages = new positionMessages(joint4); joint4.posReg.copy(jReg[3]); for (int i = 0; i < numSenders; i++) { if (j_IP[3, i]) { j4_messages.sendMessages(UDPs[i]); } } } if (jOn[4]) { indivJoint joint5 = new indivJoint(skel, j_values[4], "joint5"); positionMessages j5_messages = new positionMessages(joint5); joint5.posReg.copy(jReg[4]); for (int i = 0; i < numSenders; i++) { if (j_IP[4, i]) { j5_messages.sendMessages(UDPs[i]); } } } if (jOn[5]) { indivJoint joint6 = new indivJoint(skel, j_values[5], "joint6"); positionMessages j6_messages = new positionMessages(joint6); joint6.posReg.copy(jReg[5]); for (int i = 0; i < numSenders; i++) { if (j_IP[5, i]) { j6_messages.sendMessages(UDPs[i]); } } } if (jOn[6]) { indivJoint joint7 = new indivJoint(skel, j_values[6], "joint7"); positionMessages j7_messages = new positionMessages(joint7); joint7.posReg.copy(jReg[6]); for (int i = 0; i < numSenders; i++) { if (j_IP[6, i]) { j7_messages.sendMessages(UDPs[i]); } } } if (jOn[7]) { indivJoint joint8 = new indivJoint(skel, j_values[7], "joint8"); positionMessages j8_messages = new positionMessages(joint8); joint8.posReg.copy(jReg[7]); for (int i = 0; i < numSenders; i++) { if (j_IP[7, i]) { j8_messages.sendMessages(UDPs[i]); } } } if (jOn[8]) { indivJoint joint9 = new indivJoint(skel, j_values[8], "joint9"); positionMessages j9_messages = new positionMessages(joint9); joint9.posReg.copy(jReg[8]); for (int i = 0; i < numSenders; i++) { if (j_IP[8, i]) { j9_messages.sendMessages(UDPs[i]); } } } if (jOn[9]) { indivJoint joint10 = new indivJoint(skel, j_values[9], "joint10"); positionMessages j10_messages = new positionMessages(joint10); joint10.posReg.copy(jReg[9]); for (int i = 0; i < numSenders; i++) { if (j_IP[9, i]) { j10_messages.sendMessages(UDPs[i]); } } } //defines joint pairs if (pOn[0]) { jPair pair1 = new jPair(skel, p_values[0,0], p_values[0,1], "pair1"); distanceMessages p1_Messages = new distanceMessages(pair1); pair1.distReg.copy(pReg[0]); for (int i = 0; i < numSenders; i++) { if (p_IP[0, i]) { p1_Messages.sendMessages(UDPs[i]); } } } if (pOn[1]) { jPair pair2 = new jPair(skel, p_values[1, 0], p_values[1, 1], "pair2"); distanceMessages p2_Messages = new distanceMessages(pair2); pair2.distReg.copy(pReg[1]); for (int i = 0; i < numSenders; i++) { if (p_IP[1, i]) { p2_Messages.sendMessages(UDPs[i]); } } } if (pOn[2]) { jPair pair3 = new jPair(skel, p_values[2, 0], p_values[2, 1], "pair3"); distanceMessages p3_Messages = new distanceMessages(pair3); pair3.distReg.copy(pReg[2]); for (int i = 0; i < numSenders; i++) { if (p_IP[2, i]) { p3_Messages.sendMessages(UDPs[i]); } } } } else if (skel.TrackingState == SkeletonTrackingState.PositionOnly) { dc.DrawEllipse( this.centerPointBrush, null, this.SkeletonPointToScreen(skel.Position), BodyCenterThickness, BodyCenterThickness); } } } // prevent drawing outside of our render area this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight)); } }