Transformclass

A struct containing a position, rotation and scale. This is commonly used in engine to describe entity position, bone position and scene object position.

objectTransform
Namespace
global
Assembly
Sandbox.System
Declaration
public sealed struct Transform

Constructors4

Showing 4 constructors

Methods21

Showing 21 methods

public Transform Add(Vector3 position, bool worldSpace)PUBLIC

Add a position to this transform and return the result.

ParameterTypeDescription
positionVector3
worldSpacebool
Returns:Transform

public bool AlmostEqual(Transform tx, float delta = 0.0001)PUBLIC

Returns true if we're nearly equal to the passed transform.

ParameterTypeDescription
txTransformThe value to compare with
delta = 0.0001floatThe max difference between component values (used for Position and Scale)
Returns:boolTrue if nearly equal

public Transform LerpTo(Transform target, float t, bool clamp = True)PUBLIC

Linearly interpolate from this transform to given transform.

ParameterTypeDescription
targetTransform
tfloat
clamp = Truebool
Returns:Transform

public Transform Mirror(Sandbox.Plane plane)PUBLIC

Create a transform that is the mirror of this

ParameterTypeDescription
planePlane
Returns:Transform

public Vector3 NormalToLocal(Vector3 worldNormal)PUBLIC

Convert a world normal to a local normal

ParameterTypeDescription
worldNormalVector3
Returns:Vector3

public Vector3 NormalToWorld(Vector3 localNormal)PUBLIC

Convert a local normal to a world normal

ParameterTypeDescription
localNormalVector3
Returns:Vector3

public static Transform Parse(string str)PUBLICSTATIC

Given a string, try to convert this into a transform. The format is `"px,py,pz,rx,ry,rz,rw"`.

ParameterTypeDescription
strstring
Returns:Transform

public Vector3 PointToLocal(Vector3 worldPoint)PUBLIC

Convert a point in world space to a point in this transform's local space

ParameterTypeDescription
worldPointVector3
Returns:Vector3

public Vector3 PointToWorld(Vector3 localPoint)PUBLIC

Convert a point in this transform's local space to a point in world space

ParameterTypeDescription
localPointVector3
Returns:Vector3

public Transform RotateAround(Vector3 center, Rotation rot)PUBLIC

Rotate this transform around given point by given rotation and return the result.

ParameterTypeDescription
centerVector3Point to rotate around.
rotRotationHow much to rotate by. `Rotation.FromAxis(Vector3,System.Single)` can be useful.
Returns:TransformThe rotated transform.

public Rotation RotationToLocal(Rotation worldRot)PUBLIC

Convert a world rotation to a local rotation

ParameterTypeDescription
worldRotRotation
Returns:Rotation

public Rotation RotationToWorld(Rotation localRotation)PUBLIC

Convert a local rotation to a world rotation

ParameterTypeDescription
localRotationRotation
Returns:Rotation

Properties9

Showing 9 properties

public Ray Transform.ForwardRay { get; set; }PUBLICGETSET

Return a ray from this transform, which goes from the center along the Forward

Returns:Ray

public bool Transform.IsValid { get; set; }PUBLICGETSET

Returns true if position, scale and rotation are valid

Returns:bool

public float Transform.UniformScale { get; set; }PUBLICGETSET

A uniform scale component. Generally the scale is uniform, and we'll just access the .x component.

Returns:float

On this page

Constructorspublic Transform()public Transform(Vector3 position, Rotation rotation, System.Single scale = 1)public Transform(Vector3 position, Rotation rotation, Vector3 scale)public Transform(Vector3 pos = null)Methodspublic Transform Add(Vector3 position, System.Boolean worldSpace)public System.Boolean AlmostEqual(Transform tx, System.Single delta = 0.0001)public static Transform Concat(Transform parent, Transform local)public static Transform Lerp(Transform a, Transform b, System.Single t, System.Boolean clamp)public Transform LerpTo(Transform target, System.Single t, System.Boolean clamp = True)public Transform Mirror(Sandbox.Plane plane)public Vector3 NormalToLocal(Vector3 worldNormal)public Vector3 NormalToWorld(Vector3 localNormal)public static Transform Parse(System.String str)public Vector3 PointToLocal(Vector3 worldPoint)public Vector3 PointToWorld(Vector3 localPoint)public Transform RotateAround(Vector3 center, Rotation rot)public Rotation RotationToLocal(Rotation worldRot)public Rotation RotationToWorld(Rotation localRotation)public Transform ToLocal(Transform child)public Transform ToWorld(Transform child)public Transform WithPosition(Vector3 position, Rotation rotation)public Transform WithPosition(Vector3 position)public Transform WithRotation(Rotation rotation)public Transform WithScale(System.Single scale)public Transform WithScale(Vector3 scale)Propertiespublic Vector3 Transform.Backward { get; set; }public Vector3 Transform.Down { get; set; }public Vector3 Transform.Forward { get; set; }public Ray Transform.ForwardRay { get; set; }public System.Boolean Transform.IsValid { get; set; }public Vector3 Transform.Left { get; set; }public Vector3 Transform.Right { get; set; }public System.Single Transform.UniformScale { get; set; }public Vector3 Transform.Up { get; set; }Metadata