This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine.Unigine::mat4 Struct

This class represents a matrix of sixteen (4x4) float components.

mat4 Class

Members


mat4()

Default constructor. Produces an identity matrix.

explicit mat4(const dmat4 & m)

Constructor. Initializes the matrix using a given dmat4 source matrix (3x4). The matrix elements are filled using corresponding elements of the source matrix.

Arguments

  • const dmat4 & m - Source matrix (3x4).

explicit mat4(const quat & q)

Constructor. Initializes the matrix using a given source quaternion.
Output
For the quaternion (x, y, z, w) the corresponding rotation matrix M is defined as follows:		
    | 1 - 2y² - 2z²    2xy + 2wz      	2xz - 2wy     	0.0f | 
M=  | 2xy - 2wz        1 - 2x² - 2z²    2yz + 2wx     	0.0f |
    | 2xz + 2wy        2yz - 2wx        1 - 2x² - 2y² 	0.0f |
    |  0.0f            0.0f        		0.0f 			1.0f |

Arguments

  • const quat & q - Source quaternion.

explicit mat4(const float * m, int transpose)

Constructor. Initializes the matrix using a given pointer to the source matrix.

Arguments

  • const float * m - Pointer to the source matrix.
  • int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

void set(int row, int column, float v)

Sets a new value of the matrix element specified by row and column.

Arguments

  • int row - Row.
  • int column - Column.
  • float v - The value to be set.

void set(const float * m, int transpose)

Sets new matrix values using a pointer to the source matrix.

Arguments

  • const float * m - Pointer to the source matrix.
  • int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

float & get(int row, int column)

Returns the reference to the matrix element specified by given row and column.

Arguments

  • int row - Row.
  • int column - Column.

Return value

Matrix element reference.

float get(int row, int column) const

Returns the value of the matrix element specified by given row and column.

Arguments

  • int row - Row.
  • int column - Column.

Return value

Matrix element value.

void get(float * m, int transpose) const

Fills the destination matrix, specified by the given pointer, with matrix values.

Arguments

  • float * m - Destination matrix pointer.
  • int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

float * get()

Returns the pointer to the matrix.

Return value

Pointer to the matrix.

const float * get() const

Returns the constant pointer to the matrix.

Return value

Constant pointer to the matrix.

void setColumn(int column, const vec4 & v)

Sets the specified column of the matrix using a given vec4 vector as a source.

Arguments

  • int column - Column.
  • const vec4 & v - Source vector.

vec4 getColumn(int column) const

Returns the specified matrix column.

Arguments

  • int column - Column.

Return value

The vec4 vector with column values.

void setColumn3(int column, const vec3 & v)

Sets the specified column of the matrix using a given three-component vec3 vector as a source, the last element of the column remains as is.

Arguments

  • int column - Column.
  • const vec3 & v - Three-component source vector.

vec3 getColumn3(int column) const

Returns the XYZ components of the specified matrix column.

Arguments

  • int column - Column.

Return value

The vec3 vector with the first three elements of the specified matrix column.

void setIdentity()

Sets the matrix equal to the identity matrix.

void setRotate(const vec3 & axis, float angle)

Sets the rotation matrix for a given axis.

Arguments

  • const vec3 & axis - Rotation axis.
  • float angle - Rotation angle, in degrees.

quat getRotate() const

Returns the quaternion, representing the rotation part of the matrix.

Return value

Matrix rotation part.

void setRotateX(float angle)

Sets X rotation matrix.

Arguments

  • float angle - Rotation angle, in degrees.

void setRotateY(float angle)

Sets Y rotation matrix.

Arguments

  • float angle - Rotation angle, in degrees.

void setRotateZ(float angle)

Set Z rotation matrix.

Arguments

  • float angle - Rotation angle, in degrees.

void setRow(int row, const vec4 & v)

Sets the specified row of the matrix using a given vec4 vector as a source.

Arguments

  • int row - Row.
  • const vec4 & v - Source vector.

vec4 getRow(int row) const

Returns the specified matrix row.

Arguments

  • int row - Row.

Return value

The vec4 vector with row values.

void setRow3(int row, const vec3 & v)

Sets the specified row of the matrix using a given three-component vec3 vector as a source, the last element of the row remains as is.

Arguments

  • int row - Row.
  • const vec3 & v - Three-component source vector.

vec3 getRow3(int row) const

Returns the first three elements of the specified matrix row.

Arguments

  • int row - Row.

Return value

The vec3 vector with the first three elements of the specified matrix row.

void setScale(const vec3 & v)

Fills the scaling matrix using a given vec3 source vector.
Output
Scaling matrix: 
    | v.x   	0.0f  	  0.0f	    0.0f | 
S=  | 0.0f      v.y  	  0.0f      0.0f |
    | 0.0f      0.0f      v.z  		0.0f |
    | 0.0f      0.0f      0.0f  	1.0f |

Arguments

  • const vec3 & v - Source vector.

vec3 getScale() const

Returns the three-component vec3 vector, representing the scaling part of the matrix.

Return value

Three-component vector with the scaling part of the matrix.

void setTranslate(const vec3 & v)

Fills the translation matrix using a given vec3 source vector.
Output
Translation matrix: 
    | 1.0f   	0.0f  	  0.0f	    v.x | 
T=  | 0.0f      1.0f  	  0.0f      v.y |
    | 0.0f      0.0f      1.0f  	v.z |
    | 0.0f      0.0f      0.0f     1.0f |

Arguments

  • const vec3 & v - Source vector.

vec3 getTranslate() const

Returns the three-component vec3 vector, representing the translation part of the matrix.

Return value

Three-component vector with the translation part of the matrix.

mat4 & operator*=(const mat4 & m)

Performs matrix multiplication.

Arguments

  • const mat4 & m - Matrix.

Return value

Resulting matrix.

float & operator[](int i)

Performs array access to the matrix item reference using given item index.

Arguments

  • int i - Matrix item index.

Return value

Matrix item reference.

float operator[](int i) const

Performs array access to the matrix item using given item index.

Arguments

  • int i - Matrix item index.

Return value

Matrix item.

mat4 IDENTITY

Description

Identity matrix.

mat4 ONE

Description

Matrix of ones.

mat4 ZERO

Description

Zero matrix.
Last update: 2018-06-04
Build: ()