예제 #1
0
파일: Form1.cs 프로젝트: Deorka/cs332-lab8
        //GOURAUD
        private void show_gouraud()
        {
            float[] intensive = new float[pictureBox1.Width * pictureBox1.Height];

            figure.calc_gouraud(camera.view, pictureBox1.Width, pictureBox1.Height, out intensive, new Point3D(int.Parse(light_x.Text), int.Parse(light_y.Text), int.Parse(light_z.Text)));
            Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);

            pictureBox1.Image = bmp;
            g.Clear(Color.White);

            for (int i = 0; i < pictureBox1.Width; ++i)
            {
                for (int j = 0; j < pictureBox1.Height; ++j)
                {
                    Color c;
                    if (intensive[i * pictureBox1.Height + j] < 1E-6f)
                    {
                        c = Color.White;
                    }
                    else
                    {
                        float intsv = intensive[i * pictureBox1.Height + j];
                        if (intsv > 1)
                        {
                            intsv = 1;
                        }
                        c = Color.FromArgb((int)(fill_color.R * intsv) % 256, (int)(fill_color.G * intsv) % 256, (int)(fill_color.B * intsv) % 256);
                    }
                    bmp.SetPixel(i, j, c);
                }
            }

            pictureBox1.Refresh();
        }