Normand Briere
2019-07-24 f555e2cacc4470c5b2217a14d40d2b39c4a57ba2
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,125 +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++)
130
- {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
134
- blockloop = true;
135
- child.SaveSupports();
136
- blockloop = false;
137
- }
138
-}
139147
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
148
+ void RestoreSupports()
149
+ {
150
+ if (blockloop)
151
+ return;
144152
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
151
- {
152
- bRep.RestoreSupports();
153
- }
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
-}
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
165157
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
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)
169175 {
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
+
170251 Object3D o = hashtable.get(GetUUID());
171252
172
- assert(this.bRep == o.bRep);
173
- if (this.bRep != null)
174
- assert(this.bRep.support == o.transientrep);
175
-
176
- return;
177
- }
178
-
179
- Object3D o = new Object3D();
180
- o.bRep = this.bRep;
181
- if (this.bRep != null)
182
- {
183
- o.transientrep = this.bRep.support;
184
- o.bRep.support = null;
185
- }
186
-
187
-// o.support = this.support;
188
-// o.fileparent = this.fileparent;
189
-// if (this.bRep != null)
190
-// o.bRep = this.bRep.support;
191
-
192
- hashtable.put(GetUUID(), o);
193
-
194
- this.bRep = null;
195
-// if (this.bRep != null)
196
-// this.bRep.support = null;
197
-// this.support = null;
198
-// this.fileparent = null;
199
-
200
- for (int i=0; i<Size(); i++)
201
- {
202
- get(i).ExtractBigData(hashtable);
203
- }
204
-}
253
+ RestoreBigData(o);
205254
206
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
207
-{
208
- if (!hashtable.containsKey(GetUUID()))
209
- return;
210
-
211
- Object3D o = hashtable.get(GetUUID());
212
-
213
- this.bRep = o.bRep;
214
- if (this.bRep != null)
215
- this.bRep.support = o.transientrep;
216
-// this.support = o.support;
217
-// this.fileparent = o.fileparent;
218
-
219
- hashtable.remove(GetUUID());
220
-
221
- for (int i=0; i<Size(); i++)
222
- {
223
- get(i).RestoreBigData(hashtable);
255
+ if (blockloop)
256
+ return;
257
+
258
+ blockloop = true;
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
267
+ blockloop = false;
224268 }
225
-}
269
+
270
+ void RestoreBigData(Object3D o)
271
+ {
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;
286
+ }
226287
227288 // MOCAP SUPPORT
228289 double tx,ty,tz,rx,ry,rz;
....@@ -365,6 +426,7 @@
365426 }
366427
367428 boolean live = false;
429
+ transient boolean keepdontselect;
368430 boolean dontselect = false;
369431 boolean hide = false;
370432 boolean link2master = false; // performs reset support/master at each frame
....@@ -547,12 +609,14 @@
547609 toParent = LA.newMatrix();
548610 fromParent = LA.newMatrix();
549611 }
612
+
550613 if (toParentMarked == null)
551614 {
552615 if (maxcount != 1)
553616 {
554617 new Exception().printStackTrace();
555618 }
619
+
556620 toParentMarked = LA.newMatrix();
557621 fromParentMarked = LA.newMatrix();
558622 }
....@@ -863,7 +927,7 @@
863927
864928 if (marked && Globals.isLIVE() && live &&
865929 //TEMP21aug2018
866
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
867931 currentframe != Globals.framecount)
868932 {
869933 currentframe = Globals.framecount;
....@@ -875,7 +939,8 @@
875939
876940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
877941
878
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
879944 {
880945 countdown = 1;
881946 delay = speedup?8:1;
....@@ -947,6 +1012,7 @@
9471012 if (material == null || material.multiply)
9481013 return true;
9491014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9501016 return material.opacity > 0.99;
9511017 }
9521018
....@@ -1347,6 +1413,7 @@
13471413 toParent = LA.newMatrix();
13481414 fromParent = LA.newMatrix();
13491415 }
1416
+
13501417 LA.matCopy(other.toParent, toParent);
13511418 LA.matCopy(other.fromParent, fromParent);
13521419
....@@ -2368,6 +2435,10 @@
23682435 }
23692436 */
23702437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23712442 }
23722443
23732444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2409,6 +2480,14 @@
24092480 {
24102481 editWindow.refreshContents();
24112482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24122491 //if (parent != null)
24132492 //parent.refreshEditWindow();
24142493 }
....@@ -2488,7 +2567,8 @@
24882567 private static final int editSelf = 1;
24892568 private static final int editChild = 2;
24902569
2491
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
24922572 {
24932573 if (level == 0)
24942574 {
....@@ -2496,7 +2576,8 @@
24962576 return;
24972577
24982578 Object3D selectee;
2499
- 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))
25002581 {
25012582 selectee = (Object3D) e.nextElement();
25022583 }
....@@ -2504,19 +2585,22 @@
25042585 } else
25052586 {
25062587 //super.
2507
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25082590 }
25092591 }
25102592
2511
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25122595 {
25132596 doSomething = 0;
25142597 if (level == 0)
25152598 {
2516
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25172600 }
25182601 if (//super.
2519
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25202604 {
25212605 doSomething = 1;
25222606 return true;
....@@ -2526,7 +2610,7 @@
25262610 }
25272611 }
25282612
2529
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
25302614 {
25312615 if (selection == null)
25322616 {
....@@ -2539,7 +2623,8 @@
25392623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25402624 {
25412625 Object3D selectee = (Object3D) e.nextElement();
2542
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
25432628 {
25442629 childToDrag = selectee;
25452630 doSomething = 2;
....@@ -2551,13 +2636,15 @@
25512636 return retval;
25522637 }
25532638
2554
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
25552641 {
25562642 switch (doSomething)
25572643 {
25582644 case 1: // '\001'
25592645 //super.
2560
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
25612648 break;
25622649
25632650 case 2: // '\002'
....@@ -2570,11 +2657,13 @@
25702657 {
25712658 //sel.hitSomething = childToDrag.hitSomething;
25722659 //childToDrag.doEditDrag(info);
2573
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
25742662 } else
25752663 {
25762664 //super.
2577
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
25782667 }
25792668 }
25802669 break;
....@@ -2592,6 +2681,9 @@
25922681 {
25932682 deselectAll();
25942683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
25952687 ClickInfo newInfo = new ClickInfo();
25962688 newInfo.flags = info.flags;
25972689 newInfo.bounds = info.bounds;
....@@ -2684,6 +2776,18 @@
26842776 void GenNormalsS(boolean crease)
26852777 {
26862778 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();
26872791 // for (int i=0; i<selection.size(); i++)
26882792 // {
26892793 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2824,6 +2928,24 @@
28242928 if (child == null)
28252929 continue;
28262930 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();
28272949 // Children().release(i);
28282950 }
28292951 blockloop = false;
....@@ -2996,11 +3118,20 @@
29963118 }
29973119 }
29983120
3121
+ void GenNormalsMesh0()
3122
+ {
3123
+ if (bRep != null)
3124
+ {
3125
+ bRep.GenerateNormalsMesh();
3126
+ Touch();
3127
+ }
3128
+ }
3129
+
29993130 void GenNormalsMINE0()
30003131 {
30013132 if (bRep != null)
30023133 {
3003
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30043135 Touch();
30053136 }
30063137 }
....@@ -3446,7 +3577,8 @@
34463577 if (blockloop)
34473578 return;
34483579
3449
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
34503582 live = h;
34513583
34523584 for (int i = 0; i < Size(); i++)
....@@ -3467,7 +3599,8 @@
34673599 return;
34683600
34693601 //if (bRep != null)
3470
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
34713604 link2master = h;
34723605
34733606 for (int i = 0; i < Size(); i++)
....@@ -3487,7 +3620,8 @@
34873620 if (blockloop)
34883621 return;
34893622
3490
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
34913625 hide = h;
34923626
34933627 for (int i = 0; i < Size(); i++)
....@@ -3507,7 +3641,7 @@
35073641 if (blockloop)
35083642 return;
35093643
3510
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
35113645 marked = h;
35123646
35133647 for (int i = 0; i < Size(); i++)
....@@ -3517,6 +3651,46 @@
35173651 continue;
35183652 blockloop = true;
35193653 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);
35203694 blockloop = false;
35213695 // release(i);
35223696 }
....@@ -4294,6 +4468,55 @@
42944468 }
42954469 }
42964470
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
+
42974520 void RepairTexture()
42984521 {
42994522 if (this instanceof FileObject || blockloop)
....@@ -4808,6 +5031,14 @@
48085031 }
48095032 }
48105033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
48115042 cTreePath Select(int indexcount, boolean deselect)
48125043 {
48135044 if (hide || dontselect)
....@@ -4844,10 +5075,11 @@
48445075 if (leaf != null)
48455076 {
48465077 cTreePath tp = new cTreePath(this, leaf);
4847
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
48485080 {
48495081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4850
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
48515083 }
48525084
48535085 return tp;
....@@ -4864,6 +5096,7 @@
48645096
48655097 if (child == null)
48665098 continue;
5099
+
48675100 if (child.HasTransparency() && child.size() != 0)
48685101 {
48695102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4873,9 +5106,10 @@
48735106 if (leaf != null)
48745107 {
48755108 cTreePath tp = new cTreePath(this, leaf);
4876
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
48775111 {
4878
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
48795113 }
48805114
48815115 return tp;
....@@ -5200,6 +5434,51 @@
52005434 blockloop = false;
52015435 }
52025436
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
+
52035482 boolean IsSelected()
52045483 {
52055484 if (parent == null)
....@@ -5509,6 +5788,38 @@
55095788 }
55105789 }
55115790
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
+
55125823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55135824 {
55145825 Draw(display, root, selected, blocked);
....@@ -5517,12 +5828,23 @@
55175828 boolean NeedSupport()
55185829 {
55195830 return
5520
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55215832 // PROBLEM with CROWD!!
55225833 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55235834 }
55245835
55255836 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
+ }
55265848
55275849 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55285850 {
....@@ -5585,7 +5907,7 @@
55855907 support = support;
55865908
55875909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5588
- 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);
55895911
55905912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55915913 {
....@@ -5605,10 +5927,12 @@
56055927 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56065928
56075929 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5608
- (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)))
56095932 {
56105933 Globals.lighttouched = true;
56115934 } // all panes...
5935
+
56125936 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56135937 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56145938 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5736,6 +6060,7 @@
57366060 if (GetBRep() != null)
57376061 {
57386062 display.NextIndex();
6063
+
57396064 // vertex color conflict : gl.glCallList(list);
57406065 DrawNode(display, root, selected);
57416066 if (this instanceof BezierPatch)
....@@ -5776,16 +6101,27 @@
57766101 tex = GetTextures();
57776102 }
57786103
5779
- boolean failed = false;
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
57806106
57816107 try
57826108 {
5783
- display.BindTextures(tex, texres);
6109
+ display.BindPigmentTexture(tex, texres);
57846110 }
57856111 catch (Exception e)
57866112 {
57876113 System.err.println("FAILED: " + this);
5788
- 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;
57896125 }
57906126
57916127 if (!compiled)
....@@ -5808,8 +6144,11 @@
58086144 }
58096145 }
58106146
5811
- if (!failed)
5812
- display.ReleaseTextures(tex);
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
58136152
58146153 display.PopMaterial(this, selected);
58156154 }
....@@ -6182,6 +6521,11 @@
61826521 // dec 2012
61836522 new Exception().printStackTrace();
61846523 return;
6524
+ }
6525
+
6526
+ if (dontselect)
6527
+ {
6528
+ //bRep.GenerateNormalsMINE();
61856529 }
61866530
61876531 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6967,20 +7311,23 @@
69677311 }
69687312 }
69697313
6970
- 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)
69717318 {
6972
- int hc = info.bounds.x + info.bounds.width / 2;
6973
- int vc = info.bounds.y + info.bounds.height / 2;
6974
- 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;
69757322 if (toscreen == null)
69767323 {
6977
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69787325 }
69797326 cVector vec = in;
69807327 LA.xformPos(in, toscreen, in);
69817328 //System.out.println("Distance = " + info.camera.Distance());
6982
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6983
- 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();
69847331 outPt.x = hc + (int) vec.x;
69857332 outPt.y = vc - (int) vec.y;
69867333 outRec.x = outPt.x - 3;
....@@ -6988,15 +7335,18 @@
69887335 outRec.width = outRec.height = 6;
69897336 }
69907337
6991
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
69927340 {
69937341 Point pt = new Point(0, 0);
69947342 Rectangle rec = new Rectangle();
6995
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
69967345 return rec;
69977346 }
69987347
6999
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
70007350 {
70017351 if (level == 0)
70027352 {
....@@ -7005,16 +7355,19 @@
70057355 {
70067356 cVector origin = new cVector();
70077357 //LA.xformPos(origin, toParent, origin);
7008
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70097362 Rectangle boundary = new Rectangle();
70107363 boundary.x = spot.x - 30;
70117364 boundary.y = spot.y - 30;
70127365 boundary.width = spot.width + 60;
70137366 boundary.height = spot.height + 60;
7014
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
70157368 int spotw = spot.x + spot.width;
70167369 int spoth = spot.y + spot.height;
7017
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187371 // if (CameraPane.Xmin > spot.x)
70197372 // {
70207373 // CameraPane.Xmin = spot.x;
....@@ -7034,8 +7387,8 @@
70347387 spot.translate(32, 32);
70357388 spotw = spot.x + spot.width;
70367389 spoth = spot.y + spot.height;
7037
- info.g.setColor(Color.blue);
7038
- 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);
70397392 // if (CameraPane.Xmin > spot.x)
70407393 // {
70417394 // CameraPane.Xmin = spot.x;
....@@ -7052,11 +7405,12 @@
70527405 // {
70537406 // CameraPane.Ymax = spoth;
70547407 // }
7055
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7056
- //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
70577410 spot.translate(0, -32);
7058
- info.g.setColor(Color.green);
7059
- 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);
70607414 // if (CameraPane.Xmin > spot.x)
70617415 // {
70627416 // CameraPane.Xmin = spot.x;
....@@ -7073,8 +7427,8 @@
70737427 // {
70747428 // CameraPane.Ymax = spoth;
70757429 // }
7076
- info.g.drawArc(boundary.x, boundary.y,
7077
- 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);
70787432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70797433 // if (CameraPane.Xmin > boundary.x)
70807434 // {
....@@ -7096,7 +7450,8 @@
70967450 }
70977451 }
70987452
7099
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
71007455 {
71017456 if (level == 0)
71027457 {
....@@ -7105,8 +7460,8 @@
71057460
71067461 boolean retval = false;
71077462
7108
- startX = info.x;
7109
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
71107465
71117466 hitSomething = -1;
71127467 cVector origin = new cVector();
....@@ -7116,22 +7471,51 @@
71167471 {
71177472 centerPt = new Point(0, 0);
71187473 }
7119
- calcHotSpot(origin, info, centerPt, spot);
7120
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
71217477 {
71227478 hitSomething = hitCenter;
71237479 retval = true;
71247480 }
71257481 spot.translate(32, 0);
7126
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
71277483 {
71287484 hitSomething = hitRotate;
71297485 retval = true;
71307486 }
71317487 spot.translate(0, 32);
7132
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
71337489 {
71347490 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
+
71357519 retval = true;
71367520 }
71377521
....@@ -7141,7 +7525,7 @@
71417525 }
71427526
71437527 //System.out.println("info.modifiers = " + info.modifiers);
7144
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71457529 //System.out.println("modified = " + modified);
71467530 //new Exception().printStackTrace();
71477531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7169,7 +7553,8 @@
71697553 return true;
71707554 }
71717555
7172
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
71737558 {
71747559 if (hitSomething == 0)
71757560 {
....@@ -7183,7 +7568,7 @@
71837568
71847569 //System.out.println("hitSomething = " + hitSomething);
71857570
7186
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
71877572
71887573 cVector xlate = new cVector();
71897574 //cVector xlate2 = new cVector();
....@@ -7217,8 +7602,8 @@
72177602 toParent[3][i] = xlate.get(i);
72187603 LA.matInvert(toParent, fromParent);
72197604 */
7220
- cVector delta = LA.newVector(0, 0, startY - info.y);
7221
- 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);
72227607
72237608 LA.matCopy(startMat, toParent);
72247609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7227,7 +7612,7 @@
72277612 } else
72287613 {
72297614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7230
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
72317616 cVector away = new cVector();
72327617 //cVector right2 = new cVector();
72337618 //LA.vecCross(up, cVector.Z, right);
....@@ -7244,19 +7629,19 @@
72447629 LA.xformDir(up, ClickInfo.matbuffer, up);
72457630 // if (!CameraPane.LOCALTRANSFORM)
72467631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7247
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72487633 // if (!CameraPane.LOCALTRANSFORM)
72497634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72507635 //LA.vecCross(up, cVector.Z, right2);
72517636
7252
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72537638
72547639 //System.out.println("DELTA0 = " + delta);
72557640 //System.out.println("AWAY = " + info.camera.away);
72567641 //System.out.println("UP = " + info.camera.up);
72577642 if (away.z > 0)
72587643 {
7259
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72607645 {
72617646 delta.x = -delta.x;
72627647 } else
....@@ -7271,7 +7656,7 @@
72717656 //System.out.println("DELTA1 = " + delta);
72727657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72737658 //System.out.println("DELTA2 = " + delta);
7274
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72757660 LA.matCopy(startMat, toParent);
72767661 //System.out.println("DELTA3 = " + delta);
72777662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7281,8 +7666,8 @@
72817666 break;
72827667
72837668 case hitRotate: // rotate
7284
- int dx = info.x - centerPt.x;
7285
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
72867671 double angle = (double) Math.atan2(dx, dy);
72877672 angle = -(1.570796 - angle);
72887673
....@@ -7305,7 +7690,7 @@
73057690 }
73067691 /**/
73077692
7308
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
73097694 {
73107695 case 1: // '\001'
73117696 LA.matZRotate(toParent, angle);
....@@ -7332,7 +7717,7 @@
73327717 break;
73337718
73347719 case hitScale: // scale
7335
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
73367721 double sign = 1;
73377722 if (hScale < 0)
73387723 {
....@@ -7344,7 +7729,7 @@
73447729 //hScale = 0.01;
73457730 }
73467731
7347
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
73487733 sign = 1;
73497734 if (vScale < 0)
73507735 {
....@@ -7355,6 +7740,7 @@
73557740 {
73567741 //vScale = 0.01;
73577742 }
7743
+
73587744 LA.matCopy(startMat, toParent);
73597745 /**/
73607746 for (int i = 0; i < 3; i++)
....@@ -7364,29 +7750,30 @@
73647750 }
73657751 /**/
73667752
7367
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73687754
73697755 if (totalScale < 0.01)
73707756 {
73717757 totalScale = 0.01;
73727758 }
73737759
7374
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
73757761 {
73767762 case 3: // '\001'
7377
- if (modified)
7763
+ if (modified || opposite)
73787764 {
73797765 //LA.matScale(toParent, 1, hScale, vScale);
73807766 LA.matScale(toParent, totalScale, 1, 1);
73817767 } // vScale, 1);
73827768 else
73837769 {
7770
+ // EXCEPTION!
73847771 LA.matScale(toParent, totalScale, totalScale, totalScale);
73857772 } // vScale, 1);
73867773 break;
73877774
73887775 case 2: // '\002'
7389
- if (modified)
7776
+ if (modified || opposite)
73907777 {
73917778 //LA.matScale(toParent, hScale, 1, vScale);
73927779 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7397,7 +7784,7 @@
73977784 break;
73987785
73997786 case 1: // '\003'
7400
- if (modified)
7787
+ if (modified || opposite)
74017788 {
74027789 //LA.matScale(toParent, hScale, vScale, 1);
74037790 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7437,7 +7824,7 @@
74377824 } // NEW ...
74387825
74397826
7440
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
74417828 }
74427829
74437830 boolean overflow = false;
....@@ -7617,6 +8004,10 @@
76178004 editWindow = null;
76188005 } // ?
76198006 }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
8010
+ }
76208011 }
76218012
76228013 boolean root; // patch for edit windows
....@@ -7774,6 +8165,10 @@
77748165 }
77758166
77768167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
77778172 transient ObjectUI objectUI;
77788173 public static int povDepth = 0;
77798174 private static cVector tbMin = new cVector();