Normand Briere
2019-06-11 4113164b3be1e50251ac40d6fd65660f0a6c2e63
Object3D.java
....@@ -14,11 +14,15 @@
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();
2226
2327 ScriptNode scriptnode;
2428
....@@ -156,6 +160,67 @@
156160 blockloop = true;
157161 child.RestoreSupports();
158162 blockloop = false;
163
+ }
164
+}
165
+
166
+void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
+{
168
+ if (hashtable.containsKey(GetUUID()))
169
+ {
170
+ Object3D o = hashtable.get(GetUUID());
171
+
172
+ assert(this.bRep == o.bRep);
173
+ if (this.bRep != null)
174
+ assert(this.bRep.support == o.transientrep);
175
+
176
+ return;
177
+ }
178
+
179
+ Object3D o = new Object3D();
180
+ o.bRep = this.bRep;
181
+ if (this.bRep != null)
182
+ {
183
+ o.transientrep = this.bRep.support;
184
+ o.bRep.support = null;
185
+ }
186
+
187
+// o.support = this.support;
188
+// o.fileparent = this.fileparent;
189
+// if (this.bRep != null)
190
+// o.bRep = this.bRep.support;
191
+
192
+ hashtable.put(GetUUID(), o);
193
+
194
+ this.bRep = null;
195
+// if (this.bRep != null)
196
+// this.bRep.support = null;
197
+// this.support = null;
198
+// this.fileparent = null;
199
+
200
+ for (int i=0; i<Size(); i++)
201
+ {
202
+ get(i).ExtractBigData(hashtable);
203
+ }
204
+}
205
+
206
+void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
207
+{
208
+ if (!hashtable.containsKey(GetUUID()))
209
+ return;
210
+
211
+ Object3D o = hashtable.get(GetUUID());
212
+
213
+ this.bRep = o.bRep;
214
+ if (this.bRep != null)
215
+ this.bRep.support = o.transientrep;
216
+// this.support = o.support;
217
+// this.fileparent = o.fileparent;
218
+
219
+ hashtable.remove(GetUUID());
220
+
221
+ for (int i=0; i<Size(); i++)
222
+ {
223
+ get(i).RestoreBigData(hashtable);
159224 }
160225 }
161226
....@@ -775,7 +840,7 @@
775840 if (step == 0)
776841 step = 1;
777842 if (maxcount == 0)
778
- maxcount = 2048; // 4;
843
+ maxcount = 128; // 2048; // 4;
779844 // if (acceleration == 0)
780845 // acceleration = 10;
781846 if (delay == 0) // serial
....@@ -5371,6 +5436,43 @@
53715436 }
53725437 }
53735438
5439
+ UUID GetUUID()
5440
+ {
5441
+ if (uuid == null)
5442
+ {
5443
+ // Serial
5444
+ uuid = UUID.randomUUID();
5445
+ }
5446
+
5447
+ return uuid;
5448
+ }
5449
+
5450
+ Object3D GetObject(UUID uid)
5451
+ {
5452
+ if (blockloop)
5453
+ return null;
5454
+
5455
+ if (GetUUID().equals(uid))
5456
+ return this;
5457
+
5458
+ int nb = Size();
5459
+ for (int i = 0; i < nb; i++)
5460
+ {
5461
+ Object3D child = (Object3D) get(i);
5462
+
5463
+ if (child == null)
5464
+ continue;
5465
+
5466
+ blockloop = true;
5467
+ Object3D obj = child.GetObject(uid);
5468
+ blockloop = false;
5469
+ if (obj != null)
5470
+ return obj;
5471
+ }
5472
+
5473
+ return null;
5474
+ }
5475
+
53745476 void SetBumpTexture(String tex)
53755477 {
53765478 if (GetTextures() == null)
....@@ -6950,8 +7052,8 @@
69507052 // {
69517053 // CameraPane.Ymax = spoth;
69527054 // }
6953
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7055
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7056
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
69557057 spot.translate(0, -32);
69567058 info.g.setColor(Color.green);
69577059 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7006,7 +7108,7 @@
70067108 startX = info.x;
70077109 startY = info.y;
70087110
7009
- hitSomething = 0;
7111
+ hitSomething = -1;
70107112 cVector origin = new cVector();
70117113 //LA.xformPos(origin, toParent, origin);
70127114 Rectangle spot = new Rectangle();
....@@ -7082,6 +7184,7 @@
70827184 //System.out.println("hitSomething = " + hitSomething);
70837185
70847186 double scale = 0.005f * info.camera.Distance();
7187
+
70857188 cVector xlate = new cVector();
70867189 //cVector xlate2 = new cVector();
70877190 switch (hitSomething)
....@@ -7230,24 +7333,27 @@
72307333
72317334 case hitScale: // scale
72327335 double hScale = (double) (info.x - centerPt.x) / 32;
7336
+ double sign = 1;
7337
+ if (hScale < 0)
7338
+ {
7339
+ sign = -1;
7340
+ }
7341
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72337342 if (hScale < 0.01)
72347343 {
7235
- hScale = 0.01;
7344
+ //hScale = 0.01;
72367345 }
7237
- hScale = Math.pow(hScale, scale * 50);
7238
- if (hScale < 0.01)
7239
- {
7240
- hScale = 0.01;
7241
- }
7346
+
72427347 double vScale = (double) (info.y - centerPt.y) / 32;
7243
- if (vScale < 0.01)
7348
+ sign = 1;
7349
+ if (vScale < 0)
72447350 {
7245
- vScale = 0.01;
7351
+ sign = -1;
72467352 }
7247
- vScale = Math.pow(vScale, scale * 50);
7353
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72487354 if (vScale < 0.01)
72497355 {
7250
- vScale = 0.01;
7356
+ //vScale = 0.01;
72517357 }
72527358 LA.matCopy(startMat, toParent);
72537359 /**/
....@@ -7258,17 +7364,24 @@
72587364 }
72597365 /**/
72607366
7367
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7368
+
7369
+ if (totalScale < 0.01)
7370
+ {
7371
+ totalScale = 0.01;
7372
+ }
7373
+
72617374 switch (info.pane.RenderCamera().viewCode)
72627375 {
72637376 case 3: // '\001'
72647377 if (modified)
72657378 {
72667379 //LA.matScale(toParent, 1, hScale, vScale);
7267
- LA.matScale(toParent, vScale, 1, 1);
7380
+ LA.matScale(toParent, totalScale, 1, 1);
72687381 } // vScale, 1);
72697382 else
72707383 {
7271
- LA.matScale(toParent, vScale, vScale, vScale);
7384
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72727385 } // vScale, 1);
72737386 break;
72747387
....@@ -7276,10 +7389,10 @@
72767389 if (modified)
72777390 {
72787391 //LA.matScale(toParent, hScale, 1, vScale);
7279
- LA.matScale(toParent, 1, vScale, 1);
7392
+ LA.matScale(toParent, 1, totalScale, 1);
72807393 } else
72817394 {
7282
- LA.matScale(toParent, vScale, 1, vScale);
7395
+ LA.matScale(toParent, totalScale, 1, totalScale);
72837396 }
72847397 break;
72857398
....@@ -7287,10 +7400,10 @@
72877400 if (modified)
72887401 {
72897402 //LA.matScale(toParent, hScale, vScale, 1);
7290
- LA.matScale(toParent, 1, 1, vScale);
7403
+ LA.matScale(toParent, 1, 1, totalScale);
72917404 } else
72927405 {
7293
- LA.matScale(toParent, vScale, vScale, 1);
7406
+ LA.matScale(toParent, totalScale, totalScale, 1);
72947407 }
72957408 break;
72967409 }
....@@ -7431,7 +7544,7 @@
74317544 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74327545 } else
74337546 {
7434
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7547
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74357548 } // + super.toString();
74367549 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74377550
....@@ -7515,7 +7628,7 @@
75157628 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75167629
75177630 Object3D /*Composite*/ parent;
7518
- Object3D /*Composite*/ fileparent;
7631
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75197632
75207633 double[][] toParent; // dynamic matrix
75217634 double[][] fromParent;
....@@ -7679,9 +7792,9 @@
76797792 private static cVector edge2 = new cVector();
76807793 //private static cVector norm = new cVector();
76817794 /*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;
7795
+ static final int hitCenter = 1;
7796
+ static final int hitScale = 2;
7797
+ static final int hitRotate = 3;
76857798 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76867799 /*transient*/ private Point centerPt;
76877800 /*transient*/ private int startX;