Kohi Game Engine
editor_gizmo.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <defines.h>
4 #include <math/geometry.h>
5 #include <math/math_types.h>
7 
8 #include "identifiers/khandle.h"
9 
10 #if KOHI_DEBUG
12 #endif
13 
14 struct ray;
15 struct camera;
16 struct frame_data;
17 
18 typedef enum editor_gizmo_mode {
25 
34 
35 typedef struct editor_gizmo_mode_data {
38 
41 
43 
46 
50 
54 
61  // EDITOR_GIZMO_ORIENTATION_VIEW = 2,
64 
65 typedef struct editor_gizmo {
74 
77 
80 
83 
85 
87 
88 #if KOHI_DEBUG
89  debug_line3d plane_normal_line;
90 #endif
92 
95 
99 
103 KAPI void editor_gizmo_selected_transform_set(editor_gizmo* gizmo, khandle xform_handle, khandle parent_xform_handle);
104 
106 KAPI void editor_gizmo_render_frame_prepare(editor_gizmo* gizmo, const struct frame_data* p_frame_data);
107 
109 
110 KAPI void editor_gizmo_interaction_begin(editor_gizmo* gizmo, struct camera* c, struct ray* r, editor_gizmo_interaction_type interaction_type);
112 KAPI void editor_gizmo_handle_interaction(editor_gizmo* gizmo, struct camera* c, struct ray* r, editor_gizmo_interaction_type interaction_type);
113 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#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
float f32
32-bit floating point number
Definition: defines.h:47
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:19
KAPI b8 editor_gizmo_create(editor_gizmo *out_gizmo)
KAPI b8 editor_gizmo_unload(editor_gizmo *gizmo)
KAPI editor_gizmo_orientation editor_gizmo_orientation_get(editor_gizmo *gizmo)
KAPI void editor_gizmo_selected_transform_set(editor_gizmo *gizmo, khandle xform_handle, khandle parent_xform_handle)
struct editor_gizmo editor_gizmo
KAPI mat4 editor_gizmo_model_get(editor_gizmo *gizmo)
KAPI void editor_gizmo_orientation_set(editor_gizmo *gizmo, editor_gizmo_orientation orientation)
KAPI void editor_gizmo_refresh(editor_gizmo *gizmo)
KAPI void editor_gizmo_interaction_begin(editor_gizmo *gizmo, struct camera *c, struct ray *r, editor_gizmo_interaction_type interaction_type)
editor_gizmo_mode
Definition: editor_gizmo.h:18
@ EDITOR_GIZMO_MODE_ROTATE
Definition: editor_gizmo.h:21
@ EDITOR_GIZMO_MODE_NONE
Definition: editor_gizmo.h:19
@ EDITOR_GIZMO_MODE_SCALE
Definition: editor_gizmo.h:22
@ EDITOR_GIZMO_MODE_MOVE
Definition: editor_gizmo.h:20
@ EDITOR_GIZMO_MODE_MAX
Definition: editor_gizmo.h:23
KAPI b8 editor_gizmo_initialize(editor_gizmo *gizmo)
editor_gizmo_interaction_type
Definition: editor_gizmo.h:26
@ EDITOR_GIZMO_INTERACTION_TYPE_MOUSE_HOVER
Definition: editor_gizmo.h:28
@ EDITOR_GIZMO_INTERACTION_TYPE_NONE
Definition: editor_gizmo.h:27
@ EDITOR_GIZMO_INTERACTION_TYPE_MOUSE_DRAG
Definition: editor_gizmo.h:30
@ EDITOR_GIZMO_INTERACTION_TYPE_MOUSE_DOWN
Definition: editor_gizmo.h:29
@ EDITOR_GIZMO_INTERACTION_TYPE_CANCEL
Definition: editor_gizmo.h:32
@ EDITOR_GIZMO_INTERACTION_TYPE_MOUSE_UP
Definition: editor_gizmo.h:31
KAPI void editor_gizmo_interaction_end(editor_gizmo *gizmo)
struct editor_gizmo_mode_data editor_gizmo_mode_data
KAPI void editor_gizmo_mode_set(editor_gizmo *gizmo, editor_gizmo_mode mode)
KAPI void editor_gizmo_update(editor_gizmo *gizmo)
KAPI void editor_gizmo_destroy(editor_gizmo *gizmo)
KAPI void editor_gizmo_handle_interaction(editor_gizmo *gizmo, struct camera *c, struct ray *r, editor_gizmo_interaction_type interaction_type)
KAPI void editor_gizmo_render_frame_prepare(editor_gizmo *gizmo, const struct frame_data *p_frame_data)
editor_gizmo_orientation
Definition: editor_gizmo.h:55
@ EDITOR_GIZMO_ORIENTATION_MAX
The gizmo's transform operations are relative to the current view.
Definition: editor_gizmo.h:62
@ EDITOR_GIZMO_ORIENTATION_GLOBAL
The gizmo's transform operations are relative to global transform.
Definition: editor_gizmo.h:57
@ EDITOR_GIZMO_ORIENTATION_LOCAL
The gizmo's transform operations are relative to local transform.
Definition: editor_gizmo.h:59
KAPI b8 editor_gizmo_load(editor_gizmo *gizmo)
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.
This file contains the types for common resources the engine uses.
Represents a camera that can be used for a variety of things, especially rendering....
Definition: camera.h:21
Represents a single vertex in 3D space with position and colour data only.
Definition: math_types.h:249
Definition: debug_line3d.h:9
Definition: editor_gizmo.h:35
vec3 last_interaction_pos
Definition: editor_gizmo.h:52
plane_3d interaction_plane
Definition: editor_gizmo.h:48
u32 * indices
Definition: editor_gizmo.h:40
colour_vertex_3d * vertices
Definition: editor_gizmo.h:37
u32 index_count
Definition: editor_gizmo.h:39
kgeometry geo
Definition: editor_gizmo.h:42
u32 vertex_count
Definition: editor_gizmo.h:36
vec3 interaction_start_pos
Definition: editor_gizmo.h:51
extents_3d * mode_extents
Definition: editor_gizmo.h:45
plane_3d interaction_plane_back
Definition: editor_gizmo.h:49
u32 extents_count
Definition: editor_gizmo.h:44
u8 current_axis_index
Definition: editor_gizmo.h:47
Definition: editor_gizmo.h:65
editor_gizmo_orientation orientation
Indicates the editor transform operaton orientation.
Definition: editor_gizmo.h:79
khandle selected_xform_parent_handle
A handle to the parent of the currently selected object's transform, if one exists....
Definition: editor_gizmo.h:71
khandle xform_handle
The transform of the gizmo.
Definition: editor_gizmo.h:67
editor_gizmo_interaction_type interaction
Definition: editor_gizmo.h:84
editor_gizmo_mode mode
The current mode of the gizmo.
Definition: editor_gizmo.h:73
khandle selected_xform_handle
A handle to the currently selected object's transform. Invalid handle if nothing is selected.
Definition: editor_gizmo.h:69
editor_gizmo_mode_data mode_data[EDITOR_GIZMO_MODE_MAX+1]
The data for each mode of the gizmo.
Definition: editor_gizmo.h:82
b8 is_dirty
Definition: editor_gizmo.h:86
f32 scale_scalar
Used to keep the gizmo a consistent size on the screen despite camera distance.
Definition: editor_gizmo.h:76
Represents the extents of a 3d object.
Definition: math_types.h:213
Engine-level current frame-specific data.
Definition: frame_data.h:11
Represents geometry to be used for various purposes (rendering objects in the world,...
Definition: geometry.h:38
A handle is a unique identifier used a system in the engine to avoid using raw pointers where possibl...
Definition: khandle.h:25
Definition: math_types.h:256
Represents a line which starts at an origin and proceed infinitely in the given direction....
Definition: geometry_3d.h:9
a 4x4 matrix, typically used to represent object transformations.
Definition: math_types.h:195
A 3-element vector.
Definition: math_types.h:49