registered all leds on playa for incenter

This commit is contained in:
Peter Slattery 2022-08-28 07:54:33 -07:00
parent 0ba85af0d4
commit e568bf4982
10 changed files with 308 additions and 172 deletions

Binary file not shown.

Binary file not shown.

View File

@ -90,7 +90,7 @@ assembly_add_led(
Assembly_Handle h,
Assembly_Strip* strip,
v4 position
){
){
u32 index = assembly_handle_to_index(h);
Assembly_Pixel_Buffer* pixel_buffer = a->pixel_buffers + index;

View File

@ -235,7 +235,7 @@ InitStreamHeader (u8* Buffer, s32 BufferSize,
u8 Options,
const char* SourceName,
Sacn_Cid CID
)
)
{
// TODO(pjs): Replace packing with gs_memory_cursor
@ -395,10 +395,27 @@ sacn_string_to_cid(String str)
return (Sacn_Cid){};
}
//Unpacks a u32 from a known big endian buffer
inline u32
UpackB4(const u8* ptr)
{
return (u32)(ptr[3] | (ptr[2] << 8) | (ptr[1] << 16) | (ptr[0] << 24));
}
internal u32
sacn_universe_to_send_addr(u32 universe)
{
return 0;
u8 multicast_address_buffer[4] = {};
multicast_address_buffer[0] = 239;
multicast_address_buffer[1] = 255;
multicast_address_buffer[2] = (u8)((universe & 0xff00) >> 8); // high bit
multicast_address_buffer[3] = (u8)((universe & 0x00ff)); // low bit
u32 v4_address = (u32)((multicast_address_buffer[3] ) |
(multicast_address_buffer[2] << 8) |
(multicast_address_buffer[1] << 16) |
(multicast_address_buffer[0] << 24));
return v4_address;
}
internal u8*

View File

@ -326,6 +326,7 @@ color_ramp_reverse(Color_Ramp ramp)
v3
color_ramp_eval(Color_Ramp ramp, r32 pct)
{
pct = clamp(0, pct, 1);
// find nearest two anchors
// TODO: do a binary search and we just have to assume that the anchors
// are in order from least to greatest

View File

@ -1,6 +1,7 @@
// NOTE: This file is autogenerated by csv_to_cstruct.js
// NOTE: These are values for Incenter_City_Id
enum {
city_black_rock = 0,
city_bucharest = 1,
city_brisbane = 2,
@ -281,283 +282,283 @@ global Incenter_City_Desc city_descs[] = {
.id = city_bucharest,
.lat = 44.4,
.lon = 26.0833,
.sacn_universe = city_bucharest,
.sacn_universe = 165,
},
[city_brisbane] = {
.id = city_brisbane,
.lat = -27.4678,
.lon = 153.0281,
.sacn_universe = city_brisbane,
.sacn_universe = 61,
},
[city_chengdu] = {
.id = city_chengdu,
.lat = 30.66,
.lon = 104.0633,
.sacn_universe = city_chengdu,
.sacn_universe = 35,
},
[city_new_delhi] = {
.id = city_new_delhi,
.lat = 28.6139,
.lon = 77.209,
.sacn_universe = city_new_delhi,
.sacn_universe = 41,
},
[city_paris] = {
.id = city_paris,
.lat = 48.8566,
.lon = 2.3522,
.sacn_universe = city_paris,
.sacn_universe = 189,
},
[city_san_francisco] = {
.id = city_san_francisco,
.lat = 37.7562,
.lon = -122.443,
.sacn_universe = city_san_francisco,
.sacn_universe = 21,
},
[city_denver] = {
.id = city_denver,
.lat = 39.7621,
.lon = -104.8759,
.sacn_universe = city_denver,
.sacn_universe = 7,
},
[city_ankara] = {
.id = city_ankara,
.lat = 39.93,
.lon = 32.85,
.sacn_universe = city_ankara,
.sacn_universe = 203,
},
[city_harare] = {
.id = city_harare,
.lat = -17.8292,
.lon = 31.0522,
.sacn_universe = city_harare,
.sacn_universe = 213,
},
[city_hanoi] = {
.id = city_hanoi,
.lat = 21.0245,
.lon = 105.8412,
.sacn_universe = city_hanoi,
.sacn_universe = 33,
},
[city_washington] = {
.id = city_washington,
.lat = 38.9047,
.lon = -77.0163,
.sacn_universe = city_washington,
.sacn_universe = 3,
},
[city_bangkok] = {
.id = city_bangkok,
.lat = 13.75,
.lon = 100.5167,
.sacn_universe = city_bangkok,
.sacn_universe = 39,
},
[city_tunis] = {
.id = city_tunis,
.lat = 36.8008,
.lon = 10.18,
.sacn_universe = city_tunis,
.sacn_universe = 167,
},
[city_seoul] = {
.id = city_seoul,
.lat = 37.56,
.lon = 126.99,
.sacn_universe = city_seoul,
.sacn_universe = 57,
},
[city_belgrade] = {
.id = city_belgrade,
.lat = 44.8167,
.lon = 20.4667,
.sacn_universe = city_belgrade,
.sacn_universe = 171,
},
[city_moscow] = {
.id = city_moscow,
.lat = 55.7558,
.lon = 37.6178,
.sacn_universe = city_moscow,
.sacn_universe = 197,
},
[city_lima] = {
.id = city_lima,
.lat = -12.06,
.lon = -77.0375,
.sacn_universe = city_lima,
.sacn_universe = 19,
},
[city_islamabad] = {
.id = city_islamabad,
.lat = 33.6989,
.lon = 73.0369,
.sacn_universe = city_islamabad,
.sacn_universe = 223,
},
[city_abuja] = {
.id = city_abuja,
.lat = 9.0556,
.lon = 7.4914,
.sacn_universe = city_abuja,
.sacn_universe = 183,
},
[city_managua] = {
.id = city_managua,
.lat = 12.15,
.lon = -86.2667,
.sacn_universe = city_managua,
.sacn_universe = 5,
},
[city_amsterdam] = {
.id = city_amsterdam,
.lat = 52.3667,
.lon = 4.8833,
.sacn_universe = city_amsterdam,
.sacn_universe = 191,
},
[city_rabat] = {
.id = city_rabat,
.lat = 34.0253,
.lon = -6.8361,
.sacn_universe = city_rabat,
.sacn_universe = 187,
},
[city_ulaanbaatar] = {
.id = city_ulaanbaatar,
.lat = 47.9214,
.lon = 106.9055,
.sacn_universe = city_ulaanbaatar,
.sacn_universe = 53,
},
[city_mexico_city] = {
.id = city_mexico_city,
.lat = 19.4333,
.lon = -99.1333,
.sacn_universe = city_mexico_city,
.sacn_universe = 9,
},
[city_nairobi] = {
.id = city_nairobi,
.lat = -1.2864,
.lon = 36.8172,
.sacn_universe = city_nairobi,
.sacn_universe = 219,
},
[city_tokyo] = {
.id = city_tokyo,
.lat = 35.6839,
.lon = 139.7744,
.sacn_universe = city_tokyo,
.sacn_universe = 59,
},
[city_baghdad] = {
.id = city_baghdad,
.lat = 33.35,
.lon = 44.4167,
.sacn_universe = city_baghdad,
.sacn_universe = 195,
},
[city_tehran] = {
.id = city_tehran,
.lat = 35.7,
.lon = 51.4167,
.sacn_universe = city_tehran,
.sacn_universe = 205,
},
[city_jakarta] = {
.id = city_jakarta,
.lat = -6.2146,
.lon = 106.8451,
.sacn_universe = city_jakarta,
.sacn_universe = 63,
},
[city_guatemala_city] = {
.id = city_guatemala_city,
.lat = 14.6099,
.lon = -90.5252,
.sacn_universe = city_guatemala_city,
.sacn_universe = 13,
},
[city_berlin] = {
.id = city_berlin,
.lat = 52.5167,
.lon = 13.3833,
.sacn_universe = city_berlin,
.sacn_universe = 169,
},
[city_addis_ababa] = {
.id = city_addis_ababa,
.lat = 9.0272,
.lon = 38.7369,
.sacn_universe = city_addis_ababa,
.sacn_universe = 201,
},
[city_cairo] = {
.id = city_cairo,
.lat = 30.0444,
.lon = 31.2358,
.sacn_universe = city_cairo,
.sacn_universe = 163,
},
[city_quito] = {
.id = city_quito,
.lat = -0.22,
.lon = -78.5125,
.sacn_universe = city_quito,
.sacn_universe = 23,
},
[city_bogota] = {
.id = city_bogota,
.lat = 4.6126,
.lon = -74.0705,
.sacn_universe = city_bogota,
.sacn_universe = 25,
},
[city_beijing] = {
.id = city_beijing,
.lat = 39.904,
.lon = 116.4075,
.sacn_universe = city_beijing,
.sacn_universe = 55,
},
[city_accra] = {
.id = city_accra,
.lat = 5.6037,
.lon = -0.187,
.sacn_universe = city_accra,
.sacn_universe = 161,
},
[city_ottawa] = {
.id = city_ottawa,
.lat = 45.4247,
.lon = -75.695,
.sacn_universe = city_ottawa,
.sacn_universe = 31,
},
[city_brasilia] = {
.id = city_brasilia,
.lat = -15.7939,
.lon = -47.8828,
.sacn_universe = city_brasilia,
.sacn_universe = 181,
},
[city_la_paz] = {
.id = city_la_paz,
.lat = -16.4942,
.lon = -68.1475,
.sacn_universe = city_la_paz,
.sacn_universe = 27,
},
[city_dhaka] = {
.id = city_dhaka,
.lat = 23.7289,
.lon = 90.3944,
.sacn_universe = city_dhaka,
.sacn_universe = 43,
},
[city_yerevan] = {
.id = city_yerevan,
.lat = 40.1814,
.lon = 44.5144,
.sacn_universe = city_yerevan,
.sacn_universe = 211,
},
[city_chicago] = {
.id = city_chicago,
.lat = 41.8373,
.lon = -87.6862,
.sacn_universe = city_chicago,
.sacn_universe = 11,
},
[city_kyiv] = {
.id = city_kyiv,
.lat = 50.45,
.lon = 30.5236,
.sacn_universe = city_kyiv,
.sacn_universe = 199,
},
[city_dubai] = {
.id = city_dubai,
.lat = 25.2697,
.lon = 55.3094,
.sacn_universe = city_dubai,
.sacn_universe = 193,
},
[city_mumbai] = {
.id = city_mumbai,
.lat = 19.0758,
.lon = 72.8775,
.sacn_universe = city_mumbai,
.sacn_universe = 217,
},
[city_madrid] = {
.id = city_madrid,
.lat = 40.4167,
.lon = -3.7167,
.sacn_universe = city_madrid,
.sacn_universe = 185,
},
// Black Rock City

View File

@ -576,9 +576,8 @@ global Color_Ramp cities_ramp = {
global Color_Ramp cities_sparkle_ramp = {
.anchors = {
[0] = { .pct = 0, .color = { 0, 0, 0 } },
[1] = { .pct = .2f, .color = { 0, 0, 0 } },
[2] = { .pct = .5f, .color = { 255.f / 255.f, 194.f / 255.f, 86.f / 255.5 } },
[3] = { .pct = 1, .color = { 1, 1, 1 } },
[1] = { .pct = .7f, .color = { 0, 0, 0 } },
[2] = { .pct = .1f, .color = { 255.f / 255.f, 100.f / 255.f, 40.f / 255.5 } },
},
.anchors_count = 3
};
@ -897,18 +896,26 @@ pattern_fast_noise_test(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strip
void
secondary_pattern_twinkle(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins)
{
Assembly_Strip strip = strips.strips[city_secondary_first];
for (u32 led = 0; led < strip.pixels_len; led++)
for (u32 i = 0; i < secondary_strips_len; i++) {
Assembly_Strip* strip = secondary_city_strips[i];
for (u32 led = 0; led < strip->pixels_len; led++)
{
u32 led_index = strip.pixels[led];
u32 led_index = strip->pixels[led];
v4 p = pixels.positions[led_index];
v4 p_unit = incenter_pos_to_unit(p);
v3 p_offset = HMM_AddVec3(p.xyz, (v3){ 213.145f, 99.321f, 71.3f });
v3 p_scaled = HMM_MultiplyVec3f(p_offset, 2);
r32 v = pm_fmb_3d(p_scaled, ins->scene_time);
r32 vv = pm_smoothstep_r32(v);
r32 vv = (2 * pm_smoothstep_r32(v)) - 1;
#define TESTING_LEDS 0
#if !TESTING_LEDS
v3 color = color_ramp_eval(cities_sparkle_ramp, vv);
pixels.pixels[led_index] = color_v3_to_assembly_pixel(color);
#else
pixels.pixels[led_index] = color_v3_to_assembly_pixel((v3){1, 0, 0});
#endif
}
}
}
@ -943,7 +950,12 @@ pattern_sun_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, I
v4 pos = pixels.positions[j];
v4 p = incenter_pos_to_unit(pos);
r32 r2 = HMM_LengthSquaredVec3(pos.xyz);
#if !TESTING_LEDS
pixels.pixels[j] = sun(pos.xyz, r2, (Assembly_Pixel){0, 0, 0}, st);
#else
pixels.pixels[j] = color_v3_to_assembly_pixel((v3){0, 0, 1});
#endif
}
secondary_pattern_twinkle(pixels, strips, ins);

View File

@ -1,4 +1,8 @@
#define SECONDARY_CITY_CAP 32
u32 secondary_strips_len = 0;
Assembly_Strip* secondary_city_strips[SECONDARY_CITY_CAP];
#include "../user_space/incenter_patterns.c"
#include "../user_space/incenter_secondary_patterns.c"
#include "incenter_scenes.h"
@ -13,7 +17,8 @@ incenter_scenes_init(Incenter_State* ins, u32 cap, Allocator* a)
incenter_scene_descs_init();
ins->scenes = incenter_scene_descs;
ins->scenes_cap = Incenter_Scene_Count;
ins->scene_at = Incenter_Scene_Question_LostAccessToResources;
ins->scene_at = Incenter_Scene_AnyoneHome;
//Incenter_Scene_Question_LostAccessToResources;
}
internal void
@ -105,6 +110,27 @@ incenter_get_init_desc()
return result;
}
#define INCENTER_RADIUS INCENTER_FEET(10)
internal Assembly_Strip*
incenter_add_secondary_city_strip(Assembly_Array* assemblies, Assembly_Handle ah, u32 universe, u32 count, Incenter_City_Id city)
{
Assembly_Strip* s = assembly_add_strip(assemblies, ah, count);
s->output_kind = OutputData_NetworkSACN;
s->sacn_universe = universe;
Incenter_City_Desc d = city_descs[city];
v4 city_p = incenter_latlng_to_cartesian(d.lat, d.lon, INCENTER_RADIUS);
v4 end_p = incenter_latlng_to_cartesian(d.lat, d.lon, INCENTER_RADIUS * 2);
for (u32 i = 0; i < count; i++)
{
v4 p = pm_lerp_v4(city_p, (r32)i / (r32)count, end_p);
assembly_add_led(assemblies, ah, s, p);
}
secondary_city_strips[secondary_strips_len++] = s;
return s;
}
internal void
incenter_init(App_State* state)
{
@ -119,14 +145,15 @@ incenter_init(App_State* state)
u32 primary_city_lights = (city_count + 1) * lights_per_primary_city;
u32 secondary_city_count = (city_secondary_count - city_secondary_first) + 1;
u32 secondary_city_lights = secondary_city_count;
u32 lights_cap = primary_city_lights + secondary_city_lights;
Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("incenter"), lights_cap, city_count + 2);
u32 lights_cap = primary_city_lights + 800;
Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("incenter"), lights_cap, city_count + 50);
scratch_get(scratch);
Allocator* s = scratch.a;
v3 start_p = (v3){0, 0, 0};
Assembly_Strip* vertical_strip = assembly_add_strip(&state->assemblies, ah, 123);
assembly_strip_create_leds(
&state->assemblies,
@ -138,20 +165,97 @@ incenter_init(App_State* state)
);
// ADDING PRIMARY CITIES
r32 radius = INCENTER_FEET(10);
r32 radius = INCENTER_RADIUS;
for (u32 i = 0; i < city_count; i++)
{
Incenter_City_Desc city = city_descs[i];
if (city.sacn_universe == 0) {
printf("skipping %s\n", city_strings[i]);
continue;
}
v3 end_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius).xyz;
Assembly_Strip* strip = assembly_add_strip(&state->assemblies, ah, 123);
strip->output_kind = OutputData_NetworkSACN;
strip->sacn_universe = city.sacn_universe;
assembly_strip_create_leds(&state->assemblies, ah, strip, start_p, end_p, 123);
assembly_strip_create_leds(&state->assemblies, ah, strip, end_p, start_p, 88);
}
#define USING_ON_PLAYA_SECONDARY_CITIES 1
#if USING_ON_PLAYA_SECONDARY_CITIES
// ADDING SECONDARY CITIES
{
for (u32 i = 0; i < SECONDARY_CITY_CAP; i++) secondary_city_strips[i] = 0;
Assembly_Array* a = &state->assemblies;
{ // Australia
Assembly_Strip* aus_lef = incenter_add_secondary_city_strip(a, ah, 62, 10, city_brisbane);
Assembly_Strip* aus_rig = incenter_add_secondary_city_strip(a, ah, 64, 8, city_brisbane);
Assembly_Strip* aus_cen = incenter_add_secondary_city_strip(a, ah, 34, 6, city_brisbane);
}
{ // Islands Above Australia
Assembly_Strip* indonesia1 = incenter_add_secondary_city_strip(a, ah, 44, 9, city_jakarta);
Assembly_Strip* indonesia2 = incenter_add_secondary_city_strip(a, ah, 36, 9, city_jakarta);
Assembly_Strip* north_left_asia = incenter_add_secondary_city_strip(a, ah, 54, 6, city_tokyo);
Assembly_Strip* phillipines = incenter_add_secondary_city_strip(a, ah, 56, 10, city_jakarta);
}
{ // East Asia
// TODO(PS): update primary cities
Assembly_Strip* cen_china_to_thailand = incenter_add_secondary_city_strip(a, ah, 37, 19, city_jakarta);
Assembly_Strip* china_coast = incenter_add_secondary_city_strip(a, ah, 38, 29, city_jakarta);
Assembly_Strip* peninsula_below_china = incenter_add_secondary_city_strip(a, ah, 40, 10, city_jakarta);
Assembly_Strip* mainland_right_of_japan_north = incenter_add_secondary_city_strip(a, ah, 40, 10, city_tokyo);
Assembly_Strip* mainland_right_of_japan_south = incenter_add_secondary_city_strip(a, ah, 58, 9, city_tokyo);
}
{ // Japan
Assembly_Strip* japan = incenter_add_secondary_city_strip(a, ah, 60, 10, city_tokyo);
}
{
Assembly_Strip* rig_south_africa = incenter_add_secondary_city_strip(a, ah, 196, 9, city_nairobi);
Assembly_Strip* georgia = incenter_add_secondary_city_strip(a, ah, 198, 10, city_tokyo); // TODO(PS):
Assembly_Strip* ethiopia = incenter_add_secondary_city_strip(a, ah, 200, 5, city_addis_ababa);
Assembly_Strip* turkey = incenter_add_secondary_city_strip(a, ah, 202, 10, city_ankara);
Assembly_Strip* sudan_egypt = incenter_add_secondary_city_strip(a, ah, 204, 7, city_cairo);
Assembly_Strip* iran = incenter_add_secondary_city_strip(a, ah, 206, 9, city_tehran);
Assembly_Strip* west_russia = incenter_add_secondary_city_strip(a, ah, 208, 25, city_kyiv);
Assembly_Strip* saudi_arabia = incenter_add_secondary_city_strip(a, ah, 212, 4, city_ankara);
Assembly_Strip* south_africa = incenter_add_secondary_city_strip(a, ah, 214, 25, city_nairobi); // TODO(PS):
Assembly_Strip* right_india = incenter_add_secondary_city_strip(a, ah, 215, 19, city_mumbai);
Assembly_Strip* central_russia_right = incenter_add_secondary_city_strip(a, ah, 218, 7, city_kyiv);
Assembly_Strip* left_africa = incenter_add_secondary_city_strip(a, ah, 220, 7, city_nairobi);
Assembly_Strip* the_stans = incenter_add_secondary_city_strip(a, ah, 221, 19, city_tehran);
Assembly_Strip* left_india = incenter_add_secondary_city_strip(a, ah, 222, 40, city_mumbai);
}
{
Assembly_Strip* italy = incenter_add_secondary_city_strip(a, ah, 162, 9, city_paris);
Assembly_Strip* nigeria_cameroon = incenter_add_secondary_city_strip(a, ah, 164, 6, city_abuja);
Assembly_Strip* greece = incenter_add_secondary_city_strip(a, ah, 166, 9, city_belgrade);
Assembly_Strip* israel = incenter_add_secondary_city_strip(a, ah, 168, 6, city_cairo);
Assembly_Strip* central_europe = incenter_add_secondary_city_strip(a, ah, 170, 35, city_berlin);
Assembly_Strip* libya = incenter_add_secondary_city_strip(a, ah, 172, 9, city_tunis);
Assembly_Strip* peru = incenter_add_secondary_city_strip(a, ah, 182, 9, city_brasilia);
Assembly_Strip* right_north_africa = incenter_add_secondary_city_strip(a, ah, 184, 13, city_rabat);
Assembly_Strip* france = incenter_add_secondary_city_strip(a, ah, 188, 5, city_paris);
Assembly_Strip* uk = incenter_add_secondary_city_strip(a, ah, 190, 6, city_paris);
Assembly_Strip* scandanavia = incenter_add_secondary_city_strip(a, ah, 192, 5, city_berlin);
}
{
Assembly_Strip* us_east_coast = incenter_add_secondary_city_strip(a, ah, 1, 20, city_washington);
Assembly_Strip* central_americas = incenter_add_secondary_city_strip(a, ah, 2, 19, city_denver);
Assembly_Strip* colombia = incenter_add_secondary_city_strip(a, ah, 6, 9, city_bogota);
Assembly_Strip* missippi_river = incenter_add_secondary_city_strip(a, ah, 12, 9, city_washington);
Assembly_Strip* chile_south = incenter_add_secondary_city_strip(a, ah, 14, 9, city_la_paz);
Assembly_Strip* us_west_coast = incenter_add_secondary_city_strip(a, ah, 22, 17, city_san_francisco);
Assembly_Strip* venezuela = incenter_add_secondary_city_strip(a, ah, 26, 5, city_bogota);
Assembly_Strip* chile_north = incenter_add_secondary_city_strip(a, ah, 28, 10, city_la_paz);
Assembly_Strip* left_canada = incenter_add_secondary_city_strip(a, ah, 32, 5, city_san_francisco);
}
}
#else
// TODO: This probably isn't how these lights will be hooked up
Assembly_Strip* secondary_strip = assembly_add_strip(&state->assemblies, ah, secondary_city_lights);
secondary_strip->output_kind = OutputData_NetworkSACN;
@ -162,6 +266,7 @@ incenter_init(App_State* state)
v4 light_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius);
assembly_add_led(&state->assemblies, ah, secondary_strip, light_p);
}
#endif
// PATTERN INIT
pattern_random_fill_prep();
@ -215,7 +320,7 @@ incenter_frame(App_State* state)
incenter_interface_connection_frame(state, ins);
ins->scene_time += state->target_seconds_per_frame;
ins->scene_time += state->target_seconds_per_frame * 0.2f;
ins->transition_time += state->target_seconds_per_frame;
incenter_scene_render(state, ins);

View File

@ -46,7 +46,7 @@ struct Incenter_Data_Row
};
// TODO(PS): fix this to be the real universe
#define incenter_secondary_city_universe 128
#define incenter_secondary_city_universe 33
#include "incenter_gen_cities.h"
// Data