Core math API used by the script system. It can be accessed using the math interface and consists of a number of constants, functions, and built-in vector and matrix types.
Basic Types
Basic math types available to the script system include:
- int - 32-bit signed integer
- uint - 32-bit unsigned integer
- float - 32-bit floating point value
Vector and Matrix Types
- float2, float3, float4 - vector types of the indicated size. A float3, for example, consists of 3 floats in vector format. Components can be accessed as x, y, z, w or by index (see the examples below). GLSL style swizzling is supported, as well as array syntax. Swizzling can be used to copy out smaller vectors as well.
- float2x2, float3x3, float4x4 - matrix types of the indicated size (2x2, 3x3, or 4x4 matrix). Rows can be accessed using the array syntax and are of the associated vector type (float2x2 = 2 x float2).
Vector Operations
Vector types (float, float2, float3, float4) can be referenced using array and component syntax. Swizzling is supported.
Example Swizzles:
float2 v(1, 2); system.print("{}", v); // (1, 2) system.print("{}", v.yx); // (2, 1) system.print("{}", v.xx); // (1, 1) float a = v.y; system.print("{}", a); // 2 float3 v3(1, 2, 3); float2 v2 = v3.xz;