diff options
author | Malcolm Nixon <Malcolm.nixon@gmail.com> | 2024-02-11 20:23:52 -0500 |
---|---|---|
committer | Malcolm Nixon <Malcolm.nixon@gmail.com> | 2024-02-17 20:12:47 -0500 |
commit | 7d1a1abe7680f75b83034cbd6438690b75c83718 (patch) | |
tree | 01f4774c0cefce197aad26a0e121233e1064f9a5 /servers/xr | |
parent | 4e990cd7e51d17cf24f854cc33b2715eaa27200f (diff) | |
download | redot-engine-7d1a1abe7680f75b83034cbd6438690b75c83718.tar.gz |
Initial XRFaceTrackingProvider and XRFaceTracker work.
Updated to XRFaceModifier3D.
Diffstat (limited to 'servers/xr')
-rw-r--r-- | servers/xr/xr_face_tracker.cpp | 222 | ||||
-rw-r--r-- | servers/xr/xr_face_tracker.h | 213 |
2 files changed, 435 insertions, 0 deletions
diff --git a/servers/xr/xr_face_tracker.cpp b/servers/xr/xr_face_tracker.cpp new file mode 100644 index 0000000000..a38ccfd527 --- /dev/null +++ b/servers/xr/xr_face_tracker.cpp @@ -0,0 +1,222 @@ +/**************************************************************************/ +/* xr_face_tracker.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "xr_face_tracker.h" + +void XRFaceTracker::_bind_methods() { + // Base Shapes + BIND_ENUM_CONSTANT(FT_EYE_LOOK_OUT_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_IN_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_UP_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_DOWN_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_OUT_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_IN_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_UP_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_LOOK_DOWN_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_CLOSED_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_CLOSED_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_SQUINT_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_SQUINT_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_WIDE_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_WIDE_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_DILATION_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_DILATION_LEFT); + BIND_ENUM_CONSTANT(FT_EYE_CONSTRICT_RIGHT); + BIND_ENUM_CONSTANT(FT_EYE_CONSTRICT_LEFT); + BIND_ENUM_CONSTANT(FT_BROW_PINCH_RIGHT); + BIND_ENUM_CONSTANT(FT_BROW_PINCH_LEFT); + BIND_ENUM_CONSTANT(FT_BROW_LOWERER_RIGHT); + BIND_ENUM_CONSTANT(FT_BROW_LOWERER_LEFT); + BIND_ENUM_CONSTANT(FT_BROW_INNER_UP_RIGHT); + BIND_ENUM_CONSTANT(FT_BROW_INNER_UP_LEFT); + BIND_ENUM_CONSTANT(FT_BROW_OUTER_UP_RIGHT); + BIND_ENUM_CONSTANT(FT_BROW_OUTER_UP_LEFT); + BIND_ENUM_CONSTANT(FT_NOSE_SNEER_RIGHT); + BIND_ENUM_CONSTANT(FT_NOSE_SNEER_LEFT); + BIND_ENUM_CONSTANT(FT_NASAL_DILATION_RIGHT); + BIND_ENUM_CONSTANT(FT_NASAL_DILATION_LEFT); + BIND_ENUM_CONSTANT(FT_NASAL_CONSTRICT_RIGHT); + BIND_ENUM_CONSTANT(FT_NASAL_CONSTRICT_LEFT); + BIND_ENUM_CONSTANT(FT_CHEEK_SQUINT_RIGHT); + BIND_ENUM_CONSTANT(FT_CHEEK_SQUINT_LEFT); + BIND_ENUM_CONSTANT(FT_CHEEK_PUFF_RIGHT); + BIND_ENUM_CONSTANT(FT_CHEEK_PUFF_LEFT); + BIND_ENUM_CONSTANT(FT_CHEEK_SUCK_RIGHT); + BIND_ENUM_CONSTANT(FT_CHEEK_SUCK_LEFT); + BIND_ENUM_CONSTANT(FT_JAW_OPEN); + BIND_ENUM_CONSTANT(FT_MOUTH_CLOSED); + BIND_ENUM_CONSTANT(FT_JAW_RIGHT); + BIND_ENUM_CONSTANT(FT_JAW_LEFT); + BIND_ENUM_CONSTANT(FT_JAW_FORWARD); + BIND_ENUM_CONSTANT(FT_JAW_BACKWARD); + BIND_ENUM_CONSTANT(FT_JAW_CLENCH); + BIND_ENUM_CONSTANT(FT_JAW_MANDIBLE_RAISE); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_UPPER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_UPPER_LEFT); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_LOWER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_LOWER_LEFT); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_CORNER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_CORNER_LEFT); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL_UPPER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL_UPPER_LEFT); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL_LOWER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL_LOWER_LEFT); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER_UPPER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER_UPPER_LEFT); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER_LOWER_RIGHT); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER_LOWER_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_UP_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_UP_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_LOWER_DOWN_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_LOWER_DOWN_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_DEEPEN_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_DEEPEN_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_LOWER_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_LOWER_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_CORNER_PULL_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_CORNER_PULL_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_CORNER_SLANT_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_CORNER_SLANT_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_FROWN_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_FROWN_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_STRETCH_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_STRETCH_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_DIMPLE_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_DIMPLE_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_RAISER_UPPER); + BIND_ENUM_CONSTANT(FT_MOUTH_RAISER_LOWER); + BIND_ENUM_CONSTANT(FT_MOUTH_PRESS_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_PRESS_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_TIGHTENER_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_TIGHTENER_LEFT); + BIND_ENUM_CONSTANT(FT_TONGUE_OUT); + BIND_ENUM_CONSTANT(FT_TONGUE_UP); + BIND_ENUM_CONSTANT(FT_TONGUE_DOWN); + BIND_ENUM_CONSTANT(FT_TONGUE_RIGHT); + BIND_ENUM_CONSTANT(FT_TONGUE_LEFT); + BIND_ENUM_CONSTANT(FT_TONGUE_ROLL); + BIND_ENUM_CONSTANT(FT_TONGUE_BLEND_DOWN); + BIND_ENUM_CONSTANT(FT_TONGUE_CURL_UP); + BIND_ENUM_CONSTANT(FT_TONGUE_SQUISH); + BIND_ENUM_CONSTANT(FT_TONGUE_FLAT); + BIND_ENUM_CONSTANT(FT_TONGUE_TWIST_RIGHT); + BIND_ENUM_CONSTANT(FT_TONGUE_TWIST_LEFT); + BIND_ENUM_CONSTANT(FT_SOFT_PALATE_CLOSE); + BIND_ENUM_CONSTANT(FT_THROAT_SWALLOW); + BIND_ENUM_CONSTANT(FT_NECK_FLEX_RIGHT); + BIND_ENUM_CONSTANT(FT_NECK_FLEX_LEFT); + // Blended Shapes + BIND_ENUM_CONSTANT(FT_EYE_CLOSED); + BIND_ENUM_CONSTANT(FT_EYE_WIDE); + BIND_ENUM_CONSTANT(FT_EYE_SQUINT); + BIND_ENUM_CONSTANT(FT_EYE_DILATION); + BIND_ENUM_CONSTANT(FT_EYE_CONSTRICT); + BIND_ENUM_CONSTANT(FT_BROW_DOWN_RIGHT); + BIND_ENUM_CONSTANT(FT_BROW_DOWN_LEFT); + BIND_ENUM_CONSTANT(FT_BROW_DOWN); + BIND_ENUM_CONSTANT(FT_BROW_UP_RIGHT); + BIND_ENUM_CONSTANT(FT_BROW_UP_LEFT); + BIND_ENUM_CONSTANT(FT_BROW_UP); + BIND_ENUM_CONSTANT(FT_NOSE_SNEER); + BIND_ENUM_CONSTANT(FT_NASAL_DILATION); + BIND_ENUM_CONSTANT(FT_NASAL_CONSTRICT); + BIND_ENUM_CONSTANT(FT_CHEEK_PUFF); + BIND_ENUM_CONSTANT(FT_CHEEK_SUCK); + BIND_ENUM_CONSTANT(FT_CHEEK_SQUINT); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_UPPER); + BIND_ENUM_CONSTANT(FT_LIP_SUCK_LOWER); + BIND_ENUM_CONSTANT(FT_LIP_SUCK); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL_UPPER); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL_LOWER); + BIND_ENUM_CONSTANT(FT_LIP_FUNNEL); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER_UPPER); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER_LOWER); + BIND_ENUM_CONSTANT(FT_LIP_PUCKER); + BIND_ENUM_CONSTANT(FT_MOUTH_UPPER_UP); + BIND_ENUM_CONSTANT(FT_MOUTH_LOWER_DOWN); + BIND_ENUM_CONSTANT(FT_MOUTH_OPEN); + BIND_ENUM_CONSTANT(FT_MOUTH_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_SMILE_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_SMILE_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_SMILE); + BIND_ENUM_CONSTANT(FT_MOUTH_SAD_RIGHT); + BIND_ENUM_CONSTANT(FT_MOUTH_SAD_LEFT); + BIND_ENUM_CONSTANT(FT_MOUTH_SAD); + BIND_ENUM_CONSTANT(FT_MOUTH_STRETCH); + BIND_ENUM_CONSTANT(FT_MOUTH_DIMPLE); + BIND_ENUM_CONSTANT(FT_MOUTH_TIGHTENER); + BIND_ENUM_CONSTANT(FT_MOUTH_PRESS); + BIND_ENUM_CONSTANT(FT_MAX); + + ClassDB::bind_method(D_METHOD("get_blend_shape", "blend_shape"), &XRFaceTracker::get_blend_shape); + ClassDB::bind_method(D_METHOD("set_blend_shape", "blend_shape", "weight"), &XRFaceTracker::set_blend_shape); + + ClassDB::bind_method(D_METHOD("get_blend_shapes"), &XRFaceTracker::get_blend_shapes); + ClassDB::bind_method(D_METHOD("set_blend_shapes", "weights"), &XRFaceTracker::set_blend_shapes); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "blend_shapes"), "set_blend_shapes", "get_blend_shapes"); + ADD_PROPERTY_DEFAULT("blend_shapes", PackedFloat32Array()); // To prevent ludicrously large default values. +} + +float XRFaceTracker::get_blend_shape(BlendShapeEntry p_blend_shape) const { + // Fail if the blend shape index is out of range. + ERR_FAIL_INDEX_V(p_blend_shape, FT_MAX, 0.0f); + + // Return the blend shape value. + return blend_shape_values[p_blend_shape]; +} + +void XRFaceTracker::set_blend_shape(BlendShapeEntry p_blend_shape, float p_value) { + // Fail if the blend shape index is out of range. + ERR_FAIL_INDEX(p_blend_shape, FT_MAX); + + // Save the new blend shape value. + blend_shape_values[p_blend_shape] = p_value; +} + +PackedFloat32Array XRFaceTracker::get_blend_shapes() const { + // Create a packed float32 array and copy the blend shape values into it. + PackedFloat32Array data; + data.resize(FT_MAX); + memcpy(data.ptrw(), blend_shape_values, sizeof(blend_shape_values)); + + // Return the blend shape array. + return data; +} + +void XRFaceTracker::set_blend_shapes(const PackedFloat32Array &p_blend_shapes) { + // Fail if the blend shape array is not the correct size. + ERR_FAIL_COND(p_blend_shapes.size() != FT_MAX); + + // Copy the blend shape values into the blend shape array. + memcpy(blend_shape_values, p_blend_shapes.ptr(), sizeof(blend_shape_values)); +} diff --git a/servers/xr/xr_face_tracker.h b/servers/xr/xr_face_tracker.h new file mode 100644 index 0000000000..b9f553cba6 --- /dev/null +++ b/servers/xr/xr_face_tracker.h @@ -0,0 +1,213 @@ +/**************************************************************************/ +/* xr_face_tracker.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef XR_FACE_TRACKER_H +#define XR_FACE_TRACKER_H + +#include "core/object/ref_counted.h" + +/** + The XRFaceTracker class provides face blend shape weights. + + The supported blend shapes are based on the Unified Expressions + standard, and as such have a well defined mapping to ARKit, SRanipal, + and Meta Movement standards. + */ + +class XRFaceTracker : public RefCounted { + GDCLASS(XRFaceTracker, RefCounted); + _THREAD_SAFE_CLASS_ + +public: + enum BlendShapeEntry { + // Base Shapes + FT_EYE_LOOK_OUT_RIGHT, // Right eye looks outwards. + FT_EYE_LOOK_IN_RIGHT, // Right eye looks inwards. + FT_EYE_LOOK_UP_RIGHT, // Right eye looks upwards. + FT_EYE_LOOK_DOWN_RIGHT, // Right eye looks downwards. + FT_EYE_LOOK_OUT_LEFT, // Left eye looks outwards. + FT_EYE_LOOK_IN_LEFT, // Left eye looks inwards. + FT_EYE_LOOK_UP_LEFT, // Left eye looks upwards. + FT_EYE_LOOK_DOWN_LEFT, // Left eye looks downwards. + FT_EYE_CLOSED_RIGHT, // Closes the right eyelid. + FT_EYE_CLOSED_LEFT, // Closes the left eyelid. + FT_EYE_SQUINT_RIGHT, // Squeezes the right eye socket muscles. + FT_EYE_SQUINT_LEFT, // Squeezes the left eye socket muscles. + FT_EYE_WIDE_RIGHT, // Right eyelid widens beyond relaxed. + FT_EYE_WIDE_LEFT, // Left eyelid widens beyond relaxed. + FT_EYE_DILATION_RIGHT, // Dilates the right eye pupil. + FT_EYE_DILATION_LEFT, // Dilates the left eye pupil. + FT_EYE_CONSTRICT_RIGHT, // Constricts the right eye pupil. + FT_EYE_CONSTRICT_LEFT, // Constricts the left eye pupil. + FT_BROW_PINCH_RIGHT, // Right eyebrow pinches in. + FT_BROW_PINCH_LEFT, // Left eyebrow pinches in. + FT_BROW_LOWERER_RIGHT, // Outer right eyebrow pulls down. + FT_BROW_LOWERER_LEFT, // Outer left eyebrow pulls down. + FT_BROW_INNER_UP_RIGHT, // Inner right eyebrow pulls up. + FT_BROW_INNER_UP_LEFT, // Inner left eyebrow pulls up. + FT_BROW_OUTER_UP_RIGHT, // Outer right eyebrow pulls up. + FT_BROW_OUTER_UP_LEFT, // Outer left eyebrow pulls up. + FT_NOSE_SNEER_RIGHT, // Right side face sneers. + FT_NOSE_SNEER_LEFT, // Left side face sneers. + FT_NASAL_DILATION_RIGHT, // Right side nose canal dilates. + FT_NASAL_DILATION_LEFT, // Left side nose canal dilates. + FT_NASAL_CONSTRICT_RIGHT, // Right side nose canal constricts. + FT_NASAL_CONSTRICT_LEFT, // Left side nose canal constricts. + FT_CHEEK_SQUINT_RIGHT, // Raises the right side cheek. + FT_CHEEK_SQUINT_LEFT, // Raises the left side cheek. + FT_CHEEK_PUFF_RIGHT, // Puffs the right side cheek. + FT_CHEEK_PUFF_LEFT, // Puffs the left side cheek. + FT_CHEEK_SUCK_RIGHT, // Sucks in the right side cheek. + FT_CHEEK_SUCK_LEFT, // Sucks in the left side cheek. + FT_JAW_OPEN, // Opens jawbone. + FT_MOUTH_CLOSED, // Closes the mouth. + FT_JAW_RIGHT, // Pushes jawbone right. + FT_JAW_LEFT, // Pushes jawbone left. + FT_JAW_FORWARD, // Pushes jawbone forward. + FT_JAW_BACKWARD, // Pushes jawbone backward. + FT_JAW_CLENCH, // Flexes jaw muscles. + FT_JAW_MANDIBLE_RAISE, // Raises the jawbone. + FT_LIP_SUCK_UPPER_RIGHT, // Upper right lip part tucks in the mouth. + FT_LIP_SUCK_UPPER_LEFT, // Upper left lip part tucks in the mouth. + FT_LIP_SUCK_LOWER_RIGHT, // Lower right lip part tucks in the mouth. + FT_LIP_SUCK_LOWER_LEFT, // Lower left lip part tucks in the mouth. + FT_LIP_SUCK_CORNER_RIGHT, // Right lip corner folds into the mouth. + FT_LIP_SUCK_CORNER_LEFT, // Left lip corner folds into the mouth. + FT_LIP_FUNNEL_UPPER_RIGHT, // Upper right lip part pushes into a funnel. + FT_LIP_FUNNEL_UPPER_LEFT, // Upper left lip part pushes into a funnel. + FT_LIP_FUNNEL_LOWER_RIGHT, // Lower right lip part pushes into a funnel. + FT_LIP_FUNNEL_LOWER_LEFT, // Lower left lip part pushes into a funnel. + FT_LIP_PUCKER_UPPER_RIGHT, // Upper right lip part pushes outwards. + FT_LIP_PUCKER_UPPER_LEFT, // Upper left lip part pushes outwards. + FT_LIP_PUCKER_LOWER_RIGHT, // Lower right lip part pushes outwards. + FT_LIP_PUCKER_LOWER_LEFT, // Lower left lip part pushes outwards. + FT_MOUTH_UPPER_UP_RIGHT, // Upper right part of the lip pulls up. + FT_MOUTH_UPPER_UP_LEFT, // Upper left part of the lip pulls up. + FT_MOUTH_LOWER_DOWN_RIGHT, // Lower right part of the lip pulls up. + FT_MOUTH_LOWER_DOWN_LEFT, // Lower left part of the lip pulls up. + FT_MOUTH_UPPER_DEEPEN_RIGHT, // Upper right lip part pushes in the cheek. + FT_MOUTH_UPPER_DEEPEN_LEFT, // Upper left lip part pushes in the cheek. + FT_MOUTH_UPPER_RIGHT, // Moves upper lip right. + FT_MOUTH_UPPER_LEFT, // Moves upper lip left. + FT_MOUTH_LOWER_RIGHT, // Moves lower lip right. + FT_MOUTH_LOWER_LEFT, // Moves lower lip left. + FT_MOUTH_CORNER_PULL_RIGHT, // Right lip corner pulls diagonally up and out. + FT_MOUTH_CORNER_PULL_LEFT, // Left lip corner pulls diagonally up and out. + FT_MOUTH_CORNER_SLANT_RIGHT, // Right corner lip slants up. + FT_MOUTH_CORNER_SLANT_LEFT, // Left corner lip slants up. + FT_MOUTH_FROWN_RIGHT, // Right corner lip pulls down. + FT_MOUTH_FROWN_LEFT, // Left corner lip pulls down. + FT_MOUTH_STRETCH_RIGHT, // Mouth corner lip pulls out and down. + FT_MOUTH_STRETCH_LEFT, // Mouth corner lip pulls out and down. + FT_MOUTH_DIMPLE_RIGHT, // Right lip corner is pushed backwards. + FT_MOUTH_DIMPLE_LEFT, // Left lip corner is pushed backwards. + FT_MOUTH_RAISER_UPPER, // Raises and slightly pushes out the upper mouth. + FT_MOUTH_RAISER_LOWER, // Raises and slightly pushes out the lower mouth. + FT_MOUTH_PRESS_RIGHT, // Right side lips press and flatten together vertically. + FT_MOUTH_PRESS_LEFT, // Left side lips press and flatten together vertically. + FT_MOUTH_TIGHTENER_RIGHT, // Right side lips squeeze together horizontally. + FT_MOUTH_TIGHTENER_LEFT, // Left side lips squeeze together horizontally. + FT_TONGUE_OUT, // Tongue visibly sticks out of the mouth. + FT_TONGUE_UP, // Tongue points upwards. + FT_TONGUE_DOWN, // Tongue points downwards. + FT_TONGUE_RIGHT, // Tongue points right. + FT_TONGUE_LEFT, // Tongue points left. + FT_TONGUE_ROLL, // Sides of the tongue funnel, creating a roll. + FT_TONGUE_BLEND_DOWN, // Tongue arches up then down inside the mouth. + FT_TONGUE_CURL_UP, // Tongue arches down then up inside the mouth. + FT_TONGUE_SQUISH, // Tongue squishes together and thickens. + FT_TONGUE_FLAT, // Tongue flattens and thins out. + FT_TONGUE_TWIST_RIGHT, // Tongue tip rotates clockwise, with the rest following gradually. + FT_TONGUE_TWIST_LEFT, // Tongue tip rotates counter-clockwise, with the rest following gradually. + FT_SOFT_PALATE_CLOSE, // Inner mouth throat closes. + FT_THROAT_SWALLOW, // The Adam's apple visibly swallows. + FT_NECK_FLEX_RIGHT, // Right side neck visibly flexes. + FT_NECK_FLEX_LEFT, // Left side neck visibly flexes. + // Blended Shapes + FT_EYE_CLOSED, // Closes both eye lids. + FT_EYE_WIDE, // Widens both eye lids. + FT_EYE_SQUINT, // Squints both eye lids. + FT_EYE_DILATION, // Dilates both pupils. + FT_EYE_CONSTRICT, // Constricts both pupils. + FT_BROW_DOWN_RIGHT, // Pulls the right eyebrow down and in. + FT_BROW_DOWN_LEFT, // Pulls the left eyebrow down and in. + FT_BROW_DOWN, // Pulls both eyebrows down and in. + FT_BROW_UP_RIGHT, // Right brow appears worried. + FT_BROW_UP_LEFT, // Left brow appears worried. + FT_BROW_UP, // Both brows appear worried. + FT_NOSE_SNEER, // Entire face sneers. + FT_NASAL_DILATION, // Both nose canals dilate. + FT_NASAL_CONSTRICT, // Both nose canals constrict. + FT_CHEEK_PUFF, // Puffs both cheeks. + FT_CHEEK_SUCK, // Sucks in both cheeks. + FT_CHEEK_SQUINT, // Raises both cheeks. + FT_LIP_SUCK_UPPER, // Tucks in the upper lips. + FT_LIP_SUCK_LOWER, // Tucks in the lower lips. + FT_LIP_SUCK, // Tucks in both lips. + FT_LIP_FUNNEL_UPPER, // Funnels in the upper lips. + FT_LIP_FUNNEL_LOWER, // Funnels in the lower lips. + FT_LIP_FUNNEL, // Funnels in both lips. + FT_LIP_PUCKER_UPPER, // Upper lip part pushes outwards. + FT_LIP_PUCKER_LOWER, // Lower lip part pushes outwards. + FT_LIP_PUCKER, // Lips push outwards. + FT_MOUTH_UPPER_UP, // Raises the upper lips. + FT_MOUTH_LOWER_DOWN, // Lowers the lower lips. + FT_MOUTH_OPEN, // Mouth opens, revealing teeth. + FT_MOUTH_RIGHT, // Moves mouth right. + FT_MOUTH_LEFT, // Moves mouth left. + FT_MOUTH_SMILE_RIGHT, // Right side of the mouth smiles. + FT_MOUTH_SMILE_LEFT, // Left side of the mouth smiles. + FT_MOUTH_SMILE, // Mouth expresses a smile. + FT_MOUTH_SAD_RIGHT, // Right side of the mouth expresses sadness. + FT_MOUTH_SAD_LEFT, // Left side of the mouth expresses sadness. + FT_MOUTH_SAD, // Mouth expresses sadness. + FT_MOUTH_STRETCH, // Mouth stretches. + FT_MOUTH_DIMPLE, // Lip corners dimple. + FT_MOUTH_TIGHTENER, // Mouth tightens. + FT_MOUTH_PRESS, // Mouth presses together. + FT_MAX // Maximum blend shape. + }; + + float get_blend_shape(BlendShapeEntry p_blend_shape) const; + void set_blend_shape(BlendShapeEntry p_blend_shape, float p_value); + + PackedFloat32Array get_blend_shapes() const; + void set_blend_shapes(const PackedFloat32Array &p_blend_shapes); + +protected: + static void _bind_methods(); + +private: + float blend_shape_values[FT_MAX] = {}; +}; + +VARIANT_ENUM_CAST(XRFaceTracker::BlendShapeEntry); + +#endif // XR_FACE_TRACKER_H |