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
FursuitEyesV1.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/RoboEyes.h"
6
7#include "../../Scene/Materials/Animated/TVStatic.h"
8
9#include "../../Camera/CameraManager/Implementations/APA102CamerasV1.h"
10#include "../../Controller/APA102Controller.h"
11
13private:
16 RoboEyes pML;
17 RoboEyes pMR;
18
20
21 const __FlashStringHelper* faceArray[10] = {F("DEFAULT"), F("CLOSE"), F("DOT"), F("SAD"), F("QUESTION"), F("DISAPPOI"), F("ANGRY"), F("HEART"), F("AUDIO1"), F("AUDIO2")};
22
23 void LinkControlParameters() override {//Called from parent
24 AddParameter(RoboEyes::Close, pML.GetMorphWeightReference(RoboEyes::Close), 60);
25 AddParameter(RoboEyes::Dot, pML.GetMorphWeightReference(RoboEyes::Dot), 90, IEasyEaseAnimator::InterpolationMethod::Cosine);
26 AddParameter(RoboEyes::Sad, pML.GetMorphWeightReference(RoboEyes::Sad), 120, IEasyEaseAnimator::InterpolationMethod::Cosine);
27 AddParameter(RoboEyes::Question, pML.GetMorphWeightReference(RoboEyes::Question), 120);
28 AddParameter(RoboEyes::Disappoint, pML.GetMorphWeightReference(RoboEyes::Disappoint), 100);
29 AddParameter(RoboEyes::Angry, pML.GetMorphWeightReference(RoboEyes::Angry), 80, IEasyEaseAnimator::InterpolationMethod::Cosine);
30 AddParameter(RoboEyes::Heart, pML.GetMorphWeightReference(RoboEyes::Heart), 120);
31 AddParameter(RoboEyes::MirrorQuestion, pML.GetMorphWeightReference(RoboEyes::MirrorQuestion), 60);
32
33 AddParameter(RoboEyes::Close + 10, pMR.GetMorphWeightReference(RoboEyes::Close), 60);
34 AddParameter(RoboEyes::Dot + 10, pMR.GetMorphWeightReference(RoboEyes::Dot), 90, IEasyEaseAnimator::InterpolationMethod::Cosine);
35 AddParameter(RoboEyes::Sad + 10, pMR.GetMorphWeightReference(RoboEyes::Sad), 120, IEasyEaseAnimator::InterpolationMethod::Cosine);
36 AddParameter(RoboEyes::Question + 10, pMR.GetMorphWeightReference(RoboEyes::Question), 120);
37 AddParameter(RoboEyes::Disappoint + 10, pMR.GetMorphWeightReference(RoboEyes::Disappoint), 100);
38 AddParameter(RoboEyes::Angry + 10, pMR.GetMorphWeightReference(RoboEyes::Angry), 80, IEasyEaseAnimator::InterpolationMethod::Cosine);
39 AddParameter(RoboEyes::Heart + 10, pMR.GetMorphWeightReference(RoboEyes::Heart), 120);
40 AddParameter(RoboEyes::MirrorQuestion + 10, pMR.GetMorphWeightReference(RoboEyes::MirrorQuestion), 60);
41
42 AddViseme(Viseme::MouthShape::EE, pML.GetMorphWeightReference(RoboEyes::Empty));
43 AddViseme(Viseme::MouthShape::AH, pML.GetMorphWeightReference(RoboEyes::Empty));
44 AddViseme(Viseme::MouthShape::UH, pML.GetMorphWeightReference(RoboEyes::Empty));
45 AddViseme(Viseme::MouthShape::AR, pML.GetMorphWeightReference(RoboEyes::Empty));
46 AddViseme(Viseme::MouthShape::ER, pML.GetMorphWeightReference(RoboEyes::Empty));
47 AddViseme(Viseme::MouthShape::OO, pML.GetMorphWeightReference(RoboEyes::Empty));
48 AddViseme(Viseme::MouthShape::SS, pML.GetMorphWeightReference(RoboEyes::Empty));
49
50 AddBlinkParameter(pML.GetMorphWeightReference(RoboEyes::Blink));
51 AddBlinkParameter(pMR.GetMorphWeightReference(RoboEyes::Blink));
52 }
53
54 void Default(){
56 }
57
58 void Close(){
59 AddParameterFrame(RoboEyes::Close, 1.0f);
60 AddParameterFrame(RoboEyes::Close + 10, 1.0f);
61
63 }
64
65 void Dot(){
66 AddParameterFrame(RoboEyes::Dot, 1.0f);
67 AddParameterFrame(RoboEyes::Dot + 10, 1.0f);
69
71 }
72
73 void Sad(){
74 AddParameterFrame(RoboEyes::Sad, 1.0f);
75 AddParameterFrame(RoboEyes::Sad + 10, 1.0f);
76
78 }
79
80 void Question(){
81 if(millis() % 2000 > 1000) {
82 AddParameterFrame(RoboEyes::Question, 1.0f);
83 AddParameterFrame(RoboEyes::Question + 10, 1.0f);
84 }
85 else{
86 AddParameterFrame(RoboEyes::MirrorQuestion, 1.0f);
87 AddParameterFrame(RoboEyes::MirrorQuestion + 10, 1.0f);
88 }
89
91 }
92
93 void Disappoint(){
94 AddParameterFrame(RoboEyes::Disappoint, 1.0f);
95 AddParameterFrame(RoboEyes::Disappoint + 10, 1.0f);
96
98 }
99
100 void Angry(){
101 AddParameterFrame(RoboEyes::Angry, 1.0f);
102 AddParameterFrame(RoboEyes::Angry + 10, 1.0f);
104
106 }
107
108 void Heart(){
109 AddParameterFrame(RoboEyes::Heart, 1.0f);
110 AddParameterFrame(RoboEyes::Heart + 10, 1.0f);
111
113 }
114
115public:
116 FursuitEyesV1() : ProtogenProject(&cameras, &controller, 2, Vector2D(-110.0f, -36.0f), Vector2D(110.0f, 36.0f), 15, 21, 10){
117 scene.AddObject(pML.GetObject());
118 scene.AddObject(pMR.GetObject());
119
120 pML.GetObject()->SetMaterial(GetFaceMaterial());
121 pMR.GetObject()->SetMaterial(GetFaceMaterial());
122
124
126
127 SetWiggleSpeed(5.0f);
128 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
129 SetMenuOffset(Vector2D(-110.0f, -36.0f));
130 SetMenuSize(Vector2D(220.0f, 72.0f));
131 }
132
133 void Update(float ratio) override {
134 pML.Reset();
135 pMR.Reset();
136
137 uint8_t mode = Menu::GetFaceState();//change by button press
138
141
142 SelectFace(mode);
143
144 UpdateFace(ratio);
145
146 pML.Update();
147 pMR.Update();
148
149
150 AlignObject(Vector2D(-123.0f, -48.0f), Vector2D(-14.0f, 48.0f), pML.GetObject(), 0.0f);
151 AlignObject(Vector2D(18.0f, -48.0f), Vector2D(127.0f, 48.0f), pMR.GetObject(), 0.0f);
152
153
154
155 pML.GetObject()->GetTransform()->SetPosition(GetWiggleOffset() * 2.0f);
156 pML.GetObject()->UpdateTransform();
157
158 pMR.GetObject()->GetTransform()->SetScale(Vector3D(-1.0f, 1.0f, 1.0f));
159 pMR.GetObject()->GetTransform()->SetScaleOffset(pMR.GetObject()->GetCenterOffset());
160 pMR.GetObject()->GetTransform()->SetPosition(GetWiggleOffset() * Vector3D(-2.0f, 2.0f, 2.0f));
161 pMR.GetObject()->UpdateTransform();
162 }
163
164 void SelectFace(uint8_t code) {
165 switch(code) {
166 case 0: Default(); break;
167 case 1: Close(); break;
168 case 2: Dot(); break;
169 case 3: Sad(); break;
170 case 4: Question(); break;
171 case 5: Disappoint(); break;
172 case 6: Angry(); break;
173 case 7: Heart(); break;
174 case 8: SpectrumAnalyzerFace(); break;
175 default: OscilloscopeFace(); break;
176 }
177 }
178};
Manages APA102 LED strips with camera integration.
void SetAccentBrightness(uint8_t maxAccentBrightness) override
Sets the maximum accent brightness of the LED strip.
void SetBrightness(uint8_t maxBrightness) override
Sets the maximum brightness of the LED strip.
void SelectFace(uint8_t code)
void LinkControlParameters() override
Links external or user-defined control parameters (pure virtual to be implemented).
APA102CamerasV1 cameras
const __FlashStringHelper * faceArray[10]
TVStatic tvStatic
APA102Controller controller
void Update(float ratio) override
Updates the project state based on the given ratio.
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 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.
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 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 AlignObject(Vector2D min, Vector2D max, Object3D *obj, float rotation=0.0f, float margin=2.0f, bool mirror=true)
Aligns a single Object3D within the given bounds, applying scaling.
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
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.