Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
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,59 @@
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
+ 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;
177
+ }
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
+}
197
+
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++)
214
+ {
215
+ get(i).RestoreBigData(hashtable);
159216 }
160217 }
161218
....@@ -775,7 +832,7 @@
775832 if (step == 0)
776833 step = 1;
777834 if (maxcount == 0)
778
- maxcount = 2048; // 4;
835
+ maxcount = 128; // 2048; // 4;
779836 // if (acceleration == 0)
780837 // acceleration = 10;
781838 if (delay == 0) // serial
....@@ -5371,6 +5428,43 @@
53715428 }
53725429 }
53735430
5431
+ UUID GetUUID()
5432
+ {
5433
+ if (uuid == null)
5434
+ {
5435
+ // Serial
5436
+ uuid = UUID.randomUUID();
5437
+ }
5438
+
5439
+ return uuid;
5440
+ }
5441
+
5442
+ Object3D GetObject(UUID uid)
5443
+ {
5444
+ if (blockloop)
5445
+ return null;
5446
+
5447
+ if (GetUUID().equals(uid))
5448
+ return this;
5449
+
5450
+ int nb = Size();
5451
+ for (int i = 0; i < nb; i++)
5452
+ {
5453
+ Object3D child = (Object3D) get(i);
5454
+
5455
+ if (child == null)
5456
+ continue;
5457
+
5458
+ blockloop = true;
5459
+ Object3D obj = child.GetObject(uid);
5460
+ blockloop = false;
5461
+ if (obj != null)
5462
+ return obj;
5463
+ }
5464
+
5465
+ return null;
5466
+ }
5467
+
53745468 void SetBumpTexture(String tex)
53755469 {
53765470 if (GetTextures() == null)
....@@ -6950,8 +7044,8 @@
69507044 // {
69517045 // CameraPane.Ymax = spoth;
69527046 // }
6953
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7047
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7048
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
69557049 spot.translate(0, -32);
69567050 info.g.setColor(Color.green);
69577051 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7006,7 +7100,7 @@
70067100 startX = info.x;
70077101 startY = info.y;
70087102
7009
- hitSomething = 0;
7103
+ hitSomething = -1;
70107104 cVector origin = new cVector();
70117105 //LA.xformPos(origin, toParent, origin);
70127106 Rectangle spot = new Rectangle();
....@@ -7082,6 +7176,7 @@
70827176 //System.out.println("hitSomething = " + hitSomething);
70837177
70847178 double scale = 0.005f * info.camera.Distance();
7179
+
70857180 cVector xlate = new cVector();
70867181 //cVector xlate2 = new cVector();
70877182 switch (hitSomething)
....@@ -7230,24 +7325,27 @@
72307325
72317326 case hitScale: // scale
72327327 double hScale = (double) (info.x - centerPt.x) / 32;
7328
+ double sign = 1;
7329
+ if (hScale < 0)
7330
+ {
7331
+ sign = -1;
7332
+ }
7333
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72337334 if (hScale < 0.01)
72347335 {
7235
- hScale = 0.01;
7336
+ //hScale = 0.01;
72367337 }
7237
- hScale = Math.pow(hScale, scale * 50);
7238
- if (hScale < 0.01)
7239
- {
7240
- hScale = 0.01;
7241
- }
7338
+
72427339 double vScale = (double) (info.y - centerPt.y) / 32;
7243
- if (vScale < 0.01)
7340
+ sign = 1;
7341
+ if (vScale < 0)
72447342 {
7245
- vScale = 0.01;
7343
+ sign = -1;
72467344 }
7247
- vScale = Math.pow(vScale, scale * 50);
7345
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72487346 if (vScale < 0.01)
72497347 {
7250
- vScale = 0.01;
7348
+ //vScale = 0.01;
72517349 }
72527350 LA.matCopy(startMat, toParent);
72537351 /**/
....@@ -7258,17 +7356,24 @@
72587356 }
72597357 /**/
72607358
7359
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7360
+
7361
+ if (totalScale < 0.01)
7362
+ {
7363
+ totalScale = 0.01;
7364
+ }
7365
+
72617366 switch (info.pane.RenderCamera().viewCode)
72627367 {
72637368 case 3: // '\001'
72647369 if (modified)
72657370 {
72667371 //LA.matScale(toParent, 1, hScale, vScale);
7267
- LA.matScale(toParent, vScale, 1, 1);
7372
+ LA.matScale(toParent, totalScale, 1, 1);
72687373 } // vScale, 1);
72697374 else
72707375 {
7271
- LA.matScale(toParent, vScale, vScale, vScale);
7376
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72727377 } // vScale, 1);
72737378 break;
72747379
....@@ -7276,10 +7381,10 @@
72767381 if (modified)
72777382 {
72787383 //LA.matScale(toParent, hScale, 1, vScale);
7279
- LA.matScale(toParent, 1, vScale, 1);
7384
+ LA.matScale(toParent, 1, totalScale, 1);
72807385 } else
72817386 {
7282
- LA.matScale(toParent, vScale, 1, vScale);
7387
+ LA.matScale(toParent, totalScale, 1, totalScale);
72837388 }
72847389 break;
72857390
....@@ -7287,10 +7392,10 @@
72877392 if (modified)
72887393 {
72897394 //LA.matScale(toParent, hScale, vScale, 1);
7290
- LA.matScale(toParent, 1, 1, vScale);
7395
+ LA.matScale(toParent, 1, 1, totalScale);
72917396 } else
72927397 {
7293
- LA.matScale(toParent, vScale, vScale, 1);
7398
+ LA.matScale(toParent, totalScale, totalScale, 1);
72947399 }
72957400 break;
72967401 }
....@@ -7431,7 +7536,7 @@
74317536 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74327537 } else
74337538 {
7434
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7539
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74357540 } // + super.toString();
74367541 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74377542
....@@ -7515,7 +7620,7 @@
75157620 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75167621
75177622 Object3D /*Composite*/ parent;
7518
- Object3D /*Composite*/ fileparent;
7623
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75197624
75207625 double[][] toParent; // dynamic matrix
75217626 double[][] fromParent;
....@@ -7679,9 +7784,9 @@
76797784 private static cVector edge2 = new cVector();
76807785 //private static cVector norm = new cVector();
76817786 /*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;
7787
+ static final int hitCenter = 1;
7788
+ static final int hitScale = 2;
7789
+ static final int hitRotate = 3;
76857790 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76867791 /*transient*/ private Point centerPt;
76877792 /*transient*/ private int startX;