s&box docs

public sealed struct Transform

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

Broader workflow and conceptual references connected to this API.

Constructors

Showing 4 constructors

Methods

Showing 21 methods

public Transform Add(Vector3 position, bool worldSpace)

Add a position to this transform and return the result.

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

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

Parameters

  • tx: The value to compare with
  • delta: The max difference between component values (used for Position and Scale) Default: 0.0001

Returns

True if nearly equal

public static Transform Concat(Transform parent, Transform local)

Concatenate (add together) the 2 given transforms and return a new resulting transform.

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

Linearly interpolate from this transform to given transform.

Parameters

  • clamp: Default: True

public Transform Mirror(Sandbox.Plane plane)

Create a transform that is the mirror of this

public Vector3 NormalToLocal(Vector3 worldNormal)

Convert a world normal to a local normal

public Vector3 NormalToWorld(Vector3 localNormal)

Convert a local normal to a world normal

public static Transform Parse(string str)

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

public Vector3 PointToLocal(Vector3 worldPoint)

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

public Vector3 PointToWorld(Vector3 localPoint)

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

public Transform RotateAround(Vector3 center, Rotation rot)

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

Parameters

  • center: Point to rotate around.
  • rot: How much to rotate by. `Rotation.FromAxis(Vector3,System.Single)` can be useful.

Returns

The rotated transform.

public Rotation RotationToLocal(Rotation worldRot)

Convert a world rotation to a local rotation

public Rotation RotationToWorld(Rotation localRotation)

Convert a local rotation to a world rotation

public Transform ToLocal(Transform child)

Convert child transform from the world to a local transform

public Transform WithRotation(Rotation rotation)

Return this transform with a new rotation.

Properties

Showing 9 properties

public Ray Transform.ForwardRay { get; set; }

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

public bool Transform.IsValid { get; set; }

Returns true if position, scale and rotation are valid

public float Transform.UniformScale { get; set; }

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

Metadata

FieldValue
Namespaceglobal
Typeclass
AssemblySandbox.System
Doc IDT:Transform

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