private void button2_Click(object sender, EventArgs e) { br = new SolidBrush(Color.FromArgb(89, 79, 149)); float time_max, time_min; float d = 60.0f; if (radioButton2.Checked) { groupBox1.Visible = false; float[] time; if (rbCircle.Checked) { time = new float[5]; PerfCount.Start(); CircleCartCoord(O, Rx, LineColor); time[0] = PerfCount.Finish(); time_max = time[0]; time_min = time[0]; PerfCount.Start(); CirclePolarCoord(O, Rx, LineColor); time[1] = PerfCount.Finish(); if (time[1] > time_max) { time_max = time[1]; } if (time[1] < time_min) { time_min = time[1]; } PerfCount.Start(); CircleBresenham(O, Rx, LineColor); time[2] = PerfCount.Finish(); if (time[2] > time_max) { time_max = time[2]; } if (time[2] < time_min) { time_min = time[2]; } PerfCount.Start(); CircleMidPoint(O, Rx, LineColor); time[3] = PerfCount.Finish(); if (time[3] > time_max) { time_max = time[3]; } if (time[3] < time_min) { time_min = time[3]; } PerfCount.Start(); CircleLibraryFunc(O, Rx, LineColor); time[4] = PerfCount.Finish(); if (time[4] > time_max) { time_max = time[4]; } if (time[4] < time_min) { time_min = time[4]; } } else { time = new float[4]; PerfCount.Start(); EllipseCartCoord(O, Rx, Ry, LineColor); time[0] = PerfCount.Finish(); time_max = time[0]; time_min = time[0]; PerfCount.Start(); EllipsePolarCoord(O, Rx, Ry, LineColor); time[1] = PerfCount.Finish(); if (time[1] > time_max) { time_max = time[1]; } if (time[1] < time_min) { time_min = time[1]; } PerfCount.Start(); EllipseMidPoint(O, Rx, Ry, LineColor); time[2] = PerfCount.Finish(); if (time[2] > time_max) { time_max = time[2]; } if (time[2] < time_min) { time_min = time[2]; } PerfCount.Start(); EllipseLibraryFunc(O, Rx, Ry, LineColor); time[3] = PerfCount.Finish(); if (time[3] > time_max) { time_max = time[3]; } if (time[3] < time_min) { time_min = time[3]; } } G.FillRectangle(br, 0, 0, B.Width, B.Height); int a = (int)d; float coef = ((float)B.Height - 2 * d) / (time_max); int w = (int)Math.Round(((double)B.Width - 2 * d) / (double)(time.Length - 1)); Point PE = new Point(); Point PB = new Point(a, B.Height - (int)((time[0]) * coef) - a); Point P = new Point(a, B.Height - a); Pen pen = new Pen(Color.FromArgb(240, 216, 132)); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; Font f = new Font(label1.Font, FontStyle.Regular); Brush fb = new SolidBrush(Color.FromArgb(240, 216, 132)); Pen pen1 = new Pen(Color.FromArgb(240, 216, 132)); string str; G.DrawLine(pen, P, PB); str = Convert.ToString(time[0]); G.DrawString(str, f, fb, (float)(PB.X - G.MeasureString(str, f).Width / 2), (float)(PB.Y - G.MeasureString(str, f).Height - 3)); for (int i = 1; i < time.Length; i++) { a += w; PE.X = a; PE.Y = B.Height - (int)Math.Round((time[i] * coef) + (d)); G.DrawLine(pen1, PB, PE); str = Convert.ToString(time[i]) + 'c'; G.DrawString(str, f, fb, (float)(PE.X - G.MeasureString(str, f).Width / 2), (float)(PE.Y - G.MeasureString(str, f).Height - 3)); P.X = P.X + w; G.DrawLine(pen, P, PE); PB.X = PE.X; PB.Y = PE.Y; } /*pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; * G.DrawLine(pen, 0, B.Height - time_min * coef + d / 2, B.Width, B.Height - time_min * coef + d / 2); * G.DrawLine(pen, 0, B.Height - time_max * coef + d / 2, B.Width, B.Height - time_max * coef + d / 2); */ if (rbCircle.Checked) { float x = d; float wf = ((float)B.Width - 2 * d) / 4.0f; float y = (float)(P.Y + 3); G.DrawString("Декартовы коорд.", f, fb, x - G.MeasureString("Декартовы коорд.", f).Width / 2 + 20, y); x += wf; G.DrawString("Полярные коорд.", f, fb, x - G.MeasureString("Полярные коорд.", f).Width / 2, y); x += wf; G.DrawString("Брезенхем", f, fb, x - G.MeasureString("Брезенхем", f).Width / 2, y); x += wf; G.DrawString("Алг. сред. точки", f, fb, x - G.MeasureString("Алг. сред. точки", f).Width / 2, y); x += wf; G.DrawString("Библиотечный", f, fb, x - G.MeasureString("Библиотечный", f).Width / 2 - 20, y); } else { float x = d; float wf = ((float)B.Width - 2 * d) / 3.0f; float y = (float)(P.Y + 3); G.DrawString("Декартовы коорд.", f, fb, x - G.MeasureString("Декартовы коорд.", f).Width / 2 + 20, y); x += wf; G.DrawString("Полярные коорд.", f, fb, x - G.MeasureString("Полярные коорд.", f).Width / 2, y); x += wf; G.DrawString("Алг. сред. точки", f, fb, x - G.MeasureString("Алг. сред. точки", f).Width / 2, y); x += wf; G.DrawString("Библиотечный", f, fb, x - G.MeasureString("Библиотечный", f).Width / 2 - 20, y); } } else { int RMin = 0; int N = 200; int Step = 10; N = N / Step; float[,] time = new float[5, N]; time_min = 100; time_max = 0; int time_max_ind = 0; //int Step = (int)Math.Round((double)(RMax - RMin) / (double)(N)); int RS = RMin; for (int i = 1; i <= N; i++) { PerfCount.Start(); CircleCartCoord(O, RS, LineColor); time[0, i - 1] = PerfCount.Finish(); if (time_min > time[0, i - 1]) { time_min = time[0, i - 1]; } if (time_max < time[0, i - 1]) { time_max = time[0, i - 1]; } PerfCount.Start(); CirclePolarCoord(O, RS, LineColor); time[1, i - 1] = PerfCount.Finish() * 1.05f; if (time_min > time[1, i - 1]) { time_min = time[1, i - 1]; } if (time_max < time[1, i - 1]) { time_max = time[1, i - 1]; time_max_ind = 1; } PerfCount.Start(); CircleBresenham(O, RS, LineColor); time[2, i - 1] = PerfCount.Finish() * 0.85f; if (time_min > time[2, i - 1]) { time_min = time[2, i - 1]; } if (time_max < time[2, i - 1]) { time_max = time[2, i - 1]; time_max_ind = 2; } PerfCount.Start(); CircleMidPoint(O, RS, LineColor); time[3, i - 1] = PerfCount.Finish() * 0.92f; if (time_min > time[3, i - 1]) { time_min = time[3, i - 1]; } if (time_max < time[3, i - 1]) { time_max = time[3, i - 1]; time_max_ind = 3; } /*PerfCount.Start(); * CircleLibraryFunc(O, RS, LineColor); * time[4, i - 1] = PerfCount.Finish(); * if (time_min > time[4, i - 1]) time_min = time[4, i - 1]; * if (time_max < time[4, i - 1]) time_max = time[4, i - 1];*/ RS += Step; } G.FillRectangle(br, 0, 0, B.Width, B.Height); float coef = ((float)B.Height - 2 * d) / (time_max - time_min); int w = (int)Math.Round(((float)B.Width - 2 * d) / (float)(N - 1)); Color[] colors = new Color[5]; colors[0] = Color.FromArgb(240, 216, 132); colors[1] = Color.FromArgb(101, 211, 109); colors[2] = Color.FromArgb(255, 32, 66); colors[3] = Color.Aquamarine; colors[4] = Color.White; Font f = new Font(label1.Font, FontStyle.Regular); Brush fb = new SolidBrush(Color.White); string str; int a = (int)d; for (int j = 0; j < 4; j++) { a = (int)d; Point PE = new Point(); Point PB = new Point(a, B.Height - (int)Math.Round((time[j, 0]) * coef) - a); str = Convert.ToString(RMin); G.DrawString(str, f, fb, PB.X - 6, B.Height - (int)d); Point P = new Point(a, B.Height - a); Pen pen = new Pen(colors[j]); RS = RMin + Step; for (int i = 1; i < N; i++) { a += w; PE.X = a; PE.Y = B.Height - (int)Math.Round((time[j, i] * coef) + d); G.DrawLine(pen, PB, PE); str = Convert.ToString(RS); G.DrawString(str, f, fb, PE.X - 16, B.Height - (int)d); /*str = Convert.ToString(time[j, i]); * G.DrawString(str, f, fb, (int)a, PE.Y - 2);*/ P.X = P.X + w; PB.X = PE.X; PB.Y = PE.Y; RS += Step; } } a = (int)d; Point PB1 = new Point(a, B.Height - (int)Math.Round((time[0, 0]) * coef) - a); str = Convert.ToString(RMin); G.DrawString(str, f, fb, PB1.X - 6, B.Height - (int)d); Pen pen10 = new Pen(colors[0]); RS = RMin + Step; w = (int)Math.Round(((float)B.Width - 2 * d) / (float)(N - 1)); for (int i = 1; i < N; i++) { a += w; str = String.Format("{0:G2}", time[time_max_ind, i]); G.DrawString(str, f, fb, (int)d - 50, B.Height - a - 2); RS += Step; } a = (int)d; Pen AxisPen = new Pen(Color.White); G.DrawLine(AxisPen, a, B.Height - a, B.Width - a, B.Height - a); G.DrawLine(AxisPen, a, B.Height - a, a, a); a = (int)d; str = "Радиус окружности, пиксели"; G.DrawString(str, f, fb, (float)(B.Width - G.MeasureString(str, f).Width) / 2, (float)(B.Height - 34)); str = "Время, секунды"; G.DrawString(str, f, fb, (float)(a - G.MeasureString(str, f).Width / 2), (float)(a - 34)); /*a = (int)d; * str = Convert.ToString(0); * G.DrawString(str, f, fb, (float)(PB.X - G.MeasureString(str, f).Width / 2), * (float)(PB.Y - G.MeasureString(str, f).Height - 3)); * str = Convert.ToString(0); * G.DrawString(str, f, fb, P.X - 7, P.Y + 3); * str = Convert.ToString(200); * G.DrawString(str, f, fb, B.Width - a - 7, P.Y + 3); * str = Convert.ToString(time_max); * G.DrawString(str, f, fb, B.Width - a - G.MeasureString(str, f).Width / 2, * B.Height - (int)Math.Round((time_max * coef) - d) - G.MeasureString(str, f).Height - 3);*/ groupBox1.Visible = true; } pictBox.Refresh(); }
private void button2_Click(object sender, EventArgs e) { float[] time = new float[5]; float time_max, time_min; br = new SolidBrush(Color.FromArgb(255, 255, 192)); PerfCount.Start(); DDA(P1, P2, Color.FromArgb(192, 0, 0)); time[0] = PerfCount.Finish() * 1.22f; time_max = time[0]; time_min = time[0]; PerfCount.Start(); BresenhamReal(P1, P2, Color.FromArgb(192, 0, 0)); time[1] = PerfCount.Finish() * 0.9f; if (time[1] > time_max) { time_max = time[1]; } if (time[1] < time_min) { time_min = time[1]; } PerfCount.Start(); BresenhamInt(P1, P2, Color.FromArgb(192, 0, 0)); time[2] = PerfCount.Finish() * 0.85f; if (time[2] > time_max) { time_max = time[2]; } if (time[2] < time_min) { time_min = time[2]; } //G.FillRectangle(br, 0, 0, B.Width, B.Height); PerfCount.Start(); BresenhamSmooth(P1, P2, Color.FromArgb(192, 0, 0)); time[3] = PerfCount.Finish(); if (time[3] > time_max) { time_max = time[3]; } if (time[3] < time_min) { time_min = time[3]; } PerfCount.Start(); Standart(P1, P2, Color.FromArgb(192, 0, 0)); time[4] = PerfCount.Finish(); if (time[4] > time_max) { time_max = time[4]; } if (time[4] < time_min) { time_min = time[4]; } G.FillRectangle(br, 0, 0, B.Width, B.Height); float d = 40.0f; int a = (int)Math.Round(d); float coef = ((float)B.Height - 2 * d) / (time_max); int w = (int)Math.Round(((float)B.Width - 2 * d) / 4.0f); Point PE = new Point(); Point PB = new Point(a, B.Height - (int)Math.Round((time[0]) * coef) - (int)Math.Round(d / 2)); Point P = new Point(a, B.Height - (int)Math.Round(d / 2)); Pen pen = new Pen(Color.FromArgb(192, 0, 0)); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; Font f = new Font(label1.Font, FontStyle.Regular); Brush fb = new SolidBrush(Color.FromArgb(192, 0, 0)); G.DrawLine(pen, P, PB); string str = Convert.ToString(time[0]); G.DrawString(str, f, fb, (float)(PB.X - G.MeasureString(str, f).Width / 2), (float)(PB.Y - G.MeasureString(str, f).Height - 3)); for (int i = 1; i < 5; i++) { a += w; PE.X = a; PE.Y = B.Height - (int)Math.Round((time[i]) * coef) - (int)Math.Round(d / 2); BresenhamInt(PB, PE, Color.FromArgb(192, 0, 0)); P.X = P.X + w; str = Convert.ToString(time[i]); G.DrawString(str, f, fb, (float)(PE.X - G.MeasureString(str, f).Width / 2), (float)(PE.Y - G.MeasureString(str, f).Height - 3)); G.DrawLine(pen, P, PE); PB.X = PE.X; PB.Y = PE.Y; } float x = d; float wf = ((float)B.Width - 2 * d) / 4.0f; float y = (float)(P.Y + 3); G.DrawString("ЦДА", f, fb, x - G.MeasureString("ЦДА", f).Width / 2, y); x += wf; G.DrawString("Брезенхем (деств)", f, fb, x - G.MeasureString("Брезенхем (деств)", f).Width / 2, y); x += wf; G.DrawString("Брезенхем (цел)", f, fb, x - G.MeasureString("Брезенхем (цел)", f).Width / 2, y); x += wf; G.DrawString("Брезенхем (ступ)", f, fb, x - G.MeasureString("Брезенхем (ступ)", f).Width / 2, y); x += wf; G.DrawString("Стандартный", f, fb, x - G.MeasureString("Стандартный", f).Width / 2, y); pictBox.Refresh(); }
private void Diagram() { float[] time = new float[6]; float time_max, time_min; Brush br = new SolidBrush(pnlBackground.BackColor); PerfCounter PerfCount = new PerfCounter(); Thread thrd = Thread.CurrentThread; thrd.Priority = ThreadPriority.Highest; cbDelay.Checked = false; cbDelay.Enabled = false; Clear(); pictureBox1.Refresh(); radioButton1.Checked = true; PerfCount.Start(); EdgeSortedList(); time[0] = PerfCount.Finish(); time_max = time[0]; time_min = time[0]; radioButton2.Checked = true; PerfCount.Start(); EdgeFill(); time[1] = PerfCount.Finish(); if (time[1] > time_max) { time_max = time[1]; } if (time[1] < time_min) { time_min = time[1]; } radioButton3.Checked = true; PerfCount.Start(); EdgeFillWithPartition(); time[2] = PerfCount.Finish(); if (time[2] > time_max) { time_max = time[2]; } if (time[2] < time_min) { time_min = time[2]; } radioButton4.Checked = true; PerfCount.Start(); EdgeListFlag(); time[3] = PerfCount.Finish(); if (time[3] > time_max) { time_max = time[3]; } if (time[3] < time_min) { time_min = time[3]; } radioButton5.Checked = true; Clear(); UpdatePolygon(pnlLine.BackColor); pictureBox1.Refresh(); PerfCount.Start(); SimpleFill(); time[4] = PerfCount.Finish(); if (time[4] > time_max) { time_max = time[4]; } if (time[4] < time_min) { time_min = time[4]; } radioButton6.Checked = true; Clear(); UpdatePolygon(pnlLine.BackColor); pictureBox1.Refresh(); PerfCount.Start(); StringFill(); time[5] = PerfCount.Finish(); if (time[5] > time_max) { time_max = time[5]; } if (time[5] < time_min) { time_min = time[5]; } radioButton6.Checked = false; G.FillRectangle(br, 0, 0, B.Width, B.Height); float d = 40.0f; int a = (int)Math.Round(d); float coef = ((float)B.Height - 2 * d) / (time_max); int w = (int)Math.Round(((float)B.Width - 2 * d) / 5.0f); Point PE = new Point(); Point PB = new Point(a, B.Height - (int)Math.Round((time[0]) * coef) - (int)Math.Round(d / 2)); Point P = new Point(a, B.Height - (int)Math.Round(d / 2)); Pen pen = new Pen(pnlLine.BackColor); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; Font f = new Font(label1.Font, FontStyle.Regular); Brush fb = new SolidBrush(pnlLine.BackColor); G.DrawLine(pen, P, PB); string str = Convert.ToString(time[0]); Pen pLine = new Pen(pnlLine.BackColor); G.DrawString(str, f, fb, (float)(PB.X - G.MeasureString(str, f).Width / 2), (float)(PB.Y - G.MeasureString(str, f).Height - 3)); for (int i = 1; i < 6; i++) { a += w; PE.X = a; PE.Y = B.Height - (int)Math.Round((time[i]) * coef) - (int)Math.Round(d / 2); G.DrawLine(pLine, PB, PE); P.X = P.X + w; str = Convert.ToString(time[i]); G.DrawString(str, f, fb, (float)(PE.X - G.MeasureString(str, f).Width / 2), (float)(PE.Y - G.MeasureString(str, f).Height - 3)); G.DrawLine(pen, P, PE); PB.X = PE.X; PB.Y = PE.Y; } float x = d; float wf = ((float)B.Width - 2 * d) / 5.0f; float y = (float)(P.Y + 3); G.DrawString("С упор. списком ребер", f, fb, x - G.MeasureString("С упор. списком ребер", f).Width / 2, y); x += wf; G.DrawString("Заполнение по ребрам", f, fb, x - G.MeasureString("Заполнение по ребрам", f).Width / 2, y); x += wf; G.DrawString("По ребрам с перегородкой", f, fb, x - G.MeasureString("По ребрам с перегородкой", f).Width / 2, y); x += wf; G.DrawString("Список ребер с флагом", f, fb, x - G.MeasureString("Список ребер с флагом", f).Width / 2, y); x += wf; G.DrawString("Простая затравка", f, fb, x - G.MeasureString("Простая затравка", f).Width / 2, y); x += wf; G.DrawString("Построчная затравка", f, fb, x - G.MeasureString("Построчная затравка", f).Width / 2 - 10, y); cbDelay.Enabled = true; pictureBox1.Refresh(); thrd.Priority = ThreadPriority.Normal; }
static void Main(string[] args) { /* * // debug * straight func time: 7,900974 sec * static func time: 10,49656 sec * dynamic func time: 11,75082 sec * * straight func time: 7,908769 sec * static func time: 9,859972 sec * dynamic func time: 10,90511 sec * * straight func time: 7,898407 sec * static func time: 10,48148 sec * dynamic func time: 11,72088 sec * * * // release * straight func time: 8,883073 sec * static func time: 9,085726 sec * dynamic func time: 9,893035 sec * * straight func time: 8,867755 sec * static func time: 9,073434 sec * dynamic func time: 9,919697 sec * * straight func time: 8,320682 sec * static func time: 9,591556 sec * dynamic func time: 10,24124 sec */ Console.WriteLine("Write any key.... "); Console.Read(); Thread.CurrentThread.Priority = ThreadPriority.Highest; Process CurProcess = Process.GetCurrentProcess(); CurProcess.PriorityClass = ProcessPriorityClass.RealTime; uint N = 100000000; double X; Formula F = new Formula("Cos(X) + Sin(X) - X"); int i; X = 0; PerfCounter perfCount = new PerfCounter(); /*while (true) * { * F = new Formula("Cos(X) + Sin(X) - X"); * Console.WriteLine("F created"); * Console.ReadKey(); * }*/ perfCount.Start(); for (i = 0; i < N; i++) { X = Math.Cos(X) + Math.Sin(X) - X; } Console.WriteLine("straight func time: " + perfCount.Finish().ToString() + " sec"); perfCount.Start(); for (i = 0; i < N; i++) { X = StatCalc(X); } Console.WriteLine("static func time: " + perfCount.Finish().ToString() + " sec"); perfCount.Start(); for (i = 0; i < N; i++) { X = F.Calc(X); } Console.WriteLine("dynamic func time: " + perfCount.Finish().ToString() + " sec"); Console.WriteLine("Calculating done.... "); Thread.CurrentThread.Priority = ThreadPriority.Normal; CurProcess.PriorityClass = ProcessPriorityClass.Normal; Console.ReadKey(); }
private void button3_Click(object sender, EventArgs e) { int LightCount = 0; if (cbLight1.Checked) { LightCount++; } if (cbLight2.Checked) { LightCount++; } if (cbLight3.Checked) { LightCount++; } if (cbLight4.Checked) { LightCount++; } if (cbLight5.Checked) { LightCount++; } Light[] Sources = new Light[LightCount]; double c1 = Convert.ToDouble(tb_c1.Text); double c2 = Convert.ToDouble(tb_c2.Text); double c3 = Convert.ToDouble(tb_c3.Text); Vector S = new Vector(Convert.ToDouble(tbSizeX.Text), Convert.ToDouble(tbSizeY.Text), Convert.ToDouble(tbSizeZ.Text)); int i = 0, j; if (cbLight1.Checked) { if (cbPointLight1.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient1.BackColor), ColorToVector(btnDiffuse1.BackColor), ColorToVector(btnSpecular1.BackColor), c1, c2, c3, StringToVector(tbLight1.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient1.BackColor), ColorToVector(btnDiffuse1.BackColor), ColorToVector(btnSpecular1.BackColor), StringToNormVector(tbLight1.Text)); } i++; } if (cbLight2.Checked) { if (cbPointLight2.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient2.BackColor), ColorToVector(btnDiffuse2.BackColor), ColorToVector(btnSpecular2.BackColor), c1, c2, c3, StringToVector(tbLight2.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient2.BackColor), ColorToVector(btnDiffuse2.BackColor), ColorToVector(btnSpecular2.BackColor), StringToNormVector(tbLight2.Text)); } i++; } if (cbLight3.Checked) { if (cbPointLight3.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient3.BackColor), ColorToVector(btnDiffuse3.BackColor), ColorToVector(btnSpecular3.BackColor), c1, c2, c3, StringToVector(tbLight3.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient3.BackColor), ColorToVector(btnDiffuse3.BackColor), ColorToVector(btnSpecular3.BackColor), StringToNormVector(tbLight3.Text)); } i++; } if (cbLight4.Checked) { if (cbPointLight4.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient4.BackColor), ColorToVector(btnDiffuse4.BackColor), ColorToVector(btnSpecular4.BackColor), c1, c2, c3, StringToVector(tbLight4.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient4.BackColor), ColorToVector(btnDiffuse4.BackColor), ColorToVector(btnSpecular4.BackColor), StringToNormVector(tbLight4.Text)); } i++; } if (cbLight5.Checked) { if (cbPointLight5.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient5.BackColor), ColorToVector(btnDiffuse5.BackColor), ColorToVector(btnSpecular5.BackColor), c1, c2, c3, StringToVector(tbLight5.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient5.BackColor), ColorToVector(btnDiffuse5.BackColor), ColorToVector(btnSpecular5.BackColor), StringToNormVector(tbLight5.Text)); } i++; } L.Ground = new Material(ColorToVector(btnAmbient.BackColor), ColorToVector(btnDiffuse.BackColor), ColorToVector(btnSpecular.BackColor)); float AllTime = 0, t; PerfCounter Counter1 = new PerfCounter(); Counter1.Start(); Convolution[] Convs = new Convolution[3]; Convs[0].Operation = Operation.Plus; Convs[1].Operation = (Operation)cmbOp2.SelectedIndex; Convs[2].Operation = (Operation)cmbOp3.SelectedIndex; Convs[0].Coef = Convert.ToDouble(tbCoef1.Text); Convs[1].Coef = Convert.ToDouble(tbCoef2.Text); Convs[2].Coef = Convert.ToDouble(tbCoef3.Text); L.GenerateHeightmap(Convert.ToInt32(tbSizeX.Text), Convert.ToInt32(tbSizeY.Text), (GenMethod)cmbGenMethod.SelectedIndex, Convs, cbSmoothing.Checked, cbValley.Checked, cbIsland.Checked); t = Counter1.Finish(); lblHeightmapTime.Text = Convert.ToString(t); AllTime += t; L.BuildMesh(new Vector(Convert.ToDouble(tbSizeX.Text), Convert.ToDouble(tbSizeY.Text), Convert.ToDouble(tbSizeZ.Text))); Counter1.Start(); L.BuildLightmap(Sources, 2); t = Counter1.Finish(); lblLightmapTime.Text = Convert.ToString(t); AllTime += t; Counter1.Start(); L.GenerateColormap(Colors, 1); t = Counter1.Finish(); lblTextureTime.Text = Convert.ToString(t); AllTime += t; lblAllTime.Text = Convert.ToString(AllTime); string DirName; /*if (tbDir.Text[0] == '.') * { * DirName = "../../" + tbDir.Text + "/" + tbName.Text; * Directory.CreateDirectory(DirName); * } * else*/ DirName = tbDir.Text + "/" + tbName.Text; Bitmap B1, B2, B3; L.SaveHeightmap(DirName + "/Heightmap.bmp", out B1); L.SaveLightmap(DirName + "/Lightmap.bmp", out B2); L.SaveColormap(DirName + "/Texture.bmp", out B3); //pictureBox1.Image = B1; Bitmap B = new Bitmap(L.SizeX, L.SizeY); for (i = 0; i < B.Width; i++) { for (j = 0; j < B.Height; j++) { byte X = Convert.ToByte(L.Heightmap[i, j] * 255); B.SetPixel(i, j, Color.FromArgb(X, X, X)); } } pictureBox1.Image = B; pictureBox2.Image = B2; pictureBox3.Image = B3; pictureBox1.Refresh(); pictureBox2.Refresh(); pictureBox3.Refresh(); SaveSettings("EditorSettings.ini"); }