Reintroduced JawMovement animator parameter compatibility in OpenSeeVRMDriver.
This commit is contained in:
parent
e2d2ed700f
commit
faf653f8ad
1 changed files with 22 additions and 9 deletions
|
|
@ -216,6 +216,7 @@ public class OpenSeeVRMDriver : MonoBehaviour {
|
||||||
|
|
||||||
private OpenSeeBlendShapeProxy proxy = new OpenSeeBlendShapeProxy();
|
private OpenSeeBlendShapeProxy proxy = new OpenSeeBlendShapeProxy();
|
||||||
private Animator animator;
|
private Animator animator;
|
||||||
|
private bool haveJawParameter;
|
||||||
private Transform jawBone;
|
private Transform jawBone;
|
||||||
private Quaternion jawRotation = Quaternion.identity;
|
private Quaternion jawRotation = Quaternion.identity;
|
||||||
private HumanBodyBones[] humanBodyBones;
|
private HumanBodyBones[] humanBodyBones;
|
||||||
|
|
@ -532,17 +533,22 @@ public class OpenSeeVRMDriver : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetJaw(float v) {
|
void SetJaw(float v) {
|
||||||
if (jawBoneAnimation == null || jawBone == null)
|
if (haveJawParameter) {
|
||||||
|
animator.SetFloat("JawMovement", v);
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < humanBodyBones.Length; i++) {
|
|
||||||
if (humanBodyBoneTransforms[i] != null)
|
|
||||||
humanBodyBoneRotations[i] = humanBodyBoneTransforms[i].localRotation;
|
|
||||||
}
|
}
|
||||||
jawBoneAnimation.SampleAnimation(lastAvatar.gameObject, v / jawBoneAnimation.frameRate);
|
if (jawBoneAnimation != null && jawBone != null) {
|
||||||
jawRotation = jawBone.localRotation;
|
for (int i = 0; i < humanBodyBones.Length; i++) {
|
||||||
for (int i = 0; i < humanBodyBones.Length; i++) {
|
if (humanBodyBoneTransforms[i] != null)
|
||||||
if (humanBodyBoneTransforms[i] != null)
|
humanBodyBoneRotations[i] = humanBodyBoneTransforms[i].localRotation;
|
||||||
humanBodyBoneTransforms[i].localRotation = humanBodyBoneRotations[i];
|
}
|
||||||
|
jawBoneAnimation.SampleAnimation(lastAvatar.gameObject, v / jawBoneAnimation.frameRate);
|
||||||
|
jawRotation = jawBone.localRotation;
|
||||||
|
for (int i = 0; i < humanBodyBones.Length; i++) {
|
||||||
|
if (humanBodyBoneTransforms[i] != null)
|
||||||
|
humanBodyBoneTransforms[i].localRotation = humanBodyBoneRotations[i];
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -777,6 +783,13 @@ public class OpenSeeVRMDriver : MonoBehaviour {
|
||||||
animator = lastAvatar.gameObject.GetComponent<Animator>();
|
animator = lastAvatar.gameObject.GetComponent<Animator>();
|
||||||
|
|
||||||
if (animator != null) {
|
if (animator != null) {
|
||||||
|
haveJawParameter = false;
|
||||||
|
for (int i = 0; i < animator.parameterCount; i++) {
|
||||||
|
if (animator.parameters[i].name == "JawMovement") {
|
||||||
|
haveJawParameter = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
jawBone = animator.GetBoneTransform(HumanBodyBones.Jaw);
|
jawBone = animator.GetBoneTransform(HumanBodyBones.Jaw);
|
||||||
for (int i = 0; i < humanBodyBones.Length; i++) {
|
for (int i = 0; i < humanBodyBones.Length; i++) {
|
||||||
if (humanBodyBones[i] >= 0 && humanBodyBones[i] < HumanBodyBones.LastBone)
|
if (humanBodyBones[i] >= 0 && humanBodyBones[i] < HumanBodyBones.LastBone)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue