示例#1
0
        public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity)
        {
            if (hand.noSteamVRFallbackCamera && releaseVelocityStyle != ReleaseStyle.NoChange)
            {
                releaseVelocityStyle = ReleaseStyle.ShortEstimation; // only type that works with fallback hand is short estimation.
            }
            switch (releaseVelocityStyle)
            {
            case ReleaseStyle.ShortEstimation:
                velocityEstimator.FinishEstimatingVelocity();
                velocity        = velocityEstimator.GetVelocityEstimate();
                angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
                break;

            case ReleaseStyle.AdvancedEstimation:
                hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity);
                break;

            case ReleaseStyle.GetFromHand:
                velocity        = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset);
                angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset);
                break;

            default:
            case ReleaseStyle.NoChange:
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                break;
            }

            if (releaseVelocityStyle != ReleaseStyle.NoChange)
            {
                velocity *= scaleReleaseVelocity;
            }
        }
示例#2
0
        public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity)
        {
            switch (releaseVelocityStyle)
            {
            case ReleaseStyle.ShortEstimation:
                velocityEstimator.FinishEstimatingVelocity();
                velocity        = velocityEstimator.GetVelocityEstimate();
                angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
                break;

            case ReleaseStyle.AdvancedEstimation:
                hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity);
                break;

            case ReleaseStyle.GetFromHand:
                velocity        = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset);
                angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset);
                break;

            default:
            case ReleaseStyle.NoChange:
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                break;
            }

            if (releaseVelocityStyle != ReleaseStyle.NoChange)
            {
                velocity *= scaleReleaseVelocity;
            }
        }
示例#3
0
        public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity)
        {
            if (hand.noSteamVRFallbackCamera && releaseVelocityStyle != ReleaseStyle.NoChange)
            {
                releaseVelocityStyle = ReleaseStyle.ShortEstimation; // only type that works with fallback hand is short estimation.
            }
            switch (releaseVelocityStyle)
            {
            case ReleaseStyle.ShortEstimation:
                if (velocityEstimator != null)
                {
                    velocityEstimator.FinishEstimatingVelocity();
                    velocity        = velocityEstimator.GetVelocityEstimate();
                    angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
                }
                else
                {
                    Debug.LogWarning("[SteamVR Interaction System] Throwable: No Velocity Estimator component on object but release style set to short estimation. Please add one or change the release style.");

                    velocity        = rigidbody.velocity;
                    angularVelocity = rigidbody.angularVelocity;
                }
                break;

            case ReleaseStyle.AdvancedEstimation:
                hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity);
                break;

            case ReleaseStyle.GetFromHand:
                velocity        = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset);
                angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset);
                break;

            default:
            case ReleaseStyle.NoChange:
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                break;
            }

            if (releaseVelocityStyle != ReleaseStyle.NoChange)
            {
                float scaleFactor = 1.0f;
                if (scaleReleaseVelocityThreshold > 0)
                {
                    scaleFactor = Mathf.Clamp01(scaleReleaseVelocityCurve.Evaluate(velocity.magnitude / scaleReleaseVelocityThreshold));
                }

                velocity *= (scaleFactor * scaleReleaseVelocity);
            }
        }
示例#4
0
        private void HandAttachedUpdate(Hand hand)
        {
            //if ((rb.velocity + rb.angularVelocity).magnitude >= shakeThreshold)
            //{

            //}
            shakeVel = (hand.GetTrackedObjectVelocity() + hand.GetTrackedObjectAngularVelocity()).magnitude;
            if (shakeVel >= shakeThreshold)
            {
                if (screenStatus != ScreenStatus.MainMenu)
                {
                    screenStatus = ScreenStatus.MainMenu;
                }
                shakeVel = 0;
            }
        }
        public virtual void GetReleaseVelocities(Hand hand, out Vector3 velocity, out Vector3 angularVelocity)
        {
            switch (releaseVelocityStyle)
            {
            case ReleaseStyle.ShortEstimation:
                velocityEstimator.FinishEstimatingVelocity();
                velocity        = velocityEstimator.GetVelocityEstimate();
                angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
                break;

            case ReleaseStyle.AdvancedEstimation:
                hand.GetEstimatedPeakVelocities(out velocity, out angularVelocity);
                break;

            case ReleaseStyle.GetFromHand:
                velocity        = hand.GetTrackedObjectVelocity(releaseVelocityTimeOffset);
                angularVelocity = hand.GetTrackedObjectAngularVelocity(releaseVelocityTimeOffset);
                break;

            default:
            case ReleaseStyle.NoChange:
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                break;
            }

            if (releaseVelocityStyle != ReleaseStyle.NoChange)
            {
                float scaleFactor = 1.0f;
                if (scaleReleaseVelocityThreshold > 0)
                {
                    scaleFactor = Mathf.Clamp01(scaleReleaseVelocityCurve.Evaluate(velocity.magnitude / scaleReleaseVelocityThreshold));
                }

                velocity *= scaleFactor * scaleReleaseVelocity;
            }
        }