Class Transform2XnaExtensions
- Assembly
- Thunder.UnitsNET.Vectors.Geometry.MonoGame.dll
Extension methods for converting Transform2 to XNA/MonoGame rendering primitives.
public static class Transform2XnaExtensions
- Inheritance
-
Transform2XnaExtensions
- Inherited Members
Methods
ToXnaMatrix(Transform2)
Converts a Transform2 to an XNA Microsoft.Xna.Framework.Matrix in metres
with no additional pixel scale. Equivalent to
ToXnaMatrix(transform, LengthUnit.Meter, Ratio.FromDecimalFractions(1.0)).
public static Matrix ToXnaMatrix(this Transform2 transform)
Parameters
transformTransform2The transform to convert.
Returns
- Matrix
An XNA Microsoft.Xna.Framework.Matrix equivalent to the given transform.
ToXnaMatrix(Transform2, LengthUnit)
Converts a Transform2 to an XNA Microsoft.Xna.Framework.Matrix in the given unit
with no additional pixel scale. Equivalent to
ToXnaMatrix(transform, unit, Ratio.FromDecimalFractions(1.0)).
public static Matrix ToXnaMatrix(this Transform2 transform, LengthUnit unit)
Parameters
transformTransform2The transform to convert.
unitLengthUnitThe length unit to express position in.
Returns
- Matrix
An XNA Microsoft.Xna.Framework.Matrix equivalent to the given transform.
ToXnaMatrix(Transform2, LengthUnit, Ratio)
Converts a Transform2 to an XNA Microsoft.Xna.Framework.Matrix using TRS order: Scale × RotationZ × Translation.
The resulting matrix can be passed to a SpriteBatch or used as a transform
matrix in a MonoGame rendering pipeline.
public static Matrix ToXnaMatrix(this Transform2 transform, LengthUnit unit, Ratio pixelScale)
Parameters
transformTransform2The transform to convert.
unitLengthUnitThe length unit to express position in.
pixelScaleRatioAn additional pixel-per-unit multiplier applied to the translation components. Pass
Ratio.FromDecimalFractions(1.0)for no scaling beyond the unit conversion.
Returns
- Matrix
An XNA Microsoft.Xna.Framework.Matrix equivalent to the given transform.
Examples
var t = new Transform2(LengthPoint2.FromMeters(1, 2), Direction2.FromDegrees(90), Ratio.FromDecimalFractions(1.0));
Matrix m = t.ToXnaMatrix(LengthUnit.Meter, Ratio.FromDecimalFractions(64.0)); // 1m = 64 pixels