Normand Briere
2019-08-01 7d02eaffc02895a01d95d8fd7e089044449e1d6d
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;
....@@ -5893,8 +5912,10 @@
58935912 if (support != null)
58945913 support = support;
58955914
5896
- //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);
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.
58985919
58995920 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59005921 {
....@@ -5904,8 +5925,9 @@
59045925 // usecalllists &= !(parent instanceof RandomNode);
59055926 // usecalllists = false;
59065927
5907
- if (GetBRep() != null)
5908
- usecalllists = usecalllists;
5928
+ if (display.DrawMode() == display.SHADOW)
5929
+ //GetBRep() != null)
5930
+ usecalllists = !!usecalllists;
59095931 //System.out.println("draw " + this);
59105932 //new Exception().printStackTrace();
59115933
....@@ -5927,7 +5949,7 @@
59275949 if (!(this instanceof Composite))
59285950 touched = false;
59295951 //if (displaylist == -1 && usecalllists)
5930
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5952
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59315953 {
59325954 bRep.displaylist = display.GenList();
59335955 assert(bRep.displaylist != 0);
....@@ -5938,7 +5960,7 @@
59385960
59395961 //System.out.println("\tnew list " + list);
59405962 //gl.glDrawBuffer(gl.GL_NONE);
5941
- if (usecalllists)
5963
+ if (usecalllists && bRep.displaylist > 0)
59425964 {
59435965 // System.err.println("new list " + bRep.displaylist + " for " + this);
59445966 display.NewList(bRep.displaylist);
....@@ -5947,7 +5969,7 @@
59475969 CallList(display, root, selected, blocked);
59485970
59495971 // compiled = true;
5950
- if (usecalllists)
5972
+ if (usecalllists && bRep.displaylist > 0)
59515973 {
59525974 // System.err.println("end list " + bRep.displaylist + " for " + this);
59535975 display.EndList();
....@@ -7298,20 +7320,23 @@
72987320 }
72997321 }
73007322
7301
- 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)
73027327 {
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;
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;
73067331 if (toscreen == null)
73077332 {
7308
- toscreen = new Camera(info.camera.viewCode).toScreen;
7333
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73097334 }
73107335 cVector vec = in;
73117336 LA.xformPos(in, toscreen, in);
73127337 //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();
7338
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7339
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73157340 outPt.x = hc + (int) vec.x;
73167341 outPt.y = vc - (int) vec.y;
73177342 outRec.x = outPt.x - 3;
....@@ -7319,15 +7344,18 @@
73197344 outRec.width = outRec.height = 6;
73207345 }
73217346
7322
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7347
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7348
+ )
73237349 {
73247350 Point pt = new Point(0, 0);
73257351 Rectangle rec = new Rectangle();
7326
- calcHotSpot(in, info, pt, rec);
7352
+ calcHotSpot(in, //clickInfo,
7353
+ pt, rec);
73277354 return rec;
73287355 }
73297356
7330
- void drawEditHandles0(ClickInfo info, int level)
7357
+ void drawEditHandles0(//ClickInfo clickInfo,
7358
+ int level)
73317359 {
73327360 if (level == 0)
73337361 {
....@@ -7336,16 +7364,19 @@
73367364 {
73377365 cVector origin = new cVector();
73387366 //LA.xformPos(origin, toParent, origin);
7339
- Rectangle spot = calcHotSpot(origin, info);
7367
+ if (this.clickInfo == null)
7368
+ this.clickInfo = new ClickInfo();
7369
+
7370
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73407371 Rectangle boundary = new Rectangle();
73417372 boundary.x = spot.x - 30;
73427373 boundary.y = spot.y - 30;
73437374 boundary.width = spot.width + 60;
73447375 boundary.height = spot.height + 60;
7345
- info.g.setColor(Color.red);
7376
+ clickInfo.g.setColor(Color.red);
73467377 int spotw = spot.x + spot.width;
73477378 int spoth = spot.y + spot.height;
7348
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73497380 // if (CameraPane.Xmin > spot.x)
73507381 // {
73517382 // CameraPane.Xmin = spot.x;
....@@ -7365,8 +7396,8 @@
73657396 spot.translate(32, 32);
73667397 spotw = spot.x + spot.width;
73677398 spoth = spot.y + spot.height;
7368
- info.g.setColor(Color.cyan);
7369
- 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);
73707401 // if (CameraPane.Xmin > spot.x)
73717402 // {
73727403 // CameraPane.Xmin = spot.x;
....@@ -7386,9 +7417,9 @@
73867417 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73877418 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73887419 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);
7420
+ clickInfo.g.setColor(Color.yellow);
7421
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7422
+ clickInfo.g.setColor(Color.green);
73927423 // if (CameraPane.Xmin > spot.x)
73937424 // {
73947425 // CameraPane.Xmin = spot.x;
....@@ -7405,8 +7436,8 @@
74057436 // {
74067437 // CameraPane.Ymax = spoth;
74077438 // }
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);
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);
74107441 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74117442 // if (CameraPane.Xmin > boundary.x)
74127443 // {
....@@ -7428,7 +7459,8 @@
74287459 }
74297460 }
74307461
7431
- boolean doEditClick0(ClickInfo info, int level)
7462
+ boolean doEditClick0(//ClickInfo clickInfo,
7463
+ int level)
74327464 {
74337465 if (level == 0)
74347466 {
....@@ -7437,8 +7469,8 @@
74377469
74387470 boolean retval = false;
74397471
7440
- startX = info.x;
7441
- startY = info.y;
7472
+ startX = clickInfo.x;
7473
+ startY = clickInfo.y;
74427474
74437475 hitSomething = -1;
74447476 cVector origin = new cVector();
....@@ -7448,22 +7480,51 @@
74487480 {
74497481 centerPt = new Point(0, 0);
74507482 }
7451
- calcHotSpot(origin, info, centerPt, spot);
7452
- if (spot.contains(info.x, info.y))
7483
+ calcHotSpot(origin, //info,
7484
+ centerPt, spot);
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
74537486 {
74547487 hitSomething = hitCenter;
74557488 retval = true;
74567489 }
74577490 spot.translate(32, 0);
7458
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
74597492 {
74607493 hitSomething = hitRotate;
74617494 retval = true;
74627495 }
74637496 spot.translate(0, 32);
7464
- if (spot.contains(info.x, info.y))
7497
+ if (spot.contains(clickInfo.x, clickInfo.y))
74657498 {
74667499 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
+
74677528 retval = true;
74687529 }
74697530
....@@ -7473,7 +7534,7 @@
74737534 }
74747535
74757536 //System.out.println("info.modifiers = " + info.modifiers);
7476
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7537
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74777538 //System.out.println("modified = " + modified);
74787539 //new Exception().printStackTrace();
74797540 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7501,7 +7562,8 @@
75017562 return true;
75027563 }
75037564
7504
- void doEditDrag0(ClickInfo info, boolean opposite)
7565
+ void doEditDrag0(//ClickInfo info,
7566
+ boolean opposite)
75057567 {
75067568 if (hitSomething == 0)
75077569 {
....@@ -7515,7 +7577,7 @@
75157577
75167578 //System.out.println("hitSomething = " + hitSomething);
75177579
7518
- double scale = 0.005f * info.camera.Distance();
7580
+ double scale = 0.005f * clickInfo.camera.Distance();
75197581
75207582 cVector xlate = new cVector();
75217583 //cVector xlate2 = new cVector();
....@@ -7549,8 +7611,8 @@
75497611 toParent[3][i] = xlate.get(i);
75507612 LA.matInvert(toParent, fromParent);
75517613 */
7552
- cVector delta = LA.newVector(0, 0, startY - info.y);
7553
- 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);
75547616
75557617 LA.matCopy(startMat, toParent);
75567618 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7559,7 +7621,7 @@
75597621 } else
75607622 {
75617623 //LA.xformDir(delta, info.camera.fromScreen, delta);
7562
- cVector up = new cVector(info.camera.up);
7624
+ cVector up = new cVector(clickInfo.camera.up);
75637625 cVector away = new cVector();
75647626 //cVector right2 = new cVector();
75657627 //LA.vecCross(up, cVector.Z, right);
....@@ -7576,19 +7638,19 @@
75767638 LA.xformDir(up, ClickInfo.matbuffer, up);
75777639 // if (!CameraPane.LOCALTRANSFORM)
75787640 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7579
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7641
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75807642 // if (!CameraPane.LOCALTRANSFORM)
75817643 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75827644 //LA.vecCross(up, cVector.Z, right2);
75837645
7584
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7646
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75857647
75867648 //System.out.println("DELTA0 = " + delta);
75877649 //System.out.println("AWAY = " + info.camera.away);
75887650 //System.out.println("UP = " + info.camera.up);
75897651 if (away.z > 0)
75907652 {
7591
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7653
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75927654 {
75937655 delta.x = -delta.x;
75947656 } else
....@@ -7603,7 +7665,7 @@
76037665 //System.out.println("DELTA1 = " + delta);
76047666 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76057667 //System.out.println("DELTA2 = " + delta);
7606
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7668
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76077669 LA.matCopy(startMat, toParent);
76087670 //System.out.println("DELTA3 = " + delta);
76097671 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7613,8 +7675,8 @@
76137675 break;
76147676
76157677 case hitRotate: // rotate
7616
- int dx = info.x - centerPt.x;
7617
- int dy = -(info.y - centerPt.y);
7678
+ int dx = clickInfo.x - centerPt.x;
7679
+ int dy = -(clickInfo.y - centerPt.y);
76187680 double angle = (double) Math.atan2(dx, dy);
76197681 angle = -(1.570796 - angle);
76207682
....@@ -7637,7 +7699,7 @@
76377699 }
76387700 /**/
76397701
7640
- switch (info.pane.RenderCamera().viewCode)
7702
+ switch (clickInfo.pane.RenderCamera().viewCode)
76417703 {
76427704 case 1: // '\001'
76437705 LA.matZRotate(toParent, angle);
....@@ -7664,7 +7726,7 @@
76647726 break;
76657727
76667728 case hitScale: // scale
7667
- double hScale = (double) (info.x - centerPt.x) / 32;
7729
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
76687730 double sign = 1;
76697731 if (hScale < 0)
76707732 {
....@@ -7676,7 +7738,7 @@
76767738 //hScale = 0.01;
76777739 }
76787740
7679
- double vScale = (double) (info.y - centerPt.y) / 32;
7741
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
76807742 sign = 1;
76817743 if (vScale < 0)
76827744 {
....@@ -7687,6 +7749,7 @@
76877749 {
76887750 //vScale = 0.01;
76897751 }
7752
+
76907753 LA.matCopy(startMat, toParent);
76917754 /**/
76927755 for (int i = 0; i < 3; i++)
....@@ -7696,14 +7759,14 @@
76967759 }
76977760 /**/
76987761
7699
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7762
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
77007763
77017764 if (totalScale < 0.01)
77027765 {
77037766 totalScale = 0.01;
77047767 }
77057768
7706
- switch (info.pane.RenderCamera().viewCode)
7769
+ switch (clickInfo.pane.RenderCamera().viewCode)
77077770 {
77087771 case 3: // '\001'
77097772 if (modified || opposite)
....@@ -7770,7 +7833,7 @@
77707833 } // NEW ...
77717834
77727835
7773
- info.pane.repaint();
7836
+ clickInfo.pane.repaint();
77747837 }
77757838
77767839 boolean overflow = false;