/// <summary> /// Put a marker dataset into the pipeline /// and extract the delayed dataset. /// </summary> /// <param name="marker">the marker data to add into the queue</param> /// <returns>the delayed dataset</returns> /// public MoCapData Process(Marker marker) { if (firstPush) { // first piece of data > fill the whole pipeline with it for (int i = 0; i < pipeline.Length; i++) { pipeline[i].Store(marker); } firstPush = false; } else { pipeline[index].Store(marker); } index = (index + 1) % pipeline.Length; // manipulate data before returning MoCapData retValue = pipeline[index]; foreach (IModifier m in modifiers) { m.Process(ref retValue); } return retValue; }
/// <summary> /// Creates copies of the marker template for all markers. /// </summary> /// <param name="markers">marker data from the MoCap system</param> /// private void CreateMarkers(Marker[] markers) { // create node for containing all the marker objects markerNode = new GameObject(); markerNode.name = "Markers"; markerNode.transform.parent = this.transform; markerNode.transform.localPosition = Vector3.zero; markerNode.transform.localRotation = Quaternion.identity; markerNode.transform.localScale = Vector3.one; if (markerTemplate != null) { // create copies of the marker template foreach (Marker marker in markers) { GameObject markerRepresentation = GameObject.Instantiate(markerTemplate); markerRepresentation.name = marker.name; markerRepresentation.transform.parent = markerNode.transform; dataBuffers[marker] = new MoCapDataBuffer(marker.name, this.gameObject, markerRepresentation); } } }
/// <summary> /// Stores marker data. /// </summary> /// <param name="marker">the marker to store data of</param> /// public void Store(Marker marker) { pos.Set(marker.px, marker.py, marker.pz); tracked = marker.tracked; }
/// <summary> /// Converts a marker position from a right handed coordinate to a left handed (Unity). /// </summary> /// <param name="pos">the marker to convert</param> /// private void TransformToUnity(ref Marker marker) { marker.pz *= -1; // flip Z }
private void ReadMarkersetDescription(ref List<Actor> actors) { int id = 0; // no ID for markersets string name = dataStream.GetString(); // markerset name Actor actor = new Actor(scene, name, id); int nMarkers = dataStream.GetInt(); // marker count actor.markers = new Marker[nMarkers]; for (int markerIdx = 0; markerIdx < nMarkers; markerIdx++) { name = dataStream.GetString(); Marker marker = new Marker(actor, name); actor.markers[markerIdx] = marker; } actors.Add(actor); }
private void ParseMarkerset(NatNetPacket_In packet, List<Actor> actors) { int id = 0; // no ID for markersets string name = packet.GetString(); // markerset name Actor actor = new Actor(scene, name, id); int nMarkers = packet.GetInt32(); // marker count // TODO: Sanity check on the number before allocating that much space actor.markers = new Marker[nMarkers]; for ( int markerIdx = 0 ; markerIdx < nMarkers ; markerIdx++ ) { name = packet.GetString(); Marker marker = new Marker(actor, name); actor.markers[markerIdx] = marker; } actors.Add(actor); }