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;
}