Normand Briere
2019-08-08 8294241adc5fe698b70e13ebd6780af46ab83f7e
Object3D.java
....@@ -22,13 +22,20 @@
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 //
3132
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
3239 ScriptNode scriptnode;
3340
3441 void InitOthers()
....@@ -170,24 +177,35 @@
170177
171178 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172179 {
180
+ Object3D o;
181
+
173182 if (hashtable.containsKey(GetUUID()))
174183 {
175
- Object3D o = hashtable.get(GetUUID());
184
+ o = hashtable.get(GetUUID());
176185
177
- assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
186
+ Grafreed.Assert(this.bRep == o.bRep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
180195
181
- return;
196
+ hashtable.put(GetUUID(), o);
182197 }
183198
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
199
+ if (!blockloop)
189200 {
190
- get(i).ExtractBigData(hashtable);
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
191209 }
192210
193211 ExtractBigData(o);
....@@ -195,11 +213,26 @@
195213
196214 void ExtractBigData(Object3D o)
197215 {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
198219 o.bRep = this.bRep;
199
- if (this.bRep != null)
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
200230 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
203236 }
204237
205238 // o.support = this.support;
....@@ -214,6 +247,29 @@
214247 // this.fileparent = null;
215248 }
216249
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
217273 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218274 {
219275 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +279,35 @@
223279
224280 RestoreBigData(o);
225281
226
- hashtable.remove(GetUUID());
282
+ if (blockloop)
283
+ return;
284
+
285
+ blockloop = true;
286
+
287
+ //hashtable.remove(GetUUID());
227288
228289 for (int i=0; i<Size(); i++)
229290 {
230291 get(i).RestoreBigData(hashtable);
231292 }
293
+
294
+ blockloop = false;
232295 }
233296
234297 void RestoreBigData(Object3D o)
235298 {
236299 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
239311 // this.support = o.support;
240312 // this.fileparent = o.fileparent;
241313 }
....@@ -381,6 +453,7 @@
381453 }
382454
383455 boolean live = false;
456
+ transient boolean keepdontselect;
384457 boolean dontselect = false;
385458 boolean hide = false;
386459 boolean link2master = false; // performs reset support/master at each frame
....@@ -563,12 +636,14 @@
563636 toParent = LA.newMatrix();
564637 fromParent = LA.newMatrix();
565638 }
639
+
566640 if (toParentMarked == null)
567641 {
568642 if (maxcount != 1)
569643 {
570644 new Exception().printStackTrace();
571645 }
646
+
572647 toParentMarked = LA.newMatrix();
573648 fromParentMarked = LA.newMatrix();
574649 }
....@@ -879,7 +954,7 @@
879954
880955 if (marked && Globals.isLIVE() && live &&
881956 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883958 currentframe != Globals.framecount)
884959 {
885960 currentframe = Globals.framecount;
....@@ -891,7 +966,8 @@
891966
892967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893968
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
895971 {
896972 countdown = 1;
897973 delay = speedup?8:1;
....@@ -963,6 +1039,10 @@
9631039 if (material == null || material.multiply)
9641040 return true;
9651041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
9661046 return material.opacity > 0.99;
9671047 }
9681048
....@@ -1363,6 +1443,7 @@
13631443 toParent = LA.newMatrix();
13641444 fromParent = LA.newMatrix();
13651445 }
1446
+
13661447 LA.matCopy(other.toParent, toParent);
13671448 LA.matCopy(other.fromParent, fromParent);
13681449
....@@ -2384,6 +2465,11 @@
23842465 }
23852466 */
23862467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2472
+ }
23872473 }
23882474
23892475 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2511,14 @@
24252511 {
24262512 editWindow.refreshContents();
24272513 }
2514
+ else
2515
+ {
2516
+ if (manipWindow != null)
2517
+ {
2518
+ manipWindow.refreshContents();
2519
+ }
2520
+ }
2521
+
24282522 //if (parent != null)
24292523 //parent.refreshEditWindow();
24302524 }
....@@ -2504,7 +2598,8 @@
25042598 private static final int editSelf = 1;
25052599 private static final int editChild = 2;
25062600
2507
- void drawEditHandles(ClickInfo info, int level)
2601
+ void drawEditHandles(//ClickInfo info,
2602
+ int level)
25082603 {
25092604 if (level == 0)
25102605 {
....@@ -2512,7 +2607,8 @@
25122607 return;
25132608
25142609 Object3D selectee;
2515
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2610
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2611
+ level + 1))
25162612 {
25172613 selectee = (Object3D) e.nextElement();
25182614 }
....@@ -2520,19 +2616,22 @@
25202616 } else
25212617 {
25222618 //super.
2523
- drawEditHandles0(info, level + 1);
2619
+ drawEditHandles0(//info,
2620
+ level + 1);
25242621 }
25252622 }
25262623
2527
- boolean doEditClick(ClickInfo info, int level)
2624
+ boolean doEditClick(//ClickInfo info,
2625
+ int level)
25282626 {
25292627 doSomething = 0;
25302628 if (level == 0)
25312629 {
2532
- return doParentClick(info);
2630
+ return doParentClick(); //info);
25332631 }
25342632 if (//super.
2535
- doEditClick0(info, level))
2633
+ doEditClick0(//info,
2634
+ level))
25362635 {
25372636 doSomething = 1;
25382637 return true;
....@@ -2542,7 +2641,7 @@
25422641 }
25432642 }
25442643
2545
- boolean doParentClick(ClickInfo info)
2644
+ boolean doParentClick() //ClickInfo info)
25462645 {
25472646 if (selection == null)
25482647 {
....@@ -2555,7 +2654,8 @@
25552654 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25562655 {
25572656 Object3D selectee = (Object3D) e.nextElement();
2558
- if (selectee.doEditClick(info, 1))
2657
+ if (selectee.doEditClick(//info,
2658
+ 1))
25592659 {
25602660 childToDrag = selectee;
25612661 doSomething = 2;
....@@ -2567,13 +2667,15 @@
25672667 return retval;
25682668 }
25692669
2570
- void doEditDrag(ClickInfo info, boolean opposite)
2670
+ void doEditDrag(//ClickInfo clickInfo,
2671
+ boolean opposite)
25712672 {
25722673 switch (doSomething)
25732674 {
25742675 case 1: // '\001'
25752676 //super.
2576
- doEditDrag0(info, opposite);
2677
+ doEditDrag0(//clickInfo,
2678
+ opposite);
25772679 break;
25782680
25792681 case 2: // '\002'
....@@ -2586,11 +2688,13 @@
25862688 {
25872689 //sel.hitSomething = childToDrag.hitSomething;
25882690 //childToDrag.doEditDrag(info);
2589
- sel.doEditDrag(info, opposite);
2691
+ sel.doEditDrag(//clickInfo,
2692
+ opposite);
25902693 } else
25912694 {
25922695 //super.
2593
- doEditDrag0(info, opposite);
2696
+ doEditDrag0(//clickInfo,
2697
+ opposite);
25942698 }
25952699 }
25962700 break;
....@@ -2608,6 +2712,9 @@
26082712 {
26092713 deselectAll();
26102714 }
2715
+
2716
+ new Exception().printStackTrace();
2717
+
26112718 ClickInfo newInfo = new ClickInfo();
26122719 newInfo.flags = info.flags;
26132720 newInfo.bounds = info.bounds;
....@@ -3055,7 +3162,7 @@
30553162 {
30563163 if (bRep != null)
30573164 {
3058
- bRep.GenerateNormalsMINE();
3165
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593166 Touch();
30603167 }
30613168 }
....@@ -3501,7 +3608,8 @@
35013608 if (blockloop)
35023609 return;
35033610
3504
- if (marked || (bRep != null && material != null)) // borderline...
3611
+ if (//marked || // does not make sense
3612
+ (bRep != null || material != null)) // borderline...
35053613 live = h;
35063614
35073615 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3630,8 @@
35223630 return;
35233631
35243632 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3633
+ if (//marked || // does not make sense
3634
+ (bRep != null || material != null)) // borderline...
35263635 link2master = h;
35273636
35283637 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3651,8 @@
35423651 if (blockloop)
35433652 return;
35443653
3545
- if (marked || (bRep != null && material != null)) // borderline...
3654
+ if (//marked || // does not make sense
3655
+ (bRep != null || material != null)) // borderline...
35463656 hide = h;
35473657
35483658 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3672,7 @@
35623672 if (blockloop)
35633673 return;
35643674
3565
- if (bRep != null && material != null) // borderline...
3675
+ if (bRep != null || material != null) // borderline...
35663676 marked = h;
35673677
35683678 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3682,46 @@
35723682 continue;
35733683 blockloop = true;
35743684 child.MarkLeaves(h);
3685
+ blockloop = false;
3686
+ // release(i);
3687
+ }
3688
+ }
3689
+
3690
+ void RewindLeaves(boolean h)
3691
+ {
3692
+ if (blockloop)
3693
+ return;
3694
+
3695
+ if (bRep != null || material != null) // borderline...
3696
+ rewind = h;
3697
+
3698
+ for (int i = 0; i < Size(); i++)
3699
+ {
3700
+ Object3D child = (Object3D) get(i); // reserve(i);
3701
+ if (child == null)
3702
+ continue;
3703
+ blockloop = true;
3704
+ child.RewindLeaves(h);
3705
+ blockloop = false;
3706
+ // release(i);
3707
+ }
3708
+ }
3709
+
3710
+ void RandomLeaves(boolean h)
3711
+ {
3712
+ if (blockloop)
3713
+ return;
3714
+
3715
+ if (bRep != null || material != null) // borderline...
3716
+ random = h;
3717
+
3718
+ for (int i = 0; i < Size(); i++)
3719
+ {
3720
+ Object3D child = (Object3D) get(i); // reserve(i);
3721
+ if (child == null)
3722
+ continue;
3723
+ blockloop = true;
3724
+ child.RandomLeaves(h);
35753725 blockloop = false;
35763726 // release(i);
35773727 }
....@@ -4349,6 +4499,55 @@
43494499 }
43504500 }
43514501
4502
+ void RepairSOV()
4503
+ {
4504
+ if (blockloop)
4505
+ return;
4506
+
4507
+ String texname = this.GetPigmentTexture();
4508
+
4509
+ if (texname.startsWith("sov"))
4510
+ {
4511
+ String[] s = texname.split("/");
4512
+
4513
+ String[] sname = s[1].split("Color.pn");
4514
+
4515
+ texname = sname[0];
4516
+
4517
+ if (sname.length > 1)
4518
+ {
4519
+ texname += "Color.jpg";
4520
+ }
4521
+
4522
+ this.SetPigmentTexture("sov/" + texname);
4523
+ }
4524
+
4525
+ texname = this.GetBumpTexture();
4526
+
4527
+ if (texname.startsWith("sov"))
4528
+ {
4529
+ String[] s = texname.split("/");
4530
+
4531
+ String[] sname = s[1].split("Bump.pn");
4532
+
4533
+ texname = sname[0];
4534
+
4535
+ if (sname.length > 1)
4536
+ {
4537
+ texname += "Bump.jpg";
4538
+ }
4539
+
4540
+ this.SetBumpTexture("sov/" + texname);
4541
+ }
4542
+
4543
+ for (int i=0; i<Size(); i++)
4544
+ {
4545
+ blockloop = true;
4546
+ get(i).RepairSOV();
4547
+ blockloop = false;
4548
+ }
4549
+ }
4550
+
43524551 void RepairTexture()
43534552 {
43544553 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5062,14 @@
48635062 }
48645063 }
48655064
5065
+ ObjEditor GetWindow()
5066
+ {
5067
+ if (editWindow != null)
5068
+ return editWindow;
5069
+
5070
+ return manipWindow;
5071
+ }
5072
+
48665073 cTreePath Select(int indexcount, boolean deselect)
48675074 {
48685075 if (hide || dontselect)
....@@ -4899,10 +5106,11 @@
48995106 if (leaf != null)
49005107 {
49015108 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
49035111 {
49045112 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5113
+ window.Select(tp, deselect, true);
49065114 }
49075115
49085116 return tp;
....@@ -4919,6 +5127,7 @@
49195127
49205128 if (child == null)
49215129 continue;
5130
+
49225131 if (child.HasTransparency() && child.size() != 0)
49235132 {
49245133 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5137,10 @@
49285137 if (leaf != null)
49295138 {
49305139 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5140
+ ObjEditor window = GetWindow();
5141
+ if (window != null)
49325142 {
4933
- editWindow.Select(tp, deselect, true);
5143
+ window.Select(tp, deselect, true);
49345144 }
49355145
49365146 return tp;
....@@ -5255,6 +5465,51 @@
52555465 blockloop = false;
52565466 }
52575467
5468
+ void ResetSelectable()
5469
+ {
5470
+ if (blockloop)
5471
+ return;
5472
+
5473
+ blockloop = true;
5474
+
5475
+ keepdontselect = dontselect;
5476
+ dontselect = true;
5477
+
5478
+ Object3D child;
5479
+ int nb = Size();
5480
+ for (int i = 0; i < nb; i++)
5481
+ {
5482
+ child = (Object3D) get(i);
5483
+ if (child == null)
5484
+ continue;
5485
+ child.ResetSelectable();
5486
+ }
5487
+
5488
+ blockloop = false;
5489
+ }
5490
+
5491
+ void RestoreSelectable()
5492
+ {
5493
+ if (blockloop)
5494
+ return;
5495
+
5496
+ blockloop = true;
5497
+
5498
+ dontselect = keepdontselect;
5499
+
5500
+ Object3D child;
5501
+ int nb = Size();
5502
+ for (int i = 0; i < nb; i++)
5503
+ {
5504
+ child = (Object3D) get(i);
5505
+ if (child == null)
5506
+ continue;
5507
+ child.RestoreSelectable();
5508
+ }
5509
+
5510
+ blockloop = false;
5511
+ }
5512
+
52585513 boolean IsSelected()
52595514 {
52605515 if (parent == null)
....@@ -5564,6 +5819,38 @@
55645819 }
55655820 }
55665821
5822
+ void EmbedTextures(boolean embed)
5823
+ {
5824
+ if (blockloop)
5825
+ return;
5826
+
5827
+ //if (GetTextures() != null)
5828
+ if (embed)
5829
+ CameraPane.EmbedTextures(GetTextures());
5830
+ else
5831
+ {
5832
+ GetTextures().pigmentdata = null;
5833
+ GetTextures().bumpdata = null;
5834
+ GetTextures().pw = 0;
5835
+ GetTextures().ph = 0;
5836
+ GetTextures().bw = 0;
5837
+ GetTextures().bh = 0;
5838
+ }
5839
+
5840
+ int nb = Size();
5841
+ for (int i = 0; i < nb; i++)
5842
+ {
5843
+ Object3D child = (Object3D) get(i);
5844
+
5845
+ if (child == null)
5846
+ continue;
5847
+
5848
+ blockloop = true;
5849
+ child.EmbedTextures(embed);
5850
+ blockloop = false;
5851
+ }
5852
+ }
5853
+
55675854 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685855 {
55695856 Draw(display, root, selected, blocked);
....@@ -5572,12 +5859,23 @@
55725859 boolean NeedSupport()
55735860 {
55745861 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5862
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765863 // PROBLEM with CROWD!!
55775864 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785865 }
55795866
55805867 static boolean DEBUG_SELECTION = false;
5868
+
5869
+ boolean IsLive()
5870
+ {
5871
+ if (live)
5872
+ return true;
5873
+
5874
+ if (parent == null)
5875
+ return false;
5876
+
5877
+ return parent.IsLive();
5878
+ }
55815879
55825880 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835881 {
....@@ -5639,8 +5937,10 @@
56395937 if (support != null)
56405938 support = support;
56415939
5642
- //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);
5940
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5942
+
5943
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56445944
56455945 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465946 {
....@@ -5650,8 +5950,9 @@
56505950 // usecalllists &= !(parent instanceof RandomNode);
56515951 // usecalllists = false;
56525952
5653
- if (GetBRep() != null)
5654
- usecalllists = usecalllists;
5953
+ if (display.DrawMode() == display.SHADOW)
5954
+ //GetBRep() != null)
5955
+ usecalllists = !!usecalllists;
56555956 //System.out.println("draw " + this);
56565957 //new Exception().printStackTrace();
56575958
....@@ -5660,10 +5961,12 @@
56605961 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615962
56625963 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5964
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5965
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645966 {
56655967 Globals.lighttouched = true;
56665968 } // all panes...
5969
+
56675970 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685971 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695972 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5671,7 +5974,7 @@
56715974 if (!(this instanceof Composite))
56725975 touched = false;
56735976 //if (displaylist == -1 && usecalllists)
5674
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5977
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56755978 {
56765979 bRep.displaylist = display.GenList();
56775980 assert(bRep.displaylist != 0);
....@@ -5682,7 +5985,7 @@
56825985
56835986 //System.out.println("\tnew list " + list);
56845987 //gl.glDrawBuffer(gl.GL_NONE);
5685
- if (usecalllists)
5988
+ if (usecalllists && bRep.displaylist > 0)
56865989 {
56875990 // System.err.println("new list " + bRep.displaylist + " for " + this);
56885991 display.NewList(bRep.displaylist);
....@@ -5691,7 +5994,7 @@
56915994 CallList(display, root, selected, blocked);
56925995
56935996 // compiled = true;
5694
- if (usecalllists)
5997
+ if (usecalllists && bRep.displaylist > 0)
56955998 {
56965999 // System.err.println("end list " + bRep.displaylist + " for " + this);
56976000 display.EndList();
....@@ -5791,6 +6094,7 @@
57916094 if (GetBRep() != null)
57926095 {
57936096 display.NextIndex();
6097
+
57946098 // vertex color conflict : gl.glCallList(list);
57956099 DrawNode(display, root, selected);
57966100 if (this instanceof BezierPatch)
....@@ -5831,16 +6135,27 @@
58316135 tex = GetTextures();
58326136 }
58336137
5834
- boolean failed = false;
6138
+ boolean failedPigment = false;
6139
+ boolean failedBump = false;
58356140
58366141 try
58376142 {
5838
- display.BindTextures(tex, texres);
6143
+ display.BindPigmentTexture(tex, texres);
58396144 }
58406145 catch (Exception e)
58416146 {
58426147 System.err.println("FAILED: " + this);
5843
- failed = true;
6148
+ failedPigment = true;
6149
+ }
6150
+
6151
+ try
6152
+ {
6153
+ display.BindBumpTexture(tex, texres);
6154
+ }
6155
+ catch (Exception e)
6156
+ {
6157
+ //System.err.println("FAILED: " + this);
6158
+ failedBump = true;
58446159 }
58456160
58466161 if (!compiled)
....@@ -5863,8 +6178,11 @@
58636178 }
58646179 }
58656180
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6181
+ if (!failedBump)
6182
+ display.ReleaseBumpTexture(tex);
6183
+
6184
+ if (!failedPigment)
6185
+ display.ReleasePigmentTexture(tex);
58686186
58696187 display.PopMaterial(this, selected);
58706188 }
....@@ -6237,6 +6555,11 @@
62376555 // dec 2012
62386556 new Exception().printStackTrace();
62396557 return;
6558
+ }
6559
+
6560
+ if (dontselect)
6561
+ {
6562
+ //bRep.GenerateNormalsMINE();
62406563 }
62416564
62426565 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7022,20 +7345,23 @@
70227345 }
70237346 }
70247347
7025
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7348
+ static ClickInfo clickInfo = new ClickInfo();
7349
+
7350
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7351
+ Point outPt, Rectangle outRec)
70267352 {
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;
7353
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7354
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7355
+ double[][] toscreen = clickInfo.toScreen;
70307356 if (toscreen == null)
70317357 {
7032
- toscreen = new Camera(info.camera.viewCode).toScreen;
7358
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70337359 }
70347360 cVector vec = in;
70357361 LA.xformPos(in, toscreen, in);
70367362 //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();
7363
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7364
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70397365 outPt.x = hc + (int) vec.x;
70407366 outPt.y = vc - (int) vec.y;
70417367 outRec.x = outPt.x - 3;
....@@ -7043,15 +7369,18 @@
70437369 outRec.width = outRec.height = 6;
70447370 }
70457371
7046
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7372
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7373
+ )
70477374 {
70487375 Point pt = new Point(0, 0);
70497376 Rectangle rec = new Rectangle();
7050
- calcHotSpot(in, info, pt, rec);
7377
+ calcHotSpot(in, //clickInfo,
7378
+ pt, rec);
70517379 return rec;
70527380 }
70537381
7054
- void drawEditHandles0(ClickInfo info, int level)
7382
+ void drawEditHandles0(//ClickInfo clickInfo,
7383
+ int level)
70557384 {
70567385 if (level == 0)
70577386 {
....@@ -7060,16 +7389,19 @@
70607389 {
70617390 cVector origin = new cVector();
70627391 //LA.xformPos(origin, toParent, origin);
7063
- Rectangle spot = calcHotSpot(origin, info);
7392
+ if (this.clickInfo == null)
7393
+ this.clickInfo = new ClickInfo();
7394
+
7395
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70647396 Rectangle boundary = new Rectangle();
70657397 boundary.x = spot.x - 30;
70667398 boundary.y = spot.y - 30;
70677399 boundary.width = spot.width + 60;
70687400 boundary.height = spot.height + 60;
7069
- info.g.setColor(Color.red);
7401
+ clickInfo.g.setColor(Color.red);
70707402 int spotw = spot.x + spot.width;
70717403 int spoth = spot.y + spot.height;
7072
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7404
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70737405 // if (CameraPane.Xmin > spot.x)
70747406 // {
70757407 // CameraPane.Xmin = spot.x;
....@@ -7089,8 +7421,8 @@
70897421 spot.translate(32, 32);
70907422 spotw = spot.x + spot.width;
70917423 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7093
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7424
+ clickInfo.g.setColor(Color.cyan);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947426 // if (CameraPane.Xmin > spot.x)
70957427 // {
70967428 // CameraPane.Xmin = spot.x;
....@@ -7107,11 +7439,12 @@
71077439 // {
71087440 // CameraPane.Ymax = spoth;
71097441 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7442
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7443
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127444 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7114
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7445
+ clickInfo.g.setColor(Color.yellow);
7446
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7447
+ clickInfo.g.setColor(Color.green);
71157448 // if (CameraPane.Xmin > spot.x)
71167449 // {
71177450 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7461,8 @@
71287461 // {
71297462 // CameraPane.Ymax = spoth;
71307463 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7464
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7465
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71337466 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347467 // if (CameraPane.Xmin > boundary.x)
71357468 // {
....@@ -7151,7 +7484,8 @@
71517484 }
71527485 }
71537486
7154
- boolean doEditClick0(ClickInfo info, int level)
7487
+ boolean doEditClick0(//ClickInfo clickInfo,
7488
+ int level)
71557489 {
71567490 if (level == 0)
71577491 {
....@@ -7160,8 +7494,8 @@
71607494
71617495 boolean retval = false;
71627496
7163
- startX = info.x;
7164
- startY = info.y;
7497
+ startX = clickInfo.x;
7498
+ startY = clickInfo.y;
71657499
71667500 hitSomething = -1;
71677501 cVector origin = new cVector();
....@@ -7171,22 +7505,51 @@
71717505 {
71727506 centerPt = new Point(0, 0);
71737507 }
7174
- calcHotSpot(origin, info, centerPt, spot);
7175
- if (spot.contains(info.x, info.y))
7508
+ calcHotSpot(origin, //info,
7509
+ centerPt, spot);
7510
+ if (spot.contains(clickInfo.x, clickInfo.y))
71767511 {
71777512 hitSomething = hitCenter;
71787513 retval = true;
71797514 }
71807515 spot.translate(32, 0);
7181
- if (spot.contains(info.x, info.y))
7516
+ if (spot.contains(clickInfo.x, clickInfo.y))
71827517 {
71837518 hitSomething = hitRotate;
71847519 retval = true;
71857520 }
71867521 spot.translate(0, 32);
7187
- if (spot.contains(info.x, info.y))
7522
+ if (spot.contains(clickInfo.x, clickInfo.y))
71887523 {
71897524 hitSomething = hitScale;
7525
+
7526
+ double scale = 0.005f * clickInfo.camera.Distance();
7527
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7528
+ double sign = 1;
7529
+ if (hScale < 0)
7530
+ {
7531
+ sign = -1;
7532
+ }
7533
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7534
+ if (hScale < 0.01)
7535
+ {
7536
+ //hScale = 0.01;
7537
+ }
7538
+
7539
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7540
+ sign = 1;
7541
+ if (vScale < 0)
7542
+ {
7543
+ sign = -1;
7544
+ }
7545
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7546
+ if (vScale < 0.01)
7547
+ {
7548
+ //vScale = 0.01;
7549
+ }
7550
+
7551
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7552
+
71907553 retval = true;
71917554 }
71927555
....@@ -7196,7 +7559,7 @@
71967559 }
71977560
71987561 //System.out.println("info.modifiers = " + info.modifiers);
7199
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7562
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72007563 //System.out.println("modified = " + modified);
72017564 //new Exception().printStackTrace();
72027565 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7224,7 +7587,8 @@
72247587 return true;
72257588 }
72267589
7227
- void doEditDrag0(ClickInfo info, boolean opposite)
7590
+ void doEditDrag0(//ClickInfo info,
7591
+ boolean opposite)
72287592 {
72297593 if (hitSomething == 0)
72307594 {
....@@ -7238,7 +7602,7 @@
72387602
72397603 //System.out.println("hitSomething = " + hitSomething);
72407604
7241
- double scale = 0.005f * info.camera.Distance();
7605
+ double scale = 0.005f * clickInfo.camera.Distance();
72427606
72437607 cVector xlate = new cVector();
72447608 //cVector xlate2 = new cVector();
....@@ -7272,8 +7636,8 @@
72727636 toParent[3][i] = xlate.get(i);
72737637 LA.matInvert(toParent, fromParent);
72747638 */
7275
- cVector delta = LA.newVector(0, 0, startY - info.y);
7276
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7639
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7640
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72777641
72787642 LA.matCopy(startMat, toParent);
72797643 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7282,7 +7646,7 @@
72827646 } else
72837647 {
72847648 //LA.xformDir(delta, info.camera.fromScreen, delta);
7285
- cVector up = new cVector(info.camera.up);
7649
+ cVector up = new cVector(clickInfo.camera.up);
72867650 cVector away = new cVector();
72877651 //cVector right2 = new cVector();
72887652 //LA.vecCross(up, cVector.Z, right);
....@@ -7299,19 +7663,19 @@
72997663 LA.xformDir(up, ClickInfo.matbuffer, up);
73007664 // if (!CameraPane.LOCALTRANSFORM)
73017665 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7302
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7666
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73037667 // if (!CameraPane.LOCALTRANSFORM)
73047668 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73057669 //LA.vecCross(up, cVector.Z, right2);
73067670
7307
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7671
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73087672
73097673 //System.out.println("DELTA0 = " + delta);
73107674 //System.out.println("AWAY = " + info.camera.away);
73117675 //System.out.println("UP = " + info.camera.up);
73127676 if (away.z > 0)
73137677 {
7314
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7678
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73157679 {
73167680 delta.x = -delta.x;
73177681 } else
....@@ -7326,7 +7690,7 @@
73267690 //System.out.println("DELTA1 = " + delta);
73277691 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73287692 //System.out.println("DELTA2 = " + delta);
7329
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7693
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73307694 LA.matCopy(startMat, toParent);
73317695 //System.out.println("DELTA3 = " + delta);
73327696 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7336,8 +7700,8 @@
73367700 break;
73377701
73387702 case hitRotate: // rotate
7339
- int dx = info.x - centerPt.x;
7340
- int dy = -(info.y - centerPt.y);
7703
+ int dx = clickInfo.x - centerPt.x;
7704
+ int dy = -(clickInfo.y - centerPt.y);
73417705 double angle = (double) Math.atan2(dx, dy);
73427706 angle = -(1.570796 - angle);
73437707
....@@ -7360,7 +7724,7 @@
73607724 }
73617725 /**/
73627726
7363
- switch (info.pane.RenderCamera().viewCode)
7727
+ switch (clickInfo.pane.RenderCamera().viewCode)
73647728 {
73657729 case 1: // '\001'
73667730 LA.matZRotate(toParent, angle);
....@@ -7387,7 +7751,7 @@
73877751 break;
73887752
73897753 case hitScale: // scale
7390
- double hScale = (double) (info.x - centerPt.x) / 32;
7754
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
73917755 double sign = 1;
73927756 if (hScale < 0)
73937757 {
....@@ -7399,7 +7763,7 @@
73997763 //hScale = 0.01;
74007764 }
74017765
7402
- double vScale = (double) (info.y - centerPt.y) / 32;
7766
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74037767 sign = 1;
74047768 if (vScale < 0)
74057769 {
....@@ -7410,6 +7774,7 @@
74107774 {
74117775 //vScale = 0.01;
74127776 }
7777
+
74137778 LA.matCopy(startMat, toParent);
74147779 /**/
74157780 for (int i = 0; i < 3; i++)
....@@ -7419,29 +7784,30 @@
74197784 }
74207785 /**/
74217786
7422
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7787
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74237788
74247789 if (totalScale < 0.01)
74257790 {
74267791 totalScale = 0.01;
74277792 }
74287793
7429
- switch (info.pane.RenderCamera().viewCode)
7794
+ switch (clickInfo.pane.RenderCamera().viewCode)
74307795 {
74317796 case 3: // '\001'
7432
- if (modified)
7797
+ if (modified || opposite)
74337798 {
74347799 //LA.matScale(toParent, 1, hScale, vScale);
74357800 LA.matScale(toParent, totalScale, 1, 1);
74367801 } // vScale, 1);
74377802 else
74387803 {
7804
+ // EXCEPTION!
74397805 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407806 } // vScale, 1);
74417807 break;
74427808
74437809 case 2: // '\002'
7444
- if (modified)
7810
+ if (modified || opposite)
74457811 {
74467812 //LA.matScale(toParent, hScale, 1, vScale);
74477813 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7818,7 @@
74527818 break;
74537819
74547820 case 1: // '\003'
7455
- if (modified)
7821
+ if (modified || opposite)
74567822 {
74577823 //LA.matScale(toParent, hScale, vScale, 1);
74587824 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7492,7 +7858,7 @@
74927858 } // NEW ...
74937859
74947860
7495
- info.pane.repaint();
7861
+ clickInfo.pane.repaint();
74967862 }
74977863
74987864 boolean overflow = false;
....@@ -7672,6 +8038,10 @@
76728038 editWindow = null;
76738039 } // ?
76748040 }
8041
+ else
8042
+ {
8043
+ //editWindow.closeUI();
8044
+ }
76758045 }
76768046
76778047 boolean root; // patch for edit windows
....@@ -7829,6 +8199,10 @@
78298199 }
78308200
78318201 transient ObjEditor editWindow;
8202
+ transient ObjEditor manipWindow;
8203
+
8204
+ transient boolean pinned;
8205
+
78328206 transient ObjectUI objectUI;
78338207 public static int povDepth = 0;
78348208 private static cVector tbMin = new cVector();