Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
Object3D.java
....@@ -29,6 +29,12 @@
2929 Object3D saveskeleton;
3030 //
3131
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ byte[] versions[];
36
+ int versionindex = -1;
37
+
3238 ScriptNode scriptnode;
3339
3440 void InitOthers()
....@@ -215,6 +221,9 @@
215221 // o.transientrep = this.bRep.support;
216222 // o.bRep.support = null;
217223 // }
224
+ o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
218227
219228 if (this.support != null)
220229 {
....@@ -268,6 +277,11 @@
268277 {
269278 this.support.bRep = o.transientrep;
270279 }
280
+
281
+ this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
271285 // July 2019 if (this.bRep != null)
272286 // this.bRep.support = o.transientrep;
273287 // this.support = o.support;
....@@ -415,6 +429,7 @@
415429 }
416430
417431 boolean live = false;
432
+ transient boolean keepdontselect;
418433 boolean dontselect = false;
419434 boolean hide = false;
420435 boolean link2master = false; // performs reset support/master at each frame
....@@ -2555,7 +2570,8 @@
25552570 private static final int editSelf = 1;
25562571 private static final int editChild = 2;
25572572
2558
- void drawEditHandles(ClickInfo info, int level)
2573
+ void drawEditHandles(//ClickInfo info,
2574
+ int level)
25592575 {
25602576 if (level == 0)
25612577 {
....@@ -2563,7 +2579,8 @@
25632579 return;
25642580
25652581 Object3D selectee;
2566
- 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))
25672584 {
25682585 selectee = (Object3D) e.nextElement();
25692586 }
....@@ -2571,19 +2588,22 @@
25712588 } else
25722589 {
25732590 //super.
2574
- drawEditHandles0(info, level + 1);
2591
+ drawEditHandles0(//info,
2592
+ level + 1);
25752593 }
25762594 }
25772595
2578
- boolean doEditClick(ClickInfo info, int level)
2596
+ boolean doEditClick(//ClickInfo info,
2597
+ int level)
25792598 {
25802599 doSomething = 0;
25812600 if (level == 0)
25822601 {
2583
- return doParentClick(info);
2602
+ return doParentClick(); //info);
25842603 }
25852604 if (//super.
2586
- doEditClick0(info, level))
2605
+ doEditClick0(//info,
2606
+ level))
25872607 {
25882608 doSomething = 1;
25892609 return true;
....@@ -2593,7 +2613,7 @@
25932613 }
25942614 }
25952615
2596
- boolean doParentClick(ClickInfo info)
2616
+ boolean doParentClick() //ClickInfo info)
25972617 {
25982618 if (selection == null)
25992619 {
....@@ -2606,7 +2626,8 @@
26062626 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26072627 {
26082628 Object3D selectee = (Object3D) e.nextElement();
2609
- if (selectee.doEditClick(info, 1))
2629
+ if (selectee.doEditClick(//info,
2630
+ 1))
26102631 {
26112632 childToDrag = selectee;
26122633 doSomething = 2;
....@@ -2618,13 +2639,15 @@
26182639 return retval;
26192640 }
26202641
2621
- void doEditDrag(ClickInfo info, boolean opposite)
2642
+ void doEditDrag(//ClickInfo clickInfo,
2643
+ boolean opposite)
26222644 {
26232645 switch (doSomething)
26242646 {
26252647 case 1: // '\001'
26262648 //super.
2627
- doEditDrag0(info, opposite);
2649
+ doEditDrag0(//clickInfo,
2650
+ opposite);
26282651 break;
26292652
26302653 case 2: // '\002'
....@@ -2637,11 +2660,13 @@
26372660 {
26382661 //sel.hitSomething = childToDrag.hitSomething;
26392662 //childToDrag.doEditDrag(info);
2640
- sel.doEditDrag(info, opposite);
2663
+ sel.doEditDrag(//clickInfo,
2664
+ opposite);
26412665 } else
26422666 {
26432667 //super.
2644
- doEditDrag0(info, opposite);
2668
+ doEditDrag0(//clickInfo,
2669
+ opposite);
26452670 }
26462671 }
26472672 break;
....@@ -2659,6 +2684,9 @@
26592684 {
26602685 deselectAll();
26612686 }
2687
+
2688
+ new Exception().printStackTrace();
2689
+
26622690 ClickInfo newInfo = new ClickInfo();
26632691 newInfo.flags = info.flags;
26642692 newInfo.bounds = info.bounds;
....@@ -3106,7 +3134,7 @@
31063134 {
31073135 if (bRep != null)
31083136 {
3109
- bRep.GenerateNormalsMINE();
3137
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31103138 Touch();
31113139 }
31123140 }
....@@ -5409,6 +5437,51 @@
54095437 blockloop = false;
54105438 }
54115439
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
+
54125485 boolean IsSelected()
54135486 {
54145487 if (parent == null)
....@@ -5718,6 +5791,38 @@
57185791 }
57195792 }
57205793
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
+
57215826 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57225827 {
57235828 Draw(display, root, selected, blocked);
....@@ -5805,7 +5910,7 @@
58055910 support = support;
58065911
58075912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5808
- 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);
58095914
58105915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58115916 {
....@@ -7209,20 +7314,23 @@
72097314 }
72107315 }
72117316
7212
- 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)
72137321 {
7214
- int hc = info.bounds.x + info.bounds.width / 2;
7215
- int vc = info.bounds.y + info.bounds.height / 2;
7216
- 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;
72177325 if (toscreen == null)
72187326 {
7219
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72207328 }
72217329 cVector vec = in;
72227330 LA.xformPos(in, toscreen, in);
72237331 //System.out.println("Distance = " + info.camera.Distance());
7224
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7225
- 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();
72267334 outPt.x = hc + (int) vec.x;
72277335 outPt.y = vc - (int) vec.y;
72287336 outRec.x = outPt.x - 3;
....@@ -7230,15 +7338,18 @@
72307338 outRec.width = outRec.height = 6;
72317339 }
72327340
7233
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
72347343 {
72357344 Point pt = new Point(0, 0);
72367345 Rectangle rec = new Rectangle();
7237
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
72387348 return rec;
72397349 }
72407350
7241
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
72427353 {
72437354 if (level == 0)
72447355 {
....@@ -7247,16 +7358,19 @@
72477358 {
72487359 cVector origin = new cVector();
72497360 //LA.xformPos(origin, toParent, origin);
7250
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72517365 Rectangle boundary = new Rectangle();
72527366 boundary.x = spot.x - 30;
72537367 boundary.y = spot.y - 30;
72547368 boundary.width = spot.width + 60;
72557369 boundary.height = spot.height + 60;
7256
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
72577371 int spotw = spot.x + spot.width;
72587372 int spoth = spot.y + spot.height;
7259
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72607374 // if (CameraPane.Xmin > spot.x)
72617375 // {
72627376 // CameraPane.Xmin = spot.x;
....@@ -7276,8 +7390,8 @@
72767390 spot.translate(32, 32);
72777391 spotw = spot.x + spot.width;
72787392 spoth = spot.y + spot.height;
7279
- info.g.setColor(Color.cyan);
7280
- 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);
72817395 // if (CameraPane.Xmin > spot.x)
72827396 // {
72837397 // CameraPane.Xmin = spot.x;
....@@ -7297,9 +7411,9 @@
72977411 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72987412 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
72997413 spot.translate(0, -32);
7300
- info.g.setColor(Color.yellow);
7301
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
- 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);
73037417 // if (CameraPane.Xmin > spot.x)
73047418 // {
73057419 // CameraPane.Xmin = spot.x;
....@@ -7316,8 +7430,8 @@
73167430 // {
73177431 // CameraPane.Ymax = spoth;
73187432 // }
7319
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
- (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);
73217435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73227436 // if (CameraPane.Xmin > boundary.x)
73237437 // {
....@@ -7339,7 +7453,8 @@
73397453 }
73407454 }
73417455
7342
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
73437458 {
73447459 if (level == 0)
73457460 {
....@@ -7348,8 +7463,8 @@
73487463
73497464 boolean retval = false;
73507465
7351
- startX = info.x;
7352
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
73537468
73547469 hitSomething = -1;
73557470 cVector origin = new cVector();
....@@ -7359,22 +7474,51 @@
73597474 {
73607475 centerPt = new Point(0, 0);
73617476 }
7362
- calcHotSpot(origin, info, centerPt, spot);
7363
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
73647480 {
73657481 hitSomething = hitCenter;
73667482 retval = true;
73677483 }
73687484 spot.translate(32, 0);
7369
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707486 {
73717487 hitSomething = hitRotate;
73727488 retval = true;
73737489 }
73747490 spot.translate(0, 32);
7375
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
73767492 {
73777493 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
+
73787522 retval = true;
73797523 }
73807524
....@@ -7384,7 +7528,7 @@
73847528 }
73857529
73867530 //System.out.println("info.modifiers = " + info.modifiers);
7387
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73887532 //System.out.println("modified = " + modified);
73897533 //new Exception().printStackTrace();
73907534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7412,7 +7556,8 @@
74127556 return true;
74137557 }
74147558
7415
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
74167561 {
74177562 if (hitSomething == 0)
74187563 {
....@@ -7426,7 +7571,7 @@
74267571
74277572 //System.out.println("hitSomething = " + hitSomething);
74287573
7429
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
74307575
74317576 cVector xlate = new cVector();
74327577 //cVector xlate2 = new cVector();
....@@ -7460,8 +7605,8 @@
74607605 toParent[3][i] = xlate.get(i);
74617606 LA.matInvert(toParent, fromParent);
74627607 */
7463
- cVector delta = LA.newVector(0, 0, startY - info.y);
7464
- 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);
74657610
74667611 LA.matCopy(startMat, toParent);
74677612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7470,7 +7615,7 @@
74707615 } else
74717616 {
74727617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7473
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
74747619 cVector away = new cVector();
74757620 //cVector right2 = new cVector();
74767621 //LA.vecCross(up, cVector.Z, right);
....@@ -7487,19 +7632,19 @@
74877632 LA.xformDir(up, ClickInfo.matbuffer, up);
74887633 // if (!CameraPane.LOCALTRANSFORM)
74897634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7490
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74917636 // if (!CameraPane.LOCALTRANSFORM)
74927637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74937638 //LA.vecCross(up, cVector.Z, right2);
74947639
7495
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74967641
74977642 //System.out.println("DELTA0 = " + delta);
74987643 //System.out.println("AWAY = " + info.camera.away);
74997644 //System.out.println("UP = " + info.camera.up);
75007645 if (away.z > 0)
75017646 {
7502
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75037648 {
75047649 delta.x = -delta.x;
75057650 } else
....@@ -7514,7 +7659,7 @@
75147659 //System.out.println("DELTA1 = " + delta);
75157660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75167661 //System.out.println("DELTA2 = " + delta);
7517
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75187663 LA.matCopy(startMat, toParent);
75197664 //System.out.println("DELTA3 = " + delta);
75207665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7524,8 +7669,8 @@
75247669 break;
75257670
75267671 case hitRotate: // rotate
7527
- int dx = info.x - centerPt.x;
7528
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
75297674 double angle = (double) Math.atan2(dx, dy);
75307675 angle = -(1.570796 - angle);
75317676
....@@ -7548,7 +7693,7 @@
75487693 }
75497694 /**/
75507695
7551
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
75527697 {
75537698 case 1: // '\001'
75547699 LA.matZRotate(toParent, angle);
....@@ -7575,7 +7720,7 @@
75757720 break;
75767721
75777722 case hitScale: // scale
7578
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
75797724 double sign = 1;
75807725 if (hScale < 0)
75817726 {
....@@ -7587,7 +7732,7 @@
75877732 //hScale = 0.01;
75887733 }
75897734
7590
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
75917736 sign = 1;
75927737 if (vScale < 0)
75937738 {
....@@ -7598,6 +7743,7 @@
75987743 {
75997744 //vScale = 0.01;
76007745 }
7746
+
76017747 LA.matCopy(startMat, toParent);
76027748 /**/
76037749 for (int i = 0; i < 3; i++)
....@@ -7607,14 +7753,14 @@
76077753 }
76087754 /**/
76097755
7610
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76117757
76127758 if (totalScale < 0.01)
76137759 {
76147760 totalScale = 0.01;
76157761 }
76167762
7617
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
76187764 {
76197765 case 3: // '\001'
76207766 if (modified || opposite)
....@@ -7681,7 +7827,7 @@
76817827 } // NEW ...
76827828
76837829
7684
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
76857831 }
76867832
76877833 boolean overflow = false;