/// <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); } }
/// <summary> /// GetJointBendAngle /// </summary> /// <param name="finger">0~4 Thumb~Pinky </param> /// <param name="joint"> 0~2(MCP、PIP and DIP)</param> /// <returns></returns> private float GetJointBendAngle(UnityHandController hand, UnityHandRepresentation rep, int finger, int joint) { if (isReady) { var value = hand.GetCurrentFingerRotationInfo().Fingers[finger].Bend.Value; var handProfile = profileMgr.FindProfile(rep.GraphicsHandModel.Hand); if (handProfile != null) { var angle = handProfile.Fingers[finger].Joints[joint].BendAngleExtreme * value; return(angle); } } return(0); }