add Facial Support
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 020a75ca2e43f90458872197fe59530d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
// Copyright (c) 2014 Luminary LLC
|
||||||
|
// Licensed under The MIT License (See LICENSE for full text)
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[CustomPropertyDrawer(typeof(SetPropertyAttribute))]
|
||||||
|
public class SetPropertyDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||||
|
{
|
||||||
|
// Rely on the default inspector GUI
|
||||||
|
EditorGUI.BeginChangeCheck ();
|
||||||
|
EditorGUI.PropertyField(position, property, label);
|
||||||
|
|
||||||
|
// Update only when necessary
|
||||||
|
SetPropertyAttribute setProperty = attribute as SetPropertyAttribute;
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
// When a SerializedProperty is modified the actual field does not have the current value set (i.e.
|
||||||
|
// FieldInfo.GetValue() will return the prior value that was set) until after this OnGUI call has completed.
|
||||||
|
// Therefore, we need to mark this property as dirty, so that it can be updated with a subsequent OnGUI event
|
||||||
|
// (e.g. Repaint)
|
||||||
|
setProperty.IsDirty = true;
|
||||||
|
}
|
||||||
|
else if (setProperty.IsDirty)
|
||||||
|
{
|
||||||
|
// The propertyPath may reference something that is a child field of a field on this Object, so it is necessary
|
||||||
|
// to find which object is the actual parent before attempting to set the property with the current value.
|
||||||
|
object parent = GetParentObjectOfProperty(property.propertyPath, property.serializedObject.targetObject);
|
||||||
|
Type type = parent.GetType();
|
||||||
|
PropertyInfo pi = type.GetProperty(setProperty.Name);
|
||||||
|
if (pi == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("Invalid property name: " + setProperty.Name + "\nCheck your [SetProperty] attribute");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use FieldInfo instead of the SerializedProperty accessors as we'd have to deal with every
|
||||||
|
// SerializedPropertyType and use the correct accessor
|
||||||
|
pi.SetValue(parent, fieldInfo.GetValue(parent), null);
|
||||||
|
}
|
||||||
|
setProperty.IsDirty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private object GetParentObjectOfProperty(string path, object obj)
|
||||||
|
{
|
||||||
|
string[] fields = path.Split('.');
|
||||||
|
|
||||||
|
// We've finally arrived at the final object that contains the property
|
||||||
|
if (fields.Length == 1)
|
||||||
|
{
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We may have to walk public or private fields along the chain to finding our container object, so we have to allow for both
|
||||||
|
FieldInfo fi = obj.GetType().GetField(fields[0], BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
obj = fi.GetValue(obj);
|
||||||
|
|
||||||
|
// Keep searching for our object that contains the property
|
||||||
|
return GetParentObjectOfProperty(string.Join(".", fields, 1, fields.Length - 1), obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f52efb0d2eca47e40ab251ae0e23e311
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -13750,7 +13750,6 @@ GameObject:
|
|||||||
- component: {fileID: 2039749204}
|
- component: {fileID: 2039749204}
|
||||||
- component: {fileID: 2039749203}
|
- component: {fileID: 2039749203}
|
||||||
- component: {fileID: 2039749202}
|
- component: {fileID: 2039749202}
|
||||||
- component: {fileID: 2039749206}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: box
|
m_Name: box
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -13834,73 +13833,6 @@ Transform:
|
|||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 6
|
m_RootOrder: 6
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &2039749206
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2039749201}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: f9ac8d30c6a0d9642a11e5be4c440740, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Root: {fileID: 0}
|
|
||||||
m_UpdateRate: 60
|
|
||||||
m_UpdateMode: 3
|
|
||||||
m_Damping: 0.1
|
|
||||||
m_DampingDistrib:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
m_Elasticity: 0.1
|
|
||||||
m_ElasticityDistrib:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
m_Stiffness: 0.1
|
|
||||||
m_StiffnessDistrib:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
m_Inert: 0
|
|
||||||
m_InertDistrib:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
m_Friction: 0
|
|
||||||
m_FrictionDistrib:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
m_Radius: 0
|
|
||||||
m_RadiusDistrib:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Curve: []
|
|
||||||
m_PreInfinity: 2
|
|
||||||
m_PostInfinity: 2
|
|
||||||
m_RotationOrder: 4
|
|
||||||
m_EndLength: 0
|
|
||||||
m_EndOffset: {x: 0, y: 0, z: 0}
|
|
||||||
m_Gravity: {x: 0, y: 0, z: 0}
|
|
||||||
m_Force: {x: 0, y: 0, z: 0}
|
|
||||||
m_Colliders: []
|
|
||||||
m_Exclusions: []
|
|
||||||
m_FreezeAxis: 0
|
|
||||||
m_DistantDisable: 0
|
|
||||||
m_ReferenceObject: {fileID: 0}
|
|
||||||
m_DistanceToObject: 20
|
|
||||||
--- !u!1 &2043122521
|
--- !u!1 &2043122521
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -32,7 +32,46 @@ namespace Gallop
|
|||||||
public void SetPhysics()
|
public void SetPhysics()
|
||||||
{
|
{
|
||||||
List<Transform> gameObjects = new List<Transform>();
|
List<Transform> gameObjects = new List<Transform>();
|
||||||
gameObjects.AddRange(transform.parent.GetComponentsInChildren<Transform>());
|
Dictionary<string, DynamicBoneColliderBase> DynamicBoneColliders = new Dictionary<string, DynamicBoneColliderBase>();
|
||||||
|
gameObjects.AddRange(transform.parent.GetComponentsInChildren<Transform>());
|
||||||
|
foreach (CySpringCollisionData collider in collisionParam)
|
||||||
|
{
|
||||||
|
if (collider._isInner) continue;
|
||||||
|
|
||||||
|
var bone = gameObjects.Find(a => { return a.name == collider._targetObjectName; });
|
||||||
|
if (bone)
|
||||||
|
{
|
||||||
|
|
||||||
|
var child = new GameObject(collider._collisionName);
|
||||||
|
child.transform.SetParent(bone);
|
||||||
|
child.transform.localPosition = Vector3.zero;
|
||||||
|
child.transform.localRotation = Quaternion.identity;
|
||||||
|
child.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
switch (collider._type){
|
||||||
|
case CySpringCollisionData.CollisionType.Capsule:
|
||||||
|
case CySpringCollisionData.CollisionType.Sphere:
|
||||||
|
var dynamic = child.AddComponent<DynamicBoneCollider>();
|
||||||
|
dynamic.ColliderName = collider._collisionName;
|
||||||
|
dynamic.m_Center = collider._offset;
|
||||||
|
dynamic.m_Radius = collider._radius;
|
||||||
|
dynamic.m_Height = collider._distance;
|
||||||
|
dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
|
DynamicBoneColliders.Add(collider._collisionName,dynamic);
|
||||||
|
break;
|
||||||
|
case CySpringCollisionData.CollisionType.Plane:
|
||||||
|
var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
||||||
|
planedynamic.ColliderName = collider._collisionName;
|
||||||
|
planedynamic.m_Center = collider._offset*0.1f;
|
||||||
|
planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
|
DynamicBoneColliders.Add(collider._collisionName, planedynamic);
|
||||||
|
break;
|
||||||
|
case CySpringCollisionData.CollisionType.None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach (CySpringParamDataElement spring in springParam)
|
foreach (CySpringParamDataElement spring in springParam)
|
||||||
{
|
{
|
||||||
@@ -41,6 +80,30 @@ namespace Gallop
|
|||||||
{
|
{
|
||||||
var dynamic = bone.gameObject.AddComponent<DynamicBone>();
|
var dynamic = bone.gameObject.AddComponent<DynamicBone>();
|
||||||
dynamic.m_Root = bone;
|
dynamic.m_Root = bone;
|
||||||
|
dynamic.m_Gravity = new Vector3(0, -spring._gravity/70000, 0);
|
||||||
|
dynamic.m_Stiffness = spring._stiffnessForce/7000;
|
||||||
|
dynamic.m_Elasticity = spring._dragForce/9000;
|
||||||
|
dynamic.m_Radius = spring._collisionRadius;
|
||||||
|
dynamic.m_Colliders = new List<DynamicBoneColliderBase>();
|
||||||
|
foreach (string collisionName in spring._collisionNameList)
|
||||||
|
{
|
||||||
|
if(DynamicBoneColliders.TryGetValue(collisionName,out DynamicBoneColliderBase val))
|
||||||
|
{
|
||||||
|
if (!dynamic.m_Colliders.Contains(val))
|
||||||
|
dynamic.m_Colliders.Add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (CySpringParamDataChildElement Childcollision in spring._childElements)
|
||||||
|
{
|
||||||
|
foreach (string collisionName in Childcollision._collisionNameList)
|
||||||
|
{
|
||||||
|
if (DynamicBoneColliders.TryGetValue(collisionName, out DynamicBoneColliderBase val))
|
||||||
|
{
|
||||||
|
if(!dynamic.m_Colliders.Contains(val))
|
||||||
|
dynamic.m_Colliders.Add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -326,7 +326,8 @@ MonoBehaviour:
|
|||||||
m_EndOffset: {x: 0.1, y: -0.1, z: 0.3}
|
m_EndOffset: {x: 0.1, y: -0.1, z: 0.3}
|
||||||
m_Gravity: {x: 0, y: 0, z: 0}
|
m_Gravity: {x: 0, y: 0, z: 0}
|
||||||
m_Force: {x: 0, y: 0, z: 0}
|
m_Force: {x: 0, y: 0, z: 0}
|
||||||
m_Colliders: []
|
m_Colliders:
|
||||||
|
- {fileID: 789765167}
|
||||||
m_Exclusions: []
|
m_Exclusions: []
|
||||||
m_FreezeAxis: 0
|
m_FreezeAxis: 0
|
||||||
m_DistantDisable: 0
|
m_DistantDisable: 0
|
||||||
@@ -414,6 +415,7 @@ MonoBehaviour:
|
|||||||
m_Colliders:
|
m_Colliders:
|
||||||
- {fileID: 94102370}
|
- {fileID: 94102370}
|
||||||
- {fileID: 838898607}
|
- {fileID: 838898607}
|
||||||
|
- {fileID: 789765167}
|
||||||
m_Exclusions: []
|
m_Exclusions: []
|
||||||
m_FreezeAxis: 0
|
m_FreezeAxis: 0
|
||||||
m_DistantDisable: 0
|
m_DistantDisable: 0
|
||||||
@@ -552,6 +554,119 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: ba128457d0ea5e3439dbe4a53b9d1273, type: 3}
|
||||||
|
--- !u!1 &789765166
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 789765171}
|
||||||
|
- component: {fileID: 789765170}
|
||||||
|
- component: {fileID: 789765169}
|
||||||
|
- component: {fileID: 789765168}
|
||||||
|
- component: {fileID: 789765167}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Sphere
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &789765167
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 789765166}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: baedd976e12657241bf7ff2d1c685342, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Direction: 1
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
m_Bound: 0
|
||||||
|
m_Radius: 0.5
|
||||||
|
m_Height: 0
|
||||||
|
--- !u!135 &789765168
|
||||||
|
SphereCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 789765166}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Radius: 0.5
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!23 &789765169
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 789765166}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
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
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!33 &789765170
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 789765166}
|
||||||
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!4 &789765171
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 789765166}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -0.189, y: 1.083, z: -0.69718814}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 4
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &838898605 stripped
|
--- !u!1 &838898605 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
m_CorrespondingSourceObject: {fileID: 100140, guid: ba128457d0ea5e3439dbe4a53b9d1273,
|
m_CorrespondingSourceObject: {fileID: 100140, guid: ba128457d0ea5e3439dbe4a53b9d1273,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
public class DynamicBoneColliderBase : MonoBehaviour
|
public class DynamicBoneColliderBase : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public string ColliderName;
|
||||||
public enum Direction
|
public enum Direction
|
||||||
{
|
{
|
||||||
X, Y, Z
|
X, Y, Z
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Gallop
|
namespace Gallop
|
||||||
@@ -9,5 +10,178 @@ namespace Gallop
|
|||||||
public List<EyeTarget> _eyeTarget;
|
public List<EyeTarget> _eyeTarget;
|
||||||
public List<EyebrowTarget> _eyebrowTarget;
|
public List<EyebrowTarget> _eyebrowTarget;
|
||||||
public List<MouthTarget> _mouthTarget;
|
public List<MouthTarget> _mouthTarget;
|
||||||
|
|
||||||
|
public List<Transform> Objs = new List<Transform>();
|
||||||
|
private List<Vector3> OriTrans = new List<Vector3>();
|
||||||
|
private List<Quaternion> OriRots = new List<Quaternion>();
|
||||||
|
private List<Vector3> OriScal = new List<Vector3>();
|
||||||
|
|
||||||
|
public List<FacialMorph> EyeBrowMorphs = new List<FacialMorph>();
|
||||||
|
public List<FacialMorph> EyeMorphs = new List<FacialMorph>();
|
||||||
|
public List<FacialMorph> MouthMorphs = new List<FacialMorph>();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
Objs.AddRange(GetComponentsInChildren<Transform>());
|
||||||
|
foreach (Transform g in Objs)
|
||||||
|
{
|
||||||
|
OriTrans.Add(g.localPosition);
|
||||||
|
OriRots.Add(g.localRotation);
|
||||||
|
OriScal.Add(g.localScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _eyebrowTarget.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _eyebrowTarget[i]._faceGroupInfo.Count; j++)
|
||||||
|
{
|
||||||
|
FacialMorph morph = new FacialMorph();
|
||||||
|
morph.SetFace(this);
|
||||||
|
morph.name = "EyeBrow_" + i + "_" + (j > 0 ? "R" : "L");
|
||||||
|
morph.trsArray = _eyebrowTarget[i]._faceGroupInfo[j]._trsArray;
|
||||||
|
EyeBrowMorphs.Add(morph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _eyeTarget.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _eyeTarget[i]._faceGroupInfo.Count; j++)
|
||||||
|
{
|
||||||
|
FacialMorph morph = new FacialMorph();
|
||||||
|
morph.SetFace(this);
|
||||||
|
morph.name = "Eye_" + i + "_" + (j > 0 ? "R" : "L");
|
||||||
|
morph.trsArray = _eyeTarget[i]._faceGroupInfo[j]._trsArray;
|
||||||
|
EyeMorphs.Add(morph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _mouthTarget.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _mouthTarget[i]._faceGroupInfo.Count; j++)
|
||||||
|
{
|
||||||
|
FacialMorph morph = new FacialMorph();
|
||||||
|
morph.SetFace(this);
|
||||||
|
morph.name = "Mouth_" + i + "_" + j;
|
||||||
|
morph.trsArray = _mouthTarget[i]._faceGroupInfo[j]._trsArray;
|
||||||
|
MouthMorphs.Add(morph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < EyeBrowMorphs.Count; i++)
|
||||||
|
{
|
||||||
|
if(EyeBrowMorphs[i].LastWeight!= EyeBrowMorphs[i].Weight)
|
||||||
|
{
|
||||||
|
ChangeMorph();
|
||||||
|
EyeBrowMorphs[i].LastWeight = EyeBrowMorphs[i].Weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < EyeMorphs.Count; i++)
|
||||||
|
{
|
||||||
|
if (EyeMorphs[i].LastWeight != EyeMorphs[i].Weight)
|
||||||
|
{
|
||||||
|
ChangeMorph();
|
||||||
|
EyeMorphs[i].LastWeight = EyeMorphs[i].Weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < MouthMorphs.Count; i++)
|
||||||
|
{
|
||||||
|
if (MouthMorphs[i].LastWeight != MouthMorphs[i].Weight)
|
||||||
|
{
|
||||||
|
ChangeMorph();
|
||||||
|
MouthMorphs[i].LastWeight = MouthMorphs[i].Weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeMorph()
|
||||||
|
{
|
||||||
|
FacialReset();
|
||||||
|
foreach (FacialMorph morph in EyeBrowMorphs)
|
||||||
|
{
|
||||||
|
foreach(TrsArray trs in morph.trsArray)
|
||||||
|
{
|
||||||
|
var bone = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||||
|
if (bone)
|
||||||
|
{
|
||||||
|
if (trs.IsOverrideTarget==1)
|
||||||
|
{
|
||||||
|
bone.localRotation = Quaternion.Euler(Vector3.Lerp(OriRots[Objs.IndexOf(bone)].eulerAngles, trs._rotation, morph.Weight));
|
||||||
|
bone.localPosition = Vector3.Lerp(OriTrans[Objs.IndexOf(bone)],trs._position,morph.Weight);
|
||||||
|
bone.localScale = Vector3.Lerp(OriScal[Objs.IndexOf(bone)],trs._scale, morph.Weight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bone.localRotation = Quaternion.Euler(bone.localRotation.eulerAngles+ (trs._rotation* morph.Weight));
|
||||||
|
bone.localPosition += trs._position*morph.Weight;
|
||||||
|
bone.localScale += trs._scale* morph.Weight;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (FacialMorph morph in EyeMorphs)
|
||||||
|
{
|
||||||
|
foreach (TrsArray trs in morph.trsArray)
|
||||||
|
{
|
||||||
|
var bone = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||||
|
if (bone)
|
||||||
|
{
|
||||||
|
if (trs.IsOverrideTarget == 1)
|
||||||
|
{
|
||||||
|
bone.localRotation = Quaternion.Euler(Vector3.Lerp(OriRots[Objs.IndexOf(bone)].eulerAngles, trs._rotation, morph.Weight));
|
||||||
|
bone.localPosition = Vector3.Lerp(OriTrans[Objs.IndexOf(bone)], trs._position, morph.Weight);
|
||||||
|
bone.localScale = Vector3.Lerp(OriScal[Objs.IndexOf(bone)], trs._scale, morph.Weight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bone.localRotation = Quaternion.Euler(bone.localRotation.eulerAngles + (trs._rotation * morph.Weight));
|
||||||
|
bone.localPosition += trs._position * morph.Weight;
|
||||||
|
bone.localScale += trs._scale * morph.Weight;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (FacialMorph morph in MouthMorphs)
|
||||||
|
{
|
||||||
|
foreach (TrsArray trs in morph.trsArray)
|
||||||
|
{
|
||||||
|
var bone = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||||
|
if (bone)
|
||||||
|
{
|
||||||
|
if (trs.IsOverrideTarget == 1)
|
||||||
|
{
|
||||||
|
bone.localRotation = Quaternion.Euler(Vector3.Lerp(OriRots[Objs.IndexOf(bone)].eulerAngles, trs._rotation, morph.Weight));
|
||||||
|
bone.localPosition = Vector3.Lerp(OriTrans[Objs.IndexOf(bone)], trs._position, morph.Weight);
|
||||||
|
bone.localScale = Vector3.Lerp(OriScal[Objs.IndexOf(bone)], trs._scale, morph.Weight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bone.localRotation = Quaternion.Euler(bone.localRotation.eulerAngles + (trs._rotation * morph.Weight));
|
||||||
|
bone.localPosition += trs._position * morph.Weight;
|
||||||
|
bone.localScale += trs._scale * morph.Weight;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FacialReset()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Objs.Count; i++)
|
||||||
|
{
|
||||||
|
Objs[i].localPosition = OriTrans[i];
|
||||||
|
Objs[i].localRotation = OriRots[i];
|
||||||
|
Objs[i].localScale = OriScal[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Gallop
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class FacialMorph
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
private FaceDrivenKeyTarget face;
|
||||||
|
[Range(0, 1)]
|
||||||
|
public float Weight;
|
||||||
|
[HideInInspector]public float LastWeight;
|
||||||
|
[HideInInspector] public List<TrsArray> trsArray;
|
||||||
|
public void SetFace(FaceDrivenKeyTarget faceTarget)
|
||||||
|
{
|
||||||
|
face = faceTarget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cdfe7600c0409fa45b2d2995667ba2ec
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) 2014 Luminary LLC
|
||||||
|
// Licensed under The MIT License (See LICENSE for full text)
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class SetPropertyAttribute : PropertyAttribute
|
||||||
|
{
|
||||||
|
public string Name { get; private set; }
|
||||||
|
public bool IsDirty { get; set; }
|
||||||
|
|
||||||
|
public SetPropertyAttribute(string name)
|
||||||
|
{
|
||||||
|
this.Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5d72052b442fcfe42b1433eeb25729bb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,6 +12,9 @@ EditorUserSettings:
|
|||||||
value: 224247031146467f14000d2f19207d1f1812570e2925297f092c103cb3ae2136ebf32f
|
value: 224247031146467f14000d2f19207d1f1812570e2925297f092c103cb3ae2136ebf32f
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-2:
|
RecentlyUsedScenePath-2:
|
||||||
|
value: 22424703114646680e1c0532043010051b16153f3f3d2b35620d043de3ed3d3bc0e838eca81e3a31364dcb3909315071e704001fef
|
||||||
|
flags: 0
|
||||||
|
RecentlyUsedScenePath-3:
|
||||||
value: 22424703114646680e0b0227036c691504041125227a68252320092a
|
value: 22424703114646680e0b0227036c691504041125227a68252320092a
|
||||||
flags: 0
|
flags: 0
|
||||||
vcSharedLogLevel:
|
vcSharedLogLevel:
|
||||||
|
|||||||
Reference in New Issue
Block a user