Normand Briere
2019-07-20 0a52bd4800459cd9935f360d7ca9555b6bea2146
Object3D.java
....@@ -14,12 +14,24 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
2224
25
+ private UUID uuid = UUID.randomUUID();
26
+
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
+
2335 ScriptNode scriptnode;
2436
2537 void InitOthers()
....@@ -100,64 +112,178 @@
100112
101113 // transient boolean reduced; // for morph reduction
102114
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-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
105117
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
108120
109
-void SaveSupports()
110
-{
111
- if (blockloop)
112
- return;
113
-
114
- transientsupport = support;
115
- transientlink2master = link2master;
116
-
117
- support = null;
118
- link2master = false;
119
-
120
- if (bRep != null)
121
+ void SaveSupports()
121122 {
122
- 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
+ }
123146 }
124
-
125
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
126149 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- 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
+
130258 blockloop = true;
131
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
132267 blockloop = false;
133268 }
134
-}
135269
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
140
-
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
147271 {
148
- 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;
149286 }
150
-
151
- for (int i = 0; i < Size(); i++)
152
- {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
159
- }
160
-}
161287
162288 // MOCAP SUPPORT
163289 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +426,8 @@
300426 }
301427
302428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
303431 boolean hide = false;
304432 boolean link2master = false; // performs reset support/master at each frame
305433 boolean marked = false; // animation node
....@@ -481,12 +609,14 @@
481609 toParent = LA.newMatrix();
482610 fromParent = LA.newMatrix();
483611 }
612
+
484613 if (toParentMarked == null)
485614 {
486615 if (maxcount != 1)
487616 {
488617 new Exception().printStackTrace();
489618 }
619
+
490620 toParentMarked = LA.newMatrix();
491621 fromParentMarked = LA.newMatrix();
492622 }
....@@ -774,7 +904,7 @@
774904 if (step == 0)
775905 step = 1;
776906 if (maxcount == 0)
777
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
778908 // if (acceleration == 0)
779909 // acceleration = 10;
780910 if (delay == 0) // serial
....@@ -797,7 +927,7 @@
797927
798928 if (marked && Globals.isLIVE() && live &&
799929 //TEMP21aug2018
800
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801931 currentframe != Globals.framecount)
802932 {
803933 currentframe = Globals.framecount;
....@@ -809,7 +939,8 @@
809939
810940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811941
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
813944 {
814945 countdown = 1;
815946 delay = speedup?8:1;
....@@ -881,6 +1012,7 @@
8811012 if (material == null || material.multiply)
8821013 return true;
8831014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8841016 return material.opacity > 0.99;
8851017 }
8861018
....@@ -1281,6 +1413,7 @@
12811413 toParent = LA.newMatrix();
12821414 fromParent = LA.newMatrix();
12831415 }
1416
+
12841417 LA.matCopy(other.toParent, toParent);
12851418 LA.matCopy(other.fromParent, fromParent);
12861419
....@@ -1834,12 +1967,15 @@
18341967 if (obj.name == null)
18351968 continue; // can't be a null one
18361969
1970
+ // Try perfect match first.
18371971 if (n.equals(obj.name))
18381972 {
18391973 theobj = obj;
18401974 count++;
18411975 }
18421976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18431979
18441980 if (count != 1)
18451981 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2435,10 @@
22992435 }
23002436 */
23012437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23022442 }
23032443
23042444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2340,6 +2480,14 @@
23402480 {
23412481 editWindow.refreshContents();
23422482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23432491 //if (parent != null)
23442492 //parent.refreshEditWindow();
23452493 }
....@@ -2624,6 +2772,18 @@
26242772 //Touch();
26252773 }
26262774
2775
+ void GenNormalsMeshS()
2776
+ {
2777
+ selection.GenNormalsMesh();
2778
+// for (int i=0; i<selection.size(); i++)
2779
+// {
2780
+// Object3D selectee = (Object3D) selection.elementAt(i);
2781
+// selectee.GenNormals(crease);
2782
+// }
2783
+
2784
+ //Touch();
2785
+ }
2786
+
26272787 void ClearColorsS()
26282788 {
26292789 selection.ClearColors();
....@@ -2755,6 +2915,24 @@
27552915 if (child == null)
27562916 continue;
27572917 child.GenNormals(crease);
2918
+// Children().release(i);
2919
+ }
2920
+ blockloop = false;
2921
+ }
2922
+
2923
+ void GenNormalsMesh()
2924
+ {
2925
+ if (blockloop)
2926
+ return;
2927
+
2928
+ blockloop = true;
2929
+ GenNormalsMesh0();
2930
+ for (int i = 0; i < Children().Size(); i++)
2931
+ {
2932
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2933
+ if (child == null)
2934
+ continue;
2935
+ child.GenNormalsMesh();
27582936 // Children().release(i);
27592937 }
27602938 blockloop = false;
....@@ -2927,11 +3105,20 @@
29273105 }
29283106 }
29293107
3108
+ void GenNormalsMesh0()
3109
+ {
3110
+ if (bRep != null)
3111
+ {
3112
+ bRep.GenerateNormalsMesh();
3113
+ Touch();
3114
+ }
3115
+ }
3116
+
29303117 void GenNormalsMINE0()
29313118 {
29323119 if (bRep != null)
29333120 {
2934
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29353122 Touch();
29363123 }
29373124 }
....@@ -3002,8 +3189,10 @@
30023189 v.fromParent = LA.newMatrix();
30033190 }
30043191
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3192
+// LA.matConcat(v.toParent, toParent, v.toParent);
3193
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3194
+ LA.matConcat(toParent, v.toParent, v.toParent);
3195
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073196 }
30083197
30093198 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3425,9 @@
32363425 bRep.support = null;
32373426 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383427 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3428
+
3429
+ while(temprep.SplitInTwo(reduction34, onlyone));
3430
+
32403431 bRep = temprep;
32413432 bRep.support = sup;
32423433 Touch();
....@@ -3373,7 +3564,8 @@
33733564 if (blockloop)
33743565 return;
33753566
3376
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
33773569 live = h;
33783570
33793571 for (int i = 0; i < Size(); i++)
....@@ -3394,7 +3586,8 @@
33943586 return;
33953587
33963588 //if (bRep != null)
3397
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
33983591 link2master = h;
33993592
34003593 for (int i = 0; i < Size(); i++)
....@@ -3414,7 +3607,8 @@
34143607 if (blockloop)
34153608 return;
34163609
3417
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
34183612 hide = h;
34193613
34203614 for (int i = 0; i < Size(); i++)
....@@ -3434,7 +3628,7 @@
34343628 if (blockloop)
34353629 return;
34363630
3437
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
34383632 marked = h;
34393633
34403634 for (int i = 0; i < Size(); i++)
....@@ -3444,6 +3638,46 @@
34443638 continue;
34453639 blockloop = true;
34463640 child.MarkLeaves(h);
3641
+ blockloop = false;
3642
+ // release(i);
3643
+ }
3644
+ }
3645
+
3646
+ void RewindLeaves(boolean h)
3647
+ {
3648
+ if (blockloop)
3649
+ return;
3650
+
3651
+ if (bRep != null || material != null) // borderline...
3652
+ rewind = h;
3653
+
3654
+ for (int i = 0; i < Size(); i++)
3655
+ {
3656
+ Object3D child = (Object3D) get(i); // reserve(i);
3657
+ if (child == null)
3658
+ continue;
3659
+ blockloop = true;
3660
+ child.RewindLeaves(h);
3661
+ blockloop = false;
3662
+ // release(i);
3663
+ }
3664
+ }
3665
+
3666
+ void RandomLeaves(boolean h)
3667
+ {
3668
+ if (blockloop)
3669
+ return;
3670
+
3671
+ if (bRep != null || material != null) // borderline...
3672
+ random = h;
3673
+
3674
+ for (int i = 0; i < Size(); i++)
3675
+ {
3676
+ Object3D child = (Object3D) get(i); // reserve(i);
3677
+ if (child == null)
3678
+ continue;
3679
+ blockloop = true;
3680
+ child.RandomLeaves(h);
34473681 blockloop = false;
34483682 // release(i);
34493683 }
....@@ -4221,6 +4455,55 @@
42214455 }
42224456 }
42234457
4458
+ void RepairSOV()
4459
+ {
4460
+ if (blockloop)
4461
+ return;
4462
+
4463
+ String texname = this.GetPigmentTexture();
4464
+
4465
+ if (texname.startsWith("sov"))
4466
+ {
4467
+ String[] s = texname.split("/");
4468
+
4469
+ String[] sname = s[1].split("Color.pn");
4470
+
4471
+ texname = sname[0];
4472
+
4473
+ if (sname.length > 1)
4474
+ {
4475
+ texname += "Color.jpg";
4476
+ }
4477
+
4478
+ this.SetPigmentTexture("sov/" + texname);
4479
+ }
4480
+
4481
+ texname = this.GetBumpTexture();
4482
+
4483
+ if (texname.startsWith("sov"))
4484
+ {
4485
+ String[] s = texname.split("/");
4486
+
4487
+ String[] sname = s[1].split("Bump.pn");
4488
+
4489
+ texname = sname[0];
4490
+
4491
+ if (sname.length > 1)
4492
+ {
4493
+ texname += "Bump.jpg";
4494
+ }
4495
+
4496
+ this.SetBumpTexture("sov/" + texname);
4497
+ }
4498
+
4499
+ for (int i=0; i<Size(); i++)
4500
+ {
4501
+ blockloop = true;
4502
+ get(i).RepairSOV();
4503
+ blockloop = false;
4504
+ }
4505
+ }
4506
+
42244507 void RepairTexture()
42254508 {
42264509 if (this instanceof FileObject || blockloop)
....@@ -4711,7 +4994,7 @@
47114994
47124995 cTreePath SelectLeaf(int indexcount, boolean deselect)
47134996 {
4714
- if (hide)
4997
+ if (hide || dontselect)
47154998 return null;
47164999
47175000 if (count <= 0)
....@@ -4735,9 +5018,17 @@
47355018 }
47365019 }
47375020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
47385029 cTreePath Select(int indexcount, boolean deselect)
47395030 {
4740
- if (hide)
5031
+ if (hide || dontselect)
47415032 return null;
47425033
47435034 if (count <= 0)
....@@ -4771,10 +5062,11 @@
47715062 if (leaf != null)
47725063 {
47735064 cTreePath tp = new cTreePath(this, leaf);
4774
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
47755067 {
47765068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4777
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
47785070 }
47795071
47805072 return tp;
....@@ -4791,6 +5083,7 @@
47915083
47925084 if (child == null)
47935085 continue;
5086
+
47945087 if (child.HasTransparency() && child.size() != 0)
47955088 {
47965089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4800,9 +5093,10 @@
48005093 if (leaf != null)
48015094 {
48025095 cTreePath tp = new cTreePath(this, leaf);
4803
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
48045098 {
4805
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
48065100 }
48075101
48085102 return tp;
....@@ -5127,6 +5421,51 @@
51275421 blockloop = false;
51285422 }
51295423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
51305469 boolean IsSelected()
51315470 {
51325471 if (parent == null)
....@@ -5363,6 +5702,43 @@
53635702 }
53645703 }
53655704
5705
+ UUID GetUUID()
5706
+ {
5707
+ if (uuid == null)
5708
+ {
5709
+ // Serial
5710
+ uuid = UUID.randomUUID();
5711
+ }
5712
+
5713
+ return uuid;
5714
+ }
5715
+
5716
+ Object3D GetObject(UUID uid)
5717
+ {
5718
+ if (blockloop)
5719
+ return null;
5720
+
5721
+ if (GetUUID().equals(uid))
5722
+ return this;
5723
+
5724
+ int nb = Size();
5725
+ for (int i = 0; i < nb; i++)
5726
+ {
5727
+ Object3D child = (Object3D) get(i);
5728
+
5729
+ if (child == null)
5730
+ continue;
5731
+
5732
+ blockloop = true;
5733
+ Object3D obj = child.GetObject(uid);
5734
+ blockloop = false;
5735
+ if (obj != null)
5736
+ return obj;
5737
+ }
5738
+
5739
+ return null;
5740
+ }
5741
+
53665742 void SetBumpTexture(String tex)
53675743 {
53685744 if (GetTextures() == null)
....@@ -5407,12 +5783,23 @@
54075783 boolean NeedSupport()
54085784 {
54095785 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5786
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54115787 // PROBLEM with CROWD!!
54125788 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135789 }
54145790
54155791 static boolean DEBUG_SELECTION = false;
5792
+
5793
+ boolean IsLive()
5794
+ {
5795
+ if (live)
5796
+ return true;
5797
+
5798
+ if (parent == null)
5799
+ return false;
5800
+
5801
+ return parent.IsLive();
5802
+ }
54165803
54175804 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54185805 {
....@@ -5424,7 +5811,7 @@
54245811 }
54255812
54265813 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5814
+ (hide || dontselect))
54285815 return;
54295816
54305817 if (name != null && name.contains("sclera"))
....@@ -5475,7 +5862,7 @@
54755862 support = support;
54765863
54775864 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5478
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5865
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54795866
54805867 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54815868 {
....@@ -5495,10 +5882,12 @@
54955882 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54965883
54975884 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5498
- (touched || (bRep != null && bRep.displaylist <= 0)))
5885
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5886
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54995887 {
55005888 Globals.lighttouched = true;
55015889 } // all panes...
5890
+
55025891 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55035892 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55045893 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5626,6 +6015,7 @@
56266015 if (GetBRep() != null)
56276016 {
56286017 display.NextIndex();
6018
+
56296019 // vertex color conflict : gl.glCallList(list);
56306020 DrawNode(display, root, selected);
56316021 if (this instanceof BezierPatch)
....@@ -5666,7 +6056,28 @@
56666056 tex = GetTextures();
56676057 }
56686058
5669
- display.BindTextures(tex, texres);
6059
+ boolean failedPigment = false;
6060
+ boolean failedBump = false;
6061
+
6062
+ try
6063
+ {
6064
+ display.BindPigmentTexture(tex, texres);
6065
+ }
6066
+ catch (Exception e)
6067
+ {
6068
+ System.err.println("FAILED: " + this);
6069
+ failedPigment = true;
6070
+ }
6071
+
6072
+ try
6073
+ {
6074
+ display.BindBumpTexture(tex, texres);
6075
+ }
6076
+ catch (Exception e)
6077
+ {
6078
+ //System.err.println("FAILED: " + this);
6079
+ failedBump = true;
6080
+ }
56706081
56716082 if (!compiled)
56726083 {
....@@ -5688,7 +6099,11 @@
56886099 }
56896100 }
56906101
5691
- display.ReleaseTextures(tex);
6102
+ if (!failedBump)
6103
+ display.ReleaseBumpTexture(tex);
6104
+
6105
+ if (!failedPigment)
6106
+ display.ReleasePigmentTexture(tex);
56926107
56936108 display.PopMaterial(this, selected);
56946109 }
....@@ -5817,6 +6232,9 @@
58176232
58186233 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58196234 {
6235
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6236
+ return;
6237
+
58206238 if (hide)
58216239 return;
58226240 // shadow optimisation
....@@ -5942,6 +6360,9 @@
59426360 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59436361 return; // no shadow for transparent objects
59446362
6363
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6364
+ return;
6365
+
59456366 if (hide)
59466367 return;
59476368
....@@ -6055,6 +6476,11 @@
60556476 // dec 2012
60566477 new Exception().printStackTrace();
60576478 return;
6479
+ }
6480
+
6481
+ if (dontselect)
6482
+ {
6483
+ //bRep.GenerateNormalsMINE();
60586484 }
60596485
60606486 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6907,7 +7333,7 @@
69077333 spot.translate(32, 32);
69087334 spotw = spot.x + spot.width;
69097335 spoth = spot.y + spot.height;
6910
- info.g.setColor(Color.blue);
7336
+ info.g.setColor(Color.cyan);
69117337 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69127338 // if (CameraPane.Xmin > spot.x)
69137339 // {
....@@ -6925,11 +7351,12 @@
69257351 // {
69267352 // CameraPane.Ymax = spoth;
69277353 // }
6928
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6929
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7354
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7355
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69307356 spot.translate(0, -32);
6931
- info.g.setColor(Color.green);
7357
+ info.g.setColor(Color.yellow);
69327358 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7359
+ info.g.setColor(Color.green);
69337360 // if (CameraPane.Xmin > spot.x)
69347361 // {
69357362 // CameraPane.Xmin = spot.x;
....@@ -6946,8 +7373,8 @@
69467373 // {
69477374 // CameraPane.Ymax = spoth;
69487375 // }
6949
- info.g.drawArc(boundary.x, boundary.y,
6950
- boundary.width, boundary.height, 0, 360);
7376
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7377
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
69517378 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69527379 // if (CameraPane.Xmin > boundary.x)
69537380 // {
....@@ -6981,7 +7408,7 @@
69817408 startX = info.x;
69827409 startY = info.y;
69837410
6984
- hitSomething = 0;
7411
+ hitSomething = -1;
69857412 cVector origin = new cVector();
69867413 //LA.xformPos(origin, toParent, origin);
69877414 Rectangle spot = new Rectangle();
....@@ -7057,6 +7484,7 @@
70577484 //System.out.println("hitSomething = " + hitSomething);
70587485
70597486 double scale = 0.005f * info.camera.Distance();
7487
+
70607488 cVector xlate = new cVector();
70617489 //cVector xlate2 = new cVector();
70627490 switch (hitSomething)
....@@ -7205,24 +7633,27 @@
72057633
72067634 case hitScale: // scale
72077635 double hScale = (double) (info.x - centerPt.x) / 32;
7636
+ double sign = 1;
7637
+ if (hScale < 0)
7638
+ {
7639
+ sign = -1;
7640
+ }
7641
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72087642 if (hScale < 0.01)
72097643 {
7210
- hScale = 0.01;
7644
+ //hScale = 0.01;
72117645 }
7212
- hScale = Math.pow(hScale, scale * 50);
7213
- if (hScale < 0.01)
7214
- {
7215
- hScale = 0.01;
7216
- }
7646
+
72177647 double vScale = (double) (info.y - centerPt.y) / 32;
7218
- if (vScale < 0.01)
7648
+ sign = 1;
7649
+ if (vScale < 0)
72197650 {
7220
- vScale = 0.01;
7651
+ sign = -1;
72217652 }
7222
- vScale = Math.pow(vScale, scale * 50);
7653
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72237654 if (vScale < 0.01)
72247655 {
7225
- vScale = 0.01;
7656
+ //vScale = 0.01;
72267657 }
72277658 LA.matCopy(startMat, toParent);
72287659 /**/
....@@ -7233,39 +7664,47 @@
72337664 }
72347665 /**/
72357666
7667
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7668
+
7669
+ if (totalScale < 0.01)
7670
+ {
7671
+ totalScale = 0.01;
7672
+ }
7673
+
72367674 switch (info.pane.RenderCamera().viewCode)
72377675 {
72387676 case 3: // '\001'
7239
- if (modified)
7677
+ if (modified || opposite)
72407678 {
72417679 //LA.matScale(toParent, 1, hScale, vScale);
7242
- LA.matScale(toParent, vScale, 1, 1);
7680
+ LA.matScale(toParent, totalScale, 1, 1);
72437681 } // vScale, 1);
72447682 else
72457683 {
7246
- LA.matScale(toParent, vScale, vScale, vScale);
7684
+ // EXCEPTION!
7685
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72477686 } // vScale, 1);
72487687 break;
72497688
72507689 case 2: // '\002'
7251
- if (modified)
7690
+ if (modified || opposite)
72527691 {
72537692 //LA.matScale(toParent, hScale, 1, vScale);
7254
- LA.matScale(toParent, 1, vScale, 1);
7693
+ LA.matScale(toParent, 1, totalScale, 1);
72557694 } else
72567695 {
7257
- LA.matScale(toParent, vScale, 1, vScale);
7696
+ LA.matScale(toParent, totalScale, 1, totalScale);
72587697 }
72597698 break;
72607699
72617700 case 1: // '\003'
7262
- if (modified)
7701
+ if (modified || opposite)
72637702 {
72647703 //LA.matScale(toParent, hScale, vScale, 1);
7265
- LA.matScale(toParent, 1, 1, vScale);
7704
+ LA.matScale(toParent, 1, 1, totalScale);
72667705 } else
72677706 {
7268
- LA.matScale(toParent, vScale, vScale, 1);
7707
+ LA.matScale(toParent, totalScale, totalScale, 1);
72697708 }
72707709 break;
72717710 }
....@@ -7406,7 +7845,7 @@
74067845 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74077846 } else
74087847 {
7409
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7848
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74107849 } // + super.toString();
74117850 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74127851
....@@ -7479,6 +7918,10 @@
74797918 editWindow = null;
74807919 } // ?
74817920 }
7921
+ else
7922
+ {
7923
+ //editWindow.closeUI();
7924
+ }
74827925 }
74837926
74847927 boolean root; // patch for edit windows
....@@ -7490,7 +7933,7 @@
74907933 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74917934
74927935 Object3D /*Composite*/ parent;
7493
- Object3D /*Composite*/ fileparent;
7936
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74947937
74957938 double[][] toParent; // dynamic matrix
74967939 double[][] fromParent;
....@@ -7636,6 +8079,10 @@
76368079 }
76378080
76388081 transient ObjEditor editWindow;
8082
+ transient ObjEditor manipWindow;
8083
+
8084
+ transient boolean pinned;
8085
+
76398086 transient ObjectUI objectUI;
76408087 public static int povDepth = 0;
76418088 private static cVector tbMin = new cVector();
....@@ -7654,9 +8101,9 @@
76548101 private static cVector edge2 = new cVector();
76558102 //private static cVector norm = new cVector();
76568103 /*transient private*/ int hitSomething;
7657
- private static final int hitCenter = 1;
7658
- private static final int hitScale = 2;
7659
- private static final int hitRotate = 3;
8104
+ static final int hitCenter = 1;
8105
+ static final int hitScale = 2;
8106
+ static final int hitRotate = 3;
76608107 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76618108 /*transient*/ private Point centerPt;
76628109 /*transient*/ private int startX;