Normand Briere
2019-07-23 0f4fa9dc4191aaee9661c1e6d73725436ae64ac2
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[];
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
+ transient boolean keepdontselect;
303430 boolean dontselect = false;
304431 boolean hide = false;
305432 boolean link2master = false; // performs reset support/master at each frame
....@@ -482,12 +609,14 @@
482609 toParent = LA.newMatrix();
483610 fromParent = LA.newMatrix();
484611 }
612
+
485613 if (toParentMarked == null)
486614 {
487615 if (maxcount != 1)
488616 {
489617 new Exception().printStackTrace();
490618 }
619
+
491620 toParentMarked = LA.newMatrix();
492621 fromParentMarked = LA.newMatrix();
493622 }
....@@ -775,7 +904,7 @@
775904 if (step == 0)
776905 step = 1;
777906 if (maxcount == 0)
778
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
779908 // if (acceleration == 0)
780909 // acceleration = 10;
781910 if (delay == 0) // serial
....@@ -798,7 +927,7 @@
798927
799928 if (marked && Globals.isLIVE() && live &&
800929 //TEMP21aug2018
801
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
802931 currentframe != Globals.framecount)
803932 {
804933 currentframe = Globals.framecount;
....@@ -810,7 +939,8 @@
810939
811940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
812941
813
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
814944 {
815945 countdown = 1;
816946 delay = speedup?8:1;
....@@ -882,6 +1012,7 @@
8821012 if (material == null || material.multiply)
8831013 return true;
8841014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8851016 return material.opacity > 0.99;
8861017 }
8871018
....@@ -1282,6 +1413,7 @@
12821413 toParent = LA.newMatrix();
12831414 fromParent = LA.newMatrix();
12841415 }
1416
+
12851417 LA.matCopy(other.toParent, toParent);
12861418 LA.matCopy(other.fromParent, fromParent);
12871419
....@@ -2303,6 +2435,10 @@
23032435 }
23042436 */
23052437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23062442 }
23072443
23082444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2344,6 +2480,14 @@
23442480 {
23452481 editWindow.refreshContents();
23462482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23472491 //if (parent != null)
23482492 //parent.refreshEditWindow();
23492493 }
....@@ -2628,6 +2772,18 @@
26282772 //Touch();
26292773 }
26302774
2775
+ void GenNormalsMeshS()
2776
+ {
2777
+ selection.GenNormalsMesh();
2778
+// for (int i=0; i<selection.size(); i++)
2779
+// {
2780
+// Object3D selectee = (Object3D) selection.elementAt(i);
2781
+// selectee.GenNormals(crease);
2782
+// }
2783
+
2784
+ //Touch();
2785
+ }
2786
+
26312787 void ClearColorsS()
26322788 {
26332789 selection.ClearColors();
....@@ -2759,6 +2915,24 @@
27592915 if (child == null)
27602916 continue;
27612917 child.GenNormals(crease);
2918
+// Children().release(i);
2919
+ }
2920
+ blockloop = false;
2921
+ }
2922
+
2923
+ void GenNormalsMesh()
2924
+ {
2925
+ if (blockloop)
2926
+ return;
2927
+
2928
+ blockloop = true;
2929
+ GenNormalsMesh0();
2930
+ for (int i = 0; i < Children().Size(); i++)
2931
+ {
2932
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2933
+ if (child == null)
2934
+ continue;
2935
+ child.GenNormalsMesh();
27622936 // Children().release(i);
27632937 }
27642938 blockloop = false;
....@@ -2931,11 +3105,20 @@
29313105 }
29323106 }
29333107
3108
+ void GenNormalsMesh0()
3109
+ {
3110
+ if (bRep != null)
3111
+ {
3112
+ bRep.GenerateNormalsMesh();
3113
+ Touch();
3114
+ }
3115
+ }
3116
+
29343117 void GenNormalsMINE0()
29353118 {
29363119 if (bRep != null)
29373120 {
2938
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29393122 Touch();
29403123 }
29413124 }
....@@ -3381,7 +3564,8 @@
33813564 if (blockloop)
33823565 return;
33833566
3384
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
33853569 live = h;
33863570
33873571 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3586,8 @@
34023586 return;
34033587
34043588 //if (bRep != null)
3405
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
34063591 link2master = h;
34073592
34083593 for (int i = 0; i < Size(); i++)
....@@ -3422,7 +3607,8 @@
34223607 if (blockloop)
34233608 return;
34243609
3425
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
34263612 hide = h;
34273613
34283614 for (int i = 0; i < Size(); i++)
....@@ -3442,7 +3628,7 @@
34423628 if (blockloop)
34433629 return;
34443630
3445
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
34463632 marked = h;
34473633
34483634 for (int i = 0; i < Size(); i++)
....@@ -3452,6 +3638,46 @@
34523638 continue;
34533639 blockloop = true;
34543640 child.MarkLeaves(h);
3641
+ blockloop = false;
3642
+ // release(i);
3643
+ }
3644
+ }
3645
+
3646
+ void RewindLeaves(boolean h)
3647
+ {
3648
+ if (blockloop)
3649
+ return;
3650
+
3651
+ if (bRep != null || material != null) // borderline...
3652
+ rewind = h;
3653
+
3654
+ for (int i = 0; i < Size(); i++)
3655
+ {
3656
+ Object3D child = (Object3D) get(i); // reserve(i);
3657
+ if (child == null)
3658
+ continue;
3659
+ blockloop = true;
3660
+ child.RewindLeaves(h);
3661
+ blockloop = false;
3662
+ // release(i);
3663
+ }
3664
+ }
3665
+
3666
+ void RandomLeaves(boolean h)
3667
+ {
3668
+ if (blockloop)
3669
+ return;
3670
+
3671
+ if (bRep != null || material != null) // borderline...
3672
+ random = h;
3673
+
3674
+ for (int i = 0; i < Size(); i++)
3675
+ {
3676
+ Object3D child = (Object3D) get(i); // reserve(i);
3677
+ if (child == null)
3678
+ continue;
3679
+ blockloop = true;
3680
+ child.RandomLeaves(h);
34553681 blockloop = false;
34563682 // release(i);
34573683 }
....@@ -4229,6 +4455,55 @@
42294455 }
42304456 }
42314457
4458
+ void RepairSOV()
4459
+ {
4460
+ if (blockloop)
4461
+ return;
4462
+
4463
+ String texname = this.GetPigmentTexture();
4464
+
4465
+ if (texname.startsWith("sov"))
4466
+ {
4467
+ String[] s = texname.split("/");
4468
+
4469
+ String[] sname = s[1].split("Color.pn");
4470
+
4471
+ texname = sname[0];
4472
+
4473
+ if (sname.length > 1)
4474
+ {
4475
+ texname += "Color.jpg";
4476
+ }
4477
+
4478
+ this.SetPigmentTexture("sov/" + texname);
4479
+ }
4480
+
4481
+ texname = this.GetBumpTexture();
4482
+
4483
+ if (texname.startsWith("sov"))
4484
+ {
4485
+ String[] s = texname.split("/");
4486
+
4487
+ String[] sname = s[1].split("Bump.pn");
4488
+
4489
+ texname = sname[0];
4490
+
4491
+ if (sname.length > 1)
4492
+ {
4493
+ texname += "Bump.jpg";
4494
+ }
4495
+
4496
+ this.SetBumpTexture("sov/" + texname);
4497
+ }
4498
+
4499
+ for (int i=0; i<Size(); i++)
4500
+ {
4501
+ blockloop = true;
4502
+ get(i).RepairSOV();
4503
+ blockloop = false;
4504
+ }
4505
+ }
4506
+
42324507 void RepairTexture()
42334508 {
42344509 if (this instanceof FileObject || blockloop)
....@@ -4743,6 +5018,14 @@
47435018 }
47445019 }
47455020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
47465029 cTreePath Select(int indexcount, boolean deselect)
47475030 {
47485031 if (hide || dontselect)
....@@ -4779,10 +5062,11 @@
47795062 if (leaf != null)
47805063 {
47815064 cTreePath tp = new cTreePath(this, leaf);
4782
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
47835067 {
47845068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4785
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
47865070 }
47875071
47885072 return tp;
....@@ -4799,6 +5083,7 @@
47995083
48005084 if (child == null)
48015085 continue;
5086
+
48025087 if (child.HasTransparency() && child.size() != 0)
48035088 {
48045089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4808,9 +5093,10 @@
48085093 if (leaf != null)
48095094 {
48105095 cTreePath tp = new cTreePath(this, leaf);
4811
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
48125098 {
4813
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
48145100 }
48155101
48165102 return tp;
....@@ -5135,6 +5421,51 @@
51355421 blockloop = false;
51365422 }
51375423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
51385469 boolean IsSelected()
51395470 {
51405471 if (parent == null)
....@@ -5371,6 +5702,43 @@
53715702 }
53725703 }
53735704
5705
+ UUID GetUUID()
5706
+ {
5707
+ if (uuid == null)
5708
+ {
5709
+ // Serial
5710
+ uuid = UUID.randomUUID();
5711
+ }
5712
+
5713
+ return uuid;
5714
+ }
5715
+
5716
+ Object3D GetObject(UUID uid)
5717
+ {
5718
+ if (blockloop)
5719
+ return null;
5720
+
5721
+ if (GetUUID().equals(uid))
5722
+ return this;
5723
+
5724
+ int nb = Size();
5725
+ for (int i = 0; i < nb; i++)
5726
+ {
5727
+ Object3D child = (Object3D) get(i);
5728
+
5729
+ if (child == null)
5730
+ continue;
5731
+
5732
+ blockloop = true;
5733
+ Object3D obj = child.GetObject(uid);
5734
+ blockloop = false;
5735
+ if (obj != null)
5736
+ return obj;
5737
+ }
5738
+
5739
+ return null;
5740
+ }
5741
+
53745742 void SetBumpTexture(String tex)
53755743 {
53765744 if (GetTextures() == null)
....@@ -5407,6 +5775,38 @@
54075775 }
54085776 }
54095777
5778
+ void EmbedTextures(boolean embed)
5779
+ {
5780
+ if (blockloop)
5781
+ return;
5782
+
5783
+ //if (GetTextures() != null)
5784
+ if (embed)
5785
+ CameraPane.EmbedTextures(GetTextures());
5786
+ else
5787
+ {
5788
+ GetTextures().pigmentdata = null;
5789
+ GetTextures().bumpdata = null;
5790
+ GetTextures().pw = 0;
5791
+ GetTextures().ph = 0;
5792
+ GetTextures().bw = 0;
5793
+ GetTextures().bh = 0;
5794
+ }
5795
+
5796
+ int nb = Size();
5797
+ for (int i = 0; i < nb; i++)
5798
+ {
5799
+ Object3D child = (Object3D) get(i);
5800
+
5801
+ if (child == null)
5802
+ continue;
5803
+
5804
+ blockloop = true;
5805
+ child.EmbedTextures(embed);
5806
+ blockloop = false;
5807
+ }
5808
+ }
5809
+
54105810 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54115811 {
54125812 Draw(display, root, selected, blocked);
....@@ -5415,12 +5815,23 @@
54155815 boolean NeedSupport()
54165816 {
54175817 return
5418
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5818
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54195819 // PROBLEM with CROWD!!
54205820 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54215821 }
54225822
54235823 static boolean DEBUG_SELECTION = false;
5824
+
5825
+ boolean IsLive()
5826
+ {
5827
+ if (live)
5828
+ return true;
5829
+
5830
+ if (parent == null)
5831
+ return false;
5832
+
5833
+ return parent.IsLive();
5834
+ }
54245835
54255836 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54265837 {
....@@ -5483,7 +5894,7 @@
54835894 support = support;
54845895
54855896 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5486
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5897
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54875898
54885899 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54895900 {
....@@ -5503,10 +5914,12 @@
55035914 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55045915
55055916 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5506
- (touched || (bRep != null && bRep.displaylist <= 0)))
5917
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5918
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
55075919 {
55085920 Globals.lighttouched = true;
55095921 } // all panes...
5922
+
55105923 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55115924 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55125925 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5634,6 +6047,7 @@
56346047 if (GetBRep() != null)
56356048 {
56366049 display.NextIndex();
6050
+
56376051 // vertex color conflict : gl.glCallList(list);
56386052 DrawNode(display, root, selected);
56396053 if (this instanceof BezierPatch)
....@@ -5674,16 +6088,27 @@
56746088 tex = GetTextures();
56756089 }
56766090
5677
- boolean failed = false;
6091
+ boolean failedPigment = false;
6092
+ boolean failedBump = false;
56786093
56796094 try
56806095 {
5681
- display.BindTextures(tex, texres);
6096
+ display.BindPigmentTexture(tex, texres);
56826097 }
56836098 catch (Exception e)
56846099 {
56856100 System.err.println("FAILED: " + this);
5686
- failed = true;
6101
+ failedPigment = true;
6102
+ }
6103
+
6104
+ try
6105
+ {
6106
+ display.BindBumpTexture(tex, texres);
6107
+ }
6108
+ catch (Exception e)
6109
+ {
6110
+ //System.err.println("FAILED: " + this);
6111
+ failedBump = true;
56876112 }
56886113
56896114 if (!compiled)
....@@ -5706,8 +6131,11 @@
57066131 }
57076132 }
57086133
5709
- if (!failed)
5710
- display.ReleaseTextures(tex);
6134
+ if (!failedBump)
6135
+ display.ReleaseBumpTexture(tex);
6136
+
6137
+ if (!failedPigment)
6138
+ display.ReleasePigmentTexture(tex);
57116139
57126140 display.PopMaterial(this, selected);
57136141 }
....@@ -6080,6 +6508,11 @@
60806508 // dec 2012
60816509 new Exception().printStackTrace();
60826510 return;
6511
+ }
6512
+
6513
+ if (dontselect)
6514
+ {
6515
+ //bRep.GenerateNormalsMINE();
60836516 }
60846517
60856518 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6932,7 +7365,7 @@
69327365 spot.translate(32, 32);
69337366 spotw = spot.x + spot.width;
69347367 spoth = spot.y + spot.height;
6935
- info.g.setColor(Color.blue);
7368
+ info.g.setColor(Color.cyan);
69367369 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69377370 // if (CameraPane.Xmin > spot.x)
69387371 // {
....@@ -6950,11 +7383,12 @@
69507383 // {
69517384 // CameraPane.Ymax = spoth;
69527385 // }
6953
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7386
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7387
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69557388 spot.translate(0, -32);
6956
- info.g.setColor(Color.green);
7389
+ info.g.setColor(Color.yellow);
69577390 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7391
+ info.g.setColor(Color.green);
69587392 // if (CameraPane.Xmin > spot.x)
69597393 // {
69607394 // CameraPane.Xmin = spot.x;
....@@ -6971,8 +7405,8 @@
69717405 // {
69727406 // CameraPane.Ymax = spoth;
69737407 // }
6974
- info.g.drawArc(boundary.x, boundary.y,
6975
- boundary.width, boundary.height, 0, 360);
7408
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
69767410 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69777411 // if (CameraPane.Xmin > boundary.x)
69787412 // {
....@@ -7006,7 +7440,7 @@
70067440 startX = info.x;
70077441 startY = info.y;
70087442
7009
- hitSomething = 0;
7443
+ hitSomething = -1;
70107444 cVector origin = new cVector();
70117445 //LA.xformPos(origin, toParent, origin);
70127446 Rectangle spot = new Rectangle();
....@@ -7082,6 +7516,7 @@
70827516 //System.out.println("hitSomething = " + hitSomething);
70837517
70847518 double scale = 0.005f * info.camera.Distance();
7519
+
70857520 cVector xlate = new cVector();
70867521 //cVector xlate2 = new cVector();
70877522 switch (hitSomething)
....@@ -7230,24 +7665,27 @@
72307665
72317666 case hitScale: // scale
72327667 double hScale = (double) (info.x - centerPt.x) / 32;
7668
+ double sign = 1;
7669
+ if (hScale < 0)
7670
+ {
7671
+ sign = -1;
7672
+ }
7673
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72337674 if (hScale < 0.01)
72347675 {
7235
- hScale = 0.01;
7676
+ //hScale = 0.01;
72367677 }
7237
- hScale = Math.pow(hScale, scale * 50);
7238
- if (hScale < 0.01)
7239
- {
7240
- hScale = 0.01;
7241
- }
7678
+
72427679 double vScale = (double) (info.y - centerPt.y) / 32;
7243
- if (vScale < 0.01)
7680
+ sign = 1;
7681
+ if (vScale < 0)
72447682 {
7245
- vScale = 0.01;
7683
+ sign = -1;
72467684 }
7247
- vScale = Math.pow(vScale, scale * 50);
7685
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72487686 if (vScale < 0.01)
72497687 {
7250
- vScale = 0.01;
7688
+ //vScale = 0.01;
72517689 }
72527690 LA.matCopy(startMat, toParent);
72537691 /**/
....@@ -7258,39 +7696,47 @@
72587696 }
72597697 /**/
72607698
7699
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7700
+
7701
+ if (totalScale < 0.01)
7702
+ {
7703
+ totalScale = 0.01;
7704
+ }
7705
+
72617706 switch (info.pane.RenderCamera().viewCode)
72627707 {
72637708 case 3: // '\001'
7264
- if (modified)
7709
+ if (modified || opposite)
72657710 {
72667711 //LA.matScale(toParent, 1, hScale, vScale);
7267
- LA.matScale(toParent, vScale, 1, 1);
7712
+ LA.matScale(toParent, totalScale, 1, 1);
72687713 } // vScale, 1);
72697714 else
72707715 {
7271
- LA.matScale(toParent, vScale, vScale, vScale);
7716
+ // EXCEPTION!
7717
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72727718 } // vScale, 1);
72737719 break;
72747720
72757721 case 2: // '\002'
7276
- if (modified)
7722
+ if (modified || opposite)
72777723 {
72787724 //LA.matScale(toParent, hScale, 1, vScale);
7279
- LA.matScale(toParent, 1, vScale, 1);
7725
+ LA.matScale(toParent, 1, totalScale, 1);
72807726 } else
72817727 {
7282
- LA.matScale(toParent, vScale, 1, vScale);
7728
+ LA.matScale(toParent, totalScale, 1, totalScale);
72837729 }
72847730 break;
72857731
72867732 case 1: // '\003'
7287
- if (modified)
7733
+ if (modified || opposite)
72887734 {
72897735 //LA.matScale(toParent, hScale, vScale, 1);
7290
- LA.matScale(toParent, 1, 1, vScale);
7736
+ LA.matScale(toParent, 1, 1, totalScale);
72917737 } else
72927738 {
7293
- LA.matScale(toParent, vScale, vScale, 1);
7739
+ LA.matScale(toParent, totalScale, totalScale, 1);
72947740 }
72957741 break;
72967742 }
....@@ -7431,7 +7877,7 @@
74317877 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74327878 } else
74337879 {
7434
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7880
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74357881 } // + super.toString();
74367882 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74377883
....@@ -7504,6 +7950,10 @@
75047950 editWindow = null;
75057951 } // ?
75067952 }
7953
+ else
7954
+ {
7955
+ //editWindow.closeUI();
7956
+ }
75077957 }
75087958
75097959 boolean root; // patch for edit windows
....@@ -7515,7 +7965,7 @@
75157965 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75167966
75177967 Object3D /*Composite*/ parent;
7518
- Object3D /*Composite*/ fileparent;
7968
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75197969
75207970 double[][] toParent; // dynamic matrix
75217971 double[][] fromParent;
....@@ -7661,6 +8111,10 @@
76618111 }
76628112
76638113 transient ObjEditor editWindow;
8114
+ transient ObjEditor manipWindow;
8115
+
8116
+ transient boolean pinned;
8117
+
76648118 transient ObjectUI objectUI;
76658119 public static int povDepth = 0;
76668120 private static cVector tbMin = new cVector();
....@@ -7679,9 +8133,9 @@
76798133 private static cVector edge2 = new cVector();
76808134 //private static cVector norm = new cVector();
76818135 /*transient private*/ int hitSomething;
7682
- private static final int hitCenter = 1;
7683
- private static final int hitScale = 2;
7684
- private static final int hitRotate = 3;
8136
+ static final int hitCenter = 1;
8137
+ static final int hitScale = 2;
8138
+ static final int hitRotate = 3;
76858139 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76868140 /*transient*/ private Point centerPt;
76878141 /*transient*/ private int startX;