Normand Briere
2019-08-01 7d02eaffc02895a01d95d8fd7e089044449e1d6d
Object3D.java
....@@ -24,11 +24,17 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
3030 //
3131
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ byte[] versions[];
36
+ int versionindex = -1;
37
+
3238 ScriptNode scriptnode;
3339
3440 void InitOthers()
....@@ -170,24 +176,35 @@
170176
171177 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172178 {
179
+ Object3D o;
180
+
173181 if (hashtable.containsKey(GetUUID()))
174182 {
175
- Object3D o = hashtable.get(GetUUID());
183
+ o = hashtable.get(GetUUID());
176184
177
- assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
185
+ Grafreed.Assert(this.bRep == o.bRep);
186
+ //if (this.bRep != null)
187
+ // assert(this.bRep.support == o.transientrep);
188
+ if (this.support != null)
189
+ assert(this.support.bRep == o.transientrep);
190
+ }
191
+ else
192
+ {
193
+ o = new Object3D("copy of " + this.name);
180194
181
- return;
195
+ hashtable.put(GetUUID(), o);
182196 }
183197
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
198
+ if (!blockloop)
189199 {
190
- get(i).ExtractBigData(hashtable);
200
+ blockloop = true;
201
+
202
+ for (int i=0; i<Size(); i++)
203
+ {
204
+ get(i).ExtractBigData(hashtable);
205
+ }
206
+
207
+ blockloop = false;
191208 }
192209
193210 ExtractBigData(o);
....@@ -195,11 +212,26 @@
195212
196213 void ExtractBigData(Object3D o)
197214 {
215
+ if (o.bRep != null)
216
+ Grafreed.Assert(o.bRep == this.bRep);
217
+
198218 o.bRep = this.bRep;
199
- if (this.bRep != null)
219
+// July 2019 if (this.bRep != null)
220
+// {
221
+// o.transientrep = this.bRep.support;
222
+// o.bRep.support = null;
223
+// }
224
+ o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
227
+
228
+ if (this.support != null)
200229 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
230
+ if (o.transientrep != null)
231
+ Grafreed.Assert(o.transientrep == this.support.bRep);
232
+
233
+ o.transientrep = this.support.bRep;
234
+ this.support.bRep = null;
203235 }
204236
205237 // o.support = this.support;
....@@ -223,19 +255,35 @@
223255
224256 RestoreBigData(o);
225257
226
- hashtable.remove(GetUUID());
258
+ if (blockloop)
259
+ return;
260
+
261
+ blockloop = true;
262
+
263
+ //hashtable.remove(GetUUID());
227264
228265 for (int i=0; i<Size(); i++)
229266 {
230267 get(i).RestoreBigData(hashtable);
231268 }
269
+
270
+ blockloop = false;
232271 }
233272
234273 void RestoreBigData(Object3D o)
235274 {
236275 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
276
+ if (this.support != null && o.transientrep != null)
277
+ {
278
+ this.support.bRep = o.transientrep;
279
+ }
280
+
281
+ this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
285
+// July 2019 if (this.bRep != null)
286
+// this.bRep.support = o.transientrep;
239287 // this.support = o.support;
240288 // this.fileparent = o.fileparent;
241289 }
....@@ -381,6 +429,7 @@
381429 }
382430
383431 boolean live = false;
432
+ transient boolean keepdontselect;
384433 boolean dontselect = false;
385434 boolean hide = false;
386435 boolean link2master = false; // performs reset support/master at each frame
....@@ -563,12 +612,14 @@
563612 toParent = LA.newMatrix();
564613 fromParent = LA.newMatrix();
565614 }
615
+
566616 if (toParentMarked == null)
567617 {
568618 if (maxcount != 1)
569619 {
570620 new Exception().printStackTrace();
571621 }
622
+
572623 toParentMarked = LA.newMatrix();
573624 fromParentMarked = LA.newMatrix();
574625 }
....@@ -879,7 +930,7 @@
879930
880931 if (marked && Globals.isLIVE() && live &&
881932 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
933
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883934 currentframe != Globals.framecount)
884935 {
885936 currentframe = Globals.framecount;
....@@ -891,7 +942,8 @@
891942
892943 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893944
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
945
+ if (transformcount*factor >= maxcount && (rewind || random) ||
946
+ (step == 1 && changedir))
895947 {
896948 countdown = 1;
897949 delay = speedup?8:1;
....@@ -963,6 +1015,10 @@
9631015 if (material == null || material.multiply)
9641016 return true;
9651017
1018
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1019
+ return false;
1020
+
1021
+ // Transparent objects are dynamic because we have to sort the triangles.
9661022 return material.opacity > 0.99;
9671023 }
9681024
....@@ -1363,6 +1419,7 @@
13631419 toParent = LA.newMatrix();
13641420 fromParent = LA.newMatrix();
13651421 }
1422
+
13661423 LA.matCopy(other.toParent, toParent);
13671424 LA.matCopy(other.fromParent, fromParent);
13681425
....@@ -2384,6 +2441,10 @@
23842441 }
23852442 */
23862443 }
2444
+ else
2445
+ {
2446
+ //((ObjEditor)editWindow).SetupUI2(null);
2447
+ }
23872448 }
23882449
23892450 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2486,14 @@
24252486 {
24262487 editWindow.refreshContents();
24272488 }
2489
+ else
2490
+ {
2491
+ if (manipWindow != null)
2492
+ {
2493
+ manipWindow.refreshContents();
2494
+ }
2495
+ }
2496
+
24282497 //if (parent != null)
24292498 //parent.refreshEditWindow();
24302499 }
....@@ -2504,7 +2573,8 @@
25042573 private static final int editSelf = 1;
25052574 private static final int editChild = 2;
25062575
2507
- void drawEditHandles(ClickInfo info, int level)
2576
+ void drawEditHandles(//ClickInfo info,
2577
+ int level)
25082578 {
25092579 if (level == 0)
25102580 {
....@@ -2512,7 +2582,8 @@
25122582 return;
25132583
25142584 Object3D selectee;
2515
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2585
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2586
+ level + 1))
25162587 {
25172588 selectee = (Object3D) e.nextElement();
25182589 }
....@@ -2520,19 +2591,22 @@
25202591 } else
25212592 {
25222593 //super.
2523
- drawEditHandles0(info, level + 1);
2594
+ drawEditHandles0(//info,
2595
+ level + 1);
25242596 }
25252597 }
25262598
2527
- boolean doEditClick(ClickInfo info, int level)
2599
+ boolean doEditClick(//ClickInfo info,
2600
+ int level)
25282601 {
25292602 doSomething = 0;
25302603 if (level == 0)
25312604 {
2532
- return doParentClick(info);
2605
+ return doParentClick(); //info);
25332606 }
25342607 if (//super.
2535
- doEditClick0(info, level))
2608
+ doEditClick0(//info,
2609
+ level))
25362610 {
25372611 doSomething = 1;
25382612 return true;
....@@ -2542,7 +2616,7 @@
25422616 }
25432617 }
25442618
2545
- boolean doParentClick(ClickInfo info)
2619
+ boolean doParentClick() //ClickInfo info)
25462620 {
25472621 if (selection == null)
25482622 {
....@@ -2555,7 +2629,8 @@
25552629 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25562630 {
25572631 Object3D selectee = (Object3D) e.nextElement();
2558
- if (selectee.doEditClick(info, 1))
2632
+ if (selectee.doEditClick(//info,
2633
+ 1))
25592634 {
25602635 childToDrag = selectee;
25612636 doSomething = 2;
....@@ -2567,13 +2642,15 @@
25672642 return retval;
25682643 }
25692644
2570
- void doEditDrag(ClickInfo info, boolean opposite)
2645
+ void doEditDrag(//ClickInfo clickInfo,
2646
+ boolean opposite)
25712647 {
25722648 switch (doSomething)
25732649 {
25742650 case 1: // '\001'
25752651 //super.
2576
- doEditDrag0(info, opposite);
2652
+ doEditDrag0(//clickInfo,
2653
+ opposite);
25772654 break;
25782655
25792656 case 2: // '\002'
....@@ -2586,11 +2663,13 @@
25862663 {
25872664 //sel.hitSomething = childToDrag.hitSomething;
25882665 //childToDrag.doEditDrag(info);
2589
- sel.doEditDrag(info, opposite);
2666
+ sel.doEditDrag(//clickInfo,
2667
+ opposite);
25902668 } else
25912669 {
25922670 //super.
2593
- doEditDrag0(info, opposite);
2671
+ doEditDrag0(//clickInfo,
2672
+ opposite);
25942673 }
25952674 }
25962675 break;
....@@ -2608,6 +2687,9 @@
26082687 {
26092688 deselectAll();
26102689 }
2690
+
2691
+ new Exception().printStackTrace();
2692
+
26112693 ClickInfo newInfo = new ClickInfo();
26122694 newInfo.flags = info.flags;
26132695 newInfo.bounds = info.bounds;
....@@ -3055,7 +3137,7 @@
30553137 {
30563138 if (bRep != null)
30573139 {
3058
- bRep.GenerateNormalsMINE();
3140
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593141 Touch();
30603142 }
30613143 }
....@@ -3501,7 +3583,8 @@
35013583 if (blockloop)
35023584 return;
35033585
3504
- if (marked || (bRep != null && material != null)) // borderline...
3586
+ if (//marked || // does not make sense
3587
+ (bRep != null || material != null)) // borderline...
35053588 live = h;
35063589
35073590 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3605,8 @@
35223605 return;
35233606
35243607 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3608
+ if (//marked || // does not make sense
3609
+ (bRep != null || material != null)) // borderline...
35263610 link2master = h;
35273611
35283612 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3626,8 @@
35423626 if (blockloop)
35433627 return;
35443628
3545
- if (marked || (bRep != null && material != null)) // borderline...
3629
+ if (//marked || // does not make sense
3630
+ (bRep != null || material != null)) // borderline...
35463631 hide = h;
35473632
35483633 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3647,7 @@
35623647 if (blockloop)
35633648 return;
35643649
3565
- if (bRep != null && material != null) // borderline...
3650
+ if (bRep != null || material != null) // borderline...
35663651 marked = h;
35673652
35683653 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3657,46 @@
35723657 continue;
35733658 blockloop = true;
35743659 child.MarkLeaves(h);
3660
+ blockloop = false;
3661
+ // release(i);
3662
+ }
3663
+ }
3664
+
3665
+ void RewindLeaves(boolean h)
3666
+ {
3667
+ if (blockloop)
3668
+ return;
3669
+
3670
+ if (bRep != null || material != null) // borderline...
3671
+ rewind = h;
3672
+
3673
+ for (int i = 0; i < Size(); i++)
3674
+ {
3675
+ Object3D child = (Object3D) get(i); // reserve(i);
3676
+ if (child == null)
3677
+ continue;
3678
+ blockloop = true;
3679
+ child.RewindLeaves(h);
3680
+ blockloop = false;
3681
+ // release(i);
3682
+ }
3683
+ }
3684
+
3685
+ void RandomLeaves(boolean h)
3686
+ {
3687
+ if (blockloop)
3688
+ return;
3689
+
3690
+ if (bRep != null || material != null) // borderline...
3691
+ random = h;
3692
+
3693
+ for (int i = 0; i < Size(); i++)
3694
+ {
3695
+ Object3D child = (Object3D) get(i); // reserve(i);
3696
+ if (child == null)
3697
+ continue;
3698
+ blockloop = true;
3699
+ child.RandomLeaves(h);
35753700 blockloop = false;
35763701 // release(i);
35773702 }
....@@ -4349,6 +4474,55 @@
43494474 }
43504475 }
43514476
4477
+ void RepairSOV()
4478
+ {
4479
+ if (blockloop)
4480
+ return;
4481
+
4482
+ String texname = this.GetPigmentTexture();
4483
+
4484
+ if (texname.startsWith("sov"))
4485
+ {
4486
+ String[] s = texname.split("/");
4487
+
4488
+ String[] sname = s[1].split("Color.pn");
4489
+
4490
+ texname = sname[0];
4491
+
4492
+ if (sname.length > 1)
4493
+ {
4494
+ texname += "Color.jpg";
4495
+ }
4496
+
4497
+ this.SetPigmentTexture("sov/" + texname);
4498
+ }
4499
+
4500
+ texname = this.GetBumpTexture();
4501
+
4502
+ if (texname.startsWith("sov"))
4503
+ {
4504
+ String[] s = texname.split("/");
4505
+
4506
+ String[] sname = s[1].split("Bump.pn");
4507
+
4508
+ texname = sname[0];
4509
+
4510
+ if (sname.length > 1)
4511
+ {
4512
+ texname += "Bump.jpg";
4513
+ }
4514
+
4515
+ this.SetBumpTexture("sov/" + texname);
4516
+ }
4517
+
4518
+ for (int i=0; i<Size(); i++)
4519
+ {
4520
+ blockloop = true;
4521
+ get(i).RepairSOV();
4522
+ blockloop = false;
4523
+ }
4524
+ }
4525
+
43524526 void RepairTexture()
43534527 {
43544528 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5037,14 @@
48635037 }
48645038 }
48655039
5040
+ ObjEditor GetWindow()
5041
+ {
5042
+ if (editWindow != null)
5043
+ return editWindow;
5044
+
5045
+ return manipWindow;
5046
+ }
5047
+
48665048 cTreePath Select(int indexcount, boolean deselect)
48675049 {
48685050 if (hide || dontselect)
....@@ -4899,10 +5081,11 @@
48995081 if (leaf != null)
49005082 {
49015083 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
49035086 {
49045087 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5088
+ window.Select(tp, deselect, true);
49065089 }
49075090
49085091 return tp;
....@@ -4919,6 +5102,7 @@
49195102
49205103 if (child == null)
49215104 continue;
5105
+
49225106 if (child.HasTransparency() && child.size() != 0)
49235107 {
49245108 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5112,10 @@
49285112 if (leaf != null)
49295113 {
49305114 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
49325117 {
4933
- editWindow.Select(tp, deselect, true);
5118
+ window.Select(tp, deselect, true);
49345119 }
49355120
49365121 return tp;
....@@ -5255,6 +5440,51 @@
52555440 blockloop = false;
52565441 }
52575442
5443
+ void ResetSelectable()
5444
+ {
5445
+ if (blockloop)
5446
+ return;
5447
+
5448
+ blockloop = true;
5449
+
5450
+ keepdontselect = dontselect;
5451
+ dontselect = true;
5452
+
5453
+ Object3D child;
5454
+ int nb = Size();
5455
+ for (int i = 0; i < nb; i++)
5456
+ {
5457
+ child = (Object3D) get(i);
5458
+ if (child == null)
5459
+ continue;
5460
+ child.ResetSelectable();
5461
+ }
5462
+
5463
+ blockloop = false;
5464
+ }
5465
+
5466
+ void RestoreSelectable()
5467
+ {
5468
+ if (blockloop)
5469
+ return;
5470
+
5471
+ blockloop = true;
5472
+
5473
+ dontselect = keepdontselect;
5474
+
5475
+ Object3D child;
5476
+ int nb = Size();
5477
+ for (int i = 0; i < nb; i++)
5478
+ {
5479
+ child = (Object3D) get(i);
5480
+ if (child == null)
5481
+ continue;
5482
+ child.RestoreSelectable();
5483
+ }
5484
+
5485
+ blockloop = false;
5486
+ }
5487
+
52585488 boolean IsSelected()
52595489 {
52605490 if (parent == null)
....@@ -5564,6 +5794,38 @@
55645794 }
55655795 }
55665796
5797
+ void EmbedTextures(boolean embed)
5798
+ {
5799
+ if (blockloop)
5800
+ return;
5801
+
5802
+ //if (GetTextures() != null)
5803
+ if (embed)
5804
+ CameraPane.EmbedTextures(GetTextures());
5805
+ else
5806
+ {
5807
+ GetTextures().pigmentdata = null;
5808
+ GetTextures().bumpdata = null;
5809
+ GetTextures().pw = 0;
5810
+ GetTextures().ph = 0;
5811
+ GetTextures().bw = 0;
5812
+ GetTextures().bh = 0;
5813
+ }
5814
+
5815
+ int nb = Size();
5816
+ for (int i = 0; i < nb; i++)
5817
+ {
5818
+ Object3D child = (Object3D) get(i);
5819
+
5820
+ if (child == null)
5821
+ continue;
5822
+
5823
+ blockloop = true;
5824
+ child.EmbedTextures(embed);
5825
+ blockloop = false;
5826
+ }
5827
+ }
5828
+
55675829 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685830 {
55695831 Draw(display, root, selected, blocked);
....@@ -5572,12 +5834,23 @@
55725834 boolean NeedSupport()
55735835 {
55745836 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5837
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765838 // PROBLEM with CROWD!!
55775839 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785840 }
55795841
55805842 static boolean DEBUG_SELECTION = false;
5843
+
5844
+ boolean IsLive()
5845
+ {
5846
+ if (live)
5847
+ return true;
5848
+
5849
+ if (parent == null)
5850
+ return false;
5851
+
5852
+ return parent.IsLive();
5853
+ }
55815854
55825855 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835856 {
....@@ -5639,8 +5912,10 @@
56395912 if (support != null)
56405913 support = support;
56415914
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);
5915
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5916
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5917
+
5918
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56445919
56455920 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465921 {
....@@ -5650,8 +5925,9 @@
56505925 // usecalllists &= !(parent instanceof RandomNode);
56515926 // usecalllists = false;
56525927
5653
- if (GetBRep() != null)
5654
- usecalllists = usecalllists;
5928
+ if (display.DrawMode() == display.SHADOW)
5929
+ //GetBRep() != null)
5930
+ usecalllists = !!usecalllists;
56555931 //System.out.println("draw " + this);
56565932 //new Exception().printStackTrace();
56575933
....@@ -5660,10 +5936,12 @@
56605936 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615937
56625938 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5939
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5940
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645941 {
56655942 Globals.lighttouched = true;
56665943 } // all panes...
5944
+
56675945 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685946 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695947 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5671,7 +5949,7 @@
56715949 if (!(this instanceof Composite))
56725950 touched = false;
56735951 //if (displaylist == -1 && usecalllists)
5674
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5952
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56755953 {
56765954 bRep.displaylist = display.GenList();
56775955 assert(bRep.displaylist != 0);
....@@ -5682,7 +5960,7 @@
56825960
56835961 //System.out.println("\tnew list " + list);
56845962 //gl.glDrawBuffer(gl.GL_NONE);
5685
- if (usecalllists)
5963
+ if (usecalllists && bRep.displaylist > 0)
56865964 {
56875965 // System.err.println("new list " + bRep.displaylist + " for " + this);
56885966 display.NewList(bRep.displaylist);
....@@ -5691,7 +5969,7 @@
56915969 CallList(display, root, selected, blocked);
56925970
56935971 // compiled = true;
5694
- if (usecalllists)
5972
+ if (usecalllists && bRep.displaylist > 0)
56955973 {
56965974 // System.err.println("end list " + bRep.displaylist + " for " + this);
56975975 display.EndList();
....@@ -5791,6 +6069,7 @@
57916069 if (GetBRep() != null)
57926070 {
57936071 display.NextIndex();
6072
+
57946073 // vertex color conflict : gl.glCallList(list);
57956074 DrawNode(display, root, selected);
57966075 if (this instanceof BezierPatch)
....@@ -5831,16 +6110,27 @@
58316110 tex = GetTextures();
58326111 }
58336112
5834
- boolean failed = false;
6113
+ boolean failedPigment = false;
6114
+ boolean failedBump = false;
58356115
58366116 try
58376117 {
5838
- display.BindTextures(tex, texres);
6118
+ display.BindPigmentTexture(tex, texres);
58396119 }
58406120 catch (Exception e)
58416121 {
58426122 System.err.println("FAILED: " + this);
5843
- failed = true;
6123
+ failedPigment = true;
6124
+ }
6125
+
6126
+ try
6127
+ {
6128
+ display.BindBumpTexture(tex, texres);
6129
+ }
6130
+ catch (Exception e)
6131
+ {
6132
+ //System.err.println("FAILED: " + this);
6133
+ failedBump = true;
58446134 }
58456135
58466136 if (!compiled)
....@@ -5863,8 +6153,11 @@
58636153 }
58646154 }
58656155
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6156
+ if (!failedBump)
6157
+ display.ReleaseBumpTexture(tex);
6158
+
6159
+ if (!failedPigment)
6160
+ display.ReleasePigmentTexture(tex);
58686161
58696162 display.PopMaterial(this, selected);
58706163 }
....@@ -6237,6 +6530,11 @@
62376530 // dec 2012
62386531 new Exception().printStackTrace();
62396532 return;
6533
+ }
6534
+
6535
+ if (dontselect)
6536
+ {
6537
+ //bRep.GenerateNormalsMINE();
62406538 }
62416539
62426540 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7022,20 +7320,23 @@
70227320 }
70237321 }
70247322
7025
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7323
+ static ClickInfo clickInfo = new ClickInfo();
7324
+
7325
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7326
+ Point outPt, Rectangle outRec)
70267327 {
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;
7328
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7329
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7330
+ double[][] toscreen = clickInfo.toScreen;
70307331 if (toscreen == null)
70317332 {
7032
- toscreen = new Camera(info.camera.viewCode).toScreen;
7333
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70337334 }
70347335 cVector vec = in;
70357336 LA.xformPos(in, toscreen, in);
70367337 //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();
7338
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7339
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70397340 outPt.x = hc + (int) vec.x;
70407341 outPt.y = vc - (int) vec.y;
70417342 outRec.x = outPt.x - 3;
....@@ -7043,15 +7344,18 @@
70437344 outRec.width = outRec.height = 6;
70447345 }
70457346
7046
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7347
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7348
+ )
70477349 {
70487350 Point pt = new Point(0, 0);
70497351 Rectangle rec = new Rectangle();
7050
- calcHotSpot(in, info, pt, rec);
7352
+ calcHotSpot(in, //clickInfo,
7353
+ pt, rec);
70517354 return rec;
70527355 }
70537356
7054
- void drawEditHandles0(ClickInfo info, int level)
7357
+ void drawEditHandles0(//ClickInfo clickInfo,
7358
+ int level)
70557359 {
70567360 if (level == 0)
70577361 {
....@@ -7060,16 +7364,19 @@
70607364 {
70617365 cVector origin = new cVector();
70627366 //LA.xformPos(origin, toParent, origin);
7063
- Rectangle spot = calcHotSpot(origin, info);
7367
+ if (this.clickInfo == null)
7368
+ this.clickInfo = new ClickInfo();
7369
+
7370
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70647371 Rectangle boundary = new Rectangle();
70657372 boundary.x = spot.x - 30;
70667373 boundary.y = spot.y - 30;
70677374 boundary.width = spot.width + 60;
70687375 boundary.height = spot.height + 60;
7069
- info.g.setColor(Color.red);
7376
+ clickInfo.g.setColor(Color.red);
70707377 int spotw = spot.x + spot.width;
70717378 int spoth = spot.y + spot.height;
7072
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70737380 // if (CameraPane.Xmin > spot.x)
70747381 // {
70757382 // CameraPane.Xmin = spot.x;
....@@ -7089,8 +7396,8 @@
70897396 spot.translate(32, 32);
70907397 spotw = spot.x + spot.width;
70917398 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7093
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7399
+ clickInfo.g.setColor(Color.cyan);
7400
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947401 // if (CameraPane.Xmin > spot.x)
70957402 // {
70967403 // CameraPane.Xmin = spot.x;
....@@ -7107,11 +7414,12 @@
71077414 // {
71087415 // CameraPane.Ymax = spoth;
71097416 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7417
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7418
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127419 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7114
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7420
+ clickInfo.g.setColor(Color.yellow);
7421
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7422
+ clickInfo.g.setColor(Color.green);
71157423 // if (CameraPane.Xmin > spot.x)
71167424 // {
71177425 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7436,8 @@
71287436 // {
71297437 // CameraPane.Ymax = spoth;
71307438 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7439
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7440
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71337441 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347442 // if (CameraPane.Xmin > boundary.x)
71357443 // {
....@@ -7151,7 +7459,8 @@
71517459 }
71527460 }
71537461
7154
- boolean doEditClick0(ClickInfo info, int level)
7462
+ boolean doEditClick0(//ClickInfo clickInfo,
7463
+ int level)
71557464 {
71567465 if (level == 0)
71577466 {
....@@ -7160,8 +7469,8 @@
71607469
71617470 boolean retval = false;
71627471
7163
- startX = info.x;
7164
- startY = info.y;
7472
+ startX = clickInfo.x;
7473
+ startY = clickInfo.y;
71657474
71667475 hitSomething = -1;
71677476 cVector origin = new cVector();
....@@ -7171,22 +7480,51 @@
71717480 {
71727481 centerPt = new Point(0, 0);
71737482 }
7174
- calcHotSpot(origin, info, centerPt, spot);
7175
- if (spot.contains(info.x, info.y))
7483
+ calcHotSpot(origin, //info,
7484
+ centerPt, spot);
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
71767486 {
71777487 hitSomething = hitCenter;
71787488 retval = true;
71797489 }
71807490 spot.translate(32, 0);
7181
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
71827492 {
71837493 hitSomething = hitRotate;
71847494 retval = true;
71857495 }
71867496 spot.translate(0, 32);
7187
- if (spot.contains(info.x, info.y))
7497
+ if (spot.contains(clickInfo.x, clickInfo.y))
71887498 {
71897499 hitSomething = hitScale;
7500
+
7501
+ double scale = 0.005f * clickInfo.camera.Distance();
7502
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7503
+ double sign = 1;
7504
+ if (hScale < 0)
7505
+ {
7506
+ sign = -1;
7507
+ }
7508
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7509
+ if (hScale < 0.01)
7510
+ {
7511
+ //hScale = 0.01;
7512
+ }
7513
+
7514
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7515
+ sign = 1;
7516
+ if (vScale < 0)
7517
+ {
7518
+ sign = -1;
7519
+ }
7520
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7521
+ if (vScale < 0.01)
7522
+ {
7523
+ //vScale = 0.01;
7524
+ }
7525
+
7526
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7527
+
71907528 retval = true;
71917529 }
71927530
....@@ -7196,7 +7534,7 @@
71967534 }
71977535
71987536 //System.out.println("info.modifiers = " + info.modifiers);
7199
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7537
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72007538 //System.out.println("modified = " + modified);
72017539 //new Exception().printStackTrace();
72027540 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7224,7 +7562,8 @@
72247562 return true;
72257563 }
72267564
7227
- void doEditDrag0(ClickInfo info, boolean opposite)
7565
+ void doEditDrag0(//ClickInfo info,
7566
+ boolean opposite)
72287567 {
72297568 if (hitSomething == 0)
72307569 {
....@@ -7238,7 +7577,7 @@
72387577
72397578 //System.out.println("hitSomething = " + hitSomething);
72407579
7241
- double scale = 0.005f * info.camera.Distance();
7580
+ double scale = 0.005f * clickInfo.camera.Distance();
72427581
72437582 cVector xlate = new cVector();
72447583 //cVector xlate2 = new cVector();
....@@ -7272,8 +7611,8 @@
72727611 toParent[3][i] = xlate.get(i);
72737612 LA.matInvert(toParent, fromParent);
72747613 */
7275
- cVector delta = LA.newVector(0, 0, startY - info.y);
7276
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7614
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7615
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72777616
72787617 LA.matCopy(startMat, toParent);
72797618 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7282,7 +7621,7 @@
72827621 } else
72837622 {
72847623 //LA.xformDir(delta, info.camera.fromScreen, delta);
7285
- cVector up = new cVector(info.camera.up);
7624
+ cVector up = new cVector(clickInfo.camera.up);
72867625 cVector away = new cVector();
72877626 //cVector right2 = new cVector();
72887627 //LA.vecCross(up, cVector.Z, right);
....@@ -7299,19 +7638,19 @@
72997638 LA.xformDir(up, ClickInfo.matbuffer, up);
73007639 // if (!CameraPane.LOCALTRANSFORM)
73017640 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7302
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7641
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73037642 // if (!CameraPane.LOCALTRANSFORM)
73047643 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73057644 //LA.vecCross(up, cVector.Z, right2);
73067645
7307
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7646
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73087647
73097648 //System.out.println("DELTA0 = " + delta);
73107649 //System.out.println("AWAY = " + info.camera.away);
73117650 //System.out.println("UP = " + info.camera.up);
73127651 if (away.z > 0)
73137652 {
7314
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7653
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73157654 {
73167655 delta.x = -delta.x;
73177656 } else
....@@ -7326,7 +7665,7 @@
73267665 //System.out.println("DELTA1 = " + delta);
73277666 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73287667 //System.out.println("DELTA2 = " + delta);
7329
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7668
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73307669 LA.matCopy(startMat, toParent);
73317670 //System.out.println("DELTA3 = " + delta);
73327671 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7336,8 +7675,8 @@
73367675 break;
73377676
73387677 case hitRotate: // rotate
7339
- int dx = info.x - centerPt.x;
7340
- int dy = -(info.y - centerPt.y);
7678
+ int dx = clickInfo.x - centerPt.x;
7679
+ int dy = -(clickInfo.y - centerPt.y);
73417680 double angle = (double) Math.atan2(dx, dy);
73427681 angle = -(1.570796 - angle);
73437682
....@@ -7360,7 +7699,7 @@
73607699 }
73617700 /**/
73627701
7363
- switch (info.pane.RenderCamera().viewCode)
7702
+ switch (clickInfo.pane.RenderCamera().viewCode)
73647703 {
73657704 case 1: // '\001'
73667705 LA.matZRotate(toParent, angle);
....@@ -7387,7 +7726,7 @@
73877726 break;
73887727
73897728 case hitScale: // scale
7390
- double hScale = (double) (info.x - centerPt.x) / 32;
7729
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
73917730 double sign = 1;
73927731 if (hScale < 0)
73937732 {
....@@ -7399,7 +7738,7 @@
73997738 //hScale = 0.01;
74007739 }
74017740
7402
- double vScale = (double) (info.y - centerPt.y) / 32;
7741
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74037742 sign = 1;
74047743 if (vScale < 0)
74057744 {
....@@ -7410,6 +7749,7 @@
74107749 {
74117750 //vScale = 0.01;
74127751 }
7752
+
74137753 LA.matCopy(startMat, toParent);
74147754 /**/
74157755 for (int i = 0; i < 3; i++)
....@@ -7419,29 +7759,30 @@
74197759 }
74207760 /**/
74217761
7422
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7762
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74237763
74247764 if (totalScale < 0.01)
74257765 {
74267766 totalScale = 0.01;
74277767 }
74287768
7429
- switch (info.pane.RenderCamera().viewCode)
7769
+ switch (clickInfo.pane.RenderCamera().viewCode)
74307770 {
74317771 case 3: // '\001'
7432
- if (modified)
7772
+ if (modified || opposite)
74337773 {
74347774 //LA.matScale(toParent, 1, hScale, vScale);
74357775 LA.matScale(toParent, totalScale, 1, 1);
74367776 } // vScale, 1);
74377777 else
74387778 {
7779
+ // EXCEPTION!
74397780 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407781 } // vScale, 1);
74417782 break;
74427783
74437784 case 2: // '\002'
7444
- if (modified)
7785
+ if (modified || opposite)
74457786 {
74467787 //LA.matScale(toParent, hScale, 1, vScale);
74477788 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7793,7 @@
74527793 break;
74537794
74547795 case 1: // '\003'
7455
- if (modified)
7796
+ if (modified || opposite)
74567797 {
74577798 //LA.matScale(toParent, hScale, vScale, 1);
74587799 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7492,7 +7833,7 @@
74927833 } // NEW ...
74937834
74947835
7495
- info.pane.repaint();
7836
+ clickInfo.pane.repaint();
74967837 }
74977838
74987839 boolean overflow = false;
....@@ -7672,6 +8013,10 @@
76728013 editWindow = null;
76738014 } // ?
76748015 }
8016
+ else
8017
+ {
8018
+ //editWindow.closeUI();
8019
+ }
76758020 }
76768021
76778022 boolean root; // patch for edit windows
....@@ -7829,6 +8174,10 @@
78298174 }
78308175
78318176 transient ObjEditor editWindow;
8177
+ transient ObjEditor manipWindow;
8178
+
8179
+ transient boolean pinned;
8180
+
78328181 transient ObjectUI objectUI;
78338182 public static int povDepth = 0;
78348183 private static cVector tbMin = new cVector();