Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
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,117 +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
-}
165
-
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
169
- return;
170
-
171
- Object3D o = new Object3D();
172
- o.bRep = this.bRep;
173
- if (this.bRep != null)
174
- {
175
- o.transientrep = this.bRep.support;
176
- o.bRep.support = null;
177
- }
178
-
179
-// o.support = this.support;
180
-// o.fileparent = this.fileparent;
181
-// if (this.bRep != null)
182
-// o.bRep = this.bRep.support;
183
-
184
- hashtable.put(GetUUID(), o);
185
-
186
- this.bRep = null;
187
-// if (this.bRep != null)
188
-// this.bRep.support = null;
189
-// this.support = null;
190
-// this.fileparent = null;
191
-
192
- for (int i=0; i<Size(); i++)
193
- {
194
- get(i).ExtractBigData(hashtable);
195
- }
196
-}
197
-
198
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
199
-{
200
- if (!hashtable.containsKey(GetUUID()))
201
- return;
202
-
203
- Object3D o = hashtable.get(GetUUID());
204
-
205
- this.bRep = o.bRep;
206
- if (this.bRep != null)
207
- this.bRep.support = o.transientrep;
208
-// this.support = o.support;
209
-// this.fileparent = o.fileparent;
210
-
211
- hashtable.remove(GetUUID());
212
-
213
- for (int i=0; i<Size(); i++)
214
- {
215
- get(i).RestoreBigData(hashtable);
216
- }
217
-}
218287
219288 // MOCAP SUPPORT
220289 double tx,ty,tz,rx,ry,rz;
....@@ -357,6 +426,7 @@
357426 }
358427
359428 boolean live = false;
429
+ transient boolean keepdontselect;
360430 boolean dontselect = false;
361431 boolean hide = false;
362432 boolean link2master = false; // performs reset support/master at each frame
....@@ -539,12 +609,14 @@
539609 toParent = LA.newMatrix();
540610 fromParent = LA.newMatrix();
541611 }
612
+
542613 if (toParentMarked == null)
543614 {
544615 if (maxcount != 1)
545616 {
546617 new Exception().printStackTrace();
547618 }
619
+
548620 toParentMarked = LA.newMatrix();
549621 fromParentMarked = LA.newMatrix();
550622 }
....@@ -855,7 +927,7 @@
855927
856928 if (marked && Globals.isLIVE() && live &&
857929 //TEMP21aug2018
858
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
859931 currentframe != Globals.framecount)
860932 {
861933 currentframe = Globals.framecount;
....@@ -867,7 +939,8 @@
867939
868940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
869941
870
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
871944 {
872945 countdown = 1;
873946 delay = speedup?8:1;
....@@ -939,6 +1012,7 @@
9391012 if (material == null || material.multiply)
9401013 return true;
9411014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9421016 return material.opacity > 0.99;
9431017 }
9441018
....@@ -1339,6 +1413,7 @@
13391413 toParent = LA.newMatrix();
13401414 fromParent = LA.newMatrix();
13411415 }
1416
+
13421417 LA.matCopy(other.toParent, toParent);
13431418 LA.matCopy(other.fromParent, fromParent);
13441419
....@@ -2360,6 +2435,10 @@
23602435 }
23612436 */
23622437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23632442 }
23642443
23652444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2401,6 +2480,14 @@
24012480 {
24022481 editWindow.refreshContents();
24032482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24042491 //if (parent != null)
24052492 //parent.refreshEditWindow();
24062493 }
....@@ -2480,7 +2567,8 @@
24802567 private static final int editSelf = 1;
24812568 private static final int editChild = 2;
24822569
2483
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
24842572 {
24852573 if (level == 0)
24862574 {
....@@ -2488,7 +2576,8 @@
24882576 return;
24892577
24902578 Object3D selectee;
2491
- 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))
24922581 {
24932582 selectee = (Object3D) e.nextElement();
24942583 }
....@@ -2496,19 +2585,22 @@
24962585 } else
24972586 {
24982587 //super.
2499
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25002590 }
25012591 }
25022592
2503
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25042595 {
25052596 doSomething = 0;
25062597 if (level == 0)
25072598 {
2508
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25092600 }
25102601 if (//super.
2511
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25122604 {
25132605 doSomething = 1;
25142606 return true;
....@@ -2518,7 +2610,7 @@
25182610 }
25192611 }
25202612
2521
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
25222614 {
25232615 if (selection == null)
25242616 {
....@@ -2531,7 +2623,8 @@
25312623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25322624 {
25332625 Object3D selectee = (Object3D) e.nextElement();
2534
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
25352628 {
25362629 childToDrag = selectee;
25372630 doSomething = 2;
....@@ -2543,13 +2636,15 @@
25432636 return retval;
25442637 }
25452638
2546
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
25472641 {
25482642 switch (doSomething)
25492643 {
25502644 case 1: // '\001'
25512645 //super.
2552
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
25532648 break;
25542649
25552650 case 2: // '\002'
....@@ -2562,11 +2657,13 @@
25622657 {
25632658 //sel.hitSomething = childToDrag.hitSomething;
25642659 //childToDrag.doEditDrag(info);
2565
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
25662662 } else
25672663 {
25682664 //super.
2569
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25702667 }
25712668 }
25722669 break;
....@@ -2584,6 +2681,9 @@
25842681 {
25852682 deselectAll();
25862683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
25872687 ClickInfo newInfo = new ClickInfo();
25882688 newInfo.flags = info.flags;
25892689 newInfo.bounds = info.bounds;
....@@ -2676,6 +2776,18 @@
26762776 void GenNormalsS(boolean crease)
26772777 {
26782778 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();
26792791 // for (int i=0; i<selection.size(); i++)
26802792 // {
26812793 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2816,6 +2928,24 @@
28162928 if (child == null)
28172929 continue;
28182930 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();
28192949 // Children().release(i);
28202950 }
28212951 blockloop = false;
....@@ -2988,11 +3118,20 @@
29883118 }
29893119 }
29903120
3121
+ void GenNormalsMesh0()
3122
+ {
3123
+ if (bRep != null)
3124
+ {
3125
+ bRep.GenerateNormalsMesh();
3126
+ Touch();
3127
+ }
3128
+ }
3129
+
29913130 void GenNormalsMINE0()
29923131 {
29933132 if (bRep != null)
29943133 {
2995
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29963135 Touch();
29973136 }
29983137 }
....@@ -3438,7 +3577,8 @@
34383577 if (blockloop)
34393578 return;
34403579
3441
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
34423582 live = h;
34433583
34443584 for (int i = 0; i < Size(); i++)
....@@ -3459,7 +3599,8 @@
34593599 return;
34603600
34613601 //if (bRep != null)
3462
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
34633604 link2master = h;
34643605
34653606 for (int i = 0; i < Size(); i++)
....@@ -3479,7 +3620,8 @@
34793620 if (blockloop)
34803621 return;
34813622
3482
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
34833625 hide = h;
34843626
34853627 for (int i = 0; i < Size(); i++)
....@@ -3499,7 +3641,7 @@
34993641 if (blockloop)
35003642 return;
35013643
3502
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
35033645 marked = h;
35043646
35053647 for (int i = 0; i < Size(); i++)
....@@ -3509,6 +3651,46 @@
35093651 continue;
35103652 blockloop = true;
35113653 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);
35123694 blockloop = false;
35133695 // release(i);
35143696 }
....@@ -4286,6 +4468,55 @@
42864468 }
42874469 }
42884470
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
+
42894520 void RepairTexture()
42904521 {
42914522 if (this instanceof FileObject || blockloop)
....@@ -4800,6 +5031,14 @@
48005031 }
48015032 }
48025033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
48035042 cTreePath Select(int indexcount, boolean deselect)
48045043 {
48055044 if (hide || dontselect)
....@@ -4836,10 +5075,11 @@
48365075 if (leaf != null)
48375076 {
48385077 cTreePath tp = new cTreePath(this, leaf);
4839
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
48405080 {
48415081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4842
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
48435083 }
48445084
48455085 return tp;
....@@ -4856,6 +5096,7 @@
48565096
48575097 if (child == null)
48585098 continue;
5099
+
48595100 if (child.HasTransparency() && child.size() != 0)
48605101 {
48615102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4865,9 +5106,10 @@
48655106 if (leaf != null)
48665107 {
48675108 cTreePath tp = new cTreePath(this, leaf);
4868
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
48695111 {
4870
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
48715113 }
48725114
48735115 return tp;
....@@ -5192,6 +5434,51 @@
51925434 blockloop = false;
51935435 }
51945436
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
+
51955482 boolean IsSelected()
51965483 {
51975484 if (parent == null)
....@@ -5501,6 +5788,38 @@
55015788 }
55025789 }
55035790
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
+
55045823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55055824 {
55065825 Draw(display, root, selected, blocked);
....@@ -5509,12 +5828,23 @@
55095828 boolean NeedSupport()
55105829 {
55115830 return
5512
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55135832 // PROBLEM with CROWD!!
55145833 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55155834 }
55165835
55175836 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
+ }
55185848
55195849 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55205850 {
....@@ -5577,7 +5907,7 @@
55775907 support = support;
55785908
55795909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5580
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
55815911
55825912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55835913 {
....@@ -5597,10 +5927,12 @@
55975927 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55985928
55995929 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5600
- (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)))
56015932 {
56025933 Globals.lighttouched = true;
56035934 } // all panes...
5935
+
56045936 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56055937 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56065938 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5728,6 +6060,7 @@
57286060 if (GetBRep() != null)
57296061 {
57306062 display.NextIndex();
6063
+
57316064 // vertex color conflict : gl.glCallList(list);
57326065 DrawNode(display, root, selected);
57336066 if (this instanceof BezierPatch)
....@@ -5768,16 +6101,27 @@
57686101 tex = GetTextures();
57696102 }
57706103
5771
- boolean failed = false;
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
57726106
57736107 try
57746108 {
5775
- display.BindTextures(tex, texres);
6109
+ display.BindPigmentTexture(tex, texres);
57766110 }
57776111 catch (Exception e)
57786112 {
57796113 System.err.println("FAILED: " + this);
5780
- 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;
57816125 }
57826126
57836127 if (!compiled)
....@@ -5800,8 +6144,11 @@
58006144 }
58016145 }
58026146
5803
- if (!failed)
5804
- display.ReleaseTextures(tex);
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
58056152
58066153 display.PopMaterial(this, selected);
58076154 }
....@@ -6174,6 +6521,11 @@
61746521 // dec 2012
61756522 new Exception().printStackTrace();
61766523 return;
6524
+ }
6525
+
6526
+ if (dontselect)
6527
+ {
6528
+ //bRep.GenerateNormalsMINE();
61776529 }
61786530
61796531 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6959,20 +7311,23 @@
69597311 }
69607312 }
69617313
6962
- 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)
69637318 {
6964
- int hc = info.bounds.x + info.bounds.width / 2;
6965
- int vc = info.bounds.y + info.bounds.height / 2;
6966
- 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;
69677322 if (toscreen == null)
69687323 {
6969
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69707325 }
69717326 cVector vec = in;
69727327 LA.xformPos(in, toscreen, in);
69737328 //System.out.println("Distance = " + info.camera.Distance());
6974
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6975
- 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();
69767331 outPt.x = hc + (int) vec.x;
69777332 outPt.y = vc - (int) vec.y;
69787333 outRec.x = outPt.x - 3;
....@@ -6980,15 +7335,18 @@
69807335 outRec.width = outRec.height = 6;
69817336 }
69827337
6983
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
69847340 {
69857341 Point pt = new Point(0, 0);
69867342 Rectangle rec = new Rectangle();
6987
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
69887345 return rec;
69897346 }
69907347
6991
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
69927350 {
69937351 if (level == 0)
69947352 {
....@@ -6997,16 +7355,19 @@
69977355 {
69987356 cVector origin = new cVector();
69997357 //LA.xformPos(origin, toParent, origin);
7000
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70017362 Rectangle boundary = new Rectangle();
70027363 boundary.x = spot.x - 30;
70037364 boundary.y = spot.y - 30;
70047365 boundary.width = spot.width + 60;
70057366 boundary.height = spot.height + 60;
7006
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
70077368 int spotw = spot.x + spot.width;
70087369 int spoth = spot.y + spot.height;
7009
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70107371 // if (CameraPane.Xmin > spot.x)
70117372 // {
70127373 // CameraPane.Xmin = spot.x;
....@@ -7026,8 +7387,8 @@
70267387 spot.translate(32, 32);
70277388 spotw = spot.x + spot.width;
70287389 spoth = spot.y + spot.height;
7029
- info.g.setColor(Color.blue);
7030
- 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);
70317392 // if (CameraPane.Xmin > spot.x)
70327393 // {
70337394 // CameraPane.Xmin = spot.x;
....@@ -7044,11 +7405,12 @@
70447405 // {
70457406 // CameraPane.Ymax = spoth;
70467407 // }
7047
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7048
- //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
70497410 spot.translate(0, -32);
7050
- info.g.setColor(Color.green);
7051
- 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);
70527414 // if (CameraPane.Xmin > spot.x)
70537415 // {
70547416 // CameraPane.Xmin = spot.x;
....@@ -7065,8 +7427,8 @@
70657427 // {
70667428 // CameraPane.Ymax = spoth;
70677429 // }
7068
- info.g.drawArc(boundary.x, boundary.y,
7069
- 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);
70707432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70717433 // if (CameraPane.Xmin > boundary.x)
70727434 // {
....@@ -7088,7 +7450,8 @@
70887450 }
70897451 }
70907452
7091
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
70927455 {
70937456 if (level == 0)
70947457 {
....@@ -7097,8 +7460,8 @@
70977460
70987461 boolean retval = false;
70997462
7100
- startX = info.x;
7101
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
71027465
71037466 hitSomething = -1;
71047467 cVector origin = new cVector();
....@@ -7108,22 +7471,51 @@
71087471 {
71097472 centerPt = new Point(0, 0);
71107473 }
7111
- calcHotSpot(origin, info, centerPt, spot);
7112
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
71137477 {
71147478 hitSomething = hitCenter;
71157479 retval = true;
71167480 }
71177481 spot.translate(32, 0);
7118
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
71197483 {
71207484 hitSomething = hitRotate;
71217485 retval = true;
71227486 }
71237487 spot.translate(0, 32);
7124
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
71257489 {
71267490 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
+
71277519 retval = true;
71287520 }
71297521
....@@ -7133,7 +7525,7 @@
71337525 }
71347526
71357527 //System.out.println("info.modifiers = " + info.modifiers);
7136
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71377529 //System.out.println("modified = " + modified);
71387530 //new Exception().printStackTrace();
71397531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7161,7 +7553,8 @@
71617553 return true;
71627554 }
71637555
7164
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
71657558 {
71667559 if (hitSomething == 0)
71677560 {
....@@ -7175,7 +7568,7 @@
71757568
71767569 //System.out.println("hitSomething = " + hitSomething);
71777570
7178
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
71797572
71807573 cVector xlate = new cVector();
71817574 //cVector xlate2 = new cVector();
....@@ -7209,8 +7602,8 @@
72097602 toParent[3][i] = xlate.get(i);
72107603 LA.matInvert(toParent, fromParent);
72117604 */
7212
- cVector delta = LA.newVector(0, 0, startY - info.y);
7213
- 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);
72147607
72157608 LA.matCopy(startMat, toParent);
72167609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7219,7 +7612,7 @@
72197612 } else
72207613 {
72217614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7222
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
72237616 cVector away = new cVector();
72247617 //cVector right2 = new cVector();
72257618 //LA.vecCross(up, cVector.Z, right);
....@@ -7236,19 +7629,19 @@
72367629 LA.xformDir(up, ClickInfo.matbuffer, up);
72377630 // if (!CameraPane.LOCALTRANSFORM)
72387631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7239
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72407633 // if (!CameraPane.LOCALTRANSFORM)
72417634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72427635 //LA.vecCross(up, cVector.Z, right2);
72437636
7244
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72457638
72467639 //System.out.println("DELTA0 = " + delta);
72477640 //System.out.println("AWAY = " + info.camera.away);
72487641 //System.out.println("UP = " + info.camera.up);
72497642 if (away.z > 0)
72507643 {
7251
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72527645 {
72537646 delta.x = -delta.x;
72547647 } else
....@@ -7263,7 +7656,7 @@
72637656 //System.out.println("DELTA1 = " + delta);
72647657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72657658 //System.out.println("DELTA2 = " + delta);
7266
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72677660 LA.matCopy(startMat, toParent);
72687661 //System.out.println("DELTA3 = " + delta);
72697662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7273,8 +7666,8 @@
72737666 break;
72747667
72757668 case hitRotate: // rotate
7276
- int dx = info.x - centerPt.x;
7277
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
72787671 double angle = (double) Math.atan2(dx, dy);
72797672 angle = -(1.570796 - angle);
72807673
....@@ -7297,7 +7690,7 @@
72977690 }
72987691 /**/
72997692
7300
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
73017694 {
73027695 case 1: // '\001'
73037696 LA.matZRotate(toParent, angle);
....@@ -7324,7 +7717,7 @@
73247717 break;
73257718
73267719 case hitScale: // scale
7327
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
73287721 double sign = 1;
73297722 if (hScale < 0)
73307723 {
....@@ -7336,7 +7729,7 @@
73367729 //hScale = 0.01;
73377730 }
73387731
7339
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
73407733 sign = 1;
73417734 if (vScale < 0)
73427735 {
....@@ -7347,6 +7740,7 @@
73477740 {
73487741 //vScale = 0.01;
73497742 }
7743
+
73507744 LA.matCopy(startMat, toParent);
73517745 /**/
73527746 for (int i = 0; i < 3; i++)
....@@ -7356,29 +7750,30 @@
73567750 }
73577751 /**/
73587752
7359
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73607754
73617755 if (totalScale < 0.01)
73627756 {
73637757 totalScale = 0.01;
73647758 }
73657759
7366
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
73677761 {
73687762 case 3: // '\001'
7369
- if (modified)
7763
+ if (modified || opposite)
73707764 {
73717765 //LA.matScale(toParent, 1, hScale, vScale);
73727766 LA.matScale(toParent, totalScale, 1, 1);
73737767 } // vScale, 1);
73747768 else
73757769 {
7770
+ // EXCEPTION!
73767771 LA.matScale(toParent, totalScale, totalScale, totalScale);
73777772 } // vScale, 1);
73787773 break;
73797774
73807775 case 2: // '\002'
7381
- if (modified)
7776
+ if (modified || opposite)
73827777 {
73837778 //LA.matScale(toParent, hScale, 1, vScale);
73847779 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7389,7 +7784,7 @@
73897784 break;
73907785
73917786 case 1: // '\003'
7392
- if (modified)
7787
+ if (modified || opposite)
73937788 {
73947789 //LA.matScale(toParent, hScale, vScale, 1);
73957790 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7429,7 +7824,7 @@
74297824 } // NEW ...
74307825
74317826
7432
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
74337828 }
74347829
74357830 boolean overflow = false;
....@@ -7609,6 +8004,10 @@
76098004 editWindow = null;
76108005 } // ?
76118006 }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
8010
+ }
76128011 }
76138012
76148013 boolean root; // patch for edit windows
....@@ -7766,6 +8165,10 @@
77668165 }
77678166
77688167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
77698172 transient ObjectUI objectUI;
77708173 public static int povDepth = 0;
77718174 private static cVector tbMin = new cVector();