summaryrefslogtreecommitdiffstats
path: root/modules/mono/glue/Managed/Files/Transform.cs
diff options
context:
space:
mode:
authorKelly Thomas <kelly.thomas@hotmail.com.au>2018-09-15 10:26:11 +0800
committerKelly Thomas <kelly.thomas@hotmail.com.au>2018-09-15 13:08:21 +0800
commitd4b24234283a022e4ae2fd124e6b94fc40572f99 (patch)
tree146cb7b09400b98f4728258cc557cc4d63712b54 /modules/mono/glue/Managed/Files/Transform.cs
parent43a1b93d71d2fa8da375a9881f8f389980c68575 (diff)
downloadredot-engine-d4b24234283a022e4ae2fd124e6b94fc40572f99.tar.gz
[Mono] implement Transform.InterpolateWith()
Diffstat (limited to 'modules/mono/glue/Managed/Files/Transform.cs')
-rw-r--r--modules/mono/glue/Managed/Files/Transform.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/mono/glue/Managed/Files/Transform.cs b/modules/mono/glue/Managed/Files/Transform.cs
index e432d5b52c..068007d7f0 100644
--- a/modules/mono/glue/Managed/Files/Transform.cs
+++ b/modules/mono/glue/Managed/Files/Transform.cs
@@ -20,6 +20,25 @@ namespace Godot
return new Transform(basisInv, basisInv.Xform(-origin));
}
+ public Transform InterpolateWith(Transform transform, real_t c)
+ {
+ /* not sure if very "efficient" but good enough? */
+
+ Vector3 sourceScale = basis.Scale;
+ Quat sourceRotation = basis.RotationQuat();
+ Vector3 sourceLocation = origin;
+
+ Vector3 destinationScale = transform.basis.Scale;
+ Quat destinationRotation = transform.basis.RotationQuat();
+ Vector3 destinationLocation = transform.origin;
+
+ var interpolated = new Transform();
+ interpolated.basis.SetQuantScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.LinearInterpolate(destinationScale, c));
+ interpolated.origin = sourceLocation.LinearInterpolate(destinationLocation, c);
+
+ return interpolated;
+ }
+
public Transform Inverse()
{
Basis basisTr = basis.Transposed();