ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ProtogenWS35Project.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Templates/ProtogenProjectTemplate.h"
4#include "../../Assets/Models/FBX/NukudeFlat.h"
5
6#include "../../Camera/CameraManager/Implementations/WS35SplitCameras.h"
7#include "../../Controller/WS35Controller.h"
8
10private:
13 NukudeFace pM;
14
15 const __FlashStringHelper* faceArray[10] = {F("DEFAULT"), F("ANGRY"), F("DOUBT"), F("FROWN"), F("LOOKUP"), F("SAD"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")};
16
17 void LinkControlParameters() override {
18 AddParameter(NukudeFace::Anger, pM.GetMorphWeightReference(NukudeFace::Anger), 15);
19 AddParameter(NukudeFace::Sadness, pM.GetMorphWeightReference(NukudeFace::Sadness), 15, IEasyEaseAnimator::InterpolationMethod::Cosine);
20 AddParameter(NukudeFace::Surprised, pM.GetMorphWeightReference(NukudeFace::Surprised), 15);
21 AddParameter(NukudeFace::Doubt, pM.GetMorphWeightReference(NukudeFace::Doubt), 15);
22 AddParameter(NukudeFace::Frown, pM.GetMorphWeightReference(NukudeFace::Frown), 15);
23 AddParameter(NukudeFace::LookUp, pM.GetMorphWeightReference(NukudeFace::LookUp), 15);
24 AddParameter(NukudeFace::LookDown, pM.GetMorphWeightReference(NukudeFace::LookDown), 15);
25
26 AddParameter(NukudeFace::HideBlush, pM.GetMorphWeightReference(NukudeFace::HideBlush), 15, IEasyEaseAnimator::InterpolationMethod::Cosine, true);
27
28 AddViseme(Viseme::MouthShape::EE, pM.GetMorphWeightReference(NukudeFace::vrc_v_ee));
29 AddViseme(Viseme::MouthShape::AH, pM.GetMorphWeightReference(NukudeFace::vrc_v_aa));
30 AddViseme(Viseme::MouthShape::UH, pM.GetMorphWeightReference(NukudeFace::vrc_v_dd));
31 AddViseme(Viseme::MouthShape::AR, pM.GetMorphWeightReference(NukudeFace::vrc_v_rr));
32 AddViseme(Viseme::MouthShape::ER, pM.GetMorphWeightReference(NukudeFace::vrc_v_ch));
33 AddViseme(Viseme::MouthShape::OO, pM.GetMorphWeightReference(NukudeFace::vrc_v_oh));
34 AddViseme(Viseme::MouthShape::SS, pM.GetMorphWeightReference(NukudeFace::vrc_v_ss));
35
36 AddBlinkParameter(pM.GetMorphWeightReference(NukudeFace::Blink));
37 }
38
39 void Default(){}
40
41 void Angry(){
42 AddParameterFrame(NukudeFace::Anger, 1.0f);
44 }
45
46 void Sad(){
47 AddParameterFrame(NukudeFace::Sadness, 1.0f);
48 AddParameterFrame(NukudeFace::Frown, 1.0f);
50 }
51
52 void Surprised(){
53 AddParameterFrame(NukudeFace::Surprised, 1.0f);
54 AddParameterFrame(NukudeFace::HideBlush, 0.0f);
56 }
57
58 void Doubt(){
59 AddParameterFrame(NukudeFace::Doubt, 1.0f);
60 }
61
62 void Frown(){
63 AddParameterFrame(NukudeFace::Frown, 1.0f);
64 }
65
66 void LookUp(){
67 AddParameterFrame(NukudeFace::LookUp, 1.0f);
68 }
69
70 void LookDown(){
71 AddParameterFrame(NukudeFace::LookDown, 1.0f);
72 }
73
77
81
85
86public:
87 ProtogenWS35Project() : ProtogenProject(&cameras, &controller, 1, Vector2D(), Vector2D(192.0f, 105.0f), 22, 23, 9){
88 scene.AddObject(pM.GetObject());
89
90 pM.GetObject()->SetMaterial(GetFaceMaterial());
91
93
95
96 SetWiggleSpeed(5.0f);
97 SetMenuWiggleSpeed(0.0f, 0.0f, 0.0f);
98 SetMenuOffset(Vector2D(2.5f, -3.0f));
99 SetMenuSize(Vector2D(240, 64));
100 }
101
102 void Update(float ratio) override {
103 pM.Reset();
104
105 uint8_t mode = Menu::GetFaceState();//change by button press
106
109
110 if (IsBooped() && mode != 6){
111 Surprised();
112 }
113 else{
114 if (mode == 0) Default();
115 else if (mode == 1) Angry();
116 else if (mode == 2) Doubt();
117 else if (mode == 3) Frown();
118 else if (mode == 4) LookUp();
119 else if (mode == 5) Sad();
120 else if (mode == 6) {
122 }
123 else if (mode == 7){
125 }
126 else {
128 }
129 }
130
131 UpdateFace(ratio);
132
133 pM.SetMorphWeight(NukudeFace::BiggerNose, 1.0f);
134 pM.SetMorphWeight(NukudeFace::MoveEye, 1.0f);
135
136 pM.Update();
137
138 AlignObjectFace(pM.GetObject(), -7.5f);
139
140 pM.GetObject()->GetTransform()->SetPosition(GetWiggleOffset());
141 pM.GetObject()->UpdateTransform();
142 }
143};
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 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 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).
@ CHORIZONTALRAINBOW
Horizontal rainbow effect.
@ 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 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).
void OscilloscopeCallback() override
Callback invoked when the Oscilloscope face is enabled/updated.
void SpectrumAnalyzerCallback() override
Callback invoked when the Spectrum Analyzer face is enabled/updated.
const __FlashStringHelper * faceArray[10]
WS35SplitCameraManager cameras
void Update(float ratio) override
Updates the project state based on the given ratio.
void AudioReactiveGradientCallback() override
Callback invoked when the Audio Reactive Gradient face is enabled/updated.
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
@ 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.