Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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 &&
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
....@@ -912,6 +1043,11 @@
9121043 fromParent = null; // LA.newMatrix();
9131044 bRep = null; // new BoundaryRep();
9141045
1046
+ if (oname != null && oname.equals("LeftHand"))
1047
+ {
1048
+ name = oname;
1049
+ }
1050
+
9151051 /*
9161052 float hue = (float)Math.random();
9171053 Color col;
....@@ -1276,6 +1412,7 @@
12761412 toParent = LA.newMatrix();
12771413 fromParent = LA.newMatrix();
12781414 }
1415
+
12791416 LA.matCopy(other.toParent, toParent);
12801417 LA.matCopy(other.fromParent, fromParent);
12811418
....@@ -1470,7 +1607,7 @@
14701607 BoundaryRep.SEUIL = other.material.cameralight;
14711608
14721609 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1610
+ BoundaryRep.SEUIL /= 4; // 2;
14741611 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751612 }
14761613
....@@ -1829,12 +1966,15 @@
18291966 if (obj.name == null)
18301967 continue; // can't be a null one
18311968
1969
+ // Try perfect match first.
18321970 if (n.equals(obj.name))
18331971 {
18341972 theobj = obj;
18351973 count++;
18361974 }
18371975 }
1976
+
1977
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381978
18391979 if (count != 1)
18401980 for (int i=Size(); --i>=0;)
....@@ -2294,6 +2434,10 @@
22942434 }
22952435 */
22962436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
22972441 }
22982442
22992443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2335,6 +2479,14 @@
23352479 {
23362480 editWindow.refreshContents();
23372481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
23382490 //if (parent != null)
23392491 //parent.refreshEditWindow();
23402492 }
....@@ -2619,6 +2771,18 @@
26192771 //Touch();
26202772 }
26212773
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
+
26222786 void ClearColorsS()
26232787 {
26242788 selection.ClearColors();
....@@ -2750,6 +2914,24 @@
27502914 if (child == null)
27512915 continue;
27522916 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();
27532935 // Children().release(i);
27542936 }
27552937 blockloop = false;
....@@ -2922,6 +3104,15 @@
29223104 }
29233105 }
29243106
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
3112
+ Touch();
3113
+ }
3114
+ }
3115
+
29253116 void GenNormalsMINE0()
29263117 {
29273118 if (bRep != null)
....@@ -2983,6 +3174,33 @@
29833174 blockloop = false;
29843175 }
29853176
3177
+ void TransformChildren()
3178
+ {
3179
+ if (toParent != null)
3180
+ {
3181
+ for (int i=Size(); --i>=0;)
3182
+ {
3183
+ Object3D v = get(i);
3184
+
3185
+ if (v.toParent == null)
3186
+ {
3187
+ v.toParent = LA.newMatrix();
3188
+ v.fromParent = LA.newMatrix();
3189
+ }
3190
+
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);
3195
+ }
3196
+
3197
+ toParent = null; // LA.matIdentity(toParent);
3198
+ fromParent = null; // LA.matIdentity(fromParent);
3199
+
3200
+ Touch();
3201
+ }
3202
+ }
3203
+
29863204 void TransformGeometry()
29873205 {
29883206 Object3D obj = this;
....@@ -3206,7 +3424,9 @@
32063424 bRep.support = null;
32073425 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083426 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3427
+
3428
+ while(temprep.SplitInTwo(reduction34, onlyone));
3429
+
32103430 bRep = temprep;
32113431 bRep.support = sup;
32123432 Touch();
....@@ -3343,7 +3563,8 @@
33433563 if (blockloop)
33443564 return;
33453565
3346
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
33473568 live = h;
33483569
33493570 for (int i = 0; i < Size(); i++)
....@@ -3364,7 +3585,8 @@
33643585 return;
33653586
33663587 //if (bRep != null)
3367
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
33683590 link2master = h;
33693591
33703592 for (int i = 0; i < Size(); i++)
....@@ -3384,7 +3606,8 @@
33843606 if (blockloop)
33853607 return;
33863608
3387
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
33883611 hide = h;
33893612
33903613 for (int i = 0; i < Size(); i++)
....@@ -3404,7 +3627,7 @@
34043627 if (blockloop)
34053628 return;
34063629
3407
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
34083631 marked = h;
34093632
34103633 for (int i = 0; i < Size(); i++)
....@@ -3414,6 +3637,46 @@
34143637 continue;
34153638 blockloop = true;
34163639 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);
34173680 blockloop = false;
34183681 // release(i);
34193682 }
....@@ -4191,6 +4454,55 @@
41914454 }
41924455 }
41934456
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
+
41944506 void RepairTexture()
41954507 {
41964508 if (this instanceof FileObject || blockloop)
....@@ -4681,7 +4993,7 @@
46814993
46824994 cTreePath SelectLeaf(int indexcount, boolean deselect)
46834995 {
4684
- if (hide)
4996
+ if (hide || dontselect)
46854997 return null;
46864998
46874999 if (count <= 0)
....@@ -4705,9 +5017,17 @@
47055017 }
47065018 }
47075019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
47085028 cTreePath Select(int indexcount, boolean deselect)
47095029 {
4710
- if (hide)
5030
+ if (hide || dontselect)
47115031 return null;
47125032
47135033 if (count <= 0)
....@@ -4741,10 +5061,11 @@
47415061 if (leaf != null)
47425062 {
47435063 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
47455066 {
47465067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4747
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
47485069 }
47495070
47505071 return tp;
....@@ -4761,6 +5082,7 @@
47615082
47625083 if (child == null)
47635084 continue;
5085
+
47645086 if (child.HasTransparency() && child.size() != 0)
47655087 {
47665088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4770,9 +5092,10 @@
47705092 if (leaf != null)
47715093 {
47725094 cTreePath tp = new cTreePath(this, leaf);
4773
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
47745097 {
4775
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
47765099 }
47775100
47785101 return tp;
....@@ -5333,6 +5656,43 @@
53335656 }
53345657 }
53355658
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
+
53365696 void SetBumpTexture(String tex)
53375697 {
53385698 if (GetTextures() == null)
....@@ -5377,12 +5737,23 @@
53775737 boolean NeedSupport()
53785738 {
53795739 return
5380
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53815741 // PROBLEM with CROWD!!
5382
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5742
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53835743 }
53845744
53855745 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
+ }
53865757
53875758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53885759 {
....@@ -5394,7 +5765,7 @@
53945765 }
53955766
53965767 if (display.DrawMode() == iCameraPane.SELECTION &&
5397
- hide)
5768
+ (hide || dontselect))
53985769 return;
53995770
54005771 if (name != null && name.contains("sclera"))
....@@ -5445,7 +5816,7 @@
54455816 support = support;
54465817
54475818 //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);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54495820
54505821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54515822 {
....@@ -5465,10 +5836,12 @@
54655836 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54665837
54675838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5468
- (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)))
54695841 {
54705842 Globals.lighttouched = true;
54715843 } // all panes...
5844
+
54725845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54735846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54745847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5596,6 +5969,7 @@
55965969 if (GetBRep() != null)
55975970 {
55985971 display.NextIndex();
5972
+
55995973 // vertex color conflict : gl.glCallList(list);
56005974 DrawNode(display, root, selected);
56015975 if (this instanceof BezierPatch)
....@@ -5636,7 +6010,28 @@
56366010 tex = GetTextures();
56376011 }
56386012
5639
- 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
+ }
56406035
56416036 if (!compiled)
56426037 {
....@@ -5658,7 +6053,11 @@
56586053 }
56596054 }
56606055
5661
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
56626061
56636062 display.PopMaterial(this, selected);
56646063 }
....@@ -5787,6 +6186,9 @@
57876186
57886187 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57896188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
57906192 if (hide)
57916193 return;
57926194 // shadow optimisation
....@@ -5912,6 +6314,9 @@
59126314 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59136315 return; // no shadow for transparent objects
59146316
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
6319
+
59156320 if (hide)
59166321 return;
59176322
....@@ -6025,6 +6430,11 @@
60256430 // dec 2012
60266431 new Exception().printStackTrace();
60276432 return;
6433
+ }
6434
+
6435
+ if (dontselect)
6436
+ {
6437
+ //bRep.GenerateNormalsMINE();
60286438 }
60296439
60306440 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6877,7 +7287,7 @@
68777287 spot.translate(32, 32);
68787288 spotw = spot.x + spot.width;
68797289 spoth = spot.y + spot.height;
6880
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
68817291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68827292 // if (CameraPane.Xmin > spot.x)
68837293 // {
....@@ -6895,11 +7305,12 @@
68957305 // {
68967306 // CameraPane.Ymax = spoth;
68977307 // }
6898
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6899
- 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
69007310 spot.translate(0, -32);
6901
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
69027312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
+ info.g.setColor(Color.green);
69037314 // if (CameraPane.Xmin > spot.x)
69047315 // {
69057316 // CameraPane.Xmin = spot.x;
....@@ -6916,8 +7327,8 @@
69167327 // {
69177328 // CameraPane.Ymax = spoth;
69187329 // }
6919
- info.g.drawArc(boundary.x, boundary.y,
6920
- 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);
69217332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69227333 // if (CameraPane.Xmin > boundary.x)
69237334 // {
....@@ -6951,7 +7362,7 @@
69517362 startX = info.x;
69527363 startY = info.y;
69537364
6954
- hitSomething = 0;
7365
+ hitSomething = -1;
69557366 cVector origin = new cVector();
69567367 //LA.xformPos(origin, toParent, origin);
69577368 Rectangle spot = new Rectangle();
....@@ -7027,6 +7438,7 @@
70277438 //System.out.println("hitSomething = " + hitSomething);
70287439
70297440 double scale = 0.005f * info.camera.Distance();
7441
+
70307442 cVector xlate = new cVector();
70317443 //cVector xlate2 = new cVector();
70327444 switch (hitSomething)
....@@ -7175,24 +7587,27 @@
71757587
71767588 case hitScale: // scale
71777589 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);
71787596 if (hScale < 0.01)
71797597 {
7180
- hScale = 0.01;
7598
+ //hScale = 0.01;
71817599 }
7182
- hScale = Math.pow(hScale, scale * 50);
7183
- if (hScale < 0.01)
7184
- {
7185
- hScale = 0.01;
7186
- }
7600
+
71877601 double vScale = (double) (info.y - centerPt.y) / 32;
7188
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
71897604 {
7190
- vScale = 0.01;
7605
+ sign = -1;
71917606 }
7192
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71937608 if (vScale < 0.01)
71947609 {
7195
- vScale = 0.01;
7610
+ //vScale = 0.01;
71967611 }
71977612 LA.matCopy(startMat, toParent);
71987613 /**/
....@@ -7203,39 +7618,47 @@
72037618 }
72047619 /**/
72057620
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
+
72067628 switch (info.pane.RenderCamera().viewCode)
72077629 {
72087630 case 3: // '\001'
7209
- if (modified)
7631
+ if (modified || opposite)
72107632 {
72117633 //LA.matScale(toParent, 1, hScale, vScale);
7212
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
72137635 } // vScale, 1);
72147636 else
72157637 {
7216
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72177640 } // vScale, 1);
72187641 break;
72197642
72207643 case 2: // '\002'
7221
- if (modified)
7644
+ if (modified || opposite)
72227645 {
72237646 //LA.matScale(toParent, hScale, 1, vScale);
7224
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
72257648 } else
72267649 {
7227
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
72287651 }
72297652 break;
72307653
72317654 case 1: // '\003'
7232
- if (modified)
7655
+ if (modified || opposite)
72337656 {
72347657 //LA.matScale(toParent, hScale, vScale, 1);
7235
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
72367659 } else
72377660 {
7238
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
72397662 }
72407663 break;
72417664 }
....@@ -7368,14 +7791,22 @@
73687791 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73697792 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73707793 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7794
+
7795
+ String objname;
7796
+
73717797 if (false) //parent != null)
73727798 {
7373
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7799
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73747800 } else
73757801 {
7376
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7802
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73777803 } // + super.toString();
73787804 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7805
+
7806
+ if (!Globals.ADVANCED)
7807
+ return objname;
7808
+
7809
+ return objname + " " + System.identityHashCode(this);
73797810 }
73807811
73817812 public int hashCode()
....@@ -7441,6 +7872,10 @@
74417872 editWindow = null;
74427873 } // ?
74437874 }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
7878
+ }
74447879 }
74457880
74467881 boolean root; // patch for edit windows
....@@ -7452,7 +7887,7 @@
74527887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74537888
74547889 Object3D /*Composite*/ parent;
7455
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74567891
74577892 double[][] toParent; // dynamic matrix
74587893 double[][] fromParent;
....@@ -7598,6 +8033,10 @@
75988033 }
75998034
76008035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
76018040 transient ObjectUI objectUI;
76028041 public static int povDepth = 0;
76038042 private static cVector tbMin = new cVector();
....@@ -7616,9 +8055,9 @@
76168055 private static cVector edge2 = new cVector();
76178056 //private static cVector norm = new cVector();
76188057 /*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;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
76228061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76238062 /*transient*/ private Point centerPt;
76248063 /*transient*/ private int startX;