Normand Briere
2019-07-24 ebd16116fc612bf14e2469ba27dd7ee54918eabb
Object3D.java
....@@ -24,6 +24,14 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
2735 ScriptNode scriptnode;
2836
2937 void InitOthers()
....@@ -104,64 +112,178 @@
104112
105113 // transient boolean reduced; // for morph reduction
106114
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
109117
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
112120
113
-void SaveSupports()
114
-{
115
- if (blockloop)
116
- return;
117
-
118
- transientsupport = support;
119
- transientlink2master = link2master;
120
-
121
- support = null;
122
- link2master = false;
123
-
124
- if (bRep != null)
121
+ void SaveSupports()
125122 {
126
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
136
+
137
+ for (int i = 0; i < Size(); i++)
138
+ {
139
+ Object3D child = (Object3D) get(i);
140
+ if (child == null)
141
+ continue;
142
+ blockloop = true;
143
+ child.SaveSupports();
144
+ blockloop = false;
145
+ }
127146 }
128
-
129
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
130149 {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
134258 blockloop = true;
135
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
136267 blockloop = false;
137268 }
138
-}
139269
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
144
-
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
151271 {
152
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
153286 }
154
-
155
- for (int i = 0; i < Size(); i++)
156
- {
157
- Object3D child = (Object3D) get(i);
158
- if (child == null)
159
- continue;
160
- blockloop = true;
161
- child.RestoreSupports();
162
- blockloop = false;
163
- }
164
-}
165287
166288 // MOCAP SUPPORT
167289 double tx,ty,tz,rx,ry,rz;
....@@ -304,6 +426,7 @@
304426 }
305427
306428 boolean live = false;
429
+ transient boolean keepdontselect;
307430 boolean dontselect = false;
308431 boolean hide = false;
309432 boolean link2master = false; // performs reset support/master at each frame
....@@ -486,12 +609,14 @@
486609 toParent = LA.newMatrix();
487610 fromParent = LA.newMatrix();
488611 }
612
+
489613 if (toParentMarked == null)
490614 {
491615 if (maxcount != 1)
492616 {
493617 new Exception().printStackTrace();
494618 }
619
+
495620 toParentMarked = LA.newMatrix();
496621 fromParentMarked = LA.newMatrix();
497622 }
....@@ -802,7 +927,7 @@
802927
803928 if (marked && Globals.isLIVE() && live &&
804929 //TEMP21aug2018
805
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
806931 currentframe != Globals.framecount)
807932 {
808933 currentframe = Globals.framecount;
....@@ -814,7 +939,8 @@
814939
815940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
816941
817
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
818944 {
819945 countdown = 1;
820946 delay = speedup?8:1;
....@@ -886,6 +1012,7 @@
8861012 if (material == null || material.multiply)
8871013 return true;
8881014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8891016 return material.opacity > 0.99;
8901017 }
8911018
....@@ -1286,6 +1413,7 @@
12861413 toParent = LA.newMatrix();
12871414 fromParent = LA.newMatrix();
12881415 }
1416
+
12891417 LA.matCopy(other.toParent, toParent);
12901418 LA.matCopy(other.fromParent, fromParent);
12911419
....@@ -2307,6 +2435,10 @@
23072435 }
23082436 */
23092437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23102442 }
23112443
23122444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2348,6 +2480,14 @@
23482480 {
23492481 editWindow.refreshContents();
23502482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23512491 //if (parent != null)
23522492 //parent.refreshEditWindow();
23532493 }
....@@ -2427,7 +2567,8 @@
24272567 private static final int editSelf = 1;
24282568 private static final int editChild = 2;
24292569
2430
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
24312572 {
24322573 if (level == 0)
24332574 {
....@@ -2435,7 +2576,8 @@
24352576 return;
24362577
24372578 Object3D selectee;
2438
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
24392581 {
24402582 selectee = (Object3D) e.nextElement();
24412583 }
....@@ -2443,19 +2585,22 @@
24432585 } else
24442586 {
24452587 //super.
2446
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
24472590 }
24482591 }
24492592
2450
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
24512595 {
24522596 doSomething = 0;
24532597 if (level == 0)
24542598 {
2455
- return doParentClick(info);
2599
+ return doParentClick(); //info);
24562600 }
24572601 if (//super.
2458
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
24592604 {
24602605 doSomething = 1;
24612606 return true;
....@@ -2465,7 +2610,7 @@
24652610 }
24662611 }
24672612
2468
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
24692614 {
24702615 if (selection == null)
24712616 {
....@@ -2478,7 +2623,8 @@
24782623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24792624 {
24802625 Object3D selectee = (Object3D) e.nextElement();
2481
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
24822628 {
24832629 childToDrag = selectee;
24842630 doSomething = 2;
....@@ -2490,13 +2636,15 @@
24902636 return retval;
24912637 }
24922638
2493
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
24942641 {
24952642 switch (doSomething)
24962643 {
24972644 case 1: // '\001'
24982645 //super.
2499
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
25002648 break;
25012649
25022650 case 2: // '\002'
....@@ -2509,11 +2657,13 @@
25092657 {
25102658 //sel.hitSomething = childToDrag.hitSomething;
25112659 //childToDrag.doEditDrag(info);
2512
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
25132662 } else
25142663 {
25152664 //super.
2516
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25172667 }
25182668 }
25192669 break;
....@@ -2531,6 +2681,9 @@
25312681 {
25322682 deselectAll();
25332683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
25342687 ClickInfo newInfo = new ClickInfo();
25352688 newInfo.flags = info.flags;
25362689 newInfo.bounds = info.bounds;
....@@ -2623,6 +2776,18 @@
26232776 void GenNormalsS(boolean crease)
26242777 {
26252778 selection.GenNormals(crease);
2779
+// for (int i=0; i<selection.size(); i++)
2780
+// {
2781
+// Object3D selectee = (Object3D) selection.elementAt(i);
2782
+// selectee.GenNormals(crease);
2783
+// }
2784
+
2785
+ //Touch();
2786
+ }
2787
+
2788
+ void GenNormalsMeshS()
2789
+ {
2790
+ selection.GenNormalsMesh();
26262791 // for (int i=0; i<selection.size(); i++)
26272792 // {
26282793 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2763,6 +2928,24 @@
27632928 if (child == null)
27642929 continue;
27652930 child.GenNormals(crease);
2931
+// Children().release(i);
2932
+ }
2933
+ blockloop = false;
2934
+ }
2935
+
2936
+ void GenNormalsMesh()
2937
+ {
2938
+ if (blockloop)
2939
+ return;
2940
+
2941
+ blockloop = true;
2942
+ GenNormalsMesh0();
2943
+ for (int i = 0; i < Children().Size(); i++)
2944
+ {
2945
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2946
+ if (child == null)
2947
+ continue;
2948
+ child.GenNormalsMesh();
27662949 // Children().release(i);
27672950 }
27682951 blockloop = false;
....@@ -2935,11 +3118,20 @@
29353118 }
29363119 }
29373120
3121
+ void GenNormalsMesh0()
3122
+ {
3123
+ if (bRep != null)
3124
+ {
3125
+ bRep.GenerateNormalsMesh();
3126
+ Touch();
3127
+ }
3128
+ }
3129
+
29383130 void GenNormalsMINE0()
29393131 {
29403132 if (bRep != null)
29413133 {
2942
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29433135 Touch();
29443136 }
29453137 }
....@@ -3385,7 +3577,8 @@
33853577 if (blockloop)
33863578 return;
33873579
3388
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
33893582 live = h;
33903583
33913584 for (int i = 0; i < Size(); i++)
....@@ -3406,7 +3599,8 @@
34063599 return;
34073600
34083601 //if (bRep != null)
3409
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
34103604 link2master = h;
34113605
34123606 for (int i = 0; i < Size(); i++)
....@@ -3426,7 +3620,8 @@
34263620 if (blockloop)
34273621 return;
34283622
3429
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
34303625 hide = h;
34313626
34323627 for (int i = 0; i < Size(); i++)
....@@ -3446,7 +3641,7 @@
34463641 if (blockloop)
34473642 return;
34483643
3449
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
34503645 marked = h;
34513646
34523647 for (int i = 0; i < Size(); i++)
....@@ -3456,6 +3651,46 @@
34563651 continue;
34573652 blockloop = true;
34583653 child.MarkLeaves(h);
3654
+ blockloop = false;
3655
+ // release(i);
3656
+ }
3657
+ }
3658
+
3659
+ void RewindLeaves(boolean h)
3660
+ {
3661
+ if (blockloop)
3662
+ return;
3663
+
3664
+ if (bRep != null || material != null) // borderline...
3665
+ rewind = h;
3666
+
3667
+ for (int i = 0; i < Size(); i++)
3668
+ {
3669
+ Object3D child = (Object3D) get(i); // reserve(i);
3670
+ if (child == null)
3671
+ continue;
3672
+ blockloop = true;
3673
+ child.RewindLeaves(h);
3674
+ blockloop = false;
3675
+ // release(i);
3676
+ }
3677
+ }
3678
+
3679
+ void RandomLeaves(boolean h)
3680
+ {
3681
+ if (blockloop)
3682
+ return;
3683
+
3684
+ if (bRep != null || material != null) // borderline...
3685
+ random = h;
3686
+
3687
+ for (int i = 0; i < Size(); i++)
3688
+ {
3689
+ Object3D child = (Object3D) get(i); // reserve(i);
3690
+ if (child == null)
3691
+ continue;
3692
+ blockloop = true;
3693
+ child.RandomLeaves(h);
34593694 blockloop = false;
34603695 // release(i);
34613696 }
....@@ -4233,6 +4468,55 @@
42334468 }
42344469 }
42354470
4471
+ void RepairSOV()
4472
+ {
4473
+ if (blockloop)
4474
+ return;
4475
+
4476
+ String texname = this.GetPigmentTexture();
4477
+
4478
+ if (texname.startsWith("sov"))
4479
+ {
4480
+ String[] s = texname.split("/");
4481
+
4482
+ String[] sname = s[1].split("Color.pn");
4483
+
4484
+ texname = sname[0];
4485
+
4486
+ if (sname.length > 1)
4487
+ {
4488
+ texname += "Color.jpg";
4489
+ }
4490
+
4491
+ this.SetPigmentTexture("sov/" + texname);
4492
+ }
4493
+
4494
+ texname = this.GetBumpTexture();
4495
+
4496
+ if (texname.startsWith("sov"))
4497
+ {
4498
+ String[] s = texname.split("/");
4499
+
4500
+ String[] sname = s[1].split("Bump.pn");
4501
+
4502
+ texname = sname[0];
4503
+
4504
+ if (sname.length > 1)
4505
+ {
4506
+ texname += "Bump.jpg";
4507
+ }
4508
+
4509
+ this.SetBumpTexture("sov/" + texname);
4510
+ }
4511
+
4512
+ for (int i=0; i<Size(); i++)
4513
+ {
4514
+ blockloop = true;
4515
+ get(i).RepairSOV();
4516
+ blockloop = false;
4517
+ }
4518
+ }
4519
+
42364520 void RepairTexture()
42374521 {
42384522 if (this instanceof FileObject || blockloop)
....@@ -4747,6 +5031,14 @@
47475031 }
47485032 }
47495033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
47505042 cTreePath Select(int indexcount, boolean deselect)
47515043 {
47525044 if (hide || dontselect)
....@@ -4783,10 +5075,11 @@
47835075 if (leaf != null)
47845076 {
47855077 cTreePath tp = new cTreePath(this, leaf);
4786
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
47875080 {
47885081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4789
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
47905083 }
47915084
47925085 return tp;
....@@ -4803,6 +5096,7 @@
48035096
48045097 if (child == null)
48055098 continue;
5099
+
48065100 if (child.HasTransparency() && child.size() != 0)
48075101 {
48085102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4812,9 +5106,10 @@
48125106 if (leaf != null)
48135107 {
48145108 cTreePath tp = new cTreePath(this, leaf);
4815
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
48165111 {
4817
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
48185113 }
48195114
48205115 return tp;
....@@ -5139,6 +5434,51 @@
51395434 blockloop = false;
51405435 }
51415436
5437
+ void ResetSelectable()
5438
+ {
5439
+ if (blockloop)
5440
+ return;
5441
+
5442
+ blockloop = true;
5443
+
5444
+ keepdontselect = dontselect;
5445
+ dontselect = true;
5446
+
5447
+ Object3D child;
5448
+ int nb = Size();
5449
+ for (int i = 0; i < nb; i++)
5450
+ {
5451
+ child = (Object3D) get(i);
5452
+ if (child == null)
5453
+ continue;
5454
+ child.ResetSelectable();
5455
+ }
5456
+
5457
+ blockloop = false;
5458
+ }
5459
+
5460
+ void RestoreSelectable()
5461
+ {
5462
+ if (blockloop)
5463
+ return;
5464
+
5465
+ blockloop = true;
5466
+
5467
+ dontselect = keepdontselect;
5468
+
5469
+ Object3D child;
5470
+ int nb = Size();
5471
+ for (int i = 0; i < nb; i++)
5472
+ {
5473
+ child = (Object3D) get(i);
5474
+ if (child == null)
5475
+ continue;
5476
+ child.RestoreSelectable();
5477
+ }
5478
+
5479
+ blockloop = false;
5480
+ }
5481
+
51425482 boolean IsSelected()
51435483 {
51445484 if (parent == null)
....@@ -5448,6 +5788,38 @@
54485788 }
54495789 }
54505790
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
54515823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54525824 {
54535825 Draw(display, root, selected, blocked);
....@@ -5456,12 +5828,23 @@
54565828 boolean NeedSupport()
54575829 {
54585830 return
5459
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54605832 // PROBLEM with CROWD!!
54615833 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54625834 }
54635835
54645836 static boolean DEBUG_SELECTION = false;
5837
+
5838
+ boolean IsLive()
5839
+ {
5840
+ if (live)
5841
+ return true;
5842
+
5843
+ if (parent == null)
5844
+ return false;
5845
+
5846
+ return parent.IsLive();
5847
+ }
54655848
54665849 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54675850 {
....@@ -5524,7 +5907,7 @@
55245907 support = support;
55255908
55265909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5527
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
55285911
55295912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55305913 {
....@@ -5544,10 +5927,12 @@
55445927 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55455928
55465929 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5547
- (touched || (bRep != null && bRep.displaylist <= 0)))
5930
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5931
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
55485932 {
55495933 Globals.lighttouched = true;
55505934 } // all panes...
5935
+
55515936 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55525937 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55535938 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5675,6 +6060,7 @@
56756060 if (GetBRep() != null)
56766061 {
56776062 display.NextIndex();
6063
+
56786064 // vertex color conflict : gl.glCallList(list);
56796065 DrawNode(display, root, selected);
56806066 if (this instanceof BezierPatch)
....@@ -5715,16 +6101,27 @@
57156101 tex = GetTextures();
57166102 }
57176103
5718
- boolean failed = false;
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
57196106
57206107 try
57216108 {
5722
- display.BindTextures(tex, texres);
6109
+ display.BindPigmentTexture(tex, texres);
57236110 }
57246111 catch (Exception e)
57256112 {
57266113 System.err.println("FAILED: " + this);
5727
- failed = true;
6114
+ failedPigment = true;
6115
+ }
6116
+
6117
+ try
6118
+ {
6119
+ display.BindBumpTexture(tex, texres);
6120
+ }
6121
+ catch (Exception e)
6122
+ {
6123
+ //System.err.println("FAILED: " + this);
6124
+ failedBump = true;
57286125 }
57296126
57306127 if (!compiled)
....@@ -5747,8 +6144,11 @@
57476144 }
57486145 }
57496146
5750
- if (!failed)
5751
- display.ReleaseTextures(tex);
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
57526152
57536153 display.PopMaterial(this, selected);
57546154 }
....@@ -6121,6 +6521,11 @@
61216521 // dec 2012
61226522 new Exception().printStackTrace();
61236523 return;
6524
+ }
6525
+
6526
+ if (dontselect)
6527
+ {
6528
+ //bRep.GenerateNormalsMINE();
61246529 }
61256530
61266531 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6906,20 +7311,23 @@
69067311 }
69077312 }
69087313
6909
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
69107318 {
6911
- int hc = info.bounds.x + info.bounds.width / 2;
6912
- int vc = info.bounds.y + info.bounds.height / 2;
6913
- double[][] toscreen = info.toScreen;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
69147322 if (toscreen == null)
69157323 {
6916
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69177325 }
69187326 cVector vec = in;
69197327 LA.xformPos(in, toscreen, in);
69207328 //System.out.println("Distance = " + info.camera.Distance());
6921
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6922
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
69237331 outPt.x = hc + (int) vec.x;
69247332 outPt.y = vc - (int) vec.y;
69257333 outRec.x = outPt.x - 3;
....@@ -6927,15 +7335,18 @@
69277335 outRec.width = outRec.height = 6;
69287336 }
69297337
6930
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
69317340 {
69327341 Point pt = new Point(0, 0);
69337342 Rectangle rec = new Rectangle();
6934
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
69357345 return rec;
69367346 }
69377347
6938
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
69397350 {
69407351 if (level == 0)
69417352 {
....@@ -6944,16 +7355,19 @@
69447355 {
69457356 cVector origin = new cVector();
69467357 //LA.xformPos(origin, toParent, origin);
6947
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
69487362 Rectangle boundary = new Rectangle();
69497363 boundary.x = spot.x - 30;
69507364 boundary.y = spot.y - 30;
69517365 boundary.width = spot.width + 60;
69527366 boundary.height = spot.height + 60;
6953
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
69547368 int spotw = spot.x + spot.width;
69557369 int spoth = spot.y + spot.height;
6956
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69577371 // if (CameraPane.Xmin > spot.x)
69587372 // {
69597373 // CameraPane.Xmin = spot.x;
....@@ -6973,8 +7387,8 @@
69737387 spot.translate(32, 32);
69747388 spotw = spot.x + spot.width;
69757389 spoth = spot.y + spot.height;
6976
- info.g.setColor(Color.blue);
6977
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69787392 // if (CameraPane.Xmin > spot.x)
69797393 // {
69807394 // CameraPane.Xmin = spot.x;
....@@ -6991,11 +7405,12 @@
69917405 // {
69927406 // CameraPane.Ymax = spoth;
69937407 // }
6994
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7408
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7409
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69967410 spot.translate(0, -32);
6997
- info.g.setColor(Color.green);
6998
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
69997414 // if (CameraPane.Xmin > spot.x)
70007415 // {
70017416 // CameraPane.Xmin = spot.x;
....@@ -7012,8 +7427,8 @@
70127427 // {
70137428 // CameraPane.Ymax = spoth;
70147429 // }
7015
- info.g.drawArc(boundary.x, boundary.y,
7016
- boundary.width, boundary.height, 0, 360);
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
70177432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70187433 // if (CameraPane.Xmin > boundary.x)
70197434 // {
....@@ -7035,7 +7450,8 @@
70357450 }
70367451 }
70377452
7038
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
70397455 {
70407456 if (level == 0)
70417457 {
....@@ -7044,8 +7460,8 @@
70447460
70457461 boolean retval = false;
70467462
7047
- startX = info.x;
7048
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
70497465
70507466 hitSomething = -1;
70517467 cVector origin = new cVector();
....@@ -7055,22 +7471,51 @@
70557471 {
70567472 centerPt = new Point(0, 0);
70577473 }
7058
- calcHotSpot(origin, info, centerPt, spot);
7059
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
70607477 {
70617478 hitSomething = hitCenter;
70627479 retval = true;
70637480 }
70647481 spot.translate(32, 0);
7065
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
70667483 {
70677484 hitSomething = hitRotate;
70687485 retval = true;
70697486 }
70707487 spot.translate(0, 32);
7071
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
70727489 {
70737490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
70747519 retval = true;
70757520 }
70767521
....@@ -7080,7 +7525,7 @@
70807525 }
70817526
70827527 //System.out.println("info.modifiers = " + info.modifiers);
7083
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
70847529 //System.out.println("modified = " + modified);
70857530 //new Exception().printStackTrace();
70867531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7108,7 +7553,8 @@
71087553 return true;
71097554 }
71107555
7111
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
71127558 {
71137559 if (hitSomething == 0)
71147560 {
....@@ -7122,7 +7568,7 @@
71227568
71237569 //System.out.println("hitSomething = " + hitSomething);
71247570
7125
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
71267572
71277573 cVector xlate = new cVector();
71287574 //cVector xlate2 = new cVector();
....@@ -7156,8 +7602,8 @@
71567602 toParent[3][i] = xlate.get(i);
71577603 LA.matInvert(toParent, fromParent);
71587604 */
7159
- cVector delta = LA.newVector(0, 0, startY - info.y);
7160
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71617607
71627608 LA.matCopy(startMat, toParent);
71637609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7166,7 +7612,7 @@
71667612 } else
71677613 {
71687614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7169
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
71707616 cVector away = new cVector();
71717617 //cVector right2 = new cVector();
71727618 //LA.vecCross(up, cVector.Z, right);
....@@ -7183,19 +7629,19 @@
71837629 LA.xformDir(up, ClickInfo.matbuffer, up);
71847630 // if (!CameraPane.LOCALTRANSFORM)
71857631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7186
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
71877633 // if (!CameraPane.LOCALTRANSFORM)
71887634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
71897635 //LA.vecCross(up, cVector.Z, right2);
71907636
7191
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
71927638
71937639 //System.out.println("DELTA0 = " + delta);
71947640 //System.out.println("AWAY = " + info.camera.away);
71957641 //System.out.println("UP = " + info.camera.up);
71967642 if (away.z > 0)
71977643 {
7198
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
71997645 {
72007646 delta.x = -delta.x;
72017647 } else
....@@ -7210,7 +7656,7 @@
72107656 //System.out.println("DELTA1 = " + delta);
72117657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72127658 //System.out.println("DELTA2 = " + delta);
7213
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72147660 LA.matCopy(startMat, toParent);
72157661 //System.out.println("DELTA3 = " + delta);
72167662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7220,8 +7666,8 @@
72207666 break;
72217667
72227668 case hitRotate: // rotate
7223
- int dx = info.x - centerPt.x;
7224
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
72257671 double angle = (double) Math.atan2(dx, dy);
72267672 angle = -(1.570796 - angle);
72277673
....@@ -7244,7 +7690,7 @@
72447690 }
72457691 /**/
72467692
7247
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
72487694 {
72497695 case 1: // '\001'
72507696 LA.matZRotate(toParent, angle);
....@@ -7271,7 +7717,7 @@
72717717 break;
72727718
72737719 case hitScale: // scale
7274
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
72757721 double sign = 1;
72767722 if (hScale < 0)
72777723 {
....@@ -7283,7 +7729,7 @@
72837729 //hScale = 0.01;
72847730 }
72857731
7286
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
72877733 sign = 1;
72887734 if (vScale < 0)
72897735 {
....@@ -7294,6 +7740,7 @@
72947740 {
72957741 //vScale = 0.01;
72967742 }
7743
+
72977744 LA.matCopy(startMat, toParent);
72987745 /**/
72997746 for (int i = 0; i < 3; i++)
....@@ -7303,29 +7750,30 @@
73037750 }
73047751 /**/
73057752
7306
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73077754
73087755 if (totalScale < 0.01)
73097756 {
73107757 totalScale = 0.01;
73117758 }
73127759
7313
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
73147761 {
73157762 case 3: // '\001'
7316
- if (modified)
7763
+ if (modified || opposite)
73177764 {
73187765 //LA.matScale(toParent, 1, hScale, vScale);
73197766 LA.matScale(toParent, totalScale, 1, 1);
73207767 } // vScale, 1);
73217768 else
73227769 {
7770
+ // EXCEPTION!
73237771 LA.matScale(toParent, totalScale, totalScale, totalScale);
73247772 } // vScale, 1);
73257773 break;
73267774
73277775 case 2: // '\002'
7328
- if (modified)
7776
+ if (modified || opposite)
73297777 {
73307778 //LA.matScale(toParent, hScale, 1, vScale);
73317779 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7336,7 +7784,7 @@
73367784 break;
73377785
73387786 case 1: // '\003'
7339
- if (modified)
7787
+ if (modified || opposite)
73407788 {
73417789 //LA.matScale(toParent, hScale, vScale, 1);
73427790 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7376,7 +7824,7 @@
73767824 } // NEW ...
73777825
73787826
7379
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
73807828 }
73817829
73827830 boolean overflow = false;
....@@ -7556,6 +8004,10 @@
75568004 editWindow = null;
75578005 } // ?
75588006 }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
8010
+ }
75598011 }
75608012
75618013 boolean root; // patch for edit windows
....@@ -7567,7 +8019,7 @@
75678019 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75688020
75698021 Object3D /*Composite*/ parent;
7570
- Object3D /*Composite*/ fileparent;
8022
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75718023
75728024 double[][] toParent; // dynamic matrix
75738025 double[][] fromParent;
....@@ -7713,6 +8165,10 @@
77138165 }
77148166
77158167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
77168172 transient ObjectUI objectUI;
77178173 public static int povDepth = 0;
77188174 private static cVector tbMin = new cVector();