Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
Object3D.java
....@@ -22,12 +22,21 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
3140
3241 ScriptNode scriptnode;
3342
....@@ -170,24 +179,35 @@
170179
171180 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172181 {
182
+ Object3D o;
183
+
173184 if (hashtable.containsKey(GetUUID()))
174185 {
175
- Object3D o = hashtable.get(GetUUID());
186
+ o = hashtable.get(GetUUID());
176187
177188 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
180197
181
- return;
198
+ hashtable.put(GetUUID(), o);
182199 }
183200
184
- Object3D o = new Object3D("copy of " + this.name);
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
201
+ if (!blockloop)
189202 {
190
- get(i).ExtractBigData(hashtable);
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
191211 }
192212
193213 ExtractBigData(o);
....@@ -195,11 +215,26 @@
195215
196216 void ExtractBigData(Object3D o)
197217 {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
198221 o.bRep = this.bRep;
199
- if (this.bRep != null)
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
200232 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
203238 }
204239
205240 // o.support = this.support;
....@@ -214,19 +249,86 @@
214249 // this.fileparent = null;
215250 }
216251
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ transient boolean tag;
276
+
277
+ void TagObjects(Object3D o, boolean tag)
278
+ {
279
+ if (blockloop)
280
+ return;
281
+
282
+ o.tag = tag;
283
+
284
+ if (o == this)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).TagObjects(o, tag);
292
+ }
293
+
294
+ blockloop = false;
295
+ }
296
+
297
+ boolean HasTags()
298
+ {
299
+ if (blockloop)
300
+ return false;
301
+
302
+ blockloop = true;
303
+
304
+ boolean hasTags = false;
305
+
306
+ for (int i=0; i<Size(); i++)
307
+ {
308
+ hasTags |= get(i).tag || get(i).HasTags();
309
+
310
+ if (hasTags)
311
+ break;
312
+ }
313
+
314
+ blockloop = false;
315
+
316
+ return hasTags;
317
+ }
318
+
217319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218320 {
219321 if (!hashtable.containsKey(GetUUID()))
220322 return;
221323
324
+ Object3D o = hashtable.get(GetUUID());
325
+
326
+ RestoreBigData(o);
327
+
222328 if (blockloop)
223329 return;
224330
225331 blockloop = true;
226
-
227
- Object3D o = hashtable.get(GetUUID());
228
-
229
- RestoreBigData(o);
230332
231333 //hashtable.remove(GetUUID());
232334
....@@ -241,8 +343,17 @@
241343 void RestoreBigData(Object3D o)
242344 {
243345 this.bRep = o.bRep;
244
- if (this.bRep != null)
245
- this.bRep.support = o.transientrep;
346
+ if (this.support != null && o.transientrep != null)
347
+ {
348
+ this.support.bRep = o.transientrep;
349
+ }
350
+
351
+ this.selection = o.selection;
352
+
353
+ this.versionlist = o.versionlist;
354
+ this.versionindex = o.versionindex;
355
+// July 2019 if (this.bRep != null)
356
+// this.bRep.support = o.transientrep;
246357 // this.support = o.support;
247358 // this.fileparent = o.fileparent;
248359 }
....@@ -388,6 +499,7 @@
388499 }
389500
390501 boolean live = false;
502
+ transient boolean keepdontselect;
391503 boolean dontselect = false;
392504 boolean hide = false;
393505 boolean link2master = false; // performs reset support/master at each frame
....@@ -575,7 +687,7 @@
575687 {
576688 if (maxcount != 1)
577689 {
578
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
579691 }
580692
581693 toParentMarked = LA.newMatrix();
....@@ -972,6 +1084,9 @@
9721084
9731085 if (material == null || material.multiply)
9741086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
9751090
9761091 // Transparent objects are dynamic because we have to sort the triangles.
9771092 return material.opacity > 0.99;
....@@ -1374,6 +1489,7 @@
13741489 toParent = LA.newMatrix();
13751490 fromParent = LA.newMatrix();
13761491 }
1492
+
13771493 LA.matCopy(other.toParent, toParent);
13781494 LA.matCopy(other.fromParent, fromParent);
13791495
....@@ -2253,11 +2369,6 @@
22532369
22542370 InitOthers();
22552371
2256
- if (this instanceof Camera)
2257
- {
2258
- material.shift = 90;
2259
- }
2260
-
22612372 material.multiply = multiply;
22622373
22632374 if (multiply)
....@@ -2398,6 +2509,11 @@
23982509 else
23992510 {
24002511 //((ObjEditor)editWindow).SetupUI2(null);
2512
+ if (objectUI != null)
2513
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2514
+ else
2515
+ //new Exception().printStackTrace();
2516
+ System.err.println("objectUI is null");
24012517 }
24022518 }
24032519
....@@ -2527,7 +2643,8 @@
25272643 private static final int editSelf = 1;
25282644 private static final int editChild = 2;
25292645
2530
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25312648 {
25322649 if (level == 0)
25332650 {
....@@ -2535,7 +2652,8 @@
25352652 return;
25362653
25372654 Object3D selectee;
2538
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2655
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2656
+ level + 1))
25392657 {
25402658 selectee = (Object3D) e.nextElement();
25412659 }
....@@ -2543,19 +2661,22 @@
25432661 } else
25442662 {
25452663 //super.
2546
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25472666 }
25482667 }
25492668
2550
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25512671 {
25522672 doSomething = 0;
25532673 if (level == 0)
25542674 {
2555
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25562676 }
25572677 if (//super.
2558
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25592680 {
25602681 doSomething = 1;
25612682 return true;
....@@ -2565,7 +2686,7 @@
25652686 }
25662687 }
25672688
2568
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
25692690 {
25702691 if (selection == null)
25712692 {
....@@ -2578,7 +2699,8 @@
25782699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25792700 {
25802701 Object3D selectee = (Object3D) e.nextElement();
2581
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
25822704 {
25832705 childToDrag = selectee;
25842706 doSomething = 2;
....@@ -2590,13 +2712,15 @@
25902712 return retval;
25912713 }
25922714
2593
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
25942717 {
25952718 switch (doSomething)
25962719 {
25972720 case 1: // '\001'
25982721 //super.
2599
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26002724 break;
26012725
26022726 case 2: // '\002'
....@@ -2609,11 +2733,13 @@
26092733 {
26102734 //sel.hitSomething = childToDrag.hitSomething;
26112735 //childToDrag.doEditDrag(info);
2612
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26132738 } else
26142739 {
26152740 //super.
2616
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26172743 }
26182744 }
26192745 break;
....@@ -2631,6 +2757,9 @@
26312757 {
26322758 deselectAll();
26332759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26342763 ClickInfo newInfo = new ClickInfo();
26352764 newInfo.flags = info.flags;
26362765 newInfo.bounds = info.bounds;
....@@ -3078,7 +3207,7 @@
30783207 {
30793208 if (bRep != null)
30803209 {
3081
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30823211 Touch();
30833212 }
30843213 }
....@@ -3488,15 +3617,47 @@
34883617
34893618 void ClearMaterials()
34903619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
34913625 ClearMaterial();
3492
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
34933627 {
3494
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
34953629 if (child == null)
34963630 continue;
34973631 child.ClearMaterials();
3498
- release(i);
34993632 }
3633
+
3634
+ blockloop = false;
3635
+ }
3636
+
3637
+ void ClearVersionList()
3638
+ {
3639
+ this.versionlist = null;
3640
+ this.versionindex = -1;
3641
+ this.versiontable = null;
3642
+ }
3643
+
3644
+ void ClearVersions()
3645
+ {
3646
+ if (blockloop)
3647
+ return;
3648
+
3649
+ blockloop = true;
3650
+
3651
+ ClearVersionList();
3652
+ for (int i = 0; i < Size(); i++)
3653
+ {
3654
+ Object3D child = (Object3D) get(i);
3655
+ if (child == null)
3656
+ continue;
3657
+ child.ClearVersions();
3658
+ }
3659
+
3660
+ blockloop = false;
35003661 }
35013662
35023663 void FlipV(boolean flip)
....@@ -5381,6 +5542,51 @@
53815542 blockloop = false;
53825543 }
53835544
5545
+ void ResetSelectable()
5546
+ {
5547
+ if (blockloop)
5548
+ return;
5549
+
5550
+ blockloop = true;
5551
+
5552
+ keepdontselect = dontselect;
5553
+ dontselect = true;
5554
+
5555
+ Object3D child;
5556
+ int nb = Size();
5557
+ for (int i = 0; i < nb; i++)
5558
+ {
5559
+ child = (Object3D) get(i);
5560
+ if (child == null)
5561
+ continue;
5562
+ child.ResetSelectable();
5563
+ }
5564
+
5565
+ blockloop = false;
5566
+ }
5567
+
5568
+ void RestoreSelectable()
5569
+ {
5570
+ if (blockloop)
5571
+ return;
5572
+
5573
+ blockloop = true;
5574
+
5575
+ dontselect = keepdontselect;
5576
+
5577
+ Object3D child;
5578
+ int nb = Size();
5579
+ for (int i = 0; i < nb; i++)
5580
+ {
5581
+ child = (Object3D) get(i);
5582
+ if (child == null)
5583
+ continue;
5584
+ child.RestoreSelectable();
5585
+ }
5586
+
5587
+ blockloop = false;
5588
+ }
5589
+
53845590 boolean IsSelected()
53855591 {
53865592 if (parent == null)
....@@ -5441,6 +5647,11 @@
54415647 if (fullname == null)
54425648 return "";
54435649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54445655 // System.out.println("Fullname = " + fullname);
54455656
54465657 // Does not work on Windows due to C:
....@@ -5453,7 +5664,7 @@
54535664
54545665 if (split.length == 0)
54555666 {
5456
- return "";
5667
+ return fullname.pigment = "";
54575668 }
54585669
54595670 if (split.length <= 2)
....@@ -5461,22 +5672,27 @@
54615672 if (fullname.name.endsWith(":"))
54625673 {
54635674 // Windows
5464
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54655676 }
54665677
5467
- return split[0];
5678
+ return fullname.pigment = split[0];
54685679 }
54695680
54705681 // Windows
54715682 assert(split.length == 4);
54725683
5473
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
54745685 }
54755686
54765687 static String GetBump(cTexture fullname)
54775688 {
54785689 if (fullname == null)
54795690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
54805696
54815697 // System.out.println("Fullname = " + fullname);
54825698 // Does not work on Windows due to C:
....@@ -5488,12 +5704,12 @@
54885704
54895705 if (split.length == 0)
54905706 {
5491
- return "";
5707
+ return fullname.bump = "";
54925708 }
54935709
54945710 if (split.length == 1)
54955711 {
5496
- return "";
5712
+ return fullname.bump = "";
54975713 }
54985714
54995715 if (split.length == 2)
....@@ -5501,16 +5717,16 @@
55015717 if (fullname.name.endsWith(":"))
55025718 {
55035719 // Windows
5504
- return "";
5720
+ return fullname.bump = "";
55055721 }
55065722
5507
- return split[1];
5723
+ return fullname.bump = split[1];
55085724 }
55095725
55105726 // Windows
55115727 assert(split.length == 4);
55125728
5513
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55145730 }
55155731
55165732 String GetPigmentTexture()
....@@ -5593,6 +5809,9 @@
55935809 texname = "";
55945810
55955811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
55965815 Touch();
55975816 }
55985817
....@@ -5666,6 +5885,8 @@
56665885
56675886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56685887
5888
+ GetTextures().bump = null;
5889
+
56695890 Touch();
56705891 }
56715892
....@@ -5686,6 +5907,38 @@
56865907
56875908 blockloop = true;
56885909 child.ResetBumpTexture();
5910
+ blockloop = false;
5911
+ }
5912
+ }
5913
+
5914
+ void EmbedTextures(boolean embed)
5915
+ {
5916
+ if (blockloop)
5917
+ return;
5918
+
5919
+ //if (GetTextures() != null)
5920
+ if (embed)
5921
+ CameraPane.EmbedTextures(GetTextures());
5922
+ else
5923
+ {
5924
+ GetTextures().pigmentdata = null;
5925
+ GetTextures().bumpdata = null;
5926
+ GetTextures().pw = 0;
5927
+ GetTextures().ph = 0;
5928
+ GetTextures().bw = 0;
5929
+ GetTextures().bh = 0;
5930
+ }
5931
+
5932
+ int nb = Size();
5933
+ for (int i = 0; i < nb; i++)
5934
+ {
5935
+ Object3D child = (Object3D) get(i);
5936
+
5937
+ if (child == null)
5938
+ continue;
5939
+
5940
+ blockloop = true;
5941
+ child.EmbedTextures(embed);
56895942 blockloop = false;
56905943 }
56915944 }
....@@ -5776,8 +6029,10 @@
57766029 if (support != null)
57776030 support = support;
57786031
5779
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5780
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6032
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6033
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6034
+
6035
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57816036
57826037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57836038 {
....@@ -5787,8 +6042,9 @@
57876042 // usecalllists &= !(parent instanceof RandomNode);
57886043 // usecalllists = false;
57896044
5790
- if (GetBRep() != null)
5791
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
57926048 //System.out.println("draw " + this);
57936049 //new Exception().printStackTrace();
57946050
....@@ -5810,7 +6066,7 @@
58106066 if (!(this instanceof Composite))
58116067 touched = false;
58126068 //if (displaylist == -1 && usecalllists)
5813
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58146070 {
58156071 bRep.displaylist = display.GenList();
58166072 assert(bRep.displaylist != 0);
....@@ -5821,7 +6077,7 @@
58216077
58226078 //System.out.println("\tnew list " + list);
58236079 //gl.glDrawBuffer(gl.GL_NONE);
5824
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
58256081 {
58266082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58276083 display.NewList(bRep.displaylist);
....@@ -5830,7 +6086,7 @@
58306086 CallList(display, root, selected, blocked);
58316087
58326088 // compiled = true;
5833
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58346090 {
58356091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58366092 display.EndList();
....@@ -7181,20 +7437,23 @@
71817437 }
71827438 }
71837439
7184
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7440
+ static ClickInfo clickInfo = new ClickInfo();
7441
+
7442
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7443
+ Point outPt, Rectangle outRec)
71857444 {
7186
- int hc = info.bounds.x + info.bounds.width / 2;
7187
- int vc = info.bounds.y + info.bounds.height / 2;
7188
- double[][] toscreen = info.toScreen;
7445
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7446
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7447
+ double[][] toscreen = clickInfo.toScreen;
71897448 if (toscreen == null)
71907449 {
7191
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71927451 }
71937452 cVector vec = in;
71947453 LA.xformPos(in, toscreen, in);
71957454 //System.out.println("Distance = " + info.camera.Distance());
7196
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7197
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7455
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7456
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71987457 outPt.x = hc + (int) vec.x;
71997458 outPt.y = vc - (int) vec.y;
72007459 outRec.x = outPt.x - 3;
....@@ -7202,15 +7461,18 @@
72027461 outRec.width = outRec.height = 6;
72037462 }
72047463
7205
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
72067466 {
72077467 Point pt = new Point(0, 0);
72087468 Rectangle rec = new Rectangle();
7209
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
72107471 return rec;
72117472 }
72127473
7213
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
72147476 {
72157477 if (level == 0)
72167478 {
....@@ -7219,16 +7481,19 @@
72197481 {
72207482 cVector origin = new cVector();
72217483 //LA.xformPos(origin, toParent, origin);
7222
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72237488 Rectangle boundary = new Rectangle();
72247489 boundary.x = spot.x - 30;
72257490 boundary.y = spot.y - 30;
72267491 boundary.width = spot.width + 60;
72277492 boundary.height = spot.height + 60;
7228
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72297494 int spotw = spot.x + spot.width;
72307495 int spoth = spot.y + spot.height;
7231
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72327497 // if (CameraPane.Xmin > spot.x)
72337498 // {
72347499 // CameraPane.Xmin = spot.x;
....@@ -7245,11 +7510,6 @@
72457510 // {
72467511 // CameraPane.Ymax = spoth;
72477512 // }
7248
- spot.translate(32, 32);
7249
- spotw = spot.x + spot.width;
7250
- spoth = spot.y + spot.height;
7251
- info.g.setColor(Color.cyan);
7252
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72537513 // if (CameraPane.Xmin > spot.x)
72547514 // {
72557515 // CameraPane.Xmin = spot.x;
....@@ -7268,10 +7528,15 @@
72687528 // }
72697529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72707530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7271
- spot.translate(0, -32);
7272
- info.g.setColor(Color.yellow);
7273
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7274
- info.g.setColor(Color.green);
7531
+ spot.translate(32, 0);
7532
+ clickInfo.g.setColor(Color.yellow);
7533
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7534
+
7535
+ spot.translate(32, 64);
7536
+ spotw = spot.x + spot.width;
7537
+ spoth = spot.y + spot.height;
7538
+ clickInfo.g.setColor(Color.cyan);
7539
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72757540 // if (CameraPane.Xmin > spot.x)
72767541 // {
72777542 // CameraPane.Xmin = spot.x;
....@@ -7288,8 +7553,9 @@
72887553 // {
72897554 // CameraPane.Ymax = spoth;
72907555 // }
7291
- info.g.drawArc(boundary.x, boundary.y,
7292
- boundary.width, boundary.height, 0, 360);
7556
+ clickInfo.g.setColor(Color.green);
7557
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7558
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72937559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72947560 // if (CameraPane.Xmin > boundary.x)
72957561 // {
....@@ -7311,7 +7577,8 @@
73117577 }
73127578 }
73137579
7314
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
73157582 {
73167583 if (level == 0)
73177584 {
....@@ -7320,8 +7587,8 @@
73207587
73217588 boolean retval = false;
73227589
7323
- startX = info.x;
7324
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
73257592
73267593 hitSomething = -1;
73277594 cVector origin = new cVector();
....@@ -7331,22 +7598,53 @@
73317598 {
73327599 centerPt = new Point(0, 0);
73337600 }
7334
- calcHotSpot(origin, info, centerPt, spot);
7335
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73367604 {
73377605 hitSomething = hitCenter;
73387606 retval = true;
73397607 }
73407608 spot.translate(32, 0);
7341
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73427610 {
73437611 hitSomething = hitRotate;
73447612 retval = true;
73457613 }
73467614 spot.translate(0, 32);
7347
- if (spot.contains(info.x, info.y))
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
7617
+ if (spot.contains(clickInfo.x, clickInfo.y))
73487618 {
73497619 hitSomething = hitScale;
7620
+
7621
+ double scale = 0.005f * clickInfo.camera.Distance();
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7623
+ double sign = 1;
7624
+ if (hScale < 0)
7625
+ {
7626
+ sign = -1;
7627
+ }
7628
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7629
+ if (hScale < 0.01)
7630
+ {
7631
+ //hScale = 0.01;
7632
+ }
7633
+
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7635
+ sign = 1;
7636
+ if (vScale < 0)
7637
+ {
7638
+ sign = -1;
7639
+ }
7640
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7641
+ if (vScale < 0.01)
7642
+ {
7643
+ //vScale = 0.01;
7644
+ }
7645
+
7646
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7647
+
73507648 retval = true;
73517649 }
73527650
....@@ -7356,7 +7654,7 @@
73567654 }
73577655
73587656 //System.out.println("info.modifiers = " + info.modifiers);
7359
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73607658 //System.out.println("modified = " + modified);
73617659 //new Exception().printStackTrace();
73627660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7384,7 +7682,8 @@
73847682 return true;
73857683 }
73867684
7387
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
73887687 {
73897688 if (hitSomething == 0)
73907689 {
....@@ -7398,7 +7697,7 @@
73987697
73997698 //System.out.println("hitSomething = " + hitSomething);
74007699
7401
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
74027701
74037702 cVector xlate = new cVector();
74047703 //cVector xlate2 = new cVector();
....@@ -7412,7 +7711,9 @@
74127711
74137712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74147713
7415
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
74167717 {
74177718 //assert(false);
74187719 /*
....@@ -7432,8 +7733,8 @@
74327733 toParent[3][i] = xlate.get(i);
74337734 LA.matInvert(toParent, fromParent);
74347735 */
7435
- cVector delta = LA.newVector(0, 0, startY - info.y);
7436
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7736
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7737
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74377738
74387739 LA.matCopy(startMat, toParent);
74397740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7442,7 +7743,7 @@
74427743 } else
74437744 {
74447745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7445
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74467747 cVector away = new cVector();
74477748 //cVector right2 = new cVector();
74487749 //LA.vecCross(up, cVector.Z, right);
....@@ -7459,19 +7760,19 @@
74597760 LA.xformDir(up, ClickInfo.matbuffer, up);
74607761 // if (!CameraPane.LOCALTRANSFORM)
74617762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7462
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74637764 // if (!CameraPane.LOCALTRANSFORM)
74647765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74657766 //LA.vecCross(up, cVector.Z, right2);
74667767
7467
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74687769
74697770 //System.out.println("DELTA0 = " + delta);
74707771 //System.out.println("AWAY = " + info.camera.away);
74717772 //System.out.println("UP = " + info.camera.up);
74727773 if (away.z > 0)
74737774 {
7474
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74757776 {
74767777 delta.x = -delta.x;
74777778 } else
....@@ -7486,7 +7787,7 @@
74867787 //System.out.println("DELTA1 = " + delta);
74877788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74887789 //System.out.println("DELTA2 = " + delta);
7489
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74907791 LA.matCopy(startMat, toParent);
74917792 //System.out.println("DELTA3 = " + delta);
74927793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7496,8 +7797,8 @@
74967797 break;
74977798
74987799 case hitRotate: // rotate
7499
- int dx = info.x - centerPt.x;
7500
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
75017802 double angle = (double) Math.atan2(dx, dy);
75027803 angle = -(1.570796 - angle);
75037804
....@@ -7506,7 +7807,7 @@
75067807
75077808 if (modified)
75087809 {
7509
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
75107811 angle /= (Math.PI / 4);
75117812 angle = Math.floor(angle + 0.5);
75127813 angle *= (Math.PI / 4);
....@@ -7520,7 +7821,7 @@
75207821 }
75217822 /**/
75227823
7523
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
75247825 {
75257826 case 1: // '\001'
75267827 LA.matZRotate(toParent, angle);
....@@ -7547,7 +7848,7 @@
75477848 break;
75487849
75497850 case hitScale: // scale
7550
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75517852 double sign = 1;
75527853 if (hScale < 0)
75537854 {
....@@ -7559,7 +7860,7 @@
75597860 //hScale = 0.01;
75607861 }
75617862
7562
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75637864 sign = 1;
75647865 if (vScale < 0)
75657866 {
....@@ -7570,6 +7871,7 @@
75707871 {
75717872 //vScale = 0.01;
75727873 }
7874
+
75737875 LA.matCopy(startMat, toParent);
75747876 /**/
75757877 for (int i = 0; i < 3; i++)
....@@ -7579,33 +7881,39 @@
75797881 }
75807882 /**/
75817883
7582
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75837885
75847886 if (totalScale < 0.01)
75857887 {
75867888 totalScale = 0.01;
75877889 }
75887890
7589
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
75907892 {
75917893 case 3: // '\001'
75927894 if (modified || opposite)
75937895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
75947899 //LA.matScale(toParent, 1, hScale, vScale);
7595
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
75967901 } // vScale, 1);
75977902 else
75987903 {
75997904 // EXCEPTION!
7600
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
76017906 } // vScale, 1);
76027907 break;
76037908
76047909 case 2: // '\002'
76057910 if (modified || opposite)
76067911 {
7607
- //LA.matScale(toParent, hScale, 1, vScale);
7608
- LA.matScale(toParent, 1, totalScale, 1);
7912
+ if (modified) // && opposite)
7913
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7914
+ else
7915
+ //LA.matScale(toParent, hScale, 1, vScale);
7916
+ LA.matScale(toParent, 1, totalScale, 1);
76097917 } else
76107918 {
76117919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7615,8 +7923,11 @@
76157923 case 1: // '\003'
76167924 if (modified || opposite)
76177925 {
7618
- //LA.matScale(toParent, hScale, vScale, 1);
7619
- LA.matScale(toParent, 1, 1, totalScale);
7926
+ if (modified) // && opposite)
7927
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7928
+ else
7929
+ //LA.matScale(toParent, hScale, vScale, 1);
7930
+ LA.matScale(toParent, 1, 1, totalScale);
76207931 } else
76217932 {
76227933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7653,7 +7964,7 @@
76537964 } // NEW ...
76547965
76557966
7656
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76577968 }
76587969
76597970 boolean overflow = false;