public void Apply(LookAtEyeDirection eyeDirection, Dictionary <ExpressionKey, float> actualWeights) { var yaw = eyeDirection.LeftYaw; var pitch = eyeDirection.LeftPitch; if (yaw < 0) { // Left actualWeights[_lookRightKey] = 0; actualWeights[_lookLeftKey] = Mathf.Clamp(_horizontalOuter.Map(Mathf.Abs(yaw)), 0, 1.0f); } else { // Right actualWeights[_lookRightKey] = Mathf.Clamp(_horizontalOuter.Map(Mathf.Abs(yaw)), 0, 1.0f); actualWeights[_lookLeftKey] = 0; } if (pitch < 0) { // Down actualWeights[_lookUpKey] = 0; actualWeights[_lookDownKey] = Mathf.Clamp(_verticalDown.Map(Mathf.Abs(pitch)), 0, 1.0f); } else { // Up actualWeights[_lookUpKey] = Mathf.Clamp(_verticalUp.Map(Mathf.Abs(pitch)), 0, 1.0f); actualWeights[_lookDownKey] = 0; } }
void ILookAtApplier.ApplyRotations(VRMBlendShapeProxy proxy, float yaw, float pitch) { #pragma warning disable 0618 if (yaw < 0) { // Left proxy.SetValue(VrmLib.BlendShapePreset.LookRight, 0); // clear first proxy.SetValue(VrmLib.BlendShapePreset.LookLeft, Mathf.Clamp(HorizontalOuter.Map(-yaw), 0, 1.0f)); } else { // Right proxy.SetValue(VrmLib.BlendShapePreset.LookLeft, 0); // clear first proxy.SetValue(VrmLib.BlendShapePreset.LookRight, Mathf.Clamp(HorizontalOuter.Map(yaw), 0, 1.0f)); } if (pitch < 0) { // Down proxy.SetValue(VrmLib.BlendShapePreset.LookUp, 0); // clear first proxy.SetValue(VrmLib.BlendShapePreset.LookDown, Mathf.Clamp(VerticalDown.Map(-pitch), 0, 1.0f)); } else { // Up proxy.SetValue(VrmLib.BlendShapePreset.LookDown, 0); // clear first proxy.SetValue(VrmLib.BlendShapePreset.LookUp, Mathf.Clamp(VerticalUp.Map(pitch), 0, 1.0f)); } #pragma warning restore 0618 }
/// <summary> /// LeftEyeボーンとRightEyeボーンに回転を適用する /// </summary> public void Apply(LookAtEyeDirection eyeDirection, Dictionary <ExpressionKey, float> actualWeights) { // FIXME var yaw = eyeDirection.LeftYaw; var pitch = eyeDirection.LeftPitch; // horizontal float leftYaw, rightYaw; if (yaw < 0) { leftYaw = -_horizontalOuter.Map(-yaw); rightYaw = -_horizontalInner.Map(-yaw); } else { rightYaw = _horizontalOuter.Map(yaw); leftYaw = _horizontalInner.Map(yaw); } // vertical if (pitch < 0) { pitch = -_verticalDown.Map(-pitch); } else { pitch = _verticalUp.Map(pitch); } // Apply SetYawPitchToBones(new LookAtEyeDirection(leftYaw, pitch, rightYaw, pitch)); }
void ILookAtApplier.ApplyRotations(VRMBlendShapeProxy proxy, float yaw, float pitch) { // horizontal float leftYaw, rightYaw; if (yaw < 0) { leftYaw = -HorizontalOuter.Map(-yaw); rightYaw = -HorizontalInner.Map(-yaw); } else { rightYaw = HorizontalOuter.Map(yaw); leftYaw = HorizontalInner.Map(yaw); } // vertical if (pitch < 0) { pitch = -VerticalDown.Map(-pitch); } else { pitch = VerticalUp.Map(pitch); } // Apply if (LeftEye.Transform != null && RightEye.Transform != null) { // 目に値を適用する LeftEye.Transform.rotation = LeftEye.InitialWorldMatrix.ExtractRotation() * Matrix4x4.identity.YawPitchRotation(leftYaw, pitch); RightEye.Transform.rotation = RightEye.InitialWorldMatrix.ExtractRotation() * Matrix4x4.identity.YawPitchRotation(rightYaw, pitch); } }
void ApplyRotations(float yaw, float pitch) { // horizontal float leftYaw, rightYaw; if (yaw < 0) { leftYaw = -HorizontalOuter.Map(-yaw); rightYaw = -HorizontalInner.Map(-yaw); } else { rightYaw = HorizontalOuter.Map(yaw); leftYaw = HorizontalInner.Map(yaw); } // vertical if (pitch < 0) { pitch = -VerticalDown.Map(-pitch); } else { pitch = VerticalUp.Map(pitch); } // Apply if (LeftEye.Transform != null && RightEye.Transform != null) { // 目に値を適用する LeftEye.Transform.rotation = LeftEye.InitialWorldMatrix.ExtractRotation() * Head.OffsetRotation.YawPitchRotation(leftYaw, pitch); RightEye.Transform.rotation = RightEye.InitialWorldMatrix.ExtractRotation() * Head.OffsetRotation.YawPitchRotation(rightYaw, pitch); } else if (Head.Transform != null) { // 頭に値を適用する Head.Transform.rotation = Head.InitialWorldMatrix.ExtractRotation() * Head.OffsetRotation.YawPitchRotation(yaw, pitch); } }