/**************************************************************************/1/* xr_face_tracker.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "servers/xr/xr_tracker.h"3334/**35The XRFaceTracker class provides face blend shape weights.3637The supported blend shapes are based on the Unified Expressions38standard, and as such have a well defined mapping to ARKit, SRanipal,39and Meta Movement standards.40*/4142class XRFaceTracker : public XRTracker {43GDCLASS(XRFaceTracker, XRTracker);44_THREAD_SAFE_CLASS_4546public:47enum BlendShapeEntry {48// Base Shapes49FT_EYE_LOOK_OUT_RIGHT, // Right eye looks outwards.50FT_EYE_LOOK_IN_RIGHT, // Right eye looks inwards.51FT_EYE_LOOK_UP_RIGHT, // Right eye looks upwards.52FT_EYE_LOOK_DOWN_RIGHT, // Right eye looks downwards.53FT_EYE_LOOK_OUT_LEFT, // Left eye looks outwards.54FT_EYE_LOOK_IN_LEFT, // Left eye looks inwards.55FT_EYE_LOOK_UP_LEFT, // Left eye looks upwards.56FT_EYE_LOOK_DOWN_LEFT, // Left eye looks downwards.57FT_EYE_CLOSED_RIGHT, // Closes the right eyelid.58FT_EYE_CLOSED_LEFT, // Closes the left eyelid.59FT_EYE_SQUINT_RIGHT, // Squeezes the right eye socket muscles.60FT_EYE_SQUINT_LEFT, // Squeezes the left eye socket muscles.61FT_EYE_WIDE_RIGHT, // Right eyelid widens beyond relaxed.62FT_EYE_WIDE_LEFT, // Left eyelid widens beyond relaxed.63FT_EYE_DILATION_RIGHT, // Dilates the right eye pupil.64FT_EYE_DILATION_LEFT, // Dilates the left eye pupil.65FT_EYE_CONSTRICT_RIGHT, // Constricts the right eye pupil.66FT_EYE_CONSTRICT_LEFT, // Constricts the left eye pupil.67FT_BROW_PINCH_RIGHT, // Right eyebrow pinches in.68FT_BROW_PINCH_LEFT, // Left eyebrow pinches in.69FT_BROW_LOWERER_RIGHT, // Outer right eyebrow pulls down.70FT_BROW_LOWERER_LEFT, // Outer left eyebrow pulls down.71FT_BROW_INNER_UP_RIGHT, // Inner right eyebrow pulls up.72FT_BROW_INNER_UP_LEFT, // Inner left eyebrow pulls up.73FT_BROW_OUTER_UP_RIGHT, // Outer right eyebrow pulls up.74FT_BROW_OUTER_UP_LEFT, // Outer left eyebrow pulls up.75FT_NOSE_SNEER_RIGHT, // Right side face sneers.76FT_NOSE_SNEER_LEFT, // Left side face sneers.77FT_NASAL_DILATION_RIGHT, // Right side nose canal dilates.78FT_NASAL_DILATION_LEFT, // Left side nose canal dilates.79FT_NASAL_CONSTRICT_RIGHT, // Right side nose canal constricts.80FT_NASAL_CONSTRICT_LEFT, // Left side nose canal constricts.81FT_CHEEK_SQUINT_RIGHT, // Raises the right side cheek.82FT_CHEEK_SQUINT_LEFT, // Raises the left side cheek.83FT_CHEEK_PUFF_RIGHT, // Puffs the right side cheek.84FT_CHEEK_PUFF_LEFT, // Puffs the left side cheek.85FT_CHEEK_SUCK_RIGHT, // Sucks in the right side cheek.86FT_CHEEK_SUCK_LEFT, // Sucks in the left side cheek.87FT_JAW_OPEN, // Opens jawbone.88FT_MOUTH_CLOSED, // Closes the mouth.89FT_JAW_RIGHT, // Pushes jawbone right.90FT_JAW_LEFT, // Pushes jawbone left.91FT_JAW_FORWARD, // Pushes jawbone forward.92FT_JAW_BACKWARD, // Pushes jawbone backward.93FT_JAW_CLENCH, // Flexes jaw muscles.94FT_JAW_MANDIBLE_RAISE, // Raises the jawbone.95FT_LIP_SUCK_UPPER_RIGHT, // Upper right lip part tucks in the mouth.96FT_LIP_SUCK_UPPER_LEFT, // Upper left lip part tucks in the mouth.97FT_LIP_SUCK_LOWER_RIGHT, // Lower right lip part tucks in the mouth.98FT_LIP_SUCK_LOWER_LEFT, // Lower left lip part tucks in the mouth.99FT_LIP_SUCK_CORNER_RIGHT, // Right lip corner folds into the mouth.100FT_LIP_SUCK_CORNER_LEFT, // Left lip corner folds into the mouth.101FT_LIP_FUNNEL_UPPER_RIGHT, // Upper right lip part pushes into a funnel.102FT_LIP_FUNNEL_UPPER_LEFT, // Upper left lip part pushes into a funnel.103FT_LIP_FUNNEL_LOWER_RIGHT, // Lower right lip part pushes into a funnel.104FT_LIP_FUNNEL_LOWER_LEFT, // Lower left lip part pushes into a funnel.105FT_LIP_PUCKER_UPPER_RIGHT, // Upper right lip part pushes outwards.106FT_LIP_PUCKER_UPPER_LEFT, // Upper left lip part pushes outwards.107FT_LIP_PUCKER_LOWER_RIGHT, // Lower right lip part pushes outwards.108FT_LIP_PUCKER_LOWER_LEFT, // Lower left lip part pushes outwards.109FT_MOUTH_UPPER_UP_RIGHT, // Upper right part of the lip pulls up.110FT_MOUTH_UPPER_UP_LEFT, // Upper left part of the lip pulls up.111FT_MOUTH_LOWER_DOWN_RIGHT, // Lower right part of the lip pulls up.112FT_MOUTH_LOWER_DOWN_LEFT, // Lower left part of the lip pulls up.113FT_MOUTH_UPPER_DEEPEN_RIGHT, // Upper right lip part pushes in the cheek.114FT_MOUTH_UPPER_DEEPEN_LEFT, // Upper left lip part pushes in the cheek.115FT_MOUTH_UPPER_RIGHT, // Moves upper lip right.116FT_MOUTH_UPPER_LEFT, // Moves upper lip left.117FT_MOUTH_LOWER_RIGHT, // Moves lower lip right.118FT_MOUTH_LOWER_LEFT, // Moves lower lip left.119FT_MOUTH_CORNER_PULL_RIGHT, // Right lip corner pulls diagonally up and out.120FT_MOUTH_CORNER_PULL_LEFT, // Left lip corner pulls diagonally up and out.121FT_MOUTH_CORNER_SLANT_RIGHT, // Right corner lip slants up.122FT_MOUTH_CORNER_SLANT_LEFT, // Left corner lip slants up.123FT_MOUTH_FROWN_RIGHT, // Right corner lip pulls down.124FT_MOUTH_FROWN_LEFT, // Left corner lip pulls down.125FT_MOUTH_STRETCH_RIGHT, // Mouth corner lip pulls out and down.126FT_MOUTH_STRETCH_LEFT, // Mouth corner lip pulls out and down.127FT_MOUTH_DIMPLE_RIGHT, // Right lip corner is pushed backwards.128FT_MOUTH_DIMPLE_LEFT, // Left lip corner is pushed backwards.129FT_MOUTH_RAISER_UPPER, // Raises and slightly pushes out the upper mouth.130FT_MOUTH_RAISER_LOWER, // Raises and slightly pushes out the lower mouth.131FT_MOUTH_PRESS_RIGHT, // Right side lips press and flatten together vertically.132FT_MOUTH_PRESS_LEFT, // Left side lips press and flatten together vertically.133FT_MOUTH_TIGHTENER_RIGHT, // Right side lips squeeze together horizontally.134FT_MOUTH_TIGHTENER_LEFT, // Left side lips squeeze together horizontally.135FT_TONGUE_OUT, // Tongue visibly sticks out of the mouth.136FT_TONGUE_UP, // Tongue points upwards.137FT_TONGUE_DOWN, // Tongue points downwards.138FT_TONGUE_RIGHT, // Tongue points right.139FT_TONGUE_LEFT, // Tongue points left.140FT_TONGUE_ROLL, // Sides of the tongue funnel, creating a roll.141FT_TONGUE_BLEND_DOWN, // Tongue arches up then down inside the mouth.142FT_TONGUE_CURL_UP, // Tongue arches down then up inside the mouth.143FT_TONGUE_SQUISH, // Tongue squishes together and thickens.144FT_TONGUE_FLAT, // Tongue flattens and thins out.145FT_TONGUE_TWIST_RIGHT, // Tongue tip rotates clockwise, with the rest following gradually.146FT_TONGUE_TWIST_LEFT, // Tongue tip rotates counter-clockwise, with the rest following gradually.147FT_SOFT_PALATE_CLOSE, // Inner mouth throat closes.148FT_THROAT_SWALLOW, // The Adam's apple visibly swallows.149FT_NECK_FLEX_RIGHT, // Right side neck visibly flexes.150FT_NECK_FLEX_LEFT, // Left side neck visibly flexes.151// Blended Shapes152FT_EYE_CLOSED, // Closes both eye lids.153FT_EYE_WIDE, // Widens both eye lids.154FT_EYE_SQUINT, // Squints both eye lids.155FT_EYE_DILATION, // Dilates both pupils.156FT_EYE_CONSTRICT, // Constricts both pupils.157FT_BROW_DOWN_RIGHT, // Pulls the right eyebrow down and in.158FT_BROW_DOWN_LEFT, // Pulls the left eyebrow down and in.159FT_BROW_DOWN, // Pulls both eyebrows down and in.160FT_BROW_UP_RIGHT, // Right brow appears worried.161FT_BROW_UP_LEFT, // Left brow appears worried.162FT_BROW_UP, // Both brows appear worried.163FT_NOSE_SNEER, // Entire face sneers.164FT_NASAL_DILATION, // Both nose canals dilate.165FT_NASAL_CONSTRICT, // Both nose canals constrict.166FT_CHEEK_PUFF, // Puffs both cheeks.167FT_CHEEK_SUCK, // Sucks in both cheeks.168FT_CHEEK_SQUINT, // Raises both cheeks.169FT_LIP_SUCK_UPPER, // Tucks in the upper lips.170FT_LIP_SUCK_LOWER, // Tucks in the lower lips.171FT_LIP_SUCK, // Tucks in both lips.172FT_LIP_FUNNEL_UPPER, // Funnels in the upper lips.173FT_LIP_FUNNEL_LOWER, // Funnels in the lower lips.174FT_LIP_FUNNEL, // Funnels in both lips.175FT_LIP_PUCKER_UPPER, // Upper lip part pushes outwards.176FT_LIP_PUCKER_LOWER, // Lower lip part pushes outwards.177FT_LIP_PUCKER, // Lips push outwards.178FT_MOUTH_UPPER_UP, // Raises the upper lips.179FT_MOUTH_LOWER_DOWN, // Lowers the lower lips.180FT_MOUTH_OPEN, // Mouth opens, revealing teeth.181FT_MOUTH_RIGHT, // Moves mouth right.182FT_MOUTH_LEFT, // Moves mouth left.183FT_MOUTH_SMILE_RIGHT, // Right side of the mouth smiles.184FT_MOUTH_SMILE_LEFT, // Left side of the mouth smiles.185FT_MOUTH_SMILE, // Mouth expresses a smile.186FT_MOUTH_SAD_RIGHT, // Right side of the mouth expresses sadness.187FT_MOUTH_SAD_LEFT, // Left side of the mouth expresses sadness.188FT_MOUTH_SAD, // Mouth expresses sadness.189FT_MOUTH_STRETCH, // Mouth stretches.190FT_MOUTH_DIMPLE, // Lip corners dimple.191FT_MOUTH_TIGHTENER, // Mouth tightens.192FT_MOUTH_PRESS, // Mouth presses together.193FT_MAX // Maximum blend shape.194};195196void set_tracker_type(XRServer::TrackerType p_type) override;197198float get_blend_shape(BlendShapeEntry p_blend_shape) const;199void set_blend_shape(BlendShapeEntry p_blend_shape, float p_value);200201PackedFloat32Array get_blend_shapes() const;202void set_blend_shapes(const PackedFloat32Array &p_blend_shapes);203204XRFaceTracker();205206protected:207static void _bind_methods();208209private:210float blend_shape_values[FT_MAX] = {};211};212213VARIANT_ENUM_CAST(XRFaceTracker::BlendShapeEntry);214215216