Normand Briere
2019-07-30 7a77e39423398b7ad8bf7e80cf45fac6817000c2
Object3D.java
....@@ -29,6 +29,9 @@
2929 Object3D saveskeleton;
3030 //
3131
32
+ String skyboxname;
33
+ String skyboxext;
34
+
3235 byte[] versions[];
3336 int versionindex = -1;
3437
....@@ -2567,7 +2570,8 @@
25672570 private static final int editSelf = 1;
25682571 private static final int editChild = 2;
25692572
2570
- void drawEditHandles(ClickInfo info, int level)
2573
+ void drawEditHandles(//ClickInfo info,
2574
+ int level)
25712575 {
25722576 if (level == 0)
25732577 {
....@@ -2575,7 +2579,8 @@
25752579 return;
25762580
25772581 Object3D selectee;
2578
- 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))
25792584 {
25802585 selectee = (Object3D) e.nextElement();
25812586 }
....@@ -2583,19 +2588,22 @@
25832588 } else
25842589 {
25852590 //super.
2586
- drawEditHandles0(info, level + 1);
2591
+ drawEditHandles0(//info,
2592
+ level + 1);
25872593 }
25882594 }
25892595
2590
- boolean doEditClick(ClickInfo info, int level)
2596
+ boolean doEditClick(//ClickInfo info,
2597
+ int level)
25912598 {
25922599 doSomething = 0;
25932600 if (level == 0)
25942601 {
2595
- return doParentClick(info);
2602
+ return doParentClick(); //info);
25962603 }
25972604 if (//super.
2598
- doEditClick0(info, level))
2605
+ doEditClick0(//info,
2606
+ level))
25992607 {
26002608 doSomething = 1;
26012609 return true;
....@@ -2605,7 +2613,7 @@
26052613 }
26062614 }
26072615
2608
- boolean doParentClick(ClickInfo info)
2616
+ boolean doParentClick() //ClickInfo info)
26092617 {
26102618 if (selection == null)
26112619 {
....@@ -2618,7 +2626,8 @@
26182626 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192627 {
26202628 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2629
+ if (selectee.doEditClick(//info,
2630
+ 1))
26222631 {
26232632 childToDrag = selectee;
26242633 doSomething = 2;
....@@ -2630,13 +2639,15 @@
26302639 return retval;
26312640 }
26322641
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2642
+ void doEditDrag(//ClickInfo clickInfo,
2643
+ boolean opposite)
26342644 {
26352645 switch (doSomething)
26362646 {
26372647 case 1: // '\001'
26382648 //super.
2639
- doEditDrag0(info, opposite);
2649
+ doEditDrag0(//clickInfo,
2650
+ opposite);
26402651 break;
26412652
26422653 case 2: // '\002'
....@@ -2649,11 +2660,13 @@
26492660 {
26502661 //sel.hitSomething = childToDrag.hitSomething;
26512662 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2663
+ sel.doEditDrag(//clickInfo,
2664
+ opposite);
26532665 } else
26542666 {
26552667 //super.
2656
- doEditDrag0(info, opposite);
2668
+ doEditDrag0(//clickInfo,
2669
+ opposite);
26572670 }
26582671 }
26592672 break;
....@@ -2671,6 +2684,9 @@
26712684 {
26722685 deselectAll();
26732686 }
2687
+
2688
+ new Exception().printStackTrace();
2689
+
26742690 ClickInfo newInfo = new ClickInfo();
26752691 newInfo.flags = info.flags;
26762692 newInfo.bounds = info.bounds;
....@@ -5775,6 +5791,38 @@
57755791 }
57765792 }
57775793
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
+
57785826 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57795827 {
57805828 Draw(display, root, selected, blocked);
....@@ -5862,7 +5910,7 @@
58625910 support = support;
58635911
58645912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5865
- 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);
58665914
58675915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58685916 {
....@@ -7266,20 +7314,23 @@
72667314 }
72677315 }
72687316
7269
- 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)
72707321 {
7271
- int hc = info.bounds.x + info.bounds.width / 2;
7272
- int vc = info.bounds.y + info.bounds.height / 2;
7273
- 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;
72747325 if (toscreen == null)
72757326 {
7276
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72777328 }
72787329 cVector vec = in;
72797330 LA.xformPos(in, toscreen, in);
72807331 //System.out.println("Distance = " + info.camera.Distance());
7281
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7282
- 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();
72837334 outPt.x = hc + (int) vec.x;
72847335 outPt.y = vc - (int) vec.y;
72857336 outRec.x = outPt.x - 3;
....@@ -7287,15 +7338,18 @@
72877338 outRec.width = outRec.height = 6;
72887339 }
72897340
7290
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
72917343 {
72927344 Point pt = new Point(0, 0);
72937345 Rectangle rec = new Rectangle();
7294
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
72957348 return rec;
72967349 }
72977350
7298
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
72997353 {
73007354 if (level == 0)
73017355 {
....@@ -7304,16 +7358,19 @@
73047358 {
73057359 cVector origin = new cVector();
73067360 //LA.xformPos(origin, toParent, origin);
7307
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73087365 Rectangle boundary = new Rectangle();
73097366 boundary.x = spot.x - 30;
73107367 boundary.y = spot.y - 30;
73117368 boundary.width = spot.width + 60;
73127369 boundary.height = spot.height + 60;
7313
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
73147371 int spotw = spot.x + spot.width;
73157372 int spoth = spot.y + spot.height;
7316
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73177374 // if (CameraPane.Xmin > spot.x)
73187375 // {
73197376 // CameraPane.Xmin = spot.x;
....@@ -7333,8 +7390,8 @@
73337390 spot.translate(32, 32);
73347391 spotw = spot.x + spot.width;
73357392 spoth = spot.y + spot.height;
7336
- info.g.setColor(Color.cyan);
7337
- 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);
73387395 // if (CameraPane.Xmin > spot.x)
73397396 // {
73407397 // CameraPane.Xmin = spot.x;
....@@ -7354,9 +7411,9 @@
73547411 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73557412 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73567413 spot.translate(0, -32);
7357
- info.g.setColor(Color.yellow);
7358
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7359
- 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);
73607417 // if (CameraPane.Xmin > spot.x)
73617418 // {
73627419 // CameraPane.Xmin = spot.x;
....@@ -7373,8 +7430,8 @@
73737430 // {
73747431 // CameraPane.Ymax = spoth;
73757432 // }
7376
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7377
- (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);
73787435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73797436 // if (CameraPane.Xmin > boundary.x)
73807437 // {
....@@ -7396,7 +7453,8 @@
73967453 }
73977454 }
73987455
7399
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
74007458 {
74017459 if (level == 0)
74027460 {
....@@ -7405,8 +7463,8 @@
74057463
74067464 boolean retval = false;
74077465
7408
- startX = info.x;
7409
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
74107468
74117469 hitSomething = -1;
74127470 cVector origin = new cVector();
....@@ -7416,22 +7474,51 @@
74167474 {
74177475 centerPt = new Point(0, 0);
74187476 }
7419
- calcHotSpot(origin, info, centerPt, spot);
7420
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
74217480 {
74227481 hitSomething = hitCenter;
74237482 retval = true;
74247483 }
74257484 spot.translate(32, 0);
7426
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
74277486 {
74287487 hitSomething = hitRotate;
74297488 retval = true;
74307489 }
74317490 spot.translate(0, 32);
7432
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
74337492 {
74347493 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
+
74357522 retval = true;
74367523 }
74377524
....@@ -7441,7 +7528,7 @@
74417528 }
74427529
74437530 //System.out.println("info.modifiers = " + info.modifiers);
7444
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74457532 //System.out.println("modified = " + modified);
74467533 //new Exception().printStackTrace();
74477534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7469,7 +7556,8 @@
74697556 return true;
74707557 }
74717558
7472
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
74737561 {
74747562 if (hitSomething == 0)
74757563 {
....@@ -7483,7 +7571,7 @@
74837571
74847572 //System.out.println("hitSomething = " + hitSomething);
74857573
7486
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
74877575
74887576 cVector xlate = new cVector();
74897577 //cVector xlate2 = new cVector();
....@@ -7517,8 +7605,8 @@
75177605 toParent[3][i] = xlate.get(i);
75187606 LA.matInvert(toParent, fromParent);
75197607 */
7520
- cVector delta = LA.newVector(0, 0, startY - info.y);
7521
- 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);
75227610
75237611 LA.matCopy(startMat, toParent);
75247612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7527,7 +7615,7 @@
75277615 } else
75287616 {
75297617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7530
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
75317619 cVector away = new cVector();
75327620 //cVector right2 = new cVector();
75337621 //LA.vecCross(up, cVector.Z, right);
....@@ -7544,19 +7632,19 @@
75447632 LA.xformDir(up, ClickInfo.matbuffer, up);
75457633 // if (!CameraPane.LOCALTRANSFORM)
75467634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7547
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75487636 // if (!CameraPane.LOCALTRANSFORM)
75497637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75507638 //LA.vecCross(up, cVector.Z, right2);
75517639
7552
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75537641
75547642 //System.out.println("DELTA0 = " + delta);
75557643 //System.out.println("AWAY = " + info.camera.away);
75567644 //System.out.println("UP = " + info.camera.up);
75577645 if (away.z > 0)
75587646 {
7559
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75607648 {
75617649 delta.x = -delta.x;
75627650 } else
....@@ -7571,7 +7659,7 @@
75717659 //System.out.println("DELTA1 = " + delta);
75727660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75737661 //System.out.println("DELTA2 = " + delta);
7574
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75757663 LA.matCopy(startMat, toParent);
75767664 //System.out.println("DELTA3 = " + delta);
75777665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7581,8 +7669,8 @@
75817669 break;
75827670
75837671 case hitRotate: // rotate
7584
- int dx = info.x - centerPt.x;
7585
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
75867674 double angle = (double) Math.atan2(dx, dy);
75877675 angle = -(1.570796 - angle);
75887676
....@@ -7605,7 +7693,7 @@
76057693 }
76067694 /**/
76077695
7608
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
76097697 {
76107698 case 1: // '\001'
76117699 LA.matZRotate(toParent, angle);
....@@ -7632,7 +7720,7 @@
76327720 break;
76337721
76347722 case hitScale: // scale
7635
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
76367724 double sign = 1;
76377725 if (hScale < 0)
76387726 {
....@@ -7644,7 +7732,7 @@
76447732 //hScale = 0.01;
76457733 }
76467734
7647
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
76487736 sign = 1;
76497737 if (vScale < 0)
76507738 {
....@@ -7655,6 +7743,7 @@
76557743 {
76567744 //vScale = 0.01;
76577745 }
7746
+
76587747 LA.matCopy(startMat, toParent);
76597748 /**/
76607749 for (int i = 0; i < 3; i++)
....@@ -7664,14 +7753,14 @@
76647753 }
76657754 /**/
76667755
7667
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76687757
76697758 if (totalScale < 0.01)
76707759 {
76717760 totalScale = 0.01;
76727761 }
76737762
7674
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
76757764 {
76767765 case 3: // '\001'
76777766 if (modified || opposite)
....@@ -7738,7 +7827,7 @@
77387827 } // NEW ...
77397828
77407829
7741
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
77427831 }
77437832
77447833 boolean overflow = false;