Kohi Game Engine
editor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "kui_types.h"
4 #include <core/frame_data.h>
5 #include <core/keymap.h>
6 #include <kui_system.h>
7 #include <platform/platform.h>
9 #include <world/world_types.h>
10 
11 #define EDITOR_AXIS_COLOUR_R \
12  (colour4){1.0f, 0.5f, 0.5f, 1.0f}
13 #define EDITOR_AXIS_COLOUR_G \
14  (colour4){0.5f, 1.0f, 0.5f, 1.0f}
15 #define EDITOR_AXIS_COLOUR_B \
16  (colour4){0.5f, 0.5f, 1.0f, 1.0f}
17 
18 #include "editor/editor_gizmo.h"
19 
23 
25 
27 
29 
32 
33 typedef enum editor_mode {
39 
40 typedef struct keditor_gizmo_pass_data {
44 
45 typedef struct editor_state {
46  // Editor camera
52  // Editor state
53  // Darray of selected entities.
56 
58 
59  // Pointer to the scene currently owned by the editor (NOT necessarily the scene owned by the game code currently!)
60  struct kscene* edit_scene;
63 
65  struct renderer_system_state* renderer;
68 
70 
72 
77 
78  // UI elements
80  kui_control editor_root;
81 
82  // Main window
83  kui_control main_bg_panel;
84  kui_control save_button;
85  kui_control mode_entity_button;
86  kui_control mode_scene_button;
87  kui_control mode_tree_button;
88  kui_control view_debug_checkbox;
89  kui_control view_bvh_checkbox;
90  kui_control view_grid_checkbox;
91 
92  // Scene Inspector window
94  // Beginning position of the entity inspector right column.
97  kui_control scene_inspector_title;
98  kui_control scene_name_label;
99  kui_control scene_name_textbox;
104 
105  // Entity Inspector window
107  // Beginning position of the entity inspector right column.
111  kui_control entity_name_label;
112  kui_control entity_name_textbox;
117 
123 
124  kui_control entity_scale_label;
128 
129  // Tree window
132  // Beginning position of the entity inspector right column.
135  kui_control tree_inspector_title;
138 
140 
141 KAPI b8 editor_initialize(u64* memory_requirement, struct editor_state* state);
142 KAPI void editor_shutdown(struct editor_state* state);
143 
144 KAPI b8 editor_open(struct editor_state* state, kname scene_name, kname scene_package_name);
146 KAPI void editor_set_mode(struct editor_state* state, editor_mode mode);
147 
149 KAPI void editor_select_entities(struct editor_state* state, u32 count, kentity* entities);
150 KAPI void editor_add_to_selected_entities(struct editor_state* state, u32 count, kentity* entities);
153 
154 KAPI void editor_update(struct editor_state* state, frame_data* p_frame_data);
155 KAPI void editor_frame_prepare(struct editor_state* state, frame_data* p_frame_data, b8 draw_gizmo, keditor_gizmo_pass_render_data* gizmo_pass_render_data);
156 KAPI b8 editor_render(struct editor_state* state, frame_data* p_frame_data, ktexture colour_buffer_target, b8 draw_gizmo, keditor_gizmo_pass_render_data* gizmo_pass_render_data);
157 
158 KAPI void editor_on_window_resize(struct editor_state* state, const struct kwindow* window);
159 
162 
u16 ktexture
Represents a texture to be used for rendering purposes, stored on the GPU (VRAM)
Definition: core_render_types.h:299
u16 kshader
Definition: core_render_types.h:176
#define KAPI
Import/export qualifier.
Definition: defines.h:209
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:27
_Bool b8
8-bit boolean type
Definition: defines.h:60
float f32
32-bit floating point number
Definition: defines.h:49
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:24
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:30
KAPI void editor_add_to_selected_entities(struct editor_state *state, u32 count, kentity *entities)
KAPI void editor_set_mode(struct editor_state *state, editor_mode mode)
KAPI b8 editor_close(struct editor_state *state)
KAPI b8 editor_open(struct editor_state *state, kname scene_name, kname scene_package_name)
struct keditor_gizmo_pass_render_data keditor_gizmo_pass_render_data
KAPI b8 editor_selection_contains(struct editor_state *state, kentity entity)
KAPI void editor_select_entities(struct editor_state *state, u32 count, kentity *entities)
KAPI void editor_destroy_keymaps(struct editor_state *state)
KAPI void editor_shutdown(struct editor_state *state)
KAPI void editor_update(struct editor_state *state, frame_data *p_frame_data)
KAPI void editor_clear_selected_entities(struct editor_state *state)
struct keditor_gizmo_pass_data keditor_gizmo_pass_data
struct editor_state editor_state
KAPI void editor_setup_keymaps(struct editor_state *state)
KAPI b8 editor_render(struct editor_state *state, frame_data *p_frame_data, ktexture colour_buffer_target, b8 draw_gizmo, keditor_gizmo_pass_render_data *gizmo_pass_render_data)
KAPI void editor_select_parent(struct editor_state *state)
KAPI b8 editor_initialize(u64 *memory_requirement, struct editor_state *state)
editor_mode
Definition: editor.h:33
@ EDITOR_MODE_ASSETS
Definition: editor.h:37
@ EDITOR_MODE_TREE
Definition: editor.h:36
@ EDITOR_MODE_SCENE
Definition: editor.h:34
@ EDITOR_MODE_ENTITY
Definition: editor.h:35
KAPI void editor_frame_prepare(struct editor_state *state, frame_data *p_frame_data, b8 draw_gizmo, keditor_gizmo_pass_render_data *gizmo_pass_render_data)
KAPI void editor_on_lib_unload(struct editor_state *state)
KAPI void editor_on_window_resize(struct editor_state *state, const struct kwindow *window)
KAPI void editor_on_lib_load(struct editor_state *state)
u8 kcamera
Definition: kcamera_system.h:28
This file contains the structures and functions required to implement keymaps and keybindings,...
u64 kname
A kname is a string hash made for quick comparisons versus traditional string comparisons.
Definition: kname.h:36
This file contains the platform layer, or at least the interface to it. Each platform should provide ...
u16 krenderbuffer
Definition: renderer_types.h:175
Definition: editor_gizmo.h:75
Definition: editor.h:45
kui_control entity_position_x_textbox
Definition: editor.h:114
krenderbuffer standard_vertex_buffer
Definition: editor.h:66
f32 entity_inspector_width
Definition: editor.h:106
editor_gizmo gizmo
Definition: editor.h:50
kui_state * kui_state
Definition: editor.h:79
kui_control entity_orientation_z_textbox
Definition: editor.h:121
kui_control scene_fog_colour_g_textbox
Definition: editor.h:102
b8 using_gizmo
Definition: editor.h:51
kui_control scene_name_textbox
Definition: editor.h:99
kentity * selection_list
Definition: editor.h:54
kui_control mode_entity_button
Definition: editor.h:85
u16 font_size
Definition: editor.h:73
u16 textbox_font_size
Definition: editor.h:75
kui_control entity_orientation_label
Definition: editor.h:118
f32 editor_camera_forward_move_speed
Definition: editor.h:48
kui_control mode_tree_button
Definition: editor.h:87
f32 editor_camera_backward_move_speed
Definition: editor.h:49
kui_control entity_position_y_textbox
Definition: editor.h:115
struct renderer_system_state * renderer
Definition: editor.h:65
kname scene_package_name
Definition: editor.h:62
kui_control tree_content_container
Definition: editor.h:137
kui_control entity_orientation_w_textbox
Definition: editor.h:122
kui_control tree_scrollable_control
Definition: editor.h:136
struct kscene * edit_scene
Definition: editor.h:60
kui_control save_button
Definition: editor.h:84
kname textbox_font_name
Definition: editor.h:76
kui_control main_bg_panel
Definition: editor.h:83
krenderbuffer index_buffer
Definition: editor.h:67
kui_control entity_name_textbox
Definition: editor.h:112
f32 tree_inspector_right_col_x
Definition: editor.h:133
b8 trigger_tree_refresh
Definition: editor.h:130
kui_control entity_orientation_y_textbox
Definition: editor.h:120
kui_control entity_inspector_title
Definition: editor.h:110
kcamera editor_camera
Definition: editor.h:47
kui_control view_grid_checkbox
Definition: editor.h:90
keditor_gizmo_pass_data editor_gizmo_pass
Definition: editor.h:64
kui_control scene_inspector_title
Definition: editor.h:97
f32 scene_inspector_right_col_x
Definition: editor.h:95
kui_control entity_inspector_bg_panel
Definition: editor.h:109
kui_control entity_scale_y_textbox
Definition: editor.h:126
kui_control entity_orientation_x_textbox
Definition: editor.h:119
kui_control entity_scale_z_textbox
Definition: editor.h:127
kname font_name
Definition: editor.h:74
keymap editor_keymap
Definition: editor.h:55
kui_control entity_scale_label
Definition: editor.h:124
editor_mode mode
Definition: editor.h:71
kui_control mode_scene_button
Definition: editor.h:86
f32 tree_inspector_width
Definition: editor.h:131
kui_control view_bvh_checkbox
Definition: editor.h:89
b8 is_running
Definition: editor.h:57
kui_control editor_root
Definition: editor.h:80
kui_control scene_fog_colour_label
Definition: editor.h:100
kui_control view_debug_checkbox
Definition: editor.h:88
kui_control scene_fog_colour_r_textbox
Definition: editor.h:101
kui_control tree_inspector_bg_panel
Definition: editor.h:134
f32 scene_inspector_width
Definition: editor.h:93
kui_control scene_fog_colour_b_textbox
Definition: editor.h:103
kui_control scene_inspector_bg_panel
Definition: editor.h:96
kname scene_asset_name
Definition: editor.h:61
kui_control entity_position_z_textbox
Definition: editor.h:116
f32 entity_inspector_right_col_x
Definition: editor.h:108
keditor_gizmo_pass_render_data * editor_gizmo_render_data
Definition: editor.h:69
kui_control scene_name_label
Definition: editor.h:98
kui_control entity_position_label
Definition: editor.h:113
kui_control entity_scale_x_textbox
Definition: editor.h:125
kui_control tree_inspector_title
Definition: editor.h:135
kui_control entity_name_label
Definition: editor.h:111
Engine-level current frame-specific data.
Definition: frame_data.h:15
Definition: kforward_renderer.h:275
Definition: editor.h:40
u32 set0_instance_id
Definition: editor.h:42
kshader gizmo_shader
Definition: editor.h:41
Definition: editor.h:20
mat4 projection
Definition: editor.h:21
mat4 view
Definition: editor.h:22
b8 do_pass
Definition: editor.h:30
mat4 gizmo_transform
Definition: editor.h:28
kdebug_geometry_render_data geometry
Definition: editor.h:26
b8 visible
Definition: editor.h:24
A keymap, which holds a list of keymap entries, each with a list of bindings. These are held in an in...
Definition: keymap.h:103
Represents a window in the application.
Definition: platform.h:71
a 4x4 matrix, typically used to represent object transformations.
Definition: math_types.h:383
u64 kentity
Definition: world_types.h:35