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;
....@@ -5775,12 +5791,23 @@
57755791 }
57765792 }
57775793
5778
- void EmbedTextures()
5794
+ void EmbedTextures(boolean embed)
57795795 {
57805796 if (blockloop)
57815797 return;
57825798
5783
- CameraPane.EmbedTextures(texture);
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
+ }
57845811
57855812 int nb = Size();
57865813 for (int i = 0; i < nb; i++)
....@@ -5791,7 +5818,7 @@
57915818 continue;
57925819
57935820 blockloop = true;
5794
- child.EmbedTextures();
5821
+ child.EmbedTextures(embed);
57955822 blockloop = false;
57965823 }
57975824 }
....@@ -5883,7 +5910,7 @@
58835910 support = support;
58845911
58855912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5886
- 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);
58875914
58885915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58895916 {
....@@ -7287,20 +7314,23 @@
72877314 }
72887315 }
72897316
7290
- 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)
72917321 {
7292
- int hc = info.bounds.x + info.bounds.width / 2;
7293
- int vc = info.bounds.y + info.bounds.height / 2;
7294
- 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;
72957325 if (toscreen == null)
72967326 {
7297
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72987328 }
72997329 cVector vec = in;
73007330 LA.xformPos(in, toscreen, in);
73017331 //System.out.println("Distance = " + info.camera.Distance());
7302
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7303
- 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();
73047334 outPt.x = hc + (int) vec.x;
73057335 outPt.y = vc - (int) vec.y;
73067336 outRec.x = outPt.x - 3;
....@@ -7308,15 +7338,18 @@
73087338 outRec.width = outRec.height = 6;
73097339 }
73107340
7311
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
73127343 {
73137344 Point pt = new Point(0, 0);
73147345 Rectangle rec = new Rectangle();
7315
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
73167348 return rec;
73177349 }
73187350
7319
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
73207353 {
73217354 if (level == 0)
73227355 {
....@@ -7325,16 +7358,19 @@
73257358 {
73267359 cVector origin = new cVector();
73277360 //LA.xformPos(origin, toParent, origin);
7328
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73297365 Rectangle boundary = new Rectangle();
73307366 boundary.x = spot.x - 30;
73317367 boundary.y = spot.y - 30;
73327368 boundary.width = spot.width + 60;
73337369 boundary.height = spot.height + 60;
7334
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
73357371 int spotw = spot.x + spot.width;
73367372 int spoth = spot.y + spot.height;
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387374 // if (CameraPane.Xmin > spot.x)
73397375 // {
73407376 // CameraPane.Xmin = spot.x;
....@@ -7354,8 +7390,8 @@
73547390 spot.translate(32, 32);
73557391 spotw = spot.x + spot.width;
73567392 spoth = spot.y + spot.height;
7357
- info.g.setColor(Color.cyan);
7358
- 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);
73597395 // if (CameraPane.Xmin > spot.x)
73607396 // {
73617397 // CameraPane.Xmin = spot.x;
....@@ -7375,9 +7411,9 @@
73757411 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73767412 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73777413 spot.translate(0, -32);
7378
- info.g.setColor(Color.yellow);
7379
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7380
- 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);
73817417 // if (CameraPane.Xmin > spot.x)
73827418 // {
73837419 // CameraPane.Xmin = spot.x;
....@@ -7394,8 +7430,8 @@
73947430 // {
73957431 // CameraPane.Ymax = spoth;
73967432 // }
7397
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7398
- (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);
73997435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74007436 // if (CameraPane.Xmin > boundary.x)
74017437 // {
....@@ -7417,7 +7453,8 @@
74177453 }
74187454 }
74197455
7420
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
74217458 {
74227459 if (level == 0)
74237460 {
....@@ -7426,8 +7463,8 @@
74267463
74277464 boolean retval = false;
74287465
7429
- startX = info.x;
7430
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
74317468
74327469 hitSomething = -1;
74337470 cVector origin = new cVector();
....@@ -7437,22 +7474,51 @@
74377474 {
74387475 centerPt = new Point(0, 0);
74397476 }
7440
- calcHotSpot(origin, info, centerPt, spot);
7441
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
74427480 {
74437481 hitSomething = hitCenter;
74447482 retval = true;
74457483 }
74467484 spot.translate(32, 0);
7447
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
74487486 {
74497487 hitSomething = hitRotate;
74507488 retval = true;
74517489 }
74527490 spot.translate(0, 32);
7453
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
74547492 {
74557493 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
+
74567522 retval = true;
74577523 }
74587524
....@@ -7462,7 +7528,7 @@
74627528 }
74637529
74647530 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74667532 //System.out.println("modified = " + modified);
74677533 //new Exception().printStackTrace();
74687534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7556,8 @@
74907556 return true;
74917557 }
74927558
7493
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
74947561 {
74957562 if (hitSomething == 0)
74967563 {
....@@ -7504,7 +7571,7 @@
75047571
75057572 //System.out.println("hitSomething = " + hitSomething);
75067573
7507
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
75087575
75097576 cVector xlate = new cVector();
75107577 //cVector xlate2 = new cVector();
....@@ -7538,8 +7605,8 @@
75387605 toParent[3][i] = xlate.get(i);
75397606 LA.matInvert(toParent, fromParent);
75407607 */
7541
- cVector delta = LA.newVector(0, 0, startY - info.y);
7542
- 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);
75437610
75447611 LA.matCopy(startMat, toParent);
75457612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7548,7 +7615,7 @@
75487615 } else
75497616 {
75507617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7551
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
75527619 cVector away = new cVector();
75537620 //cVector right2 = new cVector();
75547621 //LA.vecCross(up, cVector.Z, right);
....@@ -7565,19 +7632,19 @@
75657632 LA.xformDir(up, ClickInfo.matbuffer, up);
75667633 // if (!CameraPane.LOCALTRANSFORM)
75677634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7568
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75697636 // if (!CameraPane.LOCALTRANSFORM)
75707637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75717638 //LA.vecCross(up, cVector.Z, right2);
75727639
7573
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75747641
75757642 //System.out.println("DELTA0 = " + delta);
75767643 //System.out.println("AWAY = " + info.camera.away);
75777644 //System.out.println("UP = " + info.camera.up);
75787645 if (away.z > 0)
75797646 {
7580
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75817648 {
75827649 delta.x = -delta.x;
75837650 } else
....@@ -7592,7 +7659,7 @@
75927659 //System.out.println("DELTA1 = " + delta);
75937660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75947661 //System.out.println("DELTA2 = " + delta);
7595
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75967663 LA.matCopy(startMat, toParent);
75977664 //System.out.println("DELTA3 = " + delta);
75987665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7602,8 +7669,8 @@
76027669 break;
76037670
76047671 case hitRotate: // rotate
7605
- int dx = info.x - centerPt.x;
7606
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
76077674 double angle = (double) Math.atan2(dx, dy);
76087675 angle = -(1.570796 - angle);
76097676
....@@ -7626,7 +7693,7 @@
76267693 }
76277694 /**/
76287695
7629
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
76307697 {
76317698 case 1: // '\001'
76327699 LA.matZRotate(toParent, angle);
....@@ -7653,7 +7720,7 @@
76537720 break;
76547721
76557722 case hitScale: // scale
7656
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
76577724 double sign = 1;
76587725 if (hScale < 0)
76597726 {
....@@ -7665,7 +7732,7 @@
76657732 //hScale = 0.01;
76667733 }
76677734
7668
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
76697736 sign = 1;
76707737 if (vScale < 0)
76717738 {
....@@ -7676,6 +7743,7 @@
76767743 {
76777744 //vScale = 0.01;
76787745 }
7746
+
76797747 LA.matCopy(startMat, toParent);
76807748 /**/
76817749 for (int i = 0; i < 3; i++)
....@@ -7685,14 +7753,14 @@
76857753 }
76867754 /**/
76877755
7688
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76897757
76907758 if (totalScale < 0.01)
76917759 {
76927760 totalScale = 0.01;
76937761 }
76947762
7695
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
76967764 {
76977765 case 3: // '\001'
76987766 if (modified || opposite)
....@@ -7759,7 +7827,7 @@
77597827 } // NEW ...
77607828
77617829
7762
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
77637831 }
77647832
77657833 boolean overflow = false;