Normand Briere
2019-08-01 90c87ae87a6d1b88ed8398da7bb95629f0df5b09
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;
....@@ -5894,7 +5910,7 @@
58945910 support = support;
58955911
58965912 //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);
5913
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
58985914
58995915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59005916 {
....@@ -7298,20 +7314,23 @@
72987314 }
72997315 }
73007316
7301
- 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)
73027321 {
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;
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;
73067325 if (toscreen == null)
73077326 {
7308
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73097328 }
73107329 cVector vec = in;
73117330 LA.xformPos(in, toscreen, in);
73127331 //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();
7332
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7333
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73157334 outPt.x = hc + (int) vec.x;
73167335 outPt.y = vc - (int) vec.y;
73177336 outRec.x = outPt.x - 3;
....@@ -7319,15 +7338,18 @@
73197338 outRec.width = outRec.height = 6;
73207339 }
73217340
7322
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
73237343 {
73247344 Point pt = new Point(0, 0);
73257345 Rectangle rec = new Rectangle();
7326
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
73277348 return rec;
73287349 }
73297350
7330
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
73317353 {
73327354 if (level == 0)
73337355 {
....@@ -7336,16 +7358,19 @@
73367358 {
73377359 cVector origin = new cVector();
73387360 //LA.xformPos(origin, toParent, origin);
7339
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73407365 Rectangle boundary = new Rectangle();
73417366 boundary.x = spot.x - 30;
73427367 boundary.y = spot.y - 30;
73437368 boundary.width = spot.width + 60;
73447369 boundary.height = spot.height + 60;
7345
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
73467371 int spotw = spot.x + spot.width;
73477372 int spoth = spot.y + spot.height;
7348
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73497374 // if (CameraPane.Xmin > spot.x)
73507375 // {
73517376 // CameraPane.Xmin = spot.x;
....@@ -7365,8 +7390,8 @@
73657390 spot.translate(32, 32);
73667391 spotw = spot.x + spot.width;
73677392 spoth = spot.y + spot.height;
7368
- info.g.setColor(Color.cyan);
7369
- 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);
73707395 // if (CameraPane.Xmin > spot.x)
73717396 // {
73727397 // CameraPane.Xmin = spot.x;
....@@ -7386,9 +7411,9 @@
73867411 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73877412 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73887413 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);
7414
+ clickInfo.g.setColor(Color.yellow);
7415
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7416
+ clickInfo.g.setColor(Color.green);
73927417 // if (CameraPane.Xmin > spot.x)
73937418 // {
73947419 // CameraPane.Xmin = spot.x;
....@@ -7405,8 +7430,8 @@
74057430 // {
74067431 // CameraPane.Ymax = spoth;
74077432 // }
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);
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);
74107435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74117436 // if (CameraPane.Xmin > boundary.x)
74127437 // {
....@@ -7428,7 +7453,8 @@
74287453 }
74297454 }
74307455
7431
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
74327458 {
74337459 if (level == 0)
74347460 {
....@@ -7437,8 +7463,8 @@
74377463
74387464 boolean retval = false;
74397465
7440
- startX = info.x;
7441
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
74427468
74437469 hitSomething = -1;
74447470 cVector origin = new cVector();
....@@ -7448,22 +7474,51 @@
74487474 {
74497475 centerPt = new Point(0, 0);
74507476 }
7451
- calcHotSpot(origin, info, centerPt, spot);
7452
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
74537480 {
74547481 hitSomething = hitCenter;
74557482 retval = true;
74567483 }
74577484 spot.translate(32, 0);
7458
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
74597486 {
74607487 hitSomething = hitRotate;
74617488 retval = true;
74627489 }
74637490 spot.translate(0, 32);
7464
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
74657492 {
74667493 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
+
74677522 retval = true;
74687523 }
74697524
....@@ -7473,7 +7528,7 @@
74737528 }
74747529
74757530 //System.out.println("info.modifiers = " + info.modifiers);
7476
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74777532 //System.out.println("modified = " + modified);
74787533 //new Exception().printStackTrace();
74797534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7501,7 +7556,8 @@
75017556 return true;
75027557 }
75037558
7504
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
75057561 {
75067562 if (hitSomething == 0)
75077563 {
....@@ -7515,7 +7571,7 @@
75157571
75167572 //System.out.println("hitSomething = " + hitSomething);
75177573
7518
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
75197575
75207576 cVector xlate = new cVector();
75217577 //cVector xlate2 = new cVector();
....@@ -7549,8 +7605,8 @@
75497605 toParent[3][i] = xlate.get(i);
75507606 LA.matInvert(toParent, fromParent);
75517607 */
7552
- cVector delta = LA.newVector(0, 0, startY - info.y);
7553
- 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);
75547610
75557611 LA.matCopy(startMat, toParent);
75567612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7559,7 +7615,7 @@
75597615 } else
75607616 {
75617617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7562
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
75637619 cVector away = new cVector();
75647620 //cVector right2 = new cVector();
75657621 //LA.vecCross(up, cVector.Z, right);
....@@ -7576,19 +7632,19 @@
75767632 LA.xformDir(up, ClickInfo.matbuffer, up);
75777633 // if (!CameraPane.LOCALTRANSFORM)
75787634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7579
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75807636 // if (!CameraPane.LOCALTRANSFORM)
75817637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75827638 //LA.vecCross(up, cVector.Z, right2);
75837639
7584
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75857641
75867642 //System.out.println("DELTA0 = " + delta);
75877643 //System.out.println("AWAY = " + info.camera.away);
75887644 //System.out.println("UP = " + info.camera.up);
75897645 if (away.z > 0)
75907646 {
7591
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75927648 {
75937649 delta.x = -delta.x;
75947650 } else
....@@ -7603,7 +7659,7 @@
76037659 //System.out.println("DELTA1 = " + delta);
76047660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76057661 //System.out.println("DELTA2 = " + delta);
7606
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76077663 LA.matCopy(startMat, toParent);
76087664 //System.out.println("DELTA3 = " + delta);
76097665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7613,8 +7669,8 @@
76137669 break;
76147670
76157671 case hitRotate: // rotate
7616
- int dx = info.x - centerPt.x;
7617
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
76187674 double angle = (double) Math.atan2(dx, dy);
76197675 angle = -(1.570796 - angle);
76207676
....@@ -7637,7 +7693,7 @@
76377693 }
76387694 /**/
76397695
7640
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
76417697 {
76427698 case 1: // '\001'
76437699 LA.matZRotate(toParent, angle);
....@@ -7664,7 +7720,7 @@
76647720 break;
76657721
76667722 case hitScale: // scale
7667
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
76687724 double sign = 1;
76697725 if (hScale < 0)
76707726 {
....@@ -7676,7 +7732,7 @@
76767732 //hScale = 0.01;
76777733 }
76787734
7679
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
76807736 sign = 1;
76817737 if (vScale < 0)
76827738 {
....@@ -7687,6 +7743,7 @@
76877743 {
76887744 //vScale = 0.01;
76897745 }
7746
+
76907747 LA.matCopy(startMat, toParent);
76917748 /**/
76927749 for (int i = 0; i < 3; i++)
....@@ -7696,14 +7753,14 @@
76967753 }
76977754 /**/
76987755
7699
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
77007757
77017758 if (totalScale < 0.01)
77027759 {
77037760 totalScale = 0.01;
77047761 }
77057762
7706
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
77077764 {
77087765 case 3: // '\001'
77097766 if (modified || opposite)
....@@ -7770,7 +7827,7 @@
77707827 } // NEW ...
77717828
77727829
7773
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
77747831 }
77757832
77767833 boolean overflow = false;