Beispiel #1
0
        protected void ApplyBlenderBehaviours(SteamVR_Action_Skeleton skeletonAction, HandType inputSource, SteamVR_Skeleton_PoseSnapshot snapshot)
        {
            // apply blending for each behaviour
            for (int behaviourIndex = 0; behaviourIndex < blendingBehaviours.Count; behaviourIndex++)
            {
                PoseBlendingBehaviour blending = blendingBehaviours[behaviourIndex];

                blending.Update(Time.deltaTime, inputSource, smoothSpeed);



                // if disabled or very low influence, skip for perf

                // float t = blending.targetBehaviour.influence * blending.GetValue();
                float t        = behaviourIndex == 0 ? 1 : blending.GetValue();
                bool  isManual = blending.targetBehaviour.type == SteamVR_Skeleton_PoserBehavior.PoseBlendingBehaviour.BlenderTypes.Manual;

                if ((blending.enabled || isManual || behaviourIndex == 0) && t > 0.01f)
                {
                    // if (blending.targetBehaviour.pose != 0)
                    // {
                    // update additive animation only as needed
                    blendPoses[blending.targetBehaviour.pose].UpdateAdditiveAnimation(skeletonAction, inputSource);
                    // }

                    blending.ApplyBlending(snapshot, blendPoses, inputSource, t);
                }
            }
        }
Beispiel #2
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;
            }
        }
Beispiel #3
0
        /// <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>
        /// Get a blending behaviour by name.
        /// </summary>
        public PoseBlendingBehaviour GetBlendingBehaviour(string behaviourName)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.name == behaviourName);

            if (behaviour == null)
            {
                Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name);
                return(null);
            }
            return(behaviour);
        }
        /// <summary>
        /// Enable or disable a blending behaviour.
        /// </summary>
        public void SetBlendingBehaviourEnabled(string behaviourName, bool value)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.name == behaviourName);

            if (behaviour == null)
            {
                Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name);
                return;
            }
            behaviour.enabled = value;
        }
Beispiel #6
0
        /// <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);
        }
Beispiel #7
0
        /// <summary>
        /// Set the blending value of a blendingBehaviour. Works best on Manual type behaviours.
        /// </summary>
        // public void SetBlendingBehaviourValue(string behaviourName, float value)
        // {
        //     PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.targetBehaviour.name == behaviourName);
        //     if(behaviour == null)
        //     {
        //         Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name);
        //         return;
        //     }
        //     if(behaviour.targetBehaviour.type != SteamVR_Skeleton_PoserBehavior.PoseBlendingBehaviour.BlenderTypes.Manual)
        //     {
        //         Debug.LogWarning("[SteamVR] Blending Behaviour: " + behaviourName + " is not a manual behaviour. Its value will likely be overriden.");
        //     }
        //     behaviour.value = value;
        // }
        /// <summary>
        /// Get the blending value of a blendingBehaviour.
        /// </summary>
        public float GetBlendingBehaviourValue(string behaviourName)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.targetBehaviour.name == behaviourName);

            if (behaviour == null)
            {
                Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name);
                return(0);
            }
            return(behaviour.GetValue());
        }
Beispiel #8
0
        // ebaender - does not throw error in case blending behaviour does not exist
        public void TryToSetBlendingBehaviourValue(string behaviourName, float value)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.name == 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);
                }
            }
        }
Beispiel #9
0
        /// <summary>

        /// </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_Standalone] Blending Behaviour: " + behaviourName + " is not a manual behaviour. Its value will likely be overriden.", this);
                }
            }
        }
        /// <summary>
        /// Set the blending value of a blendingBehaviour. Works best on Manual type behaviours.
        /// </summary>
        public void SetBlendingBehaviourValue(string behaviourName, float value)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.name == behaviourName);

            if (behaviour == null)
            {
                Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name);
                return;
            }
            if (behaviour.type != PoseBlendingBehaviour.BlenderTypes.Manual)
            {
                Debug.LogWarning("[SteamVR] Blending Behaviour: " + behaviourName + " is not a manual behaviour. Its value will likely be overriden.");
            }
            behaviour.value = value;
        }
Beispiel #11
0
        protected PoseBlendingBehaviour FindBlendingBehaviour(string behaviourName, bool throwErrors = true)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.name == behaviourName);

            if (behaviour == null)
            {
                if (throwErrors)
                {
                    Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name, this);
                }

                return(null);
            }

            return(behaviour);
        }
Beispiel #12
0
        /// <summary>
        /// Check if a blending behaviour is enabled.
        /// </summary>
        /// <param name="behaviourName"></param>
        /// <returns></returns>
        public bool GetBlendingBehaviourEnabled(string behaviourName)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.targetBehaviour.name == behaviourName);

            if (behaviour == null)
            {
                Debug.LogError("[SteamVR] Blending Behaviour: " + behaviourName + " not found on Skeleton Poser: " + gameObject.name);
                return(false);
            }
            if (behaviour.targetBehaviour.type == SteamVR_Skeleton_PoserBehavior.PoseBlendingBehaviour.BlenderTypes.Manual)
            {
                return(true);
            }

            return(behaviour.enabled);
        }
Beispiel #13
0
        // ebaender - cant believe i had to write this myself, only way to prevent error
        public bool HasBlendingBehaviour(string behaviourName)
        {
            PoseBlendingBehaviour behaviour = blendingBehaviours.Find(b => b.name == behaviourName);

            return(behaviour != null);
        }