Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow local transform for RT Objects #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Qualisys/QTM-Unity-Realtime-Streaming/Streaming/RTObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ 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;

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;
}
}
}

Expand Down