Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
Object3D.java
....@@ -29,7 +29,10 @@
2929 Object3D saveskeleton;
3030 //
3131
32
- byte[] versions[];
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ Object3D versions[];
3336 int versionindex = -1;
3437
3538 ScriptNode scriptnode;
....@@ -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,6 +5794,38 @@
57755794 }
57765795 }
57775796
5797
+ void EmbedTextures(boolean embed)
5798
+ {
5799
+ if (blockloop)
5800
+ return;
5801
+
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
+ }
5814
+
5815
+ int nb = Size();
5816
+ for (int i = 0; i < nb; i++)
5817
+ {
5818
+ Object3D child = (Object3D) get(i);
5819
+
5820
+ if (child == null)
5821
+ continue;
5822
+
5823
+ blockloop = true;
5824
+ child.EmbedTextures(embed);
5825
+ blockloop = false;
5826
+ }
5827
+ }
5828
+
57785829 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57795830 {
57805831 Draw(display, root, selected, blocked);
....@@ -5861,8 +5912,10 @@
58615912 if (support != null)
58625913 support = support;
58635914
5864
- //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);
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.
58665919
58675920 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58685921 {
....@@ -5872,8 +5925,9 @@
58725925 // usecalllists &= !(parent instanceof RandomNode);
58735926 // usecalllists = false;
58745927
5875
- if (GetBRep() != null)
5876
- usecalllists = usecalllists;
5928
+ if (display.DrawMode() == display.SHADOW)
5929
+ //GetBRep() != null)
5930
+ usecalllists = !!usecalllists;
58775931 //System.out.println("draw " + this);
58785932 //new Exception().printStackTrace();
58795933
....@@ -5895,7 +5949,7 @@
58955949 if (!(this instanceof Composite))
58965950 touched = false;
58975951 //if (displaylist == -1 && usecalllists)
5898
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5952
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58995953 {
59005954 bRep.displaylist = display.GenList();
59015955 assert(bRep.displaylist != 0);
....@@ -5906,7 +5960,7 @@
59065960
59075961 //System.out.println("\tnew list " + list);
59085962 //gl.glDrawBuffer(gl.GL_NONE);
5909
- if (usecalllists)
5963
+ if (usecalllists && bRep.displaylist > 0)
59105964 {
59115965 // System.err.println("new list " + bRep.displaylist + " for " + this);
59125966 display.NewList(bRep.displaylist);
....@@ -5915,7 +5969,7 @@
59155969 CallList(display, root, selected, blocked);
59165970
59175971 // compiled = true;
5918
- if (usecalllists)
5972
+ if (usecalllists && bRep.displaylist > 0)
59195973 {
59205974 // System.err.println("end list " + bRep.displaylist + " for " + this);
59215975 display.EndList();
....@@ -7266,20 +7320,23 @@
72667320 }
72677321 }
72687322
7269
- 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)
72707327 {
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;
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;
72747331 if (toscreen == null)
72757332 {
7276
- toscreen = new Camera(info.camera.viewCode).toScreen;
7333
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72777334 }
72787335 cVector vec = in;
72797336 LA.xformPos(in, toscreen, in);
72807337 //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();
7338
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7339
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72837340 outPt.x = hc + (int) vec.x;
72847341 outPt.y = vc - (int) vec.y;
72857342 outRec.x = outPt.x - 3;
....@@ -7287,15 +7344,18 @@
72877344 outRec.width = outRec.height = 6;
72887345 }
72897346
7290
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7347
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7348
+ )
72917349 {
72927350 Point pt = new Point(0, 0);
72937351 Rectangle rec = new Rectangle();
7294
- calcHotSpot(in, info, pt, rec);
7352
+ calcHotSpot(in, //clickInfo,
7353
+ pt, rec);
72957354 return rec;
72967355 }
72977356
7298
- void drawEditHandles0(ClickInfo info, int level)
7357
+ void drawEditHandles0(//ClickInfo clickInfo,
7358
+ int level)
72997359 {
73007360 if (level == 0)
73017361 {
....@@ -7304,16 +7364,19 @@
73047364 {
73057365 cVector origin = new cVector();
73067366 //LA.xformPos(origin, toParent, origin);
7307
- Rectangle spot = calcHotSpot(origin, info);
7367
+ if (this.clickInfo == null)
7368
+ this.clickInfo = new ClickInfo();
7369
+
7370
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73087371 Rectangle boundary = new Rectangle();
73097372 boundary.x = spot.x - 30;
73107373 boundary.y = spot.y - 30;
73117374 boundary.width = spot.width + 60;
73127375 boundary.height = spot.height + 60;
7313
- info.g.setColor(Color.red);
7376
+ clickInfo.g.setColor(Color.red);
73147377 int spotw = spot.x + spot.width;
73157378 int spoth = spot.y + spot.height;
7316
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73177380 // if (CameraPane.Xmin > spot.x)
73187381 // {
73197382 // CameraPane.Xmin = spot.x;
....@@ -7333,8 +7396,8 @@
73337396 spot.translate(32, 32);
73347397 spotw = spot.x + spot.width;
73357398 spoth = spot.y + spot.height;
7336
- info.g.setColor(Color.cyan);
7337
- 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);
73387401 // if (CameraPane.Xmin > spot.x)
73397402 // {
73407403 // CameraPane.Xmin = spot.x;
....@@ -7354,9 +7417,9 @@
73547417 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73557418 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73567419 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);
7420
+ clickInfo.g.setColor(Color.yellow);
7421
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7422
+ clickInfo.g.setColor(Color.green);
73607423 // if (CameraPane.Xmin > spot.x)
73617424 // {
73627425 // CameraPane.Xmin = spot.x;
....@@ -7373,8 +7436,8 @@
73737436 // {
73747437 // CameraPane.Ymax = spoth;
73757438 // }
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);
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);
73787441 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73797442 // if (CameraPane.Xmin > boundary.x)
73807443 // {
....@@ -7396,7 +7459,8 @@
73967459 }
73977460 }
73987461
7399
- boolean doEditClick0(ClickInfo info, int level)
7462
+ boolean doEditClick0(//ClickInfo clickInfo,
7463
+ int level)
74007464 {
74017465 if (level == 0)
74027466 {
....@@ -7405,8 +7469,8 @@
74057469
74067470 boolean retval = false;
74077471
7408
- startX = info.x;
7409
- startY = info.y;
7472
+ startX = clickInfo.x;
7473
+ startY = clickInfo.y;
74107474
74117475 hitSomething = -1;
74127476 cVector origin = new cVector();
....@@ -7416,22 +7480,51 @@
74167480 {
74177481 centerPt = new Point(0, 0);
74187482 }
7419
- calcHotSpot(origin, info, centerPt, spot);
7420
- if (spot.contains(info.x, info.y))
7483
+ calcHotSpot(origin, //info,
7484
+ centerPt, spot);
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
74217486 {
74227487 hitSomething = hitCenter;
74237488 retval = true;
74247489 }
74257490 spot.translate(32, 0);
7426
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
74277492 {
74287493 hitSomething = hitRotate;
74297494 retval = true;
74307495 }
74317496 spot.translate(0, 32);
7432
- if (spot.contains(info.x, info.y))
7497
+ if (spot.contains(clickInfo.x, clickInfo.y))
74337498 {
74347499 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
+
74357528 retval = true;
74367529 }
74377530
....@@ -7441,7 +7534,7 @@
74417534 }
74427535
74437536 //System.out.println("info.modifiers = " + info.modifiers);
7444
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7537
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74457538 //System.out.println("modified = " + modified);
74467539 //new Exception().printStackTrace();
74477540 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7469,7 +7562,8 @@
74697562 return true;
74707563 }
74717564
7472
- void doEditDrag0(ClickInfo info, boolean opposite)
7565
+ void doEditDrag0(//ClickInfo info,
7566
+ boolean opposite)
74737567 {
74747568 if (hitSomething == 0)
74757569 {
....@@ -7483,7 +7577,7 @@
74837577
74847578 //System.out.println("hitSomething = " + hitSomething);
74857579
7486
- double scale = 0.005f * info.camera.Distance();
7580
+ double scale = 0.005f * clickInfo.camera.Distance();
74877581
74887582 cVector xlate = new cVector();
74897583 //cVector xlate2 = new cVector();
....@@ -7517,8 +7611,8 @@
75177611 toParent[3][i] = xlate.get(i);
75187612 LA.matInvert(toParent, fromParent);
75197613 */
7520
- cVector delta = LA.newVector(0, 0, startY - info.y);
7521
- 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);
75227616
75237617 LA.matCopy(startMat, toParent);
75247618 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7527,7 +7621,7 @@
75277621 } else
75287622 {
75297623 //LA.xformDir(delta, info.camera.fromScreen, delta);
7530
- cVector up = new cVector(info.camera.up);
7624
+ cVector up = new cVector(clickInfo.camera.up);
75317625 cVector away = new cVector();
75327626 //cVector right2 = new cVector();
75337627 //LA.vecCross(up, cVector.Z, right);
....@@ -7544,19 +7638,19 @@
75447638 LA.xformDir(up, ClickInfo.matbuffer, up);
75457639 // if (!CameraPane.LOCALTRANSFORM)
75467640 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7547
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7641
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75487642 // if (!CameraPane.LOCALTRANSFORM)
75497643 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75507644 //LA.vecCross(up, cVector.Z, right2);
75517645
7552
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7646
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75537647
75547648 //System.out.println("DELTA0 = " + delta);
75557649 //System.out.println("AWAY = " + info.camera.away);
75567650 //System.out.println("UP = " + info.camera.up);
75577651 if (away.z > 0)
75587652 {
7559
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7653
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75607654 {
75617655 delta.x = -delta.x;
75627656 } else
....@@ -7571,7 +7665,7 @@
75717665 //System.out.println("DELTA1 = " + delta);
75727666 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75737667 //System.out.println("DELTA2 = " + delta);
7574
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7668
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75757669 LA.matCopy(startMat, toParent);
75767670 //System.out.println("DELTA3 = " + delta);
75777671 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7581,8 +7675,8 @@
75817675 break;
75827676
75837677 case hitRotate: // rotate
7584
- int dx = info.x - centerPt.x;
7585
- int dy = -(info.y - centerPt.y);
7678
+ int dx = clickInfo.x - centerPt.x;
7679
+ int dy = -(clickInfo.y - centerPt.y);
75867680 double angle = (double) Math.atan2(dx, dy);
75877681 angle = -(1.570796 - angle);
75887682
....@@ -7605,7 +7699,7 @@
76057699 }
76067700 /**/
76077701
7608
- switch (info.pane.RenderCamera().viewCode)
7702
+ switch (clickInfo.pane.RenderCamera().viewCode)
76097703 {
76107704 case 1: // '\001'
76117705 LA.matZRotate(toParent, angle);
....@@ -7632,7 +7726,7 @@
76327726 break;
76337727
76347728 case hitScale: // scale
7635
- double hScale = (double) (info.x - centerPt.x) / 32;
7729
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
76367730 double sign = 1;
76377731 if (hScale < 0)
76387732 {
....@@ -7644,7 +7738,7 @@
76447738 //hScale = 0.01;
76457739 }
76467740
7647
- double vScale = (double) (info.y - centerPt.y) / 32;
7741
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
76487742 sign = 1;
76497743 if (vScale < 0)
76507744 {
....@@ -7655,6 +7749,7 @@
76557749 {
76567750 //vScale = 0.01;
76577751 }
7752
+
76587753 LA.matCopy(startMat, toParent);
76597754 /**/
76607755 for (int i = 0; i < 3; i++)
....@@ -7664,14 +7759,14 @@
76647759 }
76657760 /**/
76667761
7667
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7762
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76687763
76697764 if (totalScale < 0.01)
76707765 {
76717766 totalScale = 0.01;
76727767 }
76737768
7674
- switch (info.pane.RenderCamera().viewCode)
7769
+ switch (clickInfo.pane.RenderCamera().viewCode)
76757770 {
76767771 case 3: // '\001'
76777772 if (modified || opposite)
....@@ -7738,7 +7833,7 @@
77387833 } // NEW ...
77397834
77407835
7741
- info.pane.repaint();
7836
+ clickInfo.pane.repaint();
77427837 }
77437838
77447839 boolean overflow = false;