コード例 #1
0
        public void sendUpdate(Clock clock)
        {
            if (animating)
            {
                currentTime += clock.DeltaSeconds;
                if (currentTime < animationLength)
                {
                    alpha       = EasingFunctions.Ease(currentEasing, 0, 1.0f, currentTime, animationLength);
                    currentSize = new IntSize2((int)(oldSize.Width + sizeDelta.Width * alpha), WorkingSize.Height);
                }
                else
                {
                    currentTime = animationLength;
                    alpha       = 1.0f;
                    currentSize = new IntSize2(oldSize.Width + sizeDelta.Width, WorkingSize.Height);

                    finishAnimation();
                    oldChildContainer = null;
                }
                if (childContainer != null && oldChildContainer != null)
                {
                    childContainer.setAlpha(alpha);
                }
                invalidate();
            }
        }
コード例 #2
0
        /// <summary>
        /// Primary blend funciton, will always use the terminating state's mandible muscle force and target offset.
        /// This is to retain compatability with animations that rely on this blend funciton to work.
        /// </summary>
        /// <param name="targetState"></param>
        /// <param name="blendFactor"></param>
        public void blend(MusclePosition targetState, float blendFactor)
        {
            float modifiedBlendFactor = blendFactor;

            if (blendFactor < 1.0f)
            {
                EasingFunctions.Ease(targetState.Easing, 0, 1, blendFactor, 1);
            }

            if (MuscleController.MovingTarget != null) //If this is null then the whole mandible simulation is invalid and its better to do nothing
            {
                MuscleController.changeForce("MovingMuscleDynamic", targetState.muscleForce);
                MuscleController.MovingTarget.Offset = targetState.movingTargetPosition;

                ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP");
                float delta = targetState.leftCPPosition - leftCPPosition;
                leftCP.setLocation(leftCPPosition + delta * modifiedBlendFactor);

                ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP");
                delta = targetState.rightCPPosition - rightCPPosition;
                rightCP.setLocation(rightCPPosition + delta * modifiedBlendFactor);
            }

            FKRoot pelvis;

            if (pelvisChainState != null && targetState.pelvisChainState != null && PoseableObjectsManager.tryGetFkChainRoot("Pelvis", out pelvis))
            {
                //This creates garbage, but it is unknown if this has negative effects
                FKChainState blendedState = new FKChainState();
                blendedState.setToBlendOf(pelvisChainState, targetState.pelvisChainState, modifiedBlendFactor);
                pelvis.applyChainState(blendedState);
            }
        }
コード例 #3
0
        /// <summary>
        /// Returns the Fast Fourier Transform of the song at a certain time, with the specified amount of magnitudes.
        /// Useful to make spectrum effets.
        /// </summary>
        public float[] GetFft(double time, int magnitudes, string path = null, OsbEasing easing = OsbEasing.None)
        {
            var fft = GetFft(time, path);

            if (magnitudes == fft.Length && easing == OsbEasing.None)
            {
                return(fft);
            }

            var resultFft = new float[magnitudes];
            var baseIndex = 0;

            for (var i = 0; i < magnitudes; i++)
            {
                var progress = EasingFunctions.Ease(easing, (double)i / magnitudes);
                var index    = Math.Min(Math.Max(baseIndex + 1, (int)(progress * fft.Length)), fft.Length - 1);

                var value = 0f;
                for (var v = baseIndex; v < index; v++)
                {
                    value = Math.Max(value, fft[index]);
                }

                resultFft[i] = value;
                baseIndex    = index;
            }
            return(resultFft);
        }
コード例 #4
0
        public override void sendUpdate(Clock clock)
        {
            if (camera != null)
            {
                if (automaticMovement)
                {
                    totalTime += clock.DeltaSeconds;
                    if (totalTime > animationDuration)
                    {
                        totalTime         = animationDuration;
                        automaticMovement = false;

                        orbitDistance   = targetOrbitDistance;
                        yaw             = targetYaw;
                        pitch           = targetPitch;
                        normalDirection = targetNormal;
                        rotatedUp       = targetRotatedUp;
                        rotatedLeft     = targetRotatedLeft;
                    }
                    float slerpAmount = EasingFunctions.Ease(easingFunction, 0f, 1f, totalTime, animationDuration);
                    this.lookAt = startLookAt.lerp(ref targetLookAt, ref slerpAmount);
                    Quaternion rotation = startRotation.slerp(ref targetRotation, slerpAmount);
                    //If the rotation is not a valid number just use the target rotation
                    if (!rotation.isNumber())
                    {
                        rotation = targetRotation;
                    }
                    Vector3 currentNormalDirection = Quaternion.quatRotate(ref rotation, ref Vector3.Backward);
                    float   currentOrbit           = startOrbitDistance + (targetOrbitDistance - startOrbitDistance) * slerpAmount;
                    updateTranslation(currentNormalDirection * currentOrbit + lookAt);
                    camera.LookAt = lookAt;
                }
            }
        }
コード例 #5
0
    // .. COROUTINES

    IEnumerator UpdateAnimation(Camera camera_to_animate)
    {
        float elapsed    = 0f;
        float total_time = KeyFrames.Sum(e => e.TimeBetweenFrames);

        Transform camera_transform = camera_to_animate.GetComponent <Transform>();

        while (elapsed < total_time)
        {
            float elapsed_frame = 0;
            CameraAnimationKeyframe from, to;
            GetCameraKeyFramesAtTime(elapsed, out from, out to);

            TransformValue from_transform = new TransformValue(from.CameraPreview == null ? camera_transform : from.CameraPreview.GetComponent <Transform>());
            TransformValue to_transform   = new TransformValue(to.CameraPreview.GetComponent <Transform>());
            float          from_fov       = from.CameraPreview == null ? camera_to_animate.fieldOfView : from.CameraPreview.fieldOfView;
            float          to_fov         = to.CameraPreview.fieldOfView;

            while (elapsed_frame < to.TimeBetweenFrames)
            {
                float normalized_time = elapsed_frame / to.TimeBetweenFrames;

                //Transform
                EasingFunctions.Ease(to.TransformEaseType, normalized_time, from_transform, to_transform, ref camera_transform);
                //Field of View
                camera_to_animate.fieldOfView = EasingFunctions.Ease(to.FieldOfViewEaseType, normalized_time, from_fov, to_fov);

                elapsed       += Time.deltaTime;
                elapsed_frame += Time.deltaTime;
                yield return(null);
            }

            camera_transform.localPosition = to_transform.LocalPosition;
            camera_transform.localRotation = to_transform.LocalRotation;
            camera_transform.localScale    = to_transform.LocalScale;
            camera_to_animate.fieldOfView  = to_fov;
        }

        if (OnAnimationCompleted != null)
        {
            OnAnimationCompleted.Invoke(this);
        }
    }
コード例 #6
0
 public override void update(Clock clock)
 {
     if (animating)
     {
         currentTime += clock.DeltaSeconds;
         if (currentTime < animationLength)
         {
             alpha       = EasingFunctions.Ease(currentEasing, 0, 1.0f, currentTime, animationLength);
             currentSize = orientationStrategy.getOrientedResize(alpha);
         }
         else
         {
             currentTime       = animationLength;
             alpha             = 1.0f;
             currentSize       = orientationStrategy.getOrientedFinalSize();
             finishAfterLayout = true;
         }
     }
 }
コード例 #7
0
    // -- PRIVATE

    // .. OPERATIONS

    IEnumerator UpdateScale(
        object[] parameters
        )
    {
        float
            time,
            timer;
        Vector3
            start_scale,
            end_scale;
        Transform
            the_transform;

        time  = (float)parameters[0];
        timer = 0.0f;

        start_scale = (Vector3)parameters[2];
        end_scale   = (Vector3)parameters[3];

        the_transform            = GetComponent <Transform>();
        the_transform.localScale = start_scale;

        while (timer < time)
        {
            yield return(null);

            timer += Time.deltaTime;

            the_transform.localScale = EasingFunctions.Ease(
                (EasingFunctions.TYPE)parameters[1],
                Mathf.Clamp(timer / time, 0.0f, 1.0f),
                start_scale,
                end_scale
                );
        }

        the_transform.localScale = end_scale;
    }
コード例 #8
0
ファイル: UIFader.cs プロジェクト: Jasper-Hilven/LudumDare33
    // .. COROUTINES

    IEnumerator UpdateFade(object[] args)
    {
        float target_alpha   = Mathf.Clamp01((float)args[0]);
        float animation_time = (float)args[1];

        EasingFunctions.TYPE easing_type = (EasingFunctions.TYPE)args[2];

        if (CanvasGroup == null)
        {
            CanvasGroup = GetComponent <CanvasGroup>();
        }

        float start_alpha = CanvasGroup.alpha;
        float elapsed     = 0f;

        while (elapsed < animation_time)
        {
            CanvasGroup.alpha = EasingFunctions.Ease(easing_type, elapsed / animation_time, start_alpha, target_alpha);
            elapsed          += Time.deltaTime;
            yield return(null);
        }

        CanvasGroup.alpha = target_alpha;
    }