public Color3f GetValue(float sparam, float time)
        {
            //1 item, 1 value
            if (Items.Count == 1)
            {
                return(Items [0].GetValue(time));
            }
            //Find 2 keyframes to interpolate between
            AlchemyColors c1 = null, c2 = null;

            for (int i = 0; i < Items.Count - 1; i++)
            {
                if (sparam >= Items [i].SParam && sparam <= Items [i + 1].SParam)
                {
                    c1 = Items [i];
                    c2 = Items [i + 1];
                    break;
                }
            }
            //We're at the end
            if (c1 == null)
            {
                return(Items [Items.Count - 1].GetValue(time));
            }
            //Interpolate between SParams
            var v1 = c1.GetValue(time);
            var v2 = c2.GetValue(time);

            return(Easing.EaseColorRGB(Type, sparam, c1.SParam, c2.SParam, v1, v2));
        }
        public Color3f GetValue(float time)
        {
            //Only have one keyframe? Just return it.
            if (Data.Length == 1)
            {
                return(Data [0].Item2);
            }
            //Locate the keyframes to interpolate between
            float   t1 = float.NegativeInfinity;
            float   t2 = 0;
            Color3f v1 = new Color3f(), v2 = new Color3f();

            for (int i = 0; i < Data.Length - 1; i++)
            {
                if (time >= Data [i].Item1 && time <= Data [i + 1].Item1)
                {
                    t1 = Data [i].Item1;
                    t2 = Data [i + 1].Item1;
                    v1 = Data [i].Item2;
                    v2 = Data [i + 1].Item2;
                    break;
                }
            }
            //Time wasn't between any values. Return max.
            if (t1 == float.NegativeInfinity)
            {
                return(Data [Data.Length - 1].Item2);
            }
            //Interpolate!
            return(Easing.EaseColorRGB(Type, time, t1, t2, v1, v2));
        }
Beispiel #3
0
            public override bool Run(double delta)
            {
                time += delta;
                var t = Event.GetT((float)time);

                if ((Event.SetFlags & AnimVars.Diffuse) == AnimVars.Diffuse)
                {
                    Dst.Light.Color = Easing.EaseColorRGB(EasingTypes.Linear, t, 0, 1, Orig.Color, Event.Diffuse);
                }
                if ((Event.SetFlags & AnimVars.Ambient) == AnimVars.Ambient)
                {
                    Dst.Light.Ambient = Easing.EaseColorRGB(EasingTypes.Linear, t, 0, 1, Orig.Ambient, Event.Ambient);
                }
                return(time < Event.Duration);
            }