From a35bdb8ce303aa3ac1e61a14dae4d7ba4b5ad452 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 7 Dec 2024 12:35:44 +0000 Subject: [PATCH] Add Mat4x4 to Transform3D utility conversion --- project/code/TMV/Utils.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/project/code/TMV/Utils.cs b/project/code/TMV/Utils.cs index edc2ef4..a05748f 100644 --- a/project/code/TMV/Utils.cs +++ b/project/code/TMV/Utils.cs @@ -9,4 +9,10 @@ public static class Utils { return new Godot.Vector3(vec.Y, vec.Z, vec.X) / (scale ? InverseScale : 1.0f); } + + public static Godot.Transform3D ToGodotTransform3D(this Matrix4x4 mat, bool scale = true) + { + var t = mat.Translation / (scale ? InverseScale : 1.0f); + return new Godot.Transform3D(mat.M22, mat.M21, mat.M23, mat.M31, mat.M33, mat.M32, mat.M12, mat.M13, mat.M11, t.Y, t.Z, t.X); + } } \ No newline at end of file