Normand Briere
2019-09-18 f9325048496d7cdbcad233f8a6b84c88e79adcc2
Torus.java
....@@ -2,14 +2,14 @@
22
33 class Torus extends Biparam implements java.io.Serializable
44 {
5
- //static final long serialVersionUID = -7637054329820073252L;
5
+ static final long serialVersionUID = -7637054329820073252L; // Old
66
77 Torus()
88 {
99 inPnt = new cVector();
1010 name = "Torus";
11
- uDivs = 35; // 64;
12
- vDivs = 19; // 24;
11
+ uDivs = 61; // 35; // 64;
12
+ vDivs = 21; // 19; // 24;
1313 minUDivs = 3;
1414 minVDivs = 3;
1515 retile();
....@@ -25,9 +25,9 @@
2525 return t;
2626 }
2727
28
- protected void deepCopySelf(Object3D other)
28
+ protected void deepCopyNode(Object3D other)
2929 {
30
- super.deepCopySelf(other);
30
+ super.deepCopyNode(other);
3131 Torus t = (Torus)other;
3232 t.major = major;
3333 t.minor = minor;
....@@ -56,6 +56,11 @@
5656 buffer.append("}\n");
5757 }
5858
59
+ double uStretch()
60
+ {
61
+ return 6; // Actually 6.28 (I think)
62
+ }
63
+
5964 Vertex biparamFunction(double u, double v)
6065 {
6166 if (u == 1)
....@@ -64,7 +69,7 @@
6469 v = 0;
6570
6671 double uAng = u * 2 * Math.PI;
67
- double vAng = v * 2 * Math.PI;
72
+ double vAng = -v * 2 * Math.PI;
6873 double cosua = Math.cos(uAng);
6974 double sinua = Math.sin(uAng);
7075 double cosva = Math.cos(vAng);
....@@ -87,6 +92,9 @@
8792 //temp.pos = tPos; // useless new
8893 temp.norm = tNorm;
8994 LA.vecNormalize(temp.norm);
95
+
96
+ temp.y += minor;
97
+
9098 return temp;
9199 }
92100
....@@ -118,55 +126,59 @@
118126 return rad2 <= minor * minor;
119127 }
120128
121
- void drawEditHandles(ClickInfo info, int level)
129
+ void drawEditHandles(//ClickInfo info,
130
+ int level)
122131 {
123132 if (level == 0)
124133 {
125134 return;
126135 } else
127136 {
128
- super.drawEditHandles(info, level);
137
+ super.drawEditHandles(//info,
138
+ level);
129139 cVector temp = LA.newVector(0, 0, minor);
130140 LA.xformPos(temp, toParent, temp);
131
- Rectangle majorSpot = calcHotSpot(temp, info);
141
+ Rectangle majorSpot = calcHotSpot(temp); //, info);
132142 majorSpot.translate(4, 4);
133143 temp.x = major;
134144 temp.y = temp.z = 0;
135145 LA.xformPos(temp, toParent, temp);
136
- Rectangle minorSpot = calcHotSpot(temp, info);
146
+ Rectangle minorSpot = calcHotSpot(temp); //, info);
137147 minorSpot.translate(4, 4);
138
- info.g.setColor(Color.green);
139
- info.g.fillRect(majorSpot.x, majorSpot.y, majorSpot.width, majorSpot.height);
140
- info.g.fillRect(minorSpot.x, minorSpot.y, minorSpot.width, minorSpot.height);
148
+ clickInfo.g.setColor(Color.green);
149
+ clickInfo.g.fillRect(majorSpot.x, majorSpot.y, majorSpot.width, majorSpot.height);
150
+ clickInfo.g.fillRect(minorSpot.x, minorSpot.y, minorSpot.width, minorSpot.height);
141151 return;
142152 }
143153 }
144154
145
- boolean doEditClick(ClickInfo info, int level)
155
+ boolean doEditClick(//ClickInfo info,
156
+ int level)
146157 {
147158 if (level == 0)
148159 return false;
149160 hitSomething = 0;
150
- if (super.doEditClick(info, level))
161
+ if (super.doEditClick(//info,
162
+ level))
151163 {
152164 hitSomething = 1;
153165 return true;
154166 }
155167 cVector temp = LA.newVector(0, 0, minor);
156168 LA.xformPos(temp, toParent, temp);
157
- Rectangle majorSpot = calcHotSpot(temp, info);
169
+ Rectangle majorSpot = calcHotSpot(temp); //, info);
158170 majorSpot.translate(4, 4);
159171 temp.x = major;
160172 temp.y = temp.z = 0;
161173 LA.xformPos(temp, toParent, temp);
162
- Rectangle minorSpot = calcHotSpot(temp, info);
174
+ Rectangle minorSpot = calcHotSpot(temp); //, info);
163175 minorSpot.translate(4, 4);
164
- if (majorSpot.contains(info.x, info.y))
176
+ if (majorSpot.contains(clickInfo.x, clickInfo.y))
165177 {
166178 hitSomething = 2;
167179 startRad = major;
168180 } else
169
- if (minorSpot.contains(info.x, info.y))
181
+ if (minorSpot.contains(clickInfo.x, clickInfo.y))
170182 {
171183 hitSomething = 3;
172184 startRad = minor;
....@@ -174,23 +186,25 @@
174186 {
175187 return false;
176188 }
177
- startX = info.x;
189
+ startX = clickInfo.x;
178190 return true;
179191 }
180192
181
- void doEditDrag(ClickInfo info, boolean opposite)
193
+ void doEditDrag(//ClickInfo info,
194
+ boolean opposite)
182195 {
183196 if (hitSomething == 0)
184197 return;
185198 if (hitSomething == 1)
186199 {
187
- super.doEditDrag(info, opposite);
200
+ super.doEditDrag(//info,
201
+ opposite);
188202 return;
189203 }
190
- double deltaR = info.x - startX;
204
+ double deltaR = clickInfo.x - startX;
191205 //cVector delta = LA.newVector(info.x - startX, 0, 0);
192206 //LA.xformDir(delta, info.camera.fromScreen, delta);
193
- deltaR /= 100 * info.camera.SCALE / info.camera.Distance();
207
+ deltaR /= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
194208 double newRad = startRad + deltaR;
195209 if (newRad < 0)
196210 newRad = 0;
....@@ -199,7 +213,7 @@
199213 else
200214 minor = newRad;
201215 recalculate();
202
- info.pane.repaint();
216
+ clickInfo.pane.repaint();
203217 }
204218
205219 double major;