示例#1
0
 /// <summary>
 /// 两个颜色之间做插值
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="t"></param>
 /// <param name="color"></param>
 public static void Lerp(Color a, Color b, float t, ref Color color)
 {
     if (t <= 0)
     {
         color.r = a.r; color.g = a.g; color.b = a.b;
     }
     else if (t >= 1)
     {
         color.r = b.r; color.g = b.g; color.b = b.b;
     }
     else
     {
         color.r = MathUntil.Lerp(a.r, b.r, t);
         color.g = MathUntil.Lerp(a.g, b.g, t);
         color.b = MathUntil.Lerp(a.b, b.b, t);
     }
 }
示例#2
0
        /// <summary>
        /// 插值生成新顶点(在屏幕空间,Z值是不需要进行差值的,只需要对x和y进行差值)
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public static void LerpColor(ref Vertex v, Vertex v1, Vertex v2, float t)
        {
            float Zt = 0;

            if (v1.ZView != 0.0f && v2.ZView != 0.0f)
            {
                Zt = MathUntil.Lerp(1f / v1.ZView, 1f / v2.ZView, t);
            }
            if (Zt != 0)
            {
                Zt = 1f / Zt;
            }
            v.ZView      = Zt;
            v.TexCoord.x = MathUntil.Lerp(v1.TexCoord.x, v2.TexCoord.x, t);
            v.TexCoord.y = MathUntil.Lerp(v1.TexCoord.y, v2.TexCoord.y, t);
            v.Color      = Color.Lerp(v1.Color, v2.Color, t);
            v.LightColor = Color.Lerp(v1.LightColor, v2.LightColor, t);
        }
示例#3
0
 /// <summary>
 /// 构造函数,输入分别为rgb三色
 /// </summary>
 /// <param name="r"></param>
 /// <param name="g"></param>
 /// <param name="b"></param>
 public Color(float r, float g, float b)
 {
     mR = MathUntil.Range(r, 0, 1);
     mG = MathUntil.Range(g, 0, 1);
     mB = MathUntil.Range(b, 0, 1);
 }