// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } SixDOFBody body = rtClient.GetBody(ObjectName); if (body != null) { if (body.Position.magnitude > 0) //just to avoid error when position is NaN { transform.position = body.Position + PositionOffset; if (transform.parent) { transform.position += transform.parent.position; } transform.rotation = body.Rotation * Quaternion.Euler(EulerOffset); if (transform.parent) { transform.rotation *= transform.parent.rotation; } } } }
static bool Get6DOFSettings(RTState state, RTProtocol mProtocol) { // Get settings and information for streamed bodies bool getstatus = mProtocol.Get6dSettings(); if (getstatus) { state.bodies.Clear(); Settings6D settings = mProtocol.Settings6DOF; foreach (Settings6DOF body in settings.Bodies) { SixDOFBody newbody = new SixDOFBody(); newbody.Name = body.Name; newbody.Color.r = (body.ColorRGB) & 0xFF; newbody.Color.g = (body.ColorRGB >> 8) & 0xFF; newbody.Color.b = (body.ColorRGB >> 16) & 0xFF; newbody.Color /= 255; newbody.Color.a = 1F; newbody.Position = Vector3.zero; newbody.Rotation = Quaternion.identity; state.bodies.Add(newbody); } return(true); } return(false); }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } body = rtClient.GetBody(ObjectName); if (body != null) { this.applyBody(); } }
protected virtual void applyBodyTransform(SixDOFBody body) { if (body.Position.magnitude > 0) //just to avoid error when position is NaN { transform.position = body.Position + PositionOffset; if (transform.parent) { transform.position += transform.parent.position; } transform.rotation = body.Rotation * Quaternion.Euler(RotationOffset); if (transform.parent) { transform.rotation *= transform.parent.rotation; } } }
/// <summary> /// /// </summary> /// <param name="body"></param> protected override void applyBodyTransform(SixDOFBody body) { if (useObjectOrientation) { base.applyBodyTransform(body); } // Avoid position is NaN if (body.Position.magnitude > 0) { bodyPosition = body.Position; bodyRotation = body.Rotation; } // Get the body markers, of which the 6DOF body consists markers = rtClient.Markers; if (markers == null || markers.Count == 0) { return; } if (markerGOs == null) { InitiateMarkers(); } foreach (GameObject markerGO in markerGOs) { LabeledMarker marker = rtClient.GetMarker(markerGO.name); // Show and update existing markers if (marker != null && marker.Position.magnitude > 0) { markerGO.transform.localPosition = Quaternion.Inverse(bodyRotation) * (marker.Position - bodyPosition); markerGO.transform.localScale = Vector3.one * markerScale; markerGO.SetActive(true); markerGO.GetComponent <Renderer>().enabled = visibleMarkers; markerGO.GetComponent <Renderer>().material.color = marker.Color; } else { // Hide not existing markers. markerGO.SetActive(false); } } }
private bool Get6DOFSettings() { // Get settings and information for streamed bodies bool getstatus = mProtocol.Get6DSettings(); if (getstatus) { mBodies.Clear(); Settings6D settings = mProtocol.Settings6DOF; foreach (Settings6DOF body in settings.bodies) { SixDOFBody newbody = new SixDOFBody(); newbody.Name = body.Name; newbody.Position = Vector3.zero; newbody.Rotation = Quaternion.identity; mBodies.Add(newbody); } return(true); } return(false); }
private bool Get6DOFSettings() { // Get settings and information for streamed bodies bool getstatus = mProtocol.Get6DSettings(); if (getstatus) { mBodies.Clear(); Settings6D settings = mProtocol.Settings6DOF; foreach (Settings6DOF body in settings.bodies) { SixDOFBody newbody = new SixDOFBody(); newbody.Name = body.Name; newbody.Position = Vector3.zero; newbody.Rotation = Quaternion.identity; mBodies.Add(newbody); } return true; } return false; }