Kohi Game Engine
transform.h File Reference
#include "math_types.h"

Go to the source code of this file.

Functions

KAPI transform transform_create (void)
 Creates and returns a new transform, using a zero vector for position, identity quaternion for rotation, and a one vector for scale. Also has a null parent. Marked dirty by default. More...
 
KAPI transform transform_from_position (vec3 position)
 Creates a transform from the given position. Uses a zero rotation and a one scale. More...
 
KAPI transform transform_from_rotation (quat rotation)
 Creates a transform from the given rotation. Uses a zero position and a one scale. More...
 
KAPI transform transform_from_position_rotation (vec3 position, quat rotation)
 Creates a transform from the given position and rotation. Uses a one scale. More...
 
KAPI transform transform_from_position_rotation_scale (vec3 position, quat rotation, vec3 scale)
 Creates a transform from the given position, rotation and scale. More...
 
KAPI transformtransform_parent_get (transform *t)
 Returns a pointer to the provided transform's parent. More...
 
KAPI void transform_parent_set (transform *t, transform *parent)
 Sets the parent of the provided transform. More...
 
KAPI vec3 transform_position_get (const transform *t)
 Returns the position of the given transform. More...
 
KAPI void transform_position_set (transform *t, vec3 position)
 Sets the position of the given transform. More...
 
KAPI void transform_translate (transform *t, vec3 translation)
 Applies a translation to the given transform. Not the same as setting. More...
 
KAPI quat transform_rotation_get (const transform *t)
 Returns the rotation of the given transform. More...
 
KAPI void transform_rotation_set (transform *t, quat rotation)
 Sets the rotation of the given transform. More...
 
KAPI void transform_rotate (transform *t, quat rotation)
 Applies a rotation to the given transform. Not the same as setting. More...
 
KAPI vec3 transform_scale_get (const transform *t)
 Returns the scale of the given transform. More...
 
KAPI void transform_scale_set (transform *t, vec3 scale)
 Sets the scale of the given transform. More...
 
KAPI void transform_scale (transform *t, vec3 scale)
 Applies a scale to the given transform. Not the same as setting. More...
 
KAPI void transform_position_rotation_set (transform *t, vec3 position, quat rotation)
 Sets the position and rotation of the given transform. More...
 
KAPI void transform_position_rotation_scale_set (transform *t, vec3 position, quat rotation, vec3 scale)
 Sets the position, rotation and scale of the given transform. More...
 
KAPI void transform_translate_rotate (transform *t, vec3 translation, quat rotation)
 Applies translation and rotation to the given transform. More...
 
KAPI mat4 transform_local_get (transform *t)
 Retrieves the local transformation matrix from the provided transform. Automatically recalculates the matrix if it is dirty. Otherwise, the already calculated one is returned. More...
 
KAPI mat4 transform_world_get (transform *t)
 Obtains the world matrix of the given transform by examining its parent (if there is one) and multiplying it against the local matrix. More...
 

Function Documentation

◆ transform_create()

KAPI transform transform_create ( void  )

Creates and returns a new transform, using a zero vector for position, identity quaternion for rotation, and a one vector for scale. Also has a null parent. Marked dirty by default.

◆ transform_from_position()

KAPI transform transform_from_position ( vec3  position)

Creates a transform from the given position. Uses a zero rotation and a one scale.

Parameters
positionThe position to be used.
Returns
A new transform.

◆ transform_from_position_rotation()

KAPI transform transform_from_position_rotation ( vec3  position,
quat  rotation 
)

Creates a transform from the given position and rotation. Uses a one scale.

Parameters
positionThe position to be used.
rotationThe rotation to be used.
Returns
A new transform.

◆ transform_from_position_rotation_scale()

KAPI transform transform_from_position_rotation_scale ( vec3  position,
quat  rotation,
vec3  scale 
)

Creates a transform from the given position, rotation and scale.

Parameters
positionThe position to be used.
rotationThe rotation to be used.
scaleThe scale to be used.
Returns
A new transform.

◆ transform_from_rotation()

KAPI transform transform_from_rotation ( quat  rotation)

Creates a transform from the given rotation. Uses a zero position and a one scale.

Parameters
rotationThe rotation to be used.
Returns
A new transform.

◆ transform_local_get()

KAPI mat4 transform_local_get ( transform t)

Retrieves the local transformation matrix from the provided transform. Automatically recalculates the matrix if it is dirty. Otherwise, the already calculated one is returned.

Parameters
tA pointer to the transform whose matrix to retrieve.
Returns
A copy of the local transformation matrix.

◆ transform_parent_get()

KAPI transform* transform_parent_get ( transform t)

Returns a pointer to the provided transform's parent.

Parameters
tA pointer to the transform whose parent to retrieve.
Returns
A pointer to the parent transform.

◆ transform_parent_set()

KAPI void transform_parent_set ( transform t,
transform parent 
)

Sets the parent of the provided transform.

Parameters
tA pointer to the transform whose parent will be set.
parentA pointer to the parent transform.

◆ transform_position_get()

KAPI vec3 transform_position_get ( const transform t)

Returns the position of the given transform.

Parameters
tA constant pointer whose position to get.
Returns
A copy of the position.

◆ transform_position_rotation_scale_set()

KAPI void transform_position_rotation_scale_set ( transform t,
vec3  position,
quat  rotation,
vec3  scale 
)

Sets the position, rotation and scale of the given transform.

Parameters
tA pointer to the transform to be updated.
positionThe position to be set.
rotationThe rotation to be set.
scaleThe scale to be set.

◆ transform_position_rotation_set()

KAPI void transform_position_rotation_set ( transform t,
vec3  position,
quat  rotation 
)

Sets the position and rotation of the given transform.

Parameters
tA pointer to the transform to be updated.
positionThe position to be set.
rotationThe rotation to be set.

◆ transform_position_set()

KAPI void transform_position_set ( transform t,
vec3  position 
)

Sets the position of the given transform.

Parameters
tA pointer to the transform to be updated.
positionThe position to be set.

◆ transform_rotate()

KAPI void transform_rotate ( transform t,
quat  rotation 
)

Applies a rotation to the given transform. Not the same as setting.

Parameters
tA pointer to the transform to be updated.
rotationThe rotation to be applied.

◆ transform_rotation_get()

KAPI quat transform_rotation_get ( const transform t)

Returns the rotation of the given transform.

Parameters
tA constant pointer whose rotation to get.
Returns
A copy of the rotation.

◆ transform_rotation_set()

KAPI void transform_rotation_set ( transform t,
quat  rotation 
)

Sets the rotation of the given transform.

Parameters
tA pointer to the transform to be updated.
rotationThe rotation to be set.

◆ transform_scale()

KAPI void transform_scale ( transform t,
vec3  scale 
)

Applies a scale to the given transform. Not the same as setting.

Parameters
tA pointer to the transform to be updated.
scaleThe scale to be applied.

◆ transform_scale_get()

KAPI vec3 transform_scale_get ( const transform t)

Returns the scale of the given transform.

Parameters
tA constant pointer whose scale to get.
Returns
A copy of the scale.

◆ transform_scale_set()

KAPI void transform_scale_set ( transform t,
vec3  scale 
)

Sets the scale of the given transform.

Parameters
tA pointer to the transform to be updated.
scaleThe scale to be set.

◆ transform_translate()

KAPI void transform_translate ( transform t,
vec3  translation 
)

Applies a translation to the given transform. Not the same as setting.

Parameters
tA pointer to the transform to be updated.
translationThe translation to be applied.

◆ transform_translate_rotate()

KAPI void transform_translate_rotate ( transform t,
vec3  translation,
quat  rotation 
)

Applies translation and rotation to the given transform.

Parameters
tA pointer to the transform to be updated.
translationThe translation to be applied.
rotationThe rotation to be applied.
Returns
KAPI

◆ transform_world_get()

KAPI mat4 transform_world_get ( transform t)

Obtains the world matrix of the given transform by examining its parent (if there is one) and multiplying it against the local matrix.

Parameters
tA pointer to the transform whose world matrix to retrieve.
Returns
A copy of the world matrix.