Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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,173 @@
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
+
223
+ if (this.support != null)
224
+ {
225
+ if (o.transientrep != null)
226
+ Grafreed.Assert(o.transientrep == this.support.bRep);
227
+
228
+ o.transientrep = this.support.bRep;
229
+ this.support.bRep = null;
230
+ }
231
+
232
+ // o.support = this.support;
233
+ // o.fileparent = this.fileparent;
234
+ // if (this.bRep != null)
235
+ // o.bRep = this.bRep.support;
236
+
237
+ this.bRep = null;
238
+ // if (this.bRep != null)
239
+ // this.bRep.support = null;
240
+ // this.support = null;
241
+ // this.fileparent = null;
242
+ }
243
+
244
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
245
+ {
246
+ if (!hashtable.containsKey(GetUUID()))
247
+ return;
248
+
249
+ Object3D o = hashtable.get(GetUUID());
250
+
251
+ RestoreBigData(o);
252
+
253
+ if (blockloop)
254
+ return;
255
+
130256 blockloop = true;
131
- child.SaveSupports();
257
+
258
+ //hashtable.remove(GetUUID());
259
+
260
+ for (int i=0; i<Size(); i++)
261
+ {
262
+ get(i).RestoreBigData(hashtable);
263
+ }
264
+
132265 blockloop = false;
133266 }
134
-}
135267
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)
268
+ void RestoreBigData(Object3D o)
147269 {
148
- bRep.RestoreSupports();
270
+ this.bRep = o.bRep;
271
+ if (this.support != null && o.transientrep != null)
272
+ {
273
+ this.support.bRep = o.transientrep;
274
+ }
275
+
276
+ this.selection = o.selection;
277
+// July 2019 if (this.bRep != null)
278
+// this.bRep.support = o.transientrep;
279
+ // this.support = o.support;
280
+ // this.fileparent = o.fileparent;
149281 }
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
-}
161282
162283 // MOCAP SUPPORT
163284 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +421,7 @@
300421 }
301422
302423 boolean live = false;
424
+ boolean dontselect = false;
303425 boolean hide = false;
304426 boolean link2master = false; // performs reset support/master at each frame
305427 boolean marked = false; // animation node
....@@ -481,12 +603,14 @@
481603 toParent = LA.newMatrix();
482604 fromParent = LA.newMatrix();
483605 }
606
+
484607 if (toParentMarked == null)
485608 {
486609 if (maxcount != 1)
487610 {
488611 new Exception().printStackTrace();
489612 }
613
+
490614 toParentMarked = LA.newMatrix();
491615 fromParentMarked = LA.newMatrix();
492616 }
....@@ -774,7 +898,7 @@
774898 if (step == 0)
775899 step = 1;
776900 if (maxcount == 0)
777
- maxcount = 2048; // 4;
901
+ maxcount = 128; // 2048; // 4;
778902 // if (acceleration == 0)
779903 // acceleration = 10;
780904 if (delay == 0) // serial
....@@ -797,7 +921,7 @@
797921
798922 if (marked && Globals.isLIVE() && live &&
799923 //TEMP21aug2018
800
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801925 currentframe != Globals.framecount)
802926 {
803927 currentframe = Globals.framecount;
....@@ -809,7 +933,8 @@
809933
810934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811935
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
813938 {
814939 countdown = 1;
815940 delay = speedup?8:1;
....@@ -881,6 +1006,7 @@
8811006 if (material == null || material.multiply)
8821007 return true;
8831008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
8841010 return material.opacity > 0.99;
8851011 }
8861012
....@@ -1281,6 +1407,7 @@
12811407 toParent = LA.newMatrix();
12821408 fromParent = LA.newMatrix();
12831409 }
1410
+
12841411 LA.matCopy(other.toParent, toParent);
12851412 LA.matCopy(other.fromParent, fromParent);
12861413
....@@ -1834,12 +1961,15 @@
18341961 if (obj.name == null)
18351962 continue; // can't be a null one
18361963
1964
+ // Try perfect match first.
18371965 if (n.equals(obj.name))
18381966 {
18391967 theobj = obj;
18401968 count++;
18411969 }
18421970 }
1971
+
1972
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18431973
18441974 if (count != 1)
18451975 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2429,10 @@
22992429 }
23002430 */
23012431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
23022436 }
23032437
23042438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2340,6 +2474,14 @@
23402474 {
23412475 editWindow.refreshContents();
23422476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23432485 //if (parent != null)
23442486 //parent.refreshEditWindow();
23452487 }
....@@ -2624,6 +2766,18 @@
26242766 //Touch();
26252767 }
26262768
2769
+ void GenNormalsMeshS()
2770
+ {
2771
+ selection.GenNormalsMesh();
2772
+// for (int i=0; i<selection.size(); i++)
2773
+// {
2774
+// Object3D selectee = (Object3D) selection.elementAt(i);
2775
+// selectee.GenNormals(crease);
2776
+// }
2777
+
2778
+ //Touch();
2779
+ }
2780
+
26272781 void ClearColorsS()
26282782 {
26292783 selection.ClearColors();
....@@ -2755,6 +2909,24 @@
27552909 if (child == null)
27562910 continue;
27572911 child.GenNormals(crease);
2912
+// Children().release(i);
2913
+ }
2914
+ blockloop = false;
2915
+ }
2916
+
2917
+ void GenNormalsMesh()
2918
+ {
2919
+ if (blockloop)
2920
+ return;
2921
+
2922
+ blockloop = true;
2923
+ GenNormalsMesh0();
2924
+ for (int i = 0; i < Children().Size(); i++)
2925
+ {
2926
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2927
+ if (child == null)
2928
+ continue;
2929
+ child.GenNormalsMesh();
27582930 // Children().release(i);
27592931 }
27602932 blockloop = false;
....@@ -2927,6 +3099,15 @@
29273099 }
29283100 }
29293101
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
3107
+ Touch();
3108
+ }
3109
+ }
3110
+
29303111 void GenNormalsMINE0()
29313112 {
29323113 if (bRep != null)
....@@ -3002,8 +3183,10 @@
30023183 v.fromParent = LA.newMatrix();
30033184 }
30043185
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3186
+// LA.matConcat(v.toParent, toParent, v.toParent);
3187
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3188
+ LA.matConcat(toParent, v.toParent, v.toParent);
3189
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073190 }
30083191
30093192 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3419,9 @@
32363419 bRep.support = null;
32373420 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383421 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
32403425 bRep = temprep;
32413426 bRep.support = sup;
32423427 Touch();
....@@ -3373,7 +3558,8 @@
33733558 if (blockloop)
33743559 return;
33753560
3376
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
33773563 live = h;
33783564
33793565 for (int i = 0; i < Size(); i++)
....@@ -3394,7 +3580,8 @@
33943580 return;
33953581
33963582 //if (bRep != null)
3397
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33983585 link2master = h;
33993586
34003587 for (int i = 0; i < Size(); i++)
....@@ -3414,7 +3601,8 @@
34143601 if (blockloop)
34153602 return;
34163603
3417
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
34183606 hide = h;
34193607
34203608 for (int i = 0; i < Size(); i++)
....@@ -3434,7 +3622,7 @@
34343622 if (blockloop)
34353623 return;
34363624
3437
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
34383626 marked = h;
34393627
34403628 for (int i = 0; i < Size(); i++)
....@@ -3444,6 +3632,46 @@
34443632 continue;
34453633 blockloop = true;
34463634 child.MarkLeaves(h);
3635
+ blockloop = false;
3636
+ // release(i);
3637
+ }
3638
+ }
3639
+
3640
+ void RewindLeaves(boolean h)
3641
+ {
3642
+ if (blockloop)
3643
+ return;
3644
+
3645
+ if (bRep != null || material != null) // borderline...
3646
+ rewind = h;
3647
+
3648
+ for (int i = 0; i < Size(); i++)
3649
+ {
3650
+ Object3D child = (Object3D) get(i); // reserve(i);
3651
+ if (child == null)
3652
+ continue;
3653
+ blockloop = true;
3654
+ child.RewindLeaves(h);
3655
+ blockloop = false;
3656
+ // release(i);
3657
+ }
3658
+ }
3659
+
3660
+ void RandomLeaves(boolean h)
3661
+ {
3662
+ if (blockloop)
3663
+ return;
3664
+
3665
+ if (bRep != null || material != null) // borderline...
3666
+ random = h;
3667
+
3668
+ for (int i = 0; i < Size(); i++)
3669
+ {
3670
+ Object3D child = (Object3D) get(i); // reserve(i);
3671
+ if (child == null)
3672
+ continue;
3673
+ blockloop = true;
3674
+ child.RandomLeaves(h);
34473675 blockloop = false;
34483676 // release(i);
34493677 }
....@@ -4221,6 +4449,55 @@
42214449 }
42224450 }
42234451
4452
+ void RepairSOV()
4453
+ {
4454
+ if (blockloop)
4455
+ return;
4456
+
4457
+ String texname = this.GetPigmentTexture();
4458
+
4459
+ if (texname.startsWith("sov"))
4460
+ {
4461
+ String[] s = texname.split("/");
4462
+
4463
+ String[] sname = s[1].split("Color.pn");
4464
+
4465
+ texname = sname[0];
4466
+
4467
+ if (sname.length > 1)
4468
+ {
4469
+ texname += "Color.jpg";
4470
+ }
4471
+
4472
+ this.SetPigmentTexture("sov/" + texname);
4473
+ }
4474
+
4475
+ texname = this.GetBumpTexture();
4476
+
4477
+ if (texname.startsWith("sov"))
4478
+ {
4479
+ String[] s = texname.split("/");
4480
+
4481
+ String[] sname = s[1].split("Bump.pn");
4482
+
4483
+ texname = sname[0];
4484
+
4485
+ if (sname.length > 1)
4486
+ {
4487
+ texname += "Bump.jpg";
4488
+ }
4489
+
4490
+ this.SetBumpTexture("sov/" + texname);
4491
+ }
4492
+
4493
+ for (int i=0; i<Size(); i++)
4494
+ {
4495
+ blockloop = true;
4496
+ get(i).RepairSOV();
4497
+ blockloop = false;
4498
+ }
4499
+ }
4500
+
42244501 void RepairTexture()
42254502 {
42264503 if (this instanceof FileObject || blockloop)
....@@ -4711,7 +4988,7 @@
47114988
47124989 cTreePath SelectLeaf(int indexcount, boolean deselect)
47134990 {
4714
- if (hide)
4991
+ if (hide || dontselect)
47154992 return null;
47164993
47174994 if (count <= 0)
....@@ -4735,9 +5012,17 @@
47355012 }
47365013 }
47375014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
47385023 cTreePath Select(int indexcount, boolean deselect)
47395024 {
4740
- if (hide)
5025
+ if (hide || dontselect)
47415026 return null;
47425027
47435028 if (count <= 0)
....@@ -4771,10 +5056,11 @@
47715056 if (leaf != null)
47725057 {
47735058 cTreePath tp = new cTreePath(this, leaf);
4774
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
47755061 {
47765062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4777
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
47785064 }
47795065
47805066 return tp;
....@@ -4791,6 +5077,7 @@
47915077
47925078 if (child == null)
47935079 continue;
5080
+
47945081 if (child.HasTransparency() && child.size() != 0)
47955082 {
47965083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4800,9 +5087,10 @@
48005087 if (leaf != null)
48015088 {
48025089 cTreePath tp = new cTreePath(this, leaf);
4803
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
48045092 {
4805
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
48065094 }
48075095
48085096 return tp;
....@@ -5363,6 +5651,43 @@
53635651 }
53645652 }
53655653
5654
+ UUID GetUUID()
5655
+ {
5656
+ if (uuid == null)
5657
+ {
5658
+ // Serial
5659
+ uuid = UUID.randomUUID();
5660
+ }
5661
+
5662
+ return uuid;
5663
+ }
5664
+
5665
+ Object3D GetObject(UUID uid)
5666
+ {
5667
+ if (blockloop)
5668
+ return null;
5669
+
5670
+ if (GetUUID().equals(uid))
5671
+ return this;
5672
+
5673
+ int nb = Size();
5674
+ for (int i = 0; i < nb; i++)
5675
+ {
5676
+ Object3D child = (Object3D) get(i);
5677
+
5678
+ if (child == null)
5679
+ continue;
5680
+
5681
+ blockloop = true;
5682
+ Object3D obj = child.GetObject(uid);
5683
+ blockloop = false;
5684
+ if (obj != null)
5685
+ return obj;
5686
+ }
5687
+
5688
+ return null;
5689
+ }
5690
+
53665691 void SetBumpTexture(String tex)
53675692 {
53685693 if (GetTextures() == null)
....@@ -5407,12 +5732,23 @@
54075732 boolean NeedSupport()
54085733 {
54095734 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54115736 // PROBLEM with CROWD!!
54125737 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135738 }
54145739
54155740 static boolean DEBUG_SELECTION = false;
5741
+
5742
+ boolean IsLive()
5743
+ {
5744
+ if (live)
5745
+ return true;
5746
+
5747
+ if (parent == null)
5748
+ return false;
5749
+
5750
+ return parent.IsLive();
5751
+ }
54165752
54175753 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54185754 {
....@@ -5424,7 +5760,7 @@
54245760 }
54255761
54265762 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5763
+ (hide || dontselect))
54285764 return;
54295765
54305766 if (name != null && name.contains("sclera"))
....@@ -5475,7 +5811,7 @@
54755811 support = support;
54765812
54775813 //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);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54795815
54805816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54815817 {
....@@ -5495,10 +5831,12 @@
54955831 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54965832
54975833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5498
- (touched || (bRep != null && bRep.displaylist <= 0)))
5834
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54995836 {
55005837 Globals.lighttouched = true;
55015838 } // all panes...
5839
+
55025840 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55035841 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55045842 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5626,6 +5964,7 @@
56265964 if (GetBRep() != null)
56275965 {
56285966 display.NextIndex();
5967
+
56295968 // vertex color conflict : gl.glCallList(list);
56305969 DrawNode(display, root, selected);
56315970 if (this instanceof BezierPatch)
....@@ -5666,7 +6005,28 @@
56666005 tex = GetTextures();
56676006 }
56686007
5669
- display.BindTextures(tex, texres);
6008
+ boolean failedPigment = false;
6009
+ boolean failedBump = false;
6010
+
6011
+ try
6012
+ {
6013
+ display.BindPigmentTexture(tex, texres);
6014
+ }
6015
+ catch (Exception e)
6016
+ {
6017
+ System.err.println("FAILED: " + this);
6018
+ failedPigment = true;
6019
+ }
6020
+
6021
+ try
6022
+ {
6023
+ display.BindBumpTexture(tex, texres);
6024
+ }
6025
+ catch (Exception e)
6026
+ {
6027
+ //System.err.println("FAILED: " + this);
6028
+ failedBump = true;
6029
+ }
56706030
56716031 if (!compiled)
56726032 {
....@@ -5688,7 +6048,11 @@
56886048 }
56896049 }
56906050
5691
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
56926056
56936057 display.PopMaterial(this, selected);
56946058 }
....@@ -5817,6 +6181,9 @@
58176181
58186182 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58196183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
58206187 if (hide)
58216188 return;
58226189 // shadow optimisation
....@@ -5942,6 +6309,9 @@
59426309 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59436310 return; // no shadow for transparent objects
59446311
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
6314
+
59456315 if (hide)
59466316 return;
59476317
....@@ -6055,6 +6425,11 @@
60556425 // dec 2012
60566426 new Exception().printStackTrace();
60576427 return;
6428
+ }
6429
+
6430
+ if (dontselect)
6431
+ {
6432
+ //bRep.GenerateNormalsMINE();
60586433 }
60596434
60606435 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6907,7 +7282,7 @@
69077282 spot.translate(32, 32);
69087283 spotw = spot.x + spot.width;
69097284 spoth = spot.y + spot.height;
6910
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
69117286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69127287 // if (CameraPane.Xmin > spot.x)
69137288 // {
....@@ -6925,11 +7300,12 @@
69257300 // {
69267301 // CameraPane.Ymax = spoth;
69277302 // }
6928
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6929
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7303
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7304
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69307305 spot.translate(0, -32);
6931
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
69327307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
+ info.g.setColor(Color.green);
69337309 // if (CameraPane.Xmin > spot.x)
69347310 // {
69357311 // CameraPane.Xmin = spot.x;
....@@ -6946,8 +7322,8 @@
69467322 // {
69477323 // CameraPane.Ymax = spoth;
69487324 // }
6949
- info.g.drawArc(boundary.x, boundary.y,
6950
- boundary.width, boundary.height, 0, 360);
7325
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
69517327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69527328 // if (CameraPane.Xmin > boundary.x)
69537329 // {
....@@ -6981,7 +7357,7 @@
69817357 startX = info.x;
69827358 startY = info.y;
69837359
6984
- hitSomething = 0;
7360
+ hitSomething = -1;
69857361 cVector origin = new cVector();
69867362 //LA.xformPos(origin, toParent, origin);
69877363 Rectangle spot = new Rectangle();
....@@ -7057,6 +7433,7 @@
70577433 //System.out.println("hitSomething = " + hitSomething);
70587434
70597435 double scale = 0.005f * info.camera.Distance();
7436
+
70607437 cVector xlate = new cVector();
70617438 //cVector xlate2 = new cVector();
70627439 switch (hitSomething)
....@@ -7205,24 +7582,27 @@
72057582
72067583 case hitScale: // scale
72077584 double hScale = (double) (info.x - centerPt.x) / 32;
7585
+ double sign = 1;
7586
+ if (hScale < 0)
7587
+ {
7588
+ sign = -1;
7589
+ }
7590
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72087591 if (hScale < 0.01)
72097592 {
7210
- hScale = 0.01;
7593
+ //hScale = 0.01;
72117594 }
7212
- hScale = Math.pow(hScale, scale * 50);
7213
- if (hScale < 0.01)
7214
- {
7215
- hScale = 0.01;
7216
- }
7595
+
72177596 double vScale = (double) (info.y - centerPt.y) / 32;
7218
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
72197599 {
7220
- vScale = 0.01;
7600
+ sign = -1;
72217601 }
7222
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72237603 if (vScale < 0.01)
72247604 {
7225
- vScale = 0.01;
7605
+ //vScale = 0.01;
72267606 }
72277607 LA.matCopy(startMat, toParent);
72287608 /**/
....@@ -7233,39 +7613,47 @@
72337613 }
72347614 /**/
72357615
7616
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7617
+
7618
+ if (totalScale < 0.01)
7619
+ {
7620
+ totalScale = 0.01;
7621
+ }
7622
+
72367623 switch (info.pane.RenderCamera().viewCode)
72377624 {
72387625 case 3: // '\001'
7239
- if (modified)
7626
+ if (modified || opposite)
72407627 {
72417628 //LA.matScale(toParent, 1, hScale, vScale);
7242
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
72437630 } // vScale, 1);
72447631 else
72457632 {
7246
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72477635 } // vScale, 1);
72487636 break;
72497637
72507638 case 2: // '\002'
7251
- if (modified)
7639
+ if (modified || opposite)
72527640 {
72537641 //LA.matScale(toParent, hScale, 1, vScale);
7254
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
72557643 } else
72567644 {
7257
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
72587646 }
72597647 break;
72607648
72617649 case 1: // '\003'
7262
- if (modified)
7650
+ if (modified || opposite)
72637651 {
72647652 //LA.matScale(toParent, hScale, vScale, 1);
7265
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
72667654 } else
72677655 {
7268
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
72697657 }
72707658 break;
72717659 }
....@@ -7406,7 +7794,7 @@
74067794 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74077795 } else
74087796 {
7409
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7797
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74107798 } // + super.toString();
74117799 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74127800
....@@ -7479,6 +7867,10 @@
74797867 editWindow = null;
74807868 } // ?
74817869 }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
7873
+ }
74827874 }
74837875
74847876 boolean root; // patch for edit windows
....@@ -7490,7 +7882,7 @@
74907882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74917883
74927884 Object3D /*Composite*/ parent;
7493
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74947886
74957887 double[][] toParent; // dynamic matrix
74967888 double[][] fromParent;
....@@ -7636,6 +8028,10 @@
76368028 }
76378029
76388030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
76398035 transient ObjectUI objectUI;
76408036 public static int povDepth = 0;
76418037 private static cVector tbMin = new cVector();
....@@ -7654,9 +8050,9 @@
76548050 private static cVector edge2 = new cVector();
76558051 //private static cVector norm = new cVector();
76568052 /*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;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
76608056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76618057 /*transient*/ private Point centerPt;
76628058 /*transient*/ private int startX;