Normand Briere
2019-06-26 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1
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,143 @@
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();
120
+ if (blockloop)
121
+ return;
122
+
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
125
+
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
+ }
123143 }
124
-
125
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
126146 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
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
+ }
169
+ }
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("copy of " + this.name);
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
+ if (blockloop)
223
+ return;
224
+
130225 blockloop = true;
131
- child.SaveSupports();
226
+
227
+ Object3D o = hashtable.get(GetUUID());
228
+
229
+ RestoreBigData(o);
230
+
231
+ //hashtable.remove(GetUUID());
232
+
233
+ for (int i=0; i<Size(); i++)
234
+ {
235
+ get(i).RestoreBigData(hashtable);
236
+ }
237
+
132238 blockloop = false;
133239 }
134
-}
135240
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)
241
+ void RestoreBigData(Object3D o)
147242 {
148
- bRep.RestoreSupports();
243
+ this.bRep = o.bRep;
244
+ if (this.bRep != null)
245
+ this.bRep.support = o.transientrep;
246
+ // this.support = o.support;
247
+ // this.fileparent = o.fileparent;
149248 }
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
-}
161249
162250 // MOCAP SUPPORT
163251 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +388,7 @@
300388 }
301389
302390 boolean live = false;
391
+ boolean dontselect = false;
303392 boolean hide = false;
304393 boolean link2master = false; // performs reset support/master at each frame
305394 boolean marked = false; // animation node
....@@ -481,12 +570,14 @@
481570 toParent = LA.newMatrix();
482571 fromParent = LA.newMatrix();
483572 }
573
+
484574 if (toParentMarked == null)
485575 {
486576 if (maxcount != 1)
487577 {
488578 new Exception().printStackTrace();
489579 }
580
+
490581 toParentMarked = LA.newMatrix();
491582 fromParentMarked = LA.newMatrix();
492583 }
....@@ -774,7 +865,7 @@
774865 if (step == 0)
775866 step = 1;
776867 if (maxcount == 0)
777
- maxcount = 2048; // 4;
868
+ maxcount = 128; // 2048; // 4;
778869 // if (acceleration == 0)
779870 // acceleration = 10;
780871 if (delay == 0) // serial
....@@ -797,7 +888,7 @@
797888
798889 if (marked && Globals.isLIVE() && live &&
799890 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
891
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801892 currentframe != Globals.framecount)
802893 {
803894 currentframe = Globals.framecount;
....@@ -809,7 +900,8 @@
809900
810901 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811902
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
903
+ if (transformcount*factor >= maxcount && (rewind || random) ||
904
+ (step == 1 && changedir))
813905 {
814906 countdown = 1;
815907 delay = speedup?8:1;
....@@ -881,6 +973,7 @@
881973 if (material == null || material.multiply)
882974 return true;
883975
976
+ // Transparent objects are dynamic because we have to sort the triangles.
884977 return material.opacity > 0.99;
885978 }
886979
....@@ -912,6 +1005,11 @@
9121005 fromParent = null; // LA.newMatrix();
9131006 bRep = null; // new BoundaryRep();
9141007
1008
+ if (oname != null && oname.equals("LeftHand"))
1009
+ {
1010
+ name = oname;
1011
+ }
1012
+
9151013 /*
9161014 float hue = (float)Math.random();
9171015 Color col;
....@@ -954,7 +1052,7 @@
9541052
9551053 public Object clone()
9561054 {
957
- return GrafreeD.clone(this);
1055
+ return Grafreed.clone(this);
9581056 }
9591057
9601058 Object3D copyExpand()
....@@ -1470,7 +1568,7 @@
14701568 BoundaryRep.SEUIL = other.material.cameralight;
14711569
14721570 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1571
+ BoundaryRep.SEUIL /= 4; // 2;
14741572 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751573 }
14761574
....@@ -1729,7 +1827,7 @@
17291827 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301828 o.bRep = transientrep;
17311829 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1830
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331831 o.CreateMaterial();
17341832 o.SetAttributes(this, -1);
17351833 //parent
....@@ -1742,7 +1840,7 @@
17421840 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431841 o.bRep = bRep;
17441842 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1843
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461844 o.CreateMaterial();
17471845 //o.overwriteThis(this, -1);
17481846 o.SetAttributes(this, -1);
....@@ -1829,12 +1927,15 @@
18291927 if (obj.name == null)
18301928 continue; // can't be a null one
18311929
1930
+ // Try perfect match first.
18321931 if (n.equals(obj.name))
18331932 {
18341933 theobj = obj;
18351934 count++;
18361935 }
18371936 }
1937
+
1938
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381939
18391940 if (count != 1)
18401941 for (int i=Size(); --i>=0;)
....@@ -2294,6 +2395,10 @@
22942395 }
22952396 */
22962397 }
2398
+ else
2399
+ {
2400
+ //((ObjEditor)editWindow).SetupUI2(null);
2401
+ }
22972402 }
22982403
22992404 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2335,6 +2440,14 @@
23352440 {
23362441 editWindow.refreshContents();
23372442 }
2443
+ else
2444
+ {
2445
+ if (manipWindow != null)
2446
+ {
2447
+ manipWindow.refreshContents();
2448
+ }
2449
+ }
2450
+
23382451 //if (parent != null)
23392452 //parent.refreshEditWindow();
23402453 }
....@@ -2619,6 +2732,18 @@
26192732 //Touch();
26202733 }
26212734
2735
+ void GenNormalsMeshS()
2736
+ {
2737
+ selection.GenNormalsMesh();
2738
+// for (int i=0; i<selection.size(); i++)
2739
+// {
2740
+// Object3D selectee = (Object3D) selection.elementAt(i);
2741
+// selectee.GenNormals(crease);
2742
+// }
2743
+
2744
+ //Touch();
2745
+ }
2746
+
26222747 void ClearColorsS()
26232748 {
26242749 selection.ClearColors();
....@@ -2750,6 +2875,24 @@
27502875 if (child == null)
27512876 continue;
27522877 child.GenNormals(crease);
2878
+// Children().release(i);
2879
+ }
2880
+ blockloop = false;
2881
+ }
2882
+
2883
+ void GenNormalsMesh()
2884
+ {
2885
+ if (blockloop)
2886
+ return;
2887
+
2888
+ blockloop = true;
2889
+ GenNormalsMesh0();
2890
+ for (int i = 0; i < Children().Size(); i++)
2891
+ {
2892
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2893
+ if (child == null)
2894
+ continue;
2895
+ child.GenNormalsMesh();
27532896 // Children().release(i);
27542897 }
27552898 blockloop = false;
....@@ -2922,6 +3065,15 @@
29223065 }
29233066 }
29243067
3068
+ void GenNormalsMesh0()
3069
+ {
3070
+ if (bRep != null)
3071
+ {
3072
+ bRep.GenerateNormalsMesh();
3073
+ Touch();
3074
+ }
3075
+ }
3076
+
29253077 void GenNormalsMINE0()
29263078 {
29273079 if (bRep != null)
....@@ -2983,6 +3135,33 @@
29833135 blockloop = false;
29843136 }
29853137
3138
+ void TransformChildren()
3139
+ {
3140
+ if (toParent != null)
3141
+ {
3142
+ for (int i=Size(); --i>=0;)
3143
+ {
3144
+ Object3D v = get(i);
3145
+
3146
+ if (v.toParent == null)
3147
+ {
3148
+ v.toParent = LA.newMatrix();
3149
+ v.fromParent = LA.newMatrix();
3150
+ }
3151
+
3152
+// LA.matConcat(v.toParent, toParent, v.toParent);
3153
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3154
+ LA.matConcat(toParent, v.toParent, v.toParent);
3155
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3156
+ }
3157
+
3158
+ toParent = null; // LA.matIdentity(toParent);
3159
+ fromParent = null; // LA.matIdentity(fromParent);
3160
+
3161
+ Touch();
3162
+ }
3163
+ }
3164
+
29863165 void TransformGeometry()
29873166 {
29883167 Object3D obj = this;
....@@ -3204,9 +3383,11 @@
32043383
32053384 BoundaryRep sup = bRep.support;
32063385 bRep.support = null;
3207
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3386
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083387 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3388
+
3389
+ while(temprep.SplitInTwo(reduction34, onlyone));
3390
+
32103391 bRep = temprep;
32113392 bRep.support = sup;
32123393 Touch();
....@@ -3343,7 +3524,8 @@
33433524 if (blockloop)
33443525 return;
33453526
3346
- if (marked || (bRep != null && material != null)) // borderline...
3527
+ if (//marked || // does not make sense
3528
+ (bRep != null || material != null)) // borderline...
33473529 live = h;
33483530
33493531 for (int i = 0; i < Size(); i++)
....@@ -3364,7 +3546,8 @@
33643546 return;
33653547
33663548 //if (bRep != null)
3367
- if (marked || (bRep != null && material != null)) // borderline...
3549
+ if (//marked || // does not make sense
3550
+ (bRep != null || material != null)) // borderline...
33683551 link2master = h;
33693552
33703553 for (int i = 0; i < Size(); i++)
....@@ -3384,7 +3567,8 @@
33843567 if (blockloop)
33853568 return;
33863569
3387
- if (marked || (bRep != null && material != null)) // borderline...
3570
+ if (//marked || // does not make sense
3571
+ (bRep != null || material != null)) // borderline...
33883572 hide = h;
33893573
33903574 for (int i = 0; i < Size(); i++)
....@@ -3404,7 +3588,7 @@
34043588 if (blockloop)
34053589 return;
34063590
3407
- if (bRep != null && material != null) // borderline...
3591
+ if (bRep != null || material != null) // borderline...
34083592 marked = h;
34093593
34103594 for (int i = 0; i < Size(); i++)
....@@ -3414,6 +3598,46 @@
34143598 continue;
34153599 blockloop = true;
34163600 child.MarkLeaves(h);
3601
+ blockloop = false;
3602
+ // release(i);
3603
+ }
3604
+ }
3605
+
3606
+ void RewindLeaves(boolean h)
3607
+ {
3608
+ if (blockloop)
3609
+ return;
3610
+
3611
+ if (bRep != null || material != null) // borderline...
3612
+ rewind = h;
3613
+
3614
+ for (int i = 0; i < Size(); i++)
3615
+ {
3616
+ Object3D child = (Object3D) get(i); // reserve(i);
3617
+ if (child == null)
3618
+ continue;
3619
+ blockloop = true;
3620
+ child.RewindLeaves(h);
3621
+ blockloop = false;
3622
+ // release(i);
3623
+ }
3624
+ }
3625
+
3626
+ void RandomLeaves(boolean h)
3627
+ {
3628
+ if (blockloop)
3629
+ return;
3630
+
3631
+ if (bRep != null || material != null) // borderline...
3632
+ random = h;
3633
+
3634
+ for (int i = 0; i < Size(); i++)
3635
+ {
3636
+ Object3D child = (Object3D) get(i); // reserve(i);
3637
+ if (child == null)
3638
+ continue;
3639
+ blockloop = true;
3640
+ child.RandomLeaves(h);
34173641 blockloop = false;
34183642 // release(i);
34193643 }
....@@ -3728,7 +3952,7 @@
37283952 if (child == null)
37293953 continue;
37303954
3731
- if (GrafreeD.RENDERME > 0)
3955
+ if (Grafreed.RENDERME > 0)
37323956 {
37333957 if (child instanceof Merge)
37343958 ((Merge)child).renderme();
....@@ -3879,7 +4103,7 @@
38794103 if (child == null)
38804104 continue;
38814105
3882
- if (GrafreeD.RENDERME > 0)
4106
+ if (Grafreed.RENDERME > 0)
38834107 {
38844108 if (child instanceof Merge)
38854109 ((Merge)child).renderme();
....@@ -4074,7 +4298,7 @@
40744298 if (child == null)
40754299 continue;
40764300
4077
- if (GrafreeD.RENDERME > 0)
4301
+ if (Grafreed.RENDERME > 0)
40784302 {
40794303 if (child instanceof Merge)
40804304 ((Merge)child).renderme();
....@@ -4187,6 +4411,55 @@
41874411 {
41884412 blockloop = true;
41894413 get(i).RepairShadow();
4414
+ blockloop = false;
4415
+ }
4416
+ }
4417
+
4418
+ void RepairSOV()
4419
+ {
4420
+ if (blockloop)
4421
+ return;
4422
+
4423
+ String texname = this.GetPigmentTexture();
4424
+
4425
+ if (texname.startsWith("sov"))
4426
+ {
4427
+ String[] s = texname.split("/");
4428
+
4429
+ String[] sname = s[1].split("Color.pn");
4430
+
4431
+ texname = sname[0];
4432
+
4433
+ if (sname.length > 1)
4434
+ {
4435
+ texname += "Color.jpg";
4436
+ }
4437
+
4438
+ this.SetPigmentTexture("sov/" + texname);
4439
+ }
4440
+
4441
+ texname = this.GetBumpTexture();
4442
+
4443
+ if (texname.startsWith("sov"))
4444
+ {
4445
+ String[] s = texname.split("/");
4446
+
4447
+ String[] sname = s[1].split("Bump.pn");
4448
+
4449
+ texname = sname[0];
4450
+
4451
+ if (sname.length > 1)
4452
+ {
4453
+ texname += "Bump.jpg";
4454
+ }
4455
+
4456
+ this.SetBumpTexture("sov/" + texname);
4457
+ }
4458
+
4459
+ for (int i=0; i<Size(); i++)
4460
+ {
4461
+ blockloop = true;
4462
+ get(i).RepairSOV();
41904463 blockloop = false;
41914464 }
41924465 }
....@@ -4681,7 +4954,7 @@
46814954
46824955 cTreePath SelectLeaf(int indexcount, boolean deselect)
46834956 {
4684
- if (hide)
4957
+ if (hide || dontselect)
46854958 return null;
46864959
46874960 if (count <= 0)
....@@ -4705,9 +4978,17 @@
47054978 }
47064979 }
47074980
4981
+ ObjEditor GetWindow()
4982
+ {
4983
+ if (editWindow != null)
4984
+ return editWindow;
4985
+
4986
+ return manipWindow;
4987
+ }
4988
+
47084989 cTreePath Select(int indexcount, boolean deselect)
47094990 {
4710
- if (hide)
4991
+ if (hide || dontselect)
47114992 return null;
47124993
47134994 if (count <= 0)
....@@ -4741,10 +5022,11 @@
47415022 if (leaf != null)
47425023 {
47435024 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5025
+ ObjEditor window = GetWindow();
5026
+ if (window != null)
47455027 {
47465028 //System.out.println("editWindow = " + editWindow + " vs " + this);
4747
- editWindow.Select(tp, deselect, true);
5029
+ window.Select(tp, deselect, true);
47485030 }
47495031
47505032 return tp;
....@@ -4770,9 +5052,10 @@
47705052 if (leaf != null)
47715053 {
47725054 cTreePath tp = new cTreePath(this, leaf);
4773
- if (editWindow != null)
5055
+ ObjEditor window = GetWindow();
5056
+ if (window != null)
47745057 {
4775
- editWindow.Select(tp, deselect, true);
5058
+ window.Select(tp, deselect, true);
47765059 }
47775060
47785061 return tp;
....@@ -5333,6 +5616,43 @@
53335616 }
53345617 }
53355618
5619
+ UUID GetUUID()
5620
+ {
5621
+ if (uuid == null)
5622
+ {
5623
+ // Serial
5624
+ uuid = UUID.randomUUID();
5625
+ }
5626
+
5627
+ return uuid;
5628
+ }
5629
+
5630
+ Object3D GetObject(UUID uid)
5631
+ {
5632
+ if (blockloop)
5633
+ return null;
5634
+
5635
+ if (GetUUID().equals(uid))
5636
+ return this;
5637
+
5638
+ int nb = Size();
5639
+ for (int i = 0; i < nb; i++)
5640
+ {
5641
+ Object3D child = (Object3D) get(i);
5642
+
5643
+ if (child == null)
5644
+ continue;
5645
+
5646
+ blockloop = true;
5647
+ Object3D obj = child.GetObject(uid);
5648
+ blockloop = false;
5649
+ if (obj != null)
5650
+ return obj;
5651
+ }
5652
+
5653
+ return null;
5654
+ }
5655
+
53365656 void SetBumpTexture(String tex)
53375657 {
53385658 if (GetTextures() == null)
....@@ -5377,12 +5697,23 @@
53775697 boolean NeedSupport()
53785698 {
53795699 return
5380
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5700
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53815701 // PROBLEM with CROWD!!
5382
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5702
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53835703 }
53845704
53855705 static boolean DEBUG_SELECTION = false;
5706
+
5707
+ boolean IsLive()
5708
+ {
5709
+ if (live)
5710
+ return true;
5711
+
5712
+ if (parent == null)
5713
+ return false;
5714
+
5715
+ return parent.IsLive();
5716
+ }
53865717
53875718 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53885719 {
....@@ -5394,7 +5725,7 @@
53945725 }
53955726
53965727 if (display.DrawMode() == iCameraPane.SELECTION &&
5397
- hide)
5728
+ (hide || dontselect))
53985729 return;
53995730
54005731 if (name != null && name.contains("sclera"))
....@@ -5445,7 +5776,7 @@
54455776 support = support;
54465777
54475778 //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);
5779
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54495780
54505781 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54515782 {
....@@ -5465,10 +5796,12 @@
54655796 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54665797
54675798 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5468
- (touched || (bRep != null && bRep.displaylist <= 0)))
5799
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5800
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched || (bRep != null && bRep.displaylist <= 0)))
54695801 {
54705802 Globals.lighttouched = true;
54715803 } // all panes...
5804
+
54725805 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54735806 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54745807 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5636,7 +5969,28 @@
56365969 tex = GetTextures();
56375970 }
56385971
5639
- display.BindTextures(tex, texres);
5972
+ boolean failedPigment = false;
5973
+ boolean failedBump = false;
5974
+
5975
+ try
5976
+ {
5977
+ display.BindPigmentTexture(tex, texres);
5978
+ }
5979
+ catch (Exception e)
5980
+ {
5981
+ System.err.println("FAILED: " + this);
5982
+ failedPigment = true;
5983
+ }
5984
+
5985
+ try
5986
+ {
5987
+ display.BindBumpTexture(tex, texres);
5988
+ }
5989
+ catch (Exception e)
5990
+ {
5991
+ //System.err.println("FAILED: " + this);
5992
+ failedBump = true;
5993
+ }
56405994
56415995 if (!compiled)
56425996 {
....@@ -5658,7 +6012,11 @@
56586012 }
56596013 }
56606014
5661
- display.ReleaseTextures(tex);
6015
+ if (!failedBump)
6016
+ display.ReleaseBumpTexture(tex);
6017
+
6018
+ if (!failedPigment)
6019
+ display.ReleasePigmentTexture(tex);
56626020
56636021 display.PopMaterial(this, selected);
56646022 }
....@@ -5787,6 +6145,9 @@
57876145
57886146 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57896147 {
6148
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6149
+ return;
6150
+
57906151 if (hide)
57916152 return;
57926153 // shadow optimisation
....@@ -5912,6 +6273,9 @@
59126273 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59136274 return; // no shadow for transparent objects
59146275
6276
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6277
+ return;
6278
+
59156279 if (hide)
59166280 return;
59176281
....@@ -6025,6 +6389,11 @@
60256389 // dec 2012
60266390 new Exception().printStackTrace();
60276391 return;
6392
+ }
6393
+
6394
+ if (dontselect)
6395
+ {
6396
+ //bRep.GenerateNormalsMINE();
60286397 }
60296398
60306399 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6877,7 +7246,7 @@
68777246 spot.translate(32, 32);
68787247 spotw = spot.x + spot.width;
68797248 spoth = spot.y + spot.height;
6880
- info.g.setColor(Color.blue);
7249
+ info.g.setColor(Color.cyan);
68817250 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68827251 // if (CameraPane.Xmin > spot.x)
68837252 // {
....@@ -6895,11 +7264,12 @@
68957264 // {
68967265 // CameraPane.Ymax = spoth;
68977266 // }
6898
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6899
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7267
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7268
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69007269 spot.translate(0, -32);
6901
- info.g.setColor(Color.green);
7270
+ info.g.setColor(Color.yellow);
69027271 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7272
+ info.g.setColor(Color.green);
69037273 // if (CameraPane.Xmin > spot.x)
69047274 // {
69057275 // CameraPane.Xmin = spot.x;
....@@ -6951,7 +7321,7 @@
69517321 startX = info.x;
69527322 startY = info.y;
69537323
6954
- hitSomething = 0;
7324
+ hitSomething = -1;
69557325 cVector origin = new cVector();
69567326 //LA.xformPos(origin, toParent, origin);
69577327 Rectangle spot = new Rectangle();
....@@ -7027,6 +7397,7 @@
70277397 //System.out.println("hitSomething = " + hitSomething);
70287398
70297399 double scale = 0.005f * info.camera.Distance();
7400
+
70307401 cVector xlate = new cVector();
70317402 //cVector xlate2 = new cVector();
70327403 switch (hitSomething)
....@@ -7175,24 +7546,27 @@
71757546
71767547 case hitScale: // scale
71777548 double hScale = (double) (info.x - centerPt.x) / 32;
7549
+ double sign = 1;
7550
+ if (hScale < 0)
7551
+ {
7552
+ sign = -1;
7553
+ }
7554
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71787555 if (hScale < 0.01)
71797556 {
7180
- hScale = 0.01;
7557
+ //hScale = 0.01;
71817558 }
7182
- hScale = Math.pow(hScale, scale * 50);
7183
- if (hScale < 0.01)
7184
- {
7185
- hScale = 0.01;
7186
- }
7559
+
71877560 double vScale = (double) (info.y - centerPt.y) / 32;
7188
- if (vScale < 0.01)
7561
+ sign = 1;
7562
+ if (vScale < 0)
71897563 {
7190
- vScale = 0.01;
7564
+ sign = -1;
71917565 }
7192
- vScale = Math.pow(vScale, scale * 50);
7566
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71937567 if (vScale < 0.01)
71947568 {
7195
- vScale = 0.01;
7569
+ //vScale = 0.01;
71967570 }
71977571 LA.matCopy(startMat, toParent);
71987572 /**/
....@@ -7203,39 +7577,47 @@
72037577 }
72047578 /**/
72057579
7580
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7581
+
7582
+ if (totalScale < 0.01)
7583
+ {
7584
+ totalScale = 0.01;
7585
+ }
7586
+
72067587 switch (info.pane.RenderCamera().viewCode)
72077588 {
72087589 case 3: // '\001'
7209
- if (modified)
7590
+ if (modified || opposite)
72107591 {
72117592 //LA.matScale(toParent, 1, hScale, vScale);
7212
- LA.matScale(toParent, vScale, 1, 1);
7593
+ LA.matScale(toParent, totalScale, 1, 1);
72137594 } // vScale, 1);
72147595 else
72157596 {
7216
- LA.matScale(toParent, vScale, vScale, vScale);
7597
+ // EXCEPTION!
7598
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72177599 } // vScale, 1);
72187600 break;
72197601
72207602 case 2: // '\002'
7221
- if (modified)
7603
+ if (modified || opposite)
72227604 {
72237605 //LA.matScale(toParent, hScale, 1, vScale);
7224
- LA.matScale(toParent, 1, vScale, 1);
7606
+ LA.matScale(toParent, 1, totalScale, 1);
72257607 } else
72267608 {
7227
- LA.matScale(toParent, vScale, 1, vScale);
7609
+ LA.matScale(toParent, totalScale, 1, totalScale);
72287610 }
72297611 break;
72307612
72317613 case 1: // '\003'
7232
- if (modified)
7614
+ if (modified || opposite)
72337615 {
72347616 //LA.matScale(toParent, hScale, vScale, 1);
7235
- LA.matScale(toParent, 1, 1, vScale);
7617
+ LA.matScale(toParent, 1, 1, totalScale);
72367618 } else
72377619 {
7238
- LA.matScale(toParent, vScale, vScale, 1);
7620
+ LA.matScale(toParent, totalScale, totalScale, 1);
72397621 }
72407622 break;
72417623 }
....@@ -7368,14 +7750,22 @@
73687750 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73697751 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73707752 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7753
+
7754
+ String objname;
7755
+
73717756 if (false) //parent != null)
73727757 {
7373
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7758
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73747759 } else
73757760 {
7376
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7761
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73777762 } // + super.toString();
73787763 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7764
+
7765
+ if (!Globals.ADVANCED)
7766
+ return objname;
7767
+
7768
+ return objname + " " + System.identityHashCode(this);
73797769 }
73807770
73817771 public int hashCode()
....@@ -7441,6 +7831,10 @@
74417831 editWindow = null;
74427832 } // ?
74437833 }
7834
+ else
7835
+ {
7836
+ //editWindow.closeUI();
7837
+ }
74447838 }
74457839
74467840 boolean root; // patch for edit windows
....@@ -7452,7 +7846,7 @@
74527846 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74537847
74547848 Object3D /*Composite*/ parent;
7455
- Object3D /*Composite*/ fileparent;
7849
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74567850
74577851 double[][] toParent; // dynamic matrix
74587852 double[][] fromParent;
....@@ -7567,7 +7961,7 @@
75677961 {
75687962 assert(bRep != null);
75697963 if (!(support instanceof GenericJoint)) // support.bRep != null)
7570
- GrafreeD.Assert(support.bRep == bRep.support);
7964
+ Grafreed.Assert(support.bRep == bRep.support);
75717965 }
75727966 else
75737967 {
....@@ -7598,6 +7992,10 @@
75987992 }
75997993
76007994 transient ObjEditor editWindow;
7995
+ transient ObjEditor manipWindow;
7996
+
7997
+ transient boolean pinned;
7998
+
76017999 transient ObjectUI objectUI;
76028000 public static int povDepth = 0;
76038001 private static cVector tbMin = new cVector();
....@@ -7616,9 +8014,9 @@
76168014 private static cVector edge2 = new cVector();
76178015 //private static cVector norm = new cVector();
76188016 /*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;
8017
+ static final int hitCenter = 1;
8018
+ static final int hitScale = 2;
8019
+ static final int hitRotate = 3;
76228020 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76238021 /*transient*/ private Point centerPt;
76248022 /*transient*/ private int startX;