From d0a3e95821c21c596c00c112c4fc514a162f0645 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 5 Jul 2022 21:48:26 +0900 Subject: [PATCH] Define TransformState --- .../Runtime/UniGLTF/Util/TransformState.cs | 42 +++++++++++++++++++ .../UniGLTF/Util/TransformState.cs.meta | 3 ++ 2 files changed, 45 insertions(+) create mode 100644 Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs create mode 100644 Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs b/Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs new file mode 100644 index 000000000..7e31b2f32 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace UniGLTF +{ + public readonly struct TransformState + { + public Vector3 Position { get; } + public Vector3 LocalPosition { get; } + public Quaternion Rotation { get; } + public Quaternion LocalRotation { get; } + public Vector3 LocalScale { get; } + + public TransformState(Vector3 position, Vector3 localPosition, Quaternion rotation, Quaternion localRotation, Vector3 localScale) + { + Position = position; + LocalPosition = localPosition; + Rotation = rotation; + LocalRotation = localRotation; + LocalScale = localScale; + } + + public TransformState(Transform tf) + { + if (tf == null) + { + Position = Vector3.zero; + LocalPosition = Vector3.zero; + Rotation = Quaternion.identity; + LocalRotation = Quaternion.identity; + LocalScale = Vector3.one; + } + else + { + Position = tf.position; + LocalPosition = tf.localPosition; + Rotation = tf.rotation; + LocalRotation = tf.localRotation; + LocalScale = tf.localScale; + } + } + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs.meta new file mode 100644 index 000000000..f32750195 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Util/TransformState.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 172d698f753e4e59bf65a75014016221 +timeCreated: 1657022395 \ No newline at end of file