Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
Object3D.java
....@@ -29,7 +29,10 @@
2929 Object3D saveskeleton;
3030 //
3131
32
- byte[] versions[] = new byte[100][];
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ byte[] versions[];
3336 int versionindex = -1;
3437
3538 ScriptNode scriptnode;
....@@ -426,6 +429,7 @@
426429 }
427430
428431 boolean live = false;
432
+ transient boolean keepdontselect;
429433 boolean dontselect = false;
430434 boolean hide = false;
431435 boolean link2master = false; // performs reset support/master at each frame
....@@ -2566,7 +2570,8 @@
25662570 private static final int editSelf = 1;
25672571 private static final int editChild = 2;
25682572
2569
- void drawEditHandles(ClickInfo info, int level)
2573
+ void drawEditHandles(//ClickInfo info,
2574
+ int level)
25702575 {
25712576 if (level == 0)
25722577 {
....@@ -2574,7 +2579,8 @@
25742579 return;
25752580
25762581 Object3D selectee;
2577
- 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))
25782584 {
25792585 selectee = (Object3D) e.nextElement();
25802586 }
....@@ -2582,19 +2588,22 @@
25822588 } else
25832589 {
25842590 //super.
2585
- drawEditHandles0(info, level + 1);
2591
+ drawEditHandles0(//info,
2592
+ level + 1);
25862593 }
25872594 }
25882595
2589
- boolean doEditClick(ClickInfo info, int level)
2596
+ boolean doEditClick(//ClickInfo info,
2597
+ int level)
25902598 {
25912599 doSomething = 0;
25922600 if (level == 0)
25932601 {
2594
- return doParentClick(info);
2602
+ return doParentClick(); //info);
25952603 }
25962604 if (//super.
2597
- doEditClick0(info, level))
2605
+ doEditClick0(//info,
2606
+ level))
25982607 {
25992608 doSomething = 1;
26002609 return true;
....@@ -2604,7 +2613,7 @@
26042613 }
26052614 }
26062615
2607
- boolean doParentClick(ClickInfo info)
2616
+ boolean doParentClick() //ClickInfo info)
26082617 {
26092618 if (selection == null)
26102619 {
....@@ -2617,7 +2626,8 @@
26172626 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26182627 {
26192628 Object3D selectee = (Object3D) e.nextElement();
2620
- if (selectee.doEditClick(info, 1))
2629
+ if (selectee.doEditClick(//info,
2630
+ 1))
26212631 {
26222632 childToDrag = selectee;
26232633 doSomething = 2;
....@@ -2629,13 +2639,15 @@
26292639 return retval;
26302640 }
26312641
2632
- void doEditDrag(ClickInfo info, boolean opposite)
2642
+ void doEditDrag(//ClickInfo clickInfo,
2643
+ boolean opposite)
26332644 {
26342645 switch (doSomething)
26352646 {
26362647 case 1: // '\001'
26372648 //super.
2638
- doEditDrag0(info, opposite);
2649
+ doEditDrag0(//clickInfo,
2650
+ opposite);
26392651 break;
26402652
26412653 case 2: // '\002'
....@@ -2648,11 +2660,13 @@
26482660 {
26492661 //sel.hitSomething = childToDrag.hitSomething;
26502662 //childToDrag.doEditDrag(info);
2651
- sel.doEditDrag(info, opposite);
2663
+ sel.doEditDrag(//clickInfo,
2664
+ opposite);
26522665 } else
26532666 {
26542667 //super.
2655
- doEditDrag0(info, opposite);
2668
+ doEditDrag0(//clickInfo,
2669
+ opposite);
26562670 }
26572671 }
26582672 break;
....@@ -2670,6 +2684,9 @@
26702684 {
26712685 deselectAll();
26722686 }
2687
+
2688
+ new Exception().printStackTrace();
2689
+
26732690 ClickInfo newInfo = new ClickInfo();
26742691 newInfo.flags = info.flags;
26752692 newInfo.bounds = info.bounds;
....@@ -5420,6 +5437,51 @@
54205437 blockloop = false;
54215438 }
54225439
5440
+ void ResetSelectable()
5441
+ {
5442
+ if (blockloop)
5443
+ return;
5444
+
5445
+ blockloop = true;
5446
+
5447
+ keepdontselect = dontselect;
5448
+ dontselect = true;
5449
+
5450
+ Object3D child;
5451
+ int nb = Size();
5452
+ for (int i = 0; i < nb; i++)
5453
+ {
5454
+ child = (Object3D) get(i);
5455
+ if (child == null)
5456
+ continue;
5457
+ child.ResetSelectable();
5458
+ }
5459
+
5460
+ blockloop = false;
5461
+ }
5462
+
5463
+ void RestoreSelectable()
5464
+ {
5465
+ if (blockloop)
5466
+ return;
5467
+
5468
+ blockloop = true;
5469
+
5470
+ dontselect = keepdontselect;
5471
+
5472
+ Object3D child;
5473
+ int nb = Size();
5474
+ for (int i = 0; i < nb; i++)
5475
+ {
5476
+ child = (Object3D) get(i);
5477
+ if (child == null)
5478
+ continue;
5479
+ child.RestoreSelectable();
5480
+ }
5481
+
5482
+ blockloop = false;
5483
+ }
5484
+
54235485 boolean IsSelected()
54245486 {
54255487 if (parent == null)
....@@ -5729,6 +5791,38 @@
57295791 }
57305792 }
57315793
5794
+ void EmbedTextures(boolean embed)
5795
+ {
5796
+ if (blockloop)
5797
+ return;
5798
+
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
+ }
5811
+
5812
+ int nb = Size();
5813
+ for (int i = 0; i < nb; i++)
5814
+ {
5815
+ Object3D child = (Object3D) get(i);
5816
+
5817
+ if (child == null)
5818
+ continue;
5819
+
5820
+ blockloop = true;
5821
+ child.EmbedTextures(embed);
5822
+ blockloop = false;
5823
+ }
5824
+ }
5825
+
57325826 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57335827 {
57345828 Draw(display, root, selected, blocked);
....@@ -5816,7 +5910,7 @@
58165910 support = support;
58175911
58185912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5819
- 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);
58205914
58215915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58225916 {
....@@ -7220,20 +7314,23 @@
72207314 }
72217315 }
72227316
7223
- 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)
72247321 {
7225
- int hc = info.bounds.x + info.bounds.width / 2;
7226
- int vc = info.bounds.y + info.bounds.height / 2;
7227
- 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;
72287325 if (toscreen == null)
72297326 {
7230
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72317328 }
72327329 cVector vec = in;
72337330 LA.xformPos(in, toscreen, in);
72347331 //System.out.println("Distance = " + info.camera.Distance());
7235
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7236
- 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();
72377334 outPt.x = hc + (int) vec.x;
72387335 outPt.y = vc - (int) vec.y;
72397336 outRec.x = outPt.x - 3;
....@@ -7241,15 +7338,18 @@
72417338 outRec.width = outRec.height = 6;
72427339 }
72437340
7244
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
72457343 {
72467344 Point pt = new Point(0, 0);
72477345 Rectangle rec = new Rectangle();
7248
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
72497348 return rec;
72507349 }
72517350
7252
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
72537353 {
72547354 if (level == 0)
72557355 {
....@@ -7258,16 +7358,19 @@
72587358 {
72597359 cVector origin = new cVector();
72607360 //LA.xformPos(origin, toParent, origin);
7261
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72627365 Rectangle boundary = new Rectangle();
72637366 boundary.x = spot.x - 30;
72647367 boundary.y = spot.y - 30;
72657368 boundary.width = spot.width + 60;
72667369 boundary.height = spot.height + 60;
7267
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
72687371 int spotw = spot.x + spot.width;
72697372 int spoth = spot.y + spot.height;
7270
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72717374 // if (CameraPane.Xmin > spot.x)
72727375 // {
72737376 // CameraPane.Xmin = spot.x;
....@@ -7287,8 +7390,8 @@
72877390 spot.translate(32, 32);
72887391 spotw = spot.x + spot.width;
72897392 spoth = spot.y + spot.height;
7290
- info.g.setColor(Color.cyan);
7291
- 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);
72927395 // if (CameraPane.Xmin > spot.x)
72937396 // {
72947397 // CameraPane.Xmin = spot.x;
....@@ -7308,9 +7411,9 @@
73087411 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73097412 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73107413 spot.translate(0, -32);
7311
- info.g.setColor(Color.yellow);
7312
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
- 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);
73147417 // if (CameraPane.Xmin > spot.x)
73157418 // {
73167419 // CameraPane.Xmin = spot.x;
....@@ -7327,8 +7430,8 @@
73277430 // {
73287431 // CameraPane.Ymax = spoth;
73297432 // }
7330
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
- (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);
73327435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73337436 // if (CameraPane.Xmin > boundary.x)
73347437 // {
....@@ -7350,7 +7453,8 @@
73507453 }
73517454 }
73527455
7353
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
73547458 {
73557459 if (level == 0)
73567460 {
....@@ -7359,8 +7463,8 @@
73597463
73607464 boolean retval = false;
73617465
7362
- startX = info.x;
7363
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
73647468
73657469 hitSomething = -1;
73667470 cVector origin = new cVector();
....@@ -7370,22 +7474,51 @@
73707474 {
73717475 centerPt = new Point(0, 0);
73727476 }
7373
- calcHotSpot(origin, info, centerPt, spot);
7374
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
73757480 {
73767481 hitSomething = hitCenter;
73777482 retval = true;
73787483 }
73797484 spot.translate(32, 0);
7380
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
73817486 {
73827487 hitSomething = hitRotate;
73837488 retval = true;
73847489 }
73857490 spot.translate(0, 32);
7386
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
73877492 {
73887493 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
+
73897522 retval = true;
73907523 }
73917524
....@@ -7395,7 +7528,7 @@
73957528 }
73967529
73977530 //System.out.println("info.modifiers = " + info.modifiers);
7398
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73997532 //System.out.println("modified = " + modified);
74007533 //new Exception().printStackTrace();
74017534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7423,7 +7556,8 @@
74237556 return true;
74247557 }
74257558
7426
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
74277561 {
74287562 if (hitSomething == 0)
74297563 {
....@@ -7437,7 +7571,7 @@
74377571
74387572 //System.out.println("hitSomething = " + hitSomething);
74397573
7440
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
74417575
74427576 cVector xlate = new cVector();
74437577 //cVector xlate2 = new cVector();
....@@ -7471,8 +7605,8 @@
74717605 toParent[3][i] = xlate.get(i);
74727606 LA.matInvert(toParent, fromParent);
74737607 */
7474
- cVector delta = LA.newVector(0, 0, startY - info.y);
7475
- 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);
74767610
74777611 LA.matCopy(startMat, toParent);
74787612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7481,7 +7615,7 @@
74817615 } else
74827616 {
74837617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7484
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
74857619 cVector away = new cVector();
74867620 //cVector right2 = new cVector();
74877621 //LA.vecCross(up, cVector.Z, right);
....@@ -7498,19 +7632,19 @@
74987632 LA.xformDir(up, ClickInfo.matbuffer, up);
74997633 // if (!CameraPane.LOCALTRANSFORM)
75007634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7501
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75027636 // if (!CameraPane.LOCALTRANSFORM)
75037637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75047638 //LA.vecCross(up, cVector.Z, right2);
75057639
7506
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75077641
75087642 //System.out.println("DELTA0 = " + delta);
75097643 //System.out.println("AWAY = " + info.camera.away);
75107644 //System.out.println("UP = " + info.camera.up);
75117645 if (away.z > 0)
75127646 {
7513
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75147648 {
75157649 delta.x = -delta.x;
75167650 } else
....@@ -7525,7 +7659,7 @@
75257659 //System.out.println("DELTA1 = " + delta);
75267660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75277661 //System.out.println("DELTA2 = " + delta);
7528
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75297663 LA.matCopy(startMat, toParent);
75307664 //System.out.println("DELTA3 = " + delta);
75317665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7535,8 +7669,8 @@
75357669 break;
75367670
75377671 case hitRotate: // rotate
7538
- int dx = info.x - centerPt.x;
7539
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
75407674 double angle = (double) Math.atan2(dx, dy);
75417675 angle = -(1.570796 - angle);
75427676
....@@ -7559,7 +7693,7 @@
75597693 }
75607694 /**/
75617695
7562
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
75637697 {
75647698 case 1: // '\001'
75657699 LA.matZRotate(toParent, angle);
....@@ -7586,7 +7720,7 @@
75867720 break;
75877721
75887722 case hitScale: // scale
7589
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
75907724 double sign = 1;
75917725 if (hScale < 0)
75927726 {
....@@ -7598,7 +7732,7 @@
75987732 //hScale = 0.01;
75997733 }
76007734
7601
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
76027736 sign = 1;
76037737 if (vScale < 0)
76047738 {
....@@ -7609,6 +7743,7 @@
76097743 {
76107744 //vScale = 0.01;
76117745 }
7746
+
76127747 LA.matCopy(startMat, toParent);
76137748 /**/
76147749 for (int i = 0; i < 3; i++)
....@@ -7618,14 +7753,14 @@
76187753 }
76197754 /**/
76207755
7621
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76227757
76237758 if (totalScale < 0.01)
76247759 {
76257760 totalScale = 0.01;
76267761 }
76277762
7628
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
76297764 {
76307765 case 3: // '\001'
76317766 if (modified || opposite)
....@@ -7692,7 +7827,7 @@
76927827 } // NEW ...
76937828
76947829
7695
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
76967831 }
76977832
76987833 boolean overflow = false;