From 162ac88c70a324783fd347cb43b4b5d0a1db57f9 Mon Sep 17 00:00:00 2001 From: mahaarbo Date: Fri, 17 Dec 2021 15:20:50 +0100 Subject: [PATCH] Allow local transform for RT Objects --- .../Streaming/RTObject.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Qualisys/QTM-Unity-Realtime-Streaming/Streaming/RTObject.cs b/Qualisys/QTM-Unity-Realtime-Streaming/Streaming/RTObject.cs index 18b98a5..03e5417 100644 --- a/Qualisys/QTM-Unity-Realtime-Streaming/Streaming/RTObject.cs +++ b/Qualisys/QTM-Unity-Realtime-Streaming/Streaming/RTObject.cs @@ -9,6 +9,7 @@ class RTObject : MonoBehaviour public string ObjectName = "Put QTM 6DOF object name here"; public Vector3 PositionOffset = new Vector3(0, 0, 0); public Vector3 RotationOffset = new Vector3(0, 0, 0); + public bool IsLocalTransform = false; protected RTClient rtClient; @@ -16,10 +17,18 @@ protected virtual void applyBodyTransform(SixDOFBody body) { if (!float.IsNaN(body.Position.sqrMagnitude)) //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; + if (IsLocalTransform) + { + transform.localPosition = body.Position + PositionOffset; + transform.localRotation = body.Rotation + PositionOffset; + } + else + { + 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; + } } }