ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ProtogenProjectTemplate.h
Go to the documentation of this file.
1/**
2 * @file ProtogenProjectTemplate.h
3 * @brief Contains the class definition for ProtogenProject, a default project
4 * template for handling microphone input, boop sensor input, button control,
5 * and various material/animation functionalities in a small-scale 3D
6 * rendering environment for microcontrollers.
7 */
8
9#pragma once
10
11#include "../Templates/Project.h"
12#include "../../Animation/KeyFrameTrack.h"
13#include "../../Animation/EasyEaseAnimator.h"
14#include "../../Assets/Models/OBJ/Background.h"
15#include "../../ExternalDevices/InputDevices/Menu/Menu.h"
16#include "../../ExternalDevices/Sensors/APDS9960.h"
17#include "../../ExternalDevices/Displays/SSD1306.h"
18#include "../../ExternalDevices/Sensors/Microphone/MicrophoneFourier_MAX9814.h"
19#include "../../ExternalDevices/OutputDevices/FanController.h"
20
21#include "../../Scene/Materials/Utils/MaterialAnimator.h"
22#include "../../Scene/Materials/Static/SimpleMaterial.h"
23#include "../../Scene/Materials/Animated/FlowNoise.h"
24#include "../../Scene/Materials/Animated/RainbowNoise.h"
25#include "../../Scene/Materials/Animated/RainbowSpiral.h"
26#include "../../Scene/Materials/Animated/HorizontalRainbow.h"
27#include "../../Scene/Materials/Animated/SpectrumAnalyzer.h"
28#include "../../Scene/Materials/Animated/AudioReactiveGradient.h"
29#include "../../Scene/Materials/Animated/Oscilloscope.h"
30
31#include "../../Animation/AnimationTracks/BlinkTrack.h"
32#include "../../Utils/Signals/FunctionGenerator.h"
33#include "../../ExternalDevices/Sensors/Microphone/Utils/FFTVoiceDetection.h"
34#include "../../Scene/Objects/ObjectAlign.h"
35
36#include "../../Utils/Time/TimeStep.h"
37
38#include "../UserConfiguration.h"
39
40/**
41 * @class ProtogenProject
42 * @brief A default project template that includes functionality for an analog microphone,
43 * APDS9960 boop sensor, and button control. It provides a small-scale 3D rendering
44 * environment and various material animations for prototyping.
45 *
46 * This class inherits from Project and extends it with additional features:
47 * - 2D camera alignment (front/rear) for objects
48 * - Material layering and animation
49 * - Microphone input (Fourier analysis, voice detection, spectrum analysis, etc.)
50 * - Gesture/boop sensor detection
51 * - EasyEaseAnimations for param-based transitions
52 * - HUD handling and UI control via menu
53 */
54class ProtogenProject : public Project {
55private:
56 /**
57 * @brief Background object and associated 3D model.
58 */
59 Background background;
60
61 /**
62 * @brief Minimum and maximum bounds for the primary (front) camera view.
63 */
64 Vector2D camMin = Vector2D(0.0f, 0.0f); ///< Front camera minimum bounds.
65 Vector2D camMax = Vector2D(189.0f, 93.0f); ///< Front camera maximum bounds.
66
67 /**
68 * @brief Minimum and maximum bounds for the rear camera view.
69 */
70 Vector2D camMinRear = Vector2D(214.0f, 5.0f); ///< Rear camera minimum bounds.
71 Vector2D camMaxRear = Vector2D(279.0f, 100.0f); ///< Rear camera maximum bounds.
72
73 /**
74 * @brief Flag to indicate if the APDS9960 sensor has detected a "boop".
75 */
76 bool isBooped = false;
77
78 /**
79 * @brief Flag to indicate if the blink parameter has been set.
80 */
81 bool blinkSet = false;
82
83 /**
84 * @brief The size of the camera used for rendering calculations.
85 */
87
88 /**
89 * @brief Offsets used for small "wiggle" or motion in the scene.
90 */
91 float xOffset = 0.0f; ///< X-axis offset.
92 float yOffset = 0.0f; ///< Y-axis offset.
93
94 /**
95 * @brief Pin assignments and face count.
96 */
97 uint8_t microphonePin = 0; ///< Pin for the microphone input.
98 uint8_t buttonPin = 0; ///< Pin for the button input.
99 uint8_t faceCount = 10; ///< Total number of faces available (e.g., for UI or animations).
100
101 // --- Materials ---
102 FlowNoise flowNoise; ///< Noise-based animated material.
103 RainbowSpiral rainbowSpiral; ///< Spiral rainbow animated material.
104 HorizontalRainbow hRainbow; ///< Horizontal rainbow animated material.
105 SimpleMaterial redMaterial = SimpleMaterial(RGBColor(255, 0, 0)); ///< Solid red material.
106 SimpleMaterial orangeMaterial = SimpleMaterial(RGBColor(255, 165, 0)); ///< Solid orange material.
107 SimpleMaterial whiteMaterial = SimpleMaterial(RGBColor(255, 255, 255)); ///< Solid white material.
108 SimpleMaterial greenMaterial = SimpleMaterial(RGBColor(0, 255, 0)); ///< Solid green material.
109 SimpleMaterial blueMaterial = SimpleMaterial(RGBColor(0, 0, 255)); ///< Solid blue material.
110 SimpleMaterial yellowMaterial = SimpleMaterial(RGBColor(255, 255, 0)); ///< Solid yellow material.
111 SimpleMaterial purpleMaterial = SimpleMaterial(RGBColor(255, 0, 255)); ///< Solid purple material.
112 SimpleMaterial blackMaterial = SimpleMaterial(RGBColor(0, 0, 0)); ///< Solid black material.
113
114 /**
115 * @brief Gradient used for color transitions.
116 */
117 RGBColor gradientSpectrum[2] = {RGBColor(255, 0, 0), RGBColor(255, 0, 0)};
119
120 /**
121 * @brief Material animators for face and background layering.
122 */
123 MaterialAnimator<20> materialAnimator; ///< Handles layering of face materials.
124 MaterialAnimator<20> backgroundMaterial; ///< Handles layering of background materials.
125
126 /**
127 * @brief Audio-reactive materials.
128 */
129 SpectrumAnalyzer sA = SpectrumAnalyzer(Vector2D(200, 100), Vector2D(100, 50), true, true);
132
133 // --- Project controllers ---
134 BlinkTrack<2> blink; ///< Blink track handler.
135
136 /**
137 * @brief Object alignment for the front, rear, and an additional alignment object.
138 */
139 ObjectAlign objA = ObjectAlign(camMin, camMax, Quaternion()); ///< Alignment for the front camera.
140 ObjectAlign objARear = ObjectAlign(camMinRear, camMaxRear, Quaternion()); ///< Alignment for the rear camera.
141 ObjectAlign objAOther = ObjectAlign(Vector2D(), Vector2D(), Quaternion()); ///< Generic alignment object.
142
143 /**
144 * @brief Function generators for X/Y wiggle movements.
145 */
148
149 /**
150 * @brief Fan controller for controlling a fan's PWM.
151 */
153
154 /**
155 * @brief Gesture sensor used for detecting "boops."
156 */
158
159 /**
160 * @brief Voice detection system based on FFT data.
161 */
163
164 /**
165 * @brief Facial offset parameters for layering advanced materials (e.g., Spectrum Analyzer).
166 */
167 float offsetFace = 0.0f; ///< Generic face offset.
168 float offsetFaceSA = 0.0f; ///< Offset for SpectrumAnalyzer face.
169 float offsetFaceARG = 0.0f; ///< Offset for AudioReactiveGradient face.
170 float offsetFaceOSC = 0.0f; ///< Offset for Oscilloscope face.
171
172 uint8_t offsetFaceInd = 50; ///< Index for generic face offset in EasyEaseAnimator.
173 uint8_t offsetFaceIndSA = 51; ///< Index for SpectrumAnalyzer offset in EasyEaseAnimator.
174 uint8_t offsetFaceIndARG = 52; ///< Index for AudioReactiveGradient offset in EasyEaseAnimator.
175 uint8_t offsetFaceIndOSC = 53; ///< Index for Oscilloscope offset in EasyEaseAnimator.
176
177 /**
178 * @brief Links internal parameters to the EasyEaseAnimator or other controllers.
179 */
180 void LinkParameters();
181
182 /**
183 * @brief Sets the base material for the face material animator.
184 * @param material Pointer to the material to set as the base.
185 */
186 void SetBaseMaterial(Material* material);
187
188 /**
189 * @brief Sets up the initial layering of materials for both the face and background.
190 */
191 void SetMaterialLayers();
192
193 /**
194 * @brief Updates any keyframe tracks (e.g., blink track).
195 */
197
198 /**
199 * @brief Updates FFT-based visemes for voice detection and mouth shape animations.
200 */
201 void UpdateFFTVisemes();
202
203 /**
204 * @brief Sets the material color based on menu selection, applying color changes.
205 */
206 void SetMaterialColor();
207
208 /**
209 * @brief A TimeStep object to limit frames (e.g., to 120 FPS).
210 */
212
213protected:
214 /**
215 * @enum Color
216 * @brief Enumeration of different color states for the face material.
217 */
218 enum Color {
219 CBASE, ///< Base or default color.
220 CYELLOW, ///< Yellow color.
221 CORANGE, ///< Orange color.
222 CWHITE, ///< White color.
223 CGREEN, ///< Green color.
224 CPURPLE, ///< Purple color.
225 CRED, ///< Red color.
226 CBLUE, ///< Blue color.
227 CRAINBOW, ///< Rainbow spiral.
228 CRAINBOWNOISE, ///< Flow noise (rainbow noise).
229 CHORIZONTALRAINBOW, ///< Horizontal rainbow effect.
230 CBLACK ///< Black color.
231 };
232
233 /**
234 * @brief Animator that eases parameter transitions.
235 */
237
238 /**
239 * @brief Heads-up display (HUD) for the face overlay or additional data.
240 */
241 HeadsUpDisplay hud = HeadsUpDisplay(Vector2D(0.0f, 0.0f), Vector2D(192.0f, 96.0f));
242
243 /**
244 * @brief Links external or user-defined control parameters (pure virtual to be implemented).
245 */
246 virtual void LinkControlParameters() = 0;
247
248 /**
249 * @brief Updates the face's rendered content, reading any user input and applying changes.
250 * @param ratio A normalized ratio (0.0f to 1.0f) often used in animation phases.
251 */
252 void UpdateFace(float ratio);
253
254 /**
255 * @brief Sets the camera bounds for the main (front) view.
256 * @param min The minimum 2D bounds (bottom-left corner).
257 * @param max The maximum 2D bounds (top-right corner).
258 */
259 void SetCameraMain(Vector2D min, Vector2D max);
260
261 /**
262 * @brief Sets the camera bounds for the rear view.
263 * @param min The minimum 2D bounds (bottom-left corner).
264 * @param max The maximum 2D bounds (top-right corner).
265 */
266 void SetCameraRear(Vector2D min, Vector2D max);
267
268 /**
269 * @brief Computes a transform for aligning a single Object3D within the given bounds.
270 * @param min The minimum 2D bounds (bottom-left corner).
271 * @param max The maximum 2D bounds (top-right corner).
272 * @param obj Pointer to the Object3D to align.
273 * @param rotation The rotation angle (in degrees) applied to the object.
274 * @param margin Additional margin (border spacing).
275 * @return Transform containing position, rotation, and scale to align the object.
276 */
277 Transform GetAlignmentTransform(Vector2D min, Vector2D max, Object3D* obj, float rotation = 0.0f, float margin = 2.0f);
278
279 /**
280 * @brief Computes a transform for aligning multiple Object3D objects within the given bounds.
281 * @param min The minimum 2D bounds (bottom-left corner).
282 * @param max The maximum 2D bounds (top-right corner).
283 * @param objects Pointer to an array of Object3D pointers to align.
284 * @param objectCount The number of objects in the array.
285 * @param rotation The rotation angle (in degrees) applied to the objects.
286 * @param margin Additional margin (border spacing).
287 * @return Transform containing position, rotation, and scale for the objects.
288 */
289 Transform GetAlignmentTransform(Vector2D min, Vector2D max, Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f);
290
291 /**
292 * @brief Aligns a single Object3D within the given bounds, applying scaling.
293 * @param min The minimum 2D bounds.
294 * @param max The maximum 2D bounds.
295 * @param obj Pointer to the Object3D to align.
296 * @param rotation Rotation to apply.
297 * @param margin Margin spacing.
298 * @param mirror Whether to mirror the object along the X-axis.
299 */
300 void AlignObject(Vector2D min, Vector2D max, Object3D* obj, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
301
302 /**
303 * @brief Aligns multiple Object3D objects, applying scaling.
304 * @param min The minimum 2D bounds.
305 * @param max The maximum 2D bounds.
306 * @param objects Array of Object3D pointers.
307 * @param objectCount Number of objects.
308 * @param rotation Rotation to apply.
309 * @param margin Margin spacing.
310 * @param mirror Whether to mirror along the X-axis.
311 */
312 void AlignObjects(Vector2D min, Vector2D max, Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
313
314 /**
315 * @brief Aligns a single Object3D without scaling.
316 * @param min The minimum 2D bounds.
317 * @param max The maximum 2D bounds.
318 * @param obj Pointer to the Object3D to align.
319 * @param rotation Rotation to apply.
320 * @param margin Margin spacing.
321 * @param mirror Whether to mirror the object along the X-axis.
322 */
323 void AlignObjectNoScale(Vector2D min, Vector2D max, Object3D* obj, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
324
325 /**
326 * @brief Aligns multiple Object3D objects without scaling.
327 * @param min The minimum 2D bounds.
328 * @param max The maximum 2D bounds.
329 * @param objects Array of Object3D pointers.
330 * @param objectCount Number of objects.
331 * @param rotation Rotation to apply.
332 * @param margin Margin spacing.
333 * @param mirror Whether to mirror along the X-axis.
334 */
335 void AlignObjectsNoScale(Vector2D min, Vector2D max, Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
336
337 /**
338 * @brief Aligns a single Object3D to the "face" camera bounds with scaling.
339 * @param obj Pointer to the Object3D to align.
340 * @param rotation Rotation to apply.
341 * @param margin Margin spacing.
342 * @param mirror Whether to mirror along the X-axis.
343 */
344 void AlignObjectFace(Object3D* obj, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
345
346 /**
347 * @brief Aligns multiple Object3D objects to the "face" camera bounds with scaling.
348 * @param objects Array of Object3D pointers.
349 * @param objectCount Number of objects.
350 * @param rotation Rotation to apply.
351 * @param margin Margin spacing.
352 * @param mirror Whether to mirror along the X-axis.
353 */
354 void AlignObjectsFace(Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
355
356 /**
357 * @brief Aligns a single Object3D to the "face" camera bounds without scaling.
358 * @param obj Pointer to the Object3D to align.
359 * @param rotation Rotation to apply.
360 * @param margin Margin spacing.
361 * @param mirror Whether to mirror along the X-axis.
362 */
363 void AlignObjectNoScaleFace(Object3D* obj, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
364
365 /**
366 * @brief Aligns multiple Object3D objects to the "face" camera bounds without scaling.
367 * @param objects Array of Object3D pointers.
368 * @param objectCount Number of objects.
369 * @param rotation Rotation to apply.
370 * @param margin Margin spacing.
371 * @param mirror Whether to mirror along the X-axis.
372 */
373 void AlignObjectsNoScaleFace(Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
374
375 /**
376 * @brief Aligns a single Object3D to the rear camera bounds with scaling.
377 * @param obj Pointer to the Object3D to align.
378 * @param rotation Rotation to apply.
379 * @param margin Margin spacing.
380 * @param mirror Whether to mirror along the X-axis.
381 */
382 void AlignObjectRear(Object3D* obj, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
383
384 /**
385 * @brief Aligns multiple Object3D objects to the rear camera bounds with scaling.
386 * @param objects Array of Object3D pointers.
387 * @param objectCount Number of objects.
388 * @param rotation Rotation to apply.
389 * @param margin Margin spacing.
390 * @param mirror Whether to mirror along the X-axis.
391 */
392 void AlignObjectsRear(Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
393
394 /**
395 * @brief Aligns a single Object3D to the rear camera bounds without scaling.
396 * @param obj Pointer to the Object3D to align.
397 * @param rotation Rotation to apply.
398 * @param margin Margin spacing.
399 * @param mirror Whether to mirror along the X-axis.
400 */
401 void AlignObjectNoScaleRear(Object3D* obj, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
402
403 /**
404 * @brief Aligns multiple Object3D objects to the rear camera bounds without scaling.
405 * @param objects Array of Object3D pointers.
406 * @param objectCount Number of objects.
407 * @param rotation Rotation to apply.
408 * @param margin Margin spacing.
409 * @param mirror Whether to mirror along the X-axis.
410 */
411 void AlignObjectsNoScaleRear(Object3D** objects, uint8_t objectCount, float rotation = 0.0f, float margin = 2.0f, bool mirror = true);
412
413 /**
414 * @brief Gets the generic ObjectAlign instance.
415 * @return A pointer to the ObjectAlign handling custom alignment.
416 */
418
419 /**
420 * @brief Gets the ObjectAlign instance for the face camera.
421 * @return A pointer to the ObjectAlign used for face alignment.
422 */
424
425 /**
426 * @brief Gets the ObjectAlign instance for the rear camera.
427 * @return A pointer to the ObjectAlign used for rear alignment.
428 */
430
431 /**
432 * @brief Computes the face scaling based on a user-defined face size.
433 * @return A float representing the scale factor to apply for the face.
434 */
435 float GetFaceScale();
436
437 /**
438 * @brief Adds a parameter to the EasyEaseAnimator for interpolation.
439 * @param index The parameter index within the animator.
440 * @param parameter Pointer to the float parameter to animate.
441 * @param transitionFrames How many frames the transition should take.
442 * @param interpolationMethod The interpolation method (overshoot, linear, etc.).
443 * @param invertDirection Whether to invert the animation (1.0f to 0.0f).
444 */
445 void AddParameter(uint8_t index, float* parameter, uint16_t transitionFrames,
447 bool invertDirection = false);
448
449 /**
450 * @brief Adds a viseme parameter to the animator (for mouth shapes).
451 * @param visemeName The mouth shape (e.g., Viseme::EE, Viseme::AH, etc.).
452 * @param parameter Pointer to the float parameter controlling that viseme.
453 */
454 void AddViseme(Viseme::MouthShape visemeName, float* parameter);
455
456 /**
457 * @brief Adds a float parameter to the blink track for controlling blinking.
458 * @param blinkParameter Pointer to the float controlling blinking.
459 */
460 void AddBlinkParameter(float* blinkParameter);
461
462 /**
463 * @brief Adds a frame target to a previously added parameter.
464 * @param ProjectIndex The index for the parameter.
465 * @param target The target value for that parameter.
466 */
467 void AddParameterFrame(uint16_t ProjectIndex, float target);
468
469 /**
470 * @brief Adds a new material to the face's MaterialAnimator with given parameters.
471 * @param method The blend method (e.g., Material::Add, Material::Replace).
472 * @param material Pointer to the material to add.
473 * @param frames How many frames the transition will take.
474 * @param minOpacity The minimum opacity.
475 * @param maxOpacity The maximum opacity.
476 */
477 void AddMaterial(Material::Method method, Material* material, uint16_t frames = 20,
478 float minOpacity = 0.0f, float maxOpacity = 1.0f);
479
480 /**
481 * @brief Adds a new material frame to the face's MaterialAnimator from a color enum.
482 * @param color The color enum to switch to.
483 * @param opacity The target opacity for that color material.
484 */
485 void AddMaterialFrame(Color color, float opacity = 0.8f);
486
487 /**
488 * @brief Adds a new material frame to the face's MaterialAnimator from a Material reference.
489 * @param material A reference to the material to add.
490 * @param opacity The target opacity.
491 */
492 void AddMaterialFrame(Material& material, float opacity = 1.0f);
493
494 /**
495 * @brief Adds a new material to the background's MaterialAnimator with given parameters.
496 * @param method The blend method.
497 * @param material The material to add.
498 * @param frames Transition frames.
499 * @param minOpacity Minimum opacity.
500 * @param maxOpacity Maximum opacity.
501 */
502 void AddBackgroundMaterial(Material::Method method, Material* material, uint16_t frames = 20,
503 float minOpacity = 0.0f, float maxOpacity = 1.0f);
504
505 /**
506 * @brief Adds a material frame to the background from a color enum.
507 * @param color The color enum to switch to.
508 * @param opacity The target opacity.
509 */
510 void AddBackgroundMaterialFrame(Color color, float opacity = 0.8f);
511
512 /**
513 * @brief Adds a material frame to the background from a Material reference.
514 * @param material The material to add.
515 * @param opacity The target opacity.
516 */
517 void AddBackgroundMaterialFrame(Material& material, float opacity = 1.0f);
518
519 /**
520 * @brief Enables the Spectrum Analyzer on the face, updating offsets and calling callbacks.
521 */
523
524 /**
525 * @brief Enables the Audio Reactive Gradient on the face, updating offsets and calling callbacks.
526 */
528
529 /**
530 * @brief Enables the Oscilloscope on the face, updating offsets and calling callbacks.
531 */
532 void OscilloscopeFace();
533
534 /**
535 * @brief Hides the face by setting its offset parameter.
536 */
537 void HideFace();
538
539 /**
540 * @brief Disables blinking (pauses and resets the blink track).
541 */
542 void DisableBlinking();
543
544 /**
545 * @brief Enables blinking (resets and plays the blink track).
546 */
547 void EnableBlinking();
548
549 /**
550 * @brief Checks if the sensor has detected a boop.
551 * @return True if booped, false otherwise.
552 */
553 bool IsBooped();
554
555 /**
556 * @brief Computes and returns a Vector3D offset for a "wiggle" effect using function generators.
557 * @return The updated wiggle offset in 3D.
558 */
560
561 /**
562 * @brief Sets the overall wiggle speed for both X and Y function generators.
563 * @param multiplier The speed multiplier.
564 */
565 void SetWiggleSpeed(float multiplier);
566
567 /**
568 * @brief Adjusts the menu's wiggle speed along X, Y, and rotation.
569 * @param multiplierX Speed multiplier for X-axis.
570 * @param multiplierY Speed multiplier for Y-axis.
571 * @param multiplierR Speed multiplier for rotation.
572 */
573 void SetMenuWiggleSpeed(float multiplierX, float multiplierY, float multiplierR);
574
575 /**
576 * @brief Sets the menu's position offset.
577 * @param offset The 2D offset to apply.
578 */
579 void SetMenuOffset(Vector2D offset);
580
581 /**
582 * @brief Sets the menu's size.
583 * @param size The new 2D size for the menu.
584 */
585 void SetMenuSize(Vector2D size);
586
587 /**
588 * @brief Retrieves the current face material animator.
589 * @return Pointer to the Material used for the face.
590 */
592
593 /**
594 * @brief Retrieves the current background material animator.
595 * @return Pointer to the Material used for the background.
596 */
598
599public:
600 /**
601 * @brief Constructs a ProtogenProject instance.
602 * @param cameras Pointer to the project's CameraManager.
603 * @param controller Pointer to the main Controller.
604 * @param numObjects Number of objects (including extra for internal usage).
605 * @param camMin The minimum 2D bounds for the main camera.
606 * @param camMax The maximum 2D bounds for the main camera.
607 * @param microphonePin The pin used for the microphone.
608 * @param buttonPin The pin used for the button.
609 * @param faceCount The number of faces for possible UI or animations.
610 */
613 uint8_t buttonPin, uint8_t faceCount);
614
615 /**
616 * @brief Initializes the ProtogenProject, setting up sensors, menus, and hardware.
617 */
618 void Initialize() override;
619
620 /**
621 * @brief Callback invoked when the Spectrum Analyzer face is enabled/updated.
622 *
623 * This method is pure virtual and must be implemented by the derived class
624 * to define custom behavior upon enabling or updating the Spectrum Analyzer face.
625 */
626 virtual void SpectrumAnalyzerCallback() = 0;
627
628 /**
629 * @brief Callback invoked when the Audio Reactive Gradient face is enabled/updated.
630 *
631 * This method is pure virtual and must be implemented by the derived class
632 * to define custom behavior upon enabling or updating the Audio Reactive Gradient face.
633 */
635
636 /**
637 * @brief Callback invoked when the Oscilloscope face is enabled/updated.
638 *
639 * This method is pure virtual and must be implemented by the derived class
640 * to define custom behavior upon enabling or updating the Oscilloscope face.
641 */
642 virtual void OscilloscopeCallback() = 0;
643};
A class for managing the Adafruit APDS9960 sensor.
Definition APDS9960.h:27
A material class for creating an audio-reactive gradient effect.
A template class for animating eye blinking using keyframes.
Definition BlinkTrack.h:27
Manages multiple CameraBase objects.
Abstract base class for representing a color with operations for modification and interpolation.
Definition Color.h:20
Base class for managing brightness and display operations of lighting controllers.
Definition Controller.h:25
A template class for implementing advanced animation easing.
Detects visemes based on FFT voice analysis.
Manages PWM-based fan speed control.
A dynamic simplex noise gradient material for a flowing effect.
Definition FlowNoise.h:27
A class to generate various waveform functions with customizable parameters.
@ Sine
Sine waveform.
Creates a customizable gradient material for rendering.
Renders and displays information on an SSD1306/SH1106 display.
Definition SSD1306.h:39
A dynamic horizontal rainbow gradient material.
InterpolationMethod
Enumeration of interpolation methods for animations.
@ Overshoot
Interpolation with overshooting behavior.
Animates transitions and blends between multiple materials.
Abstract base class for rendering materials.
Definition Material.h:27
Method
Defines blending methods for combining colors.
Definition Material.h:33
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
A dynamic oscilloscope material for visualizing audio signals.
Manages animations, rendering, and display operations.
Definition Project.h:31
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
A default project template that includes functionality for an analog microphone, APDS9960 boop sensor...
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.
APDS9960 boop
Gesture sensor used for detecting "boops.".
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.
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.
@ CBASE
Base or default color.
@ 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.
virtual void LinkControlParameters()=0
Links external or user-defined control parameters (pure virtual to be implemented).
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.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
A dynamic material creating a colorful rainbow spiral animation.
A material that applies a single, solid RGB color to surfaces.
A material that visualizes audio data as a spectrum.
Provides a mechanism to trigger actions at a specified frequency.
Definition TimeStep.h:18
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
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.