protected virtual void FindFingers(ManusRigger rigger) { string[] fingers = { "thumb_0", "index_0", "middle_0", "ring_0", "pinky_0" }; // Associate the game transforms with the skeletal model. FingerTransforms = new Transform[5][]; for (var i = 0; i < 5; i++) { FingerTransforms[i] = new Transform[5]; for (var j = 1; j < 4; j++) { //Get the cached transform from the manus rigger. if (rigger) { FingerTransforms[i][j] = rigger.GetFingerTransform(DeviceType, (ApolloHandData.FingerName)i, (PhalangeType)j); } //Manually find the transform if rigger is null or the transform is still not assigned/ if (!FingerTransforms[i][j]) { var postfix = DeviceType == device_type_t.GLOVE_LEFT ? "_l" : "_r"; var finger = fingers[i] + j + postfix; FingerTransforms[i][j] = transform.FindDeepChild(finger); } } } }
public void Initialize(ManusRigger rigger) { this.rigger = rigger; ReturnValue checkIfLeftResult = CheckIfLeftHand(out var isLeft); if (checkIfLeftResult == ReturnValue.Success && isLeft) { preRotWrist = new Vector3(180.0f, 0.0f, 0.0f); preRotThumb = new Vector3(-90f, -60f, 0.0f); } else { preRotWrist = new Vector3(0.0f, 0.0f, 0.0f); preRotThumb = new Vector3(-90f, -60f, 0.0f); } FindWrist(rigger); FindFingers(rigger); Wrist = AddWristComponent(); foreach (ApolloHandData.FingerName finger in Enum.GetValues(typeof(ApolloHandData.FingerName))) { FingerControllers.Add(finger, CreateFinger(finger)); } if (checkIfLeftResult != ReturnValue.Success) { return; } }
protected virtual void FindWrist(ManusRigger rigger) { // Get the cached transform from the manus rigger. if (rigger) { _wristTransform = rigger.GetWristTransform(DeviceType); } if (_wristTransform == null) { // Get the transform manually if the rigger wasn't assigned or the WristTransform was not found. if (_wristTransform || CheckIfLeftHand(out bool isLeft) != ReturnValue.Success) { return; } Log("Looking for the wrist transform (starting at " + transform.name + ")."); string wristName = isLeft ? "hand_l" : "hand_r"; _wristTransform = transform.name == wristName ? transform : transform.FindDeepChild(wristName); if (_wristTransform == null) { Debug.LogError("Attempted to add a wrist controller for the hand with laterality " + DeviceType + ", but a wrist transform with the name " + wristName + " could not be found."); return; } } Log("Found the wrist transform."); }