/// <summary> /// Constructor which loads the HandModel /// </summary> void Start() { // Ensure the library initialized correctly. Manus.ManusInit(); // Initialize the glove and the associated skeletal model. glove = new Glove(hand); // Re-center the glove for the start position. // FIXME: This works well for monitor demos, but for VR you should use a different // centering mechanism. glove.Recenter(); if (hand == GLOVE_HAND.GLOVE_LEFT) { modelObject = Resources.Load<GameObject>("Manus_Handv2_Left"); animationClip = Resources.Load<AnimationClip>("Manus_Handv2_Left"); } else { modelObject = Resources.Load<GameObject>("Manus_Handv2_Right"); animationClip = Resources.Load<AnimationClip>("Manus_Handv2_Right"); } // Associate the game transforms with the skeletal model. gameTransforms = new Transform[5][]; modelTransforms = new Transform[5][]; for (int i = 0; i < 5; i++) { gameTransforms[i] = new Transform[4]; modelTransforms[i] = new Transform[4]; for (int j = 0; j < 4; j++) { gameTransforms[i][j] = FindDeepChild(RootTransform, "Finger_" + i.ToString() + j.ToString()); modelTransforms[i][j] = FindDeepChild(modelObject.transform, "Finger_" + i.ToString() + j.ToString()); } } modelObject.SetActive(true); }
bool HandIsClosed() { // get the glove information from the predefined hand controller ManusMachina.Glove tGlove = gHandController.getGlove(); if (tGlove != null) { const float tTreshold = 0.5f; /* GRABBING */ // amount of fingers to check for grabbing int tFingers = 1; // check if at least <tFingers> fingers (NOT THUMB) are beyond a threshold ( "grabbing" gesture ) for (int i = 1; i < 5; i++) { if (tGlove.Fingers[i] > tTreshold) { tFingers--; } } // if the grabbing gesture is true pickup the closest if not null if (tFingers <= 0) { return(true); } /* THUMB + FINGER PINCHING */ /*bool tFingerBend = false; * // check if one of the fingers (not thumb) is beyond threshold * for (int i = 1; i < 5; i++) * { * if (tGlove.Fingers[i] > tTreshold - 0.2) * { * tFingerBend = true; * } * } * if (tGlove.Fingers[0] > tTreshold && tFingerBend) * { * /return true; * }*/ } return(false); }
void Start() { Manus.ManusInit(); glove = new Glove(hand); }