diff --git a/src/app/engine/assembly/foldhaus_assembly.cpp b/src/app/engine/assembly/foldhaus_assembly.cpp index 1a8cb6f..ebbff73 100644 --- a/src/app/engine/assembly/foldhaus_assembly.cpp +++ b/src/app/engine/assembly/foldhaus_assembly.cpp @@ -26,6 +26,7 @@ AssemblyArray_Push(assembly_array* Array, assembly Assembly) Assert(Array->Count < Array->CountMax); u32 Index = Array->Count++; Array->Values[Index] = Assembly; + Array->Values[Index].AssemblyIndex = Index; return Index; } diff --git a/src/app/engine/assembly/foldhaus_assembly.h b/src/app/engine/assembly/foldhaus_assembly.h index 0744e8e..7f6ca8b 100644 --- a/src/app/engine/assembly/foldhaus_assembly.h +++ b/src/app/engine/assembly/foldhaus_assembly.h @@ -143,6 +143,7 @@ struct assembly { gs_memory_arena Arena; + u32 AssemblyIndex; gs_string Name; gs_string FilePath; diff --git a/src/app/patterns/blumen_patterns.h b/src/app/patterns/blumen_patterns.h index ee59638..84d51e5 100644 --- a/src/app/patterns/blumen_patterns.h +++ b/src/app/patterns/blumen_patterns.h @@ -577,7 +577,6 @@ v4 RGBToHSV(v4 In) r32 Min = Min(In.r, Min(In.g, In.b)); r32 Max = Max(In.r, Max(In.g, In.b)); - r32 V = Max; r32 Delta = Max - Min; r32 S = 0; @@ -601,9 +600,6 @@ v4 RGBToHSV(v4 In) H *= 60; // degrees if( H < 0 ) H += 360; - Assert(H); - //if ( isNaN(h) ) - //H = 0; Result = v4{H, S, V, 1}; } else @@ -1187,15 +1183,21 @@ internal void Pattern_WavyPatchy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { DEBUG_TRACK_FUNCTION; - + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; gs_random_series Random = InitRandomSeries(24601); r32 LightSpeedMin = 1; r32 LightSpeedMax = 5; +#if 0 r32 LightHueMin = (ModR32(Time, 10) / 10) * 360; r32 LightHueMax = ModR32((LightHueMin + 45), 360) ; - +#else + v4 CenterColor = BLState->AssemblyColors[Assembly.AssemblyIndex % 3]; + r32 CenterHue = RGBToHSV(CenterColor).x; + r32 LightHueMin = ModR32(CenterHue + 30, 360);; + r32 LightHueMax = ModR32(CenterHue - 30, 360) ; +#endif s32 LightTailLength = 10; for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) { diff --git a/src/app/ss_blumen_lumen/blumen_lumen.cpp b/src/app/ss_blumen_lumen/blumen_lumen.cpp index 7361fd4..fd02a59 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen.cpp +++ b/src/app/ss_blumen_lumen/blumen_lumen.cpp @@ -183,10 +183,19 @@ BlumenLumen_CustomInit(app_state* State, context Context) BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData); #endif +#if 0 gs_const_string SculpturePath = ConstString("data/test_blumen.fold"); LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog); +#else + gs_const_string SculpturePath0 = ConstString("data/ss_blumen_one.fold"); + gs_const_string SculpturePath1 = ConstString("data/ss_blumen_two.fold"); + gs_const_string SculpturePath2 = ConstString("data/ss_blumen_three.fold"); + LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath0, State->GlobalLog); + LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath1, State->GlobalLog); + LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath2, State->GlobalLog); +#endif -#if 0 +#if 1 { // Animation PLAYGROUND animation_desc Desc = {}; Desc.NameSize = 256; @@ -218,14 +227,15 @@ BlumenLumen_CustomInit(app_state* State, context Context) State->AnimationSystem.ActiveFadeGroup.From = BLState->AnimHandles[2]; } // End Animation Playground -#endif +#else animation_handle DemoPatternsAnim = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, State->Patterns, Context, ConstString("data/demo_patterns.foldanim")); - State->AnimationSystem.ActiveFadeGroup.From = DemoPatternsAnim; - State->AnimationSystem.TimelineShouldAdvance = true; + State->AnimationSystem.ActiveFadeGroup.From = DemoPatternsAnim; +#endif + State->AnimationSystem.TimelineShouldAdvance = true; for (u32 i = 0; i < FLOWER_COLORS_COUNT; i++) { //FlowerAColors[i] = TEMP_Saturate(FlowerAColors[i]); @@ -233,6 +243,10 @@ BlumenLumen_CustomInit(app_state* State, context Context) //FlowerCColors[i] = TEMP_Saturate(FlowerCColors[i]); } + BLState->AssemblyColors[0] = RedV4; + BLState->AssemblyColors[1] = GreenV4; + BLState->AssemblyColors[2] = BlueV4; + return Result; } diff --git a/src/app/ss_blumen_lumen/blumen_lumen.h b/src/app/ss_blumen_lumen/blumen_lumen.h index 30b975a..fb5b238 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen.h +++ b/src/app/ss_blumen_lumen/blumen_lumen.h @@ -169,6 +169,8 @@ struct blumen_lumen_state system_time LastStatusUpdateTime; system_time LastSendTime; + + v4 AssemblyColors[3]; }; diff --git a/src/sculpture_gen/gen_blumen_lumen.cpp b/src/sculpture_gen/gen_blumen_lumen.cpp index 7beea9d..4555311 100644 --- a/src/sculpture_gen/gen_blumen_lumen.cpp +++ b/src/sculpture_gen/gen_blumen_lumen.cpp @@ -175,13 +175,27 @@ int main(int ArgCount, char** Args) { gs_thread_context Ctx = Win32CreateThreadContext(); - gs_string OutputBuffer = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer0 = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer2 = PushString(Ctx.Transient, MB(4)); - WriteAssemblyUARTOpen(&OutputBuffer, - "Blumen Lumen - Silver Spring", + WriteAssemblyUARTOpen(&OutputBuffer0, + "Blumen Lumen - Silver Spring - 00", 100, v3{0, 0, 0}, - 63, + 21, + ""); + WriteAssemblyUARTOpen(&OutputBuffer1, + "Blumen Lumen - Silver Spring - 01", + 100, + v3{0, 0, 0}, + 21, + ""); + WriteAssemblyUARTOpen(&OutputBuffer2, + "Blumen Lumen - Silver Spring - 02", + 100, + v3{0, 0, 0}, + 21, ""); u32 StripCount = 0; @@ -196,7 +210,7 @@ int main(int ArgCount, char** Args) F0.StemChannels = StemChannels; F0.BloomOuterChannels = BloomOuterChannels; F0.BloomInnerChannels = BloomInnerChannels; - StripCount += BuildFlower(&OutputBuffer, F0); + StripCount += BuildFlower(&OutputBuffer0, F0); flower_desc F1 = {}; F1.Pos = v3{0, 0, 0}; @@ -205,7 +219,7 @@ int main(int ArgCount, char** Args) F1.StemChannels = StemChannels; F1.BloomInnerChannels = BloomInnerChannels; F1.BloomOuterChannels = BloomOuterChannels; - StripCount += BuildFlower(&OutputBuffer, F1); + StripCount += BuildFlower(&OutputBuffer1, F1); flower_desc F2 = {}; F2.Pos = v3{1, 0, 0}; @@ -214,9 +228,13 @@ int main(int ArgCount, char** Args) F2.StemChannels = StemChannels; F2.BloomInnerChannels = BloomInnerChannels; F2.BloomOuterChannels = BloomOuterChannels; - StripCount += BuildFlower(&OutputBuffer, F2); + StripCount += BuildFlower(&OutputBuffer2, F2); - printf("%.*s\n", (u32)OutputBuffer.Length, OutputBuffer.Str); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_one.fold"), StringToData(OutputBuffer0)); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_two.fold"), StringToData(OutputBuffer1)); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_three.fold"), StringToData(OutputBuffer2)); + + //printf("%.*s\n", (u32)OutputBuffer.Length, OutputBuffer.Str); //printf("%d\n", StripCount);