Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
Object3D.java
....@@ -22,8 +22,20 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
2739 ScriptNode scriptnode;
2840
2941 void InitOthers()
....@@ -104,64 +116,201 @@
104116
105117 // transient boolean reduced; // for morph reduction
106118
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
119
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
120
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
109121
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
122
+ transient Object3D transientsupport; // for cloning
123
+ transient boolean transientlink2master;
112124
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)
125
+ void SaveSupports()
125126 {
126
- bRep.SaveSupports();
127
+ if (blockloop)
128
+ return;
129
+
130
+ transientsupport = support;
131
+ transientlink2master = link2master;
132
+
133
+ support = null;
134
+ link2master = false;
135
+
136
+ if (bRep != null)
137
+ {
138
+ bRep.SaveSupports();
139
+ }
140
+
141
+ for (int i = 0; i < Size(); i++)
142
+ {
143
+ Object3D child = (Object3D) get(i);
144
+ if (child == null)
145
+ continue;
146
+ blockloop = true;
147
+ child.SaveSupports();
148
+ blockloop = false;
149
+ }
127150 }
128
-
129
- for (int i = 0; i < Size(); i++)
151
+
152
+ void RestoreSupports()
130153 {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
154
+ if (blockloop)
155
+ return;
156
+
157
+ support = transientsupport;
158
+ link2master = transientlink2master;
159
+ transientsupport = null;
160
+ transientlink2master = false;
161
+
162
+ if (bRep != null)
163
+ {
164
+ bRep.RestoreSupports();
165
+ }
166
+
167
+ for (int i = 0; i < Size(); i++)
168
+ {
169
+ Object3D child = (Object3D) get(i);
170
+ if (child == null)
171
+ continue;
172
+ blockloop = true;
173
+ child.RestoreSupports();
174
+ blockloop = false;
175
+ }
176
+ }
177
+
178
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
179
+ {
180
+ Object3D o;
181
+
182
+ if (hashtable.containsKey(GetUUID()))
183
+ {
184
+ o = hashtable.get(GetUUID());
185
+
186
+ Grafreed.Assert(this.bRep == o.bRep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
195
+
196
+ hashtable.put(GetUUID(), o);
197
+ }
198
+
199
+ if (!blockloop)
200
+ {
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
209
+ }
210
+
211
+ ExtractBigData(o);
212
+ }
213
+
214
+ void ExtractBigData(Object3D o)
215
+ {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
219
+ o.bRep = this.bRep;
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
230
+ {
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
236
+ }
237
+
238
+ // o.support = this.support;
239
+ // o.fileparent = this.fileparent;
240
+ // if (this.bRep != null)
241
+ // o.bRep = this.bRep.support;
242
+
243
+ this.bRep = null;
244
+ // if (this.bRep != null)
245
+ // this.bRep.support = null;
246
+ // this.support = null;
247
+ // this.fileparent = null;
248
+ }
249
+
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
273
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274
+ {
275
+ if (!hashtable.containsKey(GetUUID()))
276
+ return;
277
+
278
+ Object3D o = hashtable.get(GetUUID());
279
+
280
+ RestoreBigData(o);
281
+
282
+ if (blockloop)
283
+ return;
284
+
134285 blockloop = true;
135
- child.SaveSupports();
286
+
287
+ //hashtable.remove(GetUUID());
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).RestoreBigData(hashtable);
292
+ }
293
+
136294 blockloop = false;
137295 }
138
-}
139296
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)
297
+ void RestoreBigData(Object3D o)
151298 {
152
- bRep.RestoreSupports();
299
+ this.bRep = o.bRep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
311
+ // this.support = o.support;
312
+ // this.fileparent = o.fileparent;
153313 }
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
-}
165314
166315 // MOCAP SUPPORT
167316 double tx,ty,tz,rx,ry,rz;
....@@ -304,6 +453,7 @@
304453 }
305454
306455 boolean live = false;
456
+ transient boolean keepdontselect;
307457 boolean dontselect = false;
308458 boolean hide = false;
309459 boolean link2master = false; // performs reset support/master at each frame
....@@ -486,12 +636,14 @@
486636 toParent = LA.newMatrix();
487637 fromParent = LA.newMatrix();
488638 }
639
+
489640 if (toParentMarked == null)
490641 {
491642 if (maxcount != 1)
492643 {
493644 new Exception().printStackTrace();
494645 }
646
+
495647 toParentMarked = LA.newMatrix();
496648 fromParentMarked = LA.newMatrix();
497649 }
....@@ -802,7 +954,7 @@
802954
803955 if (marked && Globals.isLIVE() && live &&
804956 //TEMP21aug2018
805
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
806958 currentframe != Globals.framecount)
807959 {
808960 currentframe = Globals.framecount;
....@@ -814,7 +966,8 @@
814966
815967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
816968
817
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
818971 {
819972 countdown = 1;
820973 delay = speedup?8:1;
....@@ -886,6 +1039,10 @@
8861039 if (material == null || material.multiply)
8871040 return true;
8881041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
8891046 return material.opacity > 0.99;
8901047 }
8911048
....@@ -1286,6 +1443,7 @@
12861443 toParent = LA.newMatrix();
12871444 fromParent = LA.newMatrix();
12881445 }
1446
+
12891447 LA.matCopy(other.toParent, toParent);
12901448 LA.matCopy(other.fromParent, fromParent);
12911449
....@@ -2307,6 +2465,10 @@
23072465 }
23082466 */
23092467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ }
23102472 }
23112473
23122474 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2348,6 +2510,14 @@
23482510 {
23492511 editWindow.refreshContents();
23502512 }
2513
+ else
2514
+ {
2515
+ if (manipWindow != null)
2516
+ {
2517
+ manipWindow.refreshContents();
2518
+ }
2519
+ }
2520
+
23512521 //if (parent != null)
23522522 //parent.refreshEditWindow();
23532523 }
....@@ -2427,7 +2597,8 @@
24272597 private static final int editSelf = 1;
24282598 private static final int editChild = 2;
24292599
2430
- void drawEditHandles(ClickInfo info, int level)
2600
+ void drawEditHandles(//ClickInfo info,
2601
+ int level)
24312602 {
24322603 if (level == 0)
24332604 {
....@@ -2435,7 +2606,8 @@
24352606 return;
24362607
24372608 Object3D selectee;
2438
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2609
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2610
+ level + 1))
24392611 {
24402612 selectee = (Object3D) e.nextElement();
24412613 }
....@@ -2443,19 +2615,22 @@
24432615 } else
24442616 {
24452617 //super.
2446
- drawEditHandles0(info, level + 1);
2618
+ drawEditHandles0(//info,
2619
+ level + 1);
24472620 }
24482621 }
24492622
2450
- boolean doEditClick(ClickInfo info, int level)
2623
+ boolean doEditClick(//ClickInfo info,
2624
+ int level)
24512625 {
24522626 doSomething = 0;
24532627 if (level == 0)
24542628 {
2455
- return doParentClick(info);
2629
+ return doParentClick(); //info);
24562630 }
24572631 if (//super.
2458
- doEditClick0(info, level))
2632
+ doEditClick0(//info,
2633
+ level))
24592634 {
24602635 doSomething = 1;
24612636 return true;
....@@ -2465,7 +2640,7 @@
24652640 }
24662641 }
24672642
2468
- boolean doParentClick(ClickInfo info)
2643
+ boolean doParentClick() //ClickInfo info)
24692644 {
24702645 if (selection == null)
24712646 {
....@@ -2478,7 +2653,8 @@
24782653 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24792654 {
24802655 Object3D selectee = (Object3D) e.nextElement();
2481
- if (selectee.doEditClick(info, 1))
2656
+ if (selectee.doEditClick(//info,
2657
+ 1))
24822658 {
24832659 childToDrag = selectee;
24842660 doSomething = 2;
....@@ -2490,13 +2666,15 @@
24902666 return retval;
24912667 }
24922668
2493
- void doEditDrag(ClickInfo info, boolean opposite)
2669
+ void doEditDrag(//ClickInfo clickInfo,
2670
+ boolean opposite)
24942671 {
24952672 switch (doSomething)
24962673 {
24972674 case 1: // '\001'
24982675 //super.
2499
- doEditDrag0(info, opposite);
2676
+ doEditDrag0(//clickInfo,
2677
+ opposite);
25002678 break;
25012679
25022680 case 2: // '\002'
....@@ -2509,11 +2687,13 @@
25092687 {
25102688 //sel.hitSomething = childToDrag.hitSomething;
25112689 //childToDrag.doEditDrag(info);
2512
- sel.doEditDrag(info, opposite);
2690
+ sel.doEditDrag(//clickInfo,
2691
+ opposite);
25132692 } else
25142693 {
25152694 //super.
2516
- doEditDrag0(info, opposite);
2695
+ doEditDrag0(//clickInfo,
2696
+ opposite);
25172697 }
25182698 }
25192699 break;
....@@ -2531,6 +2711,9 @@
25312711 {
25322712 deselectAll();
25332713 }
2714
+
2715
+ new Exception().printStackTrace();
2716
+
25342717 ClickInfo newInfo = new ClickInfo();
25352718 newInfo.flags = info.flags;
25362719 newInfo.bounds = info.bounds;
....@@ -2623,6 +2806,18 @@
26232806 void GenNormalsS(boolean crease)
26242807 {
26252808 selection.GenNormals(crease);
2809
+// for (int i=0; i<selection.size(); i++)
2810
+// {
2811
+// Object3D selectee = (Object3D) selection.elementAt(i);
2812
+// selectee.GenNormals(crease);
2813
+// }
2814
+
2815
+ //Touch();
2816
+ }
2817
+
2818
+ void GenNormalsMeshS()
2819
+ {
2820
+ selection.GenNormalsMesh();
26262821 // for (int i=0; i<selection.size(); i++)
26272822 // {
26282823 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2763,6 +2958,24 @@
27632958 if (child == null)
27642959 continue;
27652960 child.GenNormals(crease);
2961
+// Children().release(i);
2962
+ }
2963
+ blockloop = false;
2964
+ }
2965
+
2966
+ void GenNormalsMesh()
2967
+ {
2968
+ if (blockloop)
2969
+ return;
2970
+
2971
+ blockloop = true;
2972
+ GenNormalsMesh0();
2973
+ for (int i = 0; i < Children().Size(); i++)
2974
+ {
2975
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2976
+ if (child == null)
2977
+ continue;
2978
+ child.GenNormalsMesh();
27662979 // Children().release(i);
27672980 }
27682981 blockloop = false;
....@@ -2935,11 +3148,20 @@
29353148 }
29363149 }
29373150
3151
+ void GenNormalsMesh0()
3152
+ {
3153
+ if (bRep != null)
3154
+ {
3155
+ bRep.GenerateNormalsMesh();
3156
+ Touch();
3157
+ }
3158
+ }
3159
+
29383160 void GenNormalsMINE0()
29393161 {
29403162 if (bRep != null)
29413163 {
2942
- bRep.GenerateNormalsMINE();
3164
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29433165 Touch();
29443166 }
29453167 }
....@@ -3385,7 +3607,8 @@
33853607 if (blockloop)
33863608 return;
33873609
3388
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
33893612 live = h;
33903613
33913614 for (int i = 0; i < Size(); i++)
....@@ -3406,7 +3629,8 @@
34063629 return;
34073630
34083631 //if (bRep != null)
3409
- if (marked || (bRep != null && material != null)) // borderline...
3632
+ if (//marked || // does not make sense
3633
+ (bRep != null || material != null)) // borderline...
34103634 link2master = h;
34113635
34123636 for (int i = 0; i < Size(); i++)
....@@ -3426,7 +3650,8 @@
34263650 if (blockloop)
34273651 return;
34283652
3429
- if (marked || (bRep != null && material != null)) // borderline...
3653
+ if (//marked || // does not make sense
3654
+ (bRep != null || material != null)) // borderline...
34303655 hide = h;
34313656
34323657 for (int i = 0; i < Size(); i++)
....@@ -3446,7 +3671,7 @@
34463671 if (blockloop)
34473672 return;
34483673
3449
- if (bRep != null && material != null) // borderline...
3674
+ if (bRep != null || material != null) // borderline...
34503675 marked = h;
34513676
34523677 for (int i = 0; i < Size(); i++)
....@@ -3456,6 +3681,46 @@
34563681 continue;
34573682 blockloop = true;
34583683 child.MarkLeaves(h);
3684
+ blockloop = false;
3685
+ // release(i);
3686
+ }
3687
+ }
3688
+
3689
+ void RewindLeaves(boolean h)
3690
+ {
3691
+ if (blockloop)
3692
+ return;
3693
+
3694
+ if (bRep != null || material != null) // borderline...
3695
+ rewind = h;
3696
+
3697
+ for (int i = 0; i < Size(); i++)
3698
+ {
3699
+ Object3D child = (Object3D) get(i); // reserve(i);
3700
+ if (child == null)
3701
+ continue;
3702
+ blockloop = true;
3703
+ child.RewindLeaves(h);
3704
+ blockloop = false;
3705
+ // release(i);
3706
+ }
3707
+ }
3708
+
3709
+ void RandomLeaves(boolean h)
3710
+ {
3711
+ if (blockloop)
3712
+ return;
3713
+
3714
+ if (bRep != null || material != null) // borderline...
3715
+ random = h;
3716
+
3717
+ for (int i = 0; i < Size(); i++)
3718
+ {
3719
+ Object3D child = (Object3D) get(i); // reserve(i);
3720
+ if (child == null)
3721
+ continue;
3722
+ blockloop = true;
3723
+ child.RandomLeaves(h);
34593724 blockloop = false;
34603725 // release(i);
34613726 }
....@@ -4233,6 +4498,55 @@
42334498 }
42344499 }
42354500
4501
+ void RepairSOV()
4502
+ {
4503
+ if (blockloop)
4504
+ return;
4505
+
4506
+ String texname = this.GetPigmentTexture();
4507
+
4508
+ if (texname.startsWith("sov"))
4509
+ {
4510
+ String[] s = texname.split("/");
4511
+
4512
+ String[] sname = s[1].split("Color.pn");
4513
+
4514
+ texname = sname[0];
4515
+
4516
+ if (sname.length > 1)
4517
+ {
4518
+ texname += "Color.jpg";
4519
+ }
4520
+
4521
+ this.SetPigmentTexture("sov/" + texname);
4522
+ }
4523
+
4524
+ texname = this.GetBumpTexture();
4525
+
4526
+ if (texname.startsWith("sov"))
4527
+ {
4528
+ String[] s = texname.split("/");
4529
+
4530
+ String[] sname = s[1].split("Bump.pn");
4531
+
4532
+ texname = sname[0];
4533
+
4534
+ if (sname.length > 1)
4535
+ {
4536
+ texname += "Bump.jpg";
4537
+ }
4538
+
4539
+ this.SetBumpTexture("sov/" + texname);
4540
+ }
4541
+
4542
+ for (int i=0; i<Size(); i++)
4543
+ {
4544
+ blockloop = true;
4545
+ get(i).RepairSOV();
4546
+ blockloop = false;
4547
+ }
4548
+ }
4549
+
42364550 void RepairTexture()
42374551 {
42384552 if (this instanceof FileObject || blockloop)
....@@ -4747,6 +5061,14 @@
47475061 }
47485062 }
47495063
5064
+ ObjEditor GetWindow()
5065
+ {
5066
+ if (editWindow != null)
5067
+ return editWindow;
5068
+
5069
+ return manipWindow;
5070
+ }
5071
+
47505072 cTreePath Select(int indexcount, boolean deselect)
47515073 {
47525074 if (hide || dontselect)
....@@ -4783,10 +5105,11 @@
47835105 if (leaf != null)
47845106 {
47855107 cTreePath tp = new cTreePath(this, leaf);
4786
- if (editWindow != null)
5108
+ ObjEditor window = GetWindow();
5109
+ if (window != null)
47875110 {
47885111 //System.out.println("editWindow = " + editWindow + " vs " + this);
4789
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
47905113 }
47915114
47925115 return tp;
....@@ -4803,6 +5126,7 @@
48035126
48045127 if (child == null)
48055128 continue;
5129
+
48065130 if (child.HasTransparency() && child.size() != 0)
48075131 {
48085132 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4812,9 +5136,10 @@
48125136 if (leaf != null)
48135137 {
48145138 cTreePath tp = new cTreePath(this, leaf);
4815
- if (editWindow != null)
5139
+ ObjEditor window = GetWindow();
5140
+ if (window != null)
48165141 {
4817
- editWindow.Select(tp, deselect, true);
5142
+ window.Select(tp, deselect, true);
48185143 }
48195144
48205145 return tp;
....@@ -5139,6 +5464,51 @@
51395464 blockloop = false;
51405465 }
51415466
5467
+ void ResetSelectable()
5468
+ {
5469
+ if (blockloop)
5470
+ return;
5471
+
5472
+ blockloop = true;
5473
+
5474
+ keepdontselect = dontselect;
5475
+ dontselect = true;
5476
+
5477
+ Object3D child;
5478
+ int nb = Size();
5479
+ for (int i = 0; i < nb; i++)
5480
+ {
5481
+ child = (Object3D) get(i);
5482
+ if (child == null)
5483
+ continue;
5484
+ child.ResetSelectable();
5485
+ }
5486
+
5487
+ blockloop = false;
5488
+ }
5489
+
5490
+ void RestoreSelectable()
5491
+ {
5492
+ if (blockloop)
5493
+ return;
5494
+
5495
+ blockloop = true;
5496
+
5497
+ dontselect = keepdontselect;
5498
+
5499
+ Object3D child;
5500
+ int nb = Size();
5501
+ for (int i = 0; i < nb; i++)
5502
+ {
5503
+ child = (Object3D) get(i);
5504
+ if (child == null)
5505
+ continue;
5506
+ child.RestoreSelectable();
5507
+ }
5508
+
5509
+ blockloop = false;
5510
+ }
5511
+
51425512 boolean IsSelected()
51435513 {
51445514 if (parent == null)
....@@ -5448,6 +5818,38 @@
54485818 }
54495819 }
54505820
5821
+ void EmbedTextures(boolean embed)
5822
+ {
5823
+ if (blockloop)
5824
+ return;
5825
+
5826
+ //if (GetTextures() != null)
5827
+ if (embed)
5828
+ CameraPane.EmbedTextures(GetTextures());
5829
+ else
5830
+ {
5831
+ GetTextures().pigmentdata = null;
5832
+ GetTextures().bumpdata = null;
5833
+ GetTextures().pw = 0;
5834
+ GetTextures().ph = 0;
5835
+ GetTextures().bw = 0;
5836
+ GetTextures().bh = 0;
5837
+ }
5838
+
5839
+ int nb = Size();
5840
+ for (int i = 0; i < nb; i++)
5841
+ {
5842
+ Object3D child = (Object3D) get(i);
5843
+
5844
+ if (child == null)
5845
+ continue;
5846
+
5847
+ blockloop = true;
5848
+ child.EmbedTextures(embed);
5849
+ blockloop = false;
5850
+ }
5851
+ }
5852
+
54515853 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54525854 {
54535855 Draw(display, root, selected, blocked);
....@@ -5456,12 +5858,23 @@
54565858 boolean NeedSupport()
54575859 {
54585860 return
5459
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5861
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54605862 // PROBLEM with CROWD!!
54615863 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54625864 }
54635865
54645866 static boolean DEBUG_SELECTION = false;
5867
+
5868
+ boolean IsLive()
5869
+ {
5870
+ if (live)
5871
+ return true;
5872
+
5873
+ if (parent == null)
5874
+ return false;
5875
+
5876
+ return parent.IsLive();
5877
+ }
54655878
54665879 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54675880 {
....@@ -5523,8 +5936,10 @@
55235936 if (support != null)
55245937 support = support;
55255938
5526
- //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);
5939
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5940
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+
5942
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
55285943
55295944 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55305945 {
....@@ -5534,8 +5949,9 @@
55345949 // usecalllists &= !(parent instanceof RandomNode);
55355950 // usecalllists = false;
55365951
5537
- if (GetBRep() != null)
5538
- usecalllists = usecalllists;
5952
+ if (display.DrawMode() == display.SHADOW)
5953
+ //GetBRep() != null)
5954
+ usecalllists = !!usecalllists;
55395955 //System.out.println("draw " + this);
55405956 //new Exception().printStackTrace();
55415957
....@@ -5544,10 +5960,12 @@
55445960 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55455961
55465962 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5547
- (touched || (bRep != null && bRep.displaylist <= 0)))
5963
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5964
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
55485965 {
55495966 Globals.lighttouched = true;
55505967 } // all panes...
5968
+
55515969 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55525970 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55535971 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5555,7 +5973,7 @@
55555973 if (!(this instanceof Composite))
55565974 touched = false;
55575975 //if (displaylist == -1 && usecalllists)
5558
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5976
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
55595977 {
55605978 bRep.displaylist = display.GenList();
55615979 assert(bRep.displaylist != 0);
....@@ -5566,7 +5984,7 @@
55665984
55675985 //System.out.println("\tnew list " + list);
55685986 //gl.glDrawBuffer(gl.GL_NONE);
5569
- if (usecalllists)
5987
+ if (usecalllists && bRep.displaylist > 0)
55705988 {
55715989 // System.err.println("new list " + bRep.displaylist + " for " + this);
55725990 display.NewList(bRep.displaylist);
....@@ -5575,7 +5993,7 @@
55755993 CallList(display, root, selected, blocked);
55765994
55775995 // compiled = true;
5578
- if (usecalllists)
5996
+ if (usecalllists && bRep.displaylist > 0)
55795997 {
55805998 // System.err.println("end list " + bRep.displaylist + " for " + this);
55815999 display.EndList();
....@@ -5675,6 +6093,7 @@
56756093 if (GetBRep() != null)
56766094 {
56776095 display.NextIndex();
6096
+
56786097 // vertex color conflict : gl.glCallList(list);
56796098 DrawNode(display, root, selected);
56806099 if (this instanceof BezierPatch)
....@@ -5715,16 +6134,27 @@
57156134 tex = GetTextures();
57166135 }
57176136
5718
- boolean failed = false;
6137
+ boolean failedPigment = false;
6138
+ boolean failedBump = false;
57196139
57206140 try
57216141 {
5722
- display.BindTextures(tex, texres);
6142
+ display.BindPigmentTexture(tex, texres);
57236143 }
57246144 catch (Exception e)
57256145 {
57266146 System.err.println("FAILED: " + this);
5727
- failed = true;
6147
+ failedPigment = true;
6148
+ }
6149
+
6150
+ try
6151
+ {
6152
+ display.BindBumpTexture(tex, texres);
6153
+ }
6154
+ catch (Exception e)
6155
+ {
6156
+ //System.err.println("FAILED: " + this);
6157
+ failedBump = true;
57286158 }
57296159
57306160 if (!compiled)
....@@ -5747,8 +6177,11 @@
57476177 }
57486178 }
57496179
5750
- if (!failed)
5751
- display.ReleaseTextures(tex);
6180
+ if (!failedBump)
6181
+ display.ReleaseBumpTexture(tex);
6182
+
6183
+ if (!failedPigment)
6184
+ display.ReleasePigmentTexture(tex);
57526185
57536186 display.PopMaterial(this, selected);
57546187 }
....@@ -6121,6 +6554,11 @@
61216554 // dec 2012
61226555 new Exception().printStackTrace();
61236556 return;
6557
+ }
6558
+
6559
+ if (dontselect)
6560
+ {
6561
+ //bRep.GenerateNormalsMINE();
61246562 }
61256563
61266564 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6906,20 +7344,23 @@
69067344 }
69077345 }
69087346
6909
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7347
+ static ClickInfo clickInfo = new ClickInfo();
7348
+
7349
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7350
+ Point outPt, Rectangle outRec)
69107351 {
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;
7352
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7353
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7354
+ double[][] toscreen = clickInfo.toScreen;
69147355 if (toscreen == null)
69157356 {
6916
- toscreen = new Camera(info.camera.viewCode).toScreen;
7357
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69177358 }
69187359 cVector vec = in;
69197360 LA.xformPos(in, toscreen, in);
69207361 //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();
7362
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7363
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
69237364 outPt.x = hc + (int) vec.x;
69247365 outPt.y = vc - (int) vec.y;
69257366 outRec.x = outPt.x - 3;
....@@ -6927,15 +7368,18 @@
69277368 outRec.width = outRec.height = 6;
69287369 }
69297370
6930
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7371
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7372
+ )
69317373 {
69327374 Point pt = new Point(0, 0);
69337375 Rectangle rec = new Rectangle();
6934
- calcHotSpot(in, info, pt, rec);
7376
+ calcHotSpot(in, //clickInfo,
7377
+ pt, rec);
69357378 return rec;
69367379 }
69377380
6938
- void drawEditHandles0(ClickInfo info, int level)
7381
+ void drawEditHandles0(//ClickInfo clickInfo,
7382
+ int level)
69397383 {
69407384 if (level == 0)
69417385 {
....@@ -6944,16 +7388,19 @@
69447388 {
69457389 cVector origin = new cVector();
69467390 //LA.xformPos(origin, toParent, origin);
6947
- Rectangle spot = calcHotSpot(origin, info);
7391
+ if (this.clickInfo == null)
7392
+ this.clickInfo = new ClickInfo();
7393
+
7394
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
69487395 Rectangle boundary = new Rectangle();
69497396 boundary.x = spot.x - 30;
69507397 boundary.y = spot.y - 30;
69517398 boundary.width = spot.width + 60;
69527399 boundary.height = spot.height + 60;
6953
- info.g.setColor(Color.red);
7400
+ clickInfo.g.setColor(Color.red);
69547401 int spotw = spot.x + spot.width;
69557402 int spoth = spot.y + spot.height;
6956
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7403
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69577404 // if (CameraPane.Xmin > spot.x)
69587405 // {
69597406 // CameraPane.Xmin = spot.x;
....@@ -6973,8 +7420,8 @@
69737420 spot.translate(32, 32);
69747421 spotw = spot.x + spot.width;
69757422 spoth = spot.y + spot.height;
6976
- info.g.setColor(Color.blue);
6977
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.setColor(Color.cyan);
7424
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69787425 // if (CameraPane.Xmin > spot.x)
69797426 // {
69807427 // CameraPane.Xmin = spot.x;
....@@ -6991,11 +7438,12 @@
69917438 // {
69927439 // CameraPane.Ymax = spoth;
69937440 // }
6994
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7441
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7442
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69967443 spot.translate(0, -32);
6997
- info.g.setColor(Color.green);
6998
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7444
+ clickInfo.g.setColor(Color.yellow);
7445
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
+ clickInfo.g.setColor(Color.green);
69997447 // if (CameraPane.Xmin > spot.x)
70007448 // {
70017449 // CameraPane.Xmin = spot.x;
....@@ -7012,8 +7460,8 @@
70127460 // {
70137461 // CameraPane.Ymax = spoth;
70147462 // }
7015
- info.g.drawArc(boundary.x, boundary.y,
7016
- boundary.width, boundary.height, 0, 360);
7463
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7464
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
70177465 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70187466 // if (CameraPane.Xmin > boundary.x)
70197467 // {
....@@ -7035,7 +7483,8 @@
70357483 }
70367484 }
70377485
7038
- boolean doEditClick0(ClickInfo info, int level)
7486
+ boolean doEditClick0(//ClickInfo clickInfo,
7487
+ int level)
70397488 {
70407489 if (level == 0)
70417490 {
....@@ -7044,8 +7493,8 @@
70447493
70457494 boolean retval = false;
70467495
7047
- startX = info.x;
7048
- startY = info.y;
7496
+ startX = clickInfo.x;
7497
+ startY = clickInfo.y;
70497498
70507499 hitSomething = -1;
70517500 cVector origin = new cVector();
....@@ -7055,22 +7504,51 @@
70557504 {
70567505 centerPt = new Point(0, 0);
70577506 }
7058
- calcHotSpot(origin, info, centerPt, spot);
7059
- if (spot.contains(info.x, info.y))
7507
+ calcHotSpot(origin, //info,
7508
+ centerPt, spot);
7509
+ if (spot.contains(clickInfo.x, clickInfo.y))
70607510 {
70617511 hitSomething = hitCenter;
70627512 retval = true;
70637513 }
70647514 spot.translate(32, 0);
7065
- if (spot.contains(info.x, info.y))
7515
+ if (spot.contains(clickInfo.x, clickInfo.y))
70667516 {
70677517 hitSomething = hitRotate;
70687518 retval = true;
70697519 }
70707520 spot.translate(0, 32);
7071
- if (spot.contains(info.x, info.y))
7521
+ if (spot.contains(clickInfo.x, clickInfo.y))
70727522 {
70737523 hitSomething = hitScale;
7524
+
7525
+ double scale = 0.005f * clickInfo.camera.Distance();
7526
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7527
+ double sign = 1;
7528
+ if (hScale < 0)
7529
+ {
7530
+ sign = -1;
7531
+ }
7532
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7533
+ if (hScale < 0.01)
7534
+ {
7535
+ //hScale = 0.01;
7536
+ }
7537
+
7538
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7539
+ sign = 1;
7540
+ if (vScale < 0)
7541
+ {
7542
+ sign = -1;
7543
+ }
7544
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7545
+ if (vScale < 0.01)
7546
+ {
7547
+ //vScale = 0.01;
7548
+ }
7549
+
7550
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7551
+
70747552 retval = true;
70757553 }
70767554
....@@ -7080,7 +7558,7 @@
70807558 }
70817559
70827560 //System.out.println("info.modifiers = " + info.modifiers);
7083
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7561
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
70847562 //System.out.println("modified = " + modified);
70857563 //new Exception().printStackTrace();
70867564 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7108,7 +7586,8 @@
71087586 return true;
71097587 }
71107588
7111
- void doEditDrag0(ClickInfo info, boolean opposite)
7589
+ void doEditDrag0(//ClickInfo info,
7590
+ boolean opposite)
71127591 {
71137592 if (hitSomething == 0)
71147593 {
....@@ -7122,7 +7601,7 @@
71227601
71237602 //System.out.println("hitSomething = " + hitSomething);
71247603
7125
- double scale = 0.005f * info.camera.Distance();
7604
+ double scale = 0.005f * clickInfo.camera.Distance();
71267605
71277606 cVector xlate = new cVector();
71287607 //cVector xlate2 = new cVector();
....@@ -7156,8 +7635,8 @@
71567635 toParent[3][i] = xlate.get(i);
71577636 LA.matInvert(toParent, fromParent);
71587637 */
7159
- cVector delta = LA.newVector(0, 0, startY - info.y);
7160
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7638
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7639
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71617640
71627641 LA.matCopy(startMat, toParent);
71637642 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7166,7 +7645,7 @@
71667645 } else
71677646 {
71687647 //LA.xformDir(delta, info.camera.fromScreen, delta);
7169
- cVector up = new cVector(info.camera.up);
7648
+ cVector up = new cVector(clickInfo.camera.up);
71707649 cVector away = new cVector();
71717650 //cVector right2 = new cVector();
71727651 //LA.vecCross(up, cVector.Z, right);
....@@ -7183,19 +7662,19 @@
71837662 LA.xformDir(up, ClickInfo.matbuffer, up);
71847663 // if (!CameraPane.LOCALTRANSFORM)
71857664 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7186
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7665
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
71877666 // if (!CameraPane.LOCALTRANSFORM)
71887667 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
71897668 //LA.vecCross(up, cVector.Z, right2);
71907669
7191
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7670
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
71927671
71937672 //System.out.println("DELTA0 = " + delta);
71947673 //System.out.println("AWAY = " + info.camera.away);
71957674 //System.out.println("UP = " + info.camera.up);
71967675 if (away.z > 0)
71977676 {
7198
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7677
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
71997678 {
72007679 delta.x = -delta.x;
72017680 } else
....@@ -7210,7 +7689,7 @@
72107689 //System.out.println("DELTA1 = " + delta);
72117690 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72127691 //System.out.println("DELTA2 = " + delta);
7213
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7692
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72147693 LA.matCopy(startMat, toParent);
72157694 //System.out.println("DELTA3 = " + delta);
72167695 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7220,8 +7699,8 @@
72207699 break;
72217700
72227701 case hitRotate: // rotate
7223
- int dx = info.x - centerPt.x;
7224
- int dy = -(info.y - centerPt.y);
7702
+ int dx = clickInfo.x - centerPt.x;
7703
+ int dy = -(clickInfo.y - centerPt.y);
72257704 double angle = (double) Math.atan2(dx, dy);
72267705 angle = -(1.570796 - angle);
72277706
....@@ -7244,7 +7723,7 @@
72447723 }
72457724 /**/
72467725
7247
- switch (info.pane.RenderCamera().viewCode)
7726
+ switch (clickInfo.pane.RenderCamera().viewCode)
72487727 {
72497728 case 1: // '\001'
72507729 LA.matZRotate(toParent, angle);
....@@ -7271,7 +7750,7 @@
72717750 break;
72727751
72737752 case hitScale: // scale
7274
- double hScale = (double) (info.x - centerPt.x) / 32;
7753
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
72757754 double sign = 1;
72767755 if (hScale < 0)
72777756 {
....@@ -7283,7 +7762,7 @@
72837762 //hScale = 0.01;
72847763 }
72857764
7286
- double vScale = (double) (info.y - centerPt.y) / 32;
7765
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
72877766 sign = 1;
72887767 if (vScale < 0)
72897768 {
....@@ -7294,6 +7773,7 @@
72947773 {
72957774 //vScale = 0.01;
72967775 }
7776
+
72977777 LA.matCopy(startMat, toParent);
72987778 /**/
72997779 for (int i = 0; i < 3; i++)
....@@ -7303,29 +7783,30 @@
73037783 }
73047784 /**/
73057785
7306
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7786
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73077787
73087788 if (totalScale < 0.01)
73097789 {
73107790 totalScale = 0.01;
73117791 }
73127792
7313
- switch (info.pane.RenderCamera().viewCode)
7793
+ switch (clickInfo.pane.RenderCamera().viewCode)
73147794 {
73157795 case 3: // '\001'
7316
- if (modified)
7796
+ if (modified || opposite)
73177797 {
73187798 //LA.matScale(toParent, 1, hScale, vScale);
73197799 LA.matScale(toParent, totalScale, 1, 1);
73207800 } // vScale, 1);
73217801 else
73227802 {
7803
+ // EXCEPTION!
73237804 LA.matScale(toParent, totalScale, totalScale, totalScale);
73247805 } // vScale, 1);
73257806 break;
73267807
73277808 case 2: // '\002'
7328
- if (modified)
7809
+ if (modified || opposite)
73297810 {
73307811 //LA.matScale(toParent, hScale, 1, vScale);
73317812 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7336,7 +7817,7 @@
73367817 break;
73377818
73387819 case 1: // '\003'
7339
- if (modified)
7820
+ if (modified || opposite)
73407821 {
73417822 //LA.matScale(toParent, hScale, vScale, 1);
73427823 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7376,7 +7857,7 @@
73767857 } // NEW ...
73777858
73787859
7379
- info.pane.repaint();
7860
+ clickInfo.pane.repaint();
73807861 }
73817862
73827863 boolean overflow = false;
....@@ -7556,6 +8037,10 @@
75568037 editWindow = null;
75578038 } // ?
75588039 }
8040
+ else
8041
+ {
8042
+ //editWindow.closeUI();
8043
+ }
75598044 }
75608045
75618046 boolean root; // patch for edit windows
....@@ -7567,7 +8052,7 @@
75678052 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75688053
75698054 Object3D /*Composite*/ parent;
7570
- Object3D /*Composite*/ fileparent;
8055
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75718056
75728057 double[][] toParent; // dynamic matrix
75738058 double[][] fromParent;
....@@ -7713,6 +8198,10 @@
77138198 }
77148199
77158200 transient ObjEditor editWindow;
8201
+ transient ObjEditor manipWindow;
8202
+
8203
+ transient boolean pinned;
8204
+
77168205 transient ObjectUI objectUI;
77178206 public static int povDepth = 0;
77188207 private static cVector tbMin = new cVector();