Description
Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts • Server Entity Scripts • Assignment Client Scripts
TheMat4 API provides facilities for generating and
using 4 x 4 matrices. These
matrices are typically used to
represent transforms (scale, rotate, and translate) that convert one
coordinate system into
another, or perspective
transforms that convert 3D points into screen coordinates.
Methods
| Name | Return Value | Summary |
|---|---|---|
createFromArray
|
Mat4 |
Creates a matrix from an array of values. |
createFromColumns
|
Mat4 |
Creates a matrix from columns of values. |
createFromRotAndTrans
|
Mat4 |
Creates a matrix that represents a rotation and translation. |
createFromScaleRotAndTrans
|
Mat4 |
Creates a matrix that represents a scale, rotation, and translation. |
extractRotation
|
Quat |
Extracts the rotation from a matrix. |
extractScale
|
Vec3 |
Extracts the scale from a matrix. |
extractTranslation
|
Vec3 |
Extracts the translation from a matrix. |
getForward
|
Vec3 |
Gets the "forward" direction that the camera would face if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. |
getFront
|
Vec3 |
Gets the "forward" direction that the camera would face if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. Synonym for getForward. |
getRight
|
Vec3 |
Gets the "right" direction that the camera would have if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. |
getUp
|
Vec3 |
Gets the "up" direction that the camera would have if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. |
inverse
|
Mat4 |
Calculates the inverse of a matrix. |
multiply
|
Mat4 |
Multiplies two matrices. |
print
|
None |
Prints a matrix to the program log as a label followed by the matrix's values. |
transformPoint
|
Vec3 |
Transforms a point into a new coordinate system: the point value is scaled, rotated, and translated. |
transformVector
|
Vec3 |
Transforms a vector into a new coordinate system: the vector is scaled and rotated. |
Method Details
|
(static)
createFromArray( arr
) → {Mat4}
Returns: The matrix with the specified values. |
||||||
|---|---|---|---|---|---|---|
|
Creates a matrix from an array of values. Parameters
ExampleCreate a matrix from an array.
|
|
(static)
createFromColumns( col0, col1,
col2, col3
) → {Mat4}
Returns: The matrix with the specified columns values. |
|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Creates a matrix from columns of values. Parameters
ExampleCreate a matrix from columns.
|
|
(static)
createFromRotAndTrans( rot, trans
) →
{Mat4}
Returns: The matrix that represents the rotation and translation. |
|||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Creates a matrix that represents a rotation and translation. Parameters
ExampleCreate a matrix with rotation and translation.
|
|
(static)
createFromScaleRotAndTrans( scale, rot,
trans )
→ {Mat4}
Returns: The matrix that represents the scale, rotation, and translation. |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Creates a matrix that represents a scale, rotation, and translation. Parameters
ExampleCreate a matrix with scale, rotation, and translation.
|
|
(static)
extractRotation( m
) → {Quat}
Returns: The rotation contained in the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Extracts the rotation from a matrix. Parameters
ExampleExtract the rotation from a matrix.
|
|
(static)
extractScale( m
) → {Vec3}
Returns: The scale contained in the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Extracts the scale from a matrix. Parameters
ExampleExtract the scale from a matrix.
|
|
(static)
extractTranslation( m
) → {Vec3}
Returns: The translation contained in the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Extracts the translation from a matrix. Parameters
ExampleExtract the translation from a matrix.
|
|
(static)
getForward( m
)
→ {Vec3}
Returns: The negative z-axis rotated by the rotation in the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Gets the "forward" direction that the camera would face if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. Parameters
ExampleDemonstrate that the "forward" direction is the negative z-axis.
|
|
(static)
getFront(
m )
→ {Vec3}
Returns: The negative z-axis rotated by orientation. |
||||||
|---|---|---|---|---|---|---|
|
Gets the "forward" direction that the camera would face if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. Synonym for getForward. Parameters
|
|
(static)
getRight(
m )
→ {Vec3}
Returns: The x-axis rotated by the rotation in the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Gets the "right" direction that the camera would have if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. Parameters
|
|
(static)
getUp( m
)
→ {Vec3}
Returns: The y-axis rotated by the rotation in the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Gets the "up" direction that the camera would have if its orientation was set to the rotation contained in a matrix. The High Fidelity camera has axes x = right, y = up, -z = forward. Parameters
|
|
(static)
inverse(
m )
→ {Mat4}
Returns: The inverse of the matrix. |
||||||
|---|---|---|---|---|---|---|
|
Calculates the inverse of a matrix. Parameters
ExampleA matrix multiplied with its inverse is the unit matrix.
|
|
(static)
multiply(
m1, m2 ) → {Mat4}
Returns: m1 multiplied with
m2.
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Multiplies two matrices. Parameters
|
| (static) print( label, m, transposeopt ) | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Prints a matrix to the program log as a label followed by the matrix's values. Parameters
ExampleTwo ways of printing a label and matrix value.
|
|
(static)
transformPoint( m, point
) → {Vec3}
Returns: The point in the new coordinate system. |
|||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Transforms a point into a new coordinate system: the point value is scaled, rotated, and translated. Parameters
ExampleTransform a point.
|
|
(static)
transformVector( m, vector
) → {Vec3}
Returns: The vector in the new coordinate system. |
|||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Transforms a vector into a new coordinate system: the vector is scaled and rotated. Parameters
ExampleTransform a vector.
|
