ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ProtogenHUB75Project.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Templates/ProtogenProjectTemplate.h"
4#include "../../Assets/Models/OBJ/DeltaDisplayBackground.h"
5#include "../../Assets/Models/FBX/NukudeFlat.h"
6
7#include "../../Camera/CameraManager/Implementations/HUB75DeltaCameras.h"
8#include "../../Controller/HUB75Controller.h"
9
11private:
14 NukudeFace pM;
15 DeltaDisplayBackground deltaDisplayBackground;
16
17 const __FlashStringHelper* faceArray[10] = {F("DEFAULT"), F("ANGRY"), F("DOUBT"), F("FROWN"), F("LOOKUP"), F("SAD"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
18
19 void LinkControlParameters() override {//Called from parent
20 AddParameter(NukudeFace::Anger, pM.GetMorphWeightReference(NukudeFace::Anger), 15);
21 AddParameter(NukudeFace::Sadness, pM.GetMorphWeightReference(NukudeFace::Sadness), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
22 AddParameter(NukudeFace::Surprised, pM.GetMorphWeightReference(NukudeFace::Surprised), 15);
23 AddParameter(NukudeFace::Doubt, pM.GetMorphWeightReference(NukudeFace::Doubt), 15);
24 AddParameter(NukudeFace::Frown, pM.GetMorphWeightReference(NukudeFace::Frown), 15);
25 AddParameter(NukudeFace::LookUp, pM.GetMorphWeightReference(NukudeFace::LookUp), 15);
26 AddParameter(NukudeFace::LookDown, pM.GetMorphWeightReference(NukudeFace::LookDown), 15);
27
28 AddParameter(NukudeFace::HideBlush, pM.GetMorphWeightReference(NukudeFace::HideBlush), 15, IEasyEaseAnimator::InterpolationMethod::Cosine, true);
29
30 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(NukudeFace::vrc_v_ee));
31 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(NukudeFace::vrc_v_aa));
32 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(NukudeFace::vrc_v_dd));
33 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(NukudeFace::vrc_v_rr));
34 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(NukudeFace::vrc_v_ch));
35 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(NukudeFace::vrc_v_oh));
36 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(NukudeFace::vrc_v_ss));
37
38 AddBlinkParameter(pM.GetMorphWeightReference(NukudeFace::Blink));
39 }
40
41 void Default(){}
42
43 void Angry(){
44 AddParameterFrame(NukudeFace::Anger, 1.0f);
46 }
47
48 void Sad(){
49 AddParameterFrame(NukudeFace::Sadness, 1.0f);
50 AddParameterFrame(NukudeFace::Frown, 1.0f);
52 }
53
54 void Surprised(){
55 AddParameterFrame(NukudeFace::Surprised, 1.0f);
56 AddParameterFrame(NukudeFace::HideBlush, 0.0f);
58 }
59
60 void Doubt(){
61 AddParameterFrame(NukudeFace::Doubt, 1.0f);
62 }
63
64 void Frown(){
65 AddParameterFrame(NukudeFace::Frown, 1.0f);
66 }
67
68 void LookUp(){
69 AddParameterFrame(NukudeFace::LookUp, 1.0f);
70 }
71
72 void LookDown(){
73 AddParameterFrame(NukudeFace::LookDown, 1.0f);
74 }
75
79
83
87
88public:
89 ProtogenHUB75Project() : ProtogenProject(&cameras, &controller, 2, Vector2D(), Vector2D(192.0f, 94.0f), 22, 23, 9){
90 scene.AddObject(pM.GetObject());
92
93 pM.GetObject()->SetMaterial(GetFaceMaterial());
94 deltaDisplayBackground.GetObject()->SetMaterial(GetFaceMaterial());
95
97
99
100 SetWiggleSpeed(5.0f);
101 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
102 SetMenuOffset(Vector2D(17.5f, -3.0f));
103 SetMenuSize(Vector2D(192, 56));
104 }
105
106 void Update(float ratio) override {
107 pM.Reset();
108
109 uint8_t mode = Menu::GetFaceState();//change by button press
110
113
114#ifdef MORSEBUTTON
116#else
117 SelectFace(mode);
118#endif
119
120 UpdateFace(ratio);
121
122 pM.Update();
123
124 AlignObjectFace(pM.GetObject(), -7.5f);
125
126 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
127 pM.GetObject()->UpdateTransform();
128 }
129
130 void SelectFace(uint8_t code) {
131 if (IsBooped() && code != 6) {
132 Surprised();
133 return;
134 }
135
136 switch(code) {
137 case 0: Default(); break;
138 case 1: Angry(); break;
139 case 2: Doubt(); break;
140 case 3: Frown(); break;
141 case 4: LookUp(); break;
142 case 5: Sad(); break;
143 case 6: AudioReactiveGradientFace(); break;
144 case 7: OscilloscopeFace(); break;
145 default: SpectrumAnalyzerFace(); break;
146 }
147 }
148
149 void SelectFaceFromMorse(uint8_t code) {
150 if (IsBooped() && code != 24) {
151 Surprised();
152 return;
153 }
154
155 switch(code) {
156 case 1: Angry(); break; // [A]ngry
157 case 2: Surprised(); break; // [B]lush
158 case 4: Doubt(); break; // [D]oubt
159 case 6: Frown(); break; // [F]rown
160 case 19: Sad(); break; // [S]ad
161 case 21: LookUp(); break; // Look [U]p
162 case 22: LookDown(); break; // Look [V] Down
163 case 24: AudioReactiveGradientFace(); break; // [X] X.X
164 case 25: OscilloscopeFace(); break; // [Y] Oscilloscope
165 case 26: SpectrumAnalyzerFace(); break; // [Z] Spectrum
166 default: Default(); break; // [H] Happy
167 }
168 }
169};
Manages HUB75 LED matrices with camera integration.
void SetAccentBrightness(uint8_t maxAccentBrightness) override
Sets the maximum accent brightness of the secondary display.
void SetBrightness(uint8_t maxBrightness) override
Sets the maximum brightness of the LED matrix.
void SetFaceArray(const __FlashStringHelper **faceNames)
Sets the array of face names.
Definition SSD1306.cpp:217
@ Cosine
Smooth cosine interpolation.
static uint8_t GetFaceState()
Retrieves the current face state. In hardware mode, it is read from the MenuHandler.
Definition Menu.cpp:381
static uint8_t GetBrightness()
Gets the current brightness level. In hardware mode, it is read from the MenuHandler.
Definition Menu.cpp:390
static uint8_t GetAccentBrightness()
Gets the current accent brightness level.
Definition Menu.cpp:399
Scene scene
The Scene object representing the rendered environment.
Definition Project.h:35
void SelectFace(uint8_t code)
void LinkControlParameters() override
Links external or user-defined control parameters (pure virtual to be implemented).
void OscilloscopeCallback() override
Callback invoked when the Oscilloscope face is enabled/updated.
void SpectrumAnalyzerCallback() override
Callback invoked when the Spectrum Analyzer face is enabled/updated.
const __FlashStringHelper * faceArray[10]
void Update(float ratio) override
Updates the project state based on the given ratio.
DeltaDisplayBackground deltaDisplayBackground
HUB75DeltaCameraManager cameras
void AudioReactiveGradientCallback() override
Callback invoked when the Audio Reactive Gradient face is enabled/updated.
void SelectFaceFromMorse(uint8_t code)
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.
Vector3D GetWiggleOffset()
Computes and returns a Vector3D offset for a "wiggle" effect using function generators.
void AudioReactiveGradientFace()
Enables the Audio Reactive Gradient on the face, updating offsets and calling callbacks.
void SetMenuOffset(Vector2D offset)
Sets the menu's position offset.
void SetMenuSize(Vector2D size)
Sets the menu's size.
void OscilloscopeFace()
Enables the Oscilloscope on the face, updating offsets and calling callbacks.
void UpdateFace(float ratio)
Updates the face's rendered content, reading any user input and applying changes.
void SetWiggleSpeed(float multiplier)
Sets the overall wiggle speed for both X and Y function generators.
bool IsBooped()
Checks if the sensor has detected a boop.
void SpectrumAnalyzerFace()
Enables the Spectrum Analyzer on the face, updating offsets and calling callbacks.
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 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 AddViseme(Viseme::MouthShape visemeName, float *parameter)
Adds a viseme parameter to the animator (for mouth shapes).
@ CHORIZONTALRAINBOW
Horizontal rainbow effect.
@ CRAINBOW
Rainbow spiral.
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.
void AddBlinkParameter(float *blinkParameter)
Adds a float parameter to the blink track for controlling blinking.
void AddParameterFrame(uint16_t ProjectIndex, float target)
Adds a frame target to a previously added parameter.
Material * GetFaceMaterial()
Retrieves the current face material animator.
void AddObject(Object3D *object)
Adds a 3D object to the scene.
Definition Scene.cpp:31
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
@ 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.