Normand Briere
2019-08-08 8294241adc5fe698b70e13ebd6780af46ab83f7e
Object3D.java
....@@ -22,6 +22,7 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
2728 // TEMPORARY for mocap undo. No need to be transient.
....@@ -29,7 +30,10 @@
2930 Object3D saveskeleton;
3031 //
3132
32
- byte[] versions[];
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
3337 int versionindex = -1;
3438
3539 ScriptNode scriptnode;
....@@ -219,7 +223,7 @@
219223 // o.bRep.support = null;
220224 // }
221225 o.selection = this.selection;
222
- o.versions = this.versions;
226
+ o.versionlist = this.versionlist;
223227 o.versionindex = this.versionindex;
224228
225229 if (this.support != null)
....@@ -242,6 +246,29 @@
242246 // this.support = null;
243247 // this.fileparent = null;
244248 }
249
+
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
245272
246273 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247274 {
....@@ -277,7 +304,7 @@
277304
278305 this.selection = o.selection;
279306
280
- this.versions = o.versions;
307
+ this.versionlist = o.versionlist;
281308 this.versionindex = o.versionindex;
282309 // July 2019 if (this.bRep != null)
283310 // this.bRep.support = o.transientrep;
....@@ -1011,6 +1038,9 @@
10111038
10121039 if (material == null || material.multiply)
10131040 return true;
1041
+
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
10141044
10151045 // Transparent objects are dynamic because we have to sort the triangles.
10161046 return material.opacity > 0.99;
....@@ -2438,6 +2468,7 @@
24382468 else
24392469 {
24402470 //((ObjEditor)editWindow).SetupUI2(null);
2471
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
24412472 }
24422473 }
24432474
....@@ -2567,7 +2598,8 @@
25672598 private static final int editSelf = 1;
25682599 private static final int editChild = 2;
25692600
2570
- void drawEditHandles(ClickInfo info, int level)
2601
+ void drawEditHandles(//ClickInfo info,
2602
+ int level)
25712603 {
25722604 if (level == 0)
25732605 {
....@@ -2575,7 +2607,8 @@
25752607 return;
25762608
25772609 Object3D selectee;
2578
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2610
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2611
+ level + 1))
25792612 {
25802613 selectee = (Object3D) e.nextElement();
25812614 }
....@@ -2583,19 +2616,22 @@
25832616 } else
25842617 {
25852618 //super.
2586
- drawEditHandles0(info, level + 1);
2619
+ drawEditHandles0(//info,
2620
+ level + 1);
25872621 }
25882622 }
25892623
2590
- boolean doEditClick(ClickInfo info, int level)
2624
+ boolean doEditClick(//ClickInfo info,
2625
+ int level)
25912626 {
25922627 doSomething = 0;
25932628 if (level == 0)
25942629 {
2595
- return doParentClick(info);
2630
+ return doParentClick(); //info);
25962631 }
25972632 if (//super.
2598
- doEditClick0(info, level))
2633
+ doEditClick0(//info,
2634
+ level))
25992635 {
26002636 doSomething = 1;
26012637 return true;
....@@ -2605,7 +2641,7 @@
26052641 }
26062642 }
26072643
2608
- boolean doParentClick(ClickInfo info)
2644
+ boolean doParentClick() //ClickInfo info)
26092645 {
26102646 if (selection == null)
26112647 {
....@@ -2618,7 +2654,8 @@
26182654 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192655 {
26202656 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2657
+ if (selectee.doEditClick(//info,
2658
+ 1))
26222659 {
26232660 childToDrag = selectee;
26242661 doSomething = 2;
....@@ -2630,13 +2667,15 @@
26302667 return retval;
26312668 }
26322669
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2670
+ void doEditDrag(//ClickInfo clickInfo,
2671
+ boolean opposite)
26342672 {
26352673 switch (doSomething)
26362674 {
26372675 case 1: // '\001'
26382676 //super.
2639
- doEditDrag0(info, opposite);
2677
+ doEditDrag0(//clickInfo,
2678
+ opposite);
26402679 break;
26412680
26422681 case 2: // '\002'
....@@ -2649,11 +2688,13 @@
26492688 {
26502689 //sel.hitSomething = childToDrag.hitSomething;
26512690 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2691
+ sel.doEditDrag(//clickInfo,
2692
+ opposite);
26532693 } else
26542694 {
26552695 //super.
2656
- doEditDrag0(info, opposite);
2696
+ doEditDrag0(//clickInfo,
2697
+ opposite);
26572698 }
26582699 }
26592700 break;
....@@ -2671,6 +2712,9 @@
26712712 {
26722713 deselectAll();
26732714 }
2715
+
2716
+ new Exception().printStackTrace();
2717
+
26742718 ClickInfo newInfo = new ClickInfo();
26752719 newInfo.flags = info.flags;
26762720 newInfo.bounds = info.bounds;
....@@ -5893,8 +5937,10 @@
58935937 if (support != null)
58945938 support = support;
58955939
5896
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5897
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5940
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5942
+
5943
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58985944
58995945 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59005946 {
....@@ -5904,8 +5950,9 @@
59045950 // usecalllists &= !(parent instanceof RandomNode);
59055951 // usecalllists = false;
59065952
5907
- if (GetBRep() != null)
5908
- usecalllists = usecalllists;
5953
+ if (display.DrawMode() == display.SHADOW)
5954
+ //GetBRep() != null)
5955
+ usecalllists = !!usecalllists;
59095956 //System.out.println("draw " + this);
59105957 //new Exception().printStackTrace();
59115958
....@@ -5927,7 +5974,7 @@
59275974 if (!(this instanceof Composite))
59285975 touched = false;
59295976 //if (displaylist == -1 && usecalllists)
5930
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5977
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59315978 {
59325979 bRep.displaylist = display.GenList();
59335980 assert(bRep.displaylist != 0);
....@@ -5938,7 +5985,7 @@
59385985
59395986 //System.out.println("\tnew list " + list);
59405987 //gl.glDrawBuffer(gl.GL_NONE);
5941
- if (usecalllists)
5988
+ if (usecalllists && bRep.displaylist > 0)
59425989 {
59435990 // System.err.println("new list " + bRep.displaylist + " for " + this);
59445991 display.NewList(bRep.displaylist);
....@@ -5947,7 +5994,7 @@
59475994 CallList(display, root, selected, blocked);
59485995
59495996 // compiled = true;
5950
- if (usecalllists)
5997
+ if (usecalllists && bRep.displaylist > 0)
59515998 {
59525999 // System.err.println("end list " + bRep.displaylist + " for " + this);
59536000 display.EndList();
....@@ -7298,20 +7345,23 @@
72987345 }
72997346 }
73007347
7301
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7348
+ static ClickInfo clickInfo = new ClickInfo();
7349
+
7350
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7351
+ Point outPt, Rectangle outRec)
73027352 {
7303
- int hc = info.bounds.x + info.bounds.width / 2;
7304
- int vc = info.bounds.y + info.bounds.height / 2;
7305
- double[][] toscreen = info.toScreen;
7353
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7354
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7355
+ double[][] toscreen = clickInfo.toScreen;
73067356 if (toscreen == null)
73077357 {
7308
- toscreen = new Camera(info.camera.viewCode).toScreen;
7358
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73097359 }
73107360 cVector vec = in;
73117361 LA.xformPos(in, toscreen, in);
73127362 //System.out.println("Distance = " + info.camera.Distance());
7313
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7314
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7363
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7364
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73157365 outPt.x = hc + (int) vec.x;
73167366 outPt.y = vc - (int) vec.y;
73177367 outRec.x = outPt.x - 3;
....@@ -7319,15 +7369,18 @@
73197369 outRec.width = outRec.height = 6;
73207370 }
73217371
7322
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7372
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7373
+ )
73237374 {
73247375 Point pt = new Point(0, 0);
73257376 Rectangle rec = new Rectangle();
7326
- calcHotSpot(in, info, pt, rec);
7377
+ calcHotSpot(in, //clickInfo,
7378
+ pt, rec);
73277379 return rec;
73287380 }
73297381
7330
- void drawEditHandles0(ClickInfo info, int level)
7382
+ void drawEditHandles0(//ClickInfo clickInfo,
7383
+ int level)
73317384 {
73327385 if (level == 0)
73337386 {
....@@ -7336,16 +7389,19 @@
73367389 {
73377390 cVector origin = new cVector();
73387391 //LA.xformPos(origin, toParent, origin);
7339
- Rectangle spot = calcHotSpot(origin, info);
7392
+ if (this.clickInfo == null)
7393
+ this.clickInfo = new ClickInfo();
7394
+
7395
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73407396 Rectangle boundary = new Rectangle();
73417397 boundary.x = spot.x - 30;
73427398 boundary.y = spot.y - 30;
73437399 boundary.width = spot.width + 60;
73447400 boundary.height = spot.height + 60;
7345
- info.g.setColor(Color.red);
7401
+ clickInfo.g.setColor(Color.red);
73467402 int spotw = spot.x + spot.width;
73477403 int spoth = spot.y + spot.height;
7348
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7404
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73497405 // if (CameraPane.Xmin > spot.x)
73507406 // {
73517407 // CameraPane.Xmin = spot.x;
....@@ -7365,8 +7421,8 @@
73657421 spot.translate(32, 32);
73667422 spotw = spot.x + spot.width;
73677423 spoth = spot.y + spot.height;
7368
- info.g.setColor(Color.cyan);
7369
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7424
+ clickInfo.g.setColor(Color.cyan);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73707426 // if (CameraPane.Xmin > spot.x)
73717427 // {
73727428 // CameraPane.Xmin = spot.x;
....@@ -7386,9 +7442,9 @@
73867442 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73877443 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73887444 spot.translate(0, -32);
7389
- info.g.setColor(Color.yellow);
7390
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7391
- info.g.setColor(Color.green);
7445
+ clickInfo.g.setColor(Color.yellow);
7446
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7447
+ clickInfo.g.setColor(Color.green);
73927448 // if (CameraPane.Xmin > spot.x)
73937449 // {
73947450 // CameraPane.Xmin = spot.x;
....@@ -7405,8 +7461,8 @@
74057461 // {
74067462 // CameraPane.Ymax = spoth;
74077463 // }
7408
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
7464
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7465
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74107466 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74117467 // if (CameraPane.Xmin > boundary.x)
74127468 // {
....@@ -7428,7 +7484,8 @@
74287484 }
74297485 }
74307486
7431
- boolean doEditClick0(ClickInfo info, int level)
7487
+ boolean doEditClick0(//ClickInfo clickInfo,
7488
+ int level)
74327489 {
74337490 if (level == 0)
74347491 {
....@@ -7437,8 +7494,8 @@
74377494
74387495 boolean retval = false;
74397496
7440
- startX = info.x;
7441
- startY = info.y;
7497
+ startX = clickInfo.x;
7498
+ startY = clickInfo.y;
74427499
74437500 hitSomething = -1;
74447501 cVector origin = new cVector();
....@@ -7448,22 +7505,51 @@
74487505 {
74497506 centerPt = new Point(0, 0);
74507507 }
7451
- calcHotSpot(origin, info, centerPt, spot);
7452
- if (spot.contains(info.x, info.y))
7508
+ calcHotSpot(origin, //info,
7509
+ centerPt, spot);
7510
+ if (spot.contains(clickInfo.x, clickInfo.y))
74537511 {
74547512 hitSomething = hitCenter;
74557513 retval = true;
74567514 }
74577515 spot.translate(32, 0);
7458
- if (spot.contains(info.x, info.y))
7516
+ if (spot.contains(clickInfo.x, clickInfo.y))
74597517 {
74607518 hitSomething = hitRotate;
74617519 retval = true;
74627520 }
74637521 spot.translate(0, 32);
7464
- if (spot.contains(info.x, info.y))
7522
+ if (spot.contains(clickInfo.x, clickInfo.y))
74657523 {
74667524 hitSomething = hitScale;
7525
+
7526
+ double scale = 0.005f * clickInfo.camera.Distance();
7527
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7528
+ double sign = 1;
7529
+ if (hScale < 0)
7530
+ {
7531
+ sign = -1;
7532
+ }
7533
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7534
+ if (hScale < 0.01)
7535
+ {
7536
+ //hScale = 0.01;
7537
+ }
7538
+
7539
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7540
+ sign = 1;
7541
+ if (vScale < 0)
7542
+ {
7543
+ sign = -1;
7544
+ }
7545
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7546
+ if (vScale < 0.01)
7547
+ {
7548
+ //vScale = 0.01;
7549
+ }
7550
+
7551
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7552
+
74677553 retval = true;
74687554 }
74697555
....@@ -7473,7 +7559,7 @@
74737559 }
74747560
74757561 //System.out.println("info.modifiers = " + info.modifiers);
7476
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7562
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74777563 //System.out.println("modified = " + modified);
74787564 //new Exception().printStackTrace();
74797565 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7501,7 +7587,8 @@
75017587 return true;
75027588 }
75037589
7504
- void doEditDrag0(ClickInfo info, boolean opposite)
7590
+ void doEditDrag0(//ClickInfo info,
7591
+ boolean opposite)
75057592 {
75067593 if (hitSomething == 0)
75077594 {
....@@ -7515,7 +7602,7 @@
75157602
75167603 //System.out.println("hitSomething = " + hitSomething);
75177604
7518
- double scale = 0.005f * info.camera.Distance();
7605
+ double scale = 0.005f * clickInfo.camera.Distance();
75197606
75207607 cVector xlate = new cVector();
75217608 //cVector xlate2 = new cVector();
....@@ -7549,8 +7636,8 @@
75497636 toParent[3][i] = xlate.get(i);
75507637 LA.matInvert(toParent, fromParent);
75517638 */
7552
- cVector delta = LA.newVector(0, 0, startY - info.y);
7553
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7639
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7640
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75547641
75557642 LA.matCopy(startMat, toParent);
75567643 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7559,7 +7646,7 @@
75597646 } else
75607647 {
75617648 //LA.xformDir(delta, info.camera.fromScreen, delta);
7562
- cVector up = new cVector(info.camera.up);
7649
+ cVector up = new cVector(clickInfo.camera.up);
75637650 cVector away = new cVector();
75647651 //cVector right2 = new cVector();
75657652 //LA.vecCross(up, cVector.Z, right);
....@@ -7576,19 +7663,19 @@
75767663 LA.xformDir(up, ClickInfo.matbuffer, up);
75777664 // if (!CameraPane.LOCALTRANSFORM)
75787665 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7579
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7666
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75807667 // if (!CameraPane.LOCALTRANSFORM)
75817668 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75827669 //LA.vecCross(up, cVector.Z, right2);
75837670
7584
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7671
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75857672
75867673 //System.out.println("DELTA0 = " + delta);
75877674 //System.out.println("AWAY = " + info.camera.away);
75887675 //System.out.println("UP = " + info.camera.up);
75897676 if (away.z > 0)
75907677 {
7591
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7678
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75927679 {
75937680 delta.x = -delta.x;
75947681 } else
....@@ -7603,7 +7690,7 @@
76037690 //System.out.println("DELTA1 = " + delta);
76047691 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76057692 //System.out.println("DELTA2 = " + delta);
7606
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7693
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76077694 LA.matCopy(startMat, toParent);
76087695 //System.out.println("DELTA3 = " + delta);
76097696 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7613,8 +7700,8 @@
76137700 break;
76147701
76157702 case hitRotate: // rotate
7616
- int dx = info.x - centerPt.x;
7617
- int dy = -(info.y - centerPt.y);
7703
+ int dx = clickInfo.x - centerPt.x;
7704
+ int dy = -(clickInfo.y - centerPt.y);
76187705 double angle = (double) Math.atan2(dx, dy);
76197706 angle = -(1.570796 - angle);
76207707
....@@ -7637,7 +7724,7 @@
76377724 }
76387725 /**/
76397726
7640
- switch (info.pane.RenderCamera().viewCode)
7727
+ switch (clickInfo.pane.RenderCamera().viewCode)
76417728 {
76427729 case 1: // '\001'
76437730 LA.matZRotate(toParent, angle);
....@@ -7664,7 +7751,7 @@
76647751 break;
76657752
76667753 case hitScale: // scale
7667
- double hScale = (double) (info.x - centerPt.x) / 32;
7754
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
76687755 double sign = 1;
76697756 if (hScale < 0)
76707757 {
....@@ -7676,7 +7763,7 @@
76767763 //hScale = 0.01;
76777764 }
76787765
7679
- double vScale = (double) (info.y - centerPt.y) / 32;
7766
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
76807767 sign = 1;
76817768 if (vScale < 0)
76827769 {
....@@ -7687,6 +7774,7 @@
76877774 {
76887775 //vScale = 0.01;
76897776 }
7777
+
76907778 LA.matCopy(startMat, toParent);
76917779 /**/
76927780 for (int i = 0; i < 3; i++)
....@@ -7696,14 +7784,14 @@
76967784 }
76977785 /**/
76987786
7699
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7787
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
77007788
77017789 if (totalScale < 0.01)
77027790 {
77037791 totalScale = 0.01;
77047792 }
77057793
7706
- switch (info.pane.RenderCamera().viewCode)
7794
+ switch (clickInfo.pane.RenderCamera().viewCode)
77077795 {
77087796 case 3: // '\001'
77097797 if (modified || opposite)
....@@ -7770,7 +7858,7 @@
77707858 } // NEW ...
77717859
77727860
7773
- info.pane.repaint();
7861
+ clickInfo.pane.repaint();
77747862 }
77757863
77767864 boolean overflow = false;