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