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
177182 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
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
....@@ -881,7 +927,7 @@
881927
882928 if (marked && Globals.isLIVE() && live &&
883929 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885931 currentframe != Globals.framecount)
886932 {
887933 currentframe = Globals.framecount;
....@@ -893,7 +939,8 @@
893939
894940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895941
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
897944 {
898945 countdown = 1;
899946 delay = speedup?8:1;
....@@ -965,6 +1012,7 @@
9651012 if (material == null || material.multiply)
9661013 return true;
9671014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9681016 return material.opacity > 0.99;
9691017 }
9701018
....@@ -1365,6 +1413,7 @@
13651413 toParent = LA.newMatrix();
13661414 fromParent = LA.newMatrix();
13671415 }
1416
+
13681417 LA.matCopy(other.toParent, toParent);
13691418 LA.matCopy(other.fromParent, fromParent);
13701419
....@@ -2386,6 +2435,10 @@
23862435 }
23872436 */
23882437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23892442 }
23902443
23912444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2480,14 @@
24272480 {
24282481 editWindow.refreshContents();
24292482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24302491 //if (parent != null)
24312492 //parent.refreshEditWindow();
24322493 }
....@@ -2506,7 +2567,8 @@
25062567 private static final int editSelf = 1;
25072568 private static final int editChild = 2;
25082569
2509
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
25102572 {
25112573 if (level == 0)
25122574 {
....@@ -2514,7 +2576,8 @@
25142576 return;
25152577
25162578 Object3D selectee;
2517
- 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))
25182581 {
25192582 selectee = (Object3D) e.nextElement();
25202583 }
....@@ -2522,19 +2585,22 @@
25222585 } else
25232586 {
25242587 //super.
2525
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25262590 }
25272591 }
25282592
2529
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25302595 {
25312596 doSomething = 0;
25322597 if (level == 0)
25332598 {
2534
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25352600 }
25362601 if (//super.
2537
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25382604 {
25392605 doSomething = 1;
25402606 return true;
....@@ -2544,7 +2610,7 @@
25442610 }
25452611 }
25462612
2547
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
25482614 {
25492615 if (selection == null)
25502616 {
....@@ -2557,7 +2623,8 @@
25572623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582624 {
25592625 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
25612628 {
25622629 childToDrag = selectee;
25632630 doSomething = 2;
....@@ -2569,13 +2636,15 @@
25692636 return retval;
25702637 }
25712638
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
25732641 {
25742642 switch (doSomething)
25752643 {
25762644 case 1: // '\001'
25772645 //super.
2578
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
25792648 break;
25802649
25812650 case 2: // '\002'
....@@ -2588,11 +2657,13 @@
25882657 {
25892658 //sel.hitSomething = childToDrag.hitSomething;
25902659 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
25922662 } else
25932663 {
25942664 //super.
2595
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25962667 }
25972668 }
25982669 break;
....@@ -2610,6 +2681,9 @@
26102681 {
26112682 deselectAll();
26122683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
26132687 ClickInfo newInfo = new ClickInfo();
26142688 newInfo.flags = info.flags;
26152689 newInfo.bounds = info.bounds;
....@@ -3057,7 +3131,7 @@
30573131 {
30583132 if (bRep != null)
30593133 {
3060
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613135 Touch();
30623136 }
30633137 }
....@@ -3503,7 +3577,8 @@
35033577 if (blockloop)
35043578 return;
35053579
3506
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
35073582 live = h;
35083583
35093584 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3599,8 @@
35243599 return;
35253600
35263601 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
35283604 link2master = h;
35293605
35303606 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3620,8 @@
35443620 if (blockloop)
35453621 return;
35463622
3547
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
35483625 hide = h;
35493626
35503627 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3641,7 @@
35643641 if (blockloop)
35653642 return;
35663643
3567
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
35683645 marked = h;
35693646
35703647 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3651,46 @@
35743651 continue;
35753652 blockloop = true;
35763653 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);
35773694 blockloop = false;
35783695 // release(i);
35793696 }
....@@ -4351,6 +4468,55 @@
43514468 }
43524469 }
43534470
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
+
43544520 void RepairTexture()
43554521 {
43564522 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5031,14 @@
48655031 }
48665032 }
48675033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
48685042 cTreePath Select(int indexcount, boolean deselect)
48695043 {
48705044 if (hide || dontselect)
....@@ -4901,10 +5075,11 @@
49015075 if (leaf != null)
49025076 {
49035077 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
49055080 {
49065081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
49085083 }
49095084
49105085 return tp;
....@@ -4921,6 +5096,7 @@
49215096
49225097 if (child == null)
49235098 continue;
5099
+
49245100 if (child.HasTransparency() && child.size() != 0)
49255101 {
49265102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5106,10 @@
49305106 if (leaf != null)
49315107 {
49325108 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
49345111 {
4935
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
49365113 }
49375114
49385115 return tp;
....@@ -5257,6 +5434,51 @@
52575434 blockloop = false;
52585435 }
52595436
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
+
52605482 boolean IsSelected()
52615483 {
52625484 if (parent == null)
....@@ -5566,6 +5788,38 @@
55665788 }
55675789 }
55685790
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
+
55695823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55705824 {
55715825 Draw(display, root, selected, blocked);
....@@ -5653,7 +5907,7 @@
56535907 support = support;
56545908
56555909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5656
- boolean usecalllists = IsLive(); // 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);
56575911
56585912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595913 {
....@@ -5673,10 +5927,12 @@
56735927 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56745928
56755929 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5676
- (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)))
56775932 {
56785933 Globals.lighttouched = true;
56795934 } // all panes...
5935
+
56805936 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56815937 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56825938 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5804,6 +6060,7 @@
58046060 if (GetBRep() != null)
58056061 {
58066062 display.NextIndex();
6063
+
58076064 // vertex color conflict : gl.glCallList(list);
58086065 DrawNode(display, root, selected);
58096066 if (this instanceof BezierPatch)
....@@ -5844,16 +6101,27 @@
58446101 tex = GetTextures();
58456102 }
58466103
5847
- boolean failed = false;
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
58486106
58496107 try
58506108 {
5851
- display.BindTextures(tex, texres);
6109
+ display.BindPigmentTexture(tex, texres);
58526110 }
58536111 catch (Exception e)
58546112 {
58556113 System.err.println("FAILED: " + this);
5856
- 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;
58576125 }
58586126
58596127 if (!compiled)
....@@ -5876,8 +6144,11 @@
58766144 }
58776145 }
58786146
5879
- if (!failed)
5880
- display.ReleaseTextures(tex);
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
58816152
58826153 display.PopMaterial(this, selected);
58836154 }
....@@ -6250,6 +6521,11 @@
62506521 // dec 2012
62516522 new Exception().printStackTrace();
62526523 return;
6524
+ }
6525
+
6526
+ if (dontselect)
6527
+ {
6528
+ //bRep.GenerateNormalsMINE();
62536529 }
62546530
62556531 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7035,20 +7311,23 @@
70357311 }
70367312 }
70377313
7038
- 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)
70397318 {
7040
- int hc = info.bounds.x + info.bounds.width / 2;
7041
- int vc = info.bounds.y + info.bounds.height / 2;
7042
- 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;
70437322 if (toscreen == null)
70447323 {
7045
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70467325 }
70477326 cVector vec = in;
70487327 LA.xformPos(in, toscreen, in);
70497328 //System.out.println("Distance = " + info.camera.Distance());
7050
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7051
- 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();
70527331 outPt.x = hc + (int) vec.x;
70537332 outPt.y = vc - (int) vec.y;
70547333 outRec.x = outPt.x - 3;
....@@ -7056,15 +7335,18 @@
70567335 outRec.width = outRec.height = 6;
70577336 }
70587337
7059
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
70607340 {
70617341 Point pt = new Point(0, 0);
70627342 Rectangle rec = new Rectangle();
7063
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
70647345 return rec;
70657346 }
70667347
7067
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
70687350 {
70697351 if (level == 0)
70707352 {
....@@ -7073,16 +7355,19 @@
70737355 {
70747356 cVector origin = new cVector();
70757357 //LA.xformPos(origin, toParent, origin);
7076
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70777362 Rectangle boundary = new Rectangle();
70787363 boundary.x = spot.x - 30;
70797364 boundary.y = spot.y - 30;
70807365 boundary.width = spot.width + 60;
70817366 boundary.height = spot.height + 60;
7082
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
70837368 int spotw = spot.x + spot.width;
70847369 int spoth = spot.y + spot.height;
7085
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70867371 // if (CameraPane.Xmin > spot.x)
70877372 // {
70887373 // CameraPane.Xmin = spot.x;
....@@ -7102,8 +7387,8 @@
71027387 spot.translate(32, 32);
71037388 spotw = spot.x + spot.width;
71047389 spoth = spot.y + spot.height;
7105
- info.g.setColor(Color.blue);
7106
- 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);
71077392 // if (CameraPane.Xmin > spot.x)
71087393 // {
71097394 // CameraPane.Xmin = spot.x;
....@@ -7120,11 +7405,12 @@
71207405 // {
71217406 // CameraPane.Ymax = spoth;
71227407 // }
7123
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7124
- //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
71257410 spot.translate(0, -32);
7126
- info.g.setColor(Color.green);
7127
- 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);
71287414 // if (CameraPane.Xmin > spot.x)
71297415 // {
71307416 // CameraPane.Xmin = spot.x;
....@@ -7141,8 +7427,8 @@
71417427 // {
71427428 // CameraPane.Ymax = spoth;
71437429 // }
7144
- info.g.drawArc(boundary.x, boundary.y,
7145
- 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);
71467432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71477433 // if (CameraPane.Xmin > boundary.x)
71487434 // {
....@@ -7164,7 +7450,8 @@
71647450 }
71657451 }
71667452
7167
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
71687455 {
71697456 if (level == 0)
71707457 {
....@@ -7173,8 +7460,8 @@
71737460
71747461 boolean retval = false;
71757462
7176
- startX = info.x;
7177
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
71787465
71797466 hitSomething = -1;
71807467 cVector origin = new cVector();
....@@ -7184,22 +7471,51 @@
71847471 {
71857472 centerPt = new Point(0, 0);
71867473 }
7187
- calcHotSpot(origin, info, centerPt, spot);
7188
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
71897477 {
71907478 hitSomething = hitCenter;
71917479 retval = true;
71927480 }
71937481 spot.translate(32, 0);
7194
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
71957483 {
71967484 hitSomething = hitRotate;
71977485 retval = true;
71987486 }
71997487 spot.translate(0, 32);
7200
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
72017489 {
72027490 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
+
72037519 retval = true;
72047520 }
72057521
....@@ -7209,7 +7525,7 @@
72097525 }
72107526
72117527 //System.out.println("info.modifiers = " + info.modifiers);
7212
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72137529 //System.out.println("modified = " + modified);
72147530 //new Exception().printStackTrace();
72157531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7237,7 +7553,8 @@
72377553 return true;
72387554 }
72397555
7240
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
72417558 {
72427559 if (hitSomething == 0)
72437560 {
....@@ -7251,7 +7568,7 @@
72517568
72527569 //System.out.println("hitSomething = " + hitSomething);
72537570
7254
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
72557572
72567573 cVector xlate = new cVector();
72577574 //cVector xlate2 = new cVector();
....@@ -7285,8 +7602,8 @@
72857602 toParent[3][i] = xlate.get(i);
72867603 LA.matInvert(toParent, fromParent);
72877604 */
7288
- cVector delta = LA.newVector(0, 0, startY - info.y);
7289
- 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);
72907607
72917608 LA.matCopy(startMat, toParent);
72927609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7295,7 +7612,7 @@
72957612 } else
72967613 {
72977614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7298
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
72997616 cVector away = new cVector();
73007617 //cVector right2 = new cVector();
73017618 //LA.vecCross(up, cVector.Z, right);
....@@ -7312,19 +7629,19 @@
73127629 LA.xformDir(up, ClickInfo.matbuffer, up);
73137630 // if (!CameraPane.LOCALTRANSFORM)
73147631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7315
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73167633 // if (!CameraPane.LOCALTRANSFORM)
73177634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73187635 //LA.vecCross(up, cVector.Z, right2);
73197636
7320
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73217638
73227639 //System.out.println("DELTA0 = " + delta);
73237640 //System.out.println("AWAY = " + info.camera.away);
73247641 //System.out.println("UP = " + info.camera.up);
73257642 if (away.z > 0)
73267643 {
7327
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73287645 {
73297646 delta.x = -delta.x;
73307647 } else
....@@ -7339,7 +7656,7 @@
73397656 //System.out.println("DELTA1 = " + delta);
73407657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73417658 //System.out.println("DELTA2 = " + delta);
7342
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73437660 LA.matCopy(startMat, toParent);
73447661 //System.out.println("DELTA3 = " + delta);
73457662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7349,8 +7666,8 @@
73497666 break;
73507667
73517668 case hitRotate: // rotate
7352
- int dx = info.x - centerPt.x;
7353
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
73547671 double angle = (double) Math.atan2(dx, dy);
73557672 angle = -(1.570796 - angle);
73567673
....@@ -7373,7 +7690,7 @@
73737690 }
73747691 /**/
73757692
7376
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
73777694 {
73787695 case 1: // '\001'
73797696 LA.matZRotate(toParent, angle);
....@@ -7400,7 +7717,7 @@
74007717 break;
74017718
74027719 case hitScale: // scale
7403
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
74047721 double sign = 1;
74057722 if (hScale < 0)
74067723 {
....@@ -7412,7 +7729,7 @@
74127729 //hScale = 0.01;
74137730 }
74147731
7415
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
74167733 sign = 1;
74177734 if (vScale < 0)
74187735 {
....@@ -7423,6 +7740,7 @@
74237740 {
74247741 //vScale = 0.01;
74257742 }
7743
+
74267744 LA.matCopy(startMat, toParent);
74277745 /**/
74287746 for (int i = 0; i < 3; i++)
....@@ -7432,29 +7750,30 @@
74327750 }
74337751 /**/
74347752
7435
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74367754
74377755 if (totalScale < 0.01)
74387756 {
74397757 totalScale = 0.01;
74407758 }
74417759
7442
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
74437761 {
74447762 case 3: // '\001'
7445
- if (modified)
7763
+ if (modified || opposite)
74467764 {
74477765 //LA.matScale(toParent, 1, hScale, vScale);
74487766 LA.matScale(toParent, totalScale, 1, 1);
74497767 } // vScale, 1);
74507768 else
74517769 {
7770
+ // EXCEPTION!
74527771 LA.matScale(toParent, totalScale, totalScale, totalScale);
74537772 } // vScale, 1);
74547773 break;
74557774
74567775 case 2: // '\002'
7457
- if (modified)
7776
+ if (modified || opposite)
74587777 {
74597778 //LA.matScale(toParent, hScale, 1, vScale);
74607779 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7465,7 +7784,7 @@
74657784 break;
74667785
74677786 case 1: // '\003'
7468
- if (modified)
7787
+ if (modified || opposite)
74697788 {
74707789 //LA.matScale(toParent, hScale, vScale, 1);
74717790 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7505,7 +7824,7 @@
75057824 } // NEW ...
75067825
75077826
7508
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
75097828 }
75107829
75117830 boolean overflow = false;
....@@ -7685,6 +8004,10 @@
76858004 editWindow = null;
76868005 } // ?
76878006 }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
8010
+ }
76888011 }
76898012
76908013 boolean root; // patch for edit windows
....@@ -7842,6 +8165,10 @@
78428165 }
78438166
78448167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
78458172 transient ObjectUI objectUI;
78468173 public static int povDepth = 0;
78478174 private static cVector tbMin = new cVector();