mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-23 19:36:18 -05:00
Merge pull request #1763 from ousttrue/fix10/aim_axis_reversex
[1.0] AimConstraint の修正
This commit is contained in:
commit
98bed36d20
|
|
@ -70,11 +70,37 @@ namespace UniVRM10
|
|||
var toVec = (Source.position - transform.position).normalized;
|
||||
var fromToQuat = Quaternion.FromToRotation(fromVec, toVec);
|
||||
|
||||
transform.rotation = Quaternion.SlerpUnclamped(
|
||||
transform.localRotation = Quaternion.SlerpUnclamped(
|
||||
_dstRestLocalQuat,
|
||||
Quaternion.Inverse(dstParentWorldQuat) * fromToQuat * dstParentWorldQuat * _dstRestLocalQuat,
|
||||
Weight
|
||||
);
|
||||
}
|
||||
|
||||
public void OnDrawGizmosSelected()
|
||||
{
|
||||
if (Source == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Gizmos.color = Color.magenta;
|
||||
Gizmos.DrawLine(transform.position, Source.position);
|
||||
Gizmos.DrawSphere(Source.position, 0.01f);
|
||||
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
var len = 0.1f;
|
||||
switch (AimAxis)
|
||||
{
|
||||
case AimAxis.PositiveX:
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawLine(Vector3.zero, Vector3.right * len);
|
||||
break;
|
||||
case AimAxis.NegativeX:
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawLine(Vector3.zero, Vector3.left * len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
namespace UniVRM10
|
||||
{
|
||||
public static class Vrm10ConstraintUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 右手系と左手系を相互に変換する
|
||||
/// </summary>
|
||||
public static UniGLTF.Extensions.VRMC_node_constraint.AimAxis ReverseX(UniGLTF.Extensions.VRMC_node_constraint.AimAxis src)
|
||||
{
|
||||
switch (src)
|
||||
{
|
||||
case UniGLTF.Extensions.VRMC_node_constraint.AimAxis.PositiveX: return UniGLTF.Extensions.VRMC_node_constraint.AimAxis.NegativeX;
|
||||
case UniGLTF.Extensions.VRMC_node_constraint.AimAxis.NegativeX: return UniGLTF.Extensions.VRMC_node_constraint.AimAxis.PositiveX;
|
||||
default: return src;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2c7b76ebe42e9543ac52153ea9f2728
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -430,7 +430,7 @@ namespace UniVRM10
|
|||
{
|
||||
Source = model.Nodes.IndexOf(converter.Nodes[aimConstraint.Source.gameObject]),
|
||||
Weight = aimConstraint.Weight,
|
||||
AimAxis = aimConstraint.AimAxis,
|
||||
AimAxis = Vrm10ConstraintUtil.ReverseX(aimConstraint.AimAxis),
|
||||
};
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ namespace UniVRM10
|
|||
var component = node.gameObject.AddComponent<Vrm10AimConstraint>();
|
||||
component.Source = Nodes[aim.Source.Value]; // required
|
||||
component.Weight = aim.Weight.GetValueOrDefault(1.0f);
|
||||
component.AimAxis = aim.AimAxis; // required
|
||||
component.AimAxis = Vrm10ConstraintUtil.ReverseX(aim.AimAxis); // required
|
||||
}
|
||||
else if (constraint.Rotation != null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user