Esempio n. 1
0
        private void PreStep(float step)
        {
            const float MaxTilt = 1.5f;

            timer.Update(step);

            var t = timer.Progress;

            if (direction)
            {
                t = 1 - t;
            }

            t      = Ease.Compute(t, EaseTypes.QuadraticInOut);
            angle += AngularSpeed * step;

            float tilt = Ease.Compute(t, EaseTypes.QuadraticInOut) * MaxTilt - MaxTilt / 2;

            var p = vec3.Lerp(p1, p2, Ease.Compute(t, EaseTypes.Linear)).ToJVector();
            var o = p1.y == p2.y
                                ? quat.Identity//quat.FromAxisAngle(angle, vec3.UnitY) * quat.FromAxisAngle(tilt, vec3.UnitX)
                                : quat.Identity;

            controllingBody.SetTransform(p, o.ToJMatrix(), step);
        }
Esempio n. 2
0
        // Using this view, the camera can pan either 1) between two points (using this function), or 2) along a curved
        // path (using the overloaded version below).
        public void Refresh(vec3 p1, vec3 p2, float duration, EaseTypes ease)
        {
            if (!timer.IsPaused)
            {
                timer.Elapsed = 0;
            }

            timer.Duration = duration;
            timer.Tick     = t =>
            {
                Recompute(vec3.Lerp(p1, p2, Ease.Compute(t, ease)), true);
            };

            timer.IsPaused = false;

            // When a pan begins, the camera is immediately snapped to the starting transform.
            Recompute(p1, false);
        }
Esempio n. 3
0
        public void Update(float dt)
        {
            elapsed += dt;

            float t;

            if (elapsed >= duration)
            {
                // This ignores any leftover time (such that the end state is set exactly).
                t          = 1;
                IsComplete = true;
            }
            else
            {
                t = elapsed / duration;
            }

            Smooth(Ease.Compute(t, easeType));
        }