Example #1
0
        public void TransitionToArmModel(ElementsArmModel armModel)
        {
            if (armModel == null)
            {
                return;
            }

            if (currentArmModel == null)
            {
                currentArmModel = armModel;
                return;
            }

            // Drop any old transitions that have only just begun transitioning,
            // since they won't impact how smooth the transition feels anyways.
            for (int i = transitionsList.Count - 1; i >= 0; i--)
            {
                if (transitionsList[i].transitionValue < DROP_TRANSITION_THRESHOLD)
                {
                    transitionsList.RemoveAt(i);
                }
            }

            // If the max number of transitions is already active, drop the oldest.
            if (transitionsList.Count >= MAX_ACTIVE_TRANSITIONS)
            {
                transitionsList.RemoveAt(0);
            }

            transitionsList.Add(new ArmTransitionInfo(armModel));
        }
 public void SetArmModelFromUI(ElementsArmModel arm)
 {
     arm.elbowRestPosition      = elbowRestSliders.Vector;
     arm.wristRestPosition      = wristRestSliders.Vector;
     arm.controllerRestPosition = controllerRestSliders.Vector;
     arm.armExtensionOffset     = armExtensionSliders.Vector;
     arm.elbowBendRatio         = elbowBendRatioSlider.Scalar;
     arm.pointerTiltAngle       = pointerTiltAngleSlider.Scalar;
 }
 private void SetFromArmModel(ElementsArmModel arm)
 {
     elbowRestSliders.Vector       = arm.elbowRestPosition;
     wristRestSliders.Vector       = arm.wristRestPosition;
     controllerRestSliders.Vector  = arm.controllerRestPosition;
     armExtensionSliders.Vector    = arm.armExtensionOffset;
     elbowBendRatioSlider.Scalar   = arm.elbowBendRatio;
     pointerTiltAngleSlider.Scalar = arm.pointerTiltAngle;
 }
        void Awake()
        {
            if (transitionArmModel != null)
            {
                initialArmModel = transitionArmModel.CurrentArmModel;
            }

            SetupForHeldThrowable();
        }
Example #5
0
        private void OnControllerInputUpdated()
        {
            if (transitionsList.Count == 0)
            {
                // Just return early if there are no transitions right now.
                return;
            }

            float angularVelocity = GvrControllerInput.Gyro.magnitude;
            float lerpValue       = Mathf.Clamp((angularVelocity - MIN_ANGULAR_VELOCITY) / ANGULAR_VELOCITY_DIVISOR, 0.0f, 0.1f);

            // Update each transition and detect if a transition has finished.
            for (int i = transitionsList.Count - 1; i >= 0; i--)
            {
                ArmTransitionInfo transitionInfo = transitionsList[i];

                transitionInfo.transitionValue = Mathf.Lerp(transitionInfo.transitionValue, 1.0f, lerpValue);

                if (transitionInfo.transitionValue >= 0.95f)
                {
                    transitionInfo.transitionValue = 1.0f;
                }

                transitionsList[i] = transitionInfo;

                // Transition is finished, so it should be removed.
                if (transitionInfo.transitionValue >= 1.0f)
                {
                    // Set the current arm model to the arm model we just finished transitioning to.
                    currentArmModel = transitionInfo.armModel;

                    // All transitions prior to the one that finished can be removed.
                    // That means we can mutate the list to remove all prior transitions and then break out of
                    // the loop early.
                    transitionsList.RemoveRange(0, i + 1);
                    break;
                }
            }
        }
Example #6
0
 public ArmTransitionInfo(ElementsArmModel transitionArmModel)
 {
     armModel        = transitionArmModel;
     transitionValue = 0.0f;
 }