public static void StartRotation(Animatable obj) { _StartTransforming(obj); if (!KeepOldRotationAxis) { rotationAxis = ( Globals.POINTING_FINGER_COORDINATES.x * poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Fingers) + Globals.POINTING_FINGER_COORDINATES.y * poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Thumb) + Globals.POINTING_FINGER_COORDINATES.z * poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Palm) ).normalized; } var handPos = poseManager.GetHandTransform(OvrAvatar.HandType.Left, PoseManager.HandJoint.IndexTip).position; handPos -= initialObjectPose.transform.position; initialHandDirection = (handPos - rotationAxis * Vector3.Dot(handPos, rotationAxis)).normalized; StackRotation(controlledObject.RotationKeys, controlledObject, 0); }
static void ProcessRotationGesture() { var index = poseManager.GetHandTransform(OvrAvatar.HandType.Right, PoseManager.HandJoint.IndexTip); var pos = index.position; var dir = ( Globals.POINTING_FINGER_COORDINATES.x * poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Fingers) + Globals.POINTING_FINGER_COORDINATES.y * poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Thumb) + Globals.POINTING_FINGER_COORDINATES.z * poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Palm) ).normalized; var selected = GetSmallest(rightInteracting); if (selected != null) { Debug.Log("Rotation " + selected.name); TimeManager.StartRotation(selected); } }
// Update is called once per frame void Update() { OVRInput.Update(); leftTouchActive = OVRInput.IsControllerConnected(OVRInput.Controller.LTouch); rightTouchActive = OVRInput.IsControllerConnected(OVRInput.Controller.RTouch); PoseManager.HandJoint joint = PoseManager.HandJoint.Max; if (Input.GetKeyUp(KeyCode.Alpha0)) { joint = PoseManager.HandJoint.ThumbTip; } else if (Input.GetKeyUp(KeyCode.Alpha1)) { joint = PoseManager.HandJoint.IndexTip; } else if (Input.GetKeyUp(KeyCode.Alpha2)) { joint = PoseManager.HandJoint.MiddleTip; } else if (Input.GetKeyUp(KeyCode.Alpha3)) { joint = PoseManager.HandJoint.RingTip; } else if (Input.GetKeyUp(KeyCode.Alpha4)) { joint = PoseManager.HandJoint.PinkyTip; } else if (Input.GetKeyUp(KeyCode.Alpha5)) { var thumb = poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Thumb); var finger = poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Fingers); var palm = poseManager.GetHandFrameVector(OvrAvatar.HandType.Right, PoseManager.HandFrame.Palm); var wrist = poseManager.GetHandTransform(OvrAvatar.HandType.Right, PoseManager.HandJoint.Wrist); var indexBase = poseManager.GetHandTransform(OvrAvatar.HandType.Right, PoseManager.HandJoint.IndexBase); var indexTip = poseManager.GetHandTransform(OvrAvatar.HandType.Right, PoseManager.HandJoint.IndexTip); var indexFingerVec = wrist.InverseTransformVector(indexTip.position - indexBase.position).normalized; Debug.Log(indexFingerVec.ToString("F4")); } else if (Input.GetKeyUp(KeyCode.G)) { Debug.Log(GestureManager.RecognitionState); } if (joint < PoseManager.HandJoint.Max) { LogJointState(joint, OvrAvatar.HandType.Right); } // Ctrl-S to save current scene if (Input.GetKeyUp(KeyCode.S) #if UNITY_EDITOR ) #else && (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl))) #endif { FileIOManager.TrySaveCurrentScene(); }