ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
UnicornZhenjaAnimation.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/UnicornZhenja.h"
6#include "../../Scene/Materials/Animated/TVStatic.h"
7#include "../../Scene/Materials/Animated/HorizontalRainbow.h"
8
9#include "../../Camera/CameraManager/Implementations/HUB75DeltaCameras.h"
10#include "../../Controller/HUB75Controller.h"
11
13private:
16 UnicornZhenja pM;
17 DeltaDisplayBackground deltaDisplayBackground;
20
21
22 const __FlashStringHelper* faceArray[14] = {F("DEFAULT"), F("UPSET"), F("SALTY"), F("SLEEPY"), F("SAD"), F("LOADING"), F("DIZZY"), F("HEART"), F("DEAD"), F("PUPIL"), F("STATIC"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
23
24 void LinkControlParameters() override {//Called from parent
25 AddParameter(UnicornZhenja::Upset, pM.GetMorphWeightReference(UnicornZhenja::Upset), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
26 AddParameter(UnicornZhenja::Salty, pM.GetMorphWeightReference(UnicornZhenja::Salty), 20);
27 AddParameter(UnicornZhenja::Sleepy, pM.GetMorphWeightReference(UnicornZhenja::Sleepy), 45, IEasyEaseAnimator::InterpolationMethod::Cosine);
28 AddParameter(UnicornZhenja::Sad, pM.GetMorphWeightReference(UnicornZhenja::Sad), 45, IEasyEaseAnimator::InterpolationMethod::Cosine);
29 AddParameter(UnicornZhenja::Loading, pM.GetMorphWeightReference(UnicornZhenja::Loading), 25, IEasyEaseAnimator::InterpolationMethod::Cosine);
30 AddParameter(UnicornZhenja::Dizzy, pM.GetMorphWeightReference(UnicornZhenja::Dizzy), 40);
31 AddParameter(UnicornZhenja::Heart, pM.GetMorphWeightReference(UnicornZhenja::Heart), 25);
32 AddParameter(UnicornZhenja::Dead, pM.GetMorphWeightReference(UnicornZhenja::Dead), 15);
33 AddParameter(UnicornZhenja::Pupil, pM.GetMorphWeightReference(UnicornZhenja::Pupil), 15);
34 AddParameter(UnicornZhenja::Static, pM.GetMorphWeightReference(UnicornZhenja::Static), 60, IEasyEaseAnimator::InterpolationMethod::Cosine);
35
36 AddParameter(UnicornZhenja::HideHeart, pM.GetMorphWeightReference(UnicornZhenja::HideHeart), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
37 AddParameter(UnicornZhenja::HideLoading, pM.GetMorphWeightReference(UnicornZhenja::HideLoading), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
38 AddParameter(UnicornZhenja::HideSpiral, pM.GetMorphWeightReference(UnicornZhenja::HideSpiral), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
39
40 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_ee));
41 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_aa));
42 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_dd));
43 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_rr));
44 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_ch));
45 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_oh));
46 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(UnicornZhenja::vrc_v_ss));
47
48 AddBlinkParameter(pM.GetMorphWeightReference(UnicornZhenja::Blink));
49 }
50
51 void Default(){
52 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
53 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
54 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
55
57 }
58
59 void Upset(){
60 AddParameterFrame(UnicornZhenja::Upset, 1.0f);
61 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
62 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
63 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
64
66 }
67
68 void Salty(){
69 AddParameterFrame(UnicornZhenja::Salty, 1.0f);
70 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
71 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
72 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
73
75 }
76
77 void Sleepy(){
78 AddParameterFrame(UnicornZhenja::Sleepy, 1.0f);
79 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
80 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
81
83 }
84
85 void Sad(){
86 AddParameterFrame(UnicornZhenja::Sad, 1.0f);
87 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
88 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
89 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
90
92 }
93
94 void Loading(){
95 AddParameterFrame(UnicornZhenja::Loading, 1.0f);
96 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
97 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
98
100 }
101
102 void Dizzy(){
103 AddParameterFrame(UnicornZhenja::Dizzy, 1.0f);
104 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
105 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
106
108 }
109
110 void Heart(){
111 AddParameterFrame(UnicornZhenja::Heart, 1.0f);
112 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
113 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
114
116 }
117
118 void Dead(){
119 AddParameterFrame(UnicornZhenja::Dead, 1.0f);
120 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
121 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
122
124 }
125
126 void Pupil(){
127 AddParameterFrame(UnicornZhenja::Pupil, 1.0f);
128 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
129 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
130 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
131
133 }
134
135 void Static(){
136 HideFace();
137
138 AddParameterFrame(UnicornZhenja::Loading, 1.0f);
139 AddParameterFrame(UnicornZhenja::HideHeart, 1.0f);
140 AddParameterFrame(UnicornZhenja::HideLoading, 1.0f);
141 AddParameterFrame(UnicornZhenja::HideSpiral, 1.0f);
142
145 }
146
147public:
149 scene.AddObject(pM.GetObject());
151
152 pM.GetObject()->SetMaterial(GetFaceMaterial());
153 deltaDisplayBackground.GetObject()->SetMaterial(GetFaceMaterial());
154
155 AddMaterial(Material::Replace, &tvStatic, 40, 0.0f, 1.0f);
159
161
163
164 SetWiggleSpeed(5.0f);
165 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
166 SetMenuOffset(Vector2D(17.5f, -3.0f));
167 SetMenuSize(Vector2D(192, 56));
168 }
169
170 void Update(float ratio) override {
171 pM.Reset();
172
173 uint8_t mode = Menu::GetFaceState();//change by button press
174
177
178 if (IsBooped()){
179 Static();
180 }
181 else{
182 if (mode == 0) Default();
183 else if (mode == 1) Upset();
184 else if (mode == 2) Salty();
185 else if (mode == 3) Sleepy();
186 else if (mode == 4) Sad();
187 else if (mode == 5) Loading();
188 else if (mode == 6) Dizzy();
189 else if (mode == 7) Heart();
190 else if (mode == 8) Dead();
191 else if (mode == 9) Pupil();
192 else if (mode == 10) {
195 }
196 else if (mode == 11){
199 }
200 else {
203 }
204 }
205
206 tvStatic.Update(ratio);
208
209 UpdateFace(ratio);
210
211 pM.Update();
212
213 AlignObjectFace(pM.GetObject(), 0.0f);
214
215 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
216 pM.GetObject()->UpdateTransform();
217 }
218};
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.
void Update(float ratio)
Updates the gradient animation based on the provided time ratio.
@ Cosine
Smooth cosine interpolation.
@ Replace
Replaces the base color.
Definition Material.h:44
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 AddBackgroundMaterialFrame(Color color, float opacity=0.8f)
Adds a material frame to the background from a color enum.
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 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.
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).
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 HideFace()
Hides the face by setting its offset parameter.
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 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 AddObject(Object3D *object)
Adds a 3D object to the scene.
Definition Scene.cpp:31
Simulates a TV static effect with noise, scanlines, and color variations.
Definition TVStatic.h:30
void Update(float ratio)
Updates the animation parameters for the TV static effect.
Definition TVStatic.cpp:3
void LinkControlParameters() override
Links external or user-defined control parameters (pure virtual to be implemented).
HorizontalRainbow horizontalRainbow
void Update(float ratio) override
Updates the project state based on the given ratio.
DeltaDisplayBackground deltaDisplayBackground
HUB75DeltaCameraManager cameras
const __FlashStringHelper * faceArray[14]
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.