diff --git a/run_tree/osx/arm64/debug/convert_csv b/run_tree/osx/arm64/debug/convert_csv index 313a0ad..e1790c9 100755 Binary files a/run_tree/osx/arm64/debug/convert_csv and b/run_tree/osx/arm64/debug/convert_csv differ diff --git a/run_tree/osx/arm64/debug/lumenarium b/run_tree/osx/arm64/debug/lumenarium index b01321e..2d5ff7e 100755 Binary files a/run_tree/osx/arm64/debug/lumenarium and b/run_tree/osx/arm64/debug/lumenarium differ diff --git a/src/app/engine/foldhaus_network_ordering.h b/src/app/engine/foldhaus_network_ordering.h index 05e5afd..cc9634d 100644 --- a/src/app/engine/foldhaus_network_ordering.h +++ b/src/app/engine/foldhaus_network_ordering.h @@ -10,7 +10,7 @@ inline u8* PackB1(u8* ptr, u8 val) { *ptr = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u8 from a known big endian buffer @@ -25,7 +25,7 @@ inline u8* PackL1(u8* ptr, u8 val) { *ptr = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u8 from a known little endian buffer @@ -39,19 +39,19 @@ UpackL1(const u8* ptr) inline u16 PackB2(u16 Value) { - u16 Result = 0; - u8* Array = (u8*)&Result; - Array[1] = (u8)(Value & 0xFF); - Array[0] = (u8)((Value & 0xFF00) >> 8); - return Result; + u16 Result = 0; + u8* Array = (u8*)&Result; + Array[1] = (u8)(Value & 0xFF); + Array[0] = (u8)((Value & 0xFF00) >> 8); + return Result; } inline u8* PackB2(u8* ptr, u16 val) { - ptr[1] = (u8)(val & 0xff); + ptr[1] = (u8)(val & 0xff); ptr[0] = (u8)((val & 0xff00) >> 8); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u16 from a known big endian buffer @@ -66,7 +66,7 @@ inline u8* PackL2(u8* ptr, u16 val) { *((u16*)ptr) = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u16 from a known little endian buffer @@ -84,7 +84,7 @@ PackB4(u8* ptr, u32 val) ptr[2] = (u8)((val & 0xff00) >> 8); ptr[1] = (u8)((val & 0xff0000) >> 16); ptr[0] = (u8)((val & 0xff000000) >> 24); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u32 from a known big endian buffer @@ -99,7 +99,7 @@ inline u8* PackL4(u8* ptr, u32 val) { *((u32*)ptr) = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u32 from a known little endian buffer @@ -121,7 +121,7 @@ PackB8(u8* ptr, u64 val) ptr[2] = (u8)((val & 0xff0000000000) >> 40); ptr[1] = (u8)((val & 0xff000000000000) >> 48); ptr[0] = (u8)((val & 0xff00000000000000) >> 56); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a uint64 from a known big endian buffer @@ -129,9 +129,9 @@ inline u64 UpackB8(const u8* ptr) { return ((u64)ptr[7]) | (((u64)ptr[6]) << 8) | (((u64)ptr[5]) << 16) | - (((u64)ptr[4]) << 24) | (((u64)ptr[3]) << 32) | - (((u64)ptr[2]) << 40) | (((u64)ptr[1]) << 48) | - (((u64)ptr[0]) << 56); + (((u64)ptr[4]) << 24) | (((u64)ptr[3]) << 32) | + (((u64)ptr[2]) << 40) | (((u64)ptr[1]) << 48) | + (((u64)ptr[0]) << 56); } //Packs a u64 to a known little endian buffer @@ -139,7 +139,7 @@ inline u8* PackL8(u8* ptr, u64 val) { *((u64*)ptr) = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u64 from a known little endian buffer diff --git a/src_v2/engine/lumenarium_engine_assembly.c b/src_v2/engine/lumenarium_engine_assembly.c index 6025e3b..9a4f951 100644 --- a/src_v2/engine/lumenarium_engine_assembly.c +++ b/src_v2/engine/lumenarium_engine_assembly.c @@ -86,11 +86,11 @@ assembly_add_strip(Assembly_Array* a, Assembly_Handle h, u32 pixels_cap) void assembly_add_led( - Assembly_Array* a, - Assembly_Handle h, - Assembly_Strip* strip, - v4 position - ){ + Assembly_Array* a, + Assembly_Handle h, + Assembly_Strip* strip, + v4 position +){ u32 index = assembly_handle_to_index(h); Assembly_Pixel_Buffer* pixel_buffer = a->pixel_buffers + index; @@ -106,7 +106,7 @@ assembly_add_led( void assembly_strip_create_leds( - Assembly_Array* a, + Assembly_Array* a, Assembly_Handle h, Assembly_Strip* strip, v3 start, v3 end, diff --git a/src_v2/engine/output/lumenarium_output_sacn.c b/src_v2/engine/output/lumenarium_output_sacn.c index fd46365..ecd28c4 100644 --- a/src_v2/engine/output/lumenarium_output_sacn.c +++ b/src_v2/engine/output/lumenarium_output_sacn.c @@ -119,7 +119,7 @@ u8* PackB1(u8* ptr, u8 val) { *ptr = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u8 from a known big endian buffer @@ -134,7 +134,7 @@ u8* PackL1(u8* ptr, u8 val) { *ptr = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u8 from a known little endian buffer @@ -147,9 +147,9 @@ UpackL1(const u8* ptr) u8* PackB2(u8* ptr, u16 val) { - ptr[1] = (u8)(val & 0xff); + ptr[1] = (u8)(val & 0xff); ptr[0] = (u8)((val & 0xff00) >> 8); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u16 from a known big endian buffer @@ -167,7 +167,7 @@ PackB4(u8* ptr, u32 val) ptr[2] = (u8)((val & 0xff00) >> 8); ptr[1] = (u8)((val & 0xff0000) >> 16); ptr[0] = (u8)((val & 0xff000000) >> 24); - return ptr + sizeof(val); + return ptr + sizeof(val); } internal void @@ -227,15 +227,15 @@ VHD_PackLength_(u8* Buffer, u32 Length, b32 IncludeLength) internal void InitStreamHeader (u8* Buffer, s32 BufferSize, - u16 SlotCount, - u8 StartCode, - u16 Universe, - u8 Priority, - u16 Reserved, - u8 Options, - const char* SourceName, - Sacn_Cid CID - ) + u16 SlotCount, + u8 StartCode, + u16 Universe, + u8 Priority, + u16 Reserved, + u8 Options, + const char* SourceName, + Sacn_Cid CID +) { // TODO(pjs): Replace packing with gs_memory_cursor @@ -251,8 +251,8 @@ InitStreamHeader (u8* Buffer, s32 BufferSize, // TODO(Peter): If you never use this anywhere else, go back and remove the parameters VHD_PackFlags_(Cursor, false, false, false); Cursor = VHD_PackLength_(Cursor, - SACN_BUFFER_HEADER_SIZE - SACN_RLP_PREAMBLE_SIZE + SlotCount, - false); + SACN_BUFFER_HEADER_SIZE - SACN_RLP_PREAMBLE_SIZE + SlotCount, + false); // root vector Cursor = PackB4(Cursor, SACN_ROOT_VECTOR); // 22 @@ -265,8 +265,8 @@ InitStreamHeader (u8* Buffer, s32 BufferSize, VHD_PackFlags_(Cursor, false, false, false); Cursor = VHD_PackLength_(Cursor, - SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + SlotCount, - false); + SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + SlotCount, + false); // 40 // framing vector Cursor = PackB4(Cursor, SACN_FRAMING_VECTOR); @@ -295,8 +295,8 @@ InitStreamHeader (u8* Buffer, s32 BufferSize, VHD_PackFlags_(Cursor, false, false, false); Cursor = VHD_PackLength_(Cursor, - SACN_BUFFER_HEADER_SIZE - SACN_DMP_FLAGS_AND_LEN_ADDR + SlotCount, - false); // 117 + SACN_BUFFER_HEADER_SIZE - SACN_DMP_FLAGS_AND_LEN_ADDR + SlotCount, + false); // 117 // DMP Vector Cursor = PackB1(Cursor, SACN_DMP_VECTOR); @@ -345,12 +345,12 @@ sacn_fill_buffer_header(Output_Data* d, u16 universe, Sacn* sacn) dw_put_u32_b(&w, SACN_ROOT_VECTOR); for (u32 i = 0; i < SACN_CID_BYTES; i++) dw_put_u8(&w, sacn->cid.bytes[i]); - + sacn_vhd_pack_flags(&w, false, false, false); sacn_vhd_pack_len(&w, SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + slot_count, false); dw_put_u32_b(&w, SACN_FRAMING_VECTOR); - + dw_put_str_min_len_nullterm(&w, sacn->source_name, SACN_SOURCE_NAME_SIZE); dw_put_u8(&w, priority); @@ -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* @@ -406,21 +423,21 @@ output_network_sacn_init() { Sacn* result = allocator_alloc_struct(permanent, Sacn); zero_struct(*result); - + result->source_name = string_f(permanent, "lumenarium::incenter"); String cid_str = lit_str("{67F9D986-544E-4abb-8986-D5F79382586C}"); result->cid = sacn_string_to_cid(cid_str); - + s32 ttl = 20; result->socket = os_socket_create(AF_INET, SOCK_DGRAM, 0); os_socket_set_opt( - result->socket, + result->socket, IPPROTO_IP, IP_MULTICAST_TTL, (u8*)&ttl, sizeof(ttl) ); - + return (u8*)result; } diff --git a/src_v2/patterns/patterns_math.h b/src_v2/patterns/patterns_math.h index b89ed7c..b8cd8d9 100644 --- a/src_v2/patterns/patterns_math.h +++ b/src_v2/patterns/patterns_math.h @@ -170,52 +170,52 @@ pm_random_v2_to_r32(v2 n) internal r32 pm_noise_v3_to_r32(v3 p) { - p = pm_abs_v3(p); - v3 p_fl = pm_floor_v3(p); - v3 p_fr = pm_fract_v3(p); - v3 f = pm_smoothstep_v3(p_fr); - - v3 p_fl_0 = p_fl; - v3 p_fl_1 = HMM_AddVec3(p_fl, (v3){1, 0, 0}); - v3 p_fl_2 = HMM_AddVec3(p_fl, (v3){0, 1, 0}); - v3 p_fl_3 = HMM_AddVec3(p_fl, (v3){1, 1, 0}); - v3 p_fl_4 = HMM_AddVec3(p_fl, (v3){0, 0, 1}); - v3 p_fl_5 = HMM_AddVec3(p_fl, (v3){1, 0, 1}); - v3 p_fl_6 = HMM_AddVec3(p_fl, (v3){0, 1, 1}); - v3 p_fl_7 = HMM_AddVec3(p_fl, (v3){1, 1, 1}); - - r32 h0 = pm_hash_v3_to_r32(p_fl_0); - r32 h1 = pm_hash_v3_to_r32(p_fl_1); - r32 h2 = pm_hash_v3_to_r32(p_fl_2); - r32 h3 = pm_hash_v3_to_r32(p_fl_3); - r32 h4 = pm_hash_v3_to_r32(p_fl_4); - r32 h5 = pm_hash_v3_to_r32(p_fl_5); - r32 h6 = pm_hash_v3_to_r32(p_fl_6); - r32 h7 = pm_hash_v3_to_r32(p_fl_7); - - r32 h0_1 = lerp(h0, f.x, h1); - r32 h2_3 = lerp(h2, f.x, h3); - r32 h4_5 = lerp(h4, f.x, h5); - r32 h6_7 = lerp(h6, f.x, h7); - r32 h01_23 = lerp(h0_1, f.y, h2_3); - r32 h45_67 = lerp(h4_5, f.y, h6_7); - // r32 result = lerp( - // lerp( - // lerp(h0, f.x, h1), - // f.y, - // lerp(h2, f.x, h3) - // ), - // f.z, - // lerp( - // lerp(h4, f.x, h5), - // f.y, - // lerp(h6, f.x, h7) - // ) - // ); - r32 result = lerp(h01_23, f.z, h45_67); - - assert(result >= 0 && result <= 1); - return result; + p = pm_abs_v3(p); + v3 p_fl = pm_floor_v3(p); + v3 p_fr = pm_fract_v3(p); + v3 f = pm_smoothstep_v3(p_fr); + + v3 p_fl_0 = p_fl; + v3 p_fl_1 = HMM_AddVec3(p_fl, (v3){1, 0, 0}); + v3 p_fl_2 = HMM_AddVec3(p_fl, (v3){0, 1, 0}); + v3 p_fl_3 = HMM_AddVec3(p_fl, (v3){1, 1, 0}); + v3 p_fl_4 = HMM_AddVec3(p_fl, (v3){0, 0, 1}); + v3 p_fl_5 = HMM_AddVec3(p_fl, (v3){1, 0, 1}); + v3 p_fl_6 = HMM_AddVec3(p_fl, (v3){0, 1, 1}); + v3 p_fl_7 = HMM_AddVec3(p_fl, (v3){1, 1, 1}); + + r32 h0 = pm_hash_v3_to_r32(p_fl_0); + r32 h1 = pm_hash_v3_to_r32(p_fl_1); + r32 h2 = pm_hash_v3_to_r32(p_fl_2); + r32 h3 = pm_hash_v3_to_r32(p_fl_3); + r32 h4 = pm_hash_v3_to_r32(p_fl_4); + r32 h5 = pm_hash_v3_to_r32(p_fl_5); + r32 h6 = pm_hash_v3_to_r32(p_fl_6); + r32 h7 = pm_hash_v3_to_r32(p_fl_7); + + r32 h0_1 = lerp(h0, f.x, h1); + r32 h2_3 = lerp(h2, f.x, h3); + r32 h4_5 = lerp(h4, f.x, h5); + r32 h6_7 = lerp(h6, f.x, h7); + r32 h01_23 = lerp(h0_1, f.y, h2_3); + r32 h45_67 = lerp(h4_5, f.y, h6_7); + // r32 result = lerp( + // lerp( + // lerp(h0, f.x, h1), + // f.y, + // lerp(h2, f.x, h3) + // ), + // f.z, + // lerp( + // lerp(h4, f.x, h5), + // f.y, + // lerp(h6, f.x, h7) + // ) + // ); + r32 result = lerp(h01_23, f.z, h45_67); + + assert(result >= 0 && result <= 1); + return result; } r32 @@ -247,14 +247,14 @@ pm_fmb_3d(v3 x, r32 h) // t += ns; // } // return t; - + v3 ts = (v3){h, h, h}; v3 pp = x; r32 f = 0.0; v3 pp0 = HMM_AddVec3(pp, ts); v3 pp1 = HMM_SubtractVec3(pp, ts); - + f += 0.500000f * pm_noise_v3_to_r32(pp0); pp = HMM_MultiplyVec3f(pp, 2.02); f += 0.300000f * pm_noise_v3_to_r32(pp1); pp = HMM_MultiplyVec3f(pp, 2.03); f += 0.125000f * pm_noise_v3_to_r32(pp); pp = HMM_MultiplyVec3f(pp, 2.01); @@ -269,10 +269,10 @@ pm_fmb_3d(v3 x, r32 h) // pm_voronoise(v2 p, r32 u, r32 v) // { // r32 k = 1.0f + 63.0f + powf(1.0f - v, 6.0f); - + // v2 i = pm_floor_v2(p); // v2 f = pm_fract_v2(p); - + // v2 a = (v2){0, 0}; // for (s32 y = -2; y <= 2; y++) // { @@ -289,7 +289,7 @@ pm_fmb_3d(v3 x, r32 h) // a = HMM_AddVec2(a, (v2){o.z * w, w}); // } // } - + // return a.x / a.y; // } @@ -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 @@ -345,7 +346,7 @@ color_ramp_eval(Color_Ramp ramp, r32 pct) dist_above = dist; } } - + // interpolate between them r32 anchor_range = nearest_above.pct - nearest_below.pct; if (anchor_range == 0) anchor_range = 1; diff --git a/src_v2/user_space/incenter_gen_cities.h b/src_v2/user_space/incenter_gen_cities.h index 6406519..15dbaac 100644 --- a/src_v2/user_space/incenter_gen_cities.h +++ b/src_v2/user_space/incenter_gen_cities.h @@ -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,285 +282,285 @@ 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 [city_black_rock] = { .id = city_black_rock, diff --git a/src_v2/user_space/incenter_patterns.c b/src_v2/user_space/incenter_patterns.c index 79afa13..5d0aa6e 100644 --- a/src_v2/user_space/incenter_patterns.c +++ b/src_v2/user_space/incenter_patterns.c @@ -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++) - { - 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); - v3 color = color_ramp_eval(cities_sparkle_ramp, vv); - pixels.pixels[led_index] = color_v3_to_assembly_pixel(color); + 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]; + 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 = (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); diff --git a/src_v2/user_space/incenter_user_space.c b/src_v2/user_space/incenter_user_space.c index b5a061c..4d9d3f6 100644 --- a/src_v2/user_space/incenter_user_space.c +++ b/src_v2/user_space/incenter_user_space.c @@ -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); diff --git a/src_v2/user_space/incenter_user_space.h b/src_v2/user_space/incenter_user_space.h index e6d99be..ab4ae46 100644 --- a/src_v2/user_space/incenter_user_space.h +++ b/src_v2/user_space/incenter_user_space.h @@ -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