Exemplo n.º 1
0
 internal static void Update(ShaderVector4 t, float timeslice)
 {
     if (t.delay > 0)
     {
         t.delay -= timeslice;
         if (t.delay <= 0)
         {
             t.SurplusTime += t.delay;
             t.Target.SetVector(t.ParameterName, t.StartValue);
         }
     }
     else
     {
         t.SurplusTime -= timeslice;
         if (t.SurplusTime <= 0)
         {
             t.Target.SetVector(t.ParameterName, t.EndValue);
             return;
         }
         float   r = 1 - t.SurplusTime / t.Time;
         Vector4 d = t.EndValue - t.StartValue;
         d *= r;
         d += t.StartValue;
         t.Target.SetVector(t.ParameterName, d);
     }
 }
Exemplo n.º 2
0
        public static void Play(this Material mat, string name, Vector4 sv, Vector4 ev, float time, float delay = 0, Action <ShaderAnimat> over = null, bool cover = true)
        {
            if (mat == null)
            {
                return;
            }
            var ani = AnimationManage.Manage.FindAni <ShaderAnimat>((o) => { return(o.Target == mat ? true : false); });

            if (ani == null)
            {
                ani = new ShaderAnimat(mat);
                ShaderVector4 sf = new ShaderVector4();
                sf.ParameterName = name;
                sf.StartValue    = sv;
                sf.EndValue      = ev;
                sf.Time          = time;
                sf.Delay         = delay;
                ani.Time         = time;
                if (over == null)
                {
                    ani.PlayOver = (o) => { o.Dispose(); }
                }
                ;
                else
                {
                    ani.PlayOver = over;
                }
            }
            else
            {
                var sf = ani.FindVectorShader(name);
                if (sf != null)
                {
                    if (!cover)
                    {
                        return;
                    }
                }
                else
                {
                    sf = new ShaderVector4();
                }
                sf.StartValue = sv;
                sf.EndValue   = ev;
                sf.Time       = time;
                sf.Delay      = delay;
                ani.Time      = time;
                if (over == null)
                {
                    ani.PlayOver = (o) => { o.Dispose(); }
                }
                ;
                else
                {
                    ani.PlayOver = over;
                }
            }
            ani.Play();
        }
Exemplo n.º 3
0
 public void Update(float timeslice)
 {
     if (playing)
     {
         if (Delay > 0)
         {
             Delay -= timeslice;
             if (Delay <= 0)
             {
                 if (PlayStart != null)
                 {
                     PlayStart(this);
                 }
                 c_time    += Delay;
                 timeslice += Delay;
                 if (lsf != null)
                 {
                     for (int i = 0; i < lsf.Count; i++)
                     {
                         ShaderFloat.Update(lsf[i], timeslice);
                     }
                 }
                 if (lsv != null)
                 {
                     for (int i = 0; i < lsv.Count; i++)
                     {
                         ShaderVector4.Update(lsv[i], timeslice);
                     }
                 }
             }
         }
         else
         {
             c_time -= timeslice;
             if (lsf != null)
             {
                 for (int i = 0; i < lsf.Count; i++)
                 {
                     ShaderFloat.Update(lsf[i], timeslice);
                 }
             }
             if (lsv != null)
             {
                 for (int i = 0; i < lsv.Count; i++)
                 {
                     ShaderVector4.Update(lsv[i], timeslice);
                 }
             }
             if (!Loop & c_time <= 0)
             {
                 playing = false;
                 if (PlayOver != null)
                 {
                     PlayOver(this);
                 }
             }
             else
             {
                 if (c_time <= 0)
                 {
                     Play();
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public void RemoveDelegate(ShaderVector4 sv)
 {
     lsv.Remove(sv);
 }
Exemplo n.º 5
0
 public void AddDelegate(ShaderVector4 sv)
 {
     lsv.Add(sv);
     sv.Target = Target;
 }