Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
Object3D.java
....@@ -24,11 +24,14 @@
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
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
3235 ScriptNode scriptnode;
3336
3437 void InitOthers()
....@@ -170,24 +173,35 @@
170173
171174 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172175 {
176
+ Object3D o;
177
+
173178 if (hashtable.containsKey(GetUUID()))
174179 {
175
- Object3D o = hashtable.get(GetUUID());
180
+ o = hashtable.get(GetUUID());
176181
177
- assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
180191
181
- return;
192
+ hashtable.put(GetUUID(), o);
182193 }
183194
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
195
+ if (!blockloop)
189196 {
190
- get(i).ExtractBigData(hashtable);
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
191205 }
192206
193207 ExtractBigData(o);
....@@ -195,11 +209,26 @@
195209
196210 void ExtractBigData(Object3D o)
197211 {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
198215 o.bRep = this.bRep;
199
- if (this.bRep != null)
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
200226 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
203232 }
204233
205234 // o.support = this.support;
....@@ -223,19 +252,35 @@
223252
224253 RestoreBigData(o);
225254
226
- hashtable.remove(GetUUID());
255
+ if (blockloop)
256
+ return;
257
+
258
+ blockloop = true;
259
+
260
+ //hashtable.remove(GetUUID());
227261
228262 for (int i=0; i<Size(); i++)
229263 {
230264 get(i).RestoreBigData(hashtable);
231265 }
266
+
267
+ blockloop = false;
232268 }
233269
234270 void RestoreBigData(Object3D o)
235271 {
236272 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
239284 // this.support = o.support;
240285 // this.fileparent = o.fileparent;
241286 }
....@@ -381,6 +426,7 @@
381426 }
382427
383428 boolean live = false;
429
+ transient boolean keepdontselect;
384430 boolean dontselect = false;
385431 boolean hide = false;
386432 boolean link2master = false; // performs reset support/master at each frame
....@@ -563,12 +609,14 @@
563609 toParent = LA.newMatrix();
564610 fromParent = LA.newMatrix();
565611 }
612
+
566613 if (toParentMarked == null)
567614 {
568615 if (maxcount != 1)
569616 {
570617 new Exception().printStackTrace();
571618 }
619
+
572620 toParentMarked = LA.newMatrix();
573621 fromParentMarked = LA.newMatrix();
574622 }
....@@ -879,7 +927,7 @@
879927
880928 if (marked && Globals.isLIVE() && live &&
881929 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883931 currentframe != Globals.framecount)
884932 {
885933 currentframe = Globals.framecount;
....@@ -891,7 +939,8 @@
891939
892940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893941
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
895944 {
896945 countdown = 1;
897946 delay = speedup?8:1;
....@@ -963,6 +1012,7 @@
9631012 if (material == null || material.multiply)
9641013 return true;
9651014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9661016 return material.opacity > 0.99;
9671017 }
9681018
....@@ -1363,6 +1413,7 @@
13631413 toParent = LA.newMatrix();
13641414 fromParent = LA.newMatrix();
13651415 }
1416
+
13661417 LA.matCopy(other.toParent, toParent);
13671418 LA.matCopy(other.fromParent, fromParent);
13681419
....@@ -2384,6 +2435,10 @@
23842435 }
23852436 */
23862437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23872442 }
23882443
23892444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2480,14 @@
24252480 {
24262481 editWindow.refreshContents();
24272482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24282491 //if (parent != null)
24292492 //parent.refreshEditWindow();
24302493 }
....@@ -2504,7 +2567,8 @@
25042567 private static final int editSelf = 1;
25052568 private static final int editChild = 2;
25062569
2507
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
25082572 {
25092573 if (level == 0)
25102574 {
....@@ -2512,7 +2576,8 @@
25122576 return;
25132577
25142578 Object3D selectee;
2515
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
25162581 {
25172582 selectee = (Object3D) e.nextElement();
25182583 }
....@@ -2520,19 +2585,22 @@
25202585 } else
25212586 {
25222587 //super.
2523
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25242590 }
25252591 }
25262592
2527
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25282595 {
25292596 doSomething = 0;
25302597 if (level == 0)
25312598 {
2532
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25332600 }
25342601 if (//super.
2535
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25362604 {
25372605 doSomething = 1;
25382606 return true;
....@@ -2542,7 +2610,7 @@
25422610 }
25432611 }
25442612
2545
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
25462614 {
25472615 if (selection == null)
25482616 {
....@@ -2555,7 +2623,8 @@
25552623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25562624 {
25572625 Object3D selectee = (Object3D) e.nextElement();
2558
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
25592628 {
25602629 childToDrag = selectee;
25612630 doSomething = 2;
....@@ -2567,13 +2636,15 @@
25672636 return retval;
25682637 }
25692638
2570
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
25712641 {
25722642 switch (doSomething)
25732643 {
25742644 case 1: // '\001'
25752645 //super.
2576
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
25772648 break;
25782649
25792650 case 2: // '\002'
....@@ -2586,11 +2657,13 @@
25862657 {
25872658 //sel.hitSomething = childToDrag.hitSomething;
25882659 //childToDrag.doEditDrag(info);
2589
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
25902662 } else
25912663 {
25922664 //super.
2593
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25942667 }
25952668 }
25962669 break;
....@@ -2608,6 +2681,9 @@
26082681 {
26092682 deselectAll();
26102683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
26112687 ClickInfo newInfo = new ClickInfo();
26122688 newInfo.flags = info.flags;
26132689 newInfo.bounds = info.bounds;
....@@ -3055,7 +3131,7 @@
30553131 {
30563132 if (bRep != null)
30573133 {
3058
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593135 Touch();
30603136 }
30613137 }
....@@ -3501,7 +3577,8 @@
35013577 if (blockloop)
35023578 return;
35033579
3504
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
35053582 live = h;
35063583
35073584 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3599,8 @@
35223599 return;
35233600
35243601 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
35263604 link2master = h;
35273605
35283606 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3620,8 @@
35423620 if (blockloop)
35433621 return;
35443622
3545
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
35463625 hide = h;
35473626
35483627 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3641,7 @@
35623641 if (blockloop)
35633642 return;
35643643
3565
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
35663645 marked = h;
35673646
35683647 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3651,46 @@
35723651 continue;
35733652 blockloop = true;
35743653 child.MarkLeaves(h);
3654
+ blockloop = false;
3655
+ // release(i);
3656
+ }
3657
+ }
3658
+
3659
+ void RewindLeaves(boolean h)
3660
+ {
3661
+ if (blockloop)
3662
+ return;
3663
+
3664
+ if (bRep != null || material != null) // borderline...
3665
+ rewind = h;
3666
+
3667
+ for (int i = 0; i < Size(); i++)
3668
+ {
3669
+ Object3D child = (Object3D) get(i); // reserve(i);
3670
+ if (child == null)
3671
+ continue;
3672
+ blockloop = true;
3673
+ child.RewindLeaves(h);
3674
+ blockloop = false;
3675
+ // release(i);
3676
+ }
3677
+ }
3678
+
3679
+ void RandomLeaves(boolean h)
3680
+ {
3681
+ if (blockloop)
3682
+ return;
3683
+
3684
+ if (bRep != null || material != null) // borderline...
3685
+ random = h;
3686
+
3687
+ for (int i = 0; i < Size(); i++)
3688
+ {
3689
+ Object3D child = (Object3D) get(i); // reserve(i);
3690
+ if (child == null)
3691
+ continue;
3692
+ blockloop = true;
3693
+ child.RandomLeaves(h);
35753694 blockloop = false;
35763695 // release(i);
35773696 }
....@@ -4349,6 +4468,55 @@
43494468 }
43504469 }
43514470
4471
+ void RepairSOV()
4472
+ {
4473
+ if (blockloop)
4474
+ return;
4475
+
4476
+ String texname = this.GetPigmentTexture();
4477
+
4478
+ if (texname.startsWith("sov"))
4479
+ {
4480
+ String[] s = texname.split("/");
4481
+
4482
+ String[] sname = s[1].split("Color.pn");
4483
+
4484
+ texname = sname[0];
4485
+
4486
+ if (sname.length > 1)
4487
+ {
4488
+ texname += "Color.jpg";
4489
+ }
4490
+
4491
+ this.SetPigmentTexture("sov/" + texname);
4492
+ }
4493
+
4494
+ texname = this.GetBumpTexture();
4495
+
4496
+ if (texname.startsWith("sov"))
4497
+ {
4498
+ String[] s = texname.split("/");
4499
+
4500
+ String[] sname = s[1].split("Bump.pn");
4501
+
4502
+ texname = sname[0];
4503
+
4504
+ if (sname.length > 1)
4505
+ {
4506
+ texname += "Bump.jpg";
4507
+ }
4508
+
4509
+ this.SetBumpTexture("sov/" + texname);
4510
+ }
4511
+
4512
+ for (int i=0; i<Size(); i++)
4513
+ {
4514
+ blockloop = true;
4515
+ get(i).RepairSOV();
4516
+ blockloop = false;
4517
+ }
4518
+ }
4519
+
43524520 void RepairTexture()
43534521 {
43544522 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5031,14 @@
48635031 }
48645032 }
48655033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
48665042 cTreePath Select(int indexcount, boolean deselect)
48675043 {
48685044 if (hide || dontselect)
....@@ -4899,10 +5075,11 @@
48995075 if (leaf != null)
49005076 {
49015077 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
49035080 {
49045081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
49065083 }
49075084
49085085 return tp;
....@@ -4919,6 +5096,7 @@
49195096
49205097 if (child == null)
49215098 continue;
5099
+
49225100 if (child.HasTransparency() && child.size() != 0)
49235101 {
49245102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5106,10 @@
49285106 if (leaf != null)
49295107 {
49305108 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
49325111 {
4933
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
49345113 }
49355114
49365115 return tp;
....@@ -5255,6 +5434,51 @@
52555434 blockloop = false;
52565435 }
52575436
5437
+ void ResetSelectable()
5438
+ {
5439
+ if (blockloop)
5440
+ return;
5441
+
5442
+ blockloop = true;
5443
+
5444
+ keepdontselect = dontselect;
5445
+ dontselect = true;
5446
+
5447
+ Object3D child;
5448
+ int nb = Size();
5449
+ for (int i = 0; i < nb; i++)
5450
+ {
5451
+ child = (Object3D) get(i);
5452
+ if (child == null)
5453
+ continue;
5454
+ child.ResetSelectable();
5455
+ }
5456
+
5457
+ blockloop = false;
5458
+ }
5459
+
5460
+ void RestoreSelectable()
5461
+ {
5462
+ if (blockloop)
5463
+ return;
5464
+
5465
+ blockloop = true;
5466
+
5467
+ dontselect = keepdontselect;
5468
+
5469
+ Object3D child;
5470
+ int nb = Size();
5471
+ for (int i = 0; i < nb; i++)
5472
+ {
5473
+ child = (Object3D) get(i);
5474
+ if (child == null)
5475
+ continue;
5476
+ child.RestoreSelectable();
5477
+ }
5478
+
5479
+ blockloop = false;
5480
+ }
5481
+
52585482 boolean IsSelected()
52595483 {
52605484 if (parent == null)
....@@ -5564,6 +5788,38 @@
55645788 }
55655789 }
55665790
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
55675823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685824 {
55695825 Draw(display, root, selected, blocked);
....@@ -5572,12 +5828,23 @@
55725828 boolean NeedSupport()
55735829 {
55745830 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765832 // PROBLEM with CROWD!!
55775833 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785834 }
55795835
55805836 static boolean DEBUG_SELECTION = false;
5837
+
5838
+ boolean IsLive()
5839
+ {
5840
+ if (live)
5841
+ return true;
5842
+
5843
+ if (parent == null)
5844
+ return false;
5845
+
5846
+ return parent.IsLive();
5847
+ }
55815848
55825849 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835850 {
....@@ -5640,7 +5907,7 @@
56405907 support = support;
56415908
56425909 //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);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445911
56455912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465913 {
....@@ -5660,10 +5927,12 @@
56605927 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615928
56625929 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5930
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5931
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645932 {
56655933 Globals.lighttouched = true;
56665934 } // all panes...
5935
+
56675936 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685937 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695938 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5791,6 +6060,7 @@
57916060 if (GetBRep() != null)
57926061 {
57936062 display.NextIndex();
6063
+
57946064 // vertex color conflict : gl.glCallList(list);
57956065 DrawNode(display, root, selected);
57966066 if (this instanceof BezierPatch)
....@@ -5831,16 +6101,27 @@
58316101 tex = GetTextures();
58326102 }
58336103
5834
- boolean failed = false;
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
58356106
58366107 try
58376108 {
5838
- display.BindTextures(tex, texres);
6109
+ display.BindPigmentTexture(tex, texres);
58396110 }
58406111 catch (Exception e)
58416112 {
58426113 System.err.println("FAILED: " + this);
5843
- failed = true;
6114
+ failedPigment = true;
6115
+ }
6116
+
6117
+ try
6118
+ {
6119
+ display.BindBumpTexture(tex, texres);
6120
+ }
6121
+ catch (Exception e)
6122
+ {
6123
+ //System.err.println("FAILED: " + this);
6124
+ failedBump = true;
58446125 }
58456126
58466127 if (!compiled)
....@@ -5863,8 +6144,11 @@
58636144 }
58646145 }
58656146
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
58686152
58696153 display.PopMaterial(this, selected);
58706154 }
....@@ -6237,6 +6521,11 @@
62376521 // dec 2012
62386522 new Exception().printStackTrace();
62396523 return;
6524
+ }
6525
+
6526
+ if (dontselect)
6527
+ {
6528
+ //bRep.GenerateNormalsMINE();
62406529 }
62416530
62426531 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7022,20 +7311,23 @@
70227311 }
70237312 }
70247313
7025
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
70267318 {
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;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
70307322 if (toscreen == null)
70317323 {
7032
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70337325 }
70347326 cVector vec = in;
70357327 LA.xformPos(in, toscreen, in);
70367328 //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();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70397331 outPt.x = hc + (int) vec.x;
70407332 outPt.y = vc - (int) vec.y;
70417333 outRec.x = outPt.x - 3;
....@@ -7043,15 +7335,18 @@
70437335 outRec.width = outRec.height = 6;
70447336 }
70457337
7046
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
70477340 {
70487341 Point pt = new Point(0, 0);
70497342 Rectangle rec = new Rectangle();
7050
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
70517345 return rec;
70527346 }
70537347
7054
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
70557350 {
70567351 if (level == 0)
70577352 {
....@@ -7060,16 +7355,19 @@
70607355 {
70617356 cVector origin = new cVector();
70627357 //LA.xformPos(origin, toParent, origin);
7063
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70647362 Rectangle boundary = new Rectangle();
70657363 boundary.x = spot.x - 30;
70667364 boundary.y = spot.y - 30;
70677365 boundary.width = spot.width + 60;
70687366 boundary.height = spot.height + 60;
7069
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
70707368 int spotw = spot.x + spot.width;
70717369 int spoth = spot.y + spot.height;
7072
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70737371 // if (CameraPane.Xmin > spot.x)
70747372 // {
70757373 // CameraPane.Xmin = spot.x;
....@@ -7089,8 +7387,8 @@
70897387 spot.translate(32, 32);
70907388 spotw = spot.x + spot.width;
70917389 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7093
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947392 // if (CameraPane.Xmin > spot.x)
70957393 // {
70967394 // CameraPane.Xmin = spot.x;
....@@ -7107,11 +7405,12 @@
71077405 // {
71087406 // CameraPane.Ymax = spoth;
71097407 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7408
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7409
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127410 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7114
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
71157414 // if (CameraPane.Xmin > spot.x)
71167415 // {
71177416 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7427,8 @@
71287427 // {
71297428 // CameraPane.Ymax = spoth;
71307429 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71337432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347433 // if (CameraPane.Xmin > boundary.x)
71357434 // {
....@@ -7151,7 +7450,8 @@
71517450 }
71527451 }
71537452
7154
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
71557455 {
71567456 if (level == 0)
71577457 {
....@@ -7160,8 +7460,8 @@
71607460
71617461 boolean retval = false;
71627462
7163
- startX = info.x;
7164
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
71657465
71667466 hitSomething = -1;
71677467 cVector origin = new cVector();
....@@ -7171,22 +7471,51 @@
71717471 {
71727472 centerPt = new Point(0, 0);
71737473 }
7174
- calcHotSpot(origin, info, centerPt, spot);
7175
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
71767477 {
71777478 hitSomething = hitCenter;
71787479 retval = true;
71797480 }
71807481 spot.translate(32, 0);
7181
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
71827483 {
71837484 hitSomething = hitRotate;
71847485 retval = true;
71857486 }
71867487 spot.translate(0, 32);
7187
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
71887489 {
71897490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
71907519 retval = true;
71917520 }
71927521
....@@ -7196,7 +7525,7 @@
71967525 }
71977526
71987527 //System.out.println("info.modifiers = " + info.modifiers);
7199
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72007529 //System.out.println("modified = " + modified);
72017530 //new Exception().printStackTrace();
72027531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7224,7 +7553,8 @@
72247553 return true;
72257554 }
72267555
7227
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
72287558 {
72297559 if (hitSomething == 0)
72307560 {
....@@ -7238,7 +7568,7 @@
72387568
72397569 //System.out.println("hitSomething = " + hitSomething);
72407570
7241
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
72427572
72437573 cVector xlate = new cVector();
72447574 //cVector xlate2 = new cVector();
....@@ -7272,8 +7602,8 @@
72727602 toParent[3][i] = xlate.get(i);
72737603 LA.matInvert(toParent, fromParent);
72747604 */
7275
- cVector delta = LA.newVector(0, 0, startY - info.y);
7276
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72777607
72787608 LA.matCopy(startMat, toParent);
72797609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7282,7 +7612,7 @@
72827612 } else
72837613 {
72847614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7285
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
72867616 cVector away = new cVector();
72877617 //cVector right2 = new cVector();
72887618 //LA.vecCross(up, cVector.Z, right);
....@@ -7299,19 +7629,19 @@
72997629 LA.xformDir(up, ClickInfo.matbuffer, up);
73007630 // if (!CameraPane.LOCALTRANSFORM)
73017631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7302
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73037633 // if (!CameraPane.LOCALTRANSFORM)
73047634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73057635 //LA.vecCross(up, cVector.Z, right2);
73067636
7307
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73087638
73097639 //System.out.println("DELTA0 = " + delta);
73107640 //System.out.println("AWAY = " + info.camera.away);
73117641 //System.out.println("UP = " + info.camera.up);
73127642 if (away.z > 0)
73137643 {
7314
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73157645 {
73167646 delta.x = -delta.x;
73177647 } else
....@@ -7326,7 +7656,7 @@
73267656 //System.out.println("DELTA1 = " + delta);
73277657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73287658 //System.out.println("DELTA2 = " + delta);
7329
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73307660 LA.matCopy(startMat, toParent);
73317661 //System.out.println("DELTA3 = " + delta);
73327662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7336,8 +7666,8 @@
73367666 break;
73377667
73387668 case hitRotate: // rotate
7339
- int dx = info.x - centerPt.x;
7340
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
73417671 double angle = (double) Math.atan2(dx, dy);
73427672 angle = -(1.570796 - angle);
73437673
....@@ -7360,7 +7690,7 @@
73607690 }
73617691 /**/
73627692
7363
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
73647694 {
73657695 case 1: // '\001'
73667696 LA.matZRotate(toParent, angle);
....@@ -7387,7 +7717,7 @@
73877717 break;
73887718
73897719 case hitScale: // scale
7390
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
73917721 double sign = 1;
73927722 if (hScale < 0)
73937723 {
....@@ -7399,7 +7729,7 @@
73997729 //hScale = 0.01;
74007730 }
74017731
7402
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
74037733 sign = 1;
74047734 if (vScale < 0)
74057735 {
....@@ -7410,6 +7740,7 @@
74107740 {
74117741 //vScale = 0.01;
74127742 }
7743
+
74137744 LA.matCopy(startMat, toParent);
74147745 /**/
74157746 for (int i = 0; i < 3; i++)
....@@ -7419,29 +7750,30 @@
74197750 }
74207751 /**/
74217752
7422
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74237754
74247755 if (totalScale < 0.01)
74257756 {
74267757 totalScale = 0.01;
74277758 }
74287759
7429
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
74307761 {
74317762 case 3: // '\001'
7432
- if (modified)
7763
+ if (modified || opposite)
74337764 {
74347765 //LA.matScale(toParent, 1, hScale, vScale);
74357766 LA.matScale(toParent, totalScale, 1, 1);
74367767 } // vScale, 1);
74377768 else
74387769 {
7770
+ // EXCEPTION!
74397771 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407772 } // vScale, 1);
74417773 break;
74427774
74437775 case 2: // '\002'
7444
- if (modified)
7776
+ if (modified || opposite)
74457777 {
74467778 //LA.matScale(toParent, hScale, 1, vScale);
74477779 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7784,7 @@
74527784 break;
74537785
74547786 case 1: // '\003'
7455
- if (modified)
7787
+ if (modified || opposite)
74567788 {
74577789 //LA.matScale(toParent, hScale, vScale, 1);
74587790 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7492,7 +7824,7 @@
74927824 } // NEW ...
74937825
74947826
7495
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
74967828 }
74977829
74987830 boolean overflow = false;
....@@ -7672,6 +8004,10 @@
76728004 editWindow = null;
76738005 } // ?
76748006 }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
8010
+ }
76758011 }
76768012
76778013 boolean root; // patch for edit windows
....@@ -7829,6 +8165,10 @@
78298165 }
78308166
78318167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
78328172 transient ObjectUI objectUI;
78338173 public static int povDepth = 0;
78348174 private static cVector tbMin = new cVector();