-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUIControl.cs
191 lines (170 loc) · 7.67 KB
/
UIControl.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;
public class UIControl : MonoBehaviour {
private Canvas canvas;
public Slider sliderSphere1X;
public Slider sliderSphere1Y;
public Slider sliderSphere2X;
public Slider sliderSphere2Y;
public Slider numBouncSlider;
public Slider lightSliderX;
public Slider lightSliderY;
public Slider lightSliderZ;
public Toggle sphere1ReflectionToggle;
public Toggle sphere2ReflectionToggle;
public Button addSphereButton;
public Button removeSphereButton;
public InputField xInput;
public InputField yInput;
public InputField zInput;
public Toggle newSphereReflectionToggle;
public PhotonMappingStart rayTracing;
public Plane plane;
public float sliderSphere1XOld;
public float sliderSphere1YOld;
public float sliderSphere2XOld;
public float sliderSphere2YOld;
public float numBounceSliderOld;
public float lightSliderXOld;
public float lightSliderYOld;
public float lightSliderZOld;
public bool sphere1ReflectionOld;
public bool sphere2ReflectionOld;
public float newValue;
public bool newReflectionToggle;
public int numOfSpheresOld;
public int numOfSpheresNew;
// Use this for initialization
void Start () {
canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
sliderSphere1X = GameObject.Find("Slider").GetComponent<Slider>();
sliderSphere1Y = GameObject.Find("Slider (1)").GetComponent<Slider>();
sliderSphere2X = GameObject.Find("Slider (2)").GetComponent<Slider>();
sliderSphere2Y = GameObject.Find("Slider (3)").GetComponent<Slider>();
numBouncSlider = GameObject.Find("Slider (4)").GetComponent<Slider>();
lightSliderX = GameObject.Find("Slider (5)").GetComponent<Slider>();
lightSliderY = GameObject.Find("Slider (6)").GetComponent<Slider>();
lightSliderZ = GameObject.Find("Slider (7)").GetComponent<Slider>();
sphere1ReflectionToggle = GameObject.Find("Toggle").GetComponent<Toggle>();
sphere2ReflectionToggle = GameObject.Find("Toggle (1)").GetComponent<Toggle>();
newSphereReflectionToggle = GameObject.Find("Toggle (2)").GetComponent<Toggle>();
addSphereButton = GameObject.Find("Button").GetComponent<Button>();
removeSphereButton = GameObject.Find("Button (1)").GetComponent<Button>();
addSphereButton.onClick.AddListener(addSphere);
removeSphereButton.onClick.AddListener(removeSphere);
xInput = GameObject.Find("InputField").GetComponent<InputField>();
yInput = GameObject.Find("InputField (1)").GetComponent<InputField>();
zInput = GameObject.Find("InputField (2)").GetComponent<InputField>();
//plane = GameObject.Find("Plane").GetComponent<Plane>();
sliderSphere1X.value = sliderSphere1XOld = PhotonMappingStart.objects.getSphereData(0,0);
sliderSphere1Y.value = sliderSphere1YOld = PhotonMappingStart.objects.getSphereData(0,1);
sliderSphere2X.value = sliderSphere2XOld = PhotonMappingStart.objects.getSphereData(1,0);
sliderSphere2Y.value = sliderSphere2YOld = PhotonMappingStart.objects.getSphereData(1,1);
numBouncSlider.value = numBounceSliderOld = PhotonMappingStart.photonMap.getNumberOfBounces();
lightSliderX.value = lightSliderXOld = PhotonMappingStart.lightSource[0];
lightSliderY.value = lightSliderYOld = PhotonMappingStart.lightSource[1];
lightSliderZ.value = lightSliderZOld = PhotonMappingStart.lightSource[2];
sphere1ReflectionToggle.isOn = sphere1ReflectionOld = PhotonMappingStart.metalObject[0];
sphere2ReflectionToggle.isOn = sphere2ReflectionOld = PhotonMappingStart.metalObject[1];
numOfSpheresOld = numOfSpheresNew = PhotonMappingStart.objects.getObjectsPerType(0);
}
void addSphere()
{
numOfSpheresNew++;
}
void removeSphere()
{
numOfSpheresNew--;
}
// Update is called once per frame
void Update () {
newValue = sliderSphere1X.value;
if (newValue != sliderSphere1XOld)
{
PhotonMappingStart.objects.setSphereData(0,0, newValue);
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
sliderSphere1XOld = newValue;
}
newValue = sliderSphere1Y.value;
if (newValue != sliderSphere1YOld)
{
PhotonMappingStart.objects.setSphereData(0, 1, newValue);
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
sliderSphere1YOld = newValue;
}
newValue = sliderSphere2X.value;
if (newValue != sliderSphere2XOld)
{
PhotonMappingStart.objects.setSphereData(1, 0, newValue);
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
sliderSphere2XOld = newValue;
}
newValue = sliderSphere2Y.value;
if (newValue != sliderSphere2YOld)
{
PhotonMappingStart.objects.setSphereData(1, 1, newValue);
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
sliderSphere2YOld = newValue;
}
newValue = numBouncSlider.value;
if (newValue != numBounceSliderOld)
{
PhotonMappingStart.photonMap.setNumberOfBounces((int)newValue);
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
numBounceSliderOld = newValue;
}
newValue = lightSliderX.value;
if (newValue != lightSliderXOld)
{
PhotonMappingStart.lightSource[0] = newValue;
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
lightSliderXOld = newValue;
}
newValue = lightSliderY.value;
if (newValue != lightSliderYOld)
{
PhotonMappingStart.lightSource[1] = newValue;
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
lightSliderYOld = newValue;
}
newValue = lightSliderZ.value;
if (newValue != lightSliderZOld)
{
PhotonMappingStart.lightSource[2] = newValue;
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
lightSliderZOld = newValue;
}
newReflectionToggle = sphere1ReflectionToggle.isOn;
if(newReflectionToggle != sphere1ReflectionOld)
{
PhotonMappingStart.metalObject[0] = newReflectionToggle;
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
sphere1ReflectionOld = newReflectionToggle;
}
newReflectionToggle = sphere2ReflectionToggle.isOn;
if (newReflectionToggle != sphere2ReflectionOld)
{
PhotonMappingStart.metalObject[1] = newReflectionToggle;
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
sphere2ReflectionOld = newReflectionToggle;
}
if (numOfSpheresNew != numOfSpheresOld)
{
PhotonMappingStart.objects.objectsPerType[0] = numOfSpheresNew;
if (numOfSpheresNew > numOfSpheresOld)
{
PhotonMappingStart.objects.setSphereData(numOfSpheresNew-1, 0, float.Parse(xInput.text));
PhotonMappingStart.objects.setSphereData(numOfSpheresNew-1, 1, float.Parse(yInput.text));
PhotonMappingStart.objects.setSphereData(numOfSpheresNew-1, 2, float.Parse(zInput.text));
if(newSphereReflectionToggle.isOn)
{
PhotonMappingStart.metalObject[numOfSpheresNew - 1] = true;
}
}
numOfSpheresOld = numOfSpheresNew;
GameObject.Find("Plane").GetComponent<PhotonMappingStart>().init();
}
}
}