|
|
|
|
|
|
[RequireComponent(typeof(ARFace))] |
|
|
|
public class ARFaceArkitBlendShapeVisualizer : MonoBehaviour |
|
|
|
{ |
|
|
|
public float CoefficientScale = 100.0f; |
|
|
|
|
|
|
|
public SkinnedMeshRenderer SkinnedMeshRenderer; |
|
|
|
[SerializeField] |
|
|
|
float coefficientScale = 100.0f; |
|
|
|
[SerializeField] |
|
|
|
SkinnedMeshRenderer skinnedMeshRenderer; |
|
|
|
|
|
|
|
ARFace m_Face; |
|
|
|
ARKitFaceSubsystem arkitFaceSubsystem; |
|
|
|
|
|
|
s_FaceArkitBlendShapeCoefficients = new List<XRFaceArkitBlendShapeCoefficient>(); |
|
|
|
m_Face = GetComponent<ARFace>(); |
|
|
|
CreateFeatureBlendMapping(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void CreateFeatureBlendMapping() |
|
|
|
|
|
|
|
|
|
|
void SetVisible(bool visible) |
|
|
|
{ |
|
|
|
if (SkinnedMeshRenderer == null) return; |
|
|
|
if (skinnedMeshRenderer == null) return; |
|
|
|
SkinnedMeshRenderer.enabled = visible; |
|
|
|
skinnedMeshRenderer.enabled = visible; |
|
|
|
} |
|
|
|
|
|
|
|
void UpdateVisibility() |
|
|
|
|
|
|
|
|
|
|
void UpdateFaceFeatures() |
|
|
|
{ |
|
|
|
if (SkinnedMeshRenderer == null || !SkinnedMeshRenderer.enabled) |
|
|
|
if (skinnedMeshRenderer == null || !skinnedMeshRenderer.enabled) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
string mappedBlendShapeName; |
|
|
|
if (m_FaceArkitBlendShapeNameMap.TryGetValue(xrFaceFeatureCoefficient.arkitBlendShapeLocation, out mappedBlendShapeName)) |
|
|
|
{ |
|
|
|
int blendShapeIndex = SkinnedMeshRenderer.sharedMesh.GetBlendShapeIndex (strPrefix + mappedBlendShapeName); |
|
|
|
int blendShapeIndex = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex (strPrefix + mappedBlendShapeName); |
|
|
|
SkinnedMeshRenderer.SetBlendShapeWeight (blendShapeIndex, xrFaceFeatureCoefficient.coefficient * CoefficientScale); |
|
|
|
skinnedMeshRenderer.SetBlendShapeWeight (blendShapeIndex, xrFaceFeatureCoefficient.coefficient * coefficientScale); |
|
|
|
} |
|
|
|
} |
|
|
|
} |