This commit is contained in:
1605296300@qq.com
2022-08-19 02:56:00 +08:00
parent 46be47a262
commit 5fb42a0fe7
7 changed files with 70 additions and 141 deletions
+68 -28
View File
@@ -67,13 +67,15 @@ namespace Gallop
}
}
private void Update()
private void FixedUpdate()
{
bool changed = false;
for (int i = 0; i < EyeBrowMorphs.Count; i++)
{
if(EyeBrowMorphs[i].LastWeight!= EyeBrowMorphs[i].Weight)
{
ChangeMorph();
changed = true;
EyeBrowMorphs[i].LastWeight = EyeBrowMorphs[i].Weight;
}
}
@@ -81,7 +83,7 @@ namespace Gallop
{
if (EyeMorphs[i].LastWeight != EyeMorphs[i].Weight)
{
ChangeMorph();
changed = true;
EyeMorphs[i].LastWeight = EyeMorphs[i].Weight;
}
}
@@ -89,10 +91,12 @@ namespace Gallop
{
if (MouthMorphs[i].LastWeight != MouthMorphs[i].Weight)
{
ChangeMorph();
changed = true;
MouthMorphs[i].LastWeight = MouthMorphs[i].Weight;
}
}
if (changed)ChangeMorph();
}
public void ChangeMorph()
@@ -105,17 +109,13 @@ namespace Gallop
var bone = Objs.Find(ani => ani.name.Equals(trs._path));
if (bone)
{
if (trs.IsOverrideTarget==1)
if (!trs.IsOverrideTarget)
{
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;
var tmp = bone.localRotation.eulerAngles;
tmp += (trs._rotation * morph.Weight);
bone.localRotation = Quaternion.Euler(bone.localRotation.eulerAngles + (trs._rotation * morph.Weight));
bone.localPosition += trs._position * morph.Weight;
bone.localScale += trs._scale * morph.Weight;
}
};
}
@@ -128,13 +128,7 @@ namespace Gallop
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
if (!trs.IsOverrideTarget)
{
bone.localRotation = Quaternion.Euler(bone.localRotation.eulerAngles + (trs._rotation * morph.Weight));
bone.localPosition += trs._position * morph.Weight;
@@ -151,13 +145,7 @@ namespace Gallop
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
if (!trs.IsOverrideTarget)
{
bone.localRotation = Quaternion.Euler(bone.localRotation.eulerAngles + (trs._rotation * morph.Weight));
bone.localPosition += trs._position * morph.Weight;
@@ -166,6 +154,58 @@ namespace Gallop
};
}
}
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)
{
bone.localRotation = Quaternion.Euler(Vector3.Lerp(bone.localRotation.eulerAngles, trs._rotation, morph.Weight));
bone.localPosition = Vector3.Lerp(bone.localPosition, trs._position, morph.Weight);
bone.localScale = Vector3.Lerp(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)
{
bone.localRotation = Quaternion.Euler(Vector3.Lerp(bone.localRotation.eulerAngles, trs._rotation, morph.Weight));
bone.localPosition = Vector3.Lerp(bone.localPosition, trs._position, morph.Weight);
bone.localScale = Vector3.Lerp(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)
{
bone.localRotation = Quaternion.Euler(Vector3.Lerp(bone.localRotation.eulerAngles, trs._rotation, morph.Weight));
bone.localPosition = Vector3.Lerp(bone.localPosition, trs._position, morph.Weight);
bone.localScale = Vector3.Lerp(bone.localScale, trs._scale, morph.Weight);
}
};
}
}
}
public void FacialReset()