ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ProtogenProjectTemplate.cpp
Go to the documentation of this file.
2
4 eEA.AddParameter(&offsetFace, offsetFaceInd, 40, 0.0f, 1.0f);
5 eEA.AddParameter(&offsetFaceSA, offsetFaceIndSA, 40, 0.0f, 1.0f);
6 eEA.AddParameter(&offsetFaceARG, offsetFaceIndARG, 40, 0.0f, 1.0f);
7 eEA.AddParameter(&offsetFaceOSC, offsetFaceIndOSC, 40, 0.0f, 1.0f);
8}
9
11 materialAnimator.SetBaseMaterial(Material::Add, material);
12}
13
16 materialAnimator.AddMaterial(Material::Replace, &yellowMaterial, 40, 0.0f, 1.0f);//layer 1
17 materialAnimator.AddMaterial(Material::Replace, &orangeMaterial, 40, 0.0f, 1.0f);//layer 2
18 materialAnimator.AddMaterial(Material::Replace, &whiteMaterial, 40, 0.0f, 1.0f);//layer 3
19 materialAnimator.AddMaterial(Material::Replace, &greenMaterial, 40, 0.0f, 1.0f);//layer 4
20 materialAnimator.AddMaterial(Material::Replace, &purpleMaterial, 40, 0.0f, 1.0f);//layer 5
21 materialAnimator.AddMaterial(Material::Replace, &redMaterial, 40, 0.0f, 1.0f);//layer 6
22 materialAnimator.AddMaterial(Material::Replace, &blueMaterial, 40, 0.0f, 1.0f);//layer 7
23 materialAnimator.AddMaterial(Material::Replace, &flowNoise, 40, 0.15f, 1.0f);//layer 8
24 materialAnimator.AddMaterial(Material::Replace, &rainbowSpiral, 40, 0.0f, 1.0f);//layer 9
25 materialAnimator.AddMaterial(Material::Replace, &hRainbow, 40, 0.0f, 1.0f);//layer 10
26 materialAnimator.AddMaterial(Material::Replace, &blackMaterial, 40, 0.0f, 1.0f);//layer 11
27 materialAnimator.AddMaterial(Material::Replace, &sA, 20, 0.0f, 1.0f);
28 materialAnimator.AddMaterial(Material::Replace, &aRG, 20, 0.0f, 1.0f);
29 materialAnimator.AddMaterial(Material::Replace, &oSC, 20, 0.0f, 1.0f);
30
32 backgroundMaterial.AddMaterial(Material::Replace, &yellowMaterial, 40, 0.0f, 1.0f);//layer 1
33 backgroundMaterial.AddMaterial(Material::Replace, &orangeMaterial, 40, 0.0f, 1.0f);//layer 2
34 backgroundMaterial.AddMaterial(Material::Replace, &whiteMaterial, 40, 0.0f, 1.0f);//layer 3
35 backgroundMaterial.AddMaterial(Material::Replace, &greenMaterial, 40, 0.0f, 1.0f);//layer 4
36 backgroundMaterial.AddMaterial(Material::Replace, &purpleMaterial, 40, 0.0f, 1.0f);//layer 5
37 backgroundMaterial.AddMaterial(Material::Replace, &redMaterial, 40, 0.0f, 1.0f);//layer 6
38 backgroundMaterial.AddMaterial(Material::Replace, &blueMaterial, 40, 0.0f, 1.0f);//layer 7
39 backgroundMaterial.AddMaterial(Material::Replace, &flowNoise, 40, 0.0f, 1.0f);//layer 8
40 backgroundMaterial.AddMaterial(Material::Replace, &rainbowSpiral, 40, 0.0f, 1.0f);//layer 9
41 backgroundMaterial.AddMaterial(Material::Replace, &hRainbow, 40, 0.0f, 1.0f);//layer 10
42 backgroundMaterial.AddMaterial(Material::Replace, &blackMaterial, 40, 0.0f, 1.0f);//layer 11
43 backgroundMaterial.AddMaterial(Material::Add, &sA, 20, 0.0f, 1.0f);
44 backgroundMaterial.AddMaterial(Material::Add, &aRG, 20, 0.0f, 1.0f);
45 backgroundMaterial.AddMaterial(Material::Add, &oSC, 20, 0.0f, 1.0f);
46}
47
51
54 eEA.AddParameterFrame(Viseme::SS + 100, MicrophoneFourier::GetCurrentMagnitude() / 2.0f);
55
58
59 eEA.AddParameterFrame(Viseme::EE + 100, voiceDetection.GetViseme(Viseme::EE));
60 eEA.AddParameterFrame(Viseme::AH + 100, voiceDetection.GetViseme(Viseme::AH));
61 eEA.AddParameterFrame(Viseme::UH + 100, voiceDetection.GetViseme(Viseme::UH));
62 eEA.AddParameterFrame(Viseme::AR + 100, voiceDetection.GetViseme(Viseme::AR));
63 eEA.AddParameterFrame(Viseme::ER + 100, voiceDetection.GetViseme(Viseme::ER));
64 eEA.AddParameterFrame(Viseme::OO + 100, voiceDetection.GetViseme(Viseme::OO));
65 }
66 }
67}
68
70 switch(Menu::GetFaceColor()){
71 case 1: materialAnimator.AddMaterialFrame(yellowMaterial, 0.8f); break;
72 case 2: materialAnimator.AddMaterialFrame(orangeMaterial, 0.8f); break;
73 case 3: materialAnimator.AddMaterialFrame(whiteMaterial, 0.8f); break;
74 case 4: materialAnimator.AddMaterialFrame(greenMaterial, 0.8f); break;
75 case 5: materialAnimator.AddMaterialFrame(purpleMaterial, 0.8f); break;
76 case 6: materialAnimator.AddMaterialFrame(redMaterial, 0.8f); break;
77 case 7: materialAnimator.AddMaterialFrame(blueMaterial, 0.8f); break;
78 case 8: materialAnimator.AddMaterialFrame(rainbowSpiral, 0.8f); break;
79 case 9: materialAnimator.AddMaterialFrame(flowNoise, 0.8f); break;
80 case 10: materialAnimator.AddMaterialFrame(hRainbow, 0.8f); break;
81 case 11: materialAnimator.AddMaterialFrame(blackMaterial, 0.8f); break;
82 default: break;
83 }
84}
85
86void ProtogenProject::UpdateFace(float ratio) {
87 while(!frameLimiter.IsReady()) delay(1);
88
89 Menu::Update(ratio);
90
91 fanController.SetPWM(Menu::GetFanSpeed() * 25);
92
93 xOffset = fGenMatXMove.Update();
94 yOffset = fGenMatYMove.Update();
95
96 if (Menu::UseBoopSensor()) {
97 isBooped = boop60.isBooped() || boop99.isBooped();
98 }
99
100 hud.SetEffect(Menu::GetEffect());// Pull Effect from menu and store reference in hud for observing data
101 hud.Update();
102 this->scene.SetEffect(&hud);// Use HUD as effect for overlay/data extraction
103
104 voiceDetection.SetThreshold(map(Menu::GetMicLevel(), 0, 10, 1000, 50));
106
108
109 sA.SetHueAngle(ratio * 360.0f * 4.0f);
110 sA.SetMirrorYState(Menu::MirrorSpectrumAnalyzer());
111 sA.SetFlipYState(!Menu::MirrorSpectrumAnalyzer());
112
113 aRG.SetRadius((xOffset + 2.0f) * 2.0f + 25.0f);
114 aRG.SetSize(Vector2D((xOffset + 2.0f) * 10.0f + 50.0f, (xOffset + 2.0f) * 10.0f + 50.0f));
115 aRG.SetHueAngle(ratio * 360.0f * 8.0f);
116 aRG.SetRotation(ratio * 360.0f * 2.0f);
117
118 oSC.SetHueAngle(ratio * 360.0f * 8.0f);
119
121 RGBColor hueFront = RGBColor(255, 0, 0).HueShift(Menu::GetHueF() * 36);
122 RGBColor hueBack = RGBColor(255, 0, 0).HueShift(Menu::GetHueB() * 36);
123
124 gradientSpectrum[0] = hueFront;
125 gradientSpectrum[1] = hueBack;
126 gradientMat.UpdateGradient(gradientSpectrum);
127
128 flowNoise.SetGradient(hueFront, 0);
129 flowNoise.SetGradient(hueBack, 1);
130
132
133 eEA.Update();
134
135 flowNoise.Update(ratio);
136 rainbowSpiral.Update(ratio);
137 hRainbow.Update(ratio);
138 materialAnimator.Update();
139 backgroundMaterial.Update();
140
141 uint8_t faceSize = Menu::GetFaceSize();
142 float scale = Menu::ShowMenu() * 0.6f + 0.4f;
143 float faceSizeOffset = faceSize * (cameraSize.X / 20.0f);// /2 for min of half size, /10 for 10 face size options
144 float faceSizeMaxX = cameraSize.X / 2.0f;
145
146 float xMaxCamera = cameraSize.X - faceSizeMaxX + faceSizeOffset;
147
148 aRG.SetPosition(Vector2D(xMaxCamera / 2.0f + xOffset * 4.0f, cameraSize.Y / 2.0f + yOffset * 4.0f));
149
150 objA.SetCameraMax(Vector2D(xMaxCamera, cameraSize.Y - cameraSize.Y * offsetFace).Multiply(scale));
151}
152
153
155 this->camMin = min;
156 this->camMax = max;
157
158 objA.SetCameraMin(camMin);
159 objA.SetCameraMax(camMax);
160}
161
163 this->camMinRear = min;
164 this->camMaxRear = max;
165
166 objARear.SetCameraMin(camMinRear);
167 objARear.SetCameraMax(camMaxRear);
168}
169
170Transform ProtogenProject::GetAlignmentTransform(Vector2D min, Vector2D max, Object3D* obj, float rotation, float margin){
171 objAOther.SetCameraMin(min);
172 objAOther.SetCameraMax(max);
173
174 objAOther.SetPlaneOffsetAngle(rotation);
175 objAOther.SetEdgeMargin(margin);
176
177 return objAOther.GetTransform(obj);
178}
179
180Transform ProtogenProject::GetAlignmentTransform(Vector2D min, Vector2D max, Object3D** objects, uint8_t objectCount, float rotation, float margin){
181 objAOther.SetCameraMin(min);
182 objAOther.SetCameraMax(max);
183
184 objAOther.SetPlaneOffsetAngle(rotation);
185 objAOther.SetEdgeMargin(margin);
186
187 return objAOther.GetTransform(objects, objectCount);
188}
189
190void ProtogenProject::AlignObject(Vector2D min, Vector2D max, Object3D* obj, float rotation, float margin, bool mirror){
191 objAOther.SetCameraMin(min);
192 objAOther.SetCameraMax(max);
193
194 objAOther.SetPlaneOffsetAngle(rotation);
195 objAOther.SetEdgeMargin(margin);
196 objAOther.AlignObject(obj);
197
198 objAOther.SetMirrorX(mirror);
199}
200
201void ProtogenProject::AlignObjects(Vector2D min, Vector2D max, Object3D** objects, uint8_t objectCount, float rotation, float margin, bool mirror){
202 objAOther.SetCameraMin(min);
203 objAOther.SetCameraMax(max);
204
205 objAOther.SetPlaneOffsetAngle(rotation);
206 objAOther.SetEdgeMargin(margin);
207 objAOther.AlignObjects(objects, objectCount);
208
209 objAOther.SetMirrorX(mirror);
210}
211
212void ProtogenProject::AlignObjectNoScale(Vector2D min, Vector2D max, Object3D* obj, float rotation, float margin, bool mirror){
213 objAOther.SetCameraMin(min);
214 objAOther.SetCameraMax(max);
215
216 objAOther.SetPlaneOffsetAngle(rotation);
217 objAOther.SetEdgeMargin(margin);
218 objAOther.AlignObjectNoScale(obj);
219
220 objAOther.SetMirrorX(mirror);
221}
222
223void ProtogenProject::AlignObjectsNoScale(Vector2D min, Vector2D max, Object3D** objects, uint8_t objectCount, float rotation, float margin, bool mirror){
224 objAOther.SetCameraMin(min);
225 objAOther.SetCameraMax(max);
226
227 objAOther.SetPlaneOffsetAngle(rotation);
228 objAOther.SetEdgeMargin(margin);
229 objAOther.AlignObjectsNoScale(objects, objectCount);
230
231 objAOther.SetMirrorX(mirror);
232}
233
234void ProtogenProject::AlignObjectFace(Object3D* obj, float rotation, float margin, bool mirror){
235 objA.SetPlaneOffsetAngle(rotation);
236 objA.SetEdgeMargin(margin);
237 objA.AlignObject(obj);
238 objA.SetMirrorX(mirror);
239}
240
241void ProtogenProject::AlignObjectsFace(Object3D** objects, uint8_t objectCount, float rotation, float margin, bool mirror){
242 objA.SetPlaneOffsetAngle(rotation);
243 objA.SetEdgeMargin(margin);
244 objA.AlignObjects(objects, objectCount);
245 objA.SetMirrorX(mirror);
246}
247
248void ProtogenProject::AlignObjectNoScaleFace(Object3D* obj, float rotation, float margin, bool mirror){
249 objA.SetPlaneOffsetAngle(rotation);
250 objA.SetEdgeMargin(margin);
251 objA.AlignObjectNoScale(obj);
252 objA.SetMirrorX(mirror);
253}
254
255void ProtogenProject::AlignObjectsNoScaleFace(Object3D** objects, uint8_t objectCount, float rotation, float margin, bool mirror){
256 objA.SetPlaneOffsetAngle(rotation);
257 objA.SetEdgeMargin(margin);
258 objA.AlignObjectsNoScale(objects, objectCount);
259 objA.SetMirrorX(mirror);
260}
261
262void ProtogenProject::AlignObjectRear(Object3D* obj, float rotation, float margin, bool mirror){
263 objARear.SetPlaneOffsetAngle(rotation);
264 objARear.SetEdgeMargin(margin);
265 objARear.AlignObject(obj);
266 objARear.SetMirrorX(mirror);
267}
268
269void ProtogenProject::AlignObjectsRear(Object3D** objects, uint8_t objectCount, float rotation, float margin, bool mirror){
270 objARear.SetPlaneOffsetAngle(rotation);
271 objARear.SetEdgeMargin(margin);
272 objARear.AlignObjects(objects, objectCount);
273 objARear.SetMirrorX(mirror);
274}
275
276void ProtogenProject::AlignObjectNoScaleRear(Object3D* obj, float rotation, float margin, bool mirror){
277 objARear.SetPlaneOffsetAngle(rotation);
278 objARear.SetEdgeMargin(margin);
279 objARear.AlignObjectNoScale(obj);
280 objARear.SetMirrorX(mirror);
281}
282
283void ProtogenProject::AlignObjectsNoScaleRear(Object3D** objects, uint8_t objectCount, float rotation, float margin, bool mirror){
284 objARear.SetPlaneOffsetAngle(rotation);
285 objARear.SetEdgeMargin(margin);
286 objARear.AlignObjectsNoScale(objects, objectCount);
287 objARear.SetMirrorX(mirror);
288}
289
290
294
298
302
304 uint8_t faceSize = Menu::GetFaceSize();
305
306 float xSizeRatio = 1.0f - 0.5f + faceSize * (1.0f / 20.0f);
307
308 return xSizeRatio;
309}
310
311void ProtogenProject::AddParameter(uint8_t index, float* parameter, uint16_t transitionFrames, IEasyEaseAnimator::InterpolationMethod interpolationMethod, bool invertDirection){
312 if(invertDirection){
313 eEA.AddParameter(parameter, index, transitionFrames, 1.0f, 0.0f);
314 }
315 else{
316 eEA.AddParameter(parameter, index, transitionFrames, 0.0f, 1.0f);
317 }
318
319 eEA.SetInterpolationMethod(index, interpolationMethod);
320}
321
322void ProtogenProject::AddViseme(Viseme::MouthShape visemeName, float* parameter){
323 eEA.AddParameter(parameter, visemeName + 100, 2, 0.0f, 1.0f);
324
325 eEA.SetInterpolationMethod(visemeName + 100, IEasyEaseAnimator::Linear);
326}
327
328void ProtogenProject::AddBlinkParameter(float* blinkParameter){
329 blink.AddParameter(blinkParameter);
330
331 blinkSet = true;
332}
333
334void ProtogenProject::AddParameterFrame(uint16_t ProjectIndex, float target){
335 eEA.AddParameterFrame(ProjectIndex, target);
336}
337
338void ProtogenProject::AddMaterial(Material::Method method, Material* material, uint16_t frames, float minOpacity, float maxOpacity){
339 materialAnimator.AddMaterial(method, material, frames, minOpacity, maxOpacity);
340}
341
342void ProtogenProject::AddMaterialFrame(Color color, float opacity){
343 switch(color){
344 case CYELLOW:
345 materialAnimator.AddMaterialFrame(yellowMaterial, opacity);
346 break;
347 case CORANGE:
348 materialAnimator.AddMaterialFrame(orangeMaterial, opacity);
349 break;
350 case CWHITE:
351 materialAnimator.AddMaterialFrame(whiteMaterial, opacity);
352 break;
353 case CGREEN:
354 materialAnimator.AddMaterialFrame(greenMaterial, opacity);
355 break;
356 case CPURPLE:
357 materialAnimator.AddMaterialFrame(purpleMaterial, opacity);
358 break;
359 case CRED:
360 materialAnimator.AddMaterialFrame(redMaterial, opacity);
361 break;
362 case CBLUE:
363 materialAnimator.AddMaterialFrame(blueMaterial, opacity);
364 break;
365 case CRAINBOW:
366 materialAnimator.AddMaterialFrame(rainbowSpiral, opacity);
367 break;
368 case CRAINBOWNOISE:
369 materialAnimator.AddMaterialFrame(flowNoise, opacity);
370 break;
372 materialAnimator.AddMaterialFrame(hRainbow, opacity);
373 break;
374 case CBLACK:
375 materialAnimator.AddMaterialFrame(blackMaterial, opacity);
376 break;
377 default:
378 break;
379 }
380}
381
382void ProtogenProject::AddMaterialFrame(Material& material, float opacity){
383 materialAnimator.AddMaterialFrame(material, opacity);
384}
385
386void ProtogenProject::AddBackgroundMaterial(Material::Method method, Material* material, uint16_t frames, float minOpacity, float maxOpacity){
387 backgroundMaterial.AddMaterial(method, material, frames, minOpacity, maxOpacity);
388}
389
391 switch(color){
392 case CYELLOW:
393 backgroundMaterial.AddMaterialFrame(yellowMaterial, opacity);
394 break;
395 case CORANGE:
396 backgroundMaterial.AddMaterialFrame(orangeMaterial, opacity);
397 break;
398 case CWHITE:
399 backgroundMaterial.AddMaterialFrame(whiteMaterial, opacity);
400 break;
401 case CGREEN:
402 backgroundMaterial.AddMaterialFrame(greenMaterial, opacity);
403 break;
404 case CPURPLE:
405 backgroundMaterial.AddMaterialFrame(purpleMaterial, opacity);
406 break;
407 case CRED:
408 backgroundMaterial.AddMaterialFrame(redMaterial, opacity);
409 break;
410 case CBLUE:
411 backgroundMaterial.AddMaterialFrame(blueMaterial, opacity);
412 break;
413 case CRAINBOW:
414 backgroundMaterial.AddMaterialFrame(rainbowSpiral, opacity);
415 break;
416 case CRAINBOWNOISE:
417 backgroundMaterial.AddMaterialFrame(flowNoise, opacity);
418 break;
420 backgroundMaterial.AddMaterialFrame(hRainbow, opacity);
421 break;
422 case CBLACK:
423 backgroundMaterial.AddMaterialFrame(blackMaterial, opacity);
424 break;
425 default:
426 break;
427 }
428}
429
431 backgroundMaterial.AddMaterialFrame(material, opacity);
432}
433
436
437 eEA.AddParameterFrame(offsetFaceInd, 1.0f);
438 eEA.AddParameterFrame(offsetFaceIndSA, 1.0f);
439
440 materialAnimator.AddMaterialFrame(sA, offsetFaceSA);
441 backgroundMaterial.AddMaterialFrame(sA, offsetFaceSA);
442
444}
445
448
449 eEA.AddParameterFrame(offsetFaceInd, 1.0f);
450 eEA.AddParameterFrame(offsetFaceIndARG, 1.0f);
451
452 materialAnimator.AddMaterialFrame(aRG, offsetFaceARG);
453 backgroundMaterial.AddMaterialFrame(aRG, offsetFaceARG);
454
456}
457
460
461 eEA.AddParameterFrame(offsetFaceInd, 1.0f);
462 eEA.AddParameterFrame(offsetFaceIndOSC, 1.0f);
463
464 materialAnimator.AddMaterialFrame(oSC, offsetFaceOSC);
465 backgroundMaterial.AddMaterialFrame(oSC, offsetFaceOSC);
466
468}
469
471 eEA.AddParameterFrame(offsetFaceInd, 1.0f);
472}
473
475 blink.Pause();
476 blink.Reset();
477}
478
480 blink.Reset();
481 blink.Play();
482}
483
485 return isBooped;
486}
487
491
492void ProtogenProject::SetWiggleSpeed(float multiplier){
493 fGenMatXMove.SetPeriod(5.3f / multiplier);
494 fGenMatYMove.SetPeriod(6.7f / multiplier);
495}
496
497void ProtogenProject::SetMenuWiggleSpeed(float multiplierX, float multiplierY, float multiplierR){
498 Menu::SetWiggleSpeed(multiplierX, multiplierY, multiplierR);
499}
500
504
508
512
516
518 this->camMin = camMin;
519 this->camMax = camMax;
520 this->microphonePin = microphonePin;
521 this->buttonPin = buttonPin;
522 this->faceCount = faceCount;
523
524 this->scene.AddObject(background.GetObject());
525
526 background.GetObject()->SetMaterial(&backgroundMaterial);
527
529
531
532 objA.SetCameraMax(camMax);
533 objA.SetCameraMin(camMin);
534 objA.SetJustification(ObjectAlign::Stretch);
535
536 this->scene.EnableEffect();
537
539
540 //sA.SetSize(cameraSize);
541 //sA.SetPosition(cameraSize / 2.0f);
542
543 //oSC.SetSize(cameraSize);
544 //oSC.SetPosition(cameraSize / 2.0f);
545
546
547 sA.SetSize(Vector2D(220.0f, 72.0f));
548 sA.SetPosition(Vector2D());
549
550 oSC.SetSize(Vector2D(220.0f, 72.0f));
551 oSC.SetPosition(Vector2D());
552
553 hud.SetFaceMax(camMax);
554 hud.SetFaceMin(camMin);
555}
556
558 controller->Initialize();
559
560 boop60.Initialize(5);
561 boop99.Initialize(5);
562
563 hud.Initialize();
564
565 fanController.Initialize();
566
567 MicrophoneFourier::Initialize(microphonePin, 8000, 50.0f, 120.0f);//8KHz sample rate, 50dB min, 120dB max
568
569 #ifdef NEOTRELLISMENU
570 Menu::Initialize(faceCount);//NeoTrellis
571 #else
572 Menu::Initialize(faceCount, buttonPin, 500);//7 is number of faces
573 #endif
574}
Contains the class definition for ProtogenProject, a default project template for handling microphone...
Manages multiple CameraBase objects.
Base class for managing brightness and display operations of lighting controllers.
Definition Controller.h:25
InterpolationMethod
Enumeration of interpolation methods for animations.
@ Linear
Straight linear interpolation.
Abstract base class for rendering materials.
Definition Material.h:27
Method
Defines blending methods for combining colors.
Definition Material.h:33
@ Add
Adds colors together.
Definition Material.h:35
@ Replace
Replaces the base color.
Definition Material.h:44
static uint8_t GetFaceColor()
Gets the current face color index.
Definition Menu.cpp:453
static uint8_t GetMicLevel()
Gets the current microphone level.
Definition Menu.cpp:417
static void SetPositionOffset(Vector2D positionOffset)
Sets an additional offset to be added on top of the base position.
Definition Menu.cpp:276
static float ShowMenu()
Returns how much of the menu is shown, typically normalized (0.0 to 1.0).
Definition Menu.cpp:494
static void SetWiggleSpeed(float wiggleSpeedX, float wiggleSpeedY, float wiggleSpeedR)
Sets the speed multipliers for X-axis, Y-axis, and rotational wiggle.
Definition Menu.cpp:253
static uint8_t GetFanSpeed()
Gets the current fan speed index.
Definition Menu.cpp:489
static Material * GetMaterial()
Provides a pointer to the material used for rendering the menu text.
Definition Menu.cpp:155
static uint8_t MirrorSpectrumAnalyzer()
Checks if the spectrum analyzer mirroring is toggled on or off.
Definition Menu.cpp:435
static uint8_t GetFaceSize()
Gets the current face size.
Definition Menu.cpp:444
static void Initialize(uint8_t faceCount, uint8_t pin, uint16_t holdingTime, Vector2D size=Vector2D(240, 50))
Initializes the Menu using a face count, input pin, holding time, and size.
Definition Menu.cpp:102
static uint8_t GetHueF()
Gets the front hue value.
Definition Menu.cpp:462
static void SetSize(Vector2D size)
Sets the overall menu size and updates the text engine accordingly.
Definition Menu.cpp:259
static uint8_t UseMicrophone()
Checks if the microphone usage is toggled on or off.
Definition Menu.cpp:408
static uint8_t UseBoopSensor()
Checks if the boop sensor usage is toggled on or off.
Definition Menu.cpp:426
static void Update(float ratio)
Updates the menu each frame, handling transitions, wiggle effects, and text generation.
Definition Menu.cpp:208
static uint8_t GetHueB()
Gets the back hue value.
Definition Menu.cpp:471
static Effect * GetEffect()
Retrieves the current effect (post-processing) based on the menu setting.
Definition Menu.cpp:159
static float GetCurrentMagnitude()
Retrieves the current signal magnitude.
static float GetSampleRate()
Retrieves the current sampling rate.
static float * GetSamples()
Retrieves the raw input samples.
static float * GetFourierFiltered()
Retrieves the filtered FFT output data.
static void Initialize(uint8_t pin, uint32_t sampleRate, float minDB, float maxDB)
Initializes the microphone and FFT system with basic parameters.
static void Update()
Updates the microphone system, processing new samples and performing FFT.
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
Handles aligning and transforming 3D objects to fit within specified 2D camera bounds.
Definition ObjectAlign.h:24
@ Stretch
Attempt to scale the object(s) to fill the entire area.
Definition ObjectAlign.h:43
Project(CameraManager *cameras, Controller *controller, uint8_t numObjects)
Constructs a Project with specified camera manager and controller.
Definition Project.cpp:3
Scene scene
The Scene object representing the rendered environment.
Definition Project.h:35
CameraManager * cameras
Pointer to the CameraManager for managing cameras.
Definition Project.h:33
Controller * controller
Pointer to the Controller for controlling the display.
Definition Project.h:34
void SetMenuWiggleSpeed(float multiplierX, float multiplierY, float multiplierR)
Adjusts the menu's wiggle speed along X, Y, and rotation.
SimpleMaterial greenMaterial
Solid green material.
FunctionGenerator fGenMatYMove
BlinkTrack< 2 > blink
Blink track handler.
uint8_t buttonPin
Pin for the button input.
SpectrumAnalyzer sA
Audio-reactive materials.
Vector3D GetWiggleOffset()
Computes and returns a Vector3D offset for a "wiggle" effect using function generators.
uint8_t offsetFaceInd
Index for generic face offset in EasyEaseAnimator.
void Initialize() override
Initializes the ProtogenProject, setting up sensors, menus, and hardware.
SimpleMaterial redMaterial
Solid red material.
virtual void SpectrumAnalyzerCallback()=0
Callback invoked when the Spectrum Analyzer face is enabled/updated.
void UpdateKeyFrameTracks()
Updates any keyframe tracks (e.g., blink track).
void SetCameraMain(Vector2D min, Vector2D max)
Sets the camera bounds for the main (front) view.
void EnableBlinking()
Enables blinking (resets and plays the blink track).
RainbowSpiral rainbowSpiral
Spiral rainbow animated material.
bool isBooped
Flag to indicate if the APDS9960 sensor has detected a "boop".
SimpleMaterial blackMaterial
Solid black material.
SimpleMaterial blueMaterial
Solid blue material.
void AudioReactiveGradientFace()
Enables the Audio Reactive Gradient on the face, updating offsets and calling callbacks.
virtual void AudioReactiveGradientCallback()=0
Callback invoked when the Audio Reactive Gradient face is enabled/updated.
FanController fanController
Fan controller for controlling a fan's PWM.
void SetMenuOffset(Vector2D offset)
Sets the menu's position offset.
void AlignObjectsFace(Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects to the "face" camera bounds with scaling.
void SetMenuSize(Vector2D size)
Sets the menu's size.
float xOffset
Offsets used for small "wiggle" or motion in the scene.
SimpleMaterial yellowMaterial
Solid yellow material.
bool blinkSet
Flag to indicate if the blink parameter has been set.
void UpdateFFTVisemes()
Updates FFT-based visemes for voice detection and mouth shape animations.
void AlignObjectNoScaleRear(Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D to the rear camera bounds without scaling.
void AddBackgroundMaterialFrame(Color color, float opacity=0.8f)
Adds a material frame to the background from a color enum.
float yOffset
Y-axis offset.
void OscilloscopeFace()
Enables the Oscilloscope on the face, updating offsets and calling callbacks.
Vector2D camMaxRear
Rear camera maximum bounds.
float offsetFaceARG
Offset for AudioReactiveGradient face.
void UpdateFace(float ratio)
Updates the face's rendered content, reading any user input and applying changes.
void AlignObjectRear(Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D to the rear camera bounds with scaling.
void SetMaterialColor()
Sets the material color based on menu selection, applying color changes.
MaterialAnimator< 20 > backgroundMaterial
Handles layering of background materials.
FlowNoise flowNoise
Noise-based animated material.
void SetWiggleSpeed(float multiplier)
Sets the overall wiggle speed for both X and Y function generators.
Vector2D camMin
Minimum and maximum bounds for the primary (front) camera view.
EasyEaseAnimator< 60 > eEA
Animator that eases parameter transitions.
GradientMaterial< 2 > gradientMat
bool IsBooped()
Checks if the sensor has detected a boop.
float offsetFaceSA
Offset for SpectrumAnalyzer face.
void SpectrumAnalyzerFace()
Enables the Spectrum Analyzer on the face, updating offsets and calling callbacks.
Background background
Background object and associated 3D model.
void SetBaseMaterial(Material *material)
Sets the base material for the face material animator.
void AddParameter(uint8_t index, float *parameter, uint16_t transitionFrames, IEasyEaseAnimator::InterpolationMethod interpolationMethod=IEasyEaseAnimator::InterpolationMethod::Overshoot, bool invertDirection=false)
Adds a parameter to the EasyEaseAnimator for interpolation.
void SetMaterialLayers()
Sets up the initial layering of materials for both the face and background.
void AddMaterial(Material::Method method, Material *material, uint16_t frames=20, float minOpacity=0.0f, float maxOpacity=1.0f)
Adds a new material to the face's MaterialAnimator with given parameters.
ObjectAlign objAOther
Generic alignment object.
float offsetFace
Facial offset parameters for layering advanced materials (e.g., Spectrum Analyzer).
void DisableBlinking()
Disables blinking (pauses and resets the blink track).
MaterialAnimator< 20 > materialAnimator
Material animators for face and background layering.
SimpleMaterial orangeMaterial
Solid orange material.
void AlignObjectFace(Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D to the "face" camera bounds with scaling.
void AlignObjectsNoScale(Vector2D min, Vector2D max, Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects without scaling.
uint8_t faceCount
Total number of faces available (e.g., for UI or animations).
Vector2D cameraSize
The size of the camera used for rendering calculations.
void AlignObjectNoScale(Vector2D min, Vector2D max, Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D without scaling.
float GetFaceScale()
Computes the face scaling based on a user-defined face size.
APDS9960 boop60
Gesture sensor used for detecting "boops.".
FunctionGenerator fGenMatXMove
Function generators for X/Y wiggle movements.
void AddViseme(Viseme::MouthShape visemeName, float *parameter)
Adds a viseme parameter to the animator (for mouth shapes).
void SetCameraRear(Vector2D min, Vector2D max)
Sets the camera bounds for the rear view.
SimpleMaterial purpleMaterial
Solid purple material.
ObjectAlign objA
Object alignment for the front, rear, and an additional alignment object.
float offsetFaceOSC
Offset for Oscilloscope face.
Color
Enumeration of different color states for the face material.
@ CRAINBOWNOISE
Flow noise (rainbow noise).
@ CHORIZONTALRAINBOW
Horizontal rainbow effect.
@ CRAINBOW
Rainbow spiral.
uint8_t offsetFaceIndSA
Index for SpectrumAnalyzer offset in EasyEaseAnimator.
HorizontalRainbow hRainbow
Horizontal rainbow animated material.
TimeStep frameLimiter
A TimeStep object to limit frames (e.g., to 120 FPS).
FFTVoiceDetection< 128 > voiceDetection
Voice detection system based on FFT data.
HeadsUpDisplay hud
Heads-up display (HUD) for the face overlay or additional data.
void AddMaterialFrame(Color color, float opacity=0.8f)
Adds a new material frame to the face's MaterialAnimator from a color enum.
ObjectAlign objARear
Alignment for the rear camera.
ObjectAlign * GetObjectAlignFace()
Gets the ObjectAlign instance for the face camera.
RGBColor gradientSpectrum[2]
Gradient used for color transitions.
Vector2D camMinRear
Minimum and maximum bounds for the rear camera view.
void HideFace()
Hides the face by setting its offset parameter.
virtual void OscilloscopeCallback()=0
Callback invoked when the Oscilloscope face is enabled/updated.
void AlignObjectNoScaleFace(Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D to the "face" camera bounds without scaling.
uint8_t offsetFaceIndOSC
Index for Oscilloscope offset in EasyEaseAnimator.
void AddBlinkParameter(float *blinkParameter)
Adds a float parameter to the blink track for controlling blinking.
Material * GetBackgroundMaterial()
Retrieves the current background material animator.
ObjectAlign * GetObjectAlignRear()
Gets the ObjectAlign instance for the rear camera.
void AlignObjectsNoScaleRear(Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects to the rear camera bounds without scaling.
void LinkParameters()
Links internal parameters to the EasyEaseAnimator or other controllers.
uint8_t microphonePin
Pin assignments and face count.
void AlignObjectsRear(Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects to the rear camera bounds with scaling.
Vector2D camMax
Front camera maximum bounds.
void AddParameterFrame(uint16_t ProjectIndex, float target)
Adds a frame target to a previously added parameter.
Transform GetAlignmentTransform(Vector2D min, Vector2D max, Object3D *obj, float rotation=0.0f, float margin=2.0f)
Computes a transform for aligning a single Object3D within the given bounds.
Material * GetFaceMaterial()
Retrieves the current face material animator.
void AlignObjects(Vector2D min, Vector2D max, Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects, applying scaling.
SimpleMaterial whiteMaterial
Solid white material.
uint8_t offsetFaceIndARG
Index for AudioReactiveGradient offset in EasyEaseAnimator.
ObjectAlign * GetObjectAlign()
Gets the generic ObjectAlign instance.
void AddBackgroundMaterial(Material::Method method, Material *material, uint16_t frames=20, float minOpacity=0.0f, float maxOpacity=1.0f)
Adds a new material to the background's MaterialAnimator with given parameters.
void AlignObjectsNoScaleFace(Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects to the "face" camera bounds without scaling.
AudioReactiveGradient aRG
void AlignObject(Vector2D min, Vector2D max, Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D within the given bounds, applying scaling.
ProtogenProject(CameraManager *cameras, Controller *controller, uint8_t numObjects, Vector2D camMin, Vector2D camMax, uint8_t microphonePin, uint8_t buttonPin, uint8_t faceCount)
Constructs a ProtogenProject instance.
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
RGBColor HueShift(const float &hueDeg)
Shifts the hue of the color by a specified angle in degrees.
Definition RGBColor.cpp:65
Represents a 3D transformation including position, rotation, and scale.
Definition Transform.h:22
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
Vector2D Multiply(const Vector2D &vector) const
Multiplies this vector by another Vector2D component-wise.
Definition Vector2D.cpp:46
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26
MouthShape
Enumerates the possible mouth shapes for viseme detection.
@ ER
Mouth shape corresponding to the "ER" sound.
@ OO
Mouth shape corresponding to the "OO" sound.
@ AH
Mouth shape corresponding to the "AH" sound.
@ UH
Mouth shape corresponding to the "UH" sound.
@ AR
Mouth shape corresponding to the "AR" sound.
@ SS
Mouth shape corresponding to the "SS" sound (optional).
@ EE
Mouth shape corresponding to the "EE" sound.