Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
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,15 @@
23842465 }
23852466 */
23862467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ if (objectUI != null)
2472
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2473
+ else
2474
+ //new Exception().printStackTrace();
2475
+ System.err.println("objectUI is null");
2476
+ }
23872477 }
23882478
23892479 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2515,14 @@
24252515 {
24262516 editWindow.refreshContents();
24272517 }
2518
+ else
2519
+ {
2520
+ if (manipWindow != null)
2521
+ {
2522
+ manipWindow.refreshContents();
2523
+ }
2524
+ }
2525
+
24282526 //if (parent != null)
24292527 //parent.refreshEditWindow();
24302528 }
....@@ -2504,7 +2602,8 @@
25042602 private static final int editSelf = 1;
25052603 private static final int editChild = 2;
25062604
2507
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
25082607 {
25092608 if (level == 0)
25102609 {
....@@ -2512,7 +2611,8 @@
25122611 return;
25132612
25142613 Object3D selectee;
2515
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2614
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2615
+ level + 1))
25162616 {
25172617 selectee = (Object3D) e.nextElement();
25182618 }
....@@ -2520,19 +2620,22 @@
25202620 } else
25212621 {
25222622 //super.
2523
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
25242625 }
25252626 }
25262627
2527
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
25282630 {
25292631 doSomething = 0;
25302632 if (level == 0)
25312633 {
2532
- return doParentClick(info);
2634
+ return doParentClick(); //info);
25332635 }
25342636 if (//super.
2535
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
25362639 {
25372640 doSomething = 1;
25382641 return true;
....@@ -2542,7 +2645,7 @@
25422645 }
25432646 }
25442647
2545
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
25462649 {
25472650 if (selection == null)
25482651 {
....@@ -2555,7 +2658,8 @@
25552658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25562659 {
25572660 Object3D selectee = (Object3D) e.nextElement();
2558
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
25592663 {
25602664 childToDrag = selectee;
25612665 doSomething = 2;
....@@ -2567,13 +2671,15 @@
25672671 return retval;
25682672 }
25692673
2570
- void doEditDrag(ClickInfo info, boolean opposite)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
25712676 {
25722677 switch (doSomething)
25732678 {
25742679 case 1: // '\001'
25752680 //super.
2576
- doEditDrag0(info, opposite);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
25772683 break;
25782684
25792685 case 2: // '\002'
....@@ -2586,11 +2692,13 @@
25862692 {
25872693 //sel.hitSomething = childToDrag.hitSomething;
25882694 //childToDrag.doEditDrag(info);
2589
- sel.doEditDrag(info, opposite);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
25902697 } else
25912698 {
25922699 //super.
2593
- doEditDrag0(info, opposite);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
25942702 }
25952703 }
25962704 break;
....@@ -2608,6 +2716,9 @@
26082716 {
26092717 deselectAll();
26102718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
26112722 ClickInfo newInfo = new ClickInfo();
26122723 newInfo.flags = info.flags;
26132724 newInfo.bounds = info.bounds;
....@@ -3055,7 +3166,7 @@
30553166 {
30563167 if (bRep != null)
30573168 {
3058
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593170 Touch();
30603171 }
30613172 }
....@@ -3501,7 +3612,8 @@
35013612 if (blockloop)
35023613 return;
35033614
3504
- if (marked || (bRep != null && material != null)) // borderline...
3615
+ if (//marked || // does not make sense
3616
+ (bRep != null || material != null)) // borderline...
35053617 live = h;
35063618
35073619 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3634,8 @@
35223634 return;
35233635
35243636 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3637
+ if (//marked || // does not make sense
3638
+ (bRep != null || material != null)) // borderline...
35263639 link2master = h;
35273640
35283641 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3655,8 @@
35423655 if (blockloop)
35433656 return;
35443657
3545
- if (marked || (bRep != null && material != null)) // borderline...
3658
+ if (//marked || // does not make sense
3659
+ (bRep != null || material != null)) // borderline...
35463660 hide = h;
35473661
35483662 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3676,7 @@
35623676 if (blockloop)
35633677 return;
35643678
3565
- if (bRep != null && material != null) // borderline...
3679
+ if (bRep != null || material != null) // borderline...
35663680 marked = h;
35673681
35683682 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3686,46 @@
35723686 continue;
35733687 blockloop = true;
35743688 child.MarkLeaves(h);
3689
+ blockloop = false;
3690
+ // release(i);
3691
+ }
3692
+ }
3693
+
3694
+ void RewindLeaves(boolean h)
3695
+ {
3696
+ if (blockloop)
3697
+ return;
3698
+
3699
+ if (bRep != null || material != null) // borderline...
3700
+ rewind = h;
3701
+
3702
+ for (int i = 0; i < Size(); i++)
3703
+ {
3704
+ Object3D child = (Object3D) get(i); // reserve(i);
3705
+ if (child == null)
3706
+ continue;
3707
+ blockloop = true;
3708
+ child.RewindLeaves(h);
3709
+ blockloop = false;
3710
+ // release(i);
3711
+ }
3712
+ }
3713
+
3714
+ void RandomLeaves(boolean h)
3715
+ {
3716
+ if (blockloop)
3717
+ return;
3718
+
3719
+ if (bRep != null || material != null) // borderline...
3720
+ random = h;
3721
+
3722
+ for (int i = 0; i < Size(); i++)
3723
+ {
3724
+ Object3D child = (Object3D) get(i); // reserve(i);
3725
+ if (child == null)
3726
+ continue;
3727
+ blockloop = true;
3728
+ child.RandomLeaves(h);
35753729 blockloop = false;
35763730 // release(i);
35773731 }
....@@ -4349,6 +4503,55 @@
43494503 }
43504504 }
43514505
4506
+ void RepairSOV()
4507
+ {
4508
+ if (blockloop)
4509
+ return;
4510
+
4511
+ String texname = this.GetPigmentTexture();
4512
+
4513
+ if (texname.startsWith("sov"))
4514
+ {
4515
+ String[] s = texname.split("/");
4516
+
4517
+ String[] sname = s[1].split("Color.pn");
4518
+
4519
+ texname = sname[0];
4520
+
4521
+ if (sname.length > 1)
4522
+ {
4523
+ texname += "Color.jpg";
4524
+ }
4525
+
4526
+ this.SetPigmentTexture("sov/" + texname);
4527
+ }
4528
+
4529
+ texname = this.GetBumpTexture();
4530
+
4531
+ if (texname.startsWith("sov"))
4532
+ {
4533
+ String[] s = texname.split("/");
4534
+
4535
+ String[] sname = s[1].split("Bump.pn");
4536
+
4537
+ texname = sname[0];
4538
+
4539
+ if (sname.length > 1)
4540
+ {
4541
+ texname += "Bump.jpg";
4542
+ }
4543
+
4544
+ this.SetBumpTexture("sov/" + texname);
4545
+ }
4546
+
4547
+ for (int i=0; i<Size(); i++)
4548
+ {
4549
+ blockloop = true;
4550
+ get(i).RepairSOV();
4551
+ blockloop = false;
4552
+ }
4553
+ }
4554
+
43524555 void RepairTexture()
43534556 {
43544557 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5066,14 @@
48635066 }
48645067 }
48655068
5069
+ ObjEditor GetWindow()
5070
+ {
5071
+ if (editWindow != null)
5072
+ return editWindow;
5073
+
5074
+ return manipWindow;
5075
+ }
5076
+
48665077 cTreePath Select(int indexcount, boolean deselect)
48675078 {
48685079 if (hide || dontselect)
....@@ -4899,10 +5110,11 @@
48995110 if (leaf != null)
49005111 {
49015112 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5113
+ ObjEditor window = GetWindow();
5114
+ if (window != null)
49035115 {
49045116 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5117
+ window.Select(tp, deselect, true);
49065118 }
49075119
49085120 return tp;
....@@ -4919,6 +5131,7 @@
49195131
49205132 if (child == null)
49215133 continue;
5134
+
49225135 if (child.HasTransparency() && child.size() != 0)
49235136 {
49245137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5141,10 @@
49285141 if (leaf != null)
49295142 {
49305143 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5144
+ ObjEditor window = GetWindow();
5145
+ if (window != null)
49325146 {
4933
- editWindow.Select(tp, deselect, true);
5147
+ window.Select(tp, deselect, true);
49345148 }
49355149
49365150 return tp;
....@@ -5255,6 +5469,51 @@
52555469 blockloop = false;
52565470 }
52575471
5472
+ void ResetSelectable()
5473
+ {
5474
+ if (blockloop)
5475
+ return;
5476
+
5477
+ blockloop = true;
5478
+
5479
+ keepdontselect = dontselect;
5480
+ dontselect = true;
5481
+
5482
+ Object3D child;
5483
+ int nb = Size();
5484
+ for (int i = 0; i < nb; i++)
5485
+ {
5486
+ child = (Object3D) get(i);
5487
+ if (child == null)
5488
+ continue;
5489
+ child.ResetSelectable();
5490
+ }
5491
+
5492
+ blockloop = false;
5493
+ }
5494
+
5495
+ void RestoreSelectable()
5496
+ {
5497
+ if (blockloop)
5498
+ return;
5499
+
5500
+ blockloop = true;
5501
+
5502
+ dontselect = keepdontselect;
5503
+
5504
+ Object3D child;
5505
+ int nb = Size();
5506
+ for (int i = 0; i < nb; i++)
5507
+ {
5508
+ child = (Object3D) get(i);
5509
+ if (child == null)
5510
+ continue;
5511
+ child.RestoreSelectable();
5512
+ }
5513
+
5514
+ blockloop = false;
5515
+ }
5516
+
52585517 boolean IsSelected()
52595518 {
52605519 if (parent == null)
....@@ -5315,6 +5574,11 @@
53155574 if (fullname == null)
53165575 return "";
53175576
5577
+ if (fullname.pigment != null)
5578
+ {
5579
+ return fullname.pigment;
5580
+ }
5581
+
53185582 // System.out.println("Fullname = " + fullname);
53195583
53205584 // Does not work on Windows due to C:
....@@ -5327,7 +5591,7 @@
53275591
53285592 if (split.length == 0)
53295593 {
5330
- return "";
5594
+ return fullname.pigment = "";
53315595 }
53325596
53335597 if (split.length <= 2)
....@@ -5335,22 +5599,27 @@
53355599 if (fullname.name.endsWith(":"))
53365600 {
53375601 // Windows
5338
- return fullname.name.substring(0, fullname.name.length()-1);
5602
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
53395603 }
53405604
5341
- return split[0];
5605
+ return fullname.pigment = split[0];
53425606 }
53435607
53445608 // Windows
53455609 assert(split.length == 4);
53465610
5347
- return split[0] + ":" + split[1];
5611
+ return fullname.pigment = split[0] + ":" + split[1];
53485612 }
53495613
53505614 static String GetBump(cTexture fullname)
53515615 {
53525616 if (fullname == null)
53535617 return "";
5618
+
5619
+ if (fullname.bump != null)
5620
+ {
5621
+ return fullname.bump;
5622
+ }
53545623
53555624 // System.out.println("Fullname = " + fullname);
53565625 // Does not work on Windows due to C:
....@@ -5362,12 +5631,12 @@
53625631
53635632 if (split.length == 0)
53645633 {
5365
- return "";
5634
+ return fullname.bump = "";
53665635 }
53675636
53685637 if (split.length == 1)
53695638 {
5370
- return "";
5639
+ return fullname.bump = "";
53715640 }
53725641
53735642 if (split.length == 2)
....@@ -5375,16 +5644,16 @@
53755644 if (fullname.name.endsWith(":"))
53765645 {
53775646 // Windows
5378
- return "";
5647
+ return fullname.bump = "";
53795648 }
53805649
5381
- return split[1];
5650
+ return fullname.bump = split[1];
53825651 }
53835652
53845653 // Windows
53855654 assert(split.length == 4);
53865655
5387
- return split[2] + ":" + split[3];
5656
+ return fullname.bump = split[2] + ":" + split[3];
53885657 }
53895658
53905659 String GetPigmentTexture()
....@@ -5467,6 +5736,9 @@
54675736 texname = "";
54685737
54695738 GetTextures().name = texname + ":" + GetBump(GetTextures());
5739
+
5740
+ GetTextures().pigment = null;
5741
+
54705742 Touch();
54715743 }
54725744
....@@ -5540,6 +5812,8 @@
55405812
55415813 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
55425814
5815
+ GetTextures().bump = null;
5816
+
55435817 Touch();
55445818 }
55455819
....@@ -5564,6 +5838,38 @@
55645838 }
55655839 }
55665840
5841
+ void EmbedTextures(boolean embed)
5842
+ {
5843
+ if (blockloop)
5844
+ return;
5845
+
5846
+ //if (GetTextures() != null)
5847
+ if (embed)
5848
+ CameraPane.EmbedTextures(GetTextures());
5849
+ else
5850
+ {
5851
+ GetTextures().pigmentdata = null;
5852
+ GetTextures().bumpdata = null;
5853
+ GetTextures().pw = 0;
5854
+ GetTextures().ph = 0;
5855
+ GetTextures().bw = 0;
5856
+ GetTextures().bh = 0;
5857
+ }
5858
+
5859
+ int nb = Size();
5860
+ for (int i = 0; i < nb; i++)
5861
+ {
5862
+ Object3D child = (Object3D) get(i);
5863
+
5864
+ if (child == null)
5865
+ continue;
5866
+
5867
+ blockloop = true;
5868
+ child.EmbedTextures(embed);
5869
+ blockloop = false;
5870
+ }
5871
+ }
5872
+
55675873 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685874 {
55695875 Draw(display, root, selected, blocked);
....@@ -5572,12 +5878,23 @@
55725878 boolean NeedSupport()
55735879 {
55745880 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5881
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765882 // PROBLEM with CROWD!!
55775883 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785884 }
55795885
55805886 static boolean DEBUG_SELECTION = false;
5887
+
5888
+ boolean IsLive()
5889
+ {
5890
+ if (live)
5891
+ return true;
5892
+
5893
+ if (parent == null)
5894
+ return false;
5895
+
5896
+ return parent.IsLive();
5897
+ }
55815898
55825899 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835900 {
....@@ -5639,8 +5956,10 @@
56395956 if (support != null)
56405957 support = support;
56415958
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);
5959
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5960
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+
5962
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56445963
56455964 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465965 {
....@@ -5650,8 +5969,9 @@
56505969 // usecalllists &= !(parent instanceof RandomNode);
56515970 // usecalllists = false;
56525971
5653
- if (GetBRep() != null)
5654
- usecalllists = usecalllists;
5972
+ if (display.DrawMode() == display.SHADOW)
5973
+ //GetBRep() != null)
5974
+ usecalllists = !!usecalllists;
56555975 //System.out.println("draw " + this);
56565976 //new Exception().printStackTrace();
56575977
....@@ -5660,10 +5980,12 @@
56605980 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615981
56625982 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5983
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5984
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645985 {
56655986 Globals.lighttouched = true;
56665987 } // all panes...
5988
+
56675989 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685990 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695991 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5671,7 +5993,7 @@
56715993 if (!(this instanceof Composite))
56725994 touched = false;
56735995 //if (displaylist == -1 && usecalllists)
5674
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5996
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56755997 {
56765998 bRep.displaylist = display.GenList();
56775999 assert(bRep.displaylist != 0);
....@@ -5682,7 +6004,7 @@
56826004
56836005 //System.out.println("\tnew list " + list);
56846006 //gl.glDrawBuffer(gl.GL_NONE);
5685
- if (usecalllists)
6007
+ if (usecalllists && bRep.displaylist > 0)
56866008 {
56876009 // System.err.println("new list " + bRep.displaylist + " for " + this);
56886010 display.NewList(bRep.displaylist);
....@@ -5691,7 +6013,7 @@
56916013 CallList(display, root, selected, blocked);
56926014
56936015 // compiled = true;
5694
- if (usecalllists)
6016
+ if (usecalllists && bRep.displaylist > 0)
56956017 {
56966018 // System.err.println("end list " + bRep.displaylist + " for " + this);
56976019 display.EndList();
....@@ -5791,6 +6113,7 @@
57916113 if (GetBRep() != null)
57926114 {
57936115 display.NextIndex();
6116
+
57946117 // vertex color conflict : gl.glCallList(list);
57956118 DrawNode(display, root, selected);
57966119 if (this instanceof BezierPatch)
....@@ -5831,16 +6154,27 @@
58316154 tex = GetTextures();
58326155 }
58336156
5834
- boolean failed = false;
6157
+ boolean failedPigment = false;
6158
+ boolean failedBump = false;
58356159
58366160 try
58376161 {
5838
- display.BindTextures(tex, texres);
6162
+ display.BindPigmentTexture(tex, texres);
58396163 }
58406164 catch (Exception e)
58416165 {
58426166 System.err.println("FAILED: " + this);
5843
- failed = true;
6167
+ failedPigment = true;
6168
+ }
6169
+
6170
+ try
6171
+ {
6172
+ display.BindBumpTexture(tex, texres);
6173
+ }
6174
+ catch (Exception e)
6175
+ {
6176
+ //System.err.println("FAILED: " + this);
6177
+ failedBump = true;
58446178 }
58456179
58466180 if (!compiled)
....@@ -5863,8 +6197,11 @@
58636197 }
58646198 }
58656199
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6200
+ if (!failedBump)
6201
+ display.ReleaseBumpTexture(tex);
6202
+
6203
+ if (!failedPigment)
6204
+ display.ReleasePigmentTexture(tex);
58686205
58696206 display.PopMaterial(this, selected);
58706207 }
....@@ -6237,6 +6574,11 @@
62376574 // dec 2012
62386575 new Exception().printStackTrace();
62396576 return;
6577
+ }
6578
+
6579
+ if (dontselect)
6580
+ {
6581
+ //bRep.GenerateNormalsMINE();
62406582 }
62416583
62426584 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7022,20 +7364,23 @@
70227364 }
70237365 }
70247366
7025
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7367
+ static ClickInfo clickInfo = new ClickInfo();
7368
+
7369
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7370
+ Point outPt, Rectangle outRec)
70267371 {
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;
7372
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7373
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7374
+ double[][] toscreen = clickInfo.toScreen;
70307375 if (toscreen == null)
70317376 {
7032
- toscreen = new Camera(info.camera.viewCode).toScreen;
7377
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70337378 }
70347379 cVector vec = in;
70357380 LA.xformPos(in, toscreen, in);
70367381 //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();
7382
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7383
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70397384 outPt.x = hc + (int) vec.x;
70407385 outPt.y = vc - (int) vec.y;
70417386 outRec.x = outPt.x - 3;
....@@ -7043,15 +7388,18 @@
70437388 outRec.width = outRec.height = 6;
70447389 }
70457390
7046
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7391
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7392
+ )
70477393 {
70487394 Point pt = new Point(0, 0);
70497395 Rectangle rec = new Rectangle();
7050
- calcHotSpot(in, info, pt, rec);
7396
+ calcHotSpot(in, //clickInfo,
7397
+ pt, rec);
70517398 return rec;
70527399 }
70537400
7054
- void drawEditHandles0(ClickInfo info, int level)
7401
+ void drawEditHandles0(//ClickInfo clickInfo,
7402
+ int level)
70557403 {
70567404 if (level == 0)
70577405 {
....@@ -7060,16 +7408,19 @@
70607408 {
70617409 cVector origin = new cVector();
70627410 //LA.xformPos(origin, toParent, origin);
7063
- Rectangle spot = calcHotSpot(origin, info);
7411
+ if (this.clickInfo == null)
7412
+ this.clickInfo = new ClickInfo();
7413
+
7414
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70647415 Rectangle boundary = new Rectangle();
70657416 boundary.x = spot.x - 30;
70667417 boundary.y = spot.y - 30;
70677418 boundary.width = spot.width + 60;
70687419 boundary.height = spot.height + 60;
7069
- info.g.setColor(Color.red);
7420
+ clickInfo.g.setColor(Color.red);
70707421 int spotw = spot.x + spot.width;
70717422 int spoth = spot.y + spot.height;
7072
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70737424 // if (CameraPane.Xmin > spot.x)
70747425 // {
70757426 // CameraPane.Xmin = spot.x;
....@@ -7086,11 +7437,33 @@
70867437 // {
70877438 // CameraPane.Ymax = spoth;
70887439 // }
7089
- spot.translate(32, 32);
7440
+// if (CameraPane.Xmin > spot.x)
7441
+// {
7442
+// CameraPane.Xmin = spot.x;
7443
+// }
7444
+// if (CameraPane.Xmax < spotw)
7445
+// {
7446
+// CameraPane.Xmax = spotw;
7447
+// }
7448
+// if (CameraPane.Ymin > spot.y)
7449
+// {
7450
+// CameraPane.Ymin = spot.y;
7451
+// }
7452
+// if (CameraPane.Ymax < spoth)
7453
+// {
7454
+// CameraPane.Ymax = spoth;
7455
+// }
7456
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7457
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7458
+ spot.translate(32, 0);
7459
+ clickInfo.g.setColor(Color.yellow);
7460
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7461
+
7462
+ spot.translate(32, 64);
70907463 spotw = spot.x + spot.width;
70917464 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7093
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7465
+ clickInfo.g.setColor(Color.cyan);
7466
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947467 // if (CameraPane.Xmin > spot.x)
70957468 // {
70967469 // CameraPane.Xmin = spot.x;
....@@ -7107,29 +7480,9 @@
71077480 // {
71087481 // CameraPane.Ymax = spoth;
71097482 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7112
- spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7114
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7115
-// if (CameraPane.Xmin > spot.x)
7116
-// {
7117
-// CameraPane.Xmin = spot.x;
7118
-// }
7119
-// if (CameraPane.Xmax < spotw)
7120
-// {
7121
-// CameraPane.Xmax = spotw;
7122
-// }
7123
-// if (CameraPane.Ymin > spot.y)
7124
-// {
7125
-// CameraPane.Ymin = spot.y;
7126
-// }
7127
-// if (CameraPane.Ymax < spoth)
7128
-// {
7129
-// CameraPane.Ymax = spoth;
7130
-// }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7483
+ clickInfo.g.setColor(Color.green);
7484
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7485
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71337486 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347487 // if (CameraPane.Xmin > boundary.x)
71357488 // {
....@@ -7151,7 +7504,8 @@
71517504 }
71527505 }
71537506
7154
- boolean doEditClick0(ClickInfo info, int level)
7507
+ boolean doEditClick0(//ClickInfo clickInfo,
7508
+ int level)
71557509 {
71567510 if (level == 0)
71577511 {
....@@ -7160,8 +7514,8 @@
71607514
71617515 boolean retval = false;
71627516
7163
- startX = info.x;
7164
- startY = info.y;
7517
+ startX = clickInfo.x;
7518
+ startY = clickInfo.y;
71657519
71667520 hitSomething = -1;
71677521 cVector origin = new cVector();
....@@ -7171,22 +7525,53 @@
71717525 {
71727526 centerPt = new Point(0, 0);
71737527 }
7174
- calcHotSpot(origin, info, centerPt, spot);
7175
- if (spot.contains(info.x, info.y))
7528
+ calcHotSpot(origin, //info,
7529
+ centerPt, spot);
7530
+ if (spot.contains(clickInfo.x, clickInfo.y))
71767531 {
71777532 hitSomething = hitCenter;
71787533 retval = true;
71797534 }
71807535 spot.translate(32, 0);
7181
- if (spot.contains(info.x, info.y))
7536
+ if (spot.contains(clickInfo.x, clickInfo.y))
71827537 {
71837538 hitSomething = hitRotate;
71847539 retval = true;
71857540 }
71867541 spot.translate(0, 32);
7187
- if (spot.contains(info.x, info.y))
7542
+ spot.translate(32, 0);
7543
+ spot.translate(0, 32);
7544
+ if (spot.contains(clickInfo.x, clickInfo.y))
71887545 {
71897546 hitSomething = hitScale;
7547
+
7548
+ double scale = 0.005f * clickInfo.camera.Distance();
7549
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7550
+ double sign = 1;
7551
+ if (hScale < 0)
7552
+ {
7553
+ sign = -1;
7554
+ }
7555
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7556
+ if (hScale < 0.01)
7557
+ {
7558
+ //hScale = 0.01;
7559
+ }
7560
+
7561
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7562
+ sign = 1;
7563
+ if (vScale < 0)
7564
+ {
7565
+ sign = -1;
7566
+ }
7567
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7568
+ if (vScale < 0.01)
7569
+ {
7570
+ //vScale = 0.01;
7571
+ }
7572
+
7573
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7574
+
71907575 retval = true;
71917576 }
71927577
....@@ -7196,7 +7581,7 @@
71967581 }
71977582
71987583 //System.out.println("info.modifiers = " + info.modifiers);
7199
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7584
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72007585 //System.out.println("modified = " + modified);
72017586 //new Exception().printStackTrace();
72027587 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7224,7 +7609,8 @@
72247609 return true;
72257610 }
72267611
7227
- void doEditDrag0(ClickInfo info, boolean opposite)
7612
+ void doEditDrag0(//ClickInfo info,
7613
+ boolean opposite)
72287614 {
72297615 if (hitSomething == 0)
72307616 {
....@@ -7238,7 +7624,7 @@
72387624
72397625 //System.out.println("hitSomething = " + hitSomething);
72407626
7241
- double scale = 0.005f * info.camera.Distance();
7627
+ double scale = 0.005f * clickInfo.camera.Distance();
72427628
72437629 cVector xlate = new cVector();
72447630 //cVector xlate2 = new cVector();
....@@ -7272,8 +7658,8 @@
72727658 toParent[3][i] = xlate.get(i);
72737659 LA.matInvert(toParent, fromParent);
72747660 */
7275
- cVector delta = LA.newVector(0, 0, startY - info.y);
7276
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7661
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72777663
72787664 LA.matCopy(startMat, toParent);
72797665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7282,7 +7668,7 @@
72827668 } else
72837669 {
72847670 //LA.xformDir(delta, info.camera.fromScreen, delta);
7285
- cVector up = new cVector(info.camera.up);
7671
+ cVector up = new cVector(clickInfo.camera.up);
72867672 cVector away = new cVector();
72877673 //cVector right2 = new cVector();
72887674 //LA.vecCross(up, cVector.Z, right);
....@@ -7299,19 +7685,19 @@
72997685 LA.xformDir(up, ClickInfo.matbuffer, up);
73007686 // if (!CameraPane.LOCALTRANSFORM)
73017687 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7302
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7688
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73037689 // if (!CameraPane.LOCALTRANSFORM)
73047690 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73057691 //LA.vecCross(up, cVector.Z, right2);
73067692
7307
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7693
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73087694
73097695 //System.out.println("DELTA0 = " + delta);
73107696 //System.out.println("AWAY = " + info.camera.away);
73117697 //System.out.println("UP = " + info.camera.up);
73127698 if (away.z > 0)
73137699 {
7314
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7700
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73157701 {
73167702 delta.x = -delta.x;
73177703 } else
....@@ -7326,7 +7712,7 @@
73267712 //System.out.println("DELTA1 = " + delta);
73277713 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73287714 //System.out.println("DELTA2 = " + delta);
7329
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7715
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73307716 LA.matCopy(startMat, toParent);
73317717 //System.out.println("DELTA3 = " + delta);
73327718 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7336,8 +7722,8 @@
73367722 break;
73377723
73387724 case hitRotate: // rotate
7339
- int dx = info.x - centerPt.x;
7340
- int dy = -(info.y - centerPt.y);
7725
+ int dx = clickInfo.x - centerPt.x;
7726
+ int dy = -(clickInfo.y - centerPt.y);
73417727 double angle = (double) Math.atan2(dx, dy);
73427728 angle = -(1.570796 - angle);
73437729
....@@ -7360,7 +7746,7 @@
73607746 }
73617747 /**/
73627748
7363
- switch (info.pane.RenderCamera().viewCode)
7749
+ switch (clickInfo.pane.RenderCamera().viewCode)
73647750 {
73657751 case 1: // '\001'
73667752 LA.matZRotate(toParent, angle);
....@@ -7387,7 +7773,7 @@
73877773 break;
73887774
73897775 case hitScale: // scale
7390
- double hScale = (double) (info.x - centerPt.x) / 32;
7776
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
73917777 double sign = 1;
73927778 if (hScale < 0)
73937779 {
....@@ -7399,7 +7785,7 @@
73997785 //hScale = 0.01;
74007786 }
74017787
7402
- double vScale = (double) (info.y - centerPt.y) / 32;
7788
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
74037789 sign = 1;
74047790 if (vScale < 0)
74057791 {
....@@ -7410,6 +7796,7 @@
74107796 {
74117797 //vScale = 0.01;
74127798 }
7799
+
74137800 LA.matCopy(startMat, toParent);
74147801 /**/
74157802 for (int i = 0; i < 3; i++)
....@@ -7419,29 +7806,30 @@
74197806 }
74207807 /**/
74217808
7422
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7809
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74237810
74247811 if (totalScale < 0.01)
74257812 {
74267813 totalScale = 0.01;
74277814 }
74287815
7429
- switch (info.pane.RenderCamera().viewCode)
7816
+ switch (clickInfo.pane.RenderCamera().viewCode)
74307817 {
74317818 case 3: // '\001'
7432
- if (modified)
7819
+ if (modified || opposite)
74337820 {
74347821 //LA.matScale(toParent, 1, hScale, vScale);
74357822 LA.matScale(toParent, totalScale, 1, 1);
74367823 } // vScale, 1);
74377824 else
74387825 {
7826
+ // EXCEPTION!
74397827 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407828 } // vScale, 1);
74417829 break;
74427830
74437831 case 2: // '\002'
7444
- if (modified)
7832
+ if (modified || opposite)
74457833 {
74467834 //LA.matScale(toParent, hScale, 1, vScale);
74477835 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7840,7 @@
74527840 break;
74537841
74547842 case 1: // '\003'
7455
- if (modified)
7843
+ if (modified || opposite)
74567844 {
74577845 //LA.matScale(toParent, hScale, vScale, 1);
74587846 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7492,7 +7880,7 @@
74927880 } // NEW ...
74937881
74947882
7495
- info.pane.repaint();
7883
+ clickInfo.pane.repaint();
74967884 }
74977885
74987886 boolean overflow = false;
....@@ -7672,6 +8060,10 @@
76728060 editWindow = null;
76738061 } // ?
76748062 }
8063
+ else
8064
+ {
8065
+ //editWindow.closeUI();
8066
+ }
76758067 }
76768068
76778069 boolean root; // patch for edit windows
....@@ -7829,6 +8221,10 @@
78298221 }
78308222
78318223 transient ObjEditor editWindow;
8224
+ transient ObjEditor manipWindow;
8225
+
8226
+ transient boolean pinned;
8227
+
78328228 transient ObjectUI objectUI;
78338229 public static int povDepth = 0;
78348230 private static cVector tbMin = new cVector();