MRTK-HandConstraint

作者:追风剑情 发布于:2023-7-6 11:06 分类:Unity3d

将要显示的内容约束在手部指定区域(安全区)。

using Microsoft.MixedReality.Toolkit.Input;
using System.Collections;
using UnityEngine;
using UnityEngine.Events;

namespace Microsoft.MixedReality.Toolkit.Utilities.Solvers
{
    /// <summary>
    /// 提供一个解算器,该解算器将目标约束到对手动约束交互式内容安全的区域。
    /// </summary>
    [RequireComponent(typeof(HandBounds))]
    [AddComponentMenu("Scripts/MRTK/SDK/HandConstraint")]
    public class HandConstraint : Solver
    {
        /// <summary>
        /// 安全区域
        /// </summary>
        public enum SolverSafeZone
        {
            /// <summary>
            /// 尺骨侧
            /// </summary>
            UlnarSide = 0,
            /// <summary>
            /// 桡骨侧
            /// </summary>
            RadialSide = 1,
            /// <summary>
            /// 在最长的指尖上方
            /// </summary>
            AboveFingerTips = 2,
            /// <summary>
            /// 手腕以下
            /// </summary>
            BelowWrist = 3,
            /// <summary>
            /// 手撑上方
            /// </summary>
            AtopPalm = 4
        }

        [Header("Hand Constraint")]
        [SerializeField]
        [Tooltip("解算器需要跟踪手的哪个部位")]
        private SolverSafeZone safeZone = SolverSafeZone.UlnarSide;

        [SerializeField]
        [Tooltip("被追踪手的包围盒扩展值")]
        private float safeZoneBuffer = 0.15f;

        [SerializeField]
        [Tooltip("当两只手的包围盒相交时,是否继续计算被跟踪目标的位置(GoalPosition)与旋转值(GoalRotation)")]
        private bool updateWhenOppositeHandNear = false;

        [SerializeField]
        [Tooltip("当某只手被解算器跟踪时,是否应该禁用该只手上的光标?")]
        private bool hideHandCursorsOnActivate = true;

        [SerializeField]
        [Tooltip("指定在跟踪手时解算器应如何旋转")]
        private SolverRotationBehavior rotationBehavior = SolverRotationBehavior.LookAtMainCamera;

        [SerializeField]
        [Tooltip("指定如何计算解算器相对于手的偏移")]
        private SolverOffsetBehavior offsetBehavior = SolverOffsetBehavior.LookAtCameraRotation;

        [SerializeField]
        [Tooltip("面向用户方向的坐标偏移量,值越大离用户眼前越近。")]
        private float forwardOffset = 0;

        [SerializeField]
        [Tooltip("从规定的安全区顺时针施加额外的度数偏移。方向为左手顺时针,右手逆时针。")]
        private float safeZoneAngleOffset = 0;
    }
}

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号