SteamVR_Skeleton_Poser的理解

官网讲解,只讲了动作输入和混合
更换拿东西的手部模型
#更换拿东西的手部模型
在这里插入图片描述
在1那里更换手的模型,也可以在2里查看该代码的实现

#多个手部姿势的调用
在拿东西的第一时刻会调用 主手部姿势,也就是有 (MAIN) 标识的
在这里插入图片描述
启用混合的代码,在上面给的链接中有,这里是直接在那截的图
在这里插入图片描述

SteamVR_Skeleton_Poser 的 Public 方法

`

    /// <summary>
    /// Set the blending value of a blendingBehaviour. Works best on Manual type behaviours.
    /// 设置混合行为的混合值。最适用于手动类型的行为。
    /// </summary>
    public void SetBlendingBehaviourValue(string behaviourName, float value)
    {
        PoseBlendingBehaviour behaviour = FindBlendingBehaviour(behaviourName);
        if (behaviour != null)
        {
            behaviour.value = value;
            if (behaviour.type != PoseBlendingBehaviour.BlenderTypes.Manual)
            {
                Debug.LogWarning("[SteamVR] Blending Behaviour: " + behaviourName + " is not a manual behaviour. Its value will likely be overriden.", this);
            }
        }
    }
    /// <summary>
    /// Get the blending value of a blendingBehaviour.
    /// 获取混合行为的混合值。
    /// </summary>
    public float GetBlendingBehaviourValue(string behaviourName)
    {
        PoseBlendingBehaviour behaviour = FindBlendingBehaviour(behaviourName);
        if (behaviour != null)
        {
            return behaviour.value;
        }
        return 0;
    }

    /// <summary>
    /// Enable or disable a blending behaviour.
    /// 启用或禁用混合行为。
    /// </summary>
    public void SetBlendingBehaviourEnabled(string behaviourName, bool value)
    {
        PoseBlendingBehaviour behaviour = FindBlendingBehaviour(behaviourName);
        if (behaviour != null)
        {
            behaviour.enabled = value;
        }
    }
    /// <summary>
    /// Check if a blending behaviour is enabled.
    /// 检查是否启用了混合行为。
    /// </summary>
    /// <param name="behaviourName"></param>
    /// <returns></returns>
    public bool GetBlendingBehaviourEnabled(string behaviourName)
    {
        PoseBlendingBehaviour behaviour = FindBlendingBehaviour(behaviourName);
        if (behaviour != null)
        {
            return behaviour.enabled;
        }

        return false;
    }
    /// <summary>
    /// Get a blending behaviour by name.
    /// 通过名称获得混合行为。
    /// </summary>
    public PoseBlendingBehaviour GetBlendingBehaviour(string behaviourName)
    {
        return FindBlendingBehaviour(behaviourName);
    }

    /// <summary>
    /// 通过 index 获得 SteamVR_Skeleton_Pose 。
    /// </summary>
    public SteamVR_Skeleton_Pose GetPoseByIndex(int index)
    {
        if (index == 0) { return skeletonMainPose; }
        else { return skeletonAdditionalPoses[index - 1]; }
    }

    /// <summary>
    /// Retrieve the final animated pose, to be applied to a hand skeleton,
    /// 检索最后的动画姿态,将应用到一个手骨架
    /// </summary>
    /// <param name="forAction">The skeleton action you want to blend between,
    /// 您想要混合的框架动作</param>
    /// <param name="handType">If this is for the left or right hand,
    /// 如果这是左手或右手</param>
    public SteamVR_Skeleton_PoseSnapshot GetBlendedPose(SteamVR_Action_Skeleton skeletonAction, SteamVR_Input_Sources handType)
    {
        UpdatePose(skeletonAction, handType);
        return GetHandSnapshot(handType);
    }

    /// <summary>
    /// Retrieve the final animated pose, to be applied to a hand skeleton,
    /// 检索最后的动画姿态,将应用到一个手骨架
    /// </summary>
    /// <param name="skeletonBehaviour">The skeleton behaviour you want to get the action/input source from to blend between,
    /// 您希望从其中获取操作/输入源的框架行为</param>
    public SteamVR_Skeleton_PoseSnapshot GetBlendedPose(SteamVR_Behaviour_Skeleton skeletonBehaviour)
    {
        return GetBlendedPose(skeletonBehaviour.skeletonAction, skeletonBehaviour.inputSource);
    }


    /// <summary>
    /// Updates all pose animation and blending. Can be called from different places without performance concerns, as it will only let itself run once per frame.
    /// 更新所有的姿势动画和混合。可以在不考虑性能的情况下从不同的地方调用,因为它每帧只运行一次。
    /// </summary>
    public void UpdatePose(SteamVR_Action_Skeleton skeletonAction, SteamVR_Input_Sources inputSource)
    {
        // only allow this function to run once per frame
        if (poseUpdatedThisFrame) return;

        poseUpdatedThisFrame = true;

        if (skeletonAction.activeBinding)
        {
            // always do additive animation on main pose
            blendPoses[0].UpdateAdditiveAnimation(skeletonAction, inputSource);
        }

        //copy from main pose as a base
        SteamVR_Skeleton_PoseSnapshot snap = GetHandSnapshot(inputSource);
        snap.CopyFrom(blendPoses[0].GetHandSnapshot(inputSource));

        ApplyBlenderBehaviours(skeletonAction, inputSource, snap);


        if (inputSource == SteamVR_Input_Sources.RightHand)
            blendedSnapshotR = snap;
        if (inputSource == SteamVR_Input_Sources.LeftHand)
            blendedSnapshotL = snap;
    }
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值