Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
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,10 @@
23842465 }
23852466 */
23862467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ }
23872472 }
23882473
23892474 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2510,14 @@
24252510 {
24262511 editWindow.refreshContents();
24272512 }
2513
+ else
2514
+ {
2515
+ if (manipWindow != null)
2516
+ {
2517
+ manipWindow.refreshContents();
2518
+ }
2519
+ }
2520
+
24282521 //if (parent != null)
24292522 //parent.refreshEditWindow();
24302523 }
....@@ -2504,7 +2597,8 @@
25042597 private static final int editSelf = 1;
25052598 private static final int editChild = 2;
25062599
2507
- void drawEditHandles(ClickInfo info, int level)
2600
+ void drawEditHandles(//ClickInfo info,
2601
+ int level)
25082602 {
25092603 if (level == 0)
25102604 {
....@@ -2512,7 +2606,8 @@
25122606 return;
25132607
25142608 Object3D selectee;
2515
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2609
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2610
+ level + 1))
25162611 {
25172612 selectee = (Object3D) e.nextElement();
25182613 }
....@@ -2520,19 +2615,22 @@
25202615 } else
25212616 {
25222617 //super.
2523
- drawEditHandles0(info, level + 1);
2618
+ drawEditHandles0(//info,
2619
+ level + 1);
25242620 }
25252621 }
25262622
2527
- boolean doEditClick(ClickInfo info, int level)
2623
+ boolean doEditClick(//ClickInfo info,
2624
+ int level)
25282625 {
25292626 doSomething = 0;
25302627 if (level == 0)
25312628 {
2532
- return doParentClick(info);
2629
+ return doParentClick(); //info);
25332630 }
25342631 if (//super.
2535
- doEditClick0(info, level))
2632
+ doEditClick0(//info,
2633
+ level))
25362634 {
25372635 doSomething = 1;
25382636 return true;
....@@ -2542,7 +2640,7 @@
25422640 }
25432641 }
25442642
2545
- boolean doParentClick(ClickInfo info)
2643
+ boolean doParentClick() //ClickInfo info)
25462644 {
25472645 if (selection == null)
25482646 {
....@@ -2555,7 +2653,8 @@
25552653 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25562654 {
25572655 Object3D selectee = (Object3D) e.nextElement();
2558
- if (selectee.doEditClick(info, 1))
2656
+ if (selectee.doEditClick(//info,
2657
+ 1))
25592658 {
25602659 childToDrag = selectee;
25612660 doSomething = 2;
....@@ -2567,13 +2666,15 @@
25672666 return retval;
25682667 }
25692668
2570
- void doEditDrag(ClickInfo info, boolean opposite)
2669
+ void doEditDrag(//ClickInfo clickInfo,
2670
+ boolean opposite)
25712671 {
25722672 switch (doSomething)
25732673 {
25742674 case 1: // '\001'
25752675 //super.
2576
- doEditDrag0(info, opposite);
2676
+ doEditDrag0(//clickInfo,
2677
+ opposite);
25772678 break;
25782679
25792680 case 2: // '\002'
....@@ -2586,11 +2687,13 @@
25862687 {
25872688 //sel.hitSomething = childToDrag.hitSomething;
25882689 //childToDrag.doEditDrag(info);
2589
- sel.doEditDrag(info, opposite);
2690
+ sel.doEditDrag(//clickInfo,
2691
+ opposite);
25902692 } else
25912693 {
25922694 //super.
2593
- doEditDrag0(info, opposite);
2695
+ doEditDrag0(//clickInfo,
2696
+ opposite);
25942697 }
25952698 }
25962699 break;
....@@ -2608,6 +2711,9 @@
26082711 {
26092712 deselectAll();
26102713 }
2714
+
2715
+ new Exception().printStackTrace();
2716
+
26112717 ClickInfo newInfo = new ClickInfo();
26122718 newInfo.flags = info.flags;
26132719 newInfo.bounds = info.bounds;
....@@ -3055,7 +3161,7 @@
30553161 {
30563162 if (bRep != null)
30573163 {
3058
- bRep.GenerateNormalsMINE();
3164
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593165 Touch();
30603166 }
30613167 }
....@@ -3501,7 +3607,8 @@
35013607 if (blockloop)
35023608 return;
35033609
3504
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
35053612 live = h;
35063613
35073614 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3629,8 @@
35223629 return;
35233630
35243631 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3632
+ if (//marked || // does not make sense
3633
+ (bRep != null || material != null)) // borderline...
35263634 link2master = h;
35273635
35283636 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3650,8 @@
35423650 if (blockloop)
35433651 return;
35443652
3545
- if (marked || (bRep != null && material != null)) // borderline...
3653
+ if (//marked || // does not make sense
3654
+ (bRep != null || material != null)) // borderline...
35463655 hide = h;
35473656
35483657 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3671,7 @@
35623671 if (blockloop)
35633672 return;
35643673
3565
- if (bRep != null && material != null) // borderline...
3674
+ if (bRep != null || material != null) // borderline...
35663675 marked = h;
35673676
35683677 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3681,46 @@
35723681 continue;
35733682 blockloop = true;
35743683 child.MarkLeaves(h);
3684
+ blockloop = false;
3685
+ // release(i);
3686
+ }
3687
+ }
3688
+
3689
+ void RewindLeaves(boolean h)
3690
+ {
3691
+ if (blockloop)
3692
+ return;
3693
+
3694
+ if (bRep != null || material != null) // borderline...
3695
+ rewind = h;
3696
+
3697
+ for (int i = 0; i < Size(); i++)
3698
+ {
3699
+ Object3D child = (Object3D) get(i); // reserve(i);
3700
+ if (child == null)
3701
+ continue;
3702
+ blockloop = true;
3703
+ child.RewindLeaves(h);
3704
+ blockloop = false;
3705
+ // release(i);
3706
+ }
3707
+ }
3708
+
3709
+ void RandomLeaves(boolean h)
3710
+ {
3711
+ if (blockloop)
3712
+ return;
3713
+
3714
+ if (bRep != null || material != null) // borderline...
3715
+ random = h;
3716
+
3717
+ for (int i = 0; i < Size(); i++)
3718
+ {
3719
+ Object3D child = (Object3D) get(i); // reserve(i);
3720
+ if (child == null)
3721
+ continue;
3722
+ blockloop = true;
3723
+ child.RandomLeaves(h);
35753724 blockloop = false;
35763725 // release(i);
35773726 }
....@@ -4349,6 +4498,55 @@
43494498 }
43504499 }
43514500
4501
+ void RepairSOV()
4502
+ {
4503
+ if (blockloop)
4504
+ return;
4505
+
4506
+ String texname = this.GetPigmentTexture();
4507
+
4508
+ if (texname.startsWith("sov"))
4509
+ {
4510
+ String[] s = texname.split("/");
4511
+
4512
+ String[] sname = s[1].split("Color.pn");
4513
+
4514
+ texname = sname[0];
4515
+
4516
+ if (sname.length > 1)
4517
+ {
4518
+ texname += "Color.jpg";
4519
+ }
4520
+
4521
+ this.SetPigmentTexture("sov/" + texname);
4522
+ }
4523
+
4524
+ texname = this.GetBumpTexture();
4525
+
4526
+ if (texname.startsWith("sov"))
4527
+ {
4528
+ String[] s = texname.split("/");
4529
+
4530
+ String[] sname = s[1].split("Bump.pn");
4531
+
4532
+ texname = sname[0];
4533
+
4534
+ if (sname.length > 1)
4535
+ {
4536
+ texname += "Bump.jpg";
4537
+ }
4538
+
4539
+ this.SetBumpTexture("sov/" + texname);
4540
+ }
4541
+
4542
+ for (int i=0; i<Size(); i++)
4543
+ {
4544
+ blockloop = true;
4545
+ get(i).RepairSOV();
4546
+ blockloop = false;
4547
+ }
4548
+ }
4549
+
43524550 void RepairTexture()
43534551 {
43544552 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5061,14 @@
48635061 }
48645062 }
48655063
5064
+ ObjEditor GetWindow()
5065
+ {
5066
+ if (editWindow != null)
5067
+ return editWindow;
5068
+
5069
+ return manipWindow;
5070
+ }
5071
+
48665072 cTreePath Select(int indexcount, boolean deselect)
48675073 {
48685074 if (hide || dontselect)
....@@ -4899,10 +5105,11 @@
48995105 if (leaf != null)
49005106 {
49015107 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5108
+ ObjEditor window = GetWindow();
5109
+ if (window != null)
49035110 {
49045111 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
49065113 }
49075114
49085115 return tp;
....@@ -4919,6 +5126,7 @@
49195126
49205127 if (child == null)
49215128 continue;
5129
+
49225130 if (child.HasTransparency() && child.size() != 0)
49235131 {
49245132 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5136,10 @@
49285136 if (leaf != null)
49295137 {
49305138 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5139
+ ObjEditor window = GetWindow();
5140
+ if (window != null)
49325141 {
4933
- editWindow.Select(tp, deselect, true);
5142
+ window.Select(tp, deselect, true);
49345143 }
49355144
49365145 return tp;
....@@ -5255,6 +5464,51 @@
52555464 blockloop = false;
52565465 }
52575466
5467
+ void ResetSelectable()
5468
+ {
5469
+ if (blockloop)
5470
+ return;
5471
+
5472
+ blockloop = true;
5473
+
5474
+ keepdontselect = dontselect;
5475
+ dontselect = true;
5476
+
5477
+ Object3D child;
5478
+ int nb = Size();
5479
+ for (int i = 0; i < nb; i++)
5480
+ {
5481
+ child = (Object3D) get(i);
5482
+ if (child == null)
5483
+ continue;
5484
+ child.ResetSelectable();
5485
+ }
5486
+
5487
+ blockloop = false;
5488
+ }
5489
+
5490
+ void RestoreSelectable()
5491
+ {
5492
+ if (blockloop)
5493
+ return;
5494
+
5495
+ blockloop = true;
5496
+
5497
+ dontselect = keepdontselect;
5498
+
5499
+ Object3D child;
5500
+ int nb = Size();
5501
+ for (int i = 0; i < nb; i++)
5502
+ {
5503
+ child = (Object3D) get(i);
5504
+ if (child == null)
5505
+ continue;
5506
+ child.RestoreSelectable();
5507
+ }
5508
+
5509
+ blockloop = false;
5510
+ }
5511
+
52585512 boolean IsSelected()
52595513 {
52605514 if (parent == null)
....@@ -5564,6 +5818,38 @@
55645818 }
55655819 }
55665820
5821
+ void EmbedTextures(boolean embed)
5822
+ {
5823
+ if (blockloop)
5824
+ return;
5825
+
5826
+ //if (GetTextures() != null)
5827
+ if (embed)
5828
+ CameraPane.EmbedTextures(GetTextures());
5829
+ else
5830
+ {
5831
+ GetTextures().pigmentdata = null;
5832
+ GetTextures().bumpdata = null;
5833
+ GetTextures().pw = 0;
5834
+ GetTextures().ph = 0;
5835
+ GetTextures().bw = 0;
5836
+ GetTextures().bh = 0;
5837
+ }
5838
+
5839
+ int nb = Size();
5840
+ for (int i = 0; i < nb; i++)
5841
+ {
5842
+ Object3D child = (Object3D) get(i);
5843
+
5844
+ if (child == null)
5845
+ continue;
5846
+
5847
+ blockloop = true;
5848
+ child.EmbedTextures(embed);
5849
+ blockloop = false;
5850
+ }
5851
+ }
5852
+
55675853 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685854 {
55695855 Draw(display, root, selected, blocked);
....@@ -5572,12 +5858,23 @@
55725858 boolean NeedSupport()
55735859 {
55745860 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5861
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765862 // PROBLEM with CROWD!!
55775863 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785864 }
55795865
55805866 static boolean DEBUG_SELECTION = false;
5867
+
5868
+ boolean IsLive()
5869
+ {
5870
+ if (live)
5871
+ return true;
5872
+
5873
+ if (parent == null)
5874
+ return false;
5875
+
5876
+ return parent.IsLive();
5877
+ }
55815878
55825879 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835880 {
....@@ -5639,8 +5936,10 @@
56395936 if (support != null)
56405937 support = support;
56415938
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);
5939
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5940
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+
5942
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56445943
56455944 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465945 {
....@@ -5650,8 +5949,9 @@
56505949 // usecalllists &= !(parent instanceof RandomNode);
56515950 // usecalllists = false;
56525951
5653
- if (GetBRep() != null)
5654
- usecalllists = usecalllists;
5952
+ if (display.DrawMode() == display.SHADOW)
5953
+ //GetBRep() != null)
5954
+ usecalllists = !!usecalllists;
56555955 //System.out.println("draw " + this);
56565956 //new Exception().printStackTrace();
56575957
....@@ -5660,10 +5960,12 @@
56605960 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615961
56625962 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5963
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5964
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645965 {
56655966 Globals.lighttouched = true;
56665967 } // all panes...
5968
+
56675969 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685970 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695971 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5671,7 +5973,7 @@
56715973 if (!(this instanceof Composite))
56725974 touched = false;
56735975 //if (displaylist == -1 && usecalllists)
5674
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5976
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56755977 {
56765978 bRep.displaylist = display.GenList();
56775979 assert(bRep.displaylist != 0);
....@@ -5682,7 +5984,7 @@
56825984
56835985 //System.out.println("\tnew list " + list);
56845986 //gl.glDrawBuffer(gl.GL_NONE);
5685
- if (usecalllists)
5987
+ if (usecalllists && bRep.displaylist > 0)
56865988 {
56875989 // System.err.println("new list " + bRep.displaylist + " for " + this);
56885990 display.NewList(bRep.displaylist);
....@@ -5691,7 +5993,7 @@
56915993 CallList(display, root, selected, blocked);
56925994
56935995 // compiled = true;
5694
- if (usecalllists)
5996
+ if (usecalllists && bRep.displaylist > 0)
56955997 {
56965998 // System.err.println("end list " + bRep.displaylist + " for " + this);
56975999 display.EndList();
....@@ -5791,6 +6093,7 @@
57916093 if (GetBRep() != null)
57926094 {
57936095 display.NextIndex();
6096
+
57946097 // vertex color conflict : gl.glCallList(list);
57956098 DrawNode(display, root, selected);
57966099 if (this instanceof BezierPatch)
....@@ -5831,16 +6134,27 @@
58316134 tex = GetTextures();
58326135 }
58336136
5834
- boolean failed = false;
6137
+ boolean failedPigment = false;
6138
+ boolean failedBump = false;
58356139
58366140 try
58376141 {
5838
- display.BindTextures(tex, texres);
6142
+ display.BindPigmentTexture(tex, texres);
58396143 }
58406144 catch (Exception e)
58416145 {
58426146 System.err.println("FAILED: " + this);
5843
- failed = true;
6147
+ failedPigment = true;
6148
+ }
6149
+
6150
+ try
6151
+ {
6152
+ display.BindBumpTexture(tex, texres);
6153
+ }
6154
+ catch (Exception e)
6155
+ {
6156
+ //System.err.println("FAILED: " + this);
6157
+ failedBump = true;
58446158 }
58456159
58466160 if (!compiled)
....@@ -5863,8 +6177,11 @@
58636177 }
58646178 }
58656179
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6180
+ if (!failedBump)
6181
+ display.ReleaseBumpTexture(tex);
6182
+
6183
+ if (!failedPigment)
6184
+ display.ReleasePigmentTexture(tex);
58686185
58696186 display.PopMaterial(this, selected);
58706187 }
....@@ -6237,6 +6554,11 @@
62376554 // dec 2012
62386555 new Exception().printStackTrace();
62396556 return;
6557
+ }
6558
+
6559
+ if (dontselect)
6560
+ {
6561
+ //bRep.GenerateNormalsMINE();
62406562 }
62416563
62426564 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7022,20 +7344,23 @@
70227344 }
70237345 }
70247346
7025
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7347
+ static ClickInfo clickInfo = new ClickInfo();
7348
+
7349
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7350
+ Point outPt, Rectangle outRec)
70267351 {
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;
7352
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7353
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7354
+ double[][] toscreen = clickInfo.toScreen;
70307355 if (toscreen == null)
70317356 {
7032
- toscreen = new Camera(info.camera.viewCode).toScreen;
7357
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70337358 }
70347359 cVector vec = in;
70357360 LA.xformPos(in, toscreen, in);
70367361 //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();
7362
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7363
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70397364 outPt.x = hc + (int) vec.x;
70407365 outPt.y = vc - (int) vec.y;
70417366 outRec.x = outPt.x - 3;
....@@ -7043,15 +7368,18 @@
70437368 outRec.width = outRec.height = 6;
70447369 }
70457370
7046
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7371
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7372
+ )
70477373 {
70487374 Point pt = new Point(0, 0);
70497375 Rectangle rec = new Rectangle();
7050
- calcHotSpot(in, info, pt, rec);
7376
+ calcHotSpot(in, //clickInfo,
7377
+ pt, rec);
70517378 return rec;
70527379 }
70537380
7054
- void drawEditHandles0(ClickInfo info, int level)
7381
+ void drawEditHandles0(//ClickInfo clickInfo,
7382
+ int level)
70557383 {
70567384 if (level == 0)
70577385 {
....@@ -7060,16 +7388,19 @@
70607388 {
70617389 cVector origin = new cVector();
70627390 //LA.xformPos(origin, toParent, origin);
7063
- Rectangle spot = calcHotSpot(origin, info);
7391
+ if (this.clickInfo == null)
7392
+ this.clickInfo = new ClickInfo();
7393
+
7394
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70647395 Rectangle boundary = new Rectangle();
70657396 boundary.x = spot.x - 30;
70667397 boundary.y = spot.y - 30;
70677398 boundary.width = spot.width + 60;
70687399 boundary.height = spot.height + 60;
7069
- info.g.setColor(Color.red);
7400
+ clickInfo.g.setColor(Color.red);
70707401 int spotw = spot.x + spot.width;
70717402 int spoth = spot.y + spot.height;
7072
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7403
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70737404 // if (CameraPane.Xmin > spot.x)
70747405 // {
70757406 // CameraPane.Xmin = spot.x;
....@@ -7089,8 +7420,8 @@
70897420 spot.translate(32, 32);
70907421 spotw = spot.x + spot.width;
70917422 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7093
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.setColor(Color.cyan);
7424
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947425 // if (CameraPane.Xmin > spot.x)
70957426 // {
70967427 // CameraPane.Xmin = spot.x;
....@@ -7107,11 +7438,12 @@
71077438 // {
71087439 // CameraPane.Ymax = spoth;
71097440 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7441
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7442
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127443 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7114
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7444
+ clickInfo.g.setColor(Color.yellow);
7445
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
+ clickInfo.g.setColor(Color.green);
71157447 // if (CameraPane.Xmin > spot.x)
71167448 // {
71177449 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7460,8 @@
71287460 // {
71297461 // CameraPane.Ymax = spoth;
71307462 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7463
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7464
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71337465 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347466 // if (CameraPane.Xmin > boundary.x)
71357467 // {
....@@ -7151,7 +7483,8 @@
71517483 }
71527484 }
71537485
7154
- boolean doEditClick0(ClickInfo info, int level)
7486
+ boolean doEditClick0(//ClickInfo clickInfo,
7487
+ int level)
71557488 {
71567489 if (level == 0)
71577490 {
....@@ -7160,8 +7493,8 @@
71607493
71617494 boolean retval = false;
71627495
7163
- startX = info.x;
7164
- startY = info.y;
7496
+ startX = clickInfo.x;
7497
+ startY = clickInfo.y;
71657498
71667499 hitSomething = -1;
71677500 cVector origin = new cVector();
....@@ -7171,22 +7504,51 @@
71717504 {
71727505 centerPt = new Point(0, 0);
71737506 }
7174
- calcHotSpot(origin, info, centerPt, spot);
7175
- if (spot.contains(info.x, info.y))
7507
+ calcHotSpot(origin, //info,
7508
+ centerPt, spot);
7509
+ if (spot.contains(clickInfo.x, clickInfo.y))
71767510 {
71777511 hitSomething = hitCenter;
71787512 retval = true;
71797513 }
71807514 spot.translate(32, 0);
7181
- if (spot.contains(info.x, info.y))
7515
+ if (spot.contains(clickInfo.x, clickInfo.y))
71827516 {
71837517 hitSomething = hitRotate;
71847518 retval = true;
71857519 }
71867520 spot.translate(0, 32);
7187
- if (spot.contains(info.x, info.y))
7521
+ if (spot.contains(clickInfo.x, clickInfo.y))
71887522 {
71897523 hitSomething = hitScale;
7524
+
7525
+ double scale = 0.005f * clickInfo.camera.Distance();
7526
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7527
+ double sign = 1;
7528
+ if (hScale < 0)
7529
+ {
7530
+ sign = -1;
7531
+ }
7532
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7533
+ if (hScale < 0.01)
7534
+ {
7535
+ //hScale = 0.01;
7536
+ }
7537
+
7538
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7539
+ sign = 1;
7540
+ if (vScale < 0)
7541
+ {
7542
+ sign = -1;
7543
+ }
7544
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7545
+ if (vScale < 0.01)
7546
+ {
7547
+ //vScale = 0.01;
7548
+ }
7549
+
7550
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7551
+
71907552 retval = true;
71917553 }
71927554
....@@ -7196,7 +7558,7 @@
71967558 }
71977559
71987560 //System.out.println("info.modifiers = " + info.modifiers);
7199
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7561
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72007562 //System.out.println("modified = " + modified);
72017563 //new Exception().printStackTrace();
72027564 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7224,7 +7586,8 @@
72247586 return true;
72257587 }
72267588
7227
- void doEditDrag0(ClickInfo info, boolean opposite)
7589
+ void doEditDrag0(//ClickInfo info,
7590
+ boolean opposite)
72287591 {
72297592 if (hitSomething == 0)
72307593 {
....@@ -7238,7 +7601,7 @@
72387601
72397602 //System.out.println("hitSomething = " + hitSomething);
72407603
7241
- double scale = 0.005f * info.camera.Distance();
7604
+ double scale = 0.005f * clickInfo.camera.Distance();
72427605
72437606 cVector xlate = new cVector();
72447607 //cVector xlate2 = new cVector();
....@@ -7272,8 +7635,8 @@
72727635 toParent[3][i] = xlate.get(i);
72737636 LA.matInvert(toParent, fromParent);
72747637 */
7275
- cVector delta = LA.newVector(0, 0, startY - info.y);
7276
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7638
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7639
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72777640
72787641 LA.matCopy(startMat, toParent);
72797642 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7282,7 +7645,7 @@
72827645 } else
72837646 {
72847647 //LA.xformDir(delta, info.camera.fromScreen, delta);
7285
- cVector up = new cVector(info.camera.up);
7648
+ cVector up = new cVector(clickInfo.camera.up);
72867649 cVector away = new cVector();
72877650 //cVector right2 = new cVector();
72887651 //LA.vecCross(up, cVector.Z, right);
....@@ -7299,19 +7662,19 @@
72997662 LA.xformDir(up, ClickInfo.matbuffer, up);
73007663 // if (!CameraPane.LOCALTRANSFORM)
73017664 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7302
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7665
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73037666 // if (!CameraPane.LOCALTRANSFORM)
73047667 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73057668 //LA.vecCross(up, cVector.Z, right2);
73067669
7307
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7670
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73087671
73097672 //System.out.println("DELTA0 = " + delta);
73107673 //System.out.println("AWAY = " + info.camera.away);
73117674 //System.out.println("UP = " + info.camera.up);
73127675 if (away.z > 0)
73137676 {
7314
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7677
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73157678 {
73167679 delta.x = -delta.x;
73177680 } else
....@@ -7326,7 +7689,7 @@
73267689 //System.out.println("DELTA1 = " + delta);
73277690 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73287691 //System.out.println("DELTA2 = " + delta);
7329
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7692
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73307693 LA.matCopy(startMat, toParent);
73317694 //System.out.println("DELTA3 = " + delta);
73327695 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7336,8 +7699,8 @@
73367699 break;
73377700
73387701 case hitRotate: // rotate
7339
- int dx = info.x - centerPt.x;
7340
- int dy = -(info.y - centerPt.y);
7702
+ int dx = clickInfo.x - centerPt.x;
7703
+ int dy = -(clickInfo.y - centerPt.y);
73417704 double angle = (double) Math.atan2(dx, dy);
73427705 angle = -(1.570796 - angle);
73437706
....@@ -7360,7 +7723,7 @@
73607723 }
73617724 /**/
73627725
7363
- switch (info.pane.RenderCamera().viewCode)
7726
+ switch (clickInfo.pane.RenderCamera().viewCode)
73647727 {
73657728 case 1: // '\001'
73667729 LA.matZRotate(toParent, angle);
....@@ -7387,7 +7750,7 @@
73877750 break;
73887751
73897752 case hitScale: // scale
7390
- double hScale = (double) (info.x - centerPt.x) / 32;
7753
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
73917754 double sign = 1;
73927755 if (hScale < 0)
73937756 {
....@@ -7399,7 +7762,7 @@
73997762 //hScale = 0.01;
74007763 }
74017764
7402
- double vScale = (double) (info.y - centerPt.y) / 32;
7765
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74037766 sign = 1;
74047767 if (vScale < 0)
74057768 {
....@@ -7410,6 +7773,7 @@
74107773 {
74117774 //vScale = 0.01;
74127775 }
7776
+
74137777 LA.matCopy(startMat, toParent);
74147778 /**/
74157779 for (int i = 0; i < 3; i++)
....@@ -7419,29 +7783,30 @@
74197783 }
74207784 /**/
74217785
7422
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7786
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74237787
74247788 if (totalScale < 0.01)
74257789 {
74267790 totalScale = 0.01;
74277791 }
74287792
7429
- switch (info.pane.RenderCamera().viewCode)
7793
+ switch (clickInfo.pane.RenderCamera().viewCode)
74307794 {
74317795 case 3: // '\001'
7432
- if (modified)
7796
+ if (modified || opposite)
74337797 {
74347798 //LA.matScale(toParent, 1, hScale, vScale);
74357799 LA.matScale(toParent, totalScale, 1, 1);
74367800 } // vScale, 1);
74377801 else
74387802 {
7803
+ // EXCEPTION!
74397804 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407805 } // vScale, 1);
74417806 break;
74427807
74437808 case 2: // '\002'
7444
- if (modified)
7809
+ if (modified || opposite)
74457810 {
74467811 //LA.matScale(toParent, hScale, 1, vScale);
74477812 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7817,7 @@
74527817 break;
74537818
74547819 case 1: // '\003'
7455
- if (modified)
7820
+ if (modified || opposite)
74567821 {
74577822 //LA.matScale(toParent, hScale, vScale, 1);
74587823 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7492,7 +7857,7 @@
74927857 } // NEW ...
74937858
74947859
7495
- info.pane.repaint();
7860
+ clickInfo.pane.repaint();
74967861 }
74977862
74987863 boolean overflow = false;
....@@ -7672,6 +8037,10 @@
76728037 editWindow = null;
76738038 } // ?
76748039 }
8040
+ else
8041
+ {
8042
+ //editWindow.closeUI();
8043
+ }
76758044 }
76768045
76778046 boolean root; // patch for edit windows
....@@ -7829,6 +8198,10 @@
78298198 }
78308199
78318200 transient ObjEditor editWindow;
8201
+ transient ObjEditor manipWindow;
8202
+
8203
+ transient boolean pinned;
8204
+
78328205 transient ObjectUI objectUI;
78338206 public static int povDepth = 0;
78348207 private static cVector tbMin = new cVector();