Loading [MathJax]/extensions/tex2jax.js
ProtoTracer  1.0
Real-time 3D rendering and animation engine
All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
SageAnimation.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Templates/ProtogenProjectTemplate.h"
4#include "../../Assets/Models/FBX/Commissions/SageSchlo.h"
5#include "../../Assets/Models/FBX/Commissions/SageSchloSideDisplay.h"
6
7#include "../../Camera/CameraManager/Implementations/HUB75DeltaCameras.h"
8#include "../../Controller/HUB75Controller.h"
9
11private:
12 SageSchlo pM;
13 SageSchloSideDisplay sageSideDisplay;
14
17
18 const __FlashStringHelper* faceArray[14] = {F("NEUTRAL"), F("SURPRISE"), F("DIZZY"), F("ANGRY1"), F("ANGRY2"), F("ANGRY3"), F("OWO"), F("TIRED"), F("SAD"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
19
21
22 bool wiggle = false;
23
24 void LinkControlParameters() override {
25 AddParameter(SageSchlo::Surprised, pM.GetMorphWeightReference(SageSchlo::Surprised), 40);
26 AddParameter(SageSchlo::Blush, pM.GetMorphWeightReference(SageSchlo::Blush), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
27 AddParameter(SageSchlo::Dizzy, pM.GetMorphWeightReference(SageSchlo::Dizzy), 25);
28 AddParameter(SageSchlo::Angry1, pM.GetMorphWeightReference(SageSchlo::Angry1), 20, IEasyEaseAnimator::InterpolationMethod::Cosine);
29 AddParameter(SageSchlo::Angry2, pM.GetMorphWeightReference(SageSchlo::Angry2), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
30 AddParameter(SageSchlo::Angry3, pM.GetMorphWeightReference(SageSchlo::Angry3), 10, IEasyEaseAnimator::InterpolationMethod::Cosine);
31 AddParameter(SageSchlo::OwO, pM.GetMorphWeightReference(SageSchlo::OwO), 10);
32 AddParameter(SageSchlo::Tired, pM.GetMorphWeightReference(SageSchlo::Tired), 50, IEasyEaseAnimator::InterpolationMethod::Cosine);
33 AddParameter(SageSchlo::Sad, pM.GetMorphWeightReference(SageSchlo::Sad), 45, IEasyEaseAnimator::InterpolationMethod::Cosine);
34
35 AddParameter(SageSchloSideDisplay::Battery + 20, sageSideDisplay.GetMorphWeightReference(SageSchloSideDisplay::Battery), 45);
36 AddParameter(SageSchloSideDisplay::BatteryFull + 20, sageSideDisplay.GetMorphWeightReference(SageSchloSideDisplay::BatteryFull), 45);
37 AddParameter(SageSchloSideDisplay::Dizzy + 20, sageSideDisplay.GetMorphWeightReference(SageSchloSideDisplay::Dizzy), 45);
38 AddParameter(SageSchloSideDisplay::Exclamation + 20, sageSideDisplay.GetMorphWeightReference(SageSchloSideDisplay::Exclamation), 45);
39
40 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(SageSchlo::vrc_v_ee));
41 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(SageSchlo::vrc_v_aa));
42 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(SageSchlo::vrc_v_dd));
43 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(SageSchlo::vrc_v_rr));
44 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(SageSchlo::vrc_v_ch));
45 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(SageSchlo::vrc_v_oh));
46 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(SageSchlo::vrc_v_ss));
47
48 AddBlinkParameter(pM.GetMorphWeightReference(SageSchlo::Blink));
49 }
50
51 void Default(){}
52
53 void Surprised(){
54 AddParameterFrame(SageSchlo::Surprised, 1.0f);
55
56 AddParameterFrame(SageSchloSideDisplay::Exclamation + 20, 1.0f);
57
59 }
60
61 void Blush(){
62 AddParameterFrame(SageSchlo::Blush, 1.0f);
63
65 }
66
67 void Dizzy(){
68 AddParameterFrame(SageSchlo::Dizzy, 1.0f);
69
70 AddParameterFrame(SageSchloSideDisplay::Dizzy + 20, 1.0f);
71
73
74 wiggle = true;
75 }
76
77 void Angry1(){
78 AddParameterFrame(SageSchlo::Angry1, 1.0f);
79
80 AddParameterFrame(SageSchloSideDisplay::Exclamation + 20, 1.0f);
81 }
82
83 void Angry2(){
84 AddParameterFrame(SageSchlo::Angry2, 1.0f);
86
87 AddParameterFrame(SageSchloSideDisplay::Exclamation + 20, 1.0f);
88 }
89
90 void Angry3(){
91 AddParameterFrame(SageSchlo::Angry3, 1.0f);
93
94 AddParameterFrame(SageSchloSideDisplay::Exclamation + 20, 1.0f);
95 }
96
97 void OwO(){
98 AddParameterFrame(SageSchlo::OwO, 1.0f);
99
101 }
102
103 void Tired(){
104 AddParameterFrame(SageSchlo::Tired, 1.0f);
105
106 AddParameterFrame(SageSchloSideDisplay::Battery + 20, 1.0f);
107 AddParameterFrame(SageSchloSideDisplay::BatteryFull + 20, batteryChargeFunc.Update());
108
110 }
111
112 void Sad(){
113 AddParameterFrame(SageSchlo::Sad, 1.0f);
114 }
115
116public:
117 SageAnimation() : ProtogenProject(&cameras, &controller, 2, Vector2D(), Vector2D(192.0f, 94.0f), 22, 23, 12){
118 scene.AddObject(pM.GetObject());
119 scene.AddObject(sageSideDisplay.GetObject());
120
121 pM.GetObject()->SetMaterial(GetFaceMaterial());
122 sageSideDisplay.GetObject()->SetMaterial(GetFaceMaterial());
123
125
127 }
128
129 void Update(float ratio) override {
130 pM.Reset();
131 sageSideDisplay.Reset();
132
134 wiggle = false;
135
138
139 uint8_t mode = Menu::GetFaceState();//change by button press
140
141 if (IsBooped()){
142 Blush();
143 }
144 else{
145 if (mode == 0) Default();
146 else if (mode == 1) Surprised();
147 else if (mode == 2) Dizzy();
148 else if (mode == 3) Angry1();
149 else if (mode == 4) Angry2();
150 else if (mode == 5) Angry3();
151 else if (mode == 6) OwO();
152 else if (mode == 7) Tired();
153 else if (mode == 8) Sad();
154 else if (mode == 9) {
156 }
157 else if (mode == 10){
159 }
160 else {
162 }
163 }
164
165 UpdateFace(ratio);
166
167 pM.Update();
168 sageSideDisplay.Update();
169
170 AlignObjectFace(pM.GetObject(), 0.0f);
171 AlignObjectNoScaleRear(sageSideDisplay.GetObject(), 0.0f, 0.0f);
172
173 SetWiggleSpeed(5.0f);
174 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
175 SetMenuOffset(Vector2D(17.5f, -3.0f));
176 SetMenuSize(Vector2D(192, 56));
177
178 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
179 pM.GetObject()->UpdateTransform();
180
181 if(wiggle){
182 sageSideDisplay.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
183 }
184 else{
185 sageSideDisplay.GetObject()->GetTransform()->SetPosition(Vector3D(2.0f, 0.0f, 0.0f));
186 }
187
188 sageSideDisplay.GetObject()->GetTransform()->SetScaleOffset(sageSideDisplay.GetObject()->GetCenterOffset());
189 sageSideDisplay.GetObject()->GetTransform()->SetScale(Vector3D(1.45f, 1.45f, 1.45f));
190
191 sageSideDisplay.GetObject()->UpdateTransform();
192 }
193};
A class to generate various waveform functions with customizable parameters.
@ Sawtooth
Sawtooth waveform.
float Update()
Updates and calculates the next value of the waveform.
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
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 EnableBlinking()
Enables blinking (resets and plays the blink track).
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 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 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 DisableBlinking()
Disables blinking (pauses and resets the blink track).
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 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 LinkControlParameters() override
Links external or user-defined control parameters (pure virtual to be implemented).
SageSchloSideDisplay sageSideDisplay
void Update(float ratio) override
Updates the project state based on the given ratio.
HUB75Controller controller
HUB75DeltaCameraManager cameras
FunctionGenerator batteryChargeFunc
const __FlashStringHelper * faceArray[14]
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
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26
@ 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.