Browse Source

added missing constructors

Vicente Penades 3 years ago
parent
commit
b2803a8871
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/SharpGLTF.Core/Transforms/AffineTransform.cs

+ 15 - 2
src/SharpGLTF.Core/Transforms/AffineTransform.cs

@@ -92,7 +92,12 @@ namespace SharpGLTF.Transforms
         {
         {
             return new AffineTransform(matrix);
             return new AffineTransform(matrix);
         }
         }
-        
+
+        public static implicit operator AffineTransform(Quaternion rotation)
+        {
+            return new AffineTransform(rotation);
+        }
+
         public static AffineTransform CreateDecomposed(Matrix4x4 matrix)
         public static AffineTransform CreateDecomposed(Matrix4x4 matrix)
         {
         {
             if (!Matrix4x4.Decompose(matrix, out var s, out var r, out var t)) throw new ArgumentException("Can't decompose", nameof(matrix));
             if (!Matrix4x4.Decompose(matrix, out var s, out var r, out var t)) throw new ArgumentException("Can't decompose", nameof(matrix));
@@ -151,6 +156,14 @@ namespace SharpGLTF.Transforms
             : this(scale ?? Vector3.One, rotation ?? Quaternion.Identity, translation ?? Vector3.Zero)
             : this(scale ?? Vector3.One, rotation ?? Quaternion.Identity, translation ?? Vector3.Zero)
         { }
         { }
 
 
+        public AffineTransform(Quaternion rotation)
+            : this(Vector3.One, rotation, Vector3.Zero)
+        { }
+
+        public AffineTransform(Quaternion rotation, Vector3 translation)
+            : this(Vector3.One, rotation, translation)
+        { }
+
         public AffineTransform(Vector3 scale, Quaternion rotation, Vector3 translation)
         public AffineTransform(Vector3 scale, Quaternion rotation, Vector3 translation)
         {
         {
             rotation = rotation.Sanitized();
             rotation = rotation.Sanitized();
@@ -195,7 +208,7 @@ namespace SharpGLTF.Transforms
             _M33 = matrix.M33;
             _M33 = matrix.M33;
 
 
             _Translation = matrix.Translation;
             _Translation = matrix.Translation;
-        }
+        }              
 
 
         #endregion
         #endregion