/// <summary> /// Applies finger/joint rotations to the hand model /// </summary> void UpdateFingers(CyberGloveHand hand) { if (hand.m_hand == CyberGloveHandedness.RIGHT) { for (int finger = 0; finger < 5; finger++) { for (int joint = 0; joint < 3; joint++) { float thumbangle = 0; //adjustment for thumb model if (finger == 0) { thumbangle = 20; } RH_FingerJointGameObject[finger, joint].transform.rotation = (hand.transform.rotation) * hand.m_glove.m_fingerJointRot_quat[finger, joint] * Quaternion.Euler(0, 0, thumbangle) * RH_FingerJointInitial[finger, joint]; } } } //else if (hand.m_hand == CyberGloveHandedness.LEFT) //{ // for (int finger =0; finger<5; finger++) // { // for (int joint=0; joint<3; joint++) // { // float thumbangle=0; //adjustment for thumb model // if(finger==0){thumbangle = 0;} // LH_FingerJointGameObject[finger,joint].transform.rotation = (hand.transform.rotation)*hand.m_glove.m_fingerJointRot_quat[finger,joint]*Quaternion.Euler(0,0,thumbangle)*LH_FingerJointInitial[finger,joint]; // } // } //} }
/// <summary> /// Applies palm translation and rotation to the hand model /// </summary> void UpdateHand(CyberGloveHand hand) { bool bControllerActive = IsGloveActive(hand.m_glove); if (bControllerActive) { //float moveHorizontal = 0.0f; //float moveVertical = 0.0f; //float moveHeight = 0.0f; //Vector3 handposition; //Quaternion handrotation; //if(!gameController.IsG4Active()) //{ // moveHorizontal = Input.GetAxis ("Horizontal"); // moveVertical = Input.GetAxis("Vertical"); // if (Input.GetKey (KeyCode.Space)) // { // moveHeight = hand.transform.localPosition.z+0.2f; // } // else // { // moveHeight = hand.transform.localPosition.z-0.2f; // } // Vector3 movement = new Vector3 (moveHorizontal, moveVertical, 0.0f); // handposition = hand.transform.localPosition + 10*movement*WorkspaceFactor*Time.deltaTime; // hand.transform.localPosition = new Vector3 // (Mathf.Clamp (handposition.x, -22.0f, 22.0f), // Mathf.Clamp (handposition.y, 23.0f, 27.0f), // Mathf.Clamp (moveHeight, hand.CenterPosition.z, hand.CenterPosition.z+2.0f)); // handrotation = hand.m_glove.Rotation; // handrotation.eulerAngles = new Vector3(-handrotation.eulerAngles.x,handrotation.eulerAngles.y,-handrotation.eulerAngles.z); // hand.transform.rotation = handrotation * Quaternion.Euler(180,180,0)*hand.InitialRotation; //} //else if(gameController.IsG4Active()) //{ // // IF POLHEMUS G4 IS TO BE USED // Vector3 movement = new Vector3 (hand.m_glove.Position.x, -hand.m_glove.Position.y, hand.m_glove.Position.z); // //handposition = hand.InitialPosition+ WorkspaceFactor*movement; // handposition = hand.HandStartCenterPosition + G4WorkspaceFactor*movement; // hand.transform.localPosition = new Vector3 // (Mathf.Clamp (handposition.x, -22.0f, 22.0f), // Mathf.Clamp (handposition.y, 15.0f, 29.0f), // Mathf.Clamp (handposition.z, -12.0f, -2.0f)); // // // hand.transform.rotation = hand.m_glove.Rotation * Quaternion.Euler(180,0,0)*hand.InitialRotation; //} UpdateFingers(hand); } else { // use the inital position and orientation because the controller is not active hand.transform.position = hand.InitialPosition; hand.transform.rotation = hand.InitialRotation; } }