add package files
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
//========= Copyright 2019, HTC Corporation. All rights reserved. ===========
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VIVE
|
||||
{
|
||||
namespace FacialTracking.Sample
|
||||
{
|
||||
[Serializable]
|
||||
public class LipShapeTable
|
||||
{
|
||||
public SkinnedMeshRenderer skinnedMeshRenderer;
|
||||
public XrLipShapeHTC[] lipShapes;
|
||||
}
|
||||
public class AvatarLipSample : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<LipShapeTable> LipShapeTables;
|
||||
|
||||
public bool NeededToGetData = true;
|
||||
private Dictionary<XrLipShapeHTC, float> LipWeightings;
|
||||
private FacialManager facialManager = new FacialManager();
|
||||
private void Start()
|
||||
{
|
||||
facialManager.StartFramework(XrFacialTrackingTypeHTC.XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC);
|
||||
SetLipShapeTables(LipShapeTables);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (NeededToGetData)
|
||||
{
|
||||
facialManager.GetWeightings(out LipWeightings);
|
||||
//Lip.GetLipWeightings(out LipWeightings);
|
||||
UpdateLipShapes(LipWeightings);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLipShapeTables(List<LipShapeTable> lipShapeTables)
|
||||
{
|
||||
bool valid = true;
|
||||
if (lipShapeTables == null)
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int table = 0; table < lipShapeTables.Count; ++table)
|
||||
{
|
||||
if (lipShapeTables[table].skinnedMeshRenderer == null)
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
for (int shape = 0; shape < lipShapeTables[table].lipShapes.Length; ++shape)
|
||||
{
|
||||
XrLipShapeHTC lipShape = lipShapeTables[table].lipShapes[shape];
|
||||
if (lipShape > XrLipShapeHTC.XR_LIP_SHAPE_MAX_ENUM_HTC || lipShape < 0)
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
LipShapeTables = lipShapeTables;
|
||||
}
|
||||
|
||||
public void UpdateLipShapes(Dictionary<XrLipShapeHTC, float> lipWeightings)
|
||||
{
|
||||
foreach (var table in LipShapeTables)
|
||||
RenderModelLipShape(table, lipWeightings);
|
||||
}
|
||||
|
||||
private void RenderModelLipShape(LipShapeTable lipShapeTable, Dictionary<XrLipShapeHTC, float> weighting)
|
||||
{
|
||||
for (int i = 0; i < lipShapeTable.lipShapes.Length; i++)
|
||||
{
|
||||
int targetIndex = (int)lipShapeTable.lipShapes[i];
|
||||
if (targetIndex > (int)XrLipShapeHTC.XR_LIP_SHAPE_MAX_ENUM_HTC || targetIndex < 0) continue;
|
||||
lipShapeTable.skinnedMeshRenderer.SetBlendShapeWeight(i, weighting[(XrLipShapeHTC)targetIndex] * 100);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
facialManager.StopFramework(XrFacialTrackingTypeHTC.XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42350b51669fc604cb2cad73c39f116c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
//========= Copyright 2019, HTC Corporation. All rights reserved. ===========
|
||||
using UnityEngine;
|
||||
|
||||
namespace VIVE
|
||||
{
|
||||
namespace FacialTracking.Sample
|
||||
{
|
||||
/// <summary>
|
||||
/// A very basic mirror.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class MirrorCameraSample_Lip : MonoBehaviour
|
||||
{
|
||||
private const float Distance = 0.6f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Lip_Framework.Status != Lip_Framework.FrameworkStatus.WORKING) return;
|
||||
SetMirroTransform();
|
||||
}
|
||||
|
||||
private void SetMirroTransform()
|
||||
{
|
||||
transform.position = Camera.main.transform.position + Camera.main.transform.forward * Distance;
|
||||
transform.position = new Vector3(transform.position.x, Camera.main.transform.position.y, transform.position.z);
|
||||
transform.LookAt(Camera.main.transform);
|
||||
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dcb8610a1e4fe94a8cc7983d3b650cb
|
||||
timeCreated: 1545375969
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user