Normand Briere
2019-08-01 abb71c81c8a351cda9a2918dcaa7ee61e6c125c5
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
....@@ -1011,6 +1014,9 @@
10111014
10121015 if (material == null || material.multiply)
10131016 return true;
1017
+
1018
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1019
+ return false;
10141020
10151021 // Transparent objects are dynamic because we have to sort the triangles.
10161022 return material.opacity > 0.99;
....@@ -2567,7 +2573,8 @@
25672573 private static final int editSelf = 1;
25682574 private static final int editChild = 2;
25692575
2570
- void drawEditHandles(ClickInfo info, int level)
2576
+ void drawEditHandles(//ClickInfo info,
2577
+ int level)
25712578 {
25722579 if (level == 0)
25732580 {
....@@ -2575,7 +2582,8 @@
25752582 return;
25762583
25772584 Object3D selectee;
2578
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2585
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2586
+ level + 1))
25792587 {
25802588 selectee = (Object3D) e.nextElement();
25812589 }
....@@ -2583,19 +2591,22 @@
25832591 } else
25842592 {
25852593 //super.
2586
- drawEditHandles0(info, level + 1);
2594
+ drawEditHandles0(//info,
2595
+ level + 1);
25872596 }
25882597 }
25892598
2590
- boolean doEditClick(ClickInfo info, int level)
2599
+ boolean doEditClick(//ClickInfo info,
2600
+ int level)
25912601 {
25922602 doSomething = 0;
25932603 if (level == 0)
25942604 {
2595
- return doParentClick(info);
2605
+ return doParentClick(); //info);
25962606 }
25972607 if (//super.
2598
- doEditClick0(info, level))
2608
+ doEditClick0(//info,
2609
+ level))
25992610 {
26002611 doSomething = 1;
26012612 return true;
....@@ -2605,7 +2616,7 @@
26052616 }
26062617 }
26072618
2608
- boolean doParentClick(ClickInfo info)
2619
+ boolean doParentClick() //ClickInfo info)
26092620 {
26102621 if (selection == null)
26112622 {
....@@ -2618,7 +2629,8 @@
26182629 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192630 {
26202631 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2632
+ if (selectee.doEditClick(//info,
2633
+ 1))
26222634 {
26232635 childToDrag = selectee;
26242636 doSomething = 2;
....@@ -2630,13 +2642,15 @@
26302642 return retval;
26312643 }
26322644
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2645
+ void doEditDrag(//ClickInfo clickInfo,
2646
+ boolean opposite)
26342647 {
26352648 switch (doSomething)
26362649 {
26372650 case 1: // '\001'
26382651 //super.
2639
- doEditDrag0(info, opposite);
2652
+ doEditDrag0(//clickInfo,
2653
+ opposite);
26402654 break;
26412655
26422656 case 2: // '\002'
....@@ -2649,11 +2663,13 @@
26492663 {
26502664 //sel.hitSomething = childToDrag.hitSomething;
26512665 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2666
+ sel.doEditDrag(//clickInfo,
2667
+ opposite);
26532668 } else
26542669 {
26552670 //super.
2656
- doEditDrag0(info, opposite);
2671
+ doEditDrag0(//clickInfo,
2672
+ opposite);
26572673 }
26582674 }
26592675 break;
....@@ -2671,6 +2687,9 @@
26712687 {
26722688 deselectAll();
26732689 }
2690
+
2691
+ new Exception().printStackTrace();
2692
+
26742693 ClickInfo newInfo = new ClickInfo();
26752694 newInfo.flags = info.flags;
26762695 newInfo.bounds = info.bounds;
....@@ -5775,12 +5794,23 @@
57755794 }
57765795 }
57775796
5778
- void EmbedTextures()
5797
+ void EmbedTextures(boolean embed)
57795798 {
57805799 if (blockloop)
57815800 return;
57825801
5783
- CameraPane.EmbedTextures(texture);
5802
+ //if (GetTextures() != null)
5803
+ if (embed)
5804
+ CameraPane.EmbedTextures(GetTextures());
5805
+ else
5806
+ {
5807
+ GetTextures().pigmentdata = null;
5808
+ GetTextures().bumpdata = null;
5809
+ GetTextures().pw = 0;
5810
+ GetTextures().ph = 0;
5811
+ GetTextures().bw = 0;
5812
+ GetTextures().bh = 0;
5813
+ }
57845814
57855815 int nb = Size();
57865816 for (int i = 0; i < nb; i++)
....@@ -5791,7 +5821,7 @@
57915821 continue;
57925822
57935823 blockloop = true;
5794
- child.EmbedTextures();
5824
+ child.EmbedTextures(embed);
57955825 blockloop = false;
57965826 }
57975827 }
....@@ -5882,8 +5912,10 @@
58825912 if (support != null)
58835913 support = support;
58845914
5885
- //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);
5915
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5916
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5917
+
5918
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58875919
58885920 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58895921 {
....@@ -5893,8 +5925,9 @@
58935925 // usecalllists &= !(parent instanceof RandomNode);
58945926 // usecalllists = false;
58955927
5896
- if (GetBRep() != null)
5897
- usecalllists = usecalllists;
5928
+ if (display.DrawMode() == display.SHADOW)
5929
+ //GetBRep() != null)
5930
+ usecalllists = !!usecalllists;
58985931 //System.out.println("draw " + this);
58995932 //new Exception().printStackTrace();
59005933
....@@ -5916,7 +5949,7 @@
59165949 if (!(this instanceof Composite))
59175950 touched = false;
59185951 //if (displaylist == -1 && usecalllists)
5919
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5952
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59205953 {
59215954 bRep.displaylist = display.GenList();
59225955 assert(bRep.displaylist != 0);
....@@ -5927,7 +5960,7 @@
59275960
59285961 //System.out.println("\tnew list " + list);
59295962 //gl.glDrawBuffer(gl.GL_NONE);
5930
- if (usecalllists)
5963
+ if (usecalllists && bRep.displaylist > 0)
59315964 {
59325965 // System.err.println("new list " + bRep.displaylist + " for " + this);
59335966 display.NewList(bRep.displaylist);
....@@ -5936,7 +5969,7 @@
59365969 CallList(display, root, selected, blocked);
59375970
59385971 // compiled = true;
5939
- if (usecalllists)
5972
+ if (usecalllists && bRep.displaylist > 0)
59405973 {
59415974 // System.err.println("end list " + bRep.displaylist + " for " + this);
59425975 display.EndList();
....@@ -7287,20 +7320,23 @@
72877320 }
72887321 }
72897322
7290
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7323
+ static ClickInfo clickInfo = new ClickInfo();
7324
+
7325
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7326
+ Point outPt, Rectangle outRec)
72917327 {
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;
7328
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7329
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7330
+ double[][] toscreen = clickInfo.toScreen;
72957331 if (toscreen == null)
72967332 {
7297
- toscreen = new Camera(info.camera.viewCode).toScreen;
7333
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72987334 }
72997335 cVector vec = in;
73007336 LA.xformPos(in, toscreen, in);
73017337 //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();
7338
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7339
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73047340 outPt.x = hc + (int) vec.x;
73057341 outPt.y = vc - (int) vec.y;
73067342 outRec.x = outPt.x - 3;
....@@ -7308,15 +7344,18 @@
73087344 outRec.width = outRec.height = 6;
73097345 }
73107346
7311
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7347
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7348
+ )
73127349 {
73137350 Point pt = new Point(0, 0);
73147351 Rectangle rec = new Rectangle();
7315
- calcHotSpot(in, info, pt, rec);
7352
+ calcHotSpot(in, //clickInfo,
7353
+ pt, rec);
73167354 return rec;
73177355 }
73187356
7319
- void drawEditHandles0(ClickInfo info, int level)
7357
+ void drawEditHandles0(//ClickInfo clickInfo,
7358
+ int level)
73207359 {
73217360 if (level == 0)
73227361 {
....@@ -7325,16 +7364,19 @@
73257364 {
73267365 cVector origin = new cVector();
73277366 //LA.xformPos(origin, toParent, origin);
7328
- Rectangle spot = calcHotSpot(origin, info);
7367
+ if (this.clickInfo == null)
7368
+ this.clickInfo = new ClickInfo();
7369
+
7370
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73297371 Rectangle boundary = new Rectangle();
73307372 boundary.x = spot.x - 30;
73317373 boundary.y = spot.y - 30;
73327374 boundary.width = spot.width + 60;
73337375 boundary.height = spot.height + 60;
7334
- info.g.setColor(Color.red);
7376
+ clickInfo.g.setColor(Color.red);
73357377 int spotw = spot.x + spot.width;
73367378 int spoth = spot.y + spot.height;
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387380 // if (CameraPane.Xmin > spot.x)
73397381 // {
73407382 // CameraPane.Xmin = spot.x;
....@@ -7354,8 +7396,8 @@
73547396 spot.translate(32, 32);
73557397 spotw = spot.x + spot.width;
73567398 spoth = spot.y + spot.height;
7357
- info.g.setColor(Color.cyan);
7358
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7399
+ clickInfo.g.setColor(Color.cyan);
7400
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73597401 // if (CameraPane.Xmin > spot.x)
73607402 // {
73617403 // CameraPane.Xmin = spot.x;
....@@ -7375,9 +7417,9 @@
73757417 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73767418 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73777419 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);
7420
+ clickInfo.g.setColor(Color.yellow);
7421
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7422
+ clickInfo.g.setColor(Color.green);
73817423 // if (CameraPane.Xmin > spot.x)
73827424 // {
73837425 // CameraPane.Xmin = spot.x;
....@@ -7394,8 +7436,8 @@
73947436 // {
73957437 // CameraPane.Ymax = spoth;
73967438 // }
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);
7439
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7440
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73997441 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74007442 // if (CameraPane.Xmin > boundary.x)
74017443 // {
....@@ -7417,7 +7459,8 @@
74177459 }
74187460 }
74197461
7420
- boolean doEditClick0(ClickInfo info, int level)
7462
+ boolean doEditClick0(//ClickInfo clickInfo,
7463
+ int level)
74217464 {
74227465 if (level == 0)
74237466 {
....@@ -7426,8 +7469,8 @@
74267469
74277470 boolean retval = false;
74287471
7429
- startX = info.x;
7430
- startY = info.y;
7472
+ startX = clickInfo.x;
7473
+ startY = clickInfo.y;
74317474
74327475 hitSomething = -1;
74337476 cVector origin = new cVector();
....@@ -7437,22 +7480,51 @@
74377480 {
74387481 centerPt = new Point(0, 0);
74397482 }
7440
- calcHotSpot(origin, info, centerPt, spot);
7441
- if (spot.contains(info.x, info.y))
7483
+ calcHotSpot(origin, //info,
7484
+ centerPt, spot);
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
74427486 {
74437487 hitSomething = hitCenter;
74447488 retval = true;
74457489 }
74467490 spot.translate(32, 0);
7447
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
74487492 {
74497493 hitSomething = hitRotate;
74507494 retval = true;
74517495 }
74527496 spot.translate(0, 32);
7453
- if (spot.contains(info.x, info.y))
7497
+ if (spot.contains(clickInfo.x, clickInfo.y))
74547498 {
74557499 hitSomething = hitScale;
7500
+
7501
+ double scale = 0.005f * clickInfo.camera.Distance();
7502
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7503
+ double sign = 1;
7504
+ if (hScale < 0)
7505
+ {
7506
+ sign = -1;
7507
+ }
7508
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7509
+ if (hScale < 0.01)
7510
+ {
7511
+ //hScale = 0.01;
7512
+ }
7513
+
7514
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7515
+ sign = 1;
7516
+ if (vScale < 0)
7517
+ {
7518
+ sign = -1;
7519
+ }
7520
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7521
+ if (vScale < 0.01)
7522
+ {
7523
+ //vScale = 0.01;
7524
+ }
7525
+
7526
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7527
+
74567528 retval = true;
74577529 }
74587530
....@@ -7462,7 +7534,7 @@
74627534 }
74637535
74647536 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7537
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74667538 //System.out.println("modified = " + modified);
74677539 //new Exception().printStackTrace();
74687540 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7562,8 @@
74907562 return true;
74917563 }
74927564
7493
- void doEditDrag0(ClickInfo info, boolean opposite)
7565
+ void doEditDrag0(//ClickInfo info,
7566
+ boolean opposite)
74947567 {
74957568 if (hitSomething == 0)
74967569 {
....@@ -7504,7 +7577,7 @@
75047577
75057578 //System.out.println("hitSomething = " + hitSomething);
75067579
7507
- double scale = 0.005f * info.camera.Distance();
7580
+ double scale = 0.005f * clickInfo.camera.Distance();
75087581
75097582 cVector xlate = new cVector();
75107583 //cVector xlate2 = new cVector();
....@@ -7538,8 +7611,8 @@
75387611 toParent[3][i] = xlate.get(i);
75397612 LA.matInvert(toParent, fromParent);
75407613 */
7541
- cVector delta = LA.newVector(0, 0, startY - info.y);
7542
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7614
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7615
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75437616
75447617 LA.matCopy(startMat, toParent);
75457618 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7548,7 +7621,7 @@
75487621 } else
75497622 {
75507623 //LA.xformDir(delta, info.camera.fromScreen, delta);
7551
- cVector up = new cVector(info.camera.up);
7624
+ cVector up = new cVector(clickInfo.camera.up);
75527625 cVector away = new cVector();
75537626 //cVector right2 = new cVector();
75547627 //LA.vecCross(up, cVector.Z, right);
....@@ -7565,19 +7638,19 @@
75657638 LA.xformDir(up, ClickInfo.matbuffer, up);
75667639 // if (!CameraPane.LOCALTRANSFORM)
75677640 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7568
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7641
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75697642 // if (!CameraPane.LOCALTRANSFORM)
75707643 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75717644 //LA.vecCross(up, cVector.Z, right2);
75727645
7573
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7646
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75747647
75757648 //System.out.println("DELTA0 = " + delta);
75767649 //System.out.println("AWAY = " + info.camera.away);
75777650 //System.out.println("UP = " + info.camera.up);
75787651 if (away.z > 0)
75797652 {
7580
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7653
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75817654 {
75827655 delta.x = -delta.x;
75837656 } else
....@@ -7592,7 +7665,7 @@
75927665 //System.out.println("DELTA1 = " + delta);
75937666 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75947667 //System.out.println("DELTA2 = " + delta);
7595
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7668
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75967669 LA.matCopy(startMat, toParent);
75977670 //System.out.println("DELTA3 = " + delta);
75987671 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7602,8 +7675,8 @@
76027675 break;
76037676
76047677 case hitRotate: // rotate
7605
- int dx = info.x - centerPt.x;
7606
- int dy = -(info.y - centerPt.y);
7678
+ int dx = clickInfo.x - centerPt.x;
7679
+ int dy = -(clickInfo.y - centerPt.y);
76077680 double angle = (double) Math.atan2(dx, dy);
76087681 angle = -(1.570796 - angle);
76097682
....@@ -7626,7 +7699,7 @@
76267699 }
76277700 /**/
76287701
7629
- switch (info.pane.RenderCamera().viewCode)
7702
+ switch (clickInfo.pane.RenderCamera().viewCode)
76307703 {
76317704 case 1: // '\001'
76327705 LA.matZRotate(toParent, angle);
....@@ -7653,7 +7726,7 @@
76537726 break;
76547727
76557728 case hitScale: // scale
7656
- double hScale = (double) (info.x - centerPt.x) / 32;
7729
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
76577730 double sign = 1;
76587731 if (hScale < 0)
76597732 {
....@@ -7665,7 +7738,7 @@
76657738 //hScale = 0.01;
76667739 }
76677740
7668
- double vScale = (double) (info.y - centerPt.y) / 32;
7741
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
76697742 sign = 1;
76707743 if (vScale < 0)
76717744 {
....@@ -7676,6 +7749,7 @@
76767749 {
76777750 //vScale = 0.01;
76787751 }
7752
+
76797753 LA.matCopy(startMat, toParent);
76807754 /**/
76817755 for (int i = 0; i < 3; i++)
....@@ -7685,14 +7759,14 @@
76857759 }
76867760 /**/
76877761
7688
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7762
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76897763
76907764 if (totalScale < 0.01)
76917765 {
76927766 totalScale = 0.01;
76937767 }
76947768
7695
- switch (info.pane.RenderCamera().viewCode)
7769
+ switch (clickInfo.pane.RenderCamera().viewCode)
76967770 {
76977771 case 3: // '\001'
76987772 if (modified || opposite)
....@@ -7759,7 +7833,7 @@
77597833 } // NEW ...
77607834
77617835
7762
- info.pane.repaint();
7836
+ clickInfo.pane.repaint();
77637837 }
77647838
77657839 boolean overflow = false;