Split the sculpture into 3 assemblies, and created a way for patterns to use assembly specific color palettes

This commit is contained in:
PS 2021-03-24 19:45:11 -07:00
parent 2fa1a9b178
commit 83707b10b9
6 changed files with 56 additions and 18 deletions

View File

@ -26,6 +26,7 @@ AssemblyArray_Push(assembly_array* Array, assembly Assembly)
Assert(Array->Count < Array->CountMax); Assert(Array->Count < Array->CountMax);
u32 Index = Array->Count++; u32 Index = Array->Count++;
Array->Values[Index] = Assembly; Array->Values[Index] = Assembly;
Array->Values[Index].AssemblyIndex = Index;
return Index; return Index;
} }

View File

@ -143,6 +143,7 @@ struct assembly
{ {
gs_memory_arena Arena; gs_memory_arena Arena;
u32 AssemblyIndex;
gs_string Name; gs_string Name;
gs_string FilePath; gs_string FilePath;

View File

@ -577,7 +577,6 @@ v4 RGBToHSV(v4 In)
r32 Min = Min(In.r, Min(In.g, In.b)); r32 Min = Min(In.r, Min(In.g, In.b));
r32 Max = Max(In.r, Max(In.g, In.b)); r32 Max = Max(In.r, Max(In.g, In.b));
r32 V = Max; r32 V = Max;
r32 Delta = Max - Min; r32 Delta = Max - Min;
r32 S = 0; r32 S = 0;
@ -601,9 +600,6 @@ v4 RGBToHSV(v4 In)
H *= 60; // degrees H *= 60; // degrees
if( H < 0 ) if( H < 0 )
H += 360; H += 360;
Assert(H);
//if ( isNaN(h) )
//H = 0;
Result = v4{H, S, V, 1}; Result = v4{H, S, V, 1};
} }
else 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) Pattern_WavyPatchy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData)
{ {
DEBUG_TRACK_FUNCTION; DEBUG_TRACK_FUNCTION;
blumen_lumen_state* BLState = (blumen_lumen_state*)UserData;
gs_random_series Random = InitRandomSeries(24601); gs_random_series Random = InitRandomSeries(24601);
r32 LightSpeedMin = 1; r32 LightSpeedMin = 1;
r32 LightSpeedMax = 5; r32 LightSpeedMax = 5;
#if 0
r32 LightHueMin = (ModR32(Time, 10) / 10) * 360; r32 LightHueMin = (ModR32(Time, 10) / 10) * 360;
r32 LightHueMax = ModR32((LightHueMin + 45), 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; s32 LightTailLength = 10;
for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++)
{ {

View File

@ -183,10 +183,19 @@ BlumenLumen_CustomInit(app_state* State, context Context)
BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData); BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData);
#endif #endif
#if 0
gs_const_string SculpturePath = ConstString("data/test_blumen.fold"); gs_const_string SculpturePath = ConstString("data/test_blumen.fold");
LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog); 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 PLAYGROUND
animation_desc Desc = {}; animation_desc Desc = {};
Desc.NameSize = 256; Desc.NameSize = 256;
@ -218,14 +227,15 @@ BlumenLumen_CustomInit(app_state* State, context Context)
State->AnimationSystem.ActiveFadeGroup.From = BLState->AnimHandles[2]; State->AnimationSystem.ActiveFadeGroup.From = BLState->AnimHandles[2];
} // End Animation Playground } // End Animation Playground
#endif #else
animation_handle DemoPatternsAnim = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, animation_handle DemoPatternsAnim = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem,
State->Patterns, State->Patterns,
Context, Context,
ConstString("data/demo_patterns.foldanim")); 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++) for (u32 i = 0; i < FLOWER_COLORS_COUNT; i++)
{ {
//FlowerAColors[i] = TEMP_Saturate(FlowerAColors[i]); //FlowerAColors[i] = TEMP_Saturate(FlowerAColors[i]);
@ -233,6 +243,10 @@ BlumenLumen_CustomInit(app_state* State, context Context)
//FlowerCColors[i] = TEMP_Saturate(FlowerCColors[i]); //FlowerCColors[i] = TEMP_Saturate(FlowerCColors[i]);
} }
BLState->AssemblyColors[0] = RedV4;
BLState->AssemblyColors[1] = GreenV4;
BLState->AssemblyColors[2] = BlueV4;
return Result; return Result;
} }

View File

@ -169,6 +169,8 @@ struct blumen_lumen_state
system_time LastStatusUpdateTime; system_time LastStatusUpdateTime;
system_time LastSendTime; system_time LastSendTime;
v4 AssemblyColors[3];
}; };

View File

@ -175,13 +175,27 @@ int main(int ArgCount, char** Args)
{ {
gs_thread_context Ctx = Win32CreateThreadContext(); 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, WriteAssemblyUARTOpen(&OutputBuffer0,
"Blumen Lumen - Silver Spring", "Blumen Lumen - Silver Spring - 00",
100, 100,
v3{0, 0, 0}, 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; u32 StripCount = 0;
@ -196,7 +210,7 @@ int main(int ArgCount, char** Args)
F0.StemChannels = StemChannels; F0.StemChannels = StemChannels;
F0.BloomOuterChannels = BloomOuterChannels; F0.BloomOuterChannels = BloomOuterChannels;
F0.BloomInnerChannels = BloomInnerChannels; F0.BloomInnerChannels = BloomInnerChannels;
StripCount += BuildFlower(&OutputBuffer, F0); StripCount += BuildFlower(&OutputBuffer0, F0);
flower_desc F1 = {}; flower_desc F1 = {};
F1.Pos = v3{0, 0, 0}; F1.Pos = v3{0, 0, 0};
@ -205,7 +219,7 @@ int main(int ArgCount, char** Args)
F1.StemChannels = StemChannels; F1.StemChannels = StemChannels;
F1.BloomInnerChannels = BloomInnerChannels; F1.BloomInnerChannels = BloomInnerChannels;
F1.BloomOuterChannels = BloomOuterChannels; F1.BloomOuterChannels = BloomOuterChannels;
StripCount += BuildFlower(&OutputBuffer, F1); StripCount += BuildFlower(&OutputBuffer1, F1);
flower_desc F2 = {}; flower_desc F2 = {};
F2.Pos = v3{1, 0, 0}; F2.Pos = v3{1, 0, 0};
@ -214,9 +228,13 @@ int main(int ArgCount, char** Args)
F2.StemChannels = StemChannels; F2.StemChannels = StemChannels;
F2.BloomInnerChannels = BloomInnerChannels; F2.BloomInnerChannels = BloomInnerChannels;
F2.BloomOuterChannels = BloomOuterChannels; 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); //printf("%d\n", StripCount);