Displaying camera position and transform tool transformation space in top bar

dev
Shariq Shah 6 years ago
parent df19ee5e70
commit 69461c050e
  1. 78
      src/game/editor.c
  2. 1
      src/game/editor.h
  3. 2
      src/game/game.c
  4. 2
      src/game/transform.h
  5. 7
      todo.txt

@ -109,6 +109,7 @@ void editor_init(struct Editor* editor)
editor->camera_turn_speed = 50.f;
editor->camera_move_speed = 20.f;
editor->camera_sprint_multiplier = 2.f;
editor->current_transform_space = TS_WORLD;
editor->current_mode = EDITOR_MODE_NORMAL;
editor->current_axis = EDITOR_AXIS_XZ;
editor->previous_axis = EDITOR_AXIS_XZ;
@ -284,22 +285,10 @@ void editor_update(struct Editor* editor, float dt)
/* Top Panel */
if(nk_begin(context, "Top Panel", nk_recti(0, 0, win_width, editor->top_panel_height), NK_WINDOW_NO_SCROLLBAR))
{
static int frames = 0;
static int fps = 0;
static float seconds = 0.f;
seconds += dt;
frames++;
if(seconds >= 1.f)
{
fps = frames;
seconds = 0.f;
frames = 0;
}
const int row_height = 25.f;
nk_menubar_begin(context);
nk_layout_row_begin(context, NK_DYNAMIC, editor->top_panel_height - 5, 6);
nk_layout_row_begin(context, NK_DYNAMIC, editor->top_panel_height - 5, 8);
nk_layout_row_push(context, 0.03f);
if(nk_menu_begin_label(context, "File", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE, nk_vec2(150, 100)))
{
@ -333,16 +322,46 @@ void editor_update(struct Editor* editor, float dt)
nk_menu_end(context);
}
nk_layout_row_push(context, 0.6f);
nk_layout_row_push(context, 0.50f);
nk_spacing(context, 1);
nk_layout_row_push(context, 0.20f);
static const char* editor_modes[] = { "Normal", "Translate", "Rotate", "Scale" };
static const char* editor_axis[] = { "XY", "X", "Y", "Z" };
nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "Mode : %s Axis: %s", editor_modes[editor->current_mode], editor_axis[editor->current_axis]);
nk_layout_row_push(context, 0.1f);
static const char* editor_transformation_modes[] = { "Normal", "Translate", "Rotate", "Scale" };
static char transform_mode_line[32];
snprintf(&transform_mode_line, 32, "Mode : %s", editor_transformation_modes[editor->current_mode]);
if(nk_menu_begin_label(context, transform_mode_line, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, nk_vec2(180, 100)))
{
nk_menu_end(context);
}
nk_layout_row_push(context, 0.07f);
nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps);
nk_layout_row_push(context, 0.1f);
static const char* editor_transformation_spaces[] = { "Local", "Parent", "World" };
static char transform_space_text[32];
snprintf(&transform_space_text, 32, "Space : %s", editor_transformation_spaces[editor->current_transform_space]);
if(nk_menu_begin_label(context, transform_space_text, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, nk_vec2(180, 100)))
{
nk_menu_end(context);
}
nk_layout_row_push(context, 0.05f);
static const char* editor_axis[] = { "XZ", "X", "Y", "Z" };
static char axis_text[16];
snprintf(axis_text, 16, "Axis: %s", editor_axis[editor->current_axis]);
if(nk_menu_begin_label(context, axis_text, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, nk_vec2(180, 100)))
{
nk_menu_end(context);
}
nk_layout_row_push(context, 0.1f);
static char camera_text[32];
vec3 camera_position = { 0.f, 0.f, 0.f };
transform_get_absolute_position(&game_state->scene->cameras[CAM_EDITOR], &camera_position);
snprintf(camera_text, 32, "Camera: %.1f %.1f %.1f", camera_position.x, camera_position.y, camera_position.z);
if(nk_menu_begin_label(context, camera_text, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, nk_vec2(180, 100)))
{
nk_menu_end(context);
}
nk_menubar_end(context);
}
@ -351,7 +370,7 @@ void editor_update(struct Editor* editor, float dt)
/* Status Bar */
if(nk_begin(context, "Status Bar", nk_recti(0, win_height - editor->top_panel_height, win_width, editor->top_panel_height), NK_WINDOW_NO_SCROLLBAR))
{
nk_layout_row_begin(context, NK_DYNAMIC, editor->top_panel_height - 5, 5);
nk_layout_row_begin(context, NK_DYNAMIC, editor->top_panel_height - 5, 8);
nk_layout_row_push(context, 0.1f);
nk_labelf(context, NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE, "Cursor: %.1f %.1f %.1f", editor->tool_mesh_position.x, editor->tool_mesh_position.y, editor->tool_mesh_position.z);
@ -365,8 +384,23 @@ void editor_update(struct Editor* editor, float dt)
nk_layout_row_push(context, 0.1f);
nk_labelf(context, NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE, "Grid Length: %d", editor->grid_num_lines);
nk_layout_row_push(context, 0.6f);
nk_layout_row_push(context, 0.5f);
nk_spacing(context, 1);
nk_layout_row_push(context, 0.1f);
static int frames = 0;
static int fps = 0;
static float seconds = 0.f;
seconds += dt;
frames++;
if(seconds >= 1.f)
{
fps = frames;
seconds = 0.f;
frames = 0;
}
nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps);
}
nk_end(context);

@ -24,6 +24,7 @@ struct Editor
vec4 selected_entity_colour;
int current_mode;
int current_axis;
int current_transform_space;
int previous_axis;
int grid_enabled;
vec4 grid_color;

@ -783,7 +783,7 @@ void game_debug_gui(float dt)
nk_label(ctx, "Slider float", NK_TEXT_LEFT);
nk_slider_float(ctx, 0, &float_slider, 5.0, 0.5f);
nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar: %zu", prog_value);
nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar: %d", prog_value);
nk_progress(ctx, &prog_value, 100, NK_MODIFIABLE);
nk_layout_row(ctx, NK_STATIC, 25, 2, ratio);

@ -4,7 +4,7 @@
#include "../common/linmath.h"
#include "../common/num_types.h"
enum Transform_Space { TS_LOCAL, TS_PARENT, TS_WORLD};
enum Transform_Space { TS_LOCAL = 0, TS_PARENT, TS_WORLD};
struct Entity;

@ -1,5 +1,7 @@
Todo:
- Display editor camera information and speed adjustment in status bar or top bar
- Display editor camera parameter adjustment in top bar
- Display Transform mode selection in top bar
- Display Axis selection in top bar
- Add pre-render/post-render steps to deal with render order issues and culling lights before rendering
- Immediate mode render order, drawing axis and helpers on top of grid
- Better, more accurate picking
@ -9,6 +11,7 @@ Todo:
- Scale Mode
- Rotate Mode
- Add other axis combinations like YZ and XY to transform tool
- Transformation space selection for translation, rotation and scale.
- Use actual selected entity's mesh for tool mesh when the entity already has a mesh and use a placeholder like a sphere when there is not mesh
- Add warning to genie build script when running on windows and WindowsSdkVersion cannot be found. This happens when the script is not run from vcvarsall command prompt
- Improve README and add a screenshot to make the repository ready for making it public
@ -82,6 +85,7 @@ Bugs:
- Fix culling
- Fix bounding boxes not aligning in editor
- Investigate memory usage increase when window is minimized
- Fix hang on fullscreen toggle
Done:
* Input
@ -232,4 +236,5 @@ Done:
* Axis selection/cycling
* Axis switching and returning back to previously selected axis after releasing alt in translate mode
* Display tool/cursor location in editor statusbar
* Displaying camera position and tool transformation space in top bar

Loading…
Cancel
Save