Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
Object3D.java
....@@ -24,11 +24,17 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
3030 //
3131
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ byte[] versions[];
36
+ int versionindex = -1;
37
+
3238 ScriptNode scriptnode;
3339
3440 void InitOthers()
....@@ -170,24 +176,35 @@
170176
171177 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172178 {
179
+ Object3D o;
180
+
173181 if (hashtable.containsKey(GetUUID()))
174182 {
175
- Object3D o = hashtable.get(GetUUID());
183
+ o = hashtable.get(GetUUID());
176184
177
- assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
185
+ Grafreed.Assert(this.bRep == o.bRep);
186
+ //if (this.bRep != null)
187
+ // assert(this.bRep.support == o.transientrep);
188
+ if (this.support != null)
189
+ assert(this.support.bRep == o.transientrep);
190
+ }
191
+ else
192
+ {
193
+ o = new Object3D("copy of " + this.name);
180194
181
- return;
195
+ hashtable.put(GetUUID(), o);
182196 }
183197
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
198
+ if (!blockloop)
189199 {
190
- get(i).ExtractBigData(hashtable);
200
+ blockloop = true;
201
+
202
+ for (int i=0; i<Size(); i++)
203
+ {
204
+ get(i).ExtractBigData(hashtable);
205
+ }
206
+
207
+ blockloop = false;
191208 }
192209
193210 ExtractBigData(o);
....@@ -195,11 +212,26 @@
195212
196213 void ExtractBigData(Object3D o)
197214 {
215
+ if (o.bRep != null)
216
+ Grafreed.Assert(o.bRep == this.bRep);
217
+
198218 o.bRep = this.bRep;
199
- if (this.bRep != null)
219
+// July 2019 if (this.bRep != null)
220
+// {
221
+// o.transientrep = this.bRep.support;
222
+// o.bRep.support = null;
223
+// }
224
+ o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
227
+
228
+ if (this.support != null)
200229 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
230
+ if (o.transientrep != null)
231
+ Grafreed.Assert(o.transientrep == this.support.bRep);
232
+
233
+ o.transientrep = this.support.bRep;
234
+ this.support.bRep = null;
203235 }
204236
205237 // o.support = this.support;
....@@ -223,19 +255,35 @@
223255
224256 RestoreBigData(o);
225257
226
- hashtable.remove(GetUUID());
258
+ if (blockloop)
259
+ return;
260
+
261
+ blockloop = true;
262
+
263
+ //hashtable.remove(GetUUID());
227264
228265 for (int i=0; i<Size(); i++)
229266 {
230267 get(i).RestoreBigData(hashtable);
231268 }
269
+
270
+ blockloop = false;
232271 }
233272
234273 void RestoreBigData(Object3D o)
235274 {
236275 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
276
+ if (this.support != null && o.transientrep != null)
277
+ {
278
+ this.support.bRep = o.transientrep;
279
+ }
280
+
281
+ this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
285
+// July 2019 if (this.bRep != null)
286
+// this.bRep.support = o.transientrep;
239287 // this.support = o.support;
240288 // this.fileparent = o.fileparent;
241289 }
....@@ -381,6 +429,7 @@
381429 }
382430
383431 boolean live = false;
432
+ transient boolean keepdontselect;
384433 boolean dontselect = false;
385434 boolean hide = false;
386435 boolean link2master = false; // performs reset support/master at each frame
....@@ -563,12 +612,14 @@
563612 toParent = LA.newMatrix();
564613 fromParent = LA.newMatrix();
565614 }
615
+
566616 if (toParentMarked == null)
567617 {
568618 if (maxcount != 1)
569619 {
570620 new Exception().printStackTrace();
571621 }
622
+
572623 toParentMarked = LA.newMatrix();
573624 fromParentMarked = LA.newMatrix();
574625 }
....@@ -879,7 +930,7 @@
879930
880931 if (marked && Globals.isLIVE() && live &&
881932 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
933
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883934 currentframe != Globals.framecount)
884935 {
885936 currentframe = Globals.framecount;
....@@ -891,7 +942,8 @@
891942
892943 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893944
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
945
+ if (transformcount*factor >= maxcount && (rewind || random) ||
946
+ (step == 1 && changedir))
895947 {
896948 countdown = 1;
897949 delay = speedup?8:1;
....@@ -963,6 +1015,7 @@
9631015 if (material == null || material.multiply)
9641016 return true;
9651017
1018
+ // Transparent objects are dynamic because we have to sort the triangles.
9661019 return material.opacity > 0.99;
9671020 }
9681021
....@@ -1363,6 +1416,7 @@
13631416 toParent = LA.newMatrix();
13641417 fromParent = LA.newMatrix();
13651418 }
1419
+
13661420 LA.matCopy(other.toParent, toParent);
13671421 LA.matCopy(other.fromParent, fromParent);
13681422
....@@ -2384,6 +2438,10 @@
23842438 }
23852439 */
23862440 }
2441
+ else
2442
+ {
2443
+ //((ObjEditor)editWindow).SetupUI2(null);
2444
+ }
23872445 }
23882446
23892447 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2483,14 @@
24252483 {
24262484 editWindow.refreshContents();
24272485 }
2486
+ else
2487
+ {
2488
+ if (manipWindow != null)
2489
+ {
2490
+ manipWindow.refreshContents();
2491
+ }
2492
+ }
2493
+
24282494 //if (parent != null)
24292495 //parent.refreshEditWindow();
24302496 }
....@@ -2504,7 +2570,8 @@
25042570 private static final int editSelf = 1;
25052571 private static final int editChild = 2;
25062572
2507
- void drawEditHandles(ClickInfo info, int level)
2573
+ void drawEditHandles(//ClickInfo info,
2574
+ int level)
25082575 {
25092576 if (level == 0)
25102577 {
....@@ -2512,7 +2579,8 @@
25122579 return;
25132580
25142581 Object3D selectee;
2515
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2582
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2583
+ level + 1))
25162584 {
25172585 selectee = (Object3D) e.nextElement();
25182586 }
....@@ -2520,19 +2588,22 @@
25202588 } else
25212589 {
25222590 //super.
2523
- drawEditHandles0(info, level + 1);
2591
+ drawEditHandles0(//info,
2592
+ level + 1);
25242593 }
25252594 }
25262595
2527
- boolean doEditClick(ClickInfo info, int level)
2596
+ boolean doEditClick(//ClickInfo info,
2597
+ int level)
25282598 {
25292599 doSomething = 0;
25302600 if (level == 0)
25312601 {
2532
- return doParentClick(info);
2602
+ return doParentClick(); //info);
25332603 }
25342604 if (//super.
2535
- doEditClick0(info, level))
2605
+ doEditClick0(//info,
2606
+ level))
25362607 {
25372608 doSomething = 1;
25382609 return true;
....@@ -2542,7 +2613,7 @@
25422613 }
25432614 }
25442615
2545
- boolean doParentClick(ClickInfo info)
2616
+ boolean doParentClick() //ClickInfo info)
25462617 {
25472618 if (selection == null)
25482619 {
....@@ -2555,7 +2626,8 @@
25552626 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25562627 {
25572628 Object3D selectee = (Object3D) e.nextElement();
2558
- if (selectee.doEditClick(info, 1))
2629
+ if (selectee.doEditClick(//info,
2630
+ 1))
25592631 {
25602632 childToDrag = selectee;
25612633 doSomething = 2;
....@@ -2567,13 +2639,15 @@
25672639 return retval;
25682640 }
25692641
2570
- void doEditDrag(ClickInfo info, boolean opposite)
2642
+ void doEditDrag(//ClickInfo clickInfo,
2643
+ boolean opposite)
25712644 {
25722645 switch (doSomething)
25732646 {
25742647 case 1: // '\001'
25752648 //super.
2576
- doEditDrag0(info, opposite);
2649
+ doEditDrag0(//clickInfo,
2650
+ opposite);
25772651 break;
25782652
25792653 case 2: // '\002'
....@@ -2586,11 +2660,13 @@
25862660 {
25872661 //sel.hitSomething = childToDrag.hitSomething;
25882662 //childToDrag.doEditDrag(info);
2589
- sel.doEditDrag(info, opposite);
2663
+ sel.doEditDrag(//clickInfo,
2664
+ opposite);
25902665 } else
25912666 {
25922667 //super.
2593
- doEditDrag0(info, opposite);
2668
+ doEditDrag0(//clickInfo,
2669
+ opposite);
25942670 }
25952671 }
25962672 break;
....@@ -2608,6 +2684,9 @@
26082684 {
26092685 deselectAll();
26102686 }
2687
+
2688
+ new Exception().printStackTrace();
2689
+
26112690 ClickInfo newInfo = new ClickInfo();
26122691 newInfo.flags = info.flags;
26132692 newInfo.bounds = info.bounds;
....@@ -3055,7 +3134,7 @@
30553134 {
30563135 if (bRep != null)
30573136 {
3058
- bRep.GenerateNormalsMINE();
3137
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593138 Touch();
30603139 }
30613140 }
....@@ -3501,7 +3580,8 @@
35013580 if (blockloop)
35023581 return;
35033582
3504
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
35053585 live = h;
35063586
35073587 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3602,8 @@
35223602 return;
35233603
35243604 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3605
+ if (//marked || // does not make sense
3606
+ (bRep != null || material != null)) // borderline...
35263607 link2master = h;
35273608
35283609 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3623,8 @@
35423623 if (blockloop)
35433624 return;
35443625
3545
- if (marked || (bRep != null && material != null)) // borderline...
3626
+ if (//marked || // does not make sense
3627
+ (bRep != null || material != null)) // borderline...
35463628 hide = h;
35473629
35483630 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3644,7 @@
35623644 if (blockloop)
35633645 return;
35643646
3565
- if (bRep != null && material != null) // borderline...
3647
+ if (bRep != null || material != null) // borderline...
35663648 marked = h;
35673649
35683650 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3654,46 @@
35723654 continue;
35733655 blockloop = true;
35743656 child.MarkLeaves(h);
3657
+ blockloop = false;
3658
+ // release(i);
3659
+ }
3660
+ }
3661
+
3662
+ void RewindLeaves(boolean h)
3663
+ {
3664
+ if (blockloop)
3665
+ return;
3666
+
3667
+ if (bRep != null || material != null) // borderline...
3668
+ rewind = h;
3669
+
3670
+ for (int i = 0; i < Size(); i++)
3671
+ {
3672
+ Object3D child = (Object3D) get(i); // reserve(i);
3673
+ if (child == null)
3674
+ continue;
3675
+ blockloop = true;
3676
+ child.RewindLeaves(h);
3677
+ blockloop = false;
3678
+ // release(i);
3679
+ }
3680
+ }
3681
+
3682
+ void RandomLeaves(boolean h)
3683
+ {
3684
+ if (blockloop)
3685
+ return;
3686
+
3687
+ if (bRep != null || material != null) // borderline...
3688
+ random = h;
3689
+
3690
+ for (int i = 0; i < Size(); i++)
3691
+ {
3692
+ Object3D child = (Object3D) get(i); // reserve(i);
3693
+ if (child == null)
3694
+ continue;
3695
+ blockloop = true;
3696
+ child.RandomLeaves(h);
35753697 blockloop = false;
35763698 // release(i);
35773699 }
....@@ -4349,6 +4471,55 @@
43494471 }
43504472 }
43514473
4474
+ void RepairSOV()
4475
+ {
4476
+ if (blockloop)
4477
+ return;
4478
+
4479
+ String texname = this.GetPigmentTexture();
4480
+
4481
+ if (texname.startsWith("sov"))
4482
+ {
4483
+ String[] s = texname.split("/");
4484
+
4485
+ String[] sname = s[1].split("Color.pn");
4486
+
4487
+ texname = sname[0];
4488
+
4489
+ if (sname.length > 1)
4490
+ {
4491
+ texname += "Color.jpg";
4492
+ }
4493
+
4494
+ this.SetPigmentTexture("sov/" + texname);
4495
+ }
4496
+
4497
+ texname = this.GetBumpTexture();
4498
+
4499
+ if (texname.startsWith("sov"))
4500
+ {
4501
+ String[] s = texname.split("/");
4502
+
4503
+ String[] sname = s[1].split("Bump.pn");
4504
+
4505
+ texname = sname[0];
4506
+
4507
+ if (sname.length > 1)
4508
+ {
4509
+ texname += "Bump.jpg";
4510
+ }
4511
+
4512
+ this.SetBumpTexture("sov/" + texname);
4513
+ }
4514
+
4515
+ for (int i=0; i<Size(); i++)
4516
+ {
4517
+ blockloop = true;
4518
+ get(i).RepairSOV();
4519
+ blockloop = false;
4520
+ }
4521
+ }
4522
+
43524523 void RepairTexture()
43534524 {
43544525 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5034,14 @@
48635034 }
48645035 }
48655036
5037
+ ObjEditor GetWindow()
5038
+ {
5039
+ if (editWindow != null)
5040
+ return editWindow;
5041
+
5042
+ return manipWindow;
5043
+ }
5044
+
48665045 cTreePath Select(int indexcount, boolean deselect)
48675046 {
48685047 if (hide || dontselect)
....@@ -4899,10 +5078,11 @@
48995078 if (leaf != null)
49005079 {
49015080 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5081
+ ObjEditor window = GetWindow();
5082
+ if (window != null)
49035083 {
49045084 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5085
+ window.Select(tp, deselect, true);
49065086 }
49075087
49085088 return tp;
....@@ -4919,6 +5099,7 @@
49195099
49205100 if (child == null)
49215101 continue;
5102
+
49225103 if (child.HasTransparency() && child.size() != 0)
49235104 {
49245105 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5109,10 @@
49285109 if (leaf != null)
49295110 {
49305111 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5112
+ ObjEditor window = GetWindow();
5113
+ if (window != null)
49325114 {
4933
- editWindow.Select(tp, deselect, true);
5115
+ window.Select(tp, deselect, true);
49345116 }
49355117
49365118 return tp;
....@@ -5255,6 +5437,51 @@
52555437 blockloop = false;
52565438 }
52575439
5440
+ void ResetSelectable()
5441
+ {
5442
+ if (blockloop)
5443
+ return;
5444
+
5445
+ blockloop = true;
5446
+
5447
+ keepdontselect = dontselect;
5448
+ dontselect = true;
5449
+
5450
+ Object3D child;
5451
+ int nb = Size();
5452
+ for (int i = 0; i < nb; i++)
5453
+ {
5454
+ child = (Object3D) get(i);
5455
+ if (child == null)
5456
+ continue;
5457
+ child.ResetSelectable();
5458
+ }
5459
+
5460
+ blockloop = false;
5461
+ }
5462
+
5463
+ void RestoreSelectable()
5464
+ {
5465
+ if (blockloop)
5466
+ return;
5467
+
5468
+ blockloop = true;
5469
+
5470
+ dontselect = keepdontselect;
5471
+
5472
+ Object3D child;
5473
+ int nb = Size();
5474
+ for (int i = 0; i < nb; i++)
5475
+ {
5476
+ child = (Object3D) get(i);
5477
+ if (child == null)
5478
+ continue;
5479
+ child.RestoreSelectable();
5480
+ }
5481
+
5482
+ blockloop = false;
5483
+ }
5484
+
52585485 boolean IsSelected()
52595486 {
52605487 if (parent == null)
....@@ -5564,6 +5791,38 @@
55645791 }
55655792 }
55665793
5794
+ void EmbedTextures(boolean embed)
5795
+ {
5796
+ if (blockloop)
5797
+ return;
5798
+
5799
+ //if (GetTextures() != null)
5800
+ if (embed)
5801
+ CameraPane.EmbedTextures(GetTextures());
5802
+ else
5803
+ {
5804
+ GetTextures().pigmentdata = null;
5805
+ GetTextures().bumpdata = null;
5806
+ GetTextures().pw = 0;
5807
+ GetTextures().ph = 0;
5808
+ GetTextures().bw = 0;
5809
+ GetTextures().bh = 0;
5810
+ }
5811
+
5812
+ int nb = Size();
5813
+ for (int i = 0; i < nb; i++)
5814
+ {
5815
+ Object3D child = (Object3D) get(i);
5816
+
5817
+ if (child == null)
5818
+ continue;
5819
+
5820
+ blockloop = true;
5821
+ child.EmbedTextures(embed);
5822
+ blockloop = false;
5823
+ }
5824
+ }
5825
+
55675826 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685827 {
55695828 Draw(display, root, selected, blocked);
....@@ -5572,12 +5831,23 @@
55725831 boolean NeedSupport()
55735832 {
55745833 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5834
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765835 // PROBLEM with CROWD!!
55775836 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785837 }
55795838
55805839 static boolean DEBUG_SELECTION = false;
5840
+
5841
+ boolean IsLive()
5842
+ {
5843
+ if (live)
5844
+ return true;
5845
+
5846
+ if (parent == null)
5847
+ return false;
5848
+
5849
+ return parent.IsLive();
5850
+ }
55815851
55825852 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835853 {
....@@ -5640,7 +5910,7 @@
56405910 support = support;
56415911
56425912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5643
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5913
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445914
56455915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465916 {
....@@ -5660,10 +5930,12 @@
56605930 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615931
56625932 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5933
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5934
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645935 {
56655936 Globals.lighttouched = true;
56665937 } // all panes...
5938
+
56675939 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685940 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695941 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5791,6 +6063,7 @@
57916063 if (GetBRep() != null)
57926064 {
57936065 display.NextIndex();
6066
+
57946067 // vertex color conflict : gl.glCallList(list);
57956068 DrawNode(display, root, selected);
57966069 if (this instanceof BezierPatch)
....@@ -5831,16 +6104,27 @@
58316104 tex = GetTextures();
58326105 }
58336106
5834
- boolean failed = false;
6107
+ boolean failedPigment = false;
6108
+ boolean failedBump = false;
58356109
58366110 try
58376111 {
5838
- display.BindTextures(tex, texres);
6112
+ display.BindPigmentTexture(tex, texres);
58396113 }
58406114 catch (Exception e)
58416115 {
58426116 System.err.println("FAILED: " + this);
5843
- failed = true;
6117
+ failedPigment = true;
6118
+ }
6119
+
6120
+ try
6121
+ {
6122
+ display.BindBumpTexture(tex, texres);
6123
+ }
6124
+ catch (Exception e)
6125
+ {
6126
+ //System.err.println("FAILED: " + this);
6127
+ failedBump = true;
58446128 }
58456129
58466130 if (!compiled)
....@@ -5863,8 +6147,11 @@
58636147 }
58646148 }
58656149
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6150
+ if (!failedBump)
6151
+ display.ReleaseBumpTexture(tex);
6152
+
6153
+ if (!failedPigment)
6154
+ display.ReleasePigmentTexture(tex);
58686155
58696156 display.PopMaterial(this, selected);
58706157 }
....@@ -6237,6 +6524,11 @@
62376524 // dec 2012
62386525 new Exception().printStackTrace();
62396526 return;
6527
+ }
6528
+
6529
+ if (dontselect)
6530
+ {
6531
+ //bRep.GenerateNormalsMINE();
62406532 }
62416533
62426534 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7022,20 +7314,23 @@
70227314 }
70237315 }
70247316
7025
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7317
+ static ClickInfo clickInfo = new ClickInfo();
7318
+
7319
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7320
+ Point outPt, Rectangle outRec)
70267321 {
7027
- int hc = info.bounds.x + info.bounds.width / 2;
7028
- int vc = info.bounds.y + info.bounds.height / 2;
7029
- double[][] toscreen = info.toScreen;
7322
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7323
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7324
+ double[][] toscreen = clickInfo.toScreen;
70307325 if (toscreen == null)
70317326 {
7032
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70337328 }
70347329 cVector vec = in;
70357330 LA.xformPos(in, toscreen, in);
70367331 //System.out.println("Distance = " + info.camera.Distance());
7037
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7038
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7332
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7333
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70397334 outPt.x = hc + (int) vec.x;
70407335 outPt.y = vc - (int) vec.y;
70417336 outRec.x = outPt.x - 3;
....@@ -7043,15 +7338,18 @@
70437338 outRec.width = outRec.height = 6;
70447339 }
70457340
7046
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
70477343 {
70487344 Point pt = new Point(0, 0);
70497345 Rectangle rec = new Rectangle();
7050
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
70517348 return rec;
70527349 }
70537350
7054
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
70557353 {
70567354 if (level == 0)
70577355 {
....@@ -7060,16 +7358,19 @@
70607358 {
70617359 cVector origin = new cVector();
70627360 //LA.xformPos(origin, toParent, origin);
7063
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70647365 Rectangle boundary = new Rectangle();
70657366 boundary.x = spot.x - 30;
70667367 boundary.y = spot.y - 30;
70677368 boundary.width = spot.width + 60;
70687369 boundary.height = spot.height + 60;
7069
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
70707371 int spotw = spot.x + spot.width;
70717372 int spoth = spot.y + spot.height;
7072
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70737374 // if (CameraPane.Xmin > spot.x)
70747375 // {
70757376 // CameraPane.Xmin = spot.x;
....@@ -7089,8 +7390,8 @@
70897390 spot.translate(32, 32);
70907391 spotw = spot.x + spot.width;
70917392 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7093
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7393
+ clickInfo.g.setColor(Color.cyan);
7394
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947395 // if (CameraPane.Xmin > spot.x)
70957396 // {
70967397 // CameraPane.Xmin = spot.x;
....@@ -7107,11 +7408,12 @@
71077408 // {
71087409 // CameraPane.Ymax = spoth;
71097410 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7411
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7412
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127413 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7114
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7414
+ clickInfo.g.setColor(Color.yellow);
7415
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7416
+ clickInfo.g.setColor(Color.green);
71157417 // if (CameraPane.Xmin > spot.x)
71167418 // {
71177419 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7430,8 @@
71287430 // {
71297431 // CameraPane.Ymax = spoth;
71307432 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7433
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7434
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71337435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347436 // if (CameraPane.Xmin > boundary.x)
71357437 // {
....@@ -7151,7 +7453,8 @@
71517453 }
71527454 }
71537455
7154
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
71557458 {
71567459 if (level == 0)
71577460 {
....@@ -7160,8 +7463,8 @@
71607463
71617464 boolean retval = false;
71627465
7163
- startX = info.x;
7164
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
71657468
71667469 hitSomething = -1;
71677470 cVector origin = new cVector();
....@@ -7171,22 +7474,51 @@
71717474 {
71727475 centerPt = new Point(0, 0);
71737476 }
7174
- calcHotSpot(origin, info, centerPt, spot);
7175
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
71767480 {
71777481 hitSomething = hitCenter;
71787482 retval = true;
71797483 }
71807484 spot.translate(32, 0);
7181
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
71827486 {
71837487 hitSomething = hitRotate;
71847488 retval = true;
71857489 }
71867490 spot.translate(0, 32);
7187
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
71887492 {
71897493 hitSomething = hitScale;
7494
+
7495
+ double scale = 0.005f * clickInfo.camera.Distance();
7496
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7497
+ double sign = 1;
7498
+ if (hScale < 0)
7499
+ {
7500
+ sign = -1;
7501
+ }
7502
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7503
+ if (hScale < 0.01)
7504
+ {
7505
+ //hScale = 0.01;
7506
+ }
7507
+
7508
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7509
+ sign = 1;
7510
+ if (vScale < 0)
7511
+ {
7512
+ sign = -1;
7513
+ }
7514
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7515
+ if (vScale < 0.01)
7516
+ {
7517
+ //vScale = 0.01;
7518
+ }
7519
+
7520
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7521
+
71907522 retval = true;
71917523 }
71927524
....@@ -7196,7 +7528,7 @@
71967528 }
71977529
71987530 //System.out.println("info.modifiers = " + info.modifiers);
7199
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72007532 //System.out.println("modified = " + modified);
72017533 //new Exception().printStackTrace();
72027534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7224,7 +7556,8 @@
72247556 return true;
72257557 }
72267558
7227
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
72287561 {
72297562 if (hitSomething == 0)
72307563 {
....@@ -7238,7 +7571,7 @@
72387571
72397572 //System.out.println("hitSomething = " + hitSomething);
72407573
7241
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
72427575
72437576 cVector xlate = new cVector();
72447577 //cVector xlate2 = new cVector();
....@@ -7272,8 +7605,8 @@
72727605 toParent[3][i] = xlate.get(i);
72737606 LA.matInvert(toParent, fromParent);
72747607 */
7275
- cVector delta = LA.newVector(0, 0, startY - info.y);
7276
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7608
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7609
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72777610
72787611 LA.matCopy(startMat, toParent);
72797612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7282,7 +7615,7 @@
72827615 } else
72837616 {
72847617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7285
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
72867619 cVector away = new cVector();
72877620 //cVector right2 = new cVector();
72887621 //LA.vecCross(up, cVector.Z, right);
....@@ -7299,19 +7632,19 @@
72997632 LA.xformDir(up, ClickInfo.matbuffer, up);
73007633 // if (!CameraPane.LOCALTRANSFORM)
73017634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7302
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73037636 // if (!CameraPane.LOCALTRANSFORM)
73047637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73057638 //LA.vecCross(up, cVector.Z, right2);
73067639
7307
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73087641
73097642 //System.out.println("DELTA0 = " + delta);
73107643 //System.out.println("AWAY = " + info.camera.away);
73117644 //System.out.println("UP = " + info.camera.up);
73127645 if (away.z > 0)
73137646 {
7314
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73157648 {
73167649 delta.x = -delta.x;
73177650 } else
....@@ -7326,7 +7659,7 @@
73267659 //System.out.println("DELTA1 = " + delta);
73277660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73287661 //System.out.println("DELTA2 = " + delta);
7329
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73307663 LA.matCopy(startMat, toParent);
73317664 //System.out.println("DELTA3 = " + delta);
73327665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7336,8 +7669,8 @@
73367669 break;
73377670
73387671 case hitRotate: // rotate
7339
- int dx = info.x - centerPt.x;
7340
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
73417674 double angle = (double) Math.atan2(dx, dy);
73427675 angle = -(1.570796 - angle);
73437676
....@@ -7360,7 +7693,7 @@
73607693 }
73617694 /**/
73627695
7363
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
73647697 {
73657698 case 1: // '\001'
73667699 LA.matZRotate(toParent, angle);
....@@ -7387,7 +7720,7 @@
73877720 break;
73887721
73897722 case hitScale: // scale
7390
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
73917724 double sign = 1;
73927725 if (hScale < 0)
73937726 {
....@@ -7399,7 +7732,7 @@
73997732 //hScale = 0.01;
74007733 }
74017734
7402
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
74037736 sign = 1;
74047737 if (vScale < 0)
74057738 {
....@@ -7410,6 +7743,7 @@
74107743 {
74117744 //vScale = 0.01;
74127745 }
7746
+
74137747 LA.matCopy(startMat, toParent);
74147748 /**/
74157749 for (int i = 0; i < 3; i++)
....@@ -7419,29 +7753,30 @@
74197753 }
74207754 /**/
74217755
7422
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74237757
74247758 if (totalScale < 0.01)
74257759 {
74267760 totalScale = 0.01;
74277761 }
74287762
7429
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
74307764 {
74317765 case 3: // '\001'
7432
- if (modified)
7766
+ if (modified || opposite)
74337767 {
74347768 //LA.matScale(toParent, 1, hScale, vScale);
74357769 LA.matScale(toParent, totalScale, 1, 1);
74367770 } // vScale, 1);
74377771 else
74387772 {
7773
+ // EXCEPTION!
74397774 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407775 } // vScale, 1);
74417776 break;
74427777
74437778 case 2: // '\002'
7444
- if (modified)
7779
+ if (modified || opposite)
74457780 {
74467781 //LA.matScale(toParent, hScale, 1, vScale);
74477782 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7787,7 @@
74527787 break;
74537788
74547789 case 1: // '\003'
7455
- if (modified)
7790
+ if (modified || opposite)
74567791 {
74577792 //LA.matScale(toParent, hScale, vScale, 1);
74587793 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7492,7 +7827,7 @@
74927827 } // NEW ...
74937828
74947829
7495
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
74967831 }
74977832
74987833 boolean overflow = false;
....@@ -7672,6 +8007,10 @@
76728007 editWindow = null;
76738008 } // ?
76748009 }
8010
+ else
8011
+ {
8012
+ //editWindow.closeUI();
8013
+ }
76758014 }
76768015
76778016 boolean root; // patch for edit windows
....@@ -7829,6 +8168,10 @@
78298168 }
78308169
78318170 transient ObjEditor editWindow;
8171
+ transient ObjEditor manipWindow;
8172
+
8173
+ transient boolean pinned;
8174
+
78328175 transient ObjectUI objectUI;
78338176 public static int povDepth = 0;
78348177 private static cVector tbMin = new cVector();