Kohi Game Engine
scene.h File Reference

Go to the source code of this file.

Data Structures

struct  scene_attachment
 
struct  scene_node_metadata
 
struct  scene_static_mesh_metadata
 
struct  scene_terrain_metadata
 
struct  scene_skybox_metadata
 
struct  scene_water_plane_metadata
 
struct  scene
 

Typedefs

typedef enum scene_state scene_state
 
typedef struct scene_attachment scene_attachment
 
typedef enum scene_flag scene_flag
 
typedef u32 scene_flags
 
typedef struct scene_node_metadata scene_node_metadata
 
typedef struct scene_static_mesh_metadata scene_static_mesh_metadata
 
typedef struct scene_terrain_metadata scene_terrain_metadata
 
typedef struct scene_skybox_metadata scene_skybox_metadata
 
typedef struct scene_water_plane_metadata scene_water_plane_metadata
 
typedef struct scene scene
 

Enumerations

enum  scene_state {
  SCENE_STATE_UNINITIALIZED , SCENE_STATE_INITIALIZED , SCENE_STATE_LOADING , SCENE_STATE_LOADED ,
  SCENE_STATE_UNLOADING , SCENE_STATE_UNLOADED
}
 
enum  scene_flag { SCENE_FLAG_NONE = 0 , SCENE_FLAG_READONLY = 1 }
 

Functions

KAPI b8 scene_create (kasset_scene *config, scene_flags flags, scene *out_scene)
 Creates a new scene with the given config with default values. No resources are allocated. Config is not yet processed. More...
 
KAPI b8 scene_initialize (scene *scene)
 Performs initialization routines on the scene, including processing configuration (if provided) and scaffolding heirarchy. More...
 
KAPI b8 scene_load (scene *scene)
 Performs loading routines and resource allocation on the given scene. More...
 
KAPI b8 scene_unload (scene *scene, b8 immediate)
 Performs unloading routines and resource de-allocation on the given scene. A scene is also destroyed when unloading. More...
 
KAPI void scene_destroy (scene *s)
 Destroys the scene, releasing any remaining resources held by it. Automatically triggers unload if scene is currently loaded. More...
 
KAPI b8 scene_update (scene *scene, const struct frame_data *p_frame_data)
 Performs any required scene updates for the given frame. More...
 
KAPI void scene_render_frame_prepare (scene *scene, const struct frame_data *p_frame_data)
 
KAPI void scene_update_lod_from_view_position (scene *scene, const struct frame_data *p_frame_data, vec3 view_position, f32 near_clip, f32 far_clip)
 Updates LODs of items in the scene based on the given position and clipping distances. More...
 
KAPI b8 scene_raycast (scene *scene, const struct ray *r, struct raycast_result *out_result)
 
KAPI b8 scene_debug_render_data_query (scene *scene, u32 *data_count, struct geometry_render_data **debug_geometries)
 
KAPI b8 scene_mesh_render_data_query (const scene *scene, const frustum *f, vec3 center, struct frame_data *p_frame_data, u32 *out_count, struct geometry_render_data **out_geometries)
 
KAPI b8 scene_mesh_render_data_query_from_line (const scene *scene, vec3 direction, vec3 center, f32 radius, struct frame_data *p_frame_data, u32 *out_count, struct geometry_render_data **out_geometries)
 
KAPI b8 scene_terrain_render_data_query (const scene *scene, const frustum *f, vec3 center, struct frame_data *p_frame_data, u32 *out_count, struct geometry_render_data **out_terrain_geometries)
 
KAPI b8 scene_terrain_render_data_query_from_line (const scene *scene, vec3 direction, vec3 center, f32 radius, struct frame_data *p_frame_data, u32 *out_count, struct geometry_render_data **out_geometries)
 
KAPI b8 scene_water_plane_query (const scene *scene, const frustum *f, vec3 center, struct frame_data *p_frame_data, u32 *out_count, struct water_plane ***out_water_planes)
 
KAPI b8 scene_node_xform_get_by_name (const scene *scene, kname name, khandle *out_xform_handle)
 
KAPI b8 scene_node_xform_get (const scene *scene, khandle node_handle, khandle *out_xform_handle)
 
KAPI b8 scene_node_local_matrix_get (const scene *scene, khandle node_handle, mat4 *out_matrix)
 
KAPI b8 scene_node_local_matrix_get_by_name (const scene *scene, kname name, mat4 *out_matrix)
 
KAPI b8 scene_node_exists (const scene *s, kname name)
 
KAPI b8 scene_node_child_count_get (const scene *s, kname name, u32 *out_child_count)
 
KAPI b8 scene_node_child_name_get_by_index (const scene *s, kname name, u32 index, kname *out_child_name)
 
KAPI b8 scene_save (scene *s)
 

Typedef Documentation

◆ scene

typedef struct scene scene

◆ scene_attachment

◆ scene_flag

typedef enum scene_flag scene_flag

◆ scene_flags

typedef u32 scene_flags

◆ scene_node_metadata

◆ scene_skybox_metadata

◆ scene_state

typedef enum scene_state scene_state

◆ scene_static_mesh_metadata

◆ scene_terrain_metadata

◆ scene_water_plane_metadata

Enumeration Type Documentation

◆ scene_flag

enum scene_flag
Enumerator
SCENE_FLAG_NONE 
SCENE_FLAG_READONLY 

◆ scene_state

Enumerator
SCENE_STATE_UNINITIALIZED 

created, but nothing more.

SCENE_STATE_INITIALIZED 

Configuration parsed, not yet loaded hierarchy setup.

SCENE_STATE_LOADING 

In the process of loading the hierarchy.

SCENE_STATE_LOADED 

Everything is loaded, ready to play.

SCENE_STATE_UNLOADING 

In the process of unloading, not ready to play.

SCENE_STATE_UNLOADED 

Unloaded and ready to be destroyed.

Function Documentation

◆ scene_create()

KAPI b8 scene_create ( kasset_scene config,
scene_flags  flags,
scene out_scene 
)

Creates a new scene with the given config with default values. No resources are allocated. Config is not yet processed.

Parameters
configA pointer to the configuration resource. Optional.
flagsFlags to be used during creation (i.e. read-only, etc.).
out_sceneA pointer to hold the newly created scene. Required.
Returns
True on success; otherwise false.

◆ scene_debug_render_data_query()

KAPI b8 scene_debug_render_data_query ( scene scene,
u32 data_count,
struct geometry_render_data **  debug_geometries 
)

◆ scene_destroy()

KAPI void scene_destroy ( scene s)

Destroys the scene, releasing any remaining resources held by it. Automatically triggers unload if scene is currently loaded.

Parameters
sA pointer to the scene to be destroyed.

◆ scene_initialize()

KAPI b8 scene_initialize ( scene scene)

Performs initialization routines on the scene, including processing configuration (if provided) and scaffolding heirarchy.

Parameters
sceneA pointer to the scene to be initialized.
Returns
True on success; otherwise false.

◆ scene_load()

KAPI b8 scene_load ( scene scene)

Performs loading routines and resource allocation on the given scene.

Parameters
sceneA pointer to the scene to be loaded.
Returns
True on success; otherwise false.

◆ scene_mesh_render_data_query()

KAPI b8 scene_mesh_render_data_query ( const scene scene,
const frustum f,
vec3  center,
struct frame_data p_frame_data,
u32 out_count,
struct geometry_render_data **  out_geometries 
)

◆ scene_mesh_render_data_query_from_line()

KAPI b8 scene_mesh_render_data_query_from_line ( const scene scene,
vec3  direction,
vec3  center,
f32  radius,
struct frame_data p_frame_data,
u32 out_count,
struct geometry_render_data **  out_geometries 
)

◆ scene_node_child_count_get()

KAPI b8 scene_node_child_count_get ( const scene s,
kname  name,
u32 out_child_count 
)

◆ scene_node_child_name_get_by_index()

KAPI b8 scene_node_child_name_get_by_index ( const scene s,
kname  name,
u32  index,
kname out_child_name 
)

◆ scene_node_exists()

KAPI b8 scene_node_exists ( const scene s,
kname  name 
)

◆ scene_node_local_matrix_get()

KAPI b8 scene_node_local_matrix_get ( const scene scene,
khandle  node_handle,
mat4 out_matrix 
)

◆ scene_node_local_matrix_get_by_name()

KAPI b8 scene_node_local_matrix_get_by_name ( const scene scene,
kname  name,
mat4 out_matrix 
)

◆ scene_node_xform_get()

KAPI b8 scene_node_xform_get ( const scene scene,
khandle  node_handle,
khandle out_xform_handle 
)

◆ scene_node_xform_get_by_name()

KAPI b8 scene_node_xform_get_by_name ( const scene scene,
kname  name,
khandle out_xform_handle 
)

◆ scene_raycast()

KAPI b8 scene_raycast ( scene scene,
const struct ray r,
struct raycast_result out_result 
)

◆ scene_render_frame_prepare()

KAPI void scene_render_frame_prepare ( scene scene,
const struct frame_data p_frame_data 
)

◆ scene_save()

KAPI b8 scene_save ( scene s)

◆ scene_terrain_render_data_query()

KAPI b8 scene_terrain_render_data_query ( const scene scene,
const frustum f,
vec3  center,
struct frame_data p_frame_data,
u32 out_count,
struct geometry_render_data **  out_terrain_geometries 
)

◆ scene_terrain_render_data_query_from_line()

KAPI b8 scene_terrain_render_data_query_from_line ( const scene scene,
vec3  direction,
vec3  center,
f32  radius,
struct frame_data p_frame_data,
u32 out_count,
struct geometry_render_data **  out_geometries 
)

◆ scene_unload()

KAPI b8 scene_unload ( scene scene,
b8  immediate 
)

Performs unloading routines and resource de-allocation on the given scene. A scene is also destroyed when unloading.

Parameters
sceneA pointer to the scene to be unloaded.
immediateUnload immediately instead of the next frame. NOTE: can have unintended side effects if used improperly.
Returns
True on success; otherwise false.

◆ scene_update()

KAPI b8 scene_update ( scene scene,
const struct frame_data p_frame_data 
)

Performs any required scene updates for the given frame.

Parameters
sceneA pointer to the scene to be updated.
p_frame_dataA constant pointer to the current frame's data.
Returns
True on success; otherwise false.

◆ scene_update_lod_from_view_position()

KAPI void scene_update_lod_from_view_position ( scene scene,
const struct frame_data p_frame_data,
vec3  view_position,
f32  near_clip,
f32  far_clip 
)

Updates LODs of items in the scene based on the given position and clipping distances.

Parameters
sceneA pointer to the scene to be updated.
p_frame_dataA constant pointer to the current frame's data.
view_positionThe view position to use for LOD calculation.
near_clipThe near clipping distance from the view position.
far_clipThe far clipping distance from the view position.

◆ scene_water_plane_query()

KAPI b8 scene_water_plane_query ( const scene scene,
const frustum f,
vec3  center,
struct frame_data p_frame_data,
u32 out_count,
struct water_plane ***  out_water_planes 
)