public static void LinkHandPointReprs(HandSearchEngine source, BodyModel body, bool includeWrist, bool requiresCorrected) { HandModel hand; if (source.side == Helpers.Side.Left) { hand = body.leftHand; } else { hand = body.rightHand; } // Prevent invalid model string msg = GetErrorMsg(hand); if (msg != "") { Debug.LogError(msg); return; } if (requiresCorrected && !source.hand.wristPoint.corrected) { Debug.LogError("Wrist has no corrected representation. Probably rotations have not been corrected yet (use RotationWizard)"); return; } // Detect inconsistencies model-representation if ((!source.hand.thumb0Point.tsf && hand.thumb.threeUnderLast) || (source.hand.thumb0Point.tsf && !hand.thumb.threeUnderLast)) { Debug.LogError("Thumb0 is not present in both model and correct representation. Representation? " + (source.hand.thumb0Point.tsf != null) + ". Model? " + (hand.thumb.threeUnderLast != null)); return; } if ((!source.hand.pinky0Point.tsf && hand.pinky.threeUnderLast) || (source.hand.pinky0Point.tsf && !hand.pinky.threeUnderLast)) { Debug.LogError("Pinky0 is not present in both model and correct representation. Representation?" + (source.hand.pinky0Point.tsf != null) + ". Model? " + (hand.pinky.threeUnderLast != null)); return; } // Wrist if (includeWrist) { LinkPointRepr(source.hand.wristPoint, hand.wrist.point, requiresCorrected); } // Thumb if (source.hand.thumb0Point.original) { LinkPointRepr(source.hand.thumb0Point, hand.thumb.threeUnderLast.point, requiresCorrected); } LinkPointRepr(source.hand.thumb1Point, hand.thumb.twoUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.thumb2Point, hand.thumb.oneUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.thumb3Point, hand.thumb.last.point, requiresCorrected); LinkPointRepr(source.hand.thumbTipPoint, hand.thumb.tip, requiresCorrected); // Index LinkPointRepr(source.hand.index1Point, hand.index.twoUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.index2Point, hand.index.oneUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.index3Point, hand.index.last.point, requiresCorrected); LinkPointRepr(source.hand.indexTipPoint, hand.index.tip, requiresCorrected); // Middle LinkPointRepr(source.hand.middle1Point, hand.middle.twoUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.middle2Point, hand.middle.oneUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.middle3Point, hand.middle.last.point, requiresCorrected); LinkPointRepr(source.hand.middleTipPoint, hand.middle.tip, requiresCorrected); // Ring LinkPointRepr(source.hand.ring1Point, hand.ring.twoUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.ring2Point, hand.ring.oneUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.ring3Point, hand.ring.last.point, requiresCorrected); LinkPointRepr(source.hand.ringTipPoint, hand.ring.tip, requiresCorrected); // Pinky if (source.hand.pinky0Point.original) { LinkPointRepr(source.hand.pinky0Point, hand.pinky.threeUnderLast.point, requiresCorrected); } LinkPointRepr(source.hand.pinky1Point, hand.pinky.twoUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.pinky2Point, hand.pinky.oneUnderLast.point, requiresCorrected); LinkPointRepr(source.hand.pinky3Point, hand.pinky.last.point, requiresCorrected); LinkPointRepr(source.hand.pinkyTipPoint, hand.pinky.tip, requiresCorrected); // Specials LinkPointRepr(source.specialPoints.palmCenterPoint, hand.palmCenter, false); LinkPointRepr(source.specialPoints.palmNormalPoint, hand.palmNormal, false); LinkPointRepr(source.specialPoints.palmInteriorPoint, hand.palmInterior, false); LinkPointRepr(source.specialPoints.palmExteriorPoint, hand.palmExterior, false); LinkPointRepr(source.specialPoints.pinchCenterPoint, hand.pinchCenter, false); LinkPointRepr(source.specialPoints.throatCenterPoint, hand.throatCenter, false); LinkPointRepr(source.specialPoints.rayPoint, hand.ray, false); }
public override void OnInspectorGUI() { // base.OnInspectorGUI(); // DrawDefaultInspector(); HandSearchEngine myScript = (HandSearchEngine)target; GUILayout.Label("Side", EditorStyles.boldLabel); myScript.side = (Side)EditorGUILayout.EnumPopup(myScript.side); GUILayout.Label("Hand bones", EditorStyles.boldLabel); OriginalField(myScript.hand.wristPoint, "Wrist"); OriginalField(myScript.hand.thumb0Point, "Thumb 0"); OriginalField(myScript.hand.thumb1Point, "Thumb 1"); OriginalField(myScript.hand.thumb2Point, "Thumb 2"); OriginalField(myScript.hand.thumb3Point, "Thumb 3"); OriginalField(myScript.hand.thumbTipPoint, "Thumb Tip"); OriginalField(myScript.hand.index1Point, "Index 1"); OriginalField(myScript.hand.index2Point, "Index 2"); OriginalField(myScript.hand.index3Point, "Index 3"); OriginalField(myScript.hand.indexTipPoint, "Index Tip"); OriginalField(myScript.hand.middle1Point, "Middle 1"); OriginalField(myScript.hand.middle2Point, "Middle 2"); OriginalField(myScript.hand.middle3Point, "Middle 3"); OriginalField(myScript.hand.middleTipPoint, "Middle Tip"); OriginalField(myScript.hand.ring1Point, "Ring 1"); OriginalField(myScript.hand.ring2Point, "Ring 2"); OriginalField(myScript.hand.ring3Point, "Ring 3"); OriginalField(myScript.hand.ringTipPoint, "Ring Tip"); OriginalField(myScript.hand.pinky0Point, "Pinky 0"); OriginalField(myScript.hand.pinky1Point, "Pinky 1"); OriginalField(myScript.hand.pinky2Point, "Pinky 2"); OriginalField(myScript.hand.pinky3Point, "Pinky 3"); OriginalField(myScript.hand.pinkyTipPoint, "Pinky Tip"); GUILayout.Label("Hand special points", EditorStyles.boldLabel); OriginalField(myScript.specialPoints.palmCenterPoint, "Palm Center"); OriginalField(myScript.specialPoints.palmNormalPoint, "Palm Normal"); OriginalField(myScript.specialPoints.palmExteriorPoint, "Palm Exterior"); OriginalField(myScript.specialPoints.palmInteriorPoint, "Palm Interior"); OriginalField(myScript.specialPoints.pinchCenterPoint, "Pinch Center"); OriginalField(myScript.specialPoints.throatCenterPoint, "Throat Center"); OriginalField(myScript.specialPoints.rayPoint, "Ray"); myScript.AutoFill(); EditorGUILayout.PropertyField(szdBones); GUILayout.Label("Debug", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Show Gizmos"); myScript.showGizmos = EditorGUILayout.Toggle(myScript.showGizmos); EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(szdHand); EditorGUILayout.PropertyField(szdSpecialPoints); GUI.enabled = myScript.canSearch; if (GUILayout.Button("SEARCH BONES")) { myScript.Search(); } GUI.enabled = true; Repaint(); }