-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathField.cs
86 lines (81 loc) · 3.05 KB
/
Field.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using utils;
namespace WindowsFormsRayTracing
{
class Field : GameObject
{
public vec3 n;
public float r;
private static int count = 0;
public Field(vec3 N, float R)
{
count++;
name = "Field_" + count;
n = N;
r = R;
color = Color.SandyBrown;
}
public override float Interspect(vec3 ro, vec3 rd)
{
float dotDN = Utils.dot(rd, n);
if (dotDN == 0) return -1;
return -(r - Utils.dot(ro, n)) / dotDN;
}
public override vec3 getNormal(vec3 dot)
{
return n;
}
public override void getInfo(ref GroupBox parent)
{
parent.Controls.Clear();
parent.Location = new Point(7, 108);
parent.Size = new Size(146, 121);
parent.Text = name;
Label l = new Label();
l.Text = "Расстояние: ";
parent.Controls.Add(l);
l.Location = new Point(6, 16);
TextBox t = new TextBox();
parent.Controls.Add(t);
t.Location = new Point(9, 40);
t.Size = new Size(53, 20);
t.Text = r.ToString();
Label l2 = new Label();
Label lX = new Label();
Label lY = new Label();
Label lZ = new Label();
l2.Text = "Нормаль: ";
parent.Controls.Add(l2);
l2.Location = new Point(6, 63);
TextBox tX = new TextBox();
TextBox tY = new TextBox();
TextBox tZ = new TextBox();
parent.Controls.Add(lX);
lX.Location = new Point(6, 90); lX.Text = "X:"; lX.Size = new Size(15, 13);
parent.Controls.Add(tX);
tX.Location = new Point(22, 87); tX.Size = new Size(25, 20);
parent.Controls.Add(lY);
lY.Location = new Point(53, 90); lY.Text = "Y:"; lY.Size = new Size(15, 13);
parent.Controls.Add(tY);
tY.Location = new Point(69, 87); tY.Size = new Size(25, 20);
parent.Controls.Add(lZ);
lZ.Location = new Point(100, 90); lZ.Text = "Z:"; lZ.Size = new Size(15, 13);
parent.Controls.Add(tZ);
tZ.Location = new Point(115, 87); tZ.Size = new Size(25, 20);
tX.Text = n.x.ToString();
tY.Text = n.y.ToString();
tZ.Text = n.z.ToString();
}
public override void setInfo(ref GroupBox parent, ref List<NumericUpDown> pos, ref List<NumericUpDown> col)
{
color = Color.FromArgb((int)col[0].Value, (int)col[1].Value, (int)col[2].Value);
r = float.Parse(parent.Controls[1].Text);
n.x = float.Parse(parent.Controls[4].Text);
n.y = float.Parse(parent.Controls[6].Text);
n.z = float.Parse(parent.Controls[8].Text);
}
}
}