Normand Briere
2019-07-01 6600d22461ccc1cb602f238a9ffa83cf07dd830e
Object3D.java
....@@ -24,6 +24,11 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
31
+
2732 ScriptNode scriptnode;
2833
2934 void InitOthers()
....@@ -104,64 +109,143 @@
104109
105110 // transient boolean reduced; // for morph reduction
106111
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-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
109114
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
112117
113
-void SaveSupports()
114
-{
115
- if (blockloop)
116
- return;
117
-
118
- transientsupport = support;
119
- transientlink2master = link2master;
120
-
121
- support = null;
122
- link2master = false;
123
-
124
- if (bRep != null)
118
+ void SaveSupports()
125119 {
126
- 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
+ }
127143 }
128
-
129
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
130146 {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- 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
+
134225 blockloop = true;
135
- 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
+
136238 blockloop = false;
137239 }
138
-}
139240
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
144
-
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
241
+ void RestoreBigData(Object3D o)
151242 {
152
- 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;
153248 }
154
-
155
- for (int i = 0; i < Size(); i++)
156
- {
157
- Object3D child = (Object3D) get(i);
158
- if (child == null)
159
- continue;
160
- blockloop = true;
161
- child.RestoreSupports();
162
- blockloop = false;
163
- }
164
-}
165249
166250 // MOCAP SUPPORT
167251 double tx,ty,tz,rx,ry,rz;
....@@ -486,12 +570,14 @@
486570 toParent = LA.newMatrix();
487571 fromParent = LA.newMatrix();
488572 }
573
+
489574 if (toParentMarked == null)
490575 {
491576 if (maxcount != 1)
492577 {
493578 new Exception().printStackTrace();
494579 }
580
+
495581 toParentMarked = LA.newMatrix();
496582 fromParentMarked = LA.newMatrix();
497583 }
....@@ -802,7 +888,7 @@
802888
803889 if (marked && Globals.isLIVE() && live &&
804890 //TEMP21aug2018
805
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
891
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
806892 currentframe != Globals.framecount)
807893 {
808894 currentframe = Globals.framecount;
....@@ -814,7 +900,8 @@
814900
815901 boolean changedir = random && Math.random() < 0.01; // && !link2master;
816902
817
- if (transformcount*factor > maxcount || (step == 1 && changedir))
903
+ if (transformcount*factor >= maxcount && (rewind || random) ||
904
+ (step == 1 && changedir))
818905 {
819906 countdown = 1;
820907 delay = speedup?8:1;
....@@ -886,6 +973,7 @@
886973 if (material == null || material.multiply)
887974 return true;
888975
976
+ // Transparent objects are dynamic because we have to sort the triangles.
889977 return material.opacity > 0.99;
890978 }
891979
....@@ -2307,6 +2395,10 @@
23072395 }
23082396 */
23092397 }
2398
+ else
2399
+ {
2400
+ //((ObjEditor)editWindow).SetupUI2(null);
2401
+ }
23102402 }
23112403
23122404 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2348,6 +2440,14 @@
23482440 {
23492441 editWindow.refreshContents();
23502442 }
2443
+ else
2444
+ {
2445
+ if (manipWindow != null)
2446
+ {
2447
+ manipWindow.refreshContents();
2448
+ }
2449
+ }
2450
+
23512451 //if (parent != null)
23522452 //parent.refreshEditWindow();
23532453 }
....@@ -2632,6 +2732,18 @@
26322732 //Touch();
26332733 }
26342734
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
+
26352747 void ClearColorsS()
26362748 {
26372749 selection.ClearColors();
....@@ -2763,6 +2875,24 @@
27632875 if (child == null)
27642876 continue;
27652877 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();
27662896 // Children().release(i);
27672897 }
27682898 blockloop = false;
....@@ -2931,6 +3061,15 @@
29313061 if (bRep != null)
29323062 {
29333063 bRep.GenerateNormals(crease);
3064
+ Touch();
3065
+ }
3066
+ }
3067
+
3068
+ void GenNormalsMesh0()
3069
+ {
3070
+ if (bRep != null)
3071
+ {
3072
+ bRep.GenerateNormalsMesh();
29343073 Touch();
29353074 }
29363075 }
....@@ -3385,7 +3524,8 @@
33853524 if (blockloop)
33863525 return;
33873526
3388
- if (marked || (bRep != null && material != null)) // borderline...
3527
+ if (//marked || // does not make sense
3528
+ (bRep != null || material != null)) // borderline...
33893529 live = h;
33903530
33913531 for (int i = 0; i < Size(); i++)
....@@ -3406,7 +3546,8 @@
34063546 return;
34073547
34083548 //if (bRep != null)
3409
- if (marked || (bRep != null && material != null)) // borderline...
3549
+ if (//marked || // does not make sense
3550
+ (bRep != null || material != null)) // borderline...
34103551 link2master = h;
34113552
34123553 for (int i = 0; i < Size(); i++)
....@@ -3426,7 +3567,8 @@
34263567 if (blockloop)
34273568 return;
34283569
3429
- if (marked || (bRep != null && material != null)) // borderline...
3570
+ if (//marked || // does not make sense
3571
+ (bRep != null || material != null)) // borderline...
34303572 hide = h;
34313573
34323574 for (int i = 0; i < Size(); i++)
....@@ -3446,7 +3588,7 @@
34463588 if (blockloop)
34473589 return;
34483590
3449
- if (bRep != null && material != null) // borderline...
3591
+ if (bRep != null || material != null) // borderline...
34503592 marked = h;
34513593
34523594 for (int i = 0; i < Size(); i++)
....@@ -3456,6 +3598,46 @@
34563598 continue;
34573599 blockloop = true;
34583600 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);
34593641 blockloop = false;
34603642 // release(i);
34613643 }
....@@ -4233,6 +4415,55 @@
42334415 }
42344416 }
42354417
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();
4463
+ blockloop = false;
4464
+ }
4465
+ }
4466
+
42364467 void RepairTexture()
42374468 {
42384469 if (this instanceof FileObject || blockloop)
....@@ -4747,6 +4978,14 @@
47474978 }
47484979 }
47494980
4981
+ ObjEditor GetWindow()
4982
+ {
4983
+ if (editWindow != null)
4984
+ return editWindow;
4985
+
4986
+ return manipWindow;
4987
+ }
4988
+
47504989 cTreePath Select(int indexcount, boolean deselect)
47514990 {
47524991 if (hide || dontselect)
....@@ -4783,10 +5022,11 @@
47835022 if (leaf != null)
47845023 {
47855024 cTreePath tp = new cTreePath(this, leaf);
4786
- if (editWindow != null)
5025
+ ObjEditor window = GetWindow();
5026
+ if (window != null)
47875027 {
47885028 //System.out.println("editWindow = " + editWindow + " vs " + this);
4789
- editWindow.Select(tp, deselect, true);
5029
+ window.Select(tp, deselect, true);
47905030 }
47915031
47925032 return tp;
....@@ -4803,6 +5043,7 @@
48035043
48045044 if (child == null)
48055045 continue;
5046
+
48065047 if (child.HasTransparency() && child.size() != 0)
48075048 {
48085049 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4812,9 +5053,10 @@
48125053 if (leaf != null)
48135054 {
48145055 cTreePath tp = new cTreePath(this, leaf);
4815
- if (editWindow != null)
5056
+ ObjEditor window = GetWindow();
5057
+ if (window != null)
48165058 {
4817
- editWindow.Select(tp, deselect, true);
5059
+ window.Select(tp, deselect, true);
48185060 }
48195061
48205062 return tp;
....@@ -5456,12 +5698,23 @@
54565698 boolean NeedSupport()
54575699 {
54585700 return
5459
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5701
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54605702 // PROBLEM with CROWD!!
54615703 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54625704 }
54635705
54645706 static boolean DEBUG_SELECTION = false;
5707
+
5708
+ boolean IsLive()
5709
+ {
5710
+ if (live)
5711
+ return true;
5712
+
5713
+ if (parent == null)
5714
+ return false;
5715
+
5716
+ return parent.IsLive();
5717
+ }
54655718
54665719 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54675720 {
....@@ -5524,7 +5777,7 @@
55245777 support = support;
55255778
55265779 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5527
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5780
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
55285781
55295782 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55305783 {
....@@ -5544,10 +5797,12 @@
55445797 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55455798
55465799 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5547
- (touched || (bRep != null && bRep.displaylist <= 0)))
5800
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5801
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
55485802 {
55495803 Globals.lighttouched = true;
55505804 } // all panes...
5805
+
55515806 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55525807 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55535808 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5675,6 +5930,7 @@
56755930 if (GetBRep() != null)
56765931 {
56775932 display.NextIndex();
5933
+
56785934 // vertex color conflict : gl.glCallList(list);
56795935 DrawNode(display, root, selected);
56805936 if (this instanceof BezierPatch)
....@@ -5715,16 +5971,27 @@
57155971 tex = GetTextures();
57165972 }
57175973
5718
- boolean failed = false;
5974
+ boolean failedPigment = false;
5975
+ boolean failedBump = false;
57195976
57205977 try
57215978 {
5722
- display.BindTextures(tex, texres);
5979
+ display.BindPigmentTexture(tex, texres);
57235980 }
57245981 catch (Exception e)
57255982 {
57265983 System.err.println("FAILED: " + this);
5727
- failed = true;
5984
+ failedPigment = true;
5985
+ }
5986
+
5987
+ try
5988
+ {
5989
+ display.BindBumpTexture(tex, texres);
5990
+ }
5991
+ catch (Exception e)
5992
+ {
5993
+ //System.err.println("FAILED: " + this);
5994
+ failedBump = true;
57285995 }
57295996
57305997 if (!compiled)
....@@ -5747,8 +6014,11 @@
57476014 }
57486015 }
57496016
5750
- if (!failed)
5751
- display.ReleaseTextures(tex);
6017
+ if (!failedBump)
6018
+ display.ReleaseBumpTexture(tex);
6019
+
6020
+ if (!failedPigment)
6021
+ display.ReleasePigmentTexture(tex);
57526022
57536023 display.PopMaterial(this, selected);
57546024 }
....@@ -6121,6 +6391,11 @@
61216391 // dec 2012
61226392 new Exception().printStackTrace();
61236393 return;
6394
+ }
6395
+
6396
+ if (dontselect)
6397
+ {
6398
+ //bRep.GenerateNormalsMINE();
61246399 }
61256400
61266401 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6973,7 +7248,7 @@
69737248 spot.translate(32, 32);
69747249 spotw = spot.x + spot.width;
69757250 spoth = spot.y + spot.height;
6976
- info.g.setColor(Color.blue);
7251
+ info.g.setColor(Color.cyan);
69777252 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69787253 // if (CameraPane.Xmin > spot.x)
69797254 // {
....@@ -6991,11 +7266,12 @@
69917266 // {
69927267 // CameraPane.Ymax = spoth;
69937268 // }
6994
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7269
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7270
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69967271 spot.translate(0, -32);
6997
- info.g.setColor(Color.green);
7272
+ info.g.setColor(Color.yellow);
69987273 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7274
+ info.g.setColor(Color.green);
69997275 // if (CameraPane.Xmin > spot.x)
70007276 // {
70017277 // CameraPane.Xmin = spot.x;
....@@ -7313,19 +7589,20 @@
73137589 switch (info.pane.RenderCamera().viewCode)
73147590 {
73157591 case 3: // '\001'
7316
- if (modified)
7592
+ if (modified || opposite)
73177593 {
73187594 //LA.matScale(toParent, 1, hScale, vScale);
73197595 LA.matScale(toParent, totalScale, 1, 1);
73207596 } // vScale, 1);
73217597 else
73227598 {
7599
+ // EXCEPTION!
73237600 LA.matScale(toParent, totalScale, totalScale, totalScale);
73247601 } // vScale, 1);
73257602 break;
73267603
73277604 case 2: // '\002'
7328
- if (modified)
7605
+ if (modified || opposite)
73297606 {
73307607 //LA.matScale(toParent, hScale, 1, vScale);
73317608 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7336,7 +7613,7 @@
73367613 break;
73377614
73387615 case 1: // '\003'
7339
- if (modified)
7616
+ if (modified || opposite)
73407617 {
73417618 //LA.matScale(toParent, hScale, vScale, 1);
73427619 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7556,6 +7833,10 @@
75567833 editWindow = null;
75577834 } // ?
75587835 }
7836
+ else
7837
+ {
7838
+ //editWindow.closeUI();
7839
+ }
75597840 }
75607841
75617842 boolean root; // patch for edit windows
....@@ -7567,7 +7848,7 @@
75677848 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75687849
75697850 Object3D /*Composite*/ parent;
7570
- Object3D /*Composite*/ fileparent;
7851
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75717852
75727853 double[][] toParent; // dynamic matrix
75737854 double[][] fromParent;
....@@ -7713,6 +7994,10 @@
77137994 }
77147995
77157996 transient ObjEditor editWindow;
7997
+ transient ObjEditor manipWindow;
7998
+
7999
+ transient boolean pinned;
8000
+
77168001 transient ObjectUI objectUI;
77178002 public static int povDepth = 0;
77188003 private static cVector tbMin = new cVector();