浏览代码

add back the blendshapes example - mesh will be in next commit

/1.5-preview
Jimmy Alamparambil 6 年前
当前提交
de0ee7af
共有 6 个文件被更改,包括 840 次插入0 次删除
  1. 243
      Assets/Prefabs/FaceBlendShapes.prefab
  2. 8
      Assets/Prefabs/FaceBlendShapes.prefab.meta
  3. 405
      Assets/Scenes/FaceTracking/FaceBlendShapeScene.unity
  4. 7
      Assets/Scenes/FaceTracking/FaceBlendShapeScene.unity.meta
  5. 166
      Assets/Scripts/ARFaceArkitBlendShapeVisualizer.cs
  6. 11
      Assets/Scripts/ARFaceArkitBlendShapeVisualizer.cs.meta

243
Assets/Prefabs/FaceBlendShapes.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1217920764520308
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4447038815701200}
- component: {fileID: 95365403429265904}
- component: {fileID: 114957203121655242}
- component: {fileID: 3258786451724037531}
m_Layer: 0
m_Name: FaceBlendShapes
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4447038815701200
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217920764520308}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4090201786607310}
- {fileID: 4272230514208426}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &95365403429265904
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217920764520308}
m_Enabled: 1
m_Avatar: {fileID: 9000000, guid: 63ae12abc50414d5c882dbe18f6a820b, type: 3}
m_Controller: {fileID: 0}
m_CullingMode: 1
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &114957203121655242
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217920764520308}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5d87bd45cfc214ce48ce8b882225dd11, type: 3}
m_Name:
m_EditorClassIdentifier:
m_DestroyOnRemoval: 1
--- !u!114 &3258786451724037531
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217920764520308}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 77136493c3caf4805ac5a602f75072e0, type: 3}
m_Name:
m_EditorClassIdentifier:
CoefficientScale: 100
SkinnedMeshRenderer: {fileID: 137740007780104604}
--- !u!1 &1342913298729328
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4272230514208426}
- component: {fileID: 137740007780104604}
m_Layer: 0
m_Name: Sloth_Head2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4272230514208426
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1342913298729328}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
m_LocalPosition: {x: -0.000000017881392, y: 0.010724431, z: 0.0066379486}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4447038815701200}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!137 &137740007780104604
SkinnedMeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1342913298729328}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 0eafc0c8e166e4cd2b0f64b71fda0c45, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
serializedVersion: 2
m_Quality: 0
m_UpdateWhenOffscreen: 1
m_SkinnedMotionVectors: 1
m_Mesh: {fileID: 4300000, guid: 63ae12abc50414d5c882dbe18f6a820b, type: 3}
m_Bones: []
m_BlendShapeWeights:
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
m_RootBone: {fileID: 0}
m_AABB:
m_Center: {x: 0, y: -0.015557218, z: 0}
m_Extent: {x: 0.113363, y: 0.13194084, z: 0.13394047}
m_DirtyAABB: 0
--- !u!1 &1775342627339584
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4090201786607310}
m_Layer: 0
m_Name: blendshapes3
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4090201786607310
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1775342627339584}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4447038815701200}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

8
Assets/Prefabs/FaceBlendShapes.prefab.meta


fileFormatVersion: 2
guid: a5e76df5cbfd54a06abdaf52046adbc0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

405
Assets/Scenes/FaceTracking/FaceBlendShapeScene.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 1526980366}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.496413, b: 0.5748175, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 10
m_AtlasSize: 512
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 256
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &208234939
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 208234941}
- component: {fileID: 208234940}
m_Layer: 0
m_Name: AR Session
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &208234940
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 208234939}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3859a92a05d4f5d418cb6ca605290e74, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AttemptUpdate: 1
--- !u!4 &208234941
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 208234939}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &282840810
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 282840814}
- component: {fileID: 282840813}
- component: {fileID: 282840811}
- component: {fileID: 282840815}
- component: {fileID: 282840812}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &282840811
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 1
--- !u!114 &282840812
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 816b289ef451e094f9ae174fb4cf8db0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UseCustomMaterial: 0
m_CustomMaterial: {fileID: 0}
m_UseCustomRendererAsset: 0
m_CustomRendererAsset: {fileID: 0}
--- !u!20 &282840813
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.01
far clip plane: 100
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 0
m_AllowDynamicResolution: 0
m_ForceIntoRT: 1
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &282840814
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 406902931}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &282840815
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1742909100, guid: ed7343f30e3843b3afda8f8b02669cea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Device: 0
m_PoseSource: 6
m_PoseProviderComponent: {fileID: 0}
m_TrackingType: 0
m_UpdateType: 0
m_UseRelativeTransform: 0
--- !u!1 &406902928
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 406902931}
- component: {fileID: 406902930}
- component: {fileID: 406902929}
m_Layer: 0
m_Name: AR Session Origin
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &406902929
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 406902928}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: caeceacb624484daf8e379c2252fd246, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FacePrefab: {fileID: 1217920764520308, guid: a5e76df5cbfd54a06abdaf52046adbc0,
type: 3}
--- !u!114 &406902930
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 406902928}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 520bb47c46cf8624fafb307b7d1b862a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Camera: {fileID: 282840813}
--- !u!4 &406902931
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 406902928}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 282840814}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1526980365
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1526980367}
- component: {fileID: 1526980366}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1526980366
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1526980365}
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: 2
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.005
m_NormalBias: 0.1
m_NearPlane: 5
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1526980367
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1526980365}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}

7
Assets/Scenes/FaceTracking/FaceBlendShapeScene.unity.meta


fileFormatVersion: 2
guid: e9280441e79e84bdbbf6b724880ae2d9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

166
Assets/Scripts/ARFaceArkitBlendShapeVisualizer.cs


using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.XR;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARKit;
/// <summary>
/// Populates the action unit coefficients for an <see cref="ARFace"/>.
/// </summary>
/// <remarks>
/// If this <c>GameObject</c> has a <c>SkinnedMeshRenderer</c>,
/// this component will generate the blend shape coefficients from the underlying <c>ARFace</c>.
///
/// </remarks>
[RequireComponent(typeof(ARFace))]
public class ARFaceArkitBlendShapeVisualizer : MonoBehaviour
{
public float CoefficientScale = 100.0f;
public SkinnedMeshRenderer SkinnedMeshRenderer;
ARFace m_Face;
ARKitFaceSubsystem arkitFaceSubsystem;
static List<XRFaceArkitBlendShapeCoefficient> s_FaceArkitBlendShapeCoefficients;
Dictionary<XRArkitBlendShapeLocation, string> m_FaceArkitBlendShapeNameMap;
void Awake()
{
s_FaceArkitBlendShapeCoefficients = new List<XRFaceArkitBlendShapeCoefficient>();
m_Face = GetComponent<ARFace>();
CreateFeatureBlendMapping();
}
void CreateFeatureBlendMapping()
{
m_FaceArkitBlendShapeNameMap = new Dictionary<XRArkitBlendShapeLocation, string>();
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.BrowDownLeft ] = "browDown_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.BrowDownRight ] = "browDown_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.BrowInnerUp ] = "browInnerUp";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.BrowOuterUpLeft ] = "browOuterUp_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.BrowOuterUpRight ] = "browOuterUp_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.CheekPuff ] = "cheekPuff";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.CheekSquintLeft ] = "cheekSquint_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.CheekSquintRight ] = "cheekSquint_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeBlinkLeft ] = "eyeBlink_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeBlinkRight ] = "eyeBlink_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookDownLeft ] = "eyeLookDown_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookDownRight ] = "eyeLookDown_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookInLeft ] = "eyeLookIn_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookInRight ] = "eyeLookIn_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookOutLeft ] = "eyeLookOut_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookOutRight ] = "eyeLookOut_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookUpLeft ] = "eyeLookUp_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeLookUpRight ] = "eyeLookUp_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeSquintLeft ] = "eyeSquint_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeSquintRight ] = "eyeSquint_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeWideLeft ] = "eyeWide_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.EyeWideRight ] = "eyeWide_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.JawForward ] = "jawForward";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.JawLeft ] = "jawLeft";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.JawOpen ] = "jawOpen";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.JawRight ] = "jawRight";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthClose ] = "mouthClose";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthDimpleLeft ] = "mouthDimple_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthDimpleRight ] = "mouthDimple_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthFrownLeft ] = "mouthFrown_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthFrownRight ] = "mouthFrown_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthFunnel ] = "mouthFunnel";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthLeft ] = "mouthLeft";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthLowerDownLeft ] = "mouthLowerDown_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthLowerDownRight ] = "mouthLowerDown_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthPressLeft ] = "mouthPress_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthPressRight ] = "mouthPress_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthPucker ] = "mouthPucker";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthRight ] = "mouthRight";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthRollLower ] = "mouthRollLower";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthRollUpper ] = "mouthRollUpper";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthShrugLower ] = "mouthShrugLower";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthShrugUpper ] = "mouthShrugUpper";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthSmileLeft ] = "mouthSmile_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthSmileRight ] = "mouthSmile_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthStretchLeft ] = "mouthStretch_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthStretchRight ] = "mouthStretch_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthUpperUpLeft ] = "mouthUpperUp_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.MouthUpperUpRight ] = "mouthUpperUp_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.NoseSneerLeft ] = "noseSneer_L";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.NoseSneerRight ] = "noseSneer_R";
m_FaceArkitBlendShapeNameMap[XRArkitBlendShapeLocation.TongueOut ] = "tongueOut";
}
void SetVisible(bool visible)
{
if (SkinnedMeshRenderer == null) return;
SkinnedMeshRenderer.enabled = visible;
}
void UpdateVisibility()
{
var visible = enabled &&
(m_Face.trackingState != TrackingState.Unavailable) &&
(ARSubsystemManager.systemState > ARSystemState.Ready);
SetVisible(visible);
}
void OnEnable()
{
arkitFaceSubsystem = (ARKitFaceSubsystem) ARSubsystemManager.faceSubsystem;
if (arkitFaceSubsystem == null )
{
return;
}
m_Face.updated += OnUpdated;
ARSubsystemManager.systemStateChanged += OnSystemStateChanged;
UpdateVisibility();
}
void OnDisable()
{
m_Face.updated -= OnUpdated;
ARSubsystemManager.systemStateChanged -= OnSystemStateChanged;
}
void OnSystemStateChanged(ARSystemStateChangedEventArgs eventArgs)
{
UpdateVisibility();
}
void OnUpdated(ARFace face)
{
UpdateVisibility();
UpdateFaceFeatures();
}
void UpdateFaceFeatures()
{
if (SkinnedMeshRenderer == null || !SkinnedMeshRenderer.enabled)
{
return;
}
if (!arkitFaceSubsystem.TryGetFaceARKitBlendShapeCoefficients(m_Face.xrFace.trackableId,s_FaceArkitBlendShapeCoefficients))
{
return;
}
foreach (var xrFaceFeatureCoefficient in s_FaceArkitBlendShapeCoefficients)
{
const string strPrefix = "blendShape2.";
string mappedBlendShapeName;
if (m_FaceArkitBlendShapeNameMap.TryGetValue(xrFaceFeatureCoefficient.arkitBlendShapeLocation, out mappedBlendShapeName))
{
int blendShapeIndex = SkinnedMeshRenderer.sharedMesh.GetBlendShapeIndex (strPrefix + mappedBlendShapeName);
if (blendShapeIndex >= 0 ) {
SkinnedMeshRenderer.SetBlendShapeWeight (blendShapeIndex, xrFaceFeatureCoefficient.coefficient * CoefficientScale);
}
}
}
}
}

11
Assets/Scripts/ARFaceArkitBlendShapeVisualizer.cs.meta


fileFormatVersion: 2
guid: 77136493c3caf4805ac5a602f75072e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存