Kohi Game Engine
xform_system.h File Reference

Go to the source code of this file.

Data Structures

struct  xform_system_config
 

Typedefs

typedef struct xform_system_config xform_system_config
 

Functions

b8 xform_system_initialize (u64 *memory_requirement, void *state, void *config)
 
void xform_system_shutdown (void *state)
 
b8 xform_system_update (void *state, struct frame_data *p_frame_data)
 
KAPI khandle xform_create (void)
 Creates and returns a new xform, 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 khandle xform_from_position (vec3 position)
 Creates a xform from the given position. Uses a zero rotation and a one scale. More...
 
KAPI khandle xform_from_rotation (quat rotation)
 Creates a xform from the given rotation. Uses a zero position and a one scale. More...
 
KAPI khandle xform_from_position_rotation (vec3 position, quat rotation)
 Creates a xform from the given position and rotation. Uses a one scale. More...
 
KAPI khandle xform_from_position_rotation_scale (vec3 position, quat rotation, vec3 scale)
 Creates a xform from the given position, rotation and scale. More...
 
KAPI khandle xform_from_matrix (mat4 m)
 Creates a xform from the provided matrix. More...
 
KAPI void xform_destroy (khandle *t)
 Destroys the xform with the given handle, and frees the handle. More...
 
KAPI vec3 xform_position_get (khandle t)
 Returns the position of the given xform. More...
 
KAPI void xform_position_set (khandle t, vec3 position)
 Sets the position of the given xform. More...
 
KAPI void xform_translate (khandle t, vec3 translation)
 Applies a translation to the given xform. Not the same as setting. More...
 
KAPI quat xform_rotation_get (khandle t)
 Returns the rotation of the given xform. More...
 
KAPI void xform_rotation_set (khandle t, quat rotation)
 Sets the rotation of the given xform. More...
 
KAPI void xform_rotate (khandle t, quat rotation)
 Applies a rotation to the given xform. Not the same as setting. More...
 
KAPI vec3 xform_scale_get (khandle t)
 Returns the scale of the given xform. More...
 
KAPI void xform_scale_set (khandle t, vec3 scale)
 Sets the scale of the given xform. More...
 
KAPI void xform_scale (khandle t, vec3 scale)
 Applies a scale to the given xform. Not the same as setting. More...
 
KAPI void xform_position_rotation_set (khandle t, vec3 position, quat rotation)
 Sets the position and rotation of the given xform. More...
 
KAPI void xform_position_rotation_scale_set (khandle t, vec3 position, quat rotation, vec3 scale)
 Sets the position, rotation and scale of the given xform. More...
 
KAPI void xform_translate_rotate (khandle t, vec3 translation, quat rotation)
 Applies translation and rotation to the given xform. More...
 
KAPI void xform_calculate_local (khandle t)
 
KAPI mat4 xform_local_get (khandle t)
 Retrieves the local xformation matrix from the provided xform. Automatically recalculates the matrix if it is dirty. Otherwise, the already calculated one is returned. More...
 
KAPI void xform_world_set (khandle t, mat4 world)
 
KAPI mat4 xform_world_get (khandle t)
 Obtains the world matrix of the given xform. More...
 
KAPI const char * xform_to_string (khandle t)
 Returns a string representation of the xform pointed to by the given handle. More...
 
KAPI b8 xform_from_string (const char *str, khandle *out_xform)
 Creates an xform from the given string. More...
 

Typedef Documentation

◆ xform_system_config

Function Documentation

◆ xform_calculate_local()

KAPI void xform_calculate_local ( khandle  t)

Recalculates the local matrix for the transform with the given handle.

◆ xform_create()

KAPI khandle xform_create ( void  )

Creates and returns a new xform, 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.

Returns
A handle to the new xform.

◆ xform_destroy()

KAPI void xform_destroy ( khandle t)

Destroys the xform with the given handle, and frees the handle.

Parameters
tA pointer to a handle to the transform to be destroyed. The handle itself is also invalidated.

◆ xform_from_matrix()

KAPI khandle xform_from_matrix ( mat4  m)

Creates a xform from the provided matrix.

Parameters
mThe matrix to decompose and extract a transform from.
Returns
A handle to the new xform.

◆ xform_from_position()

KAPI khandle xform_from_position ( vec3  position)

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

Parameters
positionThe position to be used.
Returns
A handle to the new xform.

◆ xform_from_position_rotation()

KAPI khandle xform_from_position_rotation ( vec3  position,
quat  rotation 
)

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

Parameters
positionThe position to be used.
rotationThe rotation to be used.
Returns
A handle to the new xform.

◆ xform_from_position_rotation_scale()

KAPI khandle xform_from_position_rotation_scale ( vec3  position,
quat  rotation,
vec3  scale 
)

Creates a xform 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 handle to the new xform.

◆ xform_from_rotation()

KAPI khandle xform_from_rotation ( quat  rotation)

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

Parameters
rotationThe rotation to be used.
Returns
A handle to the new xform.

◆ xform_from_string()

KAPI b8 xform_from_string ( const char *  str,
khandle out_xform 
)

Creates an xform from the given string.

Parameters
strThe string from which to create the xform. Should be either 'x y z qx qy qz qw sx sy sz' (quaternion rotation) OR 'x y z ex ey ez sx sy sz' (euler rotation)
out_xformA pointer to hold the handle to the newly created xform.
Returns
True on success; otherwise false.

◆ xform_local_get()

KAPI mat4 xform_local_get ( khandle  t)

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

Parameters
tA handle to the xform whose matrix to retrieve.
Returns
A copy of the local xformation matrix.

◆ xform_position_get()

KAPI vec3 xform_position_get ( khandle  t)

Returns the position of the given xform.

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

◆ xform_position_rotation_scale_set()

KAPI void xform_position_rotation_scale_set ( khandle  t,
vec3  position,
quat  rotation,
vec3  scale 
)

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

Parameters
tA handle to the xform to be updated.
positionThe position to be set.
rotationThe rotation to be set.
scaleThe scale to be set.

◆ xform_position_rotation_set()

KAPI void xform_position_rotation_set ( khandle  t,
vec3  position,
quat  rotation 
)

Sets the position and rotation of the given xform.

Parameters
tA handle to the xform to be updated.
positionThe position to be set.
rotationThe rotation to be set.

◆ xform_position_set()

KAPI void xform_position_set ( khandle  t,
vec3  position 
)

Sets the position of the given xform.

Parameters
tA handle to the xform to be updated.
positionThe position to be set.

◆ xform_rotate()

KAPI void xform_rotate ( khandle  t,
quat  rotation 
)

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

Parameters
tA handle to the xform to be updated.
rotationThe rotation to be applied.

◆ xform_rotation_get()

KAPI quat xform_rotation_get ( khandle  t)

Returns the rotation of the given xform.

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

◆ xform_rotation_set()

KAPI void xform_rotation_set ( khandle  t,
quat  rotation 
)

Sets the rotation of the given xform.

Parameters
tA handle to the xform to be updated.
rotationThe rotation to be set.

◆ xform_scale()

KAPI void xform_scale ( khandle  t,
vec3  scale 
)

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

Parameters
tA handle to the xform to be updated.
scaleThe scale to be applied.

◆ xform_scale_get()

KAPI vec3 xform_scale_get ( khandle  t)

Returns the scale of the given xform.

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

◆ xform_scale_set()

KAPI void xform_scale_set ( khandle  t,
vec3  scale 
)

Sets the scale of the given xform.

Parameters
tA handle to the xform to be updated.
scaleThe scale to be set.

◆ xform_system_initialize()

b8 xform_system_initialize ( u64 memory_requirement,
void *  state,
void *  config 
)

◆ xform_system_shutdown()

void xform_system_shutdown ( void *  state)

◆ xform_system_update()

b8 xform_system_update ( void *  state,
struct frame_data p_frame_data 
)

◆ xform_to_string()

KAPI const char* xform_to_string ( khandle  t)

Returns a string representation of the xform pointed to by the given handle.

Parameters
tA handle to the xform to retrieve as a string.
Returns
The xform in string format.

◆ xform_translate()

KAPI void xform_translate ( khandle  t,
vec3  translation 
)

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

Parameters
tA handle to the xform to be updated.
translationThe translation to be applied.

◆ xform_translate_rotate()

KAPI void xform_translate_rotate ( khandle  t,
vec3  translation,
quat  rotation 
)

Applies translation and rotation to the given xform.

Parameters
tA handle to the xform to be updated.
translationThe translation to be applied.
rotationThe rotation to be applied.
Returns
KAPI

◆ xform_world_get()

KAPI mat4 xform_world_get ( khandle  t)

Obtains the world matrix of the given xform.

Parameters
tA handle to the xform whose world matrix to retrieve.
Returns
A copy of the world matrix.

◆ xform_world_set()

KAPI void xform_world_set ( khandle  t,
mat4  world 
)