Lumenarium/src_v2/user_space/user_space_incenter.cpp

89 lines
2.0 KiB
C++
Raw Normal View History

internal App_Init_Desc
incenter_get_init_desc()
{
App_Init_Desc result = {};
result.assembly_cap = 4;
return result;
}
#define INCENTER_METER 1.0f
#define INCENTER_FOOT 0.3048f
#define INCENTER_METERS(count) (count) * INCENTER_METER
#define INCENTER_FEET(count) (count) * INCENTER_FOOT
#define INCENTER_PER_METER(count) INCENTER_METER / (r32)(count)
internal void
incenter_init(App_State* state)
{
// create a fake sculpture
Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("test"), 5043, 41);
2022-04-23 13:55:53 +00:00
//Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("test"), 20000, 150);
scratch_get(scratch);
Allocator* s = scratch.a;
2022-04-16 11:00:32 +00:00
v3 start_p = (v3){0, 0, 0};
Assembly_Strip* vertical_strip = assembly_add_strip(&state->assemblies, ah, 123);
assembly_strip_create_leds(
2022-04-16 11:00:32 +00:00
&state->assemblies,
ah,
vertical_strip,
start_p,
2022-05-13 11:45:40 +00:00
(v3){0, INCENTER_FEET(-4.5f), 0},
2022-04-16 11:00:32 +00:00
123
);
r32 radius = INCENTER_FEET(10);
2022-05-13 11:45:40 +00:00
Random_Series rand = random_series_create(hash_djb2_cstr_to_u32("slfsaassdjf"));
u32 i = 0;
while (i < 40)
//for (u32 i = 0; i < 40; i++)
{
r32 theta = random_series_next_unilateral(&rand) * r32_tau;
r32 phi = random_series_next_unilateral(&rand) * r32_tau;
// spherical to cartesian conversion
v3 end_p = {
radius * sinf(phi) * cosf(theta),
radius * sinf(phi) * sinf(theta),
radius * cosf(phi)
};
2022-05-13 11:45:40 +00:00
r32 down = HMM_DotVec3(HMM_NormalizeVec3(end_p), (v3){0, -1, 0});
if (down > 0.7f || down < -0.9f) continue;
Assembly_Strip* strip = assembly_add_strip(&state->assemblies, ah, 123);
strip->output_kind = OutputData_NetworkSACN;
strip->sacn_universe = i;
assembly_strip_create_leds(&state->assemblies, ah, strip, start_p, end_p, 123);
2022-05-13 11:45:40 +00:00
i++;
}
2022-04-16 11:00:32 +00:00
r32 rad = 0.05f;
sculpture_updated(state, 5, rad);
2022-04-16 11:00:32 +00:00
scratch_release(scratch);
}
internal void
incenter_frame_prepare(App_State* state)
{
}
internal void
incenter_frame(App_State* state)
{
}
internal void
incenter_cleanup(App_State* state)
{
}