《SteamVR2.0/Input》(Yanlz+SteamVR+Input+OpenVR+Runtime+SteamVR_Action+立钻哥哥+==)

时间:2025-01-28 15:23:53

using System.Collections;

using UnityEngine;

using Valve.VR;

 

namespace Valve.VR{

    public class SteamVR_Behaviour_Skeleton : MonoBehaviour{

        //The action this component will use to update the model. Must be a Skeleton type action.(立钻哥哥:此组件将用于更新模型的操作。必须是骨架类型的动作。

        [SteamVR_DefaultAction(Skeleton, default, inputSource)]

        public SteamVR_Action_Skeleton skeletonAction;

 

        [Tooltip(The device this action should apply to. Any if the action is not device specific.)]

        public SteamVR_Input_Sources inputSource;

 

        [Tooltip(The range of motion youd like the hand to move in. With controller is the best estimate of the fingers wrapped around a controller. Without is from a flat hand to a fist.(立钻哥哥:你希望手移动的范围。用控制器是手指缠绕在控制器上的最佳估计值。没有是从平的手到拳头。)]

    public EVRSkeletalMotionRange rangeOfMotion = EVRSkeletalMotionRange.WithoutController;

 

        //The root Transform of the skeleton. Needs to have a child(wrist) then wrist should have children in the order thumb, index, middle, ring, pinky.(立钻哥哥:骨架的根变换。需要有一个孩子(手腕)那么手腕应该有孩子的顺序拇指,食指,中指,戒指,小指。

        [Tooltip(This needs to be in the order of: root -> wrist -> thumb, index, middle, ring, pinky)]

        public Transform skeletonRoot;

 

        //The transform this transform should be relative to.(立钻哥哥:这个变换应该是相对的。

        [Tooltip(If not set, relative to parent.)]

        public Transform origin;

 

        //Whether or not to update this transforms position and rotation inline with the skeleton transforms or if this is handled in another script.(立钻哥哥:是否与骨架转换一起更新此转换的位置和旋转,或者是否在另一个脚本中处理此转换。

        [Tooltip(Set to true if you want this script to update its position and rotation. False if this will be handled elsewhere.(立钻哥哥:如果您希望此脚本更新其位置和旋转,请将其设置为true。如果将在其他地方处理,则为False。)]

        public bool updatePose = true;

 

        [Tooltip(Check this to not set the positions of the bones. This is helpful for differently scaled skeletons.(立钻哥哥:检查一下,不要让骨头的位置固定。这对于不同比例的骨架是有帮助的。)]

        public bool onlySetRotations = false;

 

        //How much of a blend to apply to the transform positions and rotations. Set to 0 for the transform orientation to be set by an animation. Set to 1 for the transform orientation to be set by the skeleton action.(立钻哥哥:有多少混合应用于变换位置和旋转。为动画要设置的转换方向设置为0。将骨架动作要设置的转换方向设置为1。

        [Range(0, 1)]

        [Tooltip(Modify this to blend between animations setup on the hand.(立钻哥哥:修改这一点,以混合之间的动画设置在手上。)]

        public float skeletonBlend = 1f;

 

        //Can be set to mirror the bone data across the x axis.(立钻哥哥:可设置为在x轴上镜像骨骼数据。

        [Tooltip(Is this rendermodel a mirror of another one?)]

        public MirrorType mirroring;

 

        public bool isActive{}

 

        public Transform root{}

        public Transform wrist{}

        public Transform indexMetacarpal{}

        public Transform indexProximal{}

        public Transform indexMiddle{}

        public Transform indexDistal{}

        public Transform indexTip{}

        public Transform middleMetacarpal{}

        public Transform middleProximal{}

        public Transform middleMiddle{}

        public Transform middleDistal{}

        public Transform middleTip{}

        public Transform pinkyMetacarpal{}

        public Transform pinkyProximal{}

        public Transform pinkyMiddle{}

        public Transform pinkyDistal{}

        public Transform pinkyTip{}

        public Transform ringMetacarpal{}

        public Transform ringProximal{}

        public Transform ringMiddle{}

        public Transform ringDistal{}

        public Transform ringTip{}

        public Transform thumbMetacarpal{}

        public Transform thumbProximal{}

        public Transform thumbMiddle{}

        public Transform thumbDistal{}

        public Transform thumbTip{}

        public Transform thumbAux{}

        public Transform indexAux{}

        public Transform middleAux{}

        public Transform ringAux{}

        public Transform pinkyAux{}

 

        //An array of all the finger proximal joint transforms.(立钻哥哥:所有手指近端关节变换的数组。

        public Transform[] proximals{}

 

        //An array of all the finger middle joint transforms.(立钻哥哥:所有手指中间关节变换的数组。

        public Transform[] middles{}

 

        //An array of all the finger distal joint transforms.(立钻哥哥:所有手指远端关节变换的数组。

        public Transform[] distals{}

 

        //An array of all the finger tip transforms.(立钻哥哥:所有指尖变换的数组。)

        public Transform[] tips{}

 

        //An array of all the finger aux transforms.(立钻哥哥:所有手指辅助变换的数组。)

        public Transform[] auxs{}

 

        protected Coroutine blendRoutine;

        protected Coroutine rangeOfMotionBlendRoutine;

        protected Transform[] bones;

 

        //The range of motion that is set temporarily (Call ResetTemporaryRangeOfMotion to reset to rangeOfMotion).(立钻哥哥:临时设置的运动范围(调用ResetTemporaryRangeOfMotion将其重置为rangeOfMotion)。

        protected EVRSkeletalMotionRange? temporaryRangeOfMotion = null;

 

        //Returns true if we are in the process of blending the skeletonBlend field (between animation and bone data).(立钻哥哥:如果我们正在混合骨架混合字段(在动画和骨骼数据之间),返回true。

        public bool isBlending{}

 

        protected virtual void Awake(){}

        protected virtual void AssignBonesArray(){}

        protected virtual void OnEnable(){}

        protected virtual void OnDisable(){}

        protected virtual void SteamVR_Input_OnSkeletonsUpdated(bool obj){}

        protected virtual void UpdateSkeleton(){}

 

        //Sets a temporary range of motion for this action that can easily be reset (using ResetTemporaryRangeOfMotion). This is useful for short range of motion changes, for example picking up a controller shaped object.(立钻哥哥:为这个动作设置一个可以轻松重置的临时动作范围(使用ResetTemporaryRangeOfMotion)。这对于短范围的运动变化是有用的,例如拾取一个控制器形状的对象。

        public void SetTemporaryRangeOfMotion(EVRSkeletalMotionRange newRangeOfMotion, float blendOverSeconds=0.1f){}

 

        //Resets the previously set temporary range of motion. Will return to the range of motion defined by the rangeOfMotion field.(立钻哥哥:重置先前设置的临时运动范围。将返回到由rangeOfMotion字段定义的运动范围。

        public void ResetTemporaryRangeOfMotion(float blendOverSeconds=0.1f){}

 

        //Permanently sets the range of motion for this component.(立钻哥哥:永久设置此组件的运动范围。

        //@param newRangeOfMotion:The new range of motion to be set. WithController being the best estimation of where fingers are wrapped around the controller (pressing buttons, etc). WithoutController being a range between a flat hand and a fist.(立钻哥哥:设置新的运动范围。控制器是对手指缠绕在控制器上的位置(按下按钮等)的最佳估计。没有控制器是一个介于平手和拳头之间的范围。

        //@param blendOverSeconds:How long you want the blend to the new range of motion to take (in seconds).(立钻哥哥:你希望混合到新的运动范围需要多长时间(以秒为单位)。

        public void SetRangeOfMotion(){}

 

        //Blend from the current skeletonBlend amount to full bone data. (skeletonBlend = 1)(立钻哥哥:从当前骨骼混合到完整的骨骼数据。(skeletonBlend = 1)

        public void BlendToSkeleton(float overTime=0.1f){}

 

        //Blend from the current skeletonBlend amount to full animation data (no bone data. skeletonBlend = 0)(立钻哥哥:从当前骨骼混合到完整的动画数据(没有骨骼数据)。skeletonBlend = 0)

        public void BlendToAnimation(float overTime=0.1f){}

 

        //Blend from the current skeletonBlend amount to a specified new amount.(立钻哥哥:从当前骨架混合量到指定的新混合量。

        public void BlendTo(float blendToAmount, float overTime){}

 

        protected IEnumerator DoBlendRoutine(float blendToAmount, float overTime){}

        protected void RangeOfMotionBlend(EVRSkeletalMotionRange newRangeOfMotion, float blendOverSeconds){}

        protected void TemporaryRangeOfMotionBlend(EVRSkeletalMotionRange newRangeOfMotion, float blendOverSeconds){}

        protected void ResetTemporaryRangeOfMotionBlend(float blendOverSeconds){}

        protected IEnumerator DoRangeOfMotionBlend(EVRSkeletalMotionRange oldRangeOfMotion, EVRSkeletalMotionRange newRangeOfMotion, float overTime){}

        protected virtual void UpdateSkeletonTransforms(){}

        protected virtual void SetBonePosition(int boneIndex, Vector3 localPosition){}

        protected virtual void SetBoneRotation(int boneIndex, Quaternion localRotation){}

 

        //Gets the transform for a bone by the joint index. Joint indexes specified in: SteamVR_Skeleton_JointIndexes. (立钻哥哥:通过关节指数得到骨头的变换。在:steamvr_skeleton on_joint索引中指定的联合索引。

        public virtual Transform GetBone(int joint){}

        public Vector3 GetBonePosition(int joint, bool local=false){}

        public Vector3 GetBoneRotation(int joint, bool local=false){}

        protected Vector3[] GetBonePositions(SteamVR_Input_Sources inputSource){}

 

        protected Quaternion rightFlipAngle = Quaternion.AngleAxis(180, Vector3.right);

        protected Quaternion[] GetBoneRotations(SteamVR_Input_Sources inputSource){}

 

        protected virtual void UpdatePose(){}

 

        public enum MirrorType{

            None,

            LeftToRight,

            RightToLeft

        }    //立钻哥哥:public enum MirrorType{}

 

        protected bool IsMetacarpal(int boneIndex){}

 

    }    //立钻哥哥:public class SteamVR_Behaviour_Skeleton:MonoBehaviour{}

 

    //The order of the joints that SteamVR Skeleton Input is expecting.(立钻哥哥:SteamVR骨架输入所期望的关节顺序。

    public class SteamVR_Skeleton_JointIndexes{

        public const int root = 0;

        public const int wrist = 1;

        public const int thumbMetacarpal = 2;

        public const int thumbProximal = 2;

        public const int thumbMiddle = 3;

        public const int thumbDistal = 4;

        public const int thumbTip = 5;

        public const int indexMetacarpal = 6;

        public const int indexProximal = 7;

        public const int indexMiddle = 8;

        public const int indexDistal = 9;

        public const int indexTip = 10;

        public const int middleMetacarpal = 11;

        public const int middleProximal = 12;

        public const int middleMiddle = 13;

        public const int middleDistal = 14;

        public const int middleTip = 15;

        public const int ringMetacarpal = 16;

        public const int ringProximal = 17;

        public const int ringMiddle = 18;

        public const int ringDistal = 19;

        public const int ringTip = 20;

        public const int pinkyMetacarpal = 21;

        public const int pinkyProximal = 22;

        public const int pinkyMiddle = 23;

        public const int pinkyDistal = 24;

        public const int pinkyTip = 25;

        public const int thumbAux = 26;

        public const int indexAux = 27;

        public const int middleAux = 28;

        public const int ringAux = 29;

        public const int pinkyAux = 30;

    }    //立钻哥哥:public class SteamVR_Skeleton_JointIndexes{}

 

    public enum SteamVR_Skeleton_JointIndexEnum{

        root = SteamVR_Skeleton_JointIndexes.root,

        wrist = SteamVR_Skeleton_JointIndexes.wrist,

        thumbMetacarpal = SteamVR_Skeleton_JointIndexes.thumbMetacarpal,

        thumbProximal = SteamVR_Skeleton_JointIndexes.thumbProximal,

        thumbMiddle = SteamVR_Skeleton_JointIndexes.thumbMiddle,

        thumbDistal = SteamVR_Skeleton_JointIndexes.thumbDistal,

        thumbTip = SteamVR_Skeleton_JointIndexes.thumbTip,

        indexMetacarpal = SteamVR_Skeleton_JointIndexes.indexMetacarpal,

        indexProximal = SteamVR_Skeleton_JointIndexes.indexProximal,

        indexMiddle = SteamVR_Skeleton_JointIndexes.indexMiddle,

        indexDistal = SteamVR_Skeleton_JointIndexes.indexDistal,

        indexTip = SteamVR_Skeleton_JointIndexes.indexTip,

        middleMetacarpal = SteamVR_Skeleton_JointIndexes.middleMetacarpal,

        middleProximal = SteamVR_Skeleton_JointIndexes.middleProximal,

        middleMiddle = SteamVR_Skeleton_JointIndexes.middleMiddle,

        middleDistal = SteamVR_Skeleton_JointIndexes.middleDistal,

        middleTip = SteamVR_Skeleton_JointIndexes.middleTip,

        ringMetacarpal = SteamVR_Skeleton_JointIndexes.ringMetacarpal,

        ringProximal = SteamVR_Skeleton_JointIndexes.ringProximal,

        ringMiddle = SteamVR_Skeleton_JointIndexes.ringMiddle,

        ringDistal = SteamVR_Skeleton_JointIndexes.ringDistal,

        ringTip = SteamVR_Skeleton_JointIndexes.ringTip,

        pinkyMetacarpal = SteamVR_Skeleton_JointIndexes.pinkyMetacarpal,

        pinkyProximal = SteamVR_Skeleton_JointIndexes.pinkyProximal,

        pinkyMiddle = SteamVR_Skeleton_JointIndexes.pinkyMiddle,

        pinkyDistal = SteamVR_Skeleton_JointIndexes.pinkyDistal,

        pinkyTip = SteamVR_Skeleton_JointIndexes.pinkyTip,

        thumbAux = SteamVR_Skeleton_JointIndexes.thumbAux,

        indexAux = SteamVR_Skeleton_JointIndexes.indexAux,

        middleAux = SteamVR_Skeleton_JointIndexes.middleAux,

        ringAux = SteamVR_Skeleton_JointIndexes.ringAux,

        pinkyAux = SteamVR_Skeleton_JointIndexes.pinkyAux,

    }    //立钻哥哥:public enum SteamVR_Skeleton_JointIndexEnum{}

 

}    //立钻哥哥:namespace {}