Add Extrar Morph Support(WIP)
This commit is contained in:
@@ -7,6 +7,6 @@ namespace Gallop
|
||||
public class AssetHolder : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public AssetTable _assetTable;
|
||||
[SerializeField] private AssetTableValue _assetTableValue;
|
||||
[SerializeField] public AssetTableValue _assetTableValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,24 +26,14 @@ namespace Gallop
|
||||
public float HipMoveInfluenceMaxDistance;
|
||||
|
||||
public List<DynamicBone> DynamicBones = new List<DynamicBone>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//InitializePhysics();
|
||||
}
|
||||
public void InitializePhysics()
|
||||
{
|
||||
DynamicBones.Clear();
|
||||
List<Transform> gameObjects = new List<Transform>();
|
||||
gameObjects.AddRange(transform.parent.transform.parent.GetComponentsInChildren<Transform>());
|
||||
|
||||
List<DynamicBoneColliderBase> colliders = new List<DynamicBoneColliderBase>();
|
||||
|
||||
public List<GameObject> InitiallizeCollider(List<Transform> bones)
|
||||
{
|
||||
var colliders = new List<GameObject>();
|
||||
foreach (CySpringCollisionData collider in collisionParam)
|
||||
{
|
||||
if (collider._isInner) continue;
|
||||
|
||||
var bone = gameObjects.Find(a => { return a.name == collider._targetObjectName; });
|
||||
var bone = bones.Find(a => { return a.name == collider._targetObjectName; });
|
||||
if (bone)
|
||||
{
|
||||
|
||||
@@ -52,6 +42,7 @@ namespace Gallop
|
||||
child.transform.localPosition = Vector3.zero;
|
||||
child.transform.localRotation = Quaternion.identity;
|
||||
child.transform.localScale = Vector3.one;
|
||||
colliders.Add(child);
|
||||
|
||||
switch (collider._type)
|
||||
{
|
||||
@@ -64,7 +55,6 @@ namespace Gallop
|
||||
dynamic.m_Height = (collider._offset - collider._offset2).magnitude + collider._radius;
|
||||
dynamic.m_Radius = collider._radius;
|
||||
dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
colliders.Add(dynamic);
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.Sphere:
|
||||
var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
||||
@@ -73,25 +63,27 @@ namespace Gallop
|
||||
Spheredynamic.m_Radius = collider._radius;
|
||||
Spheredynamic.m_Height = collider._distance;
|
||||
Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
colliders.Add(Spheredynamic);
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.Plane:
|
||||
var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
||||
planedynamic.ColliderName = collider._collisionName;
|
||||
child.transform.localPosition = collider._offset;
|
||||
planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
colliders.Add(planedynamic);
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return colliders;
|
||||
}
|
||||
|
||||
|
||||
foreach(CySpringParamDataElement spring in springParam)
|
||||
public void InitializePhysics(List<Transform> bones, List<GameObject> colliders)
|
||||
{
|
||||
DynamicBones.Clear();
|
||||
foreach (CySpringParamDataElement spring in springParam)
|
||||
{
|
||||
var bone = gameObjects.Find(a => { return a.name == spring._boneName; });
|
||||
var bone = bones.Find(a => { return a.name == spring._boneName; });
|
||||
if (bone)
|
||||
{
|
||||
bool isTail = gameObject.name.Contains("tail");//The tail needs less traction
|
||||
@@ -112,14 +104,13 @@ namespace Gallop
|
||||
dynamic.m_Damping = 0.2f;
|
||||
dynamic.m_Stiffness = Mathf.Clamp01(45 / spring._stiffnessForce);
|
||||
dynamic.m_Elasticity = Mathf.Clamp01(45 / spring._dragForce);
|
||||
|
||||
|
||||
}
|
||||
dynamic.m_Radius = spring._collisionRadius;
|
||||
dynamic.m_Friction = 0.5f;
|
||||
dynamic.m_Inert = spring.MoveSpringApplyRate / 3;
|
||||
dynamic.SetupParticles();
|
||||
DynamicBones.Add(dynamic);
|
||||
|
||||
|
||||
foreach (string collisionName in spring._collisionNameList)
|
||||
{
|
||||
var tmp = colliders.Find(a => { return a.gameObject.name == collisionName; });
|
||||
@@ -130,7 +121,7 @@ namespace Gallop
|
||||
}
|
||||
foreach (CySpringParamDataChildElement Childcollision in spring._childElements)
|
||||
{
|
||||
|
||||
|
||||
var tempParticle = dynamic.Particles.Find(a => { return a.m_Transform.gameObject.name == Childcollision._boneName; });
|
||||
if (tempParticle != null)
|
||||
{
|
||||
@@ -146,7 +137,6 @@ namespace Gallop
|
||||
tempParticle.m_Stiffness = Mathf.Clamp01(45 / Childcollision._stiffnessForce);
|
||||
tempParticle.m_Elasticity = Mathf.Clamp01(45 / Childcollision._dragForce);
|
||||
}
|
||||
tempParticle.m_Friction = 0.5f;
|
||||
tempParticle.m_Inert = Childcollision.MoveSpringApplyRate / 3;
|
||||
tempParticle.m_Radius = Childcollision._collisionRadius;
|
||||
tempParticle.m_LimitAngel_Min = Childcollision._limitAngleMin;
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Gallop
|
||||
{
|
||||
public class FaceDrivenKeyTarget : ScriptableObject
|
||||
{
|
||||
public UmaContainer Container;
|
||||
|
||||
public List<EyeTarget> _eyeTarget;
|
||||
public List<EyebrowTarget> _eyebrowTarget;
|
||||
public List<MouthTarget> _mouthTarget;
|
||||
@@ -20,18 +22,19 @@ namespace Gallop
|
||||
private FacialMorph BaseMouthMorph;
|
||||
public FacialMorph LeftEyeXrange, LeftEyeYrange, RightEyeXrange, RightEyeYrange;
|
||||
|
||||
|
||||
public List<FacialMorph> EarMorphs = new List<FacialMorph>();
|
||||
public List<FacialMorph> EyeBrowMorphs = new List<FacialMorph>();
|
||||
public List<FacialMorph> EyeMorphs = new List<FacialMorph>();
|
||||
public List<FacialMorph> MouthMorphs = new List<FacialMorph>();
|
||||
public List<FacialExtraMorph> OtherMorphs = new List<FacialExtraMorph>();
|
||||
|
||||
public GameObject DrivenKeyLocator;
|
||||
public GameObject EyeballCtrl_L_Locator, EyeballCtrl_R_Locator, EyeballCtrl_All_Locator;
|
||||
|
||||
public UmaContainer Container;
|
||||
public Transform DrivenKeyLocator;
|
||||
public Transform EyeballCtrl_L_Locator, EyeballCtrl_R_Locator, EyeballCtrl_All_Locator;
|
||||
|
||||
Dictionary<Transform, Vector3> RotationRecorder = new Dictionary<Transform, Vector3>();
|
||||
Dictionary<Particle, Vector3> ParticleRecorder = new Dictionary<Particle, Vector3>();
|
||||
|
||||
public void Initialize(List<Transform> objs)
|
||||
{
|
||||
Objs = objs;
|
||||
@@ -50,7 +53,6 @@ namespace Gallop
|
||||
for (int j = 0; j < _earTarget[i]._faceGroupInfo.Count; j++)
|
||||
{
|
||||
FacialMorph morph = new FacialMorph();
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "Ear_" + i + "_" + (morph.direction ? "L" : "R");
|
||||
morph.tag = Enum.GetName(typeof(EarType), i);
|
||||
@@ -82,7 +84,6 @@ namespace Gallop
|
||||
for (int j = 0; j < _eyebrowTarget[i]._faceGroupInfo.Count; j++)
|
||||
{
|
||||
FacialMorph morph = new FacialMorph();
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "EyeBrow_" + i + "_" + (morph.direction ? "L" : "R");
|
||||
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialEyebrowId), i);
|
||||
@@ -108,7 +109,6 @@ namespace Gallop
|
||||
for (int j = 0; j < _eyeTarget[i]._faceGroupInfo.Count; j++)
|
||||
{
|
||||
FacialMorph morph = new FacialMorph();
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "Eye_" + i + "_" + (morph.direction ? "L" : "R");
|
||||
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialEyeId), i);
|
||||
@@ -145,7 +145,6 @@ namespace Gallop
|
||||
for (int j = 0; j < _mouthTarget[i]._faceGroupInfo.Count; j++)
|
||||
{
|
||||
FacialMorph morph = new FacialMorph();
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "Mouth_" + i + "_" + j;
|
||||
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialMouthId), i);
|
||||
@@ -165,105 +164,168 @@ namespace Gallop
|
||||
}
|
||||
}
|
||||
|
||||
ChangeMorphWeight(MouthMorphs[3], 1);
|
||||
InitializeExtra();
|
||||
SetupAnimator();
|
||||
|
||||
if (UmaViewerUI.Instance)
|
||||
{
|
||||
UmaViewerUI.Instance.LoadFacialPanels(this);
|
||||
}
|
||||
|
||||
public void InitializeExtra()
|
||||
{
|
||||
if (Container.CheekTex_0)
|
||||
{
|
||||
var CheekMorph = new FacialExtraMorph
|
||||
{
|
||||
name = "Cheek_Ctrl",
|
||||
locator = DrivenKeyLocator.Find("Cheek_Ctrl"),
|
||||
BindGameObject = Container.Head.transform.Find("M_Cheek").gameObject
|
||||
};
|
||||
var bindMaterial = CheekMorph.BindGameObject.GetComponent<SkinnedMeshRenderer>().material;
|
||||
|
||||
BindProperty cheekProperty = new BindProperty()
|
||||
{
|
||||
BindMaterial = bindMaterial,
|
||||
Part = BindProperty.LocatorPart.ScaX,
|
||||
Type = BindProperty.BindType.Texture,
|
||||
BindTexture = Container.CheekTex_0,
|
||||
PropertyName = "_CheekRate"
|
||||
};
|
||||
CheekMorph.BindProperties.Add(cheekProperty);
|
||||
|
||||
if (Container.CheekTex_1)
|
||||
{
|
||||
BindProperty cheekProperty1 = new BindProperty()
|
||||
{
|
||||
BindMaterial = bindMaterial,
|
||||
Part = BindProperty.LocatorPart.ScaY,
|
||||
Type = BindProperty.BindType.Texture,
|
||||
BindTexture = Container.CheekTex_1,
|
||||
PropertyName = "_CheekRate"
|
||||
};
|
||||
CheekMorph.BindProperties.Add(cheekProperty1);
|
||||
}
|
||||
|
||||
if (Container.CheekTex_2)
|
||||
{
|
||||
BindProperty cheekProperty2 = new BindProperty()
|
||||
{
|
||||
BindMaterial = bindMaterial,
|
||||
Part = BindProperty.LocatorPart.ScaZ,
|
||||
Type = BindProperty.BindType.Texture,
|
||||
BindTexture = Container.CheekTex_2,
|
||||
PropertyName = "_CheekRate"
|
||||
};
|
||||
CheekMorph.BindProperties.Add(cheekProperty2);
|
||||
}
|
||||
OtherMorphs.Add(CheekMorph);
|
||||
}
|
||||
|
||||
Container.FaceMaterial = Container.Head.transform.Find("M_Face").GetComponent<SkinnedMeshRenderer>().material;
|
||||
if (Container.FaceMaterial)
|
||||
{
|
||||
FacialExtraMorph FaceShadowMorph = new FacialExtraMorph()
|
||||
{
|
||||
name = "Shade_Ctrl",
|
||||
locator = DrivenKeyLocator.Find("Shade_Ctrl")
|
||||
};
|
||||
FaceShadowMorph.BindProperties.Add(
|
||||
new BindProperty()
|
||||
{
|
||||
BindMaterial = Container.FaceMaterial,
|
||||
Part = BindProperty.LocatorPart.ScaX,
|
||||
Type = BindProperty.BindType.Shader,
|
||||
PropertyName = "_faceShadowAlpha"
|
||||
});
|
||||
OtherMorphs.Add(FaceShadowMorph);
|
||||
}
|
||||
|
||||
FacialExtraMorph FaceMangaMorph = new FacialExtraMorph()
|
||||
{
|
||||
name = "Manga_Ctrl",
|
||||
locator = DrivenKeyLocator.Find("Manga_Ctrl")
|
||||
};
|
||||
|
||||
var mangaObjects = new List<GameObject>();
|
||||
mangaObjects.AddRange(Container.LeftMangaObject);
|
||||
mangaObjects.AddRange(Container.RightMangaObject);
|
||||
FaceMangaMorph.BindProperties.Add(new BindProperty()
|
||||
{
|
||||
Part = BindProperty.LocatorPart.ScaY,
|
||||
Type = BindProperty.BindType.EyeSelect,
|
||||
BindPrefab = mangaObjects
|
||||
});
|
||||
FaceMangaMorph.BindProperties.Add(new BindProperty()
|
||||
{
|
||||
Part = BindProperty.LocatorPart.ScaX,
|
||||
Type = BindProperty.BindType.Bool,
|
||||
BindPrefab = mangaObjects
|
||||
});
|
||||
OtherMorphs.Add(FaceMangaMorph);
|
||||
}
|
||||
|
||||
public void SetupAnimator()
|
||||
{
|
||||
DrivenKeyLocator = new GameObject("DrivenKeyLocator");
|
||||
DrivenKeyLocator.transform.SetParent(Container.transform);
|
||||
SetupLocator("Ear_L_Ctrl", "Ear_L__", EarMorphs.FindAll(a => a.direction == true));
|
||||
SetupLocator("Ear_R_Ctrl", "Ear_R__", EarMorphs.FindAll(a => a.direction == false));
|
||||
SetupLocator("Eye_L_Base_Ctrl", "Eye_L__", EyeMorphs.FindAll(a => a.direction == true));
|
||||
SetupLocator("Eye_R_Base_Ctrl", "Eye_R__", EyeMorphs.FindAll(a => a.direction == false));
|
||||
SetupLocator("Eyebrow_L_Base_Ctrl", "Eyebrow_L__", EyeBrowMorphs.FindAll(a => a.direction == true));
|
||||
SetupLocator("Eyebrow_R_Base_Ctrl", "Eyebrow_R__", EyeBrowMorphs.FindAll(a => a.direction == false));
|
||||
SetupLocator("Mouth_Base_Ctrl", "Mouth__", MouthMorphs.FindAll(a => a.direction == false));
|
||||
if (!DrivenKeyLocator) return;
|
||||
|
||||
var root = new GameObject("Eyeball_L_Ctrl");
|
||||
root.transform.SetParent(DrivenKeyLocator.transform);
|
||||
EyeballCtrl_L_Locator = root;
|
||||
|
||||
root = new GameObject("Eyeball_R_Ctrl");
|
||||
root.transform.SetParent(DrivenKeyLocator.transform);
|
||||
EyeballCtrl_R_Locator = root;
|
||||
|
||||
root = new GameObject("Eyeball_all_Ctrl");
|
||||
root.transform.SetParent(DrivenKeyLocator.transform);
|
||||
EyeballCtrl_All_Locator = root;
|
||||
SetupLocator("Ear_L_Ctrl", EarMorphs.FindAll(a => a.direction == true));
|
||||
SetupLocator("Ear_R_Ctrl", EarMorphs.FindAll(a => a.direction == false));
|
||||
SetupLocator("Eye_L_Base_Ctrl", EyeMorphs.FindAll(a => a.direction == true));
|
||||
SetupLocator("Eye_R_Base_Ctrl", EyeMorphs.FindAll(a => a.direction == false));
|
||||
SetupLocator("Eyebrow_L_Base_Ctrl", EyeBrowMorphs.FindAll(a => a.direction == true));
|
||||
SetupLocator("Eyebrow_R_Base_Ctrl", EyeBrowMorphs.FindAll(a => a.direction == false));
|
||||
SetupLocator("Mouth_Base_Ctrl", MouthMorphs.FindAll(a => a.direction == false));
|
||||
|
||||
Container.UmaFaceAnimator = DrivenKeyLocator.AddComponent<Animator>();
|
||||
Container.UmaFaceAnimator.avatar = AvatarBuilder.BuildGenericAvatar(DrivenKeyLocator, "DrivenKeyLocator");
|
||||
EyeballCtrl_L_Locator = DrivenKeyLocator.transform.Find("Eyeball_L_Ctrl");
|
||||
EyeballCtrl_R_Locator = DrivenKeyLocator.transform.Find("Eyeball_R_Ctrl");
|
||||
EyeballCtrl_All_Locator = DrivenKeyLocator.transform.Find("Eyeball_all_Ctrl");
|
||||
|
||||
Container.UmaFaceAnimator = DrivenKeyLocator.GetComponent<Animator>();
|
||||
Container.UmaFaceAnimator.avatar = AvatarBuilder.BuildGenericAvatar(DrivenKeyLocator.gameObject, "DrivenKeyLocator");
|
||||
Container.FaceOverrideController = Instantiate(UmaViewerBuilder.Instance.FaceOverrideController);
|
||||
Container.UmaFaceAnimator.runtimeAnimatorController = Container.FaceOverrideController;
|
||||
}
|
||||
|
||||
public void SetupLocator(string rootName, string prefix, List<FacialMorph> morphs)
|
||||
public void SetupLocator(string rootName, List<FacialMorph> morphs)
|
||||
{
|
||||
var root = new GameObject(rootName);
|
||||
root.transform.SetParent(DrivenKeyLocator.transform);
|
||||
|
||||
var root = DrivenKeyLocator.transform.Find(rootName);
|
||||
var locators = new List<Transform>(root.GetComponentsInChildren<Transform>());
|
||||
morphs.ForEach(morph =>
|
||||
{
|
||||
var locator = new GameObject(prefix + morph.tag);
|
||||
locator.transform.SetParent(root.transform);
|
||||
morph.locator = locator.transform;
|
||||
var locator = locators.Find(a => a.name.EndsWith(morph.tag));
|
||||
if (locator)
|
||||
{
|
||||
morph.locator = locator;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void ChangeMorph()
|
||||
{
|
||||
FacialResetAll();
|
||||
|
||||
foreach (FacialMorph morph in EarMorphs)
|
||||
{
|
||||
ProcessMorph(morph);
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in EyeBrowMorphs)
|
||||
{
|
||||
ProcessMorph(morph);
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in EyeMorphs)
|
||||
{
|
||||
ProcessMorph(morph);
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in MouthMorphs)
|
||||
{
|
||||
ProcessMorph(morph);
|
||||
}
|
||||
|
||||
EarMorphs.ForEach(morph => ProcessMorph(morph));
|
||||
EyeBrowMorphs.ForEach(morph => ProcessMorph(morph));
|
||||
EyeMorphs.ForEach(morph => ProcessMorph(morph));
|
||||
MouthMorphs.ForEach(morph => ProcessMorph(morph));
|
||||
OtherMorphs.ForEach(morph => ProcessExtraMorph(morph));
|
||||
ApplyRotation();
|
||||
}
|
||||
|
||||
public void ClearMorph()
|
||||
{
|
||||
foreach (FacialMorph morph in EarMorphs)
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
EarMorphs.ForEach(morph => morph.weight = 0);
|
||||
EyeBrowMorphs.ForEach(morph => morph.weight = 0);
|
||||
EyeMorphs.ForEach(morph => morph.weight = 0);
|
||||
MouthMorphs.ForEach(morph => morph.weight = 0);
|
||||
|
||||
foreach (FacialMorph morph in EyeBrowMorphs)
|
||||
OtherMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in EyeMorphs)
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in MouthMorphs)
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
morph.BindProperties.ForEach(property =>
|
||||
{
|
||||
property.Value = morph.GetLocatorValue(property.Part);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void ProcessMorph(FacialMorph morph)
|
||||
@@ -275,7 +337,7 @@ namespace Gallop
|
||||
trs.physicsParticle.m_InitLocalPosition += trs._position * morph.weight;
|
||||
ParticleRecorder[trs.physicsParticle] += trs._rotation * morph.weight;
|
||||
}
|
||||
else if(trs.transform)
|
||||
else if (trs.transform)
|
||||
{
|
||||
trs.transform.localScale += trs._scale * morph.weight;
|
||||
trs.transform.localPosition += trs._position * morph.weight;
|
||||
@@ -284,6 +346,50 @@ namespace Gallop
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessExtraMorph(FacialExtraMorph morph)
|
||||
{
|
||||
foreach (var property in morph.BindProperties)
|
||||
{
|
||||
switch (property.Type)
|
||||
{
|
||||
case BindProperty.BindType.Texture:
|
||||
if (property.Value > 0.01f)
|
||||
{
|
||||
morph.BindGameObject.SetActive(true);
|
||||
property.BindMaterial.mainTexture = property.BindTexture;
|
||||
property.BindMaterial.SetFloat(property.PropertyName, property.Value);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (morph.BindProperties.IndexOf(property) == morph.BindProperties.Count - 1)
|
||||
{
|
||||
morph.BindGameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BindProperty.BindType.Shader:
|
||||
property.BindMaterial.SetFloat(property.PropertyName, property.Value);
|
||||
break;
|
||||
case BindProperty.BindType.Select:
|
||||
property.BindPrefab.ForEach(a=>a.SetActive((int)property.Value == property.BindPrefab.IndexOf(a)));
|
||||
break;
|
||||
case BindProperty.BindType.EyeSelect:
|
||||
var count = property.BindPrefab.Count / 2;
|
||||
var val = (int)property.Value;
|
||||
property.BindPrefab.ForEach(a =>
|
||||
a.SetActive(val + count < property.BindPrefab.Count && (val == property.BindPrefab.IndexOf(a) || val + count == property.BindPrefab.IndexOf(a))));
|
||||
break;
|
||||
case BindProperty.BindType.Bool:
|
||||
if (property.Value <= 0)
|
||||
{
|
||||
property.BindPrefab.ForEach(a =>a.SetActive(false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FacialResetAll()
|
||||
{
|
||||
FacialReset(BaseLEarMorph.trsArray);
|
||||
@@ -336,6 +442,13 @@ namespace Gallop
|
||||
ChangeMorph();
|
||||
}
|
||||
|
||||
public void ChangeMorphWeight(BindProperty property, float val)
|
||||
{
|
||||
Container.isAnimatorControl = false;
|
||||
property.Value = val < 0 ? 0 : val;
|
||||
ChangeMorph();
|
||||
}
|
||||
|
||||
public void SetEyeRange(float lx, float ly, float rx, float ry)
|
||||
{
|
||||
LeftEyeXrange.weight = lx;
|
||||
@@ -349,26 +462,32 @@ namespace Gallop
|
||||
{
|
||||
EyeBrowMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
if (morph.locator)
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
});
|
||||
|
||||
EarMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
if (morph.locator)
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
});
|
||||
|
||||
MouthMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
if (morph.weight < 0)
|
||||
morph.weight = -morph.weight;
|
||||
if (morph.locator)
|
||||
{
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
if (morph.weight < 0)
|
||||
morph.weight = -morph.weight;
|
||||
}
|
||||
});
|
||||
|
||||
EyeMorphs.ForEach(morph =>
|
||||
{
|
||||
if (!(morph == LeftEyeXrange || morph == LeftEyeYrange || morph == RightEyeXrange || morph == RightEyeYrange))
|
||||
{
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
if (morph.locator)
|
||||
morph.weight = morph.locator.transform.localPosition.x * -100;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -378,39 +497,20 @@ namespace Gallop
|
||||
LeftEyeYrange.weight = -(EyeballCtrl_L_Locator.transform.localPosition.y * -100 + EyeballCtrl_All_Locator.transform.localPosition.y * -100);
|
||||
RightEyeYrange.weight = (EyeballCtrl_R_Locator.transform.localPosition.y * -100 + EyeballCtrl_All_Locator.transform.localPosition.y * -100);
|
||||
|
||||
OtherMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.BindProperties.ForEach(property =>
|
||||
{
|
||||
property.Value = morph.GetLocatorValue(property.Part);
|
||||
});
|
||||
});
|
||||
|
||||
ChangeMorph();
|
||||
}
|
||||
|
||||
public void ResetLocator()
|
||||
{
|
||||
EarMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = 0;
|
||||
morph.locator.transform.localPosition = Vector3.zero;
|
||||
});
|
||||
|
||||
EyeBrowMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = 0;
|
||||
morph.locator.transform.localPosition = Vector3.zero;
|
||||
});
|
||||
|
||||
EyeMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = 0;
|
||||
morph.locator.transform.localPosition = Vector3.zero;
|
||||
});
|
||||
|
||||
MouthMorphs.ForEach(morph =>
|
||||
{
|
||||
morph.weight = 0;
|
||||
morph.locator.transform.localPosition = Vector3.zero;
|
||||
});
|
||||
|
||||
|
||||
EyeballCtrl_L_Locator.transform.localPosition = Vector3.zero;
|
||||
EyeballCtrl_R_Locator.transform.localPosition = Vector3.zero;
|
||||
EyeballCtrl_All_Locator.transform.localPosition = Vector3.zero;
|
||||
Container.UmaFaceAnimator.Rebind();
|
||||
ChangeMorph();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,58 @@ namespace Gallop
|
||||
public string name;
|
||||
public string tag = "";
|
||||
public bool direction;
|
||||
public FaceDrivenKeyTarget target;
|
||||
public float weight;
|
||||
public List<TrsArray> trsArray;
|
||||
public Transform locator;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FacialExtraMorph : FacialMorph
|
||||
{
|
||||
public GameObject BindGameObject;
|
||||
public List<BindProperty> BindProperties = new List<BindProperty>();
|
||||
public float GetLocatorValue(BindProperty.LocatorPart part)
|
||||
{
|
||||
switch (part)
|
||||
{
|
||||
case BindProperty.LocatorPart.PosX: return locator.localPosition.x;
|
||||
case BindProperty.LocatorPart.PosY: return locator.localPosition.y;
|
||||
case BindProperty.LocatorPart.PosZ: return locator.localPosition.z;
|
||||
case BindProperty.LocatorPart.ScaX: return locator.localScale.x;
|
||||
case BindProperty.LocatorPart.ScaY: return locator.localScale.y;
|
||||
case BindProperty.LocatorPart.ScaZ: return locator.localScale.z;
|
||||
default: return locator.position.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class BindProperty
|
||||
{
|
||||
public enum LocatorPart
|
||||
{
|
||||
PosX,
|
||||
PosY,
|
||||
PosZ,
|
||||
ScaX,
|
||||
ScaY,
|
||||
ScaZ,
|
||||
}
|
||||
|
||||
public enum BindType
|
||||
{
|
||||
Shader,
|
||||
Select,
|
||||
EyeSelect,
|
||||
Texture,
|
||||
Bool
|
||||
}
|
||||
public Material BindMaterial;
|
||||
public Texture BindTexture;
|
||||
public List<GameObject> BindPrefab = new List<GameObject>();
|
||||
public string PropertyName;
|
||||
public LocatorPart Part;
|
||||
public BindType Type;
|
||||
public float Value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,22 @@ using static DynamicBone;
|
||||
[System.Serializable]
|
||||
public class AssetTable
|
||||
{
|
||||
public Object this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
var item = list.Find(a => a.Key.Equals(key));
|
||||
if(item != null)
|
||||
{
|
||||
return item.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<StringObjectPair> list;
|
||||
}
|
||||
|
||||
@@ -13,6 +29,21 @@ public class AssetTable
|
||||
[System.Serializable]
|
||||
public class AssetTableValue
|
||||
{
|
||||
public float this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
var item = list.Find(a => a.Key.Equals(key));
|
||||
if (item != null)
|
||||
{
|
||||
return item.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<StringValuePair> list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user