Kohi Game Engine
xform_system.h
Go to the documentation of this file.
1 #ifndef _XFORM_SYSTEM_H_
2 #define _XFORM_SYSTEM_H_
3 
5 #include "identifiers/khandle.h"
6 #include "math/math_types.h"
7 
8 struct frame_data;
9 
10 typedef struct xform_system_config {
11  // The initial number of slots to allocate for xforms on startup.
14 
15 b8 xform_system_initialize(u64* memory_requirement, void* state, void* config);
16 
17 void xform_system_shutdown(void* state);
18 
19 b8 xform_system_update(void* state, struct frame_data* p_frame_data);
20 
29 
38 
47 
57 
67 
75 
81 
89 
96 KAPI void xform_position_set(khandle t, vec3 position);
97 
105 KAPI void xform_translate(khandle t, vec3 translation);
106 
114 
122 
130 KAPI void xform_rotate(khandle t, quat rotation);
131 
139 
147 
155 KAPI void xform_scale(khandle t, vec3 scale);
156 
164 KAPI void xform_position_rotation_set(khandle t, vec3 position, quat rotation);
165 
174 KAPI void xform_position_rotation_scale_set(khandle t, vec3 position, quat rotation, vec3 scale);
175 
184 KAPI void xform_translate_rotate(khandle t, vec3 translation, quat rotation);
185 
190 
200 
202 
210 
217 KAPI const char* xform_to_string(khandle t);
218 
226 KAPI b8 xform_from_string(const char* str, khandle* out_xform);
227 
228 #endif
#define KAPI
Import/export qualifier.
Definition: defines.h:205
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
Contains a system for creating numeric identifiers.
A global handle system for Kohi. Handles are used to obtain various resources using a unique handle i...
Contains various math types required for the engine.
Engine-level current frame-specific data.
Definition: frame_data.h:11
A handle is a unique identifier used a system in the engine to avoid using raw pointers where possibl...
Definition: khandle.h:25
Definition: xform_system.h:10
u32 initial_slot_count
Definition: xform_system.h:12
a 4x4 matrix, typically used to represent object transformations.
Definition: math_types.h:195
A 3-element vector.
Definition: math_types.h:49
A 4-element vector.
Definition: math_types.h:89
KAPI mat4 xform_local_get(khandle t)
Retrieves the local xformation matrix from the provided xform. Automatically recalculates the matrix ...
KAPI void xform_position_set(khandle t, vec3 position)
Sets the position of the given xform.
b8 xform_system_update(void *state, struct frame_data *p_frame_data)
KAPI khandle xform_from_position(vec3 position)
Creates a xform from the given position. Uses a zero rotation and a one scale.
KAPI vec3 xform_position_get(khandle t)
Returns the position of the given xform.
void xform_system_shutdown(void *state)
KAPI void xform_translate_rotate(khandle t, vec3 translation, quat rotation)
Applies translation and rotation to the given xform.
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.
KAPI void xform_scale_set(khandle t, vec3 scale)
Sets the scale of the given xform.
KAPI void xform_scale(khandle t, vec3 scale)
Applies a scale to the given xform. Not the same as setting.
KAPI khandle xform_from_position_rotation_scale(vec3 position, quat rotation, vec3 scale)
Creates a xform from the given position, rotation and scale.
KAPI const char * xform_to_string(khandle t)
Returns a string representation of the xform pointed to by the given handle.
KAPI void xform_rotation_set(khandle t, quat rotation)
Sets the rotation of the given xform.
struct xform_system_config xform_system_config
KAPI void xform_destroy(khandle *t)
Destroys the xform with the given handle, and frees the handle.
KAPI khandle xform_from_rotation(quat rotation)
Creates a xform from the given rotation. Uses a zero position and a one scale.
KAPI khandle xform_from_position_rotation(vec3 position, quat rotation)
Creates a xform from the given position and rotation. Uses a one scale.
KAPI b8 xform_from_string(const char *str, khandle *out_xform)
Creates an xform from the given string.
KAPI void xform_position_rotation_set(khandle t, vec3 position, quat rotation)
Sets the position and rotation of the given xform.
KAPI vec3 xform_scale_get(khandle t)
Returns the scale of the given xform.
KAPI khandle xform_from_matrix(mat4 m)
Creates a xform from the provided matrix.
KAPI void xform_translate(khandle t, vec3 translation)
Applies a translation to the given xform. Not the same as setting.
KAPI mat4 xform_world_get(khandle t)
Obtains the world matrix of the given xform.
b8 xform_system_initialize(u64 *memory_requirement, void *state, void *config)
KAPI khandle xform_create(void)
Creates and returns a new xform, using a zero vector for position, identity quaternion for rotation,...
KAPI void xform_world_set(khandle t, mat4 world)
KAPI void xform_calculate_local(khandle t)
KAPI void xform_rotate(khandle t, quat rotation)
Applies a rotation to the given xform. Not the same as setting.
KAPI quat xform_rotation_get(khandle t)
Returns the rotation of the given xform.