Changed property inspector to show local transform values by default entities and show absolute values as read-only

dev
Shariq Shah 6 years ago
parent 882880b7cf
commit 7e769eb64f
  1. 2
      src/common/version.h
  2. 72
      src/game/editor.c
  3. 8
      src/game/transform.c
  4. 2
      src/game/transform.h
  5. 4
      todo.txt

@ -4,7 +4,7 @@
/* Auto generated version file. DO NOT MODIFY */ /* Auto generated version file. DO NOT MODIFY */
#define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MAJOR 0
#define SYMMETRY_VERSION_MINOR 1 #define SYMMETRY_VERSION_MINOR 1
#define SYMMETRY_VERSION_REVISION 340 #define SYMMETRY_VERSION_REVISION 341
#define SYMMETRY_VERSION_BRANCH "dev" #define SYMMETRY_VERSION_BRANCH "dev"
#endif #endif

@ -213,7 +213,7 @@ void editor_render(struct Editor* editor, struct Camera * active_camera)
vec3 abs_pos; vec3 abs_pos;
quat abs_rot; quat abs_rot;
transform_get_absolute_position(editor->selected_entity, &abs_pos); transform_get_absolute_position(editor->selected_entity, &abs_pos);
transform_get_absolute_rot(editor->selected_entity, &abs_rot); transform_get_absolute_rotation(editor->selected_entity, &abs_rot);
switch(editor->selected_entity->type) switch(editor->selected_entity->type)
{ {
case ET_LIGHT: case ET_LIGHT:
@ -319,7 +319,7 @@ void editor_render(struct Editor* editor, struct Camera * active_camera)
vec3 abs_pos; vec3 abs_pos;
quat abs_rot; quat abs_rot;
transform_get_absolute_position(editor->hovered_entity, &abs_pos); transform_get_absolute_position(editor->hovered_entity, &abs_pos);
transform_get_absolute_rot(editor->hovered_entity, &abs_rot); transform_get_absolute_rotation(editor->hovered_entity, &abs_rot);
im_sphere(1.f, abs_pos, abs_rot, editor->hovered_entity_color, GDM_TRIANGLES, 4); im_sphere(1.f, abs_pos, abs_rot, editor->hovered_entity_color, GDM_TRIANGLES, 4);
} }
} }
@ -1889,15 +1889,15 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor*
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED);
vec3 abs_pos = { 0.f, 0.f, 0.f }; vec3 abs_pos = { 0.f, 0.f, 0.f };
transform_get_absolute_position(entity, &abs_pos); transform_get_absolute_position(entity, &abs_pos);
if(editor_widget_v3(context, &abs_pos, "#X", "#Y", "#Z", -FLT_MAX, FLT_MAX, 1.f, 1.f, row_height)) transform_set_position(entity, &abs_pos); //if(editor_widget_v3(context, &abs_pos, "#X", "#Y", "#Z", -FLT_MAX, FLT_MAX, 1.f, 1.f, row_height)) transform_set_position(entity, &abs_pos);
if(editor_widget_v3(context, &entity->transform.position, "#X", "#Y", "#Z", -FLT_MAX, FLT_MAX, 1.f, 1.f, row_height))
transform_update_transmat(entity);
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED);
quat abs_rot = { 0.f, 0.f, 0.f, 1.f };
transform_get_absolute_rot(entity, &abs_rot);
vec3 rot_angles = { 0.f, 0.f, 0.f }; vec3 rot_angles = { 0.f, 0.f, 0.f };
rot_angles.x = quat_get_pitch(&abs_rot); rot_angles.x = quat_get_pitch(&entity->transform.rotation);
rot_angles.y = quat_get_yaw(&abs_rot); rot_angles.y = quat_get_yaw(&entity->transform.rotation);
rot_angles.z = quat_get_roll(&abs_rot); rot_angles.z = quat_get_roll(&entity->transform.rotation);
vec3 curr_rot = { rot_angles.x, rot_angles.y, rot_angles.z }; vec3 curr_rot = { rot_angles.x, rot_angles.y, rot_angles.z };
nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "#X", -FLT_MAX, &curr_rot.x, FLT_MAX, 5.f, 1.f); nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "#X", -FLT_MAX, &curr_rot.x, FLT_MAX, 5.f, 1.f);
@ -1912,17 +1912,31 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor*
vec3 AXIS_Z = { 0.f, 0.f, 1.f }; vec3 AXIS_Z = { 0.f, 0.f, 1.f };
const float epsilon = 0.0001f; const float epsilon = 0.0001f;
if(fabsf(delta.x) > epsilon) transform_rotate(entity, &AXIS_X, delta.x, TS_WORLD); if(fabsf(delta.x) > epsilon) transform_rotate(entity, &AXIS_X, delta.x, TS_LOCAL);
if(fabsf(delta.y) > epsilon) transform_rotate(entity, &AXIS_Y, delta.y, TS_WORLD); if(fabsf(delta.y) > epsilon) transform_rotate(entity, &AXIS_Y, delta.y, TS_LOCAL);
if(fabsf(delta.z) > epsilon) transform_rotate(entity, &AXIS_Z, delta.z, TS_WORLD); if(fabsf(delta.z) > epsilon) transform_rotate(entity, &AXIS_Z, delta.z, TS_LOCAL);
nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED);
vec3 abs_scale = { 0.f, 0.f, 0.f }; if(editor_widget_v3(context, &entity->transform.scale, "#X", "#Y", "#Z", 0.1f, FLT_MAX, 1.f, 0.1f, row_height))
transform_get_absolute_scale(entity, &abs_scale);
if(editor_widget_v3(context, &abs_scale, "#X", "#Y", "#Z", 0.1f, FLT_MAX, 1.f, 0.1f, row_height))
{
entity->transform.scale = abs_scale;
transform_update_transmat(entity); transform_update_transmat(entity);
if(nk_tree_push(context, NK_TREE_NODE, "Absolute Transform Values", NK_MINIMIZED))
{
vec3 abs_pos, abs_rot_angles, abs_scale;
quat abs_rot;
transform_get_absolute_position(entity, &abs_pos);
transform_get_absolute_scale(entity, &abs_scale);
transform_get_absolute_rotation(entity, &abs_rot);
abs_rot_angles.x = quat_get_pitch(&abs_rot);
abs_rot_angles.y = quat_get_yaw(&abs_rot);
abs_rot_angles.z = quat_get_roll(&abs_rot);
nk_layout_row_dynamic(context, row_height, 2);
nk_label(context, "Position", LABEL_FLAGS_ALIGN_LEFT); nk_labelf(context, LABEL_FLAGS_ALIGN_RIGHT, "%.1f %.1f %.1f", abs_pos.x, abs_pos.y, abs_pos.z);
nk_label(context, "Rotation", LABEL_FLAGS_ALIGN_LEFT); nk_labelf(context, LABEL_FLAGS_ALIGN_RIGHT, "%.1f %.1f %.1f", abs_rot_angles.x, abs_rot_angles.y, abs_rot_angles.z);
nk_label(context, "Scale", LABEL_FLAGS_ALIGN_LEFT); nk_labelf(context, LABEL_FLAGS_ALIGN_RIGHT, "%.1f %.1f %.1f", abs_scale.x, abs_scale.y, abs_scale.z);
nk_tree_pop(context);
} }
if(nk_tree_push(context, NK_TREE_TAB, "Bounding Box", NK_MINIMIZED)) if(nk_tree_push(context, NK_TREE_TAB, "Bounding Box", NK_MINIMIZED))
@ -2329,6 +2343,31 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor*
nk_label(context, "Default Color", LABEL_FLAGS_ALIGN_LEFT); editor_widget_color_combov4(context, &enemy->Turret.color_default, 50, row_height * 2); nk_label(context, "Default Color", LABEL_FLAGS_ALIGN_LEFT); editor_widget_color_combov4(context, &enemy->Turret.color_default, 50, row_height * 2);
nk_label(context, "Alert Color", LABEL_FLAGS_ALIGN_LEFT); editor_widget_color_combov4(context, &enemy->Turret.color_alert, 50, row_height * 2); nk_label(context, "Alert Color", LABEL_FLAGS_ALIGN_LEFT); editor_widget_color_combov4(context, &enemy->Turret.color_alert, 50, row_height * 2);
nk_label(context, "Attack Color", LABEL_FLAGS_ALIGN_LEFT); editor_widget_color_combov4(context, &enemy->Turret.color_attack, 50, row_height * 2); nk_label(context, "Attack Color", LABEL_FLAGS_ALIGN_LEFT); editor_widget_color_combov4(context, &enemy->Turret.color_attack, 50, row_height * 2);
nk_layout_row_dynamic(context, row_height, 1);
if(nk_button_label(context, "Select Weapon Sound"))
{
editor_entity_select(editor, enemy->weapon_sound);
nk_tree_pop(context);
nk_end(context);
return;
}
if(nk_button_label(context, "Select Ambient Sound"))
{
editor_entity_select(editor, enemy->ambient_sound);
nk_tree_pop(context);
nk_end(context);
return;
}
if(nk_button_label(context, "Select Static Mesh"))
{
editor_entity_select(editor, enemy->mesh);
nk_tree_pop(context);
nk_end(context);
return;
}
} }
break; break;
} }
@ -2379,6 +2418,7 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor*
nk_checkbox_flags_label(context, "Red", &door->mask, DOOR_KEY_MASK_RED); nk_checkbox_flags_label(context, "Red", &door->mask, DOOR_KEY_MASK_RED);
nk_checkbox_flags_label(context, "Green", &door->mask, DOOR_KEY_MASK_GREEN); nk_checkbox_flags_label(context, "Green", &door->mask, DOOR_KEY_MASK_GREEN);
nk_checkbox_flags_label(context, "Blue", &door->mask, DOOR_KEY_MASK_BLUE); nk_checkbox_flags_label(context, "Blue", &door->mask, DOOR_KEY_MASK_BLUE);
nk_layout_row_dynamic(context, row_height, 1); nk_layout_row_dynamic(context, row_height, 1);
nk_property_float(context, "Speed", -FLT_MAX, &door->speed, FLT_MAX, 0.1f, 0.1f); nk_property_float(context, "Speed", -FLT_MAX, &door->speed, FLT_MAX, 0.1f, 0.1f);
nk_property_float(context, "Open Pos", -FLT_MAX, &door->open_position, FLT_MAX, 0.1f, 0.1f); nk_property_float(context, "Open Pos", -FLT_MAX, &door->open_position, FLT_MAX, 0.1f, 0.1f);

@ -164,7 +164,7 @@ void transform_get_absolute_forward(struct Entity* entity, vec3* res)
{ {
quat abs_rot; quat abs_rot;
quat_identity(&abs_rot); quat_identity(&abs_rot);
transform_get_absolute_rot(entity, &abs_rot); transform_get_absolute_rotation(entity, &abs_rot);
quat_get_forward_rh(res, &abs_rot); quat_get_forward_rh(res, &abs_rot);
} }
@ -187,7 +187,7 @@ void transform_get_absolute_up(struct Entity* entity, vec3* res)
{ {
quat abs_rot; quat abs_rot;
quat_identity(&abs_rot); quat_identity(&abs_rot);
transform_get_absolute_rot(entity, &abs_rot); transform_get_absolute_rotation(entity, &abs_rot);
quat_get_up(res, &abs_rot); quat_get_up(res, &abs_rot);
} }
@ -195,7 +195,7 @@ void transform_get_absolute_right(struct Entity* entity, vec3* res)
{ {
quat abs_rot; quat abs_rot;
quat_identity(&abs_rot); quat_identity(&abs_rot);
transform_get_absolute_rot(entity, &abs_rot); transform_get_absolute_rotation(entity, &abs_rot);
quat_get_right(res, &abs_rot); quat_get_right(res, &abs_rot);
} }
@ -312,7 +312,7 @@ void transform_get_absolute_scale(struct Entity* entity, vec3* res)
} }
void transform_get_absolute_rot(struct Entity* entity, quat* res) void transform_get_absolute_rotation(struct Entity* entity, quat* res)
{ {
quat_assign(res, &entity->transform.rotation); quat_assign(res, &entity->transform.rotation);
bool done = false; bool done = false;

@ -24,7 +24,7 @@ void transform_get_up(struct Entity* entity, vec3* res);
void transform_get_right(struct Entity* entity, vec3* res); void transform_get_right(struct Entity* entity, vec3* res);
void transform_update_transmat(struct Entity* entity); void transform_update_transmat(struct Entity* entity);
void transform_get_absolute_position(struct Entity* entity, vec3* res); void transform_get_absolute_position(struct Entity* entity, vec3* res);
void transform_get_absolute_rot(struct Entity* entity, quat* res); void transform_get_absolute_rotation(struct Entity* entity, quat* res);
void transform_get_absolute_scale(struct Entity* entity, vec3* res); void transform_get_absolute_scale(struct Entity* entity, vec3* res);
void transform_get_absolute_lookat(struct Entity* entity, vec3* res); void transform_get_absolute_lookat(struct Entity* entity, vec3* res);
void transform_get_absolute_up(struct Entity* entity, vec3* res); void transform_get_absolute_up(struct Entity* entity, vec3* res);

@ -1,5 +1,4 @@
Todo: Todo:
- Switch transformation in property inspector to show/modify local transform values by default and show absolute transform values as read-only.
- Doors that open using the red/green/blue keys only as a way of progressing the level or cordoing off certain sections - Doors that open using the red/green/blue keys only as a way of progressing the level or cordoing off certain sections
- RGB keys to progress to next level - RGB keys to progress to next level
- Player/enemies getting hit by bullets - Player/enemies getting hit by bullets
@ -419,4 +418,5 @@ Done:
* Fixed console not working in game mode * Fixed console not working in game mode
* Pause sound when game is in pause mode * Pause sound when game is in pause mode
* Composite door entity made up of static mesh, sound entity and trigger. Door might require 0-3 keys in order to be opened. * Composite door entity made up of static mesh, sound entity and trigger. Door might require 0-3 keys in order to be opened.
* Add door properties to property inspector in editor * Add door properties to property inspector in editor
* Switched transformation in property inspector to show/modify local transform values by default and show absolute transform values as read-only.
Loading…
Cancel
Save