Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
Object3D.java
....@@ -22,12 +22,21 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
3140
3241 ScriptNode scriptnode;
3342
....@@ -170,24 +179,35 @@
170179
171180 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172181 {
182
+ Object3D o;
183
+
173184 if (hashtable.containsKey(GetUUID()))
174185 {
175
- Object3D o = hashtable.get(GetUUID());
186
+ o = hashtable.get(GetUUID());
176187
177188 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
180197
181
- return;
198
+ hashtable.put(GetUUID(), o);
182199 }
183200
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
201
+ if (!blockloop)
189202 {
190
- get(i).ExtractBigData(hashtable);
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
191211 }
192212
193213 ExtractBigData(o);
....@@ -195,11 +215,26 @@
195215
196216 void ExtractBigData(Object3D o)
197217 {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
198221 o.bRep = this.bRep;
199
- if (this.bRep != null)
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
200232 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
203238 }
204239
205240 // o.support = this.support;
....@@ -214,6 +249,29 @@
214249 // this.fileparent = null;
215250 }
216251
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
217275 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218276 {
219277 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +281,35 @@
223281
224282 RestoreBigData(o);
225283
226
- hashtable.remove(GetUUID());
284
+ if (blockloop)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ //hashtable.remove(GetUUID());
227290
228291 for (int i=0; i<Size(); i++)
229292 {
230293 get(i).RestoreBigData(hashtable);
231294 }
295
+
296
+ blockloop = false;
232297 }
233298
234299 void RestoreBigData(Object3D o)
235300 {
236301 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
302
+ if (this.support != null && o.transientrep != null)
303
+ {
304
+ this.support.bRep = o.transientrep;
305
+ }
306
+
307
+ this.selection = o.selection;
308
+
309
+ this.versionlist = o.versionlist;
310
+ this.versionindex = o.versionindex;
311
+// July 2019 if (this.bRep != null)
312
+// this.bRep.support = o.transientrep;
239313 // this.support = o.support;
240314 // this.fileparent = o.fileparent;
241315 }
....@@ -381,6 +455,7 @@
381455 }
382456
383457 boolean live = false;
458
+ transient boolean keepdontselect;
384459 boolean dontselect = false;
385460 boolean hide = false;
386461 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +956,7 @@
881956
882957 if (marked && Globals.isLIVE() && live &&
883958 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885960 currentframe != Globals.framecount)
886961 {
887962 currentframe = Globals.framecount;
....@@ -893,7 +968,8 @@
893968
894969 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895970
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
971
+ if (transformcount*factor >= maxcount && (rewind || random) ||
972
+ (step == 1 && changedir))
897973 {
898974 countdown = 1;
899975 delay = speedup?8:1;
....@@ -965,6 +1041,10 @@
9651041 if (material == null || material.multiply)
9661042 return true;
9671043
1044
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1045
+ return false;
1046
+
1047
+ // Transparent objects are dynamic because we have to sort the triangles.
9681048 return material.opacity > 0.99;
9691049 }
9701050
....@@ -1365,6 +1445,7 @@
13651445 toParent = LA.newMatrix();
13661446 fromParent = LA.newMatrix();
13671447 }
1448
+
13681449 LA.matCopy(other.toParent, toParent);
13691450 LA.matCopy(other.fromParent, fromParent);
13701451
....@@ -2386,6 +2467,15 @@
23862467 }
23872468 */
23882469 }
2470
+ else
2471
+ {
2472
+ //((ObjEditor)editWindow).SetupUI2(null);
2473
+ if (objectUI != null)
2474
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2475
+ else
2476
+ //new Exception().printStackTrace();
2477
+ System.err.println("objectUI is null");
2478
+ }
23892479 }
23902480
23912481 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2517,14 @@
24272517 {
24282518 editWindow.refreshContents();
24292519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
24302528 //if (parent != null)
24312529 //parent.refreshEditWindow();
24322530 }
....@@ -2506,7 +2604,8 @@
25062604 private static final int editSelf = 1;
25072605 private static final int editChild = 2;
25082606
2509
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
25102609 {
25112610 if (level == 0)
25122611 {
....@@ -2514,7 +2613,8 @@
25142613 return;
25152614
25162615 Object3D selectee;
2517
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2616
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2617
+ level + 1))
25182618 {
25192619 selectee = (Object3D) e.nextElement();
25202620 }
....@@ -2522,19 +2622,22 @@
25222622 } else
25232623 {
25242624 //super.
2525
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
25262627 }
25272628 }
25282629
2529
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
25302632 {
25312633 doSomething = 0;
25322634 if (level == 0)
25332635 {
2534
- return doParentClick(info);
2636
+ return doParentClick(); //info);
25352637 }
25362638 if (//super.
2537
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
25382641 {
25392642 doSomething = 1;
25402643 return true;
....@@ -2544,7 +2647,7 @@
25442647 }
25452648 }
25462649
2547
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
25482651 {
25492652 if (selection == null)
25502653 {
....@@ -2557,7 +2660,8 @@
25572660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582661 {
25592662 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
25612665 {
25622666 childToDrag = selectee;
25632667 doSomething = 2;
....@@ -2569,13 +2673,15 @@
25692673 return retval;
25702674 }
25712675
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
25732678 {
25742679 switch (doSomething)
25752680 {
25762681 case 1: // '\001'
25772682 //super.
2578
- doEditDrag0(info, opposite);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
25792685 break;
25802686
25812687 case 2: // '\002'
....@@ -2588,11 +2694,13 @@
25882694 {
25892695 //sel.hitSomething = childToDrag.hitSomething;
25902696 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
25922699 } else
25932700 {
25942701 //super.
2595
- doEditDrag0(info, opposite);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
25962704 }
25972705 }
25982706 break;
....@@ -2610,6 +2718,9 @@
26102718 {
26112719 deselectAll();
26122720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
26132724 ClickInfo newInfo = new ClickInfo();
26142725 newInfo.flags = info.flags;
26152726 newInfo.bounds = info.bounds;
....@@ -3057,7 +3168,7 @@
30573168 {
30583169 if (bRep != null)
30593170 {
3060
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613172 Touch();
30623173 }
30633174 }
....@@ -3503,7 +3614,8 @@
35033614 if (blockloop)
35043615 return;
35053616
3506
- if (marked || (bRep != null && material != null)) // borderline...
3617
+ if (//marked || // does not make sense
3618
+ (bRep != null || material != null)) // borderline...
35073619 live = h;
35083620
35093621 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3636,8 @@
35243636 return;
35253637
35263638 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3639
+ if (//marked || // does not make sense
3640
+ (bRep != null || material != null)) // borderline...
35283641 link2master = h;
35293642
35303643 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3657,8 @@
35443657 if (blockloop)
35453658 return;
35463659
3547
- if (marked || (bRep != null && material != null)) // borderline...
3660
+ if (//marked || // does not make sense
3661
+ (bRep != null || material != null)) // borderline...
35483662 hide = h;
35493663
35503664 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3678,7 @@
35643678 if (blockloop)
35653679 return;
35663680
3567
- if (bRep != null && material != null) // borderline...
3681
+ if (bRep != null || material != null) // borderline...
35683682 marked = h;
35693683
35703684 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3688,46 @@
35743688 continue;
35753689 blockloop = true;
35763690 child.MarkLeaves(h);
3691
+ blockloop = false;
3692
+ // release(i);
3693
+ }
3694
+ }
3695
+
3696
+ void RewindLeaves(boolean h)
3697
+ {
3698
+ if (blockloop)
3699
+ return;
3700
+
3701
+ if (bRep != null || material != null) // borderline...
3702
+ rewind = h;
3703
+
3704
+ for (int i = 0; i < Size(); i++)
3705
+ {
3706
+ Object3D child = (Object3D) get(i); // reserve(i);
3707
+ if (child == null)
3708
+ continue;
3709
+ blockloop = true;
3710
+ child.RewindLeaves(h);
3711
+ blockloop = false;
3712
+ // release(i);
3713
+ }
3714
+ }
3715
+
3716
+ void RandomLeaves(boolean h)
3717
+ {
3718
+ if (blockloop)
3719
+ return;
3720
+
3721
+ if (bRep != null || material != null) // borderline...
3722
+ random = h;
3723
+
3724
+ for (int i = 0; i < Size(); i++)
3725
+ {
3726
+ Object3D child = (Object3D) get(i); // reserve(i);
3727
+ if (child == null)
3728
+ continue;
3729
+ blockloop = true;
3730
+ child.RandomLeaves(h);
35773731 blockloop = false;
35783732 // release(i);
35793733 }
....@@ -4351,6 +4505,55 @@
43514505 }
43524506 }
43534507
4508
+ void RepairSOV()
4509
+ {
4510
+ if (blockloop)
4511
+ return;
4512
+
4513
+ String texname = this.GetPigmentTexture();
4514
+
4515
+ if (texname.startsWith("sov"))
4516
+ {
4517
+ String[] s = texname.split("/");
4518
+
4519
+ String[] sname = s[1].split("Color.pn");
4520
+
4521
+ texname = sname[0];
4522
+
4523
+ if (sname.length > 1)
4524
+ {
4525
+ texname += "Color.jpg";
4526
+ }
4527
+
4528
+ this.SetPigmentTexture("sov/" + texname);
4529
+ }
4530
+
4531
+ texname = this.GetBumpTexture();
4532
+
4533
+ if (texname.startsWith("sov"))
4534
+ {
4535
+ String[] s = texname.split("/");
4536
+
4537
+ String[] sname = s[1].split("Bump.pn");
4538
+
4539
+ texname = sname[0];
4540
+
4541
+ if (sname.length > 1)
4542
+ {
4543
+ texname += "Bump.jpg";
4544
+ }
4545
+
4546
+ this.SetBumpTexture("sov/" + texname);
4547
+ }
4548
+
4549
+ for (int i=0; i<Size(); i++)
4550
+ {
4551
+ blockloop = true;
4552
+ get(i).RepairSOV();
4553
+ blockloop = false;
4554
+ }
4555
+ }
4556
+
43544557 void RepairTexture()
43554558 {
43564559 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5068,14 @@
48655068 }
48665069 }
48675070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
48685079 cTreePath Select(int indexcount, boolean deselect)
48695080 {
48705081 if (hide || dontselect)
....@@ -4901,10 +5112,11 @@
49015112 if (leaf != null)
49025113 {
49035114 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
49055117 {
49065118 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
49085120 }
49095121
49105122 return tp;
....@@ -4921,6 +5133,7 @@
49215133
49225134 if (child == null)
49235135 continue;
5136
+
49245137 if (child.HasTransparency() && child.size() != 0)
49255138 {
49265139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5143,10 @@
49305143 if (leaf != null)
49315144 {
49325145 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
49345148 {
4935
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
49365150 }
49375151
49385152 return tp;
....@@ -5257,6 +5471,51 @@
52575471 blockloop = false;
52585472 }
52595473
5474
+ void ResetSelectable()
5475
+ {
5476
+ if (blockloop)
5477
+ return;
5478
+
5479
+ blockloop = true;
5480
+
5481
+ keepdontselect = dontselect;
5482
+ dontselect = true;
5483
+
5484
+ Object3D child;
5485
+ int nb = Size();
5486
+ for (int i = 0; i < nb; i++)
5487
+ {
5488
+ child = (Object3D) get(i);
5489
+ if (child == null)
5490
+ continue;
5491
+ child.ResetSelectable();
5492
+ }
5493
+
5494
+ blockloop = false;
5495
+ }
5496
+
5497
+ void RestoreSelectable()
5498
+ {
5499
+ if (blockloop)
5500
+ return;
5501
+
5502
+ blockloop = true;
5503
+
5504
+ dontselect = keepdontselect;
5505
+
5506
+ Object3D child;
5507
+ int nb = Size();
5508
+ for (int i = 0; i < nb; i++)
5509
+ {
5510
+ child = (Object3D) get(i);
5511
+ if (child == null)
5512
+ continue;
5513
+ child.RestoreSelectable();
5514
+ }
5515
+
5516
+ blockloop = false;
5517
+ }
5518
+
52605519 boolean IsSelected()
52615520 {
52625521 if (parent == null)
....@@ -5317,6 +5576,11 @@
53175576 if (fullname == null)
53185577 return "";
53195578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
53205584 // System.out.println("Fullname = " + fullname);
53215585
53225586 // Does not work on Windows due to C:
....@@ -5329,7 +5593,7 @@
53295593
53305594 if (split.length == 0)
53315595 {
5332
- return "";
5596
+ return fullname.pigment = "";
53335597 }
53345598
53355599 if (split.length <= 2)
....@@ -5337,22 +5601,27 @@
53375601 if (fullname.name.endsWith(":"))
53385602 {
53395603 // Windows
5340
- return fullname.name.substring(0, fullname.name.length()-1);
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
53415605 }
53425606
5343
- return split[0];
5607
+ return fullname.pigment = split[0];
53445608 }
53455609
53465610 // Windows
53475611 assert(split.length == 4);
53485612
5349
- return split[0] + ":" + split[1];
5613
+ return fullname.pigment = split[0] + ":" + split[1];
53505614 }
53515615
53525616 static String GetBump(cTexture fullname)
53535617 {
53545618 if (fullname == null)
53555619 return "";
5620
+
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
53565625
53575626 // System.out.println("Fullname = " + fullname);
53585627 // Does not work on Windows due to C:
....@@ -5364,12 +5633,12 @@
53645633
53655634 if (split.length == 0)
53665635 {
5367
- return "";
5636
+ return fullname.bump = "";
53685637 }
53695638
53705639 if (split.length == 1)
53715640 {
5372
- return "";
5641
+ return fullname.bump = "";
53735642 }
53745643
53755644 if (split.length == 2)
....@@ -5377,16 +5646,16 @@
53775646 if (fullname.name.endsWith(":"))
53785647 {
53795648 // Windows
5380
- return "";
5649
+ return fullname.bump = "";
53815650 }
53825651
5383
- return split[1];
5652
+ return fullname.bump = split[1];
53845653 }
53855654
53865655 // Windows
53875656 assert(split.length == 4);
53885657
5389
- return split[2] + ":" + split[3];
5658
+ return fullname.bump = split[2] + ":" + split[3];
53905659 }
53915660
53925661 String GetPigmentTexture()
....@@ -5469,6 +5738,9 @@
54695738 texname = "";
54705739
54715740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
54725744 Touch();
54735745 }
54745746
....@@ -5542,6 +5814,8 @@
55425814
55435815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
55445816
5817
+ GetTextures().bump = null;
5818
+
55455819 Touch();
55465820 }
55475821
....@@ -5562,6 +5836,38 @@
55625836
55635837 blockloop = true;
55645838 child.ResetBumpTexture();
5839
+ blockloop = false;
5840
+ }
5841
+ }
5842
+
5843
+ void EmbedTextures(boolean embed)
5844
+ {
5845
+ if (blockloop)
5846
+ return;
5847
+
5848
+ //if (GetTextures() != null)
5849
+ if (embed)
5850
+ CameraPane.EmbedTextures(GetTextures());
5851
+ else
5852
+ {
5853
+ GetTextures().pigmentdata = null;
5854
+ GetTextures().bumpdata = null;
5855
+ GetTextures().pw = 0;
5856
+ GetTextures().ph = 0;
5857
+ GetTextures().bw = 0;
5858
+ GetTextures().bh = 0;
5859
+ }
5860
+
5861
+ int nb = Size();
5862
+ for (int i = 0; i < nb; i++)
5863
+ {
5864
+ Object3D child = (Object3D) get(i);
5865
+
5866
+ if (child == null)
5867
+ continue;
5868
+
5869
+ blockloop = true;
5870
+ child.EmbedTextures(embed);
55655871 blockloop = false;
55665872 }
55675873 }
....@@ -5652,8 +5958,10 @@
56525958 if (support != null)
56535959 support = support;
56545960
5655
- //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);
5961
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5962
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5963
+
5964
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56575965
56585966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595967 {
....@@ -5663,8 +5971,9 @@
56635971 // usecalllists &= !(parent instanceof RandomNode);
56645972 // usecalllists = false;
56655973
5666
- if (GetBRep() != null)
5667
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
56685977 //System.out.println("draw " + this);
56695978 //new Exception().printStackTrace();
56705979
....@@ -5673,10 +5982,12 @@
56735982 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56745983
56755984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5676
- (touched || (bRep != null && bRep.displaylist <= 0)))
5985
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5986
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56775987 {
56785988 Globals.lighttouched = true;
56795989 } // all panes...
5990
+
56805991 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56815992 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56825993 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5684,7 +5995,7 @@
56845995 if (!(this instanceof Composite))
56855996 touched = false;
56865997 //if (displaylist == -1 && usecalllists)
5687
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56885999 {
56896000 bRep.displaylist = display.GenList();
56906001 assert(bRep.displaylist != 0);
....@@ -5695,7 +6006,7 @@
56956006
56966007 //System.out.println("\tnew list " + list);
56976008 //gl.glDrawBuffer(gl.GL_NONE);
5698
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
56996010 {
57006011 // System.err.println("new list " + bRep.displaylist + " for " + this);
57016012 display.NewList(bRep.displaylist);
....@@ -5704,7 +6015,7 @@
57046015 CallList(display, root, selected, blocked);
57056016
57066017 // compiled = true;
5707
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
57086019 {
57096020 // System.err.println("end list " + bRep.displaylist + " for " + this);
57106021 display.EndList();
....@@ -5804,6 +6115,7 @@
58046115 if (GetBRep() != null)
58056116 {
58066117 display.NextIndex();
6118
+
58076119 // vertex color conflict : gl.glCallList(list);
58086120 DrawNode(display, root, selected);
58096121 if (this instanceof BezierPatch)
....@@ -5844,16 +6156,27 @@
58446156 tex = GetTextures();
58456157 }
58466158
5847
- boolean failed = false;
6159
+ boolean failedPigment = false;
6160
+ boolean failedBump = false;
58486161
58496162 try
58506163 {
5851
- display.BindTextures(tex, texres);
6164
+ display.BindPigmentTexture(tex, texres);
58526165 }
58536166 catch (Exception e)
58546167 {
58556168 System.err.println("FAILED: " + this);
5856
- failed = true;
6169
+ failedPigment = true;
6170
+ }
6171
+
6172
+ try
6173
+ {
6174
+ display.BindBumpTexture(tex, texres);
6175
+ }
6176
+ catch (Exception e)
6177
+ {
6178
+ //System.err.println("FAILED: " + this);
6179
+ failedBump = true;
58576180 }
58586181
58596182 if (!compiled)
....@@ -5876,8 +6199,11 @@
58766199 }
58776200 }
58786201
5879
- if (!failed)
5880
- display.ReleaseTextures(tex);
6202
+ if (!failedBump)
6203
+ display.ReleaseBumpTexture(tex);
6204
+
6205
+ if (!failedPigment)
6206
+ display.ReleasePigmentTexture(tex);
58816207
58826208 display.PopMaterial(this, selected);
58836209 }
....@@ -6250,6 +6576,11 @@
62506576 // dec 2012
62516577 new Exception().printStackTrace();
62526578 return;
6579
+ }
6580
+
6581
+ if (dontselect)
6582
+ {
6583
+ //bRep.GenerateNormalsMINE();
62536584 }
62546585
62556586 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7035,20 +7366,23 @@
70357366 }
70367367 }
70377368
7038
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7369
+ static ClickInfo clickInfo = new ClickInfo();
7370
+
7371
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7372
+ Point outPt, Rectangle outRec)
70397373 {
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;
7374
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7375
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7376
+ double[][] toscreen = clickInfo.toScreen;
70437377 if (toscreen == null)
70447378 {
7045
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70467380 }
70477381 cVector vec = in;
70487382 LA.xformPos(in, toscreen, in);
70497383 //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();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70527386 outPt.x = hc + (int) vec.x;
70537387 outPt.y = vc - (int) vec.y;
70547388 outRec.x = outPt.x - 3;
....@@ -7056,15 +7390,18 @@
70567390 outRec.width = outRec.height = 6;
70577391 }
70587392
7059
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
70607395 {
70617396 Point pt = new Point(0, 0);
70627397 Rectangle rec = new Rectangle();
7063
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
70647400 return rec;
70657401 }
70667402
7067
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
70687405 {
70697406 if (level == 0)
70707407 {
....@@ -7073,16 +7410,19 @@
70737410 {
70747411 cVector origin = new cVector();
70757412 //LA.xformPos(origin, toParent, origin);
7076
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70777417 Rectangle boundary = new Rectangle();
70787418 boundary.x = spot.x - 30;
70797419 boundary.y = spot.y - 30;
70807420 boundary.width = spot.width + 60;
70817421 boundary.height = spot.height + 60;
7082
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
70837423 int spotw = spot.x + spot.width;
70847424 int spoth = spot.y + spot.height;
7085
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70867426 // if (CameraPane.Xmin > spot.x)
70877427 // {
70887428 // CameraPane.Xmin = spot.x;
....@@ -7099,11 +7439,6 @@
70997439 // {
71007440 // CameraPane.Ymax = spoth;
71017441 // }
7102
- spot.translate(32, 32);
7103
- spotw = spot.x + spot.width;
7104
- spoth = spot.y + spot.height;
7105
- info.g.setColor(Color.cyan);
7106
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71077442 // if (CameraPane.Xmin > spot.x)
71087443 // {
71097444 // CameraPane.Xmin = spot.x;
....@@ -7122,10 +7457,15 @@
71227457 // }
71237458 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
71247459 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7125
- spot.translate(0, -32);
7126
- info.g.setColor(Color.yellow);
7127
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7128
- info.g.setColor(Color.green);
7460
+ spot.translate(32, 0);
7461
+ clickInfo.g.setColor(Color.yellow);
7462
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7463
+
7464
+ spot.translate(32, 64);
7465
+ spotw = spot.x + spot.width;
7466
+ spoth = spot.y + spot.height;
7467
+ clickInfo.g.setColor(Color.cyan);
7468
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71297469 // if (CameraPane.Xmin > spot.x)
71307470 // {
71317471 // CameraPane.Xmin = spot.x;
....@@ -7142,8 +7482,9 @@
71427482 // {
71437483 // CameraPane.Ymax = spoth;
71447484 // }
7145
- info.g.drawArc(boundary.x, boundary.y,
7146
- boundary.width, boundary.height, 0, 360);
7485
+ clickInfo.g.setColor(Color.green);
7486
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7487
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71477488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71487489 // if (CameraPane.Xmin > boundary.x)
71497490 // {
....@@ -7165,7 +7506,8 @@
71657506 }
71667507 }
71677508
7168
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
71697511 {
71707512 if (level == 0)
71717513 {
....@@ -7174,8 +7516,8 @@
71747516
71757517 boolean retval = false;
71767518
7177
- startX = info.x;
7178
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
71797521
71807522 hitSomething = -1;
71817523 cVector origin = new cVector();
....@@ -7185,22 +7527,53 @@
71857527 {
71867528 centerPt = new Point(0, 0);
71877529 }
7188
- calcHotSpot(origin, info, centerPt, spot);
7189
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
71907533 {
71917534 hitSomething = hitCenter;
71927535 retval = true;
71937536 }
71947537 spot.translate(32, 0);
7195
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
71967539 {
71977540 hitSomething = hitRotate;
71987541 retval = true;
71997542 }
72007543 spot.translate(0, 32);
7201
- if (spot.contains(info.x, info.y))
7544
+ spot.translate(32, 0);
7545
+ spot.translate(0, 32);
7546
+ if (spot.contains(clickInfo.x, clickInfo.y))
72027547 {
72037548 hitSomething = hitScale;
7549
+
7550
+ double scale = 0.005f * clickInfo.camera.Distance();
7551
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7552
+ double sign = 1;
7553
+ if (hScale < 0)
7554
+ {
7555
+ sign = -1;
7556
+ }
7557
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7558
+ if (hScale < 0.01)
7559
+ {
7560
+ //hScale = 0.01;
7561
+ }
7562
+
7563
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7564
+ sign = 1;
7565
+ if (vScale < 0)
7566
+ {
7567
+ sign = -1;
7568
+ }
7569
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7570
+ if (vScale < 0.01)
7571
+ {
7572
+ //vScale = 0.01;
7573
+ }
7574
+
7575
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7576
+
72047577 retval = true;
72057578 }
72067579
....@@ -7210,7 +7583,7 @@
72107583 }
72117584
72127585 //System.out.println("info.modifiers = " + info.modifiers);
7213
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72147587 //System.out.println("modified = " + modified);
72157588 //new Exception().printStackTrace();
72167589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7238,7 +7611,8 @@
72387611 return true;
72397612 }
72407613
7241
- void doEditDrag0(ClickInfo info, boolean opposite)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
72427616 {
72437617 if (hitSomething == 0)
72447618 {
....@@ -7252,7 +7626,7 @@
72527626
72537627 //System.out.println("hitSomething = " + hitSomething);
72547628
7255
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
72567630
72577631 cVector xlate = new cVector();
72587632 //cVector xlate2 = new cVector();
....@@ -7286,8 +7660,8 @@
72867660 toParent[3][i] = xlate.get(i);
72877661 LA.matInvert(toParent, fromParent);
72887662 */
7289
- cVector delta = LA.newVector(0, 0, startY - info.y);
7290
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7663
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7664
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72917665
72927666 LA.matCopy(startMat, toParent);
72937667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7296,7 +7670,7 @@
72967670 } else
72977671 {
72987672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7299
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
73007674 cVector away = new cVector();
73017675 //cVector right2 = new cVector();
73027676 //LA.vecCross(up, cVector.Z, right);
....@@ -7313,19 +7687,19 @@
73137687 LA.xformDir(up, ClickInfo.matbuffer, up);
73147688 // if (!CameraPane.LOCALTRANSFORM)
73157689 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7316
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73177691 // if (!CameraPane.LOCALTRANSFORM)
73187692 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73197693 //LA.vecCross(up, cVector.Z, right2);
73207694
7321
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73227696
73237697 //System.out.println("DELTA0 = " + delta);
73247698 //System.out.println("AWAY = " + info.camera.away);
73257699 //System.out.println("UP = " + info.camera.up);
73267700 if (away.z > 0)
73277701 {
7328
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73297703 {
73307704 delta.x = -delta.x;
73317705 } else
....@@ -7340,7 +7714,7 @@
73407714 //System.out.println("DELTA1 = " + delta);
73417715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73427716 //System.out.println("DELTA2 = " + delta);
7343
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73447718 LA.matCopy(startMat, toParent);
73457719 //System.out.println("DELTA3 = " + delta);
73467720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7350,8 +7724,8 @@
73507724 break;
73517725
73527726 case hitRotate: // rotate
7353
- int dx = info.x - centerPt.x;
7354
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
73557729 double angle = (double) Math.atan2(dx, dy);
73567730 angle = -(1.570796 - angle);
73577731
....@@ -7374,7 +7748,7 @@
73747748 }
73757749 /**/
73767750
7377
- switch (info.pane.RenderCamera().viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
73787752 {
73797753 case 1: // '\001'
73807754 LA.matZRotate(toParent, angle);
....@@ -7401,7 +7775,7 @@
74017775 break;
74027776
74037777 case hitScale: // scale
7404
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74057779 double sign = 1;
74067780 if (hScale < 0)
74077781 {
....@@ -7413,7 +7787,7 @@
74137787 //hScale = 0.01;
74147788 }
74157789
7416
- double vScale = (double) (info.y - centerPt.y) / 32;
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
74177791 sign = 1;
74187792 if (vScale < 0)
74197793 {
....@@ -7424,6 +7798,7 @@
74247798 {
74257799 //vScale = 0.01;
74267800 }
7801
+
74277802 LA.matCopy(startMat, toParent);
74287803 /**/
74297804 for (int i = 0; i < 3; i++)
....@@ -7433,23 +7808,27 @@
74337808 }
74347809 /**/
74357810
7436
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74377812
74387813 if (totalScale < 0.01)
74397814 {
74407815 totalScale = 0.01;
74417816 }
74427817
7443
- switch (info.pane.RenderCamera().viewCode)
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
74447819 {
74457820 case 3: // '\001'
74467821 if (modified || opposite)
74477822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
74487826 //LA.matScale(toParent, 1, hScale, vScale);
7449
- LA.matScale(toParent, totalScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
74507828 } // vScale, 1);
74517829 else
74527830 {
7831
+ // EXCEPTION!
74537832 LA.matScale(toParent, 1, totalScale, totalScale);
74547833 } // vScale, 1);
74557834 break;
....@@ -7457,8 +7836,11 @@
74577836 case 2: // '\002'
74587837 if (modified || opposite)
74597838 {
7460
- //LA.matScale(toParent, hScale, 1, vScale);
7461
- LA.matScale(toParent, 1, totalScale, 1);
7839
+ if (modified && opposite)
7840
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7841
+ else
7842
+ //LA.matScale(toParent, hScale, 1, vScale);
7843
+ LA.matScale(toParent, 1, totalScale, 1);
74627844 } else
74637845 {
74647846 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7468,8 +7850,11 @@
74687850 case 1: // '\003'
74697851 if (modified || opposite)
74707852 {
7471
- //LA.matScale(toParent, hScale, vScale, 1);
7472
- LA.matScale(toParent, 1, 1, totalScale);
7853
+ if (modified && opposite)
7854
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7855
+ else
7856
+ //LA.matScale(toParent, hScale, vScale, 1);
7857
+ LA.matScale(toParent, 1, 1, totalScale);
74737858 } else
74747859 {
74757860 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7506,7 +7891,7 @@
75067891 } // NEW ...
75077892
75087893
7509
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
75107895 }
75117896
75127897 boolean overflow = false;
....@@ -7686,6 +8071,10 @@
76868071 editWindow = null;
76878072 } // ?
76888073 }
8074
+ else
8075
+ {
8076
+ //editWindow.closeUI();
8077
+ }
76898078 }
76908079
76918080 boolean root; // patch for edit windows
....@@ -7843,6 +8232,10 @@
78438232 }
78448233
78458234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
78468239 transient ObjectUI objectUI;
78478240 public static int povDepth = 0;
78488241 private static cVector tbMin = new cVector();