[scene] Implement simple UI functions for lights

Both dynamic lights and "static" lights display their values, but
currently no interaction.
This commit is contained in:
Bill Currie 2023-08-08 17:25:53 +09:00
parent d9c6db8865
commit 1319ed0e94
3 changed files with 76 additions and 0 deletions

View file

@ -72,4 +72,11 @@ void Light_DecayLights (lightingdata_t *ldata, float frametime,
double realtime);
void Light_LinkLight (lightingdata_t *ldata, uint32_t entid);
struct imui_ctx_s;
struct ecs_registry_s;
void Light_dyn_light_ui (void *l, struct imui_ctx_s *imui_ctx,
struct ecs_registry_s *reg, uint32_t ent, void *data);
void Light_light_ui (void *l, struct imui_ctx_s *imui_ctx,
struct ecs_registry_s *reg, uint32_t ent, void *data);
#endif//__QF_scene_light_h

View file

@ -12,6 +12,9 @@
#include "QF/scene/scene.h"
#include "QF/simd/vec4f.h"
#include "QF/ui/imui.h"
#define IMUI_context imui_ctx
static void
expand_pvs (set_t *pvs, mod_brush_t *brush)
{
@ -207,3 +210,67 @@ Light_DecayLights (lightingdata_t *ldata, float frametime, double realtime)
}
}
}
void
Light_dyn_light_ui (void *comp, imui_ctx_t *imui_ctx,
ecs_registry_t *reg, uint32_t ent, void *data)
{
dlight_t *dlight = comp;
UI_Horizontal {
UI_Labelf ("Origin: ");
UI_FlexibleSpace ();
UI_Labelf ("%6.1f %6.1f %6.1f %6g", VEC4_EXP (dlight->origin));
}
UI_Horizontal {
UI_Label ("Color: ");
UI_FlexibleSpace ();
UI_Labelf ("%5.3f %5.3f %5.3f %5.3f", VEC4_EXP (dlight->color));
}
UI_Horizontal {
UI_Labelf ("Radius: ");
UI_FlexibleSpace ();
UI_Labelf ("%6g", dlight->radius);
}
UI_Horizontal {
UI_Labelf ("Die: ");
UI_FlexibleSpace ();
UI_Labelf ("%6.2f", dlight->die);
}
UI_Horizontal {
UI_Labelf ("Decay: ");
UI_FlexibleSpace ();
UI_Labelf ("%6.2f", dlight->decay);
}
UI_Horizontal {
UI_Labelf ("Min Light: ");
UI_FlexibleSpace ();
UI_Labelf ("%6g", dlight->minlight);
}
}
void
Light_light_ui (void *comp, imui_ctx_t *imui_ctx,
ecs_registry_t *reg, uint32_t ent, void *data)
{
light_t *light = comp;
UI_Horizontal {
UI_Label ("Color: ");
UI_FlexibleSpace ();
UI_Labelf ("%5.3f %5.3f %5.3f %3g", VEC4_EXP (light->color));
}
UI_Horizontal {
UI_Labelf ("Position: ");
UI_FlexibleSpace ();
UI_Labelf ("%6.1f %6.1f %6.1f %6g", VEC4_EXP (light->position));
}
UI_Horizontal {
UI_Labelf ("Direction: ");
UI_FlexibleSpace ();
UI_Labelf ("%6.3f %6.3f %6.3f %6.3g", VEC4_EXP (light->direction));
}
UI_Horizontal {
UI_Labelf ("Attenuation: ");
UI_FlexibleSpace ();
UI_Labelf ("%g %g %g %g", VEC4_EXP (light->attenuation));
}
}

View file

@ -156,11 +156,13 @@ static const component_t scene_components[scene_comp_count] = {
[scene_dynlight] = {
.size = sizeof (dlight_t),
.name = "dyn_light",
.ui = Light_dyn_light_ui,
},
[scene_light] = {
.size = sizeof (light_t),
.name = "light",
.ui = Light_light_ui,
},
[scene_efrags] = {
.size = sizeof (efrag_t *),