Skip to content

KernelAPI reference

Struct Transform

Namespace: MicroEngine.Scenes
Assembly: MicroEngine.Scene.dll
Guide: Scenes

Position, rotation and scale relative to the parent (or to the world for a root entity). Stored in 3D; 2D games use the 2D helpers, which read and write X/Y and the rotation about Z. default is degenerate (zero scale and a zero quaternion): entities start at Identity.

C#
public struct Transform

Fields

Position

Translation.

C#
public Vector3 Position

Field Value

Vector3

Rotation

Rotation (unit quaternion).

C#
public Quaternion Rotation

Field Value

Quaternion

Scale

Scale per axis.

C#
public Vector3 Scale

Field Value

Vector3

Properties

Identity

No translation, no rotation, unit scale.

C#
public static Transform Identity { get; }

Property Value

Transform

Position2D

X and Y of Position; writing keeps Z. Exact: a written value reads back bit for bit.

C#
public Vector2 Position2D { readonly get; set; }

Property Value

Vector2

Rotation2D

The rotation about Z in radians. Writing replaces Rotation; reading converts back from the quaternion, so a written angle reads back within a few ulps, not bit for bit (keep the angle in game state when the exact value matters).

C#
public float Rotation2D { readonly get; set; }

Property Value

float

Scale2D

X and Y of Scale; writing keeps Z.

C#
public Vector2 Scale2D { readonly get; set; }

Property Value

Vector2

Methods

Interpolate(in Transform, in Transform, float)

The transform t of the way from from to to: positions and scales lerp, rotations slerp. Returns to exactly when t is 1 or more or the two are equal, so a fixed-step run draws exactly the simulated state.

C#
public static Transform Interpolate(in Transform from, in Transform to, float t)

Parameters

from Transform

to Transform

t float

Returns

Transform

ToMatrix()

The matrix that maps this transform’s space to its parent’s (scale, then rotate, then translate).

C#
public readonly Matrix4x4 ToMatrix()

Returns

Matrix4x4