ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
AceAnimation.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Templates/ProtogenProjectTemplate.h"
4#include "../../Assets/Models/OBJ/Background.h"
5#include "../../Assets/Models/FBX/Commissions/AceFace.h"
6#include "../../Assets/Models/FBX/Commissions/AceCrash.h"
7#include "../../Assets/Models/FBX/Commissions/AceCrashBackground.h"
8#include "../../Scene/Materials/Utils/MaterialAnimator.h"
9
10#include "../../Camera/CameraManager/Implementations/WS35SplitCameras.h"
11#include "../../Controller/WS35Controller.h"
12
14private:
17
18 AceFace pM;
19 AceCrash crash;
20 AceCrashBackground crashBackground;
21
25
28
29 const __FlashStringHelper* faceArray[12] = {F("DEFAULT"), F("SMIRK"), F("CONTENT"), F("SRPRISE"), F("SRSLY"), F("ANGRY"), F("SCRUNCHY"), F("HAPPY"), F("CRASH"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
30
31 void LinkControlParameters() override {
32 AddParameter(AceFace::Smirk, pM.GetMorphWeightReference(AceFace::Smirk), 25, IEasyEaseAnimator::InterpolationMethod::Cosine);
33 AddParameter(AceFace::Blush, pM.GetMorphWeightReference(AceFace::Blush), 35);
34 AddParameter(AceFace::Content, pM.GetMorphWeightReference(AceFace::Content), 40);
35 AddParameter(AceFace::Surprised, pM.GetMorphWeightReference(AceFace::Surprised), 15);
36 AddParameter(AceFace::Seriously, pM.GetMorphWeightReference(AceFace::Seriously), 30);
37 AddParameter(AceFace::Angry, pM.GetMorphWeightReference(AceFace::Angry), 20);
38 AddParameter(AceFace::Scrunchy, pM.GetMorphWeightReference(AceFace::Scrunchy), 35);
39 AddParameter(AceFace::Happy, pM.GetMorphWeightReference(AceFace::Happy), 45);
40
41 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(AceFace::vrc_v_ee));
42 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(AceFace::vrc_v_aa));
43 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(AceFace::vrc_v_dd));
44 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(AceFace::vrc_v_rr));
45 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(AceFace::vrc_v_ch));
46 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(AceFace::vrc_v_oh));
47 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(AceFace::vrc_v_ss));
48
49 AddBlinkParameter(pM.GetMorphWeightReference(AceFace::Blink));
50
53
56 }
57
58 void Default(){}
59
60 void Smirk(){
61 AddParameterFrame(AceFace::Smirk, 1.0f);
62 }
63
64 void Blush(){
65 AddParameterFrame(AceFace::Blush, 1.0f);
67 }
68
69 void Content(){
71 AddParameterFrame(AceFace::Content, 1.0f);
72 }
73
74 void Surprised(){
75 AddParameterFrame(AceFace::Surprised, 1.0f);
76 }
77
78 void Seriously(){
79 AddParameterFrame(AceFace::Seriously, 1.0f);
80 }
81
82 void Angry(){
83 AddParameterFrame(AceFace::Angry, 1.0f);
84 }
85
86 void Scrunchy(){
88 AddParameterFrame(AceFace::Scrunchy, 1.0f);
89 }
90
91 void Happy(){
93 AddParameterFrame(AceFace::Happy, 1.0f);
94 }
95
102
103public:
104 AceAnimation() : ProtogenProject(&cameras, &controller, 1, Vector2D(10.0f, 5.0f), Vector2D(195.0f, 115.0f), 22, 23, 12){
105 scene.AddObject(pM.GetObject());
106 scene.AddObject(crash.GetObject());
107 scene.AddObject(crashBackground.GetObject());
108
109 pM.GetObject()->SetMaterial(GetFaceMaterial());
110 crash.GetObject()->SetMaterial(&crashMaterial);
111 crashBackground.GetObject()->SetMaterial(&crashBackgroundMaterial);
112
114
116 }
117
118 void Update(float ratio) override {
119 pM.Reset();
120 crash.Reset();
121 crashBackground.Reset();
123
124 uint8_t mode = Menu::GetFaceState();//change by button press
125
128
129 if (IsBooped() && mode != 6){
130 Blush();
131 }
132 else{
133 if (mode == 0) Default();
134 else if (mode == 1) Smirk();
135 else if (mode == 2) Content();
136 else if (mode == 3) Surprised();
137 else if (mode == 4) Seriously();
138 else if (mode == 5) Angry();
139 else if (mode == 6) Scrunchy();
140 else if (mode == 7) Happy();
141 else if (mode == 8) Crash();
142 else if (mode == 9) {
144 }
145 else if (mode == 10){
147 }
148 else {
150 }
151 }
152
153 UpdateFace(ratio);
154
155 pM.SetMorphWeight(AceFace::MoveNose, 1.0f);
156
157 pM.Update();
158 crash.Update();
159 crashBackground.Update();
160
163
164 Object3D* crashObjs[2] = {crash.GetObject(), crashBackground.GetObject()};
165
166 AlignObjectFace(pM.GetObject(), -7.5f);
167 AlignObjectsNoScale(Vector2D(10.0f, 5.0f), Vector2D(195.0f, 115.0f), crashObjs, 2, -2.5f);
168
169 SetWiggleSpeed(5.0f);
170 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
171 SetMenuOffset(Vector2D(2.5f, -3.0f));
172 SetMenuSize(Vector2D(240, 64));
173
174 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
175 pM.GetObject()->UpdateTransform();
176
177 //crash.GetObject()->GetTransform()->SetPosition(Vector3D(-8.0f, 60.0f, 600.0f) + GetWiggleOffset());
178 crash.GetObject()->GetTransform()->SetScale(Vector3D(1.0f, crashMaterial.GetMaterialOpacity(whiteMaterial), 1.0f));
179 crash.GetObject()->UpdateTransform();
180
181 //crashBackground.GetObject()->GetTransform()->SetPosition(Vector3D(-8.0f, 60.0f, 700.0f) + GetWiggleOffset());
182 crashBackground.GetObject()->GetTransform()->SetScale(Vector3D(1.0f, crashBackgroundMaterial.GetMaterialOpacity(lBlueMaterial), 1.0f));
183 crashBackground.GetObject()->UpdateTransform();
184 }
185};
WS35Controller controller
void LinkControlParameters() override
Links external or user-defined control parameters (pure virtual to be implemented).
SimpleMaterial blackMaterial
AceCrash crash
WS35SplitCameraManager cameras
void Scrunchy()
void Seriously()
AceCrashBackground crashBackground
MaterialAnimator< 2 > crashBackgroundMaterial
void Update(float ratio) override
Updates the project state based on the given ratio.
const __FlashStringHelper * faceArray[12]
SimpleMaterial whiteMaterial
void Surprised()
SimpleMaterial lBlueMaterial
MaterialAnimator< 2 > crashMaterial
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.
float GetMaterialOpacity(Material &material)
Retrieves the current opacity of a material.
void AddMaterialFrame(Material &material, float opacity)
Adds a specific frame for a material in the animation.
void Update()
Updates the animator, advancing the transitions.
@ Add
Adds colors together.
Definition Material.h:35
@ 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
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
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 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 AlignObjectsNoScale(Vector2D min, Vector2D max, Object3D **objects, uint8_t objectCount, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns multiple Object3D objects without 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 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.
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 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.
Manages WS2812-based displays for the Delta, Epsilon, and Sigma Protogen heads.
void SetAccentBrightness(uint8_t maxAccentBrightness) override
Sets the maximum accent brightness (not used for this controller).
void SetBrightness(uint8_t maxBrightness) override
Sets the maximum brightness for the displays.