ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
DrGonzoProject.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Templates/ProtogenProjectTemplate.h"
4#include "../../Assets/Models/FBX/Commissions/DrGonzoFace.h"
5#include "../../Assets/Models/FBX/Commissions/DrGonzoSD.h"
6#include "../../Assets/Models/FBX/Commissions/DrGonzoTears.h"
7
8#include "../../Camera/CameraManager/Implementations/HUB75DeltaCameras.h"
9#include "../../Controller/HUB75Controller.h"
10
11#include "../../Animation/MorphTransform.h"
12
13//#define NEOTRELLISMENU
14
16private:
19
20 DrGonzoFace pM;
21 DrGonzoSD sideDisplay;
22 DrGonzoTears tears;
23 //DeltaDisplayBackground deltaDisplayBackground;
24
26
28
32
34
36
38
39 const __FlashStringHelper* faceArray[14] = {F("DEFAULT"), F("HAPPY"), F("ANGY"), F("LEWD"), F("LOADING"), F("QUESTION"), F("DIZZY"), F("SAD"), F("OWO"), F("BOOP"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
40
41 void LinkControlParameters() override {
42 AddParameter(DrGonzoFace::Happy, pM.GetMorphWeightReference(DrGonzoFace::Happy), 30);
43 AddParameter(DrGonzoFace::Angy, pM.GetMorphWeightReference(DrGonzoFace::Angy), 15);
44 AddParameter(DrGonzoFace::Lewd, pM.GetMorphWeightReference(DrGonzoFace::Lewd), 35);
45 AddParameter(DrGonzoFace::Loading, pM.GetMorphWeightReference(DrGonzoFace::Loading), 20);
46 AddParameter(DrGonzoFace::LoadingB1, pM.GetMorphWeightReference(DrGonzoFace::LoadingB1), 30, IEasyEaseAnimator::InterpolationMethod::Cosine);
47 AddParameter(DrGonzoFace::LoadingB2, pM.GetMorphWeightReference(DrGonzoFace::LoadingB2), 30, IEasyEaseAnimator::InterpolationMethod::Cosine);
48 AddParameter(DrGonzoFace::LoadingB3, pM.GetMorphWeightReference(DrGonzoFace::LoadingB3), 30, IEasyEaseAnimator::InterpolationMethod::Cosine);
49 AddParameter(DrGonzoFace::LoadingB4, pM.GetMorphWeightReference(DrGonzoFace::LoadingB4), 30, IEasyEaseAnimator::InterpolationMethod::Cosine);
50 AddParameter(DrGonzoFace::LoadingB5, pM.GetMorphWeightReference(DrGonzoFace::LoadingB5), 30, IEasyEaseAnimator::InterpolationMethod::Cosine);
51 AddParameter(DrGonzoFace::Question, pM.GetMorphWeightReference(DrGonzoFace::Question), 45);
52 AddParameter(DrGonzoFace::Dizzy, pM.GetMorphWeightReference(DrGonzoFace::Dizzy), 45);
53 AddParameter(DrGonzoFace::Sad, pM.GetMorphWeightReference(DrGonzoFace::Sad), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
54 AddParameter(DrGonzoFace::OwO, pM.GetMorphWeightReference(DrGonzoFace::OwO), 40);
55 AddParameter(DrGonzoFace::Boop, pM.GetMorphWeightReference(DrGonzoFace::Boop), 35);
56
57 AddParameter(DrGonzoSD::Angy + 50, sideDisplay.GetMorphWeightReference(DrGonzoSD::Angy), 15);
58 AddParameter(DrGonzoSD::Lewd + 50, sideDisplay.GetMorphWeightReference(DrGonzoSD::Lewd), 35);
59 AddParameter(DrGonzoSD::OwO + 50, sideDisplay.GetMorphWeightReference(DrGonzoSD::OwO), 20);
60 AddParameter(DrGonzoSD::Question + 50, sideDisplay.GetMorphWeightReference(DrGonzoSD::Question), 30);
61
62 AddParameter(DrGonzoFace::HideBlush, pM.GetMorphWeightReference(DrGonzoFace::HideBlush), 15, IEasyEaseAnimator::InterpolationMethod::Cosine, true);
63
64 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_ee));
65 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_aa));
66 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_dd));
67 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_rr));
68 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_ch));
69 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_oh));
70 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(DrGonzoFace::vrc_v_ss));
71
72 AddBlinkParameter(pM.GetMorphWeightReference(DrGonzoFace::Blink));
73
76
77 morphTransform.AddMorph(DrGonzoFace::LoadingB1, Vector3D(0.0f, -17.5f, 0.0f), Vector3D(1.6f, 6.0f, 1.0f));
78 morphTransform.AddMorph(DrGonzoSD::Angy + 50, Vector3D(), Vector3D(1.5f, 2.0f, 1.0f), Vector3D(0.0f, 0.0f, 0.0f));
79 morphTransform.AddMorph(DrGonzoSD::Lewd + 50, Vector3D(), Vector3D(1.5f, 1.5f, 1.0f));
80 morphTransform.AddMorph(DrGonzoSD::OwO + 50, Vector3D(1.0f, -8.5f, 0.0f), Vector3D(1.3f, 3.0f, 1.0f));
81 morphTransform.AddMorph(DrGonzoSD::Question + 50, Vector3D(), Vector3D(1.0f, 1.1f, 1.0f));
82 }
83
84 void Default(){
85 tears.GetObject()->Disable();
86 }
87
88 void Happy(){
89 tears.GetObject()->Disable();
90
91 AddParameterFrame(DrGonzoFace::Happy, 1.0f);
92 }
93
94 void Angy(){
95 tears.GetObject()->Disable();
96
97 AddParameterFrame(DrGonzoFace::Angy, 1.0f);
98 AddParameterFrame(DrGonzoSD::Angy + 50, 1.0f);
99
100 }
101
102 void Lewd(){
103 tears.GetObject()->Disable();
104
105 AddParameterFrame(DrGonzoFace::HideBlush, 0.0f);
106 AddParameterFrame(DrGonzoFace::Lewd, 1.0f);
107 AddParameterFrame(DrGonzoSD::Lewd + 50, 1.0f);
108
110 }
111
112 void Loading(){
113 tears.GetObject()->Disable();
114
115 SetWiggleSpeed(1.0f);
117 AddParameterFrame(DrGonzoFace::HideBlush, 0.0f);
118 AddParameterFrame(DrGonzoFace::Loading, 1.0f);
120
121 float loadingRatio = loadingBar.Update();
122 float setRatio = 0.0f;
123
124 if(loadingRatio < 0.15f){
125
126 }
127 else if(loadingRatio < 0.30f){
128 setRatio = Mathematics::Map(loadingRatio, 0.0f, 0.2f, 0.0f, 1.0f);
129
130 AddParameterFrame(DrGonzoFace::LoadingB1, setRatio);
131 }
132 else if(loadingRatio < 0.55f){
133 setRatio = Mathematics::Map(loadingRatio, 0.2f, 0.4f, 0.0f, 1.0f);
134
135 AddParameterFrame(DrGonzoFace::LoadingB1, 1.0f);
136 AddParameterFrame(DrGonzoFace::LoadingB2, setRatio);
137 }
138 else if(loadingRatio < 0.7f){
139 setRatio = Mathematics::Map(loadingRatio, 0.4f, 0.6f, 0.0f, 1.0f);
140
141 AddParameterFrame(DrGonzoFace::LoadingB1, 1.0f);
142 AddParameterFrame(DrGonzoFace::LoadingB2, 1.0f);
143 AddParameterFrame(DrGonzoFace::LoadingB3, setRatio);
144 }
145 else if(loadingRatio < 0.85f){
146 setRatio = Mathematics::Map(loadingRatio, 0.6f, 0.8f, 0.0f, 1.0f);
147
148 AddParameterFrame(DrGonzoFace::LoadingB1, 1.0f);
149 AddParameterFrame(DrGonzoFace::LoadingB2, 1.0f);
150 AddParameterFrame(DrGonzoFace::LoadingB3, 1.0f);
151 AddParameterFrame(DrGonzoFace::LoadingB4, setRatio);
152 }
153 else{
154 setRatio = Mathematics::Map(loadingRatio, 0.8f, 1.0f, 0.0f, 1.0f);
155
156 AddParameterFrame(DrGonzoFace::LoadingB1, 1.0f);
157 AddParameterFrame(DrGonzoFace::LoadingB2, 1.0f);
158 AddParameterFrame(DrGonzoFace::LoadingB3, 1.0f);
159 AddParameterFrame(DrGonzoFace::LoadingB4, 1.0f);
160 AddParameterFrame(DrGonzoFace::LoadingB5, setRatio);
161 }
162 }
163
164 void Question(){
165 tears.GetObject()->Disable();
166
168 AddParameterFrame(DrGonzoFace::Question, 1.0f);
169 AddParameterFrame(DrGonzoSD::Question + 50, 1.0f);
170 }
171
172 void Dizzy(){
173 tears.GetObject()->Disable();
174
176 AddParameterFrame(DrGonzoFace::Dizzy, 1.0f);
177 }
178
179 void Sad(){
180 tears.GetObject()->Enable();
181
182 AddParameterFrame(DrGonzoFace::Sad, 1.0f);
183
184 tears.SetMorphWeight(DrGonzoTears::DropTear1, drip1.Update());
185 tears.SetMorphWeight(DrGonzoTears::DropTear2, drip2.Update());
186 tears.SetMorphWeight(DrGonzoTears::DropTear3, drip3.Update());
187 }
188
189 void OwO(){
190 tears.GetObject()->Disable();
191
193 AddParameterFrame(DrGonzoFace::OwO, 1.0f);
194 AddParameterFrame(DrGonzoSD::OwO + 50, 1.0f);
195
196 //AddMaterialFrame(Color::CRAINBOW);
197 }
198
199 void Boop(){
200 tears.GetObject()->Disable();
201
202 AddParameterFrame(DrGonzoFace::Boop, 1.0f);
203 }
204
205public:
206 DrGonzoProject() : ProtogenProject(&cameras, &controller, 3, Vector2D(), Vector2D(192.0f, 94.0f), 22, 23, 12){
207 scene.AddObject(pM.GetObject());
208 scene.AddObject(sideDisplay.GetObject());
209 scene.AddObject(tears.GetObject());
210 //scene.AddObject(deltaDisplayBackground.GetObject());
211
212 pM.GetObject()->SetMaterial(GetFaceMaterial());
213 sideDisplay.GetObject()->SetMaterial(&sideDisplayMaterial);
214 tears.GetObject()->SetMaterial(&lBlue);
215 //deltaDisplayBackground.GetObject()->SetMaterial(GetFaceMaterial());
216
218
220
221 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
222 SetMenuOffset(Vector2D(17.5f, -3.0f));
223 SetMenuSize(Vector2D(192, 56));
224 }
225
226 void Update(float ratio) override {
227 SetWiggleSpeed(3.0f);
229
230 pM.Reset();
231 sideDisplay.Reset();
232 tears.Reset();
233
234 tears.GetObject()->ResetVertices();
235 tearTransform = GetAlignmentTransform(Vector2D(100.0f * GetFaceScale(), 60.0f), Vector2D(140.0f * GetFaceScale(), 100.0f), tears.GetObject(), 0.0f);
236
237 uint8_t mode = Menu::GetFaceState();//change by button press
238
241
242 if (IsBooped()){
243 Boop();
244 }
245 else{
246 if (mode == 0) Default();
247 else if (mode == 1) Happy();
248 else if (mode == 2) Angy();
249 else if (mode == 3) Lewd();
250 else if (mode == 4) Loading();
251 else if (mode == 5) Question();
252 else if (mode == 6) Dizzy();
253 else if (mode == 7) Sad();
254 else if (mode == 8) OwO();
255 else if (mode == 9) {
257 }
258 else if (mode == 10){
260 }
261 else {
263 }
264 }
265
266 UpdateFace(ratio);
267
268 *sideDisplay.GetMorphWeightReference(DrGonzoSD::Merge) = 1.0f;
269 *sideDisplay.GetMorphWeightReference(DrGonzoSD::LoadingB1) = *pM.GetMorphWeightReference(DrGonzoFace::LoadingB1);
270 *sideDisplay.GetMorphWeightReference(DrGonzoSD::LoadingB2) = *pM.GetMorphWeightReference(DrGonzoFace::LoadingB2);
271 *sideDisplay.GetMorphWeightReference(DrGonzoSD::LoadingB3) = *pM.GetMorphWeightReference(DrGonzoFace::LoadingB3);
272 *sideDisplay.GetMorphWeightReference(DrGonzoSD::LoadingB4) = *pM.GetMorphWeightReference(DrGonzoFace::LoadingB4);
273 *sideDisplay.GetMorphWeightReference(DrGonzoSD::LoadingB5) = *pM.GetMorphWeightReference(DrGonzoFace::LoadingB5);
274
275 pM.Update();
276 sideDisplay.Update();
277 tears.Update();
278
280
281 AlignObjectFace(pM.GetObject(), 0.0f);
282 AlignObjectRear(sideDisplay.GetObject(), 0.0f);
283
284 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
285 pM.GetObject()->UpdateTransform();
286
287 morphTransform.SetMorphPositionOffset(DrGonzoSD::Angy + 50, Vector3D(3.5f, -11.0f, 0.0f) + GetWiggleOffset());
288 morphTransform.SetMorphPositionOffset(DrGonzoSD::Lewd + 50, Vector3D(10.0f, -10.0f, 0.0f) + GetWiggleOffset());
289 morphTransform.SetMorphPositionOffset(DrGonzoSD::Question + 50, Vector3D(17.5f, -7.5f, 0.0f) + GetWiggleOffset());
290
291 sideDisplay.GetObject()->GetTransform()->SetPosition(morphTransform.GetPositionOffset());
292 sideDisplay.GetObject()->GetTransform()->SetScale(morphTransform.GetScaleOffset());
293 sideDisplay.GetObject()->GetTransform()->SetScaleOffset(sideDisplay.GetObject()->GetCenterOffset());
294 sideDisplay.GetObject()->GetTransform()->SetRotation(morphTransform.GetRotationOffset());
295 sideDisplay.GetObject()->GetTransform()->SetRotationOffset(sideDisplay.GetObject()->GetCenterOffset());
296 sideDisplay.GetObject()->UpdateTransform();
297
298 //Serial.print(morphTransform.GetPositionOffset().ToString()); Serial.print('\t');
299 //Serial.print(morphTransform.GetScaleOffset().ToString()); Serial.print('\t');
300 //Serial.println(morphTransform.GetRotationOffset().ToString());
301
303
304 tears.GetObject()->SetTransform(tearTransform);
305 tears.GetObject()->UpdateTransform();
306
307 //Serial.println(tears.GetObject()->GetCenterOffset().ToString());
308 }
309};
FunctionGenerator drip1
void LinkControlParameters() override
Links external or user-defined control parameters (pure virtual to be implemented).
FunctionGenerator drip3
FunctionGenerator loadingBar
Transform tearTransform
DrGonzoSD sideDisplay
DrGonzoFace pM
void Update(float ratio) override
Updates the project state based on the given ratio.
HUB75Controller controller
HUB75DeltaCameraManager cameras
MaterialAnimator< 2 > sideDisplayMaterial
const __FlashStringHelper * faceArray[14]
MorphTransform< 5 > morphTransform
DrGonzoTears tears
FunctionGenerator drip2
SimpleMaterial lBlue
A class to generate various waveform functions with customizable parameters.
@ Gravity
Gravity-like function.
@ 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.
Animates transitions and blends between multiple materials.
void AddMaterial(Material::Method method, Material *material, uint16_t frames, float minOpacity, float maxOpacity)
Adds a material to the animation with specified properties.
void SetBaseMaterial(Material::Method method, Material *material)
Sets the base material for the animation.
void AddMaterialFrame(Material &material, float opacity)
Adds a specific frame for a material in the animation.
void Update()
Updates the animator, advancing the transitions.
@ Replace
Replaces the base color.
Definition Material.h:44
@ Base
The base material color.
Definition Material.h:34
static T Map(T value, T inLow, T inMax, T outMin, T outMax)
Maps a value from one range to another.
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
A template class for managing 3D transformations using morph targets.
void SetMorphPositionOffset(uint16_t dictionaryValue, Vector3D positionOffset)
Sets the position offset for a specific morph target.
Vector3D GetRotationOffset()
Retrieves the combined rotation offset for all active morph targets.
void AddMorph(uint16_t dictionaryValue, Vector3D positionOffset)
Adds a morph target with a position offset.
Vector3D GetPositionOffset()
Retrieves the combined position offset for all active morph targets.
Vector3D GetScaleOffset()
Retrieves the combined scale offset for all active morph targets.
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 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 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 SetWiggleSpeed(float multiplier)
Sets the overall wiggle speed for both X and Y function generators.
EasyEaseAnimator< 60 > eEA
Animator that eases parameter transitions.
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.
float GetFaceScale()
Computes the face scaling based on a user-defined face size.
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.
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.
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
void AddObject(Object3D *object)
Adds a 3D object to the scene.
Definition Scene.cpp:31
A material that applies a single, solid RGB color to surfaces.
Represents a 3D transformation including position, rotation, and scale.
Definition Transform.h:22
Vector3D GetPosition()
Gets the position of the object.
Definition Transform.cpp:69
void SetPosition(const Vector3D &position)
Sets the position of the object.
Definition Transform.cpp:65
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.