12 #ifndef hifi_HeadData_h
13 #define hifi_HeadData_h
19 #include <glm/glm.hpp>
20 #include <glm/gtc/quaternion.hpp>
22 #include <SharedUtil.h>
23 #include <BlendshapeConstants.h>
26 const float MIN_HEAD_YAW = -180.0f;
27 const float MAX_HEAD_YAW = 180.0f;
28 const float MIN_HEAD_PITCH = -60.0f;
29 const float MAX_HEAD_PITCH = 60.0f;
30 const float MIN_HEAD_ROLL = -50.0f;
31 const float MAX_HEAD_ROLL = 50.0f;
38 explicit HeadData(AvatarData* owningAvatar);
39 virtual ~HeadData() { };
42 float getBaseYaw()
const {
return _baseYaw; }
43 void setBaseYaw(
float yaw) { _baseYaw = glm::clamp(yaw, MIN_HEAD_YAW, MAX_HEAD_YAW); }
44 float getBasePitch()
const {
return _basePitch; }
45 void setBasePitch(
float pitch) { _basePitch = glm::clamp(pitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); }
46 float getBaseRoll()
const {
return _baseRoll; }
47 void setBaseRoll(
float roll) { _baseRoll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); }
49 virtual float getFinalYaw()
const {
return _baseYaw; }
50 virtual float getFinalPitch()
const {
return _basePitch; }
51 virtual float getFinalRoll()
const {
return _baseRoll; }
52 virtual glm::quat getRawOrientation()
const;
53 virtual void setRawOrientation(
const glm::quat& orientation);
55 glm::quat getOrientation()
const;
56 void setOrientation(
const glm::quat& orientation);
58 void setBlendshape(QString name,
float val);
59 int getBlendshapeIndex(
const QString& name);
60 void getBlendshapeIndices(
const std::vector<QString>& blendShapeNames, std::vector<int>& indexes);
61 const QVector<float>& getBlendshapeCoefficients()
const {
return _blendshapeCoefficients; }
62 const QVector<float>& getSummedBlendshapeCoefficients();
63 int getNumSummedBlendshapeCoefficients()
const;
64 void setBlendshapeCoefficients(
const QVector<float>& blendshapeCoefficients) { _blendshapeCoefficients = blendshapeCoefficients; }
65 void clearBlendshapeCoefficients();
67 const glm::vec3& getLookAtPosition()
const {
return _lookAtPosition; }
68 virtual void setLookAtPosition(
const glm::vec3& lookAtPosition) {
69 if (_lookAtPosition != lookAtPosition) {
70 _lookAtPositionChanged = usecTimestampNow();
72 _lookAtPosition = lookAtPosition;
74 bool lookAtPositionChangedSince(quint64 time) {
return _lookAtPositionChanged >= time; }
76 enum ProceduralAnimationType {
77 AudioProceduralBlendshapeAnimation = 0,
78 BlinkProceduralBlendshapeAnimation,
79 LidAdjustmentProceduralBlendshapeAnimation,
80 SaccadeProceduralEyeJointAnimation,
81 ProceduralAnimaitonTypeCount,
85 bool getProceduralAnimationFlag(ProceduralAnimationType type)
const;
86 void setProceduralAnimationFlag(ProceduralAnimationType type,
bool value);
89 bool getSuppressProceduralAnimationFlag(ProceduralAnimationType flag)
const;
90 void setSuppressProceduralAnimationFlag(ProceduralAnimationType flag,
bool value);
93 void setHasScriptedBlendshapes(
bool value);
94 bool getHasScriptedBlendshapes()
const;
97 void setHasInputDrivenBlendshapes(
bool value);
98 bool getHasInputDrivenBlendshapes()
const;
100 friend class AvatarData;
102 QJsonObject toJson()
const;
103 void fromJson(
const QJsonObject& json);
111 glm::vec3 _lookAtPosition;
112 quint64 _lookAtPositionChanged { 0 };
114 std::vector<bool> _userProceduralAnimationFlags;
115 std::vector<bool> _suppressProceduralAnimationFlags;
117 bool _hasScriptedBlendshapes {
false };
118 bool _hasInputDrivenBlendshapes {
false };
120 float _leftEyeBlink { 0.0f };
121 float _rightEyeBlink { 0.0f };
122 float _averageLoudness { 0.0f };
123 float _browAudioLift { 0.0f };
125 QVector<float> _blendshapeCoefficients;
126 QVector<float> _transientBlendshapeCoefficients;
127 QVector<float> _summedBlendshapeCoefficients;
128 AvatarData* _owningAvatar;
131 Q_DISABLE_COPY(HeadData)
133 void setHeadOrientation(
const glm::quat& orientation);