Kohi Game Engine
simple_scene.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "defines.h"
4 #include "math/math_types.h"
6 
7 struct frame_data;
8 struct render_packet;
9 struct directional_light;
10 struct point_light;
11 struct mesh;
12 struct skybox;
13 struct geometry_config;
14 struct camera;
15 struct simple_scene_config;
16 struct terrain;
17 struct ray;
18 struct raycast_result;
19 struct transform;
20 struct viewport;
22 
23 typedef enum simple_scene_state {
37 
38 typedef struct pending_mesh {
39  struct mesh* m;
40 
41  const char* mesh_resource_name;
42 
46 
47 typedef struct simple_scene {
51 
52  char* name;
53  char* description;
54 
56 
57  // Singlular pointer to a directional light.
59 
60  // darray of point lights.
62 
63  // darray of meshes.
64  struct mesh* meshes;
65 
66  // darray of terrains.
67  struct terrain* terrains;
68 
69  // darray of meshes to be loaded.`
71 
72  // Singlular pointer to a skybox.
73  struct skybox* sb;
74 
75  // A grid for the scene.
77 
78  // A pointer to the scene configuration, if provided.
80 
82 
91 KAPI b8 simple_scene_create(void* config, simple_scene* out_scene);
92 
101 
109 
119 
127 KAPI b8 simple_scene_update(simple_scene* scene, const struct frame_data* p_frame_data);
128 
139 KAPI b8 simple_scene_populate_render_packet(simple_scene* scene, struct camera* current_camera, struct viewport* v, struct frame_data* p_frame_data, struct render_packet* packet);
140 
141 KAPI b8 simple_scene_raycast(simple_scene* scene, const struct ray* r, struct raycast_result* out_result);
142 
144 
145 KAPI b8 simple_scene_point_light_add(simple_scene* scene, const char* name, struct point_light* light);
146 
147 KAPI b8 simple_scene_mesh_add(simple_scene* scene, const char* name, struct mesh* m);
148 
149 KAPI b8 simple_scene_skybox_add(simple_scene* scene, const char* name, struct skybox* sb);
150 
151 KAPI b8 simple_scene_terrain_add(simple_scene* scene, const char* name, struct terrain* t);
152 
154 
156 
158 
160 
162 
164 
166 
167 KAPI struct mesh* simple_scene_mesh_get(simple_scene* scene, const char* name);
168 
169 KAPI struct skybox* simple_scene_skybox_get(simple_scene* scene, const char* name);
170 
172 
174 
175 KAPI b8 simple_scene_debug_render_data_query(simple_scene* scene, u32* data_count, struct geometry_render_data** debug_geometries);
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:177
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
Contains various math types required for the engine.
KAPI b8 simple_scene_populate_render_packet(simple_scene *scene, struct camera *current_camera, struct viewport *v, struct frame_data *p_frame_data, struct render_packet *packet)
Populate the given render packet with data from the provided scene.
KAPI struct skybox * simple_scene_skybox_get(simple_scene *scene, const char *name)
KAPI b8 simple_scene_unload(simple_scene *scene, b8 immediate)
Performs unloading routines and resource de-allocation on the given scene. A scene is also destroyed ...
KAPI struct transform * simple_scene_transform_get_by_id(simple_scene *scene, u32 unique_id)
KAPI struct point_light * simple_scene_point_light_get(simple_scene *scene, const char *name)
KAPI b8 simple_scene_skybox_remove(simple_scene *scene, const char *name)
KAPI b8 simple_scene_directional_light_remove(simple_scene *scene, const char *name)
KAPI b8 simple_scene_load(simple_scene *scene)
Performs loading routines and resource allocation on the given scene.
KAPI b8 simple_scene_update(simple_scene *scene, const struct frame_data *p_frame_data)
Performs any required scene updates for the given frame.
KAPI b8 simple_scene_mesh_add(simple_scene *scene, const char *name, struct mesh *m)
KAPI b8 simple_scene_initialize(simple_scene *scene)
Performs initialization routines on the scene, including processing configuration (if provided) and s...
KAPI b8 simple_scene_directional_light_add(simple_scene *scene, const char *name, struct directional_light *light)
KAPI struct terrain * simple_scene_terrain_get(simple_scene *scene, const char *name)
KAPI b8 simple_scene_skybox_add(simple_scene *scene, const char *name, struct skybox *sb)
KAPI b8 simple_scene_terrain_remove(simple_scene *scene, const char *name)
struct pending_mesh pending_mesh
KAPI b8 simple_scene_point_light_remove(simple_scene *scene, const char *name)
KAPI struct directional_light * simple_scene_directional_light_get(simple_scene *scene, const char *name)
KAPI b8 simple_scene_create(void *config, simple_scene *out_scene)
Creates a new scene with the given config with default values. No resources are allocated....
struct simple_scene simple_scene
KAPI struct mesh * simple_scene_mesh_get(simple_scene *scene, const char *name)
KAPI b8 simple_scene_debug_render_data_query(simple_scene *scene, u32 *data_count, struct geometry_render_data **debug_geometries)
KAPI b8 simple_scene_point_light_add(simple_scene *scene, const char *name, struct point_light *light)
KAPI b8 simple_scene_raycast(simple_scene *scene, const struct ray *r, struct raycast_result *out_result)
KAPI b8 simple_scene_mesh_remove(simple_scene *scene, const char *name)
KAPI b8 simple_scene_terrain_add(simple_scene *scene, const char *name, struct terrain *t)
simple_scene_state
Definition: simple_scene.h:23
@ SIMPLE_SCENE_STATE_UNLOADED
Unloaded and ready to be destroyed.
Definition: simple_scene.h:35
@ SIMPLE_SCENE_STATE_UNINITIALIZED
created, but nothing more.
Definition: simple_scene.h:25
@ SIMPLE_SCENE_STATE_INITIALIZED
Configuration parsed, not yet loaded hierarchy setup.
Definition: simple_scene.h:27
@ SIMPLE_SCENE_STATE_UNLOADING
In the process of unloading, not ready to play.
Definition: simple_scene.h:33
@ SIMPLE_SCENE_STATE_LOADING
In the process of loading the hierarchy.
Definition: simple_scene.h:29
@ SIMPLE_SCENE_STATE_LOADED
Everything is loaded, ready to play.
Definition: simple_scene.h:31
Represents a camera that can be used for a variety of things, especially rendering....
Definition: camera.h:21
Definition: debug_grid.h:40
A directional light, typically used to emulate sun/moon light.
Definition: light_system.h:28
char * name
The name of the directional light.
Definition: light_system.h:30
Engine-level current frame-specific data.
Definition: frame_data.h:16
Represents the configuration for a geometry.
Definition: geometry_system.h:31
Definition: renderer_types.h:15
Definition: resource_types.h:354
char * name
Definition: resource_types.h:355
Definition: simple_scene.h:38
const char * mesh_resource_name
Definition: simple_scene.h:41
struct mesh * m
Definition: simple_scene.h:39
u32 geometry_config_count
Definition: simple_scene.h:43
struct geometry_config ** g_configs
Definition: simple_scene.h:44
A point light, the most common light source, which radiates out from the given position.
Definition: light_system.h:56
char * name
The name of the light.
Definition: light_system.h:58
Represents a line which starts at an origin and proceed infinitely in the given direction....
Definition: geometry_3d.h:8
Definition: geometry_3d.h:25
A structure which is generated by the application and sent once to the renderer to render a given fra...
Definition: renderer_types.h:1018
Definition: resource_types.h:640
char * name
Definition: resource_types.h:641
Definition: simple_scene.h:47
struct terrain * terrains
Definition: simple_scene.h:67
struct point_light * point_lights
Definition: simple_scene.h:61
debug_grid grid
Definition: simple_scene.h:76
struct mesh * meshes
Definition: simple_scene.h:64
transform scene_transform
Definition: simple_scene.h:55
char * name
Definition: simple_scene.h:52
u32 id
Definition: simple_scene.h:48
char * description
Definition: simple_scene.h:53
pending_mesh * pending_meshes
Definition: simple_scene.h:70
struct simple_scene_config * config
Definition: simple_scene.h:79
simple_scene_state state
Definition: simple_scene.h:49
struct skybox * sb
Definition: simple_scene.h:73
b8 enabled
Definition: simple_scene.h:50
struct directional_light * dir_light
Definition: simple_scene.h:58
Definition: skybox.h:14
Definition: terrain.h:58
char * name
Definition: terrain.h:60
Represents the transform of an object in the world. Transforms can have a parent whose own transform ...
Definition: math_types.h:215
Definition: viewport.h:6