diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml
index b3145ea0227..90c10e36643 100644
--- a/doc/classes/Transform3D.xml
+++ b/doc/classes/Transform3D.xml
@@ -41,6 +41,7 @@
+ Constructs a Transform3D from a [Projection] by trimming the last row of the projection matrix ([code]from.x.w[/code], [code]from.y.w[/code], [code]from.z.w[/code], and [code]from.w.w[/code] are not copied over).
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
index 7366760e3f0..0ac49583258 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
@@ -858,8 +858,20 @@ namespace Godot
// We need to assign the struct fields here first so we can't do it that way...
}
- // Arguments are named such that xy is equal to calling x.y
- internal Basis(real_t xx, real_t yx, real_t zx, real_t xy, real_t yy, real_t zy, real_t xz, real_t yz, real_t zz)
+ ///
+ /// Constructs a transformation matrix from the given components.
+ /// Arguments are named such that xy is equal to calling x.y.
+ ///
+ /// The X component of the X column vector, accessed via b.x.x or [0][0].
+ /// The X component of the Y column vector, accessed via b.y.x or [1][0].
+ /// The X component of the Z column vector, accessed via b.z.x or [2][0].
+ /// The Y component of the X column vector, accessed via b.x.y or [0][1].
+ /// The Y component of the Y column vector, accessed via b.y.y or [1][1].
+ /// The Y component of the Z column vector, accessed via b.y.y or [2][1].
+ /// The Z component of the X column vector, accessed via b.x.y or [0][2].
+ /// The Z component of the Y column vector, accessed via b.y.y or [1][2].
+ /// The Z component of the Z column vector, accessed via b.y.y or [2][2].
+ public Basis(real_t xx, real_t yx, real_t zx, real_t xy, real_t yy, real_t zy, real_t xz, real_t yz, real_t zz)
{
Row0 = new Vector3(xx, yx, zx);
Row1 = new Vector3(xy, yy, zy);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
index 09e656af491..6dda150c2b4 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
@@ -411,7 +411,7 @@ namespace Godot
///
/// Constructs a transformation matrix from the given components.
- /// Arguments are named such that xy is equal to calling x.y
+ /// Arguments are named such that xy is equal to calling x.y.
///
/// The X component of the X column vector, accessed via t.x.x or [0][0].
/// The Y component of the X column vector, accessed via t.x.y or [0][1].
@@ -440,6 +440,24 @@ namespace Godot
this.origin = origin;
}
+ ///
+ /// Constructs a transformation matrix from a value,
+ /// vector, value, and
+ /// vector.
+ ///
+ /// The rotation of the new transform, in radians.
+ /// The scale of the new transform.
+ /// The skew of the new transform, in radians.
+ /// The origin vector, or column index 2.
+ public Transform2D(real_t rotation, Vector2 scale, real_t skew, Vector2 origin)
+ {
+ x.x = Mathf.Cos(rotation) * scale.x;
+ y.y = Mathf.Cos(rotation + skew) * scale.y;
+ y.x = -Mathf.Sin(rotation + skew) * scale.y;
+ x.y = Mathf.Sin(rotation) * scale.x;
+ this.origin = origin;
+ }
+
///
/// Composes these two transformation matrices by multiplying them
/// together. This has the effect of transforming the second transform
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs
index 4f0a557e0af..6b2475fc595 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs
@@ -342,15 +342,25 @@ namespace Godot
}
///
- /// Constructs a transformation matrix from the given
- /// and vector.
+ /// Constructs a transformation matrix from the given components.
+ /// Arguments are named such that xy is equal to calling basis.x.y.
///
- /// The to create the basis from.
- /// The origin vector, or column index 3.
- public Transform3D(Quaternion quaternion, Vector3 origin)
+ /// The X component of the X column vector, accessed via t.basis.x.x or [0][0].
+ /// The X component of the Y column vector, accessed via t.basis.y.x or [1][0].
+ /// The X component of the Z column vector, accessed via t.basis.z.x or [2][0].
+ /// The Y component of the X column vector, accessed via t.basis.x.y or [0][1].
+ /// The Y component of the Y column vector, accessed via t.basis.y.y or [1][1].
+ /// The Y component of the Z column vector, accessed via t.basis.y.y or [2][1].
+ /// The Z component of the X column vector, accessed via t.basis.x.y or [0][2].
+ /// The Z component of the Y column vector, accessed via t.basis.y.y or [1][2].
+ /// The Z component of the Z column vector, accessed via t.basis.y.y or [2][2].
+ /// The X component of the origin vector, accessed via t.origin.x or [2][0].
+ /// The Y component of the origin vector, accessed via t.origin.y or [2][1].
+ /// The Z component of the origin vector, accessed via t.origin.z or [2][2].
+ public Transform3D(real_t xx, real_t yx, real_t zx, real_t xy, real_t yy, real_t zy, real_t xz, real_t yz, real_t zz, real_t ox, real_t oy, real_t oz)
{
- basis = new Basis(quaternion);
- this.origin = origin;
+ basis = new Basis(xx, yx, zx, xy, yy, zy, xz, yz, zz);
+ origin = new Vector3(ox, oy, oz);
}
///
@@ -365,6 +375,29 @@ namespace Godot
this.origin = origin;
}
+ ///
+ /// Constructs a transformation matrix from the given
+ /// by trimming the last row of the projection matrix (projection.x.w,
+ /// projection.y.w, projection.z.w, and projection.w.w
+ /// are not copied over).
+ ///
+ /// The to create the transform from.
+ public Transform3D(Projection projection)
+ {
+ basis = new Basis
+ (
+ projection.x.x, projection.y.x, projection.z.x,
+ projection.x.y, projection.y.y, projection.z.y,
+ projection.x.z, projection.y.z, projection.z.z
+ );
+ origin = new Vector3
+ (
+ projection.w.x,
+ projection.w.y,
+ projection.w.z
+ );
+ }
+
///
/// Composes these two transformation matrices by multiplying them
/// together. This has the effect of transforming the second transform