Пример #1
0
        /// <summary>
        /// Updates the pose of the root of the hand
        /// using the visual provided values. Sometimes this
        /// might require lerping between the tracked pose
        /// and the provided one to improve the movement of the hand
        /// without worrying about when the overwrite value was written.
        ///
        /// During this update, the modifier also ensures the unlocking
        /// animations are executed.
        /// </summary>
        /// <param name="root">The tracked root value to modify</param>
        private void UpdateRootPose(ref Pose root)
        {
            float   smoothPositionFactor = _wristPositionLocked ? _wristPositionLockCurve.Progress() : _wristPositionUnlockCurve.Progress();
            Vector3 position             = Vector3.Lerp(root.position, _desiredWristPose.position, _wristPositionOverrideFactor);

            root.position = Vector3.Lerp(_constrainedWristPose.position, position, smoothPositionFactor);

            float      smoothRotationFactor = _wristRotationLocked ? _wristRotationLockCurve.Progress() : _wristRotationUnlockCurve.Progress();
            Quaternion rotation             = Quaternion.Lerp(root.rotation, _desiredWristPose.rotation, _wristRotationOverrideFactor);

            root.rotation = Quaternion.Lerp(_constrainedWristPose.rotation, rotation, smoothRotationFactor);

            _lastWristPose.CopyFrom(root);
        }
Пример #2
0
        private void UpdateWristJoint(HandJointId jointid, ref Pose pose)
        {
            int jointIndex = (int)jointid;

            if ((_dirtyWristJoints & (1 << jointIndex)) != 0)// its dirty
            {
                if (jointid > HandJointId.HandWristRoot)
                {
                    UpdateWristJoint((HandJointId)_originalJoints[jointIndex].parent, ref pose);
                    PoseUtils.Multiply(pose, _localPoses[jointIndex], ref _posesFromWrist[jointIndex]);
                }
                _dirtyWristJoints = _dirtyWristJoints & ~(1 << jointIndex); //set clean
            }
            pose.CopyFrom(_posesFromWrist[jointIndex]);
        }
Пример #3
0
        protected override void Apply(HandDataAsset data)
        {
            if (!data.IsDataValid || !data.IsTracked || !data.IsHighConfidence)
            {
                data.IsConnected    = false;
                data.RootPoseOrigin = PoseOrigin.None;
                _hasConnectedData   = false;
                return;
            }

            UpdateRequired.Invoke();
            _lastStates.CopyFrom(data);

            if (!_hasConnectedData)
            {
                _constrainedWristPose.CopyFrom(data.Root);
                _hasConnectedData = true;
            }

            UpdateJointsRotation(data);
            UpdateRootPose(ref data.Root);

            data.RootPoseOrigin = PoseOrigin.SyntheticPose;
        }