Table of Contents

Class Transform2XnaExtensions

Namespace
Thunder.UnitsNET.Vectors.Geometry.MonoGame
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

transform Transform2

The 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

transform Transform2

The transform to convert.

unit LengthUnit

The 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

transform Transform2

The transform to convert.

unit LengthUnit

The length unit to express position in.

pixelScale Ratio

An 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
latest ▼