static void parseDataDescriptor(List <NatNetML.DataDescriptor> description) { // [NatNet] Request a description of the Active Model List from the server. // This sample will list only names of the data sets, but you can access int numDataSet = description.Count; Console.WriteLine("Total {0} data sets in the capture:", numDataSet); for (int i = 0; i < numDataSet; ++i) { int dataSetType = description[i].type; // Parse Data Descriptions for each data sets and save them in the delcared lists and hashtables for later uses. switch (dataSetType) { case ((int)NatNetML.DataDescriptorType.eMarkerSetData): NatNetML.MarkerSet mkset = (NatNetML.MarkerSet)description[i]; Console.WriteLine("\tMarkerSet ({0})", mkset.Name); break; case ((int)NatNetML.DataDescriptorType.eRigidbodyData): NatNetML.RigidBody rb = (NatNetML.RigidBody)description[i]; Console.WriteLine("\tRigidBody ({0})", rb.Name); // Saving Rigid Body Descriptions mRigidBodies.Add(rb); break; default: // When a Data Set does not match any of the descriptions provided by the SDK. Console.WriteLine("\tError: Invalid Data Set"); break; } } }
/// <summary> /// [NatNet] Request a description of the Active Model List from the server (e.g. Motive) and build up a new spreadsheet /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonGetDataDescriptions_Click(object sender, EventArgs e) { mRigidBodies.Clear(); dataGridView1.Rows.Clear(); htMarkers.Clear(); htRigidBodies.Clear(); needMarkerListUpdate = true; OutputMessage("Retrieving Data Descriptions...."); List <NatNetML.DataDescriptor> descs = new List <NatNetML.DataDescriptor>(); bool bSuccess = m_NatNet.GetDataDescriptions(out descs); if (bSuccess) { OutputMessage(String.Format("Retrieved {0} Data Descriptions....", descs.Count)); int iObject = 0; foreach (NatNetML.DataDescriptor d in descs) { iObject++; // MarkerSets if (d.type == (int)NatNetML.DataDescriptorType.eMarkerSetData) { NatNetML.MarkerSet ms = (NatNetML.MarkerSet)d; OutputMessage("Data Def " + iObject.ToString() + " [MarkerSet]"); OutputMessage(" Name : " + ms.Name); OutputMessage(String.Format(" Markers ({0}) ", ms.nMarkers)); dataGridView1.Rows.Add("MarkerSet: " + ms.Name); for (int i = 0; i < ms.nMarkers; i++) { OutputMessage((" " + ms.MarkerNames[i])); int rowIndex = dataGridView1.Rows.Add(" " + ms.MarkerNames[i]); // MarkerNameIndexToRow map String strUniqueName = ms.Name + i.ToString(); int key = strUniqueName.GetHashCode(); htMarkers.Add(key, rowIndex); } } // RigidBodies else if (d.type == (int)NatNetML.DataDescriptorType.eRigidbodyData) { NatNetML.RigidBody rb = (NatNetML.RigidBody)d; OutputMessage("Data Def " + iObject.ToString() + " [RigidBody]"); OutputMessage(" Name : " + rb.Name); OutputMessage(" ID : " + rb.ID); OutputMessage(" ParentID : " + rb.parentID); OutputMessage(" OffsetX : " + rb.offsetx); OutputMessage(" OffsetY : " + rb.offsety); OutputMessage(" OffsetZ : " + rb.offsetz); mRigidBodies.Add(rb); int rowIndex = dataGridView1.Rows.Add("RigidBody: " + rb.Name); // RigidBodyIDToRow map int key = rb.ID.GetHashCode(); htRigidBodies.Add(key, rowIndex); } // Skeletons else if (d.type == (int)NatNetML.DataDescriptorType.eSkeletonData) { NatNetML.Skeleton sk = (NatNetML.Skeleton)d; OutputMessage("Data Def " + iObject.ToString() + " [Skeleton]"); OutputMessage(" Name : " + sk.Name); OutputMessage(" ID : " + sk.ID); dataGridView1.Rows.Add("Skeleton: " + sk.Name); for (int i = 0; i < sk.nRigidBodies; i++) { RigidBody rb = sk.RigidBodies[i]; OutputMessage(" RB Name : " + rb.Name); OutputMessage(" RB ID : " + rb.ID); OutputMessage(" ParentID : " + rb.parentID); OutputMessage(" OffsetX : " + rb.offsetx); OutputMessage(" OffsetY : " + rb.offsety); OutputMessage(" OffsetZ : " + rb.offsetz); int rowIndex = dataGridView1.Rows.Add("Bone: " + rb.Name); // RigidBodyIDToRow map int uniqueID = sk.ID * 1000 + rb.ID; int key = uniqueID.GetHashCode(); if (htRigidBodies.ContainsKey(key)) { MessageBox.Show("Duplicate RigidBody ID"); } else { htRigidBodies.Add(key, rowIndex); } } } else { OutputMessage("Unknown DataType"); } } } else { OutputMessage("Unable to retrieve DataDescriptions"); } }
static void parseDataDescriptor(List <NatNetML.DataDescriptor> description) { // [NatNet] Request a description of the Active Model List from the server. // This sample will list only names of the data sets, but you can access int numDataSet = description.Count; Console.WriteLine("Total {0} data sets in the capture:", numDataSet); for (int i = 0; i < numDataSet; ++i) { int dataSetType = description[i].type; // Parse Data Descriptions for each data sets and save them in the delcared lists and hashtables for later uses. switch (dataSetType) { case ((int)NatNetML.DataDescriptorType.eMarkerSetData): NatNetML.MarkerSet mkset = (NatNetML.MarkerSet)description[i]; Console.WriteLine("\tMarkerSet ({0})", mkset.Name); break; case ((int)NatNetML.DataDescriptorType.eRigidbodyData): NatNetML.RigidBody rb = (NatNetML.RigidBody)description[i]; Console.WriteLine("\tRigidBody ({0})", rb.Name); // Saving Rigid Body Descriptions mRigidBodies.Add(rb); break; case ((int)NatNetML.DataDescriptorType.eSkeletonData): NatNetML.Skeleton skl = (NatNetML.Skeleton)description[i]; Console.WriteLine("\tSkeleton ({0}), Bones:", skl.Name); //Saving Skeleton Descriptions mSkeletons.Add(skl); // Saving Individual Bone Descriptions for (int j = 0; j < skl.nRigidBodies; j++) { Console.WriteLine("\t\t{0}. {1}", j + 1, skl.RigidBodies[j].Name); int uniqueID = skl.ID * 1000 + skl.RigidBodies[j].ID; int key = uniqueID.GetHashCode(); mHtSkelRBs.Add(key, skl.RigidBodies[j]); //Saving the bone segments onto the hashtable } break; case ((int)NatNetML.DataDescriptorType.eForcePlateData): NatNetML.ForcePlate fp = (NatNetML.ForcePlate)description[i]; Console.WriteLine("\tForcePlate ({0})", fp.Serial); // Saving Force Plate Channel Names mForcePlates.Add(fp); for (int j = 0; j < fp.ChannelCount; j++) { Console.WriteLine("\t\tChannel {0}: {1}", j + 1, fp.ChannelNames[j]); } break; default: // When a Data Set does not match any of the descriptions provided by the SDK. Console.WriteLine("\tError: Invalid Data Set"); break; } } }