private void ApplyArmModel() { Quaternion controllerOrientation = GvrControllerInput.GetOrientation(SvrControllerState.GvrController); Vector3 resetarmposition = Vector3.zero; if (isLockedToHead) { resetarmposition = CalculatArmRoot(Camera.main.transform.localPosition); } else { resetarmposition = mArmRootPosition; } //Debug.Log(controllerOrientation); // Get the relative positions of the joints. Matrix4x4 tt = Matrix4x4.identity; try { tt = Matrix4x4.TRS(resetarmposition, controllerOrientation, Vector3.one); } catch (System.Exception e) { Debug.Log(e.Message); } Vector3 elbowPosition = resetarmposition + new Vector3(0.0f, addedElbowHeight, addedElbowDepth); elbowPosition = tt.MultiplyPoint(new Vector3(0, 0, ElbowToHandLength)); wristPosition = elbowPosition; wristRotation = controllerOrientation; }
/// Get the controller's orientation. protected void GetControllerRotation(out Quaternion rotation, out Quaternion xyRotation, out float xAngle) { // Find the controller's orientation relative to the player. rotation = GvrControllerInput.GetOrientation(SvrControllerState.GvrController); rotation = Quaternion.Inverse(torsoRotation) * rotation; // Extract just the x rotation angle. Vector3 controllerForward = rotation * Vector3.forward; xAngle = 90.0f - Vector3.Angle(controllerForward, Vector3.up); // Remove the z rotation from the controller. xyRotation = Quaternion.FromToRotation(Vector3.forward, controllerForward); }
void UpdatePose() { var pose = GvrControllerInput.GetPosition(deviceType); var roation = GvrControllerInput.GetOrientation(deviceType); if (!GvrHead.TrackPosition) { Vector3 headPos = GvrControllerInput.GetPosition(SvrControllerState.NoloHead); transform.localPosition = pose + new Vector3(-headPos.x, -headPos.y, -headPos.z); } else { transform.localPosition = pose; } transform.localRotation = roation; }