Example #1
0
 private void AddButtonControlForOneFinger(HandModelCalibrationProfile handProfile, string label,
                                           HandProfileMethodForOneFinger handProfileMethodForOneFinger)
 {
     EditorGUI.BeginChangeCheck();
     if (GUILayout.Button(label))
     {
         if (EditorGUI.EndChangeCheck())
         {
             if (handProfile.Hand == null)
             {
                 Debug.LogError("Hand transform cannot be null.");
                 throw new NullReferenceException("shit!");
             }
             else
             {
                 Transform[]          handAndFingers = handProfile.Hand.GetComponentsInChildren <Transform>();
                 int                  n    = handAndFingers.Length;
                 UnityEngine.Object[] objs = new UnityEngine.Object[n];
                 for (int i = 0; i < n; i++)
                 {
                     objs[i] = handAndFingers[i];
                 }
                 Undo.RecordObjects(objs, "Changed finger transform.");
                 handProfileMethodForOneFinger(handProfile.Hand, _fingerTypeSelected);
             }
         }
     }
 }
Example #2
0
    void OnEnable()
    {
        HandModelCalibrationProfile handProfile = serializedObject.targetObject as HandModelCalibrationProfile;

        foreach (FingerModelCalibrationProfile fingerProfile in handProfile.Fingers)
        {
            fingerProfile.Init();
        }
    }
Example #3
0
        /// <summary>
        /// Initialize hand controller pairs corresponding to each of the hand model pairs
        /// configured in _handPool.HandPairs list. If any of the hand model in
        /// _handPool.HandPairs is not configured properly, its corresponding hand controller
        /// will be null and will not be updated afterwards.
        /// </summary>
        private void InitHandControllers()
        {
            _handModelCalibProfileManager = CalibrationProfileManager.Instance;
            _handControllerPairs          = new List <LeftRightPair <UnityHandController> >();
            _handControllers = new List <UnityHandController>();
            int n = _handPool.HandPairs.Count;
            int vrControllerPairNum = _vrControllerObjReferencePairs.Count;

            for (int i = 0; i < n; i++)
            {
                UnityHandRepresentation leftRep = _handPool.HandPairs[i].Left;
                UnityHandController     left    = null;
                if (leftRep.Initialized)
                {
                    HandModelCalibrationProfile profile =
                        _handModelCalibProfileManager.FindProfile(
                            leftRep.GraphicsHandModel.Hand);
                    left = new UnityHandController(false, leftRep, this);
                    GameObject vrControllerObj = i < vrControllerPairNum ?
                                                 _vrControllerObjReferencePairs[i].Left : null;

                    Debug.Log(leftRep.GraphicsHandModel.Hand + "+++++++++++++++");
                    Debug.Log(profile);
                    Debug.Log("_handModelCalibProfileManager" + _handModelCalibProfileManager);
                    //Debug.Log(vrControllerObj);
                    //Debug.Log(rightRep.BendInwardLocalDirection);

                    left.StartInit(profile, vrControllerObj,
                                   leftRep.BendInwardLocalDirection);
                    _handControllers.Add(left);
                }
                UnityHandRepresentation rightRep = _handPool.HandPairs[i].Right;
                UnityHandController     right    = null;
                if (rightRep.Initialized)
                {
                    HandModelCalibrationProfile profile =
                        _handModelCalibProfileManager.FindProfile(
                            rightRep.GraphicsHandModel.Hand);
                    right = new UnityHandController(true, rightRep, this);
                    GameObject vrControllerObj = i < vrControllerPairNum ?
                                                 _vrControllerObjReferencePairs[i].Right : null;

                    right.StartInit(profile, vrControllerObj,
                                    rightRep.BendInwardLocalDirection);
                    _handControllers.Add(right);
                }
                LeftRightPair <UnityHandController> pair =
                    new LeftRightPair <UnityHandController>(left, right);
                _handControllerPairs.Add(pair);
            }
        }
Example #4
0
    private void ShowCalibrateHandOptions(HandModelCalibrationProfile handProfile)
    {
        //GUILayout.BeginHorizontal();
        AddButtonControlForAllFingers(handProfile, "Calibrate Hand Initial Config",
                                      handProfile.CalibrateHandInitialConfigRotation);

        AddButtonControlForAllFingers(handProfile, "Calibrate Hand Split Extreme",
                                      handProfile.CalibrateHandSplitExtreme);

        AddButtonControlForAllFingers(handProfile, "Calibrate Hand Bend Extreme",
                                      handProfile.CalibrateHandBendExtreme);

        AddButtonControlForAllFingers(handProfile, "Reset Hand to Initial Config",
                                      handProfile.ResetHandToInitialConfig);

        AddButtonControlForAllFingers(handProfile, "Reset Hand to Split Extreme",
                                      handProfile.ResetHandToSplitExtreme);

        AddButtonControlForAllFingers(handProfile, "Reset Hand to Bend Extreme",
                                      handProfile.ResetHandToBendExtreme);
    }
Example #5
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        DrawDefaultInspector();
        HandModelCalibrationProfile handProfile =
            (HandModelCalibrationProfile)serializedObject.targetObject;

        //_bendAxis = (BendAxis)EditorGUILayout.EnumPopup("Bend axis:", _bendAxis);
        _calibrateHandFoldout = EditorGUILayout.Foldout(_calibrateHandFoldout, "Hand Calibration");

        if (_calibrateHandFoldout)
        {
            ShowCalibrateHandOptions(handProfile);
        }

        _calibrateFingerFoldout = EditorGUILayout.Foldout(_calibrateFingerFoldout, "Finger Calibration");

        if (_calibrateFingerFoldout)
        {
            ShowCalibrateFingerOptions(handProfile);
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #6
0
    private void ShowCalibrateFingerOptions(HandModelCalibrationProfile handProfile)
    {
        _fingerTypeSelected = (FingerType)EditorGUILayout.EnumPopup("Finger Type:", _fingerTypeSelected);
        //GUILayout.BeginHorizontal();

        AddButtonControlForOneFinger(handProfile, "Calibrate Finger Initial Config",
                                     handProfile.CalibrateFingerInitialConfigRotation);

        AddButtonControlForOneFinger(handProfile, "Calibrate Finger Split Extreme",
                                     handProfile.CalibrateFingerSplitExtreme);

        AddButtonControlForOneFinger(handProfile, "Calibrate Finger Bend Extreme",
                                     handProfile.CalibrateFingerBendExtreme);

        AddButtonControlForOneFinger(handProfile, "Reset Finger To Initial Config",
                                     handProfile.ResetFingerToInitialConfig);

        AddButtonControlForOneFinger(handProfile, "Reset Finger To Split Extreme",
                                     handProfile.ResetFingerToSplitExtreme);

        AddButtonControlForOneFinger(handProfile, "Reset Finger To Bend Extreme",
                                     handProfile.ResetFingerToBendExtreme);
        //GUILayout.EndHorizontal();
    }