Normand Briere
2019-06-23 8088590686a45e71278f9a52bb9cc37943dc0c37
Object3D.java
....@@ -14,11 +14,20 @@
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;
24
+
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
2231
2332 ScriptNode scriptnode;
2433
....@@ -100,64 +109,136 @@
100109
101110 // transient boolean reduced; // for morph reduction
102111
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105114
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
108117
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)
118
+ void SaveSupports()
121119 {
122
- bRep.SaveSupports();
123
- }
124
-
125
- for (int i = 0; i < Size(); i++)
126
- {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
130
- blockloop = true;
131
- child.SaveSupports();
132
- blockloop = false;
133
- }
134
-}
120
+ if (blockloop)
121
+ return;
135122
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
140125
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
147
- {
148
- bRep.RestoreSupports();
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
149143 }
150
-
151
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
152146 {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
159169 }
160
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
161242
162243 // MOCAP SUPPORT
163244 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +381,7 @@
300381 }
301382
302383 boolean live = false;
384
+ boolean dontselect = false;
303385 boolean hide = false;
304386 boolean link2master = false; // performs reset support/master at each frame
305387 boolean marked = false; // animation node
....@@ -481,12 +563,14 @@
481563 toParent = LA.newMatrix();
482564 fromParent = LA.newMatrix();
483565 }
566
+
484567 if (toParentMarked == null)
485568 {
486569 if (maxcount != 1)
487570 {
488571 new Exception().printStackTrace();
489572 }
573
+
490574 toParentMarked = LA.newMatrix();
491575 fromParentMarked = LA.newMatrix();
492576 }
....@@ -774,7 +858,7 @@
774858 if (step == 0)
775859 step = 1;
776860 if (maxcount == 0)
777
- maxcount = 2048; // 4;
861
+ maxcount = 128; // 2048; // 4;
778862 // if (acceleration == 0)
779863 // acceleration = 10;
780864 if (delay == 0) // serial
....@@ -797,7 +881,7 @@
797881
798882 if (marked && Globals.isLIVE() && live &&
799883 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
801885 currentframe != Globals.framecount)
802886 {
803887 currentframe = Globals.framecount;
....@@ -809,7 +893,8 @@
809893
810894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811895
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
813898 {
814899 countdown = 1;
815900 delay = speedup?8:1;
....@@ -912,6 +997,11 @@
912997 fromParent = null; // LA.newMatrix();
913998 bRep = null; // new BoundaryRep();
914999
1000
+ if (oname != null && oname.equals("LeftHand"))
1001
+ {
1002
+ name = oname;
1003
+ }
1004
+
9151005 /*
9161006 float hue = (float)Math.random();
9171007 Color col;
....@@ -954,7 +1044,7 @@
9541044
9551045 public Object clone()
9561046 {
957
- return GrafreeD.clone(this);
1047
+ return Grafreed.clone(this);
9581048 }
9591049
9601050 Object3D copyExpand()
....@@ -1470,7 +1560,7 @@
14701560 BoundaryRep.SEUIL = other.material.cameralight;
14711561
14721562 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1563
+ BoundaryRep.SEUIL /= 4; // 2;
14741564 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751565 }
14761566
....@@ -1729,7 +1819,7 @@
17291819 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301820 o.bRep = transientrep;
17311821 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1822
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331823 o.CreateMaterial();
17341824 o.SetAttributes(this, -1);
17351825 //parent
....@@ -1742,7 +1832,7 @@
17421832 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431833 o.bRep = bRep;
17441834 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1835
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461836 o.CreateMaterial();
17471837 //o.overwriteThis(this, -1);
17481838 o.SetAttributes(this, -1);
....@@ -1829,12 +1919,15 @@
18291919 if (obj.name == null)
18301920 continue; // can't be a null one
18311921
1922
+ // Try perfect match first.
18321923 if (n.equals(obj.name))
18331924 {
18341925 theobj = obj;
18351926 count++;
18361927 }
18371928 }
1929
+
1930
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381931
18391932 if (count != 1)
18401933 for (int i=Size(); --i>=0;)
....@@ -2294,6 +2387,10 @@
22942387 }
22952388 */
22962389 }
2390
+ else
2391
+ {
2392
+ //((ObjEditor)editWindow).SetupUI2(null);
2393
+ }
22972394 }
22982395
22992396 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2619,6 +2716,18 @@
26192716 //Touch();
26202717 }
26212718
2719
+ void GenNormalsMeshS()
2720
+ {
2721
+ selection.GenNormalsMesh();
2722
+// for (int i=0; i<selection.size(); i++)
2723
+// {
2724
+// Object3D selectee = (Object3D) selection.elementAt(i);
2725
+// selectee.GenNormals(crease);
2726
+// }
2727
+
2728
+ //Touch();
2729
+ }
2730
+
26222731 void ClearColorsS()
26232732 {
26242733 selection.ClearColors();
....@@ -2750,6 +2859,24 @@
27502859 if (child == null)
27512860 continue;
27522861 child.GenNormals(crease);
2862
+// Children().release(i);
2863
+ }
2864
+ blockloop = false;
2865
+ }
2866
+
2867
+ void GenNormalsMesh()
2868
+ {
2869
+ if (blockloop)
2870
+ return;
2871
+
2872
+ blockloop = true;
2873
+ GenNormalsMesh0();
2874
+ for (int i = 0; i < Children().Size(); i++)
2875
+ {
2876
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2877
+ if (child == null)
2878
+ continue;
2879
+ child.GenNormalsMesh();
27532880 // Children().release(i);
27542881 }
27552882 blockloop = false;
....@@ -2922,6 +3049,15 @@
29223049 }
29233050 }
29243051
3052
+ void GenNormalsMesh0()
3053
+ {
3054
+ if (bRep != null)
3055
+ {
3056
+ bRep.GenerateNormalsMesh();
3057
+ Touch();
3058
+ }
3059
+ }
3060
+
29253061 void GenNormalsMINE0()
29263062 {
29273063 if (bRep != null)
....@@ -2983,6 +3119,33 @@
29833119 blockloop = false;
29843120 }
29853121
3122
+ void TransformChildren()
3123
+ {
3124
+ if (toParent != null)
3125
+ {
3126
+ for (int i=Size(); --i>=0;)
3127
+ {
3128
+ Object3D v = get(i);
3129
+
3130
+ if (v.toParent == null)
3131
+ {
3132
+ v.toParent = LA.newMatrix();
3133
+ v.fromParent = LA.newMatrix();
3134
+ }
3135
+
3136
+// LA.matConcat(v.toParent, toParent, v.toParent);
3137
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3138
+ LA.matConcat(toParent, v.toParent, v.toParent);
3139
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3140
+ }
3141
+
3142
+ toParent = null; // LA.matIdentity(toParent);
3143
+ fromParent = null; // LA.matIdentity(fromParent);
3144
+
3145
+ Touch();
3146
+ }
3147
+ }
3148
+
29863149 void TransformGeometry()
29873150 {
29883151 Object3D obj = this;
....@@ -3204,9 +3367,11 @@
32043367
32053368 BoundaryRep sup = bRep.support;
32063369 bRep.support = null;
3207
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3370
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083371 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3372
+
3373
+ while(temprep.SplitInTwo(reduction34, onlyone));
3374
+
32103375 bRep = temprep;
32113376 bRep.support = sup;
32123377 Touch();
....@@ -3343,7 +3508,8 @@
33433508 if (blockloop)
33443509 return;
33453510
3346
- if (marked || (bRep != null && material != null)) // borderline...
3511
+ if (//marked || // does not make sense
3512
+ (bRep != null || material != null)) // borderline...
33473513 live = h;
33483514
33493515 for (int i = 0; i < Size(); i++)
....@@ -3364,7 +3530,8 @@
33643530 return;
33653531
33663532 //if (bRep != null)
3367
- if (marked || (bRep != null && material != null)) // borderline...
3533
+ if (//marked || // does not make sense
3534
+ (bRep != null || material != null)) // borderline...
33683535 link2master = h;
33693536
33703537 for (int i = 0; i < Size(); i++)
....@@ -3384,7 +3551,8 @@
33843551 if (blockloop)
33853552 return;
33863553
3387
- if (marked || (bRep != null && material != null)) // borderline...
3554
+ if (//marked || // does not make sense
3555
+ (bRep != null || material != null)) // borderline...
33883556 hide = h;
33893557
33903558 for (int i = 0; i < Size(); i++)
....@@ -3404,7 +3572,7 @@
34043572 if (blockloop)
34053573 return;
34063574
3407
- if (bRep != null && material != null) // borderline...
3575
+ if (bRep != null || material != null) // borderline...
34083576 marked = h;
34093577
34103578 for (int i = 0; i < Size(); i++)
....@@ -3414,6 +3582,46 @@
34143582 continue;
34153583 blockloop = true;
34163584 child.MarkLeaves(h);
3585
+ blockloop = false;
3586
+ // release(i);
3587
+ }
3588
+ }
3589
+
3590
+ void RewindLeaves(boolean h)
3591
+ {
3592
+ if (blockloop)
3593
+ return;
3594
+
3595
+ if (bRep != null || material != null) // borderline...
3596
+ rewind = h;
3597
+
3598
+ for (int i = 0; i < Size(); i++)
3599
+ {
3600
+ Object3D child = (Object3D) get(i); // reserve(i);
3601
+ if (child == null)
3602
+ continue;
3603
+ blockloop = true;
3604
+ child.RewindLeaves(h);
3605
+ blockloop = false;
3606
+ // release(i);
3607
+ }
3608
+ }
3609
+
3610
+ void RandomLeaves(boolean h)
3611
+ {
3612
+ if (blockloop)
3613
+ return;
3614
+
3615
+ if (bRep != null || material != null) // borderline...
3616
+ random = h;
3617
+
3618
+ for (int i = 0; i < Size(); i++)
3619
+ {
3620
+ Object3D child = (Object3D) get(i); // reserve(i);
3621
+ if (child == null)
3622
+ continue;
3623
+ blockloop = true;
3624
+ child.RandomLeaves(h);
34173625 blockloop = false;
34183626 // release(i);
34193627 }
....@@ -3728,7 +3936,7 @@
37283936 if (child == null)
37293937 continue;
37303938
3731
- if (GrafreeD.RENDERME > 0)
3939
+ if (Grafreed.RENDERME > 0)
37323940 {
37333941 if (child instanceof Merge)
37343942 ((Merge)child).renderme();
....@@ -3879,7 +4087,7 @@
38794087 if (child == null)
38804088 continue;
38814089
3882
- if (GrafreeD.RENDERME > 0)
4090
+ if (Grafreed.RENDERME > 0)
38834091 {
38844092 if (child instanceof Merge)
38854093 ((Merge)child).renderme();
....@@ -4074,7 +4282,7 @@
40744282 if (child == null)
40754283 continue;
40764284
4077
- if (GrafreeD.RENDERME > 0)
4285
+ if (Grafreed.RENDERME > 0)
40784286 {
40794287 if (child instanceof Merge)
40804288 ((Merge)child).renderme();
....@@ -4187,6 +4395,55 @@
41874395 {
41884396 blockloop = true;
41894397 get(i).RepairShadow();
4398
+ blockloop = false;
4399
+ }
4400
+ }
4401
+
4402
+ void RepairSOV()
4403
+ {
4404
+ if (blockloop)
4405
+ return;
4406
+
4407
+ String texname = this.GetPigmentTexture();
4408
+
4409
+ if (texname.startsWith("sov"))
4410
+ {
4411
+ String[] s = texname.split("/");
4412
+
4413
+ String[] sname = s[1].split("Color.pn");
4414
+
4415
+ texname = sname[0];
4416
+
4417
+ if (sname.length > 1)
4418
+ {
4419
+ texname += "Color.jpg";
4420
+ }
4421
+
4422
+ this.SetPigmentTexture("sov/" + texname);
4423
+ }
4424
+
4425
+ texname = this.GetBumpTexture();
4426
+
4427
+ if (texname.startsWith("sov"))
4428
+ {
4429
+ String[] s = texname.split("/");
4430
+
4431
+ String[] sname = s[1].split("Bump.pn");
4432
+
4433
+ texname = sname[0];
4434
+
4435
+ if (sname.length > 1)
4436
+ {
4437
+ texname += "Bump.jpg";
4438
+ }
4439
+
4440
+ this.SetBumpTexture("sov/" + texname);
4441
+ }
4442
+
4443
+ for (int i=0; i<Size(); i++)
4444
+ {
4445
+ blockloop = true;
4446
+ get(i).RepairSOV();
41904447 blockloop = false;
41914448 }
41924449 }
....@@ -4681,7 +4938,7 @@
46814938
46824939 cTreePath SelectLeaf(int indexcount, boolean deselect)
46834940 {
4684
- if (hide)
4941
+ if (hide || dontselect)
46854942 return null;
46864943
46874944 if (count <= 0)
....@@ -4707,7 +4964,7 @@
47074964
47084965 cTreePath Select(int indexcount, boolean deselect)
47094966 {
4710
- if (hide)
4967
+ if (hide || dontselect)
47114968 return null;
47124969
47134970 if (count <= 0)
....@@ -5333,6 +5590,43 @@
53335590 }
53345591 }
53355592
5593
+ UUID GetUUID()
5594
+ {
5595
+ if (uuid == null)
5596
+ {
5597
+ // Serial
5598
+ uuid = UUID.randomUUID();
5599
+ }
5600
+
5601
+ return uuid;
5602
+ }
5603
+
5604
+ Object3D GetObject(UUID uid)
5605
+ {
5606
+ if (blockloop)
5607
+ return null;
5608
+
5609
+ if (GetUUID().equals(uid))
5610
+ return this;
5611
+
5612
+ int nb = Size();
5613
+ for (int i = 0; i < nb; i++)
5614
+ {
5615
+ Object3D child = (Object3D) get(i);
5616
+
5617
+ if (child == null)
5618
+ continue;
5619
+
5620
+ blockloop = true;
5621
+ Object3D obj = child.GetObject(uid);
5622
+ blockloop = false;
5623
+ if (obj != null)
5624
+ return obj;
5625
+ }
5626
+
5627
+ return null;
5628
+ }
5629
+
53365630 void SetBumpTexture(String tex)
53375631 {
53385632 if (GetTextures() == null)
....@@ -5377,12 +5671,23 @@
53775671 boolean NeedSupport()
53785672 {
53795673 return
5380
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5674
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53815675 // PROBLEM with CROWD!!
5382
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5676
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53835677 }
53845678
53855679 static boolean DEBUG_SELECTION = false;
5680
+
5681
+ boolean IsLive()
5682
+ {
5683
+ if (live)
5684
+ return true;
5685
+
5686
+ if (parent == null)
5687
+ return false;
5688
+
5689
+ return parent.IsLive();
5690
+ }
53865691
53875692 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53885693 {
....@@ -5394,7 +5699,7 @@
53945699 }
53955700
53965701 if (display.DrawMode() == iCameraPane.SELECTION &&
5397
- hide)
5702
+ (hide || dontselect))
53985703 return;
53995704
54005705 if (name != null && name.contains("sclera"))
....@@ -5445,7 +5750,7 @@
54455750 support = support;
54465751
54475752 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5448
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5753
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54495754
54505755 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54515756 {
....@@ -5465,10 +5770,12 @@
54655770 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54665771
54675772 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5468
- (touched || (bRep != null && bRep.displaylist <= 0)))
5773
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
54695775 {
54705776 Globals.lighttouched = true;
54715777 } // all panes...
5778
+
54725779 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54735780 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54745781 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5636,7 +5943,28 @@
56365943 tex = GetTextures();
56375944 }
56385945
5639
- display.BindTextures(tex, texres);
5946
+ boolean failedPigment = false;
5947
+ boolean failedBump = false;
5948
+
5949
+ try
5950
+ {
5951
+ display.BindPigmentTexture(tex, texres);
5952
+ }
5953
+ catch (Exception e)
5954
+ {
5955
+ System.err.println("FAILED: " + this);
5956
+ failedPigment = true;
5957
+ }
5958
+
5959
+ try
5960
+ {
5961
+ display.BindBumpTexture(tex, texres);
5962
+ }
5963
+ catch (Exception e)
5964
+ {
5965
+ //System.err.println("FAILED: " + this);
5966
+ failedBump = true;
5967
+ }
56405968
56415969 if (!compiled)
56425970 {
....@@ -5658,7 +5986,11 @@
56585986 }
56595987 }
56605988
5661
- display.ReleaseTextures(tex);
5989
+ if (!failedBump)
5990
+ display.ReleaseBumpTexture(tex);
5991
+
5992
+ if (!failedPigment)
5993
+ display.ReleasePigmentTexture(tex);
56625994
56635995 display.PopMaterial(this, selected);
56645996 }
....@@ -5787,6 +6119,9 @@
57876119
57886120 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57896121 {
6122
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6123
+ return;
6124
+
57906125 if (hide)
57916126 return;
57926127 // shadow optimisation
....@@ -5912,6 +6247,9 @@
59126247 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59136248 return; // no shadow for transparent objects
59146249
6250
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6251
+ return;
6252
+
59156253 if (hide)
59166254 return;
59176255
....@@ -6025,6 +6363,11 @@
60256363 // dec 2012
60266364 new Exception().printStackTrace();
60276365 return;
6366
+ }
6367
+
6368
+ if (dontselect)
6369
+ {
6370
+ //bRep.GenerateNormalsMINE();
60286371 }
60296372
60306373 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6877,7 +7220,7 @@
68777220 spot.translate(32, 32);
68787221 spotw = spot.x + spot.width;
68797222 spoth = spot.y + spot.height;
6880
- info.g.setColor(Color.blue);
7223
+ info.g.setColor(Color.cyan);
68817224 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68827225 // if (CameraPane.Xmin > spot.x)
68837226 // {
....@@ -6895,11 +7238,12 @@
68957238 // {
68967239 // CameraPane.Ymax = spoth;
68977240 // }
6898
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6899
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7241
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7242
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69007243 spot.translate(0, -32);
6901
- info.g.setColor(Color.green);
7244
+ info.g.setColor(Color.yellow);
69027245 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
+ info.g.setColor(Color.green);
69037247 // if (CameraPane.Xmin > spot.x)
69047248 // {
69057249 // CameraPane.Xmin = spot.x;
....@@ -6951,7 +7295,7 @@
69517295 startX = info.x;
69527296 startY = info.y;
69537297
6954
- hitSomething = 0;
7298
+ hitSomething = -1;
69557299 cVector origin = new cVector();
69567300 //LA.xformPos(origin, toParent, origin);
69577301 Rectangle spot = new Rectangle();
....@@ -7027,6 +7371,7 @@
70277371 //System.out.println("hitSomething = " + hitSomething);
70287372
70297373 double scale = 0.005f * info.camera.Distance();
7374
+
70307375 cVector xlate = new cVector();
70317376 //cVector xlate2 = new cVector();
70327377 switch (hitSomething)
....@@ -7175,24 +7520,27 @@
71757520
71767521 case hitScale: // scale
71777522 double hScale = (double) (info.x - centerPt.x) / 32;
7523
+ double sign = 1;
7524
+ if (hScale < 0)
7525
+ {
7526
+ sign = -1;
7527
+ }
7528
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71787529 if (hScale < 0.01)
71797530 {
7180
- hScale = 0.01;
7531
+ //hScale = 0.01;
71817532 }
7182
- hScale = Math.pow(hScale, scale * 50);
7183
- if (hScale < 0.01)
7184
- {
7185
- hScale = 0.01;
7186
- }
7533
+
71877534 double vScale = (double) (info.y - centerPt.y) / 32;
7188
- if (vScale < 0.01)
7535
+ sign = 1;
7536
+ if (vScale < 0)
71897537 {
7190
- vScale = 0.01;
7538
+ sign = -1;
71917539 }
7192
- vScale = Math.pow(vScale, scale * 50);
7540
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71937541 if (vScale < 0.01)
71947542 {
7195
- vScale = 0.01;
7543
+ //vScale = 0.01;
71967544 }
71977545 LA.matCopy(startMat, toParent);
71987546 /**/
....@@ -7203,39 +7551,47 @@
72037551 }
72047552 /**/
72057553
7554
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7555
+
7556
+ if (totalScale < 0.01)
7557
+ {
7558
+ totalScale = 0.01;
7559
+ }
7560
+
72067561 switch (info.pane.RenderCamera().viewCode)
72077562 {
72087563 case 3: // '\001'
7209
- if (modified)
7564
+ if (modified || opposite)
72107565 {
72117566 //LA.matScale(toParent, 1, hScale, vScale);
7212
- LA.matScale(toParent, vScale, 1, 1);
7567
+ LA.matScale(toParent, totalScale, 1, 1);
72137568 } // vScale, 1);
72147569 else
72157570 {
7216
- LA.matScale(toParent, vScale, vScale, vScale);
7571
+ // EXCEPTION!
7572
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72177573 } // vScale, 1);
72187574 break;
72197575
72207576 case 2: // '\002'
7221
- if (modified)
7577
+ if (modified || opposite)
72227578 {
72237579 //LA.matScale(toParent, hScale, 1, vScale);
7224
- LA.matScale(toParent, 1, vScale, 1);
7580
+ LA.matScale(toParent, 1, totalScale, 1);
72257581 } else
72267582 {
7227
- LA.matScale(toParent, vScale, 1, vScale);
7583
+ LA.matScale(toParent, totalScale, 1, totalScale);
72287584 }
72297585 break;
72307586
72317587 case 1: // '\003'
7232
- if (modified)
7588
+ if (modified || opposite)
72337589 {
72347590 //LA.matScale(toParent, hScale, vScale, 1);
7235
- LA.matScale(toParent, 1, 1, vScale);
7591
+ LA.matScale(toParent, 1, 1, totalScale);
72367592 } else
72377593 {
7238
- LA.matScale(toParent, vScale, vScale, 1);
7594
+ LA.matScale(toParent, totalScale, totalScale, 1);
72397595 }
72407596 break;
72417597 }
....@@ -7368,14 +7724,22 @@
73687724 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73697725 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73707726 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7727
+
7728
+ String objname;
7729
+
73717730 if (false) //parent != null)
73727731 {
7373
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7732
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73747733 } else
73757734 {
7376
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7735
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73777736 } // + super.toString();
73787737 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7738
+
7739
+ if (!Globals.ADVANCED)
7740
+ return objname;
7741
+
7742
+ return objname + " " + System.identityHashCode(this);
73797743 }
73807744
73817745 public int hashCode()
....@@ -7441,6 +7805,10 @@
74417805 editWindow = null;
74427806 } // ?
74437807 }
7808
+ else
7809
+ {
7810
+ //editWindow.closeUI();
7811
+ }
74447812 }
74457813
74467814 boolean root; // patch for edit windows
....@@ -7452,7 +7820,7 @@
74527820 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74537821
74547822 Object3D /*Composite*/ parent;
7455
- Object3D /*Composite*/ fileparent;
7823
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74567824
74577825 double[][] toParent; // dynamic matrix
74587826 double[][] fromParent;
....@@ -7567,7 +7935,7 @@
75677935 {
75687936 assert(bRep != null);
75697937 if (!(support instanceof GenericJoint)) // support.bRep != null)
7570
- GrafreeD.Assert(support.bRep == bRep.support);
7938
+ Grafreed.Assert(support.bRep == bRep.support);
75717939 }
75727940 else
75737941 {
....@@ -7616,9 +7984,9 @@
76167984 private static cVector edge2 = new cVector();
76177985 //private static cVector norm = new cVector();
76187986 /*transient private*/ int hitSomething;
7619
- private static final int hitCenter = 1;
7620
- private static final int hitScale = 2;
7621
- private static final int hitRotate = 3;
7987
+ static final int hitCenter = 1;
7988
+ static final int hitScale = 2;
7989
+ static final int hitRotate = 3;
76227990 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76237991 /*transient*/ private Point centerPt;
76247992 /*transient*/ private int startX;