Normand Briere
2019-06-24 c67da2e5d8655704601d6d06e8bc60aabe212253
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,117 +109,136 @@
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;
118
+ void SaveSupports()
119
+ {
120
+ if (blockloop)
121
+ return;
117122
118
- transientsupport = support;
119
- transientlink2master = link2master;
120
-
121
- support = null;
122
- link2master = false;
123
-
124
- if (bRep != null)
125
- {
126
- bRep.SaveSupports();
127
- }
128
-
129
- for (int i = 0; i < Size(); i++)
130
- {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
134
- blockloop = true;
135
- child.SaveSupports();
136
- blockloop = false;
137
- }
138
-}
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
139125
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
126
+ support = null;
127
+ link2master = false;
144128
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
151
- {
152
- bRep.RestoreSupports();
153
- }
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
-}
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
165133
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
169
- return;
170
-
171
- Object3D o = new Object3D();
172
- o.bRep = this.bRep;
173
- if (this.bRep != null)
174
- {
175
- o.transientrep = this.bRep.support;
176
- o.bRep.support = null;
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
+ }
177143 }
178
-
179
-// o.support = this.support;
180
-// o.fileparent = this.fileparent;
181
-// if (this.bRep != null)
182
-// o.bRep = this.bRep.support;
183
-
184
- hashtable.put(GetUUID(), o);
185
-
186
- this.bRep = null;
187
-// if (this.bRep != null)
188
-// this.bRep.support = null;
189
-// this.support = null;
190
-// this.fileparent = null;
191
-
192
- for (int i=0; i<Size(); i++)
193
- {
194
- get(i).ExtractBigData(hashtable);
195
- }
196
-}
197144
198
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
199
-{
200
- if (!hashtable.containsKey(GetUUID()))
201
- return;
202
-
203
- Object3D o = hashtable.get(GetUUID());
204
-
205
- this.bRep = o.bRep;
206
- if (this.bRep != null)
207
- this.bRep.support = o.transientrep;
208
-// this.support = o.support;
209
-// this.fileparent = o.fileparent;
210
-
211
- hashtable.remove(GetUUID());
212
-
213
- for (int i=0; i<Size(); i++)
145
+ void RestoreSupports()
214146 {
215
- get(i).RestoreBigData(hashtable);
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
+ }
216169 }
217
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
218242
219243 // MOCAP SUPPORT
220244 double tx,ty,tz,rx,ry,rz;
....@@ -539,12 +563,14 @@
539563 toParent = LA.newMatrix();
540564 fromParent = LA.newMatrix();
541565 }
566
+
542567 if (toParentMarked == null)
543568 {
544569 if (maxcount != 1)
545570 {
546571 new Exception().printStackTrace();
547572 }
573
+
548574 toParentMarked = LA.newMatrix();
549575 fromParentMarked = LA.newMatrix();
550576 }
....@@ -855,7 +881,7 @@
855881
856882 if (marked && Globals.isLIVE() && live &&
857883 //TEMP21aug2018
858
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
859885 currentframe != Globals.framecount)
860886 {
861887 currentframe = Globals.framecount;
....@@ -867,7 +893,8 @@
867893
868894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
869895
870
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
871898 {
872899 countdown = 1;
873900 delay = speedup?8:1;
....@@ -939,6 +966,7 @@
939966 if (material == null || material.multiply)
940967 return true;
941968
969
+ // Transparent objects are dynamic because we have to sort the triangles.
942970 return material.opacity > 0.99;
943971 }
944972
....@@ -2360,6 +2388,10 @@
23602388 }
23612389 */
23622390 }
2391
+ else
2392
+ {
2393
+ //((ObjEditor)editWindow).SetupUI2(null);
2394
+ }
23632395 }
23642396
23652397 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2685,6 +2717,18 @@
26852717 //Touch();
26862718 }
26872719
2720
+ void GenNormalsMeshS()
2721
+ {
2722
+ selection.GenNormalsMesh();
2723
+// for (int i=0; i<selection.size(); i++)
2724
+// {
2725
+// Object3D selectee = (Object3D) selection.elementAt(i);
2726
+// selectee.GenNormals(crease);
2727
+// }
2728
+
2729
+ //Touch();
2730
+ }
2731
+
26882732 void ClearColorsS()
26892733 {
26902734 selection.ClearColors();
....@@ -2816,6 +2860,24 @@
28162860 if (child == null)
28172861 continue;
28182862 child.GenNormals(crease);
2863
+// Children().release(i);
2864
+ }
2865
+ blockloop = false;
2866
+ }
2867
+
2868
+ void GenNormalsMesh()
2869
+ {
2870
+ if (blockloop)
2871
+ return;
2872
+
2873
+ blockloop = true;
2874
+ GenNormalsMesh0();
2875
+ for (int i = 0; i < Children().Size(); i++)
2876
+ {
2877
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2878
+ if (child == null)
2879
+ continue;
2880
+ child.GenNormalsMesh();
28192881 // Children().release(i);
28202882 }
28212883 blockloop = false;
....@@ -2984,6 +3046,15 @@
29843046 if (bRep != null)
29853047 {
29863048 bRep.GenerateNormals(crease);
3049
+ Touch();
3050
+ }
3051
+ }
3052
+
3053
+ void GenNormalsMesh0()
3054
+ {
3055
+ if (bRep != null)
3056
+ {
3057
+ bRep.GenerateNormalsMesh();
29873058 Touch();
29883059 }
29893060 }
....@@ -3438,7 +3509,8 @@
34383509 if (blockloop)
34393510 return;
34403511
3441
- if (marked || (bRep != null && material != null)) // borderline...
3512
+ if (//marked || // does not make sense
3513
+ (bRep != null || material != null)) // borderline...
34423514 live = h;
34433515
34443516 for (int i = 0; i < Size(); i++)
....@@ -3459,7 +3531,8 @@
34593531 return;
34603532
34613533 //if (bRep != null)
3462
- if (marked || (bRep != null && material != null)) // borderline...
3534
+ if (//marked || // does not make sense
3535
+ (bRep != null || material != null)) // borderline...
34633536 link2master = h;
34643537
34653538 for (int i = 0; i < Size(); i++)
....@@ -3479,7 +3552,8 @@
34793552 if (blockloop)
34803553 return;
34813554
3482
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
34833557 hide = h;
34843558
34853559 for (int i = 0; i < Size(); i++)
....@@ -3499,7 +3573,7 @@
34993573 if (blockloop)
35003574 return;
35013575
3502
- if (bRep != null && material != null) // borderline...
3576
+ if (bRep != null || material != null) // borderline...
35033577 marked = h;
35043578
35053579 for (int i = 0; i < Size(); i++)
....@@ -3509,6 +3583,46 @@
35093583 continue;
35103584 blockloop = true;
35113585 child.MarkLeaves(h);
3586
+ blockloop = false;
3587
+ // release(i);
3588
+ }
3589
+ }
3590
+
3591
+ void RewindLeaves(boolean h)
3592
+ {
3593
+ if (blockloop)
3594
+ return;
3595
+
3596
+ if (bRep != null || material != null) // borderline...
3597
+ rewind = h;
3598
+
3599
+ for (int i = 0; i < Size(); i++)
3600
+ {
3601
+ Object3D child = (Object3D) get(i); // reserve(i);
3602
+ if (child == null)
3603
+ continue;
3604
+ blockloop = true;
3605
+ child.RewindLeaves(h);
3606
+ blockloop = false;
3607
+ // release(i);
3608
+ }
3609
+ }
3610
+
3611
+ void RandomLeaves(boolean h)
3612
+ {
3613
+ if (blockloop)
3614
+ return;
3615
+
3616
+ if (bRep != null || material != null) // borderline...
3617
+ random = h;
3618
+
3619
+ for (int i = 0; i < Size(); i++)
3620
+ {
3621
+ Object3D child = (Object3D) get(i); // reserve(i);
3622
+ if (child == null)
3623
+ continue;
3624
+ blockloop = true;
3625
+ child.RandomLeaves(h);
35123626 blockloop = false;
35133627 // release(i);
35143628 }
....@@ -4282,6 +4396,55 @@
42824396 {
42834397 blockloop = true;
42844398 get(i).RepairShadow();
4399
+ blockloop = false;
4400
+ }
4401
+ }
4402
+
4403
+ void RepairSOV()
4404
+ {
4405
+ if (blockloop)
4406
+ return;
4407
+
4408
+ String texname = this.GetPigmentTexture();
4409
+
4410
+ if (texname.startsWith("sov"))
4411
+ {
4412
+ String[] s = texname.split("/");
4413
+
4414
+ String[] sname = s[1].split("Color.pn");
4415
+
4416
+ texname = sname[0];
4417
+
4418
+ if (sname.length > 1)
4419
+ {
4420
+ texname += "Color.jpg";
4421
+ }
4422
+
4423
+ this.SetPigmentTexture("sov/" + texname);
4424
+ }
4425
+
4426
+ texname = this.GetBumpTexture();
4427
+
4428
+ if (texname.startsWith("sov"))
4429
+ {
4430
+ String[] s = texname.split("/");
4431
+
4432
+ String[] sname = s[1].split("Bump.pn");
4433
+
4434
+ texname = sname[0];
4435
+
4436
+ if (sname.length > 1)
4437
+ {
4438
+ texname += "Bump.jpg";
4439
+ }
4440
+
4441
+ this.SetBumpTexture("sov/" + texname);
4442
+ }
4443
+
4444
+ for (int i=0; i<Size(); i++)
4445
+ {
4446
+ blockloop = true;
4447
+ get(i).RepairSOV();
42854448 blockloop = false;
42864449 }
42874450 }
....@@ -5509,12 +5672,23 @@
55095672 boolean NeedSupport()
55105673 {
55115674 return
5512
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5675
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55135676 // PROBLEM with CROWD!!
55145677 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55155678 }
55165679
55175680 static boolean DEBUG_SELECTION = false;
5681
+
5682
+ boolean IsLive()
5683
+ {
5684
+ if (live)
5685
+ return true;
5686
+
5687
+ if (parent == null)
5688
+ return false;
5689
+
5690
+ return parent.IsLive();
5691
+ }
55185692
55195693 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55205694 {
....@@ -5577,7 +5751,7 @@
55775751 support = support;
55785752
55795753 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5580
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5754
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
55815755
55825756 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55835757 {
....@@ -5597,10 +5771,12 @@
55975771 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55985772
55995773 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5600
- (touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5775
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
56015776 {
56025777 Globals.lighttouched = true;
56035778 } // all panes...
5779
+
56045780 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56055781 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56065782 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5768,16 +5944,27 @@
57685944 tex = GetTextures();
57695945 }
57705946
5771
- boolean failed = false;
5947
+ boolean failedPigment = false;
5948
+ boolean failedBump = false;
57725949
57735950 try
57745951 {
5775
- display.BindTextures(tex, texres);
5952
+ display.BindPigmentTexture(tex, texres);
57765953 }
57775954 catch (Exception e)
57785955 {
57795956 System.err.println("FAILED: " + this);
5780
- failed = true;
5957
+ failedPigment = true;
5958
+ }
5959
+
5960
+ try
5961
+ {
5962
+ display.BindBumpTexture(tex, texres);
5963
+ }
5964
+ catch (Exception e)
5965
+ {
5966
+ //System.err.println("FAILED: " + this);
5967
+ failedBump = true;
57815968 }
57825969
57835970 if (!compiled)
....@@ -5800,8 +5987,11 @@
58005987 }
58015988 }
58025989
5803
- if (!failed)
5804
- display.ReleaseTextures(tex);
5990
+ if (!failedBump)
5991
+ display.ReleaseBumpTexture(tex);
5992
+
5993
+ if (!failedPigment)
5994
+ display.ReleasePigmentTexture(tex);
58055995
58065996 display.PopMaterial(this, selected);
58075997 }
....@@ -6174,6 +6364,11 @@
61746364 // dec 2012
61756365 new Exception().printStackTrace();
61766366 return;
6367
+ }
6368
+
6369
+ if (dontselect)
6370
+ {
6371
+ //bRep.GenerateNormalsMINE();
61776372 }
61786373
61796374 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7026,7 +7221,7 @@
70267221 spot.translate(32, 32);
70277222 spotw = spot.x + spot.width;
70287223 spoth = spot.y + spot.height;
7029
- info.g.setColor(Color.blue);
7224
+ info.g.setColor(Color.cyan);
70307225 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70317226 // if (CameraPane.Xmin > spot.x)
70327227 // {
....@@ -7044,11 +7239,12 @@
70447239 // {
70457240 // CameraPane.Ymax = spoth;
70467241 // }
7047
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7048
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7242
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7243
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70497244 spot.translate(0, -32);
7050
- info.g.setColor(Color.green);
7245
+ info.g.setColor(Color.yellow);
70517246 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7247
+ info.g.setColor(Color.green);
70527248 // if (CameraPane.Xmin > spot.x)
70537249 // {
70547250 // CameraPane.Xmin = spot.x;
....@@ -7366,19 +7562,20 @@
73667562 switch (info.pane.RenderCamera().viewCode)
73677563 {
73687564 case 3: // '\001'
7369
- if (modified)
7565
+ if (modified || opposite)
73707566 {
73717567 //LA.matScale(toParent, 1, hScale, vScale);
73727568 LA.matScale(toParent, totalScale, 1, 1);
73737569 } // vScale, 1);
73747570 else
73757571 {
7572
+ // EXCEPTION!
73767573 LA.matScale(toParent, totalScale, totalScale, totalScale);
73777574 } // vScale, 1);
73787575 break;
73797576
73807577 case 2: // '\002'
7381
- if (modified)
7578
+ if (modified || opposite)
73827579 {
73837580 //LA.matScale(toParent, hScale, 1, vScale);
73847581 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7389,7 +7586,7 @@
73897586 break;
73907587
73917588 case 1: // '\003'
7392
- if (modified)
7589
+ if (modified || opposite)
73937590 {
73947591 //LA.matScale(toParent, hScale, vScale, 1);
73957592 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7609,6 +7806,10 @@
76097806 editWindow = null;
76107807 } // ?
76117808 }
7809
+ else
7810
+ {
7811
+ //editWindow.closeUI();
7812
+ }
76127813 }
76137814
76147815 boolean root; // patch for edit windows