ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ArrowAnimation.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/Commissions/ArrowFace.h"
6#include "../../Assets/Models/OBJ/LEDStripBackground.h"
7
8#include "../../Camera/CameraManager/Implementations/HUB75DeltaCameras.h"
9#include "../../Controller/HUB75Controller.h"
10
11#include "../../Scene/Materials/Animated/HorizontalRainbow.h"
12
14private:
17 ArrowFace pM;
18 DeltaDisplayBackground deltaDisplayBackground;
19 LEDStripBackground ledStripBackground;
21
22 const __FlashStringHelper* faceArray[12] = {F("DEFAULT"), F("ANGRY"), F("EXCITED"), F("HAPPY"), F("HEART"), F("OWO"), F("UNAMUSE"), F("UWU"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
23
24 void LinkControlParameters() override {//Called from parent
25 AddParameter(ArrowFace::AngryEyesFlip, pM.GetMorphWeightReference(ArrowFace::AngryEyesFlip), 15);
26 AddParameter(ArrowFace::AngryMouth, pM.GetMorphWeightReference(ArrowFace::AngryMouth), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
27 AddParameter(ArrowFace::ExcitedEyes, pM.GetMorphWeightReference(ArrowFace::ExcitedEyes), 10);
28 AddParameter(ArrowFace::ExcitedMouthTODO, pM.GetMorphWeightReference(ArrowFace::ExcitedMouthTODO), 10);
29 AddParameter(ArrowFace::HappyEyes, pM.GetMorphWeightReference(ArrowFace::HappyEyes), 10);
30 AddParameter(ArrowFace::HeartEyes, pM.GetMorphWeightReference(ArrowFace::HeartEyes), 15);
31 AddParameter(ArrowFace::OwoEyes, pM.GetMorphWeightReference(ArrowFace::OwoEyes), 15);
32 AddParameter(ArrowFace::OwoMouth, pM.GetMorphWeightReference(ArrowFace::OwoMouth), 15);
33 AddParameter(ArrowFace::UnamusedEyes, pM.GetMorphWeightReference(ArrowFace::UnamusedEyes), 45);
34 AddParameter(ArrowFace::UnamusedMouth, pM.GetMorphWeightReference(ArrowFace::UnamusedMouth), 45);
35 AddParameter(ArrowFace::UwuEyes, pM.GetMorphWeightReference(ArrowFace::UwuEyes), 30);
36
37 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(ArrowFace::vrc_v_ee));
38 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(ArrowFace::vrc_v_aa));
39 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(ArrowFace::vrc_v_dd));
40 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(ArrowFace::vrc_v_rr));
41 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(ArrowFace::vrc_v_ch));
42 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(ArrowFace::vrc_v_oh));
43 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(ArrowFace::vrc_v_ss));
44
45 AddBlinkParameter(pM.GetMorphWeightReference(ArrowFace::Blink));
46 }
47
48 void Default(){
49 ledStripBackground.GetObject()->SetMaterial(GetFaceMaterial());
50 }
51
52 void Angry(){
53 AddParameterFrame(ArrowFace::AngryEyesFlip, 1.0f);
54 AddParameterFrame(ArrowFace::AngryMouth, 1.0f);
56 }
57
58 void Excited(){
59 AddParameterFrame(ArrowFace::ExcitedEyes, 1.0f);
60 AddParameterFrame(ArrowFace::ExcitedMouthTODO, 1.0f);
62 }
63
64 void Happy() {
65 AddParameterFrame(ArrowFace::HappyEyes, 1.0f);
67 }
68
69 void Heart() {
70 AddParameterFrame(ArrowFace::HeartEyes, 1.0f);
72 }
73
74 void Owo() {
75 AddParameterFrame(ArrowFace::OwoEyes, 1.0f);
76 AddParameterFrame(ArrowFace::OwoMouth, 1.0f);
78 }
79
80 void Unamused() {
81 AddParameterFrame(ArrowFace::UnamusedEyes, 1.0f);
82 AddParameterFrame(ArrowFace::UnamusedMouth, 1.0f);
83 }
84
85 void Uwu() {
86 AddParameterFrame(ArrowFace::UwuEyes, 1.0f);
87 AddParameterFrame(ArrowFace::OwoMouth, 1.0f);
89 }
90
91 void SpectrumAnalyzerCallback() override {
92 deltaDisplayBackground.GetObject()->SetMaterial(&hRainbow);
93 ledStripBackground.GetObject()->SetMaterial(&hRainbow);
94 }
95
97 deltaDisplayBackground.GetObject()->SetMaterial(&hRainbow);
98 ledStripBackground.GetObject()->SetMaterial(&hRainbow);
99 }
100
101 void OscilloscopeCallback() override {
102 deltaDisplayBackground.GetObject()->SetMaterial(&hRainbow);
103 ledStripBackground.GetObject()->SetMaterial(&hRainbow);
104 }
105
106public:
107 ArrowAnimation() : ProtogenProject(&cameras, &controller, 3, Vector2D(), Vector2D(192.0f, 94.0f), A0, 20, 11){
108 scene.AddObject(pM.GetObject());
111
112 pM.GetObject()->SetMaterial(GetFaceMaterial());
113 deltaDisplayBackground.GetObject()->SetMaterial(GetFaceMaterial());
114 ledStripBackground.GetObject()->SetMaterial(GetFaceMaterial());
115
117
119
120 SetWiggleSpeed(5.0f);
121 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
122 SetMenuOffset(Vector2D(17.5f, -3.0f));
123 SetMenuSize(Vector2D(192, 56));
124 }
125
126 void Update(float ratio) override {
127 pM.Reset();
128
129 uint8_t mode = Menu::GetFaceState();//change by button press
130
133
134 SelectFace(mode);
135
136 UpdateFace(ratio);
137
138 pM.Update();
139
140 AlignObjectFace(pM.GetObject(), 90.75f);
141
142 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
143 pM.GetObject()->UpdateTransform();
144 }
145
146 void SelectFace(uint8_t code) {
147 if (IsBooped() && code < 8) {
148 Heart();
149 return;
150 }
151
152 switch(code) {
153 case 0: Default(); break;
154 case 1: Angry(); break;
155 case 2: Excited(); break;
156 case 3: Happy(); break;
157 case 4: Heart(); break;
158 case 5: Owo(); break;
159 case 6: Unamused(); break;
160 case 7: Uwu(); break;
161 case 8: AudioReactiveGradientFace(); break;
162 case 9: OscilloscopeFace(); break;
163 default: SpectrumAnalyzerFace(); break;
164 }
165 }
166};
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.
LEDStripBackground ledStripBackground
void Update(float ratio) override
Updates the project state based on the given ratio.
HorizontalRainbow hRainbow
DeltaDisplayBackground deltaDisplayBackground
HUB75Controller controller
HUB75DeltaCameraManager cameras
const __FlashStringHelper * faceArray[12]
void AudioReactiveGradientCallback() override
Callback invoked when the Audio Reactive Gradient face is enabled/updated.
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
A dynamic horizontal rainbow gradient material.
@ 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
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).
@ 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.