Пример #1
0
        /// <summary>
        /// diffuses the color relative to its light distance
        /// </summary>
        /// <param name="light"></param>
        /// <returns></returns>
        public SLVec3f difuse(SLLight light)
        {
            float   NdL    = Math.Max(SLVec3f.DotProduct(this.normale, light.direction), 0);
            SLVec3f colorD = ((nColor & light.diffuse) * NdL);

            return(colorD);
        }
Пример #2
0
 /// <summary>
 /// Creates a Bitmap with set height and width
 /// </summary>
 /// <param name="width">Width of the bitmap</param>
 /// <param name="height">Height of the bitmap</param>
 public BmpG(int width, int height, ZBuffer buffer, SLLight light)
 {
     this.bmp   = new Bitmap(width, height);
     zB         = buffer;
     this.light = light;
     this.phong = false;
     this.data  = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
     stride     = data.Stride;
 }
Пример #3
0
        /// <summary>
        /// calculates a new color relative to the light
        /// </summary>
        /// <param name="light">relative to this light</param>
        /// <returns>new color</returns>
        public SLVec3f colorToLight(SLLight light)
        {
            if (light.isPhong)
            {
                this.normale.Normalize();
            }
            SLVec3f c = spiegel(light) + difuse(light);

            return(checkColor(c) * 255);
        }
Пример #4
0
        /// <summary>
        /// calculates mirror effect from normale relative to the light
        /// </summary>
        /// <param name="light"></param>
        /// <returns></returns>
        public SLVec3f spiegel(SLLight light)
        {
            SLVec3f R = 2 * (SLVec3f.DotProduct(light.direction, this.normale)) * this.normale - light.direction;
            SLVec3f E = -(this.posInView);

            E.Normalize();
            float RsE = (float)Math.Pow(Math.Max(SLVec3f.DotProduct(R, E), 0), 5);

            return((light.mirror) * RsE);
        }