Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
Object3D.java
....@@ -29,7 +29,10 @@
2929 Object3D saveskeleton;
3030 //
3131
32
- byte[] versions[] = new byte[100][];
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ byte[] versions[];
3336 int versionindex = -1;
3437
3538 ScriptNode scriptnode;
....@@ -219,6 +222,8 @@
219222 // o.bRep.support = null;
220223 // }
221224 o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
222227
223228 if (this.support != null)
224229 {
....@@ -274,6 +279,9 @@
274279 }
275280
276281 this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
277285 // July 2019 if (this.bRep != null)
278286 // this.bRep.support = o.transientrep;
279287 // this.support = o.support;
....@@ -421,6 +429,7 @@
421429 }
422430
423431 boolean live = false;
432
+ transient boolean keepdontselect;
424433 boolean dontselect = false;
425434 boolean hide = false;
426435 boolean link2master = false; // performs reset support/master at each frame
....@@ -2561,7 +2570,8 @@
25612570 private static final int editSelf = 1;
25622571 private static final int editChild = 2;
25632572
2564
- void drawEditHandles(ClickInfo info, int level)
2573
+ void drawEditHandles(//ClickInfo info,
2574
+ int level)
25652575 {
25662576 if (level == 0)
25672577 {
....@@ -2569,7 +2579,8 @@
25692579 return;
25702580
25712581 Object3D selectee;
2572
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2582
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2583
+ level + 1))
25732584 {
25742585 selectee = (Object3D) e.nextElement();
25752586 }
....@@ -2577,19 +2588,22 @@
25772588 } else
25782589 {
25792590 //super.
2580
- drawEditHandles0(info, level + 1);
2591
+ drawEditHandles0(//info,
2592
+ level + 1);
25812593 }
25822594 }
25832595
2584
- boolean doEditClick(ClickInfo info, int level)
2596
+ boolean doEditClick(//ClickInfo info,
2597
+ int level)
25852598 {
25862599 doSomething = 0;
25872600 if (level == 0)
25882601 {
2589
- return doParentClick(info);
2602
+ return doParentClick(); //info);
25902603 }
25912604 if (//super.
2592
- doEditClick0(info, level))
2605
+ doEditClick0(//info,
2606
+ level))
25932607 {
25942608 doSomething = 1;
25952609 return true;
....@@ -2599,7 +2613,7 @@
25992613 }
26002614 }
26012615
2602
- boolean doParentClick(ClickInfo info)
2616
+ boolean doParentClick() //ClickInfo info)
26032617 {
26042618 if (selection == null)
26052619 {
....@@ -2612,7 +2626,8 @@
26122626 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26132627 {
26142628 Object3D selectee = (Object3D) e.nextElement();
2615
- if (selectee.doEditClick(info, 1))
2629
+ if (selectee.doEditClick(//info,
2630
+ 1))
26162631 {
26172632 childToDrag = selectee;
26182633 doSomething = 2;
....@@ -2624,13 +2639,15 @@
26242639 return retval;
26252640 }
26262641
2627
- void doEditDrag(ClickInfo info, boolean opposite)
2642
+ void doEditDrag(//ClickInfo clickInfo,
2643
+ boolean opposite)
26282644 {
26292645 switch (doSomething)
26302646 {
26312647 case 1: // '\001'
26322648 //super.
2633
- doEditDrag0(info, opposite);
2649
+ doEditDrag0(//clickInfo,
2650
+ opposite);
26342651 break;
26352652
26362653 case 2: // '\002'
....@@ -2643,11 +2660,13 @@
26432660 {
26442661 //sel.hitSomething = childToDrag.hitSomething;
26452662 //childToDrag.doEditDrag(info);
2646
- sel.doEditDrag(info, opposite);
2663
+ sel.doEditDrag(//clickInfo,
2664
+ opposite);
26472665 } else
26482666 {
26492667 //super.
2650
- doEditDrag0(info, opposite);
2668
+ doEditDrag0(//clickInfo,
2669
+ opposite);
26512670 }
26522671 }
26532672 break;
....@@ -2665,6 +2684,9 @@
26652684 {
26662685 deselectAll();
26672686 }
2687
+
2688
+ new Exception().printStackTrace();
2689
+
26682690 ClickInfo newInfo = new ClickInfo();
26692691 newInfo.flags = info.flags;
26702692 newInfo.bounds = info.bounds;
....@@ -3112,7 +3134,7 @@
31123134 {
31133135 if (bRep != null)
31143136 {
3115
- bRep.GenerateNormalsMINE();
3137
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31163138 Touch();
31173139 }
31183140 }
....@@ -5415,6 +5437,51 @@
54155437 blockloop = false;
54165438 }
54175439
5440
+ void ResetSelectable()
5441
+ {
5442
+ if (blockloop)
5443
+ return;
5444
+
5445
+ blockloop = true;
5446
+
5447
+ keepdontselect = dontselect;
5448
+ dontselect = true;
5449
+
5450
+ Object3D child;
5451
+ int nb = Size();
5452
+ for (int i = 0; i < nb; i++)
5453
+ {
5454
+ child = (Object3D) get(i);
5455
+ if (child == null)
5456
+ continue;
5457
+ child.ResetSelectable();
5458
+ }
5459
+
5460
+ blockloop = false;
5461
+ }
5462
+
5463
+ void RestoreSelectable()
5464
+ {
5465
+ if (blockloop)
5466
+ return;
5467
+
5468
+ blockloop = true;
5469
+
5470
+ dontselect = keepdontselect;
5471
+
5472
+ Object3D child;
5473
+ int nb = Size();
5474
+ for (int i = 0; i < nb; i++)
5475
+ {
5476
+ child = (Object3D) get(i);
5477
+ if (child == null)
5478
+ continue;
5479
+ child.RestoreSelectable();
5480
+ }
5481
+
5482
+ blockloop = false;
5483
+ }
5484
+
54185485 boolean IsSelected()
54195486 {
54205487 if (parent == null)
....@@ -5724,6 +5791,38 @@
57245791 }
57255792 }
57265793
5794
+ void EmbedTextures(boolean embed)
5795
+ {
5796
+ if (blockloop)
5797
+ return;
5798
+
5799
+ //if (GetTextures() != null)
5800
+ if (embed)
5801
+ CameraPane.EmbedTextures(GetTextures());
5802
+ else
5803
+ {
5804
+ GetTextures().pigmentdata = null;
5805
+ GetTextures().bumpdata = null;
5806
+ GetTextures().pw = 0;
5807
+ GetTextures().ph = 0;
5808
+ GetTextures().bw = 0;
5809
+ GetTextures().bh = 0;
5810
+ }
5811
+
5812
+ int nb = Size();
5813
+ for (int i = 0; i < nb; i++)
5814
+ {
5815
+ Object3D child = (Object3D) get(i);
5816
+
5817
+ if (child == null)
5818
+ continue;
5819
+
5820
+ blockloop = true;
5821
+ child.EmbedTextures(embed);
5822
+ blockloop = false;
5823
+ }
5824
+ }
5825
+
57275826 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57285827 {
57295828 Draw(display, root, selected, blocked);
....@@ -5811,7 +5910,7 @@
58115910 support = support;
58125911
58135912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5814
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5913
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
58155914
58165915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58175916 {
....@@ -7215,20 +7314,23 @@
72157314 }
72167315 }
72177316
7218
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7317
+ static ClickInfo clickInfo = new ClickInfo();
7318
+
7319
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7320
+ Point outPt, Rectangle outRec)
72197321 {
7220
- int hc = info.bounds.x + info.bounds.width / 2;
7221
- int vc = info.bounds.y + info.bounds.height / 2;
7222
- double[][] toscreen = info.toScreen;
7322
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7323
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7324
+ double[][] toscreen = clickInfo.toScreen;
72237325 if (toscreen == null)
72247326 {
7225
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72267328 }
72277329 cVector vec = in;
72287330 LA.xformPos(in, toscreen, in);
72297331 //System.out.println("Distance = " + info.camera.Distance());
7230
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7231
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7332
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7333
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72327334 outPt.x = hc + (int) vec.x;
72337335 outPt.y = vc - (int) vec.y;
72347336 outRec.x = outPt.x - 3;
....@@ -7236,15 +7338,18 @@
72367338 outRec.width = outRec.height = 6;
72377339 }
72387340
7239
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
72407343 {
72417344 Point pt = new Point(0, 0);
72427345 Rectangle rec = new Rectangle();
7243
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
72447348 return rec;
72457349 }
72467350
7247
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
72487353 {
72497354 if (level == 0)
72507355 {
....@@ -7253,16 +7358,19 @@
72537358 {
72547359 cVector origin = new cVector();
72557360 //LA.xformPos(origin, toParent, origin);
7256
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72577365 Rectangle boundary = new Rectangle();
72587366 boundary.x = spot.x - 30;
72597367 boundary.y = spot.y - 30;
72607368 boundary.width = spot.width + 60;
72617369 boundary.height = spot.height + 60;
7262
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
72637371 int spotw = spot.x + spot.width;
72647372 int spoth = spot.y + spot.height;
7265
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72667374 // if (CameraPane.Xmin > spot.x)
72677375 // {
72687376 // CameraPane.Xmin = spot.x;
....@@ -7282,8 +7390,8 @@
72827390 spot.translate(32, 32);
72837391 spotw = spot.x + spot.width;
72847392 spoth = spot.y + spot.height;
7285
- info.g.setColor(Color.cyan);
7286
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7393
+ clickInfo.g.setColor(Color.cyan);
7394
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72877395 // if (CameraPane.Xmin > spot.x)
72887396 // {
72897397 // CameraPane.Xmin = spot.x;
....@@ -7303,9 +7411,9 @@
73037411 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73047412 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73057413 spot.translate(0, -32);
7306
- info.g.setColor(Color.yellow);
7307
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
- info.g.setColor(Color.green);
7414
+ clickInfo.g.setColor(Color.yellow);
7415
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7416
+ clickInfo.g.setColor(Color.green);
73097417 // if (CameraPane.Xmin > spot.x)
73107418 // {
73117419 // CameraPane.Xmin = spot.x;
....@@ -7322,8 +7430,8 @@
73227430 // {
73237431 // CameraPane.Ymax = spoth;
73247432 // }
7325
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
7433
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7434
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73277435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73287436 // if (CameraPane.Xmin > boundary.x)
73297437 // {
....@@ -7345,7 +7453,8 @@
73457453 }
73467454 }
73477455
7348
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
73497458 {
73507459 if (level == 0)
73517460 {
....@@ -7354,8 +7463,8 @@
73547463
73557464 boolean retval = false;
73567465
7357
- startX = info.x;
7358
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
73597468
73607469 hitSomething = -1;
73617470 cVector origin = new cVector();
....@@ -7365,22 +7474,51 @@
73657474 {
73667475 centerPt = new Point(0, 0);
73677476 }
7368
- calcHotSpot(origin, info, centerPt, spot);
7369
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707480 {
73717481 hitSomething = hitCenter;
73727482 retval = true;
73737483 }
73747484 spot.translate(32, 0);
7375
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
73767486 {
73777487 hitSomething = hitRotate;
73787488 retval = true;
73797489 }
73807490 spot.translate(0, 32);
7381
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
73827492 {
73837493 hitSomething = hitScale;
7494
+
7495
+ double scale = 0.005f * clickInfo.camera.Distance();
7496
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7497
+ double sign = 1;
7498
+ if (hScale < 0)
7499
+ {
7500
+ sign = -1;
7501
+ }
7502
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7503
+ if (hScale < 0.01)
7504
+ {
7505
+ //hScale = 0.01;
7506
+ }
7507
+
7508
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7509
+ sign = 1;
7510
+ if (vScale < 0)
7511
+ {
7512
+ sign = -1;
7513
+ }
7514
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7515
+ if (vScale < 0.01)
7516
+ {
7517
+ //vScale = 0.01;
7518
+ }
7519
+
7520
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7521
+
73847522 retval = true;
73857523 }
73867524
....@@ -7390,7 +7528,7 @@
73907528 }
73917529
73927530 //System.out.println("info.modifiers = " + info.modifiers);
7393
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73947532 //System.out.println("modified = " + modified);
73957533 //new Exception().printStackTrace();
73967534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7418,7 +7556,8 @@
74187556 return true;
74197557 }
74207558
7421
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
74227561 {
74237562 if (hitSomething == 0)
74247563 {
....@@ -7432,7 +7571,7 @@
74327571
74337572 //System.out.println("hitSomething = " + hitSomething);
74347573
7435
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
74367575
74377576 cVector xlate = new cVector();
74387577 //cVector xlate2 = new cVector();
....@@ -7466,8 +7605,8 @@
74667605 toParent[3][i] = xlate.get(i);
74677606 LA.matInvert(toParent, fromParent);
74687607 */
7469
- cVector delta = LA.newVector(0, 0, startY - info.y);
7470
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7608
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7609
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74717610
74727611 LA.matCopy(startMat, toParent);
74737612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7476,7 +7615,7 @@
74767615 } else
74777616 {
74787617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7479
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
74807619 cVector away = new cVector();
74817620 //cVector right2 = new cVector();
74827621 //LA.vecCross(up, cVector.Z, right);
....@@ -7493,19 +7632,19 @@
74937632 LA.xformDir(up, ClickInfo.matbuffer, up);
74947633 // if (!CameraPane.LOCALTRANSFORM)
74957634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7496
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74977636 // if (!CameraPane.LOCALTRANSFORM)
74987637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74997638 //LA.vecCross(up, cVector.Z, right2);
75007639
7501
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75027641
75037642 //System.out.println("DELTA0 = " + delta);
75047643 //System.out.println("AWAY = " + info.camera.away);
75057644 //System.out.println("UP = " + info.camera.up);
75067645 if (away.z > 0)
75077646 {
7508
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75097648 {
75107649 delta.x = -delta.x;
75117650 } else
....@@ -7520,7 +7659,7 @@
75207659 //System.out.println("DELTA1 = " + delta);
75217660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75227661 //System.out.println("DELTA2 = " + delta);
7523
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75247663 LA.matCopy(startMat, toParent);
75257664 //System.out.println("DELTA3 = " + delta);
75267665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7530,8 +7669,8 @@
75307669 break;
75317670
75327671 case hitRotate: // rotate
7533
- int dx = info.x - centerPt.x;
7534
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
75357674 double angle = (double) Math.atan2(dx, dy);
75367675 angle = -(1.570796 - angle);
75377676
....@@ -7554,7 +7693,7 @@
75547693 }
75557694 /**/
75567695
7557
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
75587697 {
75597698 case 1: // '\001'
75607699 LA.matZRotate(toParent, angle);
....@@ -7581,7 +7720,7 @@
75817720 break;
75827721
75837722 case hitScale: // scale
7584
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
75857724 double sign = 1;
75867725 if (hScale < 0)
75877726 {
....@@ -7593,7 +7732,7 @@
75937732 //hScale = 0.01;
75947733 }
75957734
7596
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
75977736 sign = 1;
75987737 if (vScale < 0)
75997738 {
....@@ -7604,6 +7743,7 @@
76047743 {
76057744 //vScale = 0.01;
76067745 }
7746
+
76077747 LA.matCopy(startMat, toParent);
76087748 /**/
76097749 for (int i = 0; i < 3; i++)
....@@ -7613,14 +7753,14 @@
76137753 }
76147754 /**/
76157755
7616
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76177757
76187758 if (totalScale < 0.01)
76197759 {
76207760 totalScale = 0.01;
76217761 }
76227762
7623
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
76247764 {
76257765 case 3: // '\001'
76267766 if (modified || opposite)
....@@ -7687,7 +7827,7 @@
76877827 } // NEW ...
76887828
76897829
7690
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
76917831 }
76927832
76937833 boolean overflow = false;