Normand Briere
2019-06-17 26b49d8e26625491f4a407a05e9bc9d72037f938
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,136 @@
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();
123
- }
124
-
125
- for (int i = 0; i < Size(); i++)
126
- {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
130
- blockloop = true;
131
- child.SaveSupports();
132
- blockloop = false;
133
- }
134
-}
120
+ if (blockloop)
121
+ return;
135122
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
140125
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
147
- {
148
- bRep.RestoreSupports();
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
+ }
149143 }
150
-
151
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
152146 {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
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
+ }
159169 }
160
-}
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
+ }
161242
162243 // MOCAP SUPPORT
163244 double tx,ty,tz,rx,ry,rz;
....@@ -482,12 +563,14 @@
482563 toParent = LA.newMatrix();
483564 fromParent = LA.newMatrix();
484565 }
566
+
485567 if (toParentMarked == null)
486568 {
487569 if (maxcount != 1)
488570 {
489571 new Exception().printStackTrace();
490572 }
573
+
491574 toParentMarked = LA.newMatrix();
492575 fromParentMarked = LA.newMatrix();
493576 }
....@@ -2628,6 +2711,18 @@
26282711 //Touch();
26292712 }
26302713
2714
+ void GenNormalsMeshS()
2715
+ {
2716
+ selection.GenNormalsMesh();
2717
+// for (int i=0; i<selection.size(); i++)
2718
+// {
2719
+// Object3D selectee = (Object3D) selection.elementAt(i);
2720
+// selectee.GenNormals(crease);
2721
+// }
2722
+
2723
+ //Touch();
2724
+ }
2725
+
26312726 void ClearColorsS()
26322727 {
26332728 selection.ClearColors();
....@@ -2759,6 +2854,24 @@
27592854 if (child == null)
27602855 continue;
27612856 child.GenNormals(crease);
2857
+// Children().release(i);
2858
+ }
2859
+ blockloop = false;
2860
+ }
2861
+
2862
+ void GenNormalsMesh()
2863
+ {
2864
+ if (blockloop)
2865
+ return;
2866
+
2867
+ blockloop = true;
2868
+ GenNormalsMesh0();
2869
+ for (int i = 0; i < Children().Size(); i++)
2870
+ {
2871
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2872
+ if (child == null)
2873
+ continue;
2874
+ child.GenNormalsMesh();
27622875 // Children().release(i);
27632876 }
27642877 blockloop = false;
....@@ -2927,6 +3040,15 @@
29273040 if (bRep != null)
29283041 {
29293042 bRep.GenerateNormals(crease);
3043
+ Touch();
3044
+ }
3045
+ }
3046
+
3047
+ void GenNormalsMesh0()
3048
+ {
3049
+ if (bRep != null)
3050
+ {
3051
+ bRep.GenerateNormalsMesh();
29303052 Touch();
29313053 }
29323054 }
....@@ -5371,6 +5493,43 @@
53715493 }
53725494 }
53735495
5496
+ UUID GetUUID()
5497
+ {
5498
+ if (uuid == null)
5499
+ {
5500
+ // Serial
5501
+ uuid = UUID.randomUUID();
5502
+ }
5503
+
5504
+ return uuid;
5505
+ }
5506
+
5507
+ Object3D GetObject(UUID uid)
5508
+ {
5509
+ if (blockloop)
5510
+ return null;
5511
+
5512
+ if (GetUUID().equals(uid))
5513
+ return this;
5514
+
5515
+ int nb = Size();
5516
+ for (int i = 0; i < nb; i++)
5517
+ {
5518
+ Object3D child = (Object3D) get(i);
5519
+
5520
+ if (child == null)
5521
+ continue;
5522
+
5523
+ blockloop = true;
5524
+ Object3D obj = child.GetObject(uid);
5525
+ blockloop = false;
5526
+ if (obj != null)
5527
+ return obj;
5528
+ }
5529
+
5530
+ return null;
5531
+ }
5532
+
53745533 void SetBumpTexture(String tex)
53755534 {
53765535 if (GetTextures() == null)
....@@ -5415,12 +5574,23 @@
54155574 boolean NeedSupport()
54165575 {
54175576 return
5418
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5577
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54195578 // PROBLEM with CROWD!!
54205579 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54215580 }
54225581
54235582 static boolean DEBUG_SELECTION = false;
5583
+
5584
+ boolean IsLive()
5585
+ {
5586
+ if (live)
5587
+ return true;
5588
+
5589
+ if (parent == null)
5590
+ return false;
5591
+
5592
+ return parent.IsLive();
5593
+ }
54245594
54255595 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54265596 {
....@@ -5483,7 +5653,7 @@
54835653 support = support;
54845654
54855655 //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);
5656
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54875657
54885658 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54895659 {
....@@ -5503,10 +5673,12 @@
55035673 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55045674
55055675 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5506
- (touched || (bRep != null && bRep.displaylist <= 0)))
5676
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
55075678 {
55085679 Globals.lighttouched = true;
55095680 } // all panes...
5681
+
55105682 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55115683 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55125684 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -6932,7 +7104,7 @@
69327104 spot.translate(32, 32);
69337105 spotw = spot.x + spot.width;
69347106 spoth = spot.y + spot.height;
6935
- info.g.setColor(Color.blue);
7107
+ info.g.setColor(Color.cyan);
69367108 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69377109 // if (CameraPane.Xmin > spot.x)
69387110 // {
....@@ -6950,11 +7122,12 @@
69507122 // {
69517123 // CameraPane.Ymax = spoth;
69527124 // }
6953
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7125
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7126
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69557127 spot.translate(0, -32);
6956
- info.g.setColor(Color.green);
7128
+ info.g.setColor(Color.yellow);
69577129 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7130
+ info.g.setColor(Color.green);
69587131 // if (CameraPane.Xmin > spot.x)
69597132 // {
69607133 // CameraPane.Xmin = spot.x;
....@@ -7272,19 +7445,20 @@
72727445 switch (info.pane.RenderCamera().viewCode)
72737446 {
72747447 case 3: // '\001'
7275
- if (modified)
7448
+ if (modified || opposite)
72767449 {
72777450 //LA.matScale(toParent, 1, hScale, vScale);
72787451 LA.matScale(toParent, totalScale, 1, 1);
72797452 } // vScale, 1);
72807453 else
72817454 {
7455
+ // EXCEPTION!
72827456 LA.matScale(toParent, totalScale, totalScale, totalScale);
72837457 } // vScale, 1);
72847458 break;
72857459
72867460 case 2: // '\002'
7287
- if (modified)
7461
+ if (modified || opposite)
72887462 {
72897463 //LA.matScale(toParent, hScale, 1, vScale);
72907464 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7295,7 +7469,7 @@
72957469 break;
72967470
72977471 case 1: // '\003'
7298
- if (modified)
7472
+ if (modified || opposite)
72997473 {
73007474 //LA.matScale(toParent, hScale, vScale, 1);
73017475 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7526,7 +7700,7 @@
75267700 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75277701
75287702 Object3D /*Composite*/ parent;
7529
- Object3D /*Composite*/ fileparent;
7703
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75307704
75317705 double[][] toParent; // dynamic matrix
75327706 double[][] fromParent;