public virtual void UpdateAutoPose(bool lerp) { collisionPose = GetAutoPose(); // Lerp to collision hand pose if (collisionPose != null) { InspectedPose.UpdateHandPose(collisionPose, lerp); } }
public virtual void UpdateHandPose(HandPoseDefinition pose, bool lerp) { UpdateJoint(pose.WristJoint, WristJoint, lerp); UpdateJoints(pose.ThumbJoints, ThumbJoints, lerp); UpdateJoints(pose.IndexJoints, IndexJoints, lerp); UpdateJoints(pose.MiddleJoints, MiddleJoints, lerp); UpdateJoints(pose.RingJoints, RingJoints, lerp); UpdateJoints(pose.PinkyJoints, PinkyJoints, lerp); UpdateJoints(pose.OtherJoints, OtherJoints, lerp); }
public HandPoseDefinition CopyHandDefinition(HandPoseDefinition ToCopy) { return(new HandPoseDefinition() { IndexJoints = GetJointsCopy(ToCopy.IndexJoints), MiddleJoints = GetJointsCopy(ToCopy.MiddleJoints), OtherJoints = GetJointsCopy(ToCopy.OtherJoints), PinkyJoints = GetJointsCopy(ToCopy.PinkyJoints), RingJoints = GetJointsCopy(ToCopy.RingJoints), ThumbJoints = GetJointsCopy(ToCopy.ThumbJoints), WristJoint = GetJointCopy(ToCopy.WristJoint), }); }
// Update is called once per frame void Update() { // Auto Update Auto Pose if (UpdateContinuously) { bool useIdlePose = CollisionDetected == false && IdleHandPose != null && InspectedPose != null; if (useIdlePose) { collisionPose = GetAutoPose(); InspectedPose.UpdateHandPose(IdleHandPose.Joints, true); } else { UpdateAutoPose(true); } } }
public HandPoseDefinition GetAutoPose() { if (InspectedPose == null || OpenHandPose == null || ClosedHandPose == null) { return(null); } // Store our current hand state so we can snap back to it after we determine a collision currentPose = CopyHandDefinition(InspectedPose.GetHandPoseDefinition()); // Start in open pose before InspectedPose.UpdateHandPose(OpenHandPose.Joints, false); // Lerp between Open and Closed hand position, stopping if we hit something _count = 0; _thumbHit = false; _indexHit = false; _middleHit = false; _ringHit = false; _pinkyHit = false; while (_count < 300) { // Check Tip Collision if (!_thumbHit) { _thumbHit = GetThumbHit(InspectedPose); } if (!_indexHit) { _indexHit = GetIndexHit(InspectedPose); } if (!_middleHit) { _middleHit = GetMiddleHit(InspectedPose); } if (!_ringHit) { _ringHit = GetRingHit(InspectedPose); } if (!_pinkyHit) { _pinkyHit = GetPinkyHit(InspectedPose); } // Can bail if everything is touching if (_thumbHit && _indexHit && _middleHit && _ringHit && _pinkyHit) { break; } _count++; } // Store the collision pose so we can return it after we've reset out hand back to it's original position tempPose = CopyHandDefinition(InspectedPose.GetHandPoseDefinition()); // Switch back to the original hand pose we were in InspectedPose.UpdateHandPose(currentPose, false); return(tempPose); }