Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
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[] = new byte[100][];
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,7 @@
300426 }
301427
302428 boolean live = false;
429
+ boolean dontselect = false;
303430 boolean hide = false;
304431 boolean link2master = false; // performs reset support/master at each frame
305432 boolean marked = false; // animation node
....@@ -481,12 +608,14 @@
481608 toParent = LA.newMatrix();
482609 fromParent = LA.newMatrix();
483610 }
611
+
484612 if (toParentMarked == null)
485613 {
486614 if (maxcount != 1)
487615 {
488616 new Exception().printStackTrace();
489617 }
618
+
490619 toParentMarked = LA.newMatrix();
491620 fromParentMarked = LA.newMatrix();
492621 }
....@@ -774,7 +903,7 @@
774903 if (step == 0)
775904 step = 1;
776905 if (maxcount == 0)
777
- maxcount = 2048; // 4;
906
+ maxcount = 128; // 2048; // 4;
778907 // if (acceleration == 0)
779908 // acceleration = 10;
780909 if (delay == 0) // serial
....@@ -797,7 +926,7 @@
797926
798927 if (marked && Globals.isLIVE() && live &&
799928 //TEMP21aug2018
800
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
929
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801930 currentframe != Globals.framecount)
802931 {
803932 currentframe = Globals.framecount;
....@@ -809,7 +938,8 @@
809938
810939 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811940
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
941
+ if (transformcount*factor >= maxcount && (rewind || random) ||
942
+ (step == 1 && changedir))
813943 {
814944 countdown = 1;
815945 delay = speedup?8:1;
....@@ -881,6 +1011,7 @@
8811011 if (material == null || material.multiply)
8821012 return true;
8831013
1014
+ // Transparent objects are dynamic because we have to sort the triangles.
8841015 return material.opacity > 0.99;
8851016 }
8861017
....@@ -1281,6 +1412,7 @@
12811412 toParent = LA.newMatrix();
12821413 fromParent = LA.newMatrix();
12831414 }
1415
+
12841416 LA.matCopy(other.toParent, toParent);
12851417 LA.matCopy(other.fromParent, fromParent);
12861418
....@@ -1834,12 +1966,15 @@
18341966 if (obj.name == null)
18351967 continue; // can't be a null one
18361968
1969
+ // Try perfect match first.
18371970 if (n.equals(obj.name))
18381971 {
18391972 theobj = obj;
18401973 count++;
18411974 }
18421975 }
1976
+
1977
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18431978
18441979 if (count != 1)
18451980 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2434,10 @@
22992434 }
23002435 */
23012436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
23022441 }
23032442
23042443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2340,6 +2479,14 @@
23402479 {
23412480 editWindow.refreshContents();
23422481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
23432490 //if (parent != null)
23442491 //parent.refreshEditWindow();
23452492 }
....@@ -2624,6 +2771,18 @@
26242771 //Touch();
26252772 }
26262773
2774
+ void GenNormalsMeshS()
2775
+ {
2776
+ selection.GenNormalsMesh();
2777
+// for (int i=0; i<selection.size(); i++)
2778
+// {
2779
+// Object3D selectee = (Object3D) selection.elementAt(i);
2780
+// selectee.GenNormals(crease);
2781
+// }
2782
+
2783
+ //Touch();
2784
+ }
2785
+
26272786 void ClearColorsS()
26282787 {
26292788 selection.ClearColors();
....@@ -2755,6 +2914,24 @@
27552914 if (child == null)
27562915 continue;
27572916 child.GenNormals(crease);
2917
+// Children().release(i);
2918
+ }
2919
+ blockloop = false;
2920
+ }
2921
+
2922
+ void GenNormalsMesh()
2923
+ {
2924
+ if (blockloop)
2925
+ return;
2926
+
2927
+ blockloop = true;
2928
+ GenNormalsMesh0();
2929
+ for (int i = 0; i < Children().Size(); i++)
2930
+ {
2931
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2932
+ if (child == null)
2933
+ continue;
2934
+ child.GenNormalsMesh();
27582935 // Children().release(i);
27592936 }
27602937 blockloop = false;
....@@ -2927,11 +3104,20 @@
29273104 }
29283105 }
29293106
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
3112
+ Touch();
3113
+ }
3114
+ }
3115
+
29303116 void GenNormalsMINE0()
29313117 {
29323118 if (bRep != null)
29333119 {
2934
- bRep.GenerateNormalsMINE();
3120
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29353121 Touch();
29363122 }
29373123 }
....@@ -3002,8 +3188,10 @@
30023188 v.fromParent = LA.newMatrix();
30033189 }
30043190
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3191
+// LA.matConcat(v.toParent, toParent, v.toParent);
3192
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3193
+ LA.matConcat(toParent, v.toParent, v.toParent);
3194
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073195 }
30083196
30093197 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3424,9 @@
32363424 bRep.support = null;
32373425 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383426 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3427
+
3428
+ while(temprep.SplitInTwo(reduction34, onlyone));
3429
+
32403430 bRep = temprep;
32413431 bRep.support = sup;
32423432 Touch();
....@@ -3373,7 +3563,8 @@
33733563 if (blockloop)
33743564 return;
33753565
3376
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
33773568 live = h;
33783569
33793570 for (int i = 0; i < Size(); i++)
....@@ -3394,7 +3585,8 @@
33943585 return;
33953586
33963587 //if (bRep != null)
3397
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
33983590 link2master = h;
33993591
34003592 for (int i = 0; i < Size(); i++)
....@@ -3414,7 +3606,8 @@
34143606 if (blockloop)
34153607 return;
34163608
3417
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
34183611 hide = h;
34193612
34203613 for (int i = 0; i < Size(); i++)
....@@ -3434,7 +3627,7 @@
34343627 if (blockloop)
34353628 return;
34363629
3437
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
34383631 marked = h;
34393632
34403633 for (int i = 0; i < Size(); i++)
....@@ -3444,6 +3637,46 @@
34443637 continue;
34453638 blockloop = true;
34463639 child.MarkLeaves(h);
3640
+ blockloop = false;
3641
+ // release(i);
3642
+ }
3643
+ }
3644
+
3645
+ void RewindLeaves(boolean h)
3646
+ {
3647
+ if (blockloop)
3648
+ return;
3649
+
3650
+ if (bRep != null || material != null) // borderline...
3651
+ rewind = h;
3652
+
3653
+ for (int i = 0; i < Size(); i++)
3654
+ {
3655
+ Object3D child = (Object3D) get(i); // reserve(i);
3656
+ if (child == null)
3657
+ continue;
3658
+ blockloop = true;
3659
+ child.RewindLeaves(h);
3660
+ blockloop = false;
3661
+ // release(i);
3662
+ }
3663
+ }
3664
+
3665
+ void RandomLeaves(boolean h)
3666
+ {
3667
+ if (blockloop)
3668
+ return;
3669
+
3670
+ if (bRep != null || material != null) // borderline...
3671
+ random = h;
3672
+
3673
+ for (int i = 0; i < Size(); i++)
3674
+ {
3675
+ Object3D child = (Object3D) get(i); // reserve(i);
3676
+ if (child == null)
3677
+ continue;
3678
+ blockloop = true;
3679
+ child.RandomLeaves(h);
34473680 blockloop = false;
34483681 // release(i);
34493682 }
....@@ -4221,6 +4454,55 @@
42214454 }
42224455 }
42234456
4457
+ void RepairSOV()
4458
+ {
4459
+ if (blockloop)
4460
+ return;
4461
+
4462
+ String texname = this.GetPigmentTexture();
4463
+
4464
+ if (texname.startsWith("sov"))
4465
+ {
4466
+ String[] s = texname.split("/");
4467
+
4468
+ String[] sname = s[1].split("Color.pn");
4469
+
4470
+ texname = sname[0];
4471
+
4472
+ if (sname.length > 1)
4473
+ {
4474
+ texname += "Color.jpg";
4475
+ }
4476
+
4477
+ this.SetPigmentTexture("sov/" + texname);
4478
+ }
4479
+
4480
+ texname = this.GetBumpTexture();
4481
+
4482
+ if (texname.startsWith("sov"))
4483
+ {
4484
+ String[] s = texname.split("/");
4485
+
4486
+ String[] sname = s[1].split("Bump.pn");
4487
+
4488
+ texname = sname[0];
4489
+
4490
+ if (sname.length > 1)
4491
+ {
4492
+ texname += "Bump.jpg";
4493
+ }
4494
+
4495
+ this.SetBumpTexture("sov/" + texname);
4496
+ }
4497
+
4498
+ for (int i=0; i<Size(); i++)
4499
+ {
4500
+ blockloop = true;
4501
+ get(i).RepairSOV();
4502
+ blockloop = false;
4503
+ }
4504
+ }
4505
+
42244506 void RepairTexture()
42254507 {
42264508 if (this instanceof FileObject || blockloop)
....@@ -4711,7 +4993,7 @@
47114993
47124994 cTreePath SelectLeaf(int indexcount, boolean deselect)
47134995 {
4714
- if (hide)
4996
+ if (hide || dontselect)
47154997 return null;
47164998
47174999 if (count <= 0)
....@@ -4735,9 +5017,17 @@
47355017 }
47365018 }
47375019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
47385028 cTreePath Select(int indexcount, boolean deselect)
47395029 {
4740
- if (hide)
5030
+ if (hide || dontselect)
47415031 return null;
47425032
47435033 if (count <= 0)
....@@ -4771,10 +5061,11 @@
47715061 if (leaf != null)
47725062 {
47735063 cTreePath tp = new cTreePath(this, leaf);
4774
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
47755066 {
47765067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4777
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
47785069 }
47795070
47805071 return tp;
....@@ -4791,6 +5082,7 @@
47915082
47925083 if (child == null)
47935084 continue;
5085
+
47945086 if (child.HasTransparency() && child.size() != 0)
47955087 {
47965088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4800,9 +5092,10 @@
48005092 if (leaf != null)
48015093 {
48025094 cTreePath tp = new cTreePath(this, leaf);
4803
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
48045097 {
4805
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
48065099 }
48075100
48085101 return tp;
....@@ -5363,6 +5656,43 @@
53635656 }
53645657 }
53655658
5659
+ UUID GetUUID()
5660
+ {
5661
+ if (uuid == null)
5662
+ {
5663
+ // Serial
5664
+ uuid = UUID.randomUUID();
5665
+ }
5666
+
5667
+ return uuid;
5668
+ }
5669
+
5670
+ Object3D GetObject(UUID uid)
5671
+ {
5672
+ if (blockloop)
5673
+ return null;
5674
+
5675
+ if (GetUUID().equals(uid))
5676
+ return this;
5677
+
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ Object3D child = (Object3D) get(i);
5682
+
5683
+ if (child == null)
5684
+ continue;
5685
+
5686
+ blockloop = true;
5687
+ Object3D obj = child.GetObject(uid);
5688
+ blockloop = false;
5689
+ if (obj != null)
5690
+ return obj;
5691
+ }
5692
+
5693
+ return null;
5694
+ }
5695
+
53665696 void SetBumpTexture(String tex)
53675697 {
53685698 if (GetTextures() == null)
....@@ -5407,12 +5737,23 @@
54075737 boolean NeedSupport()
54085738 {
54095739 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54115741 // PROBLEM with CROWD!!
54125742 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135743 }
54145744
54155745 static boolean DEBUG_SELECTION = false;
5746
+
5747
+ boolean IsLive()
5748
+ {
5749
+ if (live)
5750
+ return true;
5751
+
5752
+ if (parent == null)
5753
+ return false;
5754
+
5755
+ return parent.IsLive();
5756
+ }
54165757
54175758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54185759 {
....@@ -5424,7 +5765,7 @@
54245765 }
54255766
54265767 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5768
+ (hide || dontselect))
54285769 return;
54295770
54305771 if (name != null && name.contains("sclera"))
....@@ -5475,7 +5816,7 @@
54755816 support = support;
54765817
54775818 //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);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54795820
54805821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54815822 {
....@@ -5495,10 +5836,12 @@
54955836 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54965837
54975838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5498
- (touched || (bRep != null && bRep.displaylist <= 0)))
5839
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5840
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54995841 {
55005842 Globals.lighttouched = true;
55015843 } // all panes...
5844
+
55025845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55035846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55045847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5626,6 +5969,7 @@
56265969 if (GetBRep() != null)
56275970 {
56285971 display.NextIndex();
5972
+
56295973 // vertex color conflict : gl.glCallList(list);
56305974 DrawNode(display, root, selected);
56315975 if (this instanceof BezierPatch)
....@@ -5666,7 +6010,28 @@
56666010 tex = GetTextures();
56676011 }
56686012
5669
- display.BindTextures(tex, texres);
6013
+ boolean failedPigment = false;
6014
+ boolean failedBump = false;
6015
+
6016
+ try
6017
+ {
6018
+ display.BindPigmentTexture(tex, texres);
6019
+ }
6020
+ catch (Exception e)
6021
+ {
6022
+ System.err.println("FAILED: " + this);
6023
+ failedPigment = true;
6024
+ }
6025
+
6026
+ try
6027
+ {
6028
+ display.BindBumpTexture(tex, texres);
6029
+ }
6030
+ catch (Exception e)
6031
+ {
6032
+ //System.err.println("FAILED: " + this);
6033
+ failedBump = true;
6034
+ }
56706035
56716036 if (!compiled)
56726037 {
....@@ -5688,7 +6053,11 @@
56886053 }
56896054 }
56906055
5691
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
56926061
56936062 display.PopMaterial(this, selected);
56946063 }
....@@ -5817,6 +6186,9 @@
58176186
58186187 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58196188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
58206192 if (hide)
58216193 return;
58226194 // shadow optimisation
....@@ -5942,6 +6314,9 @@
59426314 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59436315 return; // no shadow for transparent objects
59446316
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
6319
+
59456320 if (hide)
59466321 return;
59476322
....@@ -6055,6 +6430,11 @@
60556430 // dec 2012
60566431 new Exception().printStackTrace();
60576432 return;
6433
+ }
6434
+
6435
+ if (dontselect)
6436
+ {
6437
+ //bRep.GenerateNormalsMINE();
60586438 }
60596439
60606440 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6907,7 +7287,7 @@
69077287 spot.translate(32, 32);
69087288 spotw = spot.x + spot.width;
69097289 spoth = spot.y + spot.height;
6910
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
69117291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69127292 // if (CameraPane.Xmin > spot.x)
69137293 // {
....@@ -6925,11 +7305,12 @@
69257305 // {
69267306 // CameraPane.Ymax = spoth;
69277307 // }
6928
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6929
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7308
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7309
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69307310 spot.translate(0, -32);
6931
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
69327312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
+ info.g.setColor(Color.green);
69337314 // if (CameraPane.Xmin > spot.x)
69347315 // {
69357316 // CameraPane.Xmin = spot.x;
....@@ -6946,8 +7327,8 @@
69467327 // {
69477328 // CameraPane.Ymax = spoth;
69487329 // }
6949
- info.g.drawArc(boundary.x, boundary.y,
6950
- boundary.width, boundary.height, 0, 360);
7330
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
69517332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69527333 // if (CameraPane.Xmin > boundary.x)
69537334 // {
....@@ -6981,7 +7362,7 @@
69817362 startX = info.x;
69827363 startY = info.y;
69837364
6984
- hitSomething = 0;
7365
+ hitSomething = -1;
69857366 cVector origin = new cVector();
69867367 //LA.xformPos(origin, toParent, origin);
69877368 Rectangle spot = new Rectangle();
....@@ -7057,6 +7438,7 @@
70577438 //System.out.println("hitSomething = " + hitSomething);
70587439
70597440 double scale = 0.005f * info.camera.Distance();
7441
+
70607442 cVector xlate = new cVector();
70617443 //cVector xlate2 = new cVector();
70627444 switch (hitSomething)
....@@ -7205,24 +7587,27 @@
72057587
72067588 case hitScale: // scale
72077589 double hScale = (double) (info.x - centerPt.x) / 32;
7590
+ double sign = 1;
7591
+ if (hScale < 0)
7592
+ {
7593
+ sign = -1;
7594
+ }
7595
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72087596 if (hScale < 0.01)
72097597 {
7210
- hScale = 0.01;
7598
+ //hScale = 0.01;
72117599 }
7212
- hScale = Math.pow(hScale, scale * 50);
7213
- if (hScale < 0.01)
7214
- {
7215
- hScale = 0.01;
7216
- }
7600
+
72177601 double vScale = (double) (info.y - centerPt.y) / 32;
7218
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
72197604 {
7220
- vScale = 0.01;
7605
+ sign = -1;
72217606 }
7222
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72237608 if (vScale < 0.01)
72247609 {
7225
- vScale = 0.01;
7610
+ //vScale = 0.01;
72267611 }
72277612 LA.matCopy(startMat, toParent);
72287613 /**/
....@@ -7233,39 +7618,47 @@
72337618 }
72347619 /**/
72357620
7621
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7622
+
7623
+ if (totalScale < 0.01)
7624
+ {
7625
+ totalScale = 0.01;
7626
+ }
7627
+
72367628 switch (info.pane.RenderCamera().viewCode)
72377629 {
72387630 case 3: // '\001'
7239
- if (modified)
7631
+ if (modified || opposite)
72407632 {
72417633 //LA.matScale(toParent, 1, hScale, vScale);
7242
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
72437635 } // vScale, 1);
72447636 else
72457637 {
7246
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72477640 } // vScale, 1);
72487641 break;
72497642
72507643 case 2: // '\002'
7251
- if (modified)
7644
+ if (modified || opposite)
72527645 {
72537646 //LA.matScale(toParent, hScale, 1, vScale);
7254
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
72557648 } else
72567649 {
7257
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
72587651 }
72597652 break;
72607653
72617654 case 1: // '\003'
7262
- if (modified)
7655
+ if (modified || opposite)
72637656 {
72647657 //LA.matScale(toParent, hScale, vScale, 1);
7265
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
72667659 } else
72677660 {
7268
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
72697662 }
72707663 break;
72717664 }
....@@ -7406,7 +7799,7 @@
74067799 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74077800 } else
74087801 {
7409
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7802
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74107803 } // + super.toString();
74117804 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74127805
....@@ -7479,6 +7872,10 @@
74797872 editWindow = null;
74807873 } // ?
74817874 }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
7878
+ }
74827879 }
74837880
74847881 boolean root; // patch for edit windows
....@@ -7490,7 +7887,7 @@
74907887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74917888
74927889 Object3D /*Composite*/ parent;
7493
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74947891
74957892 double[][] toParent; // dynamic matrix
74967893 double[][] fromParent;
....@@ -7636,6 +8033,10 @@
76368033 }
76378034
76388035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
76398040 transient ObjectUI objectUI;
76408041 public static int povDepth = 0;
76418042 private static cVector tbMin = new cVector();
....@@ -7654,9 +8055,9 @@
76548055 private static cVector edge2 = new cVector();
76558056 //private static cVector norm = new cVector();
76568057 /*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;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
76608061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76618062 /*transient*/ private Point centerPt;
76628063 /*transient*/ private int startX;