static private DrawCrosshairs ( |
||
position | ||
scale | float | |
a | float | |
b | float | |
c | float | |
d | float | |
transform | ||
리턴 | void |
public static void DrawConstraints(Transform transform, Skeleton skeleton, float skeletonRenderScale = 1f) { Vector3 targetPos; Vector3 pos; bool active; Color handleColor; const float Thickness = 4f; Vector3 normal = transform.forward; // Transform Constraints handleColor = SpineHandles.TransformContraintColor; foreach (var tc in skeleton.TransformConstraints) { var targetBone = tc.Target; targetPos = targetBone.GetWorldPosition(transform, skeletonRenderScale); if (tc.TranslateMix > 0) { if (tc.TranslateMix != 1f) { Handles.color = handleColor; foreach (var b in tc.Bones) { pos = b.GetWorldPosition(transform, skeletonRenderScale); Handles.DrawDottedLine(targetPos, pos, Thickness); } } SpineHandles.DrawBoneCircle(targetPos, handleColor, normal, 1.3f * skeletonRenderScale); Handles.color = handleColor; SpineHandles.DrawCrosshairs(targetPos, 0.2f, targetBone.A, targetBone.B, targetBone.C, targetBone.D, transform, skeletonRenderScale); } } // IK Constraints handleColor = SpineHandles.IkColor; foreach (var ikc in skeleton.IkConstraints) { Bone targetBone = ikc.Target; targetPos = targetBone.GetWorldPosition(transform, skeletonRenderScale); var bones = ikc.Bones; active = ikc.Mix > 0; if (active) { pos = bones.Items[0].GetWorldPosition(transform, skeletonRenderScale); switch (bones.Count) { case 1: { Handles.color = handleColor; Handles.DrawLine(targetPos, pos); SpineHandles.DrawBoneCircle(targetPos, handleColor, normal); var m = bones.Items[0].GetMatrix4x4(); m.m03 = targetBone.WorldX * skeletonRenderScale; m.m13 = targetBone.WorldY * skeletonRenderScale; SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m); break; } case 2: { Bone childBone = bones.Items[1]; Vector3 child = childBone.GetWorldPosition(transform, skeletonRenderScale); Handles.color = handleColor; Handles.DrawLine(child, pos); Handles.DrawLine(targetPos, child); SpineHandles.DrawBoneCircle(pos, handleColor, normal, 0.5f); SpineHandles.DrawBoneCircle(child, handleColor, normal, 0.5f); SpineHandles.DrawBoneCircle(targetPos, handleColor, normal); var m = childBone.GetMatrix4x4(); m.m03 = targetBone.WorldX * skeletonRenderScale; m.m13 = targetBone.WorldY * skeletonRenderScale; SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m); break; } } } //Handles.Label(targetPos, ikc.Data.Name, SpineHandles.BoneNameStyle); } // Path Constraints handleColor = SpineHandles.PathColor; foreach (var pc in skeleton.PathConstraints) { active = pc.TranslateMix > 0; if (active) { foreach (var b in pc.Bones) { SpineHandles.DrawBoneCircle(b.GetWorldPosition(transform, skeletonRenderScale), handleColor, normal, 1f * skeletonRenderScale); } } } }