Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
Object3D.java
....@@ -2567,7 +2567,8 @@
25672567 private static final int editSelf = 1;
25682568 private static final int editChild = 2;
25692569
2570
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
25712572 {
25722573 if (level == 0)
25732574 {
....@@ -2575,7 +2576,8 @@
25752576 return;
25762577
25772578 Object3D selectee;
2578
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
25792581 {
25802582 selectee = (Object3D) e.nextElement();
25812583 }
....@@ -2583,19 +2585,22 @@
25832585 } else
25842586 {
25852587 //super.
2586
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25872590 }
25882591 }
25892592
2590
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25912595 {
25922596 doSomething = 0;
25932597 if (level == 0)
25942598 {
2595
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25962600 }
25972601 if (//super.
2598
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25992604 {
26002605 doSomething = 1;
26012606 return true;
....@@ -2605,7 +2610,7 @@
26052610 }
26062611 }
26072612
2608
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
26092614 {
26102615 if (selection == null)
26112616 {
....@@ -2618,7 +2623,8 @@
26182623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192624 {
26202625 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
26222628 {
26232629 childToDrag = selectee;
26242630 doSomething = 2;
....@@ -2630,13 +2636,15 @@
26302636 return retval;
26312637 }
26322638
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
26342641 {
26352642 switch (doSomething)
26362643 {
26372644 case 1: // '\001'
26382645 //super.
2639
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
26402648 break;
26412649
26422650 case 2: // '\002'
....@@ -2649,11 +2657,13 @@
26492657 {
26502658 //sel.hitSomething = childToDrag.hitSomething;
26512659 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
26532662 } else
26542663 {
26552664 //super.
2656
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
26572667 }
26582668 }
26592669 break;
....@@ -2671,6 +2681,9 @@
26712681 {
26722682 deselectAll();
26732683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
26742687 ClickInfo newInfo = new ClickInfo();
26752688 newInfo.flags = info.flags;
26762689 newInfo.bounds = info.bounds;
....@@ -5775,6 +5788,38 @@
57755788 }
57765789 }
57775790
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
57785823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57795824 {
57805825 Draw(display, root, selected, blocked);
....@@ -5862,7 +5907,7 @@
58625907 support = support;
58635908
58645909 //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);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
58665911
58675912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58685913 {
....@@ -7266,20 +7311,23 @@
72667311 }
72677312 }
72687313
7269
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
72707318 {
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;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
72747322 if (toscreen == null)
72757323 {
7276
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72777325 }
72787326 cVector vec = in;
72797327 LA.xformPos(in, toscreen, in);
72807328 //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();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72837331 outPt.x = hc + (int) vec.x;
72847332 outPt.y = vc - (int) vec.y;
72857333 outRec.x = outPt.x - 3;
....@@ -7287,15 +7335,18 @@
72877335 outRec.width = outRec.height = 6;
72887336 }
72897337
7290
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
72917340 {
72927341 Point pt = new Point(0, 0);
72937342 Rectangle rec = new Rectangle();
7294
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
72957345 return rec;
72967346 }
72977347
7298
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
72997350 {
73007351 if (level == 0)
73017352 {
....@@ -7304,16 +7355,19 @@
73047355 {
73057356 cVector origin = new cVector();
73067357 //LA.xformPos(origin, toParent, origin);
7307
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73087362 Rectangle boundary = new Rectangle();
73097363 boundary.x = spot.x - 30;
73107364 boundary.y = spot.y - 30;
73117365 boundary.width = spot.width + 60;
73127366 boundary.height = spot.height + 60;
7313
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
73147368 int spotw = spot.x + spot.width;
73157369 int spoth = spot.y + spot.height;
7316
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73177371 // if (CameraPane.Xmin > spot.x)
73187372 // {
73197373 // CameraPane.Xmin = spot.x;
....@@ -7333,8 +7387,8 @@
73337387 spot.translate(32, 32);
73347388 spotw = spot.x + spot.width;
73357389 spoth = spot.y + spot.height;
7336
- info.g.setColor(Color.cyan);
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387392 // if (CameraPane.Xmin > spot.x)
73397393 // {
73407394 // CameraPane.Xmin = spot.x;
....@@ -7354,9 +7408,9 @@
73547408 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73557409 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73567410 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);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
73607414 // if (CameraPane.Xmin > spot.x)
73617415 // {
73627416 // CameraPane.Xmin = spot.x;
....@@ -7373,8 +7427,8 @@
73737427 // {
73747428 // CameraPane.Ymax = spoth;
73757429 // }
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);
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73787432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73797433 // if (CameraPane.Xmin > boundary.x)
73807434 // {
....@@ -7396,7 +7450,8 @@
73967450 }
73977451 }
73987452
7399
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
74007455 {
74017456 if (level == 0)
74027457 {
....@@ -7405,8 +7460,8 @@
74057460
74067461 boolean retval = false;
74077462
7408
- startX = info.x;
7409
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
74107465
74117466 hitSomething = -1;
74127467 cVector origin = new cVector();
....@@ -7416,22 +7471,51 @@
74167471 {
74177472 centerPt = new Point(0, 0);
74187473 }
7419
- calcHotSpot(origin, info, centerPt, spot);
7420
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
74217477 {
74227478 hitSomething = hitCenter;
74237479 retval = true;
74247480 }
74257481 spot.translate(32, 0);
7426
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
74277483 {
74287484 hitSomething = hitRotate;
74297485 retval = true;
74307486 }
74317487 spot.translate(0, 32);
7432
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
74337489 {
74347490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
74357519 retval = true;
74367520 }
74377521
....@@ -7441,7 +7525,7 @@
74417525 }
74427526
74437527 //System.out.println("info.modifiers = " + info.modifiers);
7444
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74457529 //System.out.println("modified = " + modified);
74467530 //new Exception().printStackTrace();
74477531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7469,7 +7553,8 @@
74697553 return true;
74707554 }
74717555
7472
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
74737558 {
74747559 if (hitSomething == 0)
74757560 {
....@@ -7483,7 +7568,7 @@
74837568
74847569 //System.out.println("hitSomething = " + hitSomething);
74857570
7486
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
74877572
74887573 cVector xlate = new cVector();
74897574 //cVector xlate2 = new cVector();
....@@ -7517,8 +7602,8 @@
75177602 toParent[3][i] = xlate.get(i);
75187603 LA.matInvert(toParent, fromParent);
75197604 */
7520
- cVector delta = LA.newVector(0, 0, startY - info.y);
7521
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75227607
75237608 LA.matCopy(startMat, toParent);
75247609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7527,7 +7612,7 @@
75277612 } else
75287613 {
75297614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7530
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
75317616 cVector away = new cVector();
75327617 //cVector right2 = new cVector();
75337618 //LA.vecCross(up, cVector.Z, right);
....@@ -7544,19 +7629,19 @@
75447629 LA.xformDir(up, ClickInfo.matbuffer, up);
75457630 // if (!CameraPane.LOCALTRANSFORM)
75467631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7547
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75487633 // if (!CameraPane.LOCALTRANSFORM)
75497634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75507635 //LA.vecCross(up, cVector.Z, right2);
75517636
7552
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75537638
75547639 //System.out.println("DELTA0 = " + delta);
75557640 //System.out.println("AWAY = " + info.camera.away);
75567641 //System.out.println("UP = " + info.camera.up);
75577642 if (away.z > 0)
75587643 {
7559
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75607645 {
75617646 delta.x = -delta.x;
75627647 } else
....@@ -7571,7 +7656,7 @@
75717656 //System.out.println("DELTA1 = " + delta);
75727657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75737658 //System.out.println("DELTA2 = " + delta);
7574
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75757660 LA.matCopy(startMat, toParent);
75767661 //System.out.println("DELTA3 = " + delta);
75777662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7581,8 +7666,8 @@
75817666 break;
75827667
75837668 case hitRotate: // rotate
7584
- int dx = info.x - centerPt.x;
7585
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
75867671 double angle = (double) Math.atan2(dx, dy);
75877672 angle = -(1.570796 - angle);
75887673
....@@ -7605,7 +7690,7 @@
76057690 }
76067691 /**/
76077692
7608
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
76097694 {
76107695 case 1: // '\001'
76117696 LA.matZRotate(toParent, angle);
....@@ -7632,7 +7717,7 @@
76327717 break;
76337718
76347719 case hitScale: // scale
7635
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
76367721 double sign = 1;
76377722 if (hScale < 0)
76387723 {
....@@ -7644,7 +7729,7 @@
76447729 //hScale = 0.01;
76457730 }
76467731
7647
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
76487733 sign = 1;
76497734 if (vScale < 0)
76507735 {
....@@ -7655,6 +7740,7 @@
76557740 {
76567741 //vScale = 0.01;
76577742 }
7743
+
76587744 LA.matCopy(startMat, toParent);
76597745 /**/
76607746 for (int i = 0; i < 3; i++)
....@@ -7664,14 +7750,14 @@
76647750 }
76657751 /**/
76667752
7667
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76687754
76697755 if (totalScale < 0.01)
76707756 {
76717757 totalScale = 0.01;
76727758 }
76737759
7674
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
76757761 {
76767762 case 3: // '\001'
76777763 if (modified || opposite)
....@@ -7738,7 +7824,7 @@
77387824 } // NEW ...
77397825
77407826
7741
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
77427828 }
77437829
77447830 boolean overflow = false;