Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
Object3D.java
....@@ -22,6 +22,7 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
2728 // TEMPORARY for mocap undo. No need to be transient.
....@@ -29,9 +30,14 @@
2930 Object3D saveskeleton;
3031 //
3132
32
- byte[] versions[];
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
3337 int versionindex = -1;
3438
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3541 ScriptNode scriptnode;
3642
3743 void InitOthers()
....@@ -219,7 +225,7 @@
219225 // o.bRep.support = null;
220226 // }
221227 o.selection = this.selection;
222
- o.versions = this.versions;
228
+ o.versionlist = this.versionlist;
223229 o.versionindex = this.versionindex;
224230
225231 if (this.support != null)
....@@ -241,6 +247,73 @@
241247 // this.bRep.support = null;
242248 // this.support = null;
243249 // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ transient boolean tag;
276
+
277
+ void TagObjects(Object3D o, boolean tag)
278
+ {
279
+ if (blockloop)
280
+ return;
281
+
282
+ o.tag = tag;
283
+
284
+ if (o == this)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).TagObjects(o, tag);
292
+ }
293
+
294
+ blockloop = false;
295
+ }
296
+
297
+ boolean HasTags()
298
+ {
299
+ if (blockloop)
300
+ return false;
301
+
302
+ blockloop = true;
303
+
304
+ boolean hasTags = false;
305
+
306
+ for (int i=0; i<Size(); i++)
307
+ {
308
+ hasTags |= get(i).tag || get(i).HasTags();
309
+
310
+ if (hasTags)
311
+ break;
312
+ }
313
+
314
+ blockloop = false;
315
+
316
+ return hasTags;
244317 }
245318
246319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -277,7 +350,7 @@
277350
278351 this.selection = o.selection;
279352
280
- this.versions = o.versions;
353
+ this.versionlist = o.versionlist;
281354 this.versionindex = o.versionindex;
282355 // July 2019 if (this.bRep != null)
283356 // this.bRep.support = o.transientrep;
....@@ -1011,6 +1084,9 @@
10111084
10121085 if (material == null || material.multiply)
10131086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10141090
10151091 // Transparent objects are dynamic because we have to sort the triangles.
10161092 return material.opacity > 0.99;
....@@ -2438,6 +2514,11 @@
24382514 else
24392515 {
24402516 //((ObjEditor)editWindow).SetupUI2(null);
2517
+ if (objectUI != null)
2518
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2519
+ else
2520
+ //new Exception().printStackTrace();
2521
+ System.err.println("objectUI is null");
24412522 }
24422523 }
24432524
....@@ -2567,7 +2648,8 @@
25672648 private static final int editSelf = 1;
25682649 private static final int editChild = 2;
25692650
2570
- void drawEditHandles(ClickInfo info, int level)
2651
+ void drawEditHandles(//ClickInfo info,
2652
+ int level)
25712653 {
25722654 if (level == 0)
25732655 {
....@@ -2575,7 +2657,8 @@
25752657 return;
25762658
25772659 Object3D selectee;
2578
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2660
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2661
+ level + 1))
25792662 {
25802663 selectee = (Object3D) e.nextElement();
25812664 }
....@@ -2583,19 +2666,22 @@
25832666 } else
25842667 {
25852668 //super.
2586
- drawEditHandles0(info, level + 1);
2669
+ drawEditHandles0(//info,
2670
+ level + 1);
25872671 }
25882672 }
25892673
2590
- boolean doEditClick(ClickInfo info, int level)
2674
+ boolean doEditClick(//ClickInfo info,
2675
+ int level)
25912676 {
25922677 doSomething = 0;
25932678 if (level == 0)
25942679 {
2595
- return doParentClick(info);
2680
+ return doParentClick(); //info);
25962681 }
25972682 if (//super.
2598
- doEditClick0(info, level))
2683
+ doEditClick0(//info,
2684
+ level))
25992685 {
26002686 doSomething = 1;
26012687 return true;
....@@ -2605,7 +2691,7 @@
26052691 }
26062692 }
26072693
2608
- boolean doParentClick(ClickInfo info)
2694
+ boolean doParentClick() //ClickInfo info)
26092695 {
26102696 if (selection == null)
26112697 {
....@@ -2618,7 +2704,8 @@
26182704 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192705 {
26202706 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2707
+ if (selectee.doEditClick(//info,
2708
+ 1))
26222709 {
26232710 childToDrag = selectee;
26242711 doSomething = 2;
....@@ -2630,13 +2717,15 @@
26302717 return retval;
26312718 }
26322719
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2720
+ void doEditDrag(//ClickInfo clickInfo,
2721
+ boolean opposite)
26342722 {
26352723 switch (doSomething)
26362724 {
26372725 case 1: // '\001'
26382726 //super.
2639
- doEditDrag0(info, opposite);
2727
+ doEditDrag0(//clickInfo,
2728
+ opposite);
26402729 break;
26412730
26422731 case 2: // '\002'
....@@ -2649,11 +2738,13 @@
26492738 {
26502739 //sel.hitSomething = childToDrag.hitSomething;
26512740 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2741
+ sel.doEditDrag(//clickInfo,
2742
+ opposite);
26532743 } else
26542744 {
26552745 //super.
2656
- doEditDrag0(info, opposite);
2746
+ doEditDrag0(//clickInfo,
2747
+ opposite);
26572748 }
26582749 }
26592750 break;
....@@ -2671,6 +2762,9 @@
26712762 {
26722763 deselectAll();
26732764 }
2765
+
2766
+ new Exception().printStackTrace();
2767
+
26742768 ClickInfo newInfo = new ClickInfo();
26752769 newInfo.flags = info.flags;
26762770 newInfo.bounds = info.bounds;
....@@ -3528,15 +3622,47 @@
35283622
35293623 void ClearMaterials()
35303624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35313630 ClearMaterial();
3532
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35333632 {
3534
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35353634 if (child == null)
35363635 continue;
35373636 child.ClearMaterials();
3538
- release(i);
35393637 }
3638
+
3639
+ blockloop = false;
3640
+ }
3641
+
3642
+ void ClearVersionList()
3643
+ {
3644
+ this.versionlist = null;
3645
+ this.versionindex = -1;
3646
+ this.versiontable = null;
3647
+ }
3648
+
3649
+ void ClearVersions()
3650
+ {
3651
+ if (blockloop)
3652
+ return;
3653
+
3654
+ blockloop = true;
3655
+
3656
+ ClearVersionList();
3657
+ for (int i = 0; i < Size(); i++)
3658
+ {
3659
+ Object3D child = (Object3D) get(i);
3660
+ if (child == null)
3661
+ continue;
3662
+ child.ClearVersions();
3663
+ }
3664
+
3665
+ blockloop = false;
35403666 }
35413667
35423668 void FlipV(boolean flip)
....@@ -5526,6 +5652,11 @@
55265652 if (fullname == null)
55275653 return "";
55285654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55295660 // System.out.println("Fullname = " + fullname);
55305661
55315662 // Does not work on Windows due to C:
....@@ -5538,7 +5669,7 @@
55385669
55395670 if (split.length == 0)
55405671 {
5541
- return "";
5672
+ return fullname.pigment = "";
55425673 }
55435674
55445675 if (split.length <= 2)
....@@ -5546,22 +5677,27 @@
55465677 if (fullname.name.endsWith(":"))
55475678 {
55485679 // Windows
5549
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55505681 }
55515682
5552
- return split[0];
5683
+ return fullname.pigment = split[0];
55535684 }
55545685
55555686 // Windows
55565687 assert(split.length == 4);
55575688
5558
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
55595690 }
55605691
55615692 static String GetBump(cTexture fullname)
55625693 {
55635694 if (fullname == null)
55645695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
55655701
55665702 // System.out.println("Fullname = " + fullname);
55675703 // Does not work on Windows due to C:
....@@ -5573,12 +5709,12 @@
55735709
55745710 if (split.length == 0)
55755711 {
5576
- return "";
5712
+ return fullname.bump = "";
55775713 }
55785714
55795715 if (split.length == 1)
55805716 {
5581
- return "";
5717
+ return fullname.bump = "";
55825718 }
55835719
55845720 if (split.length == 2)
....@@ -5586,16 +5722,16 @@
55865722 if (fullname.name.endsWith(":"))
55875723 {
55885724 // Windows
5589
- return "";
5725
+ return fullname.bump = "";
55905726 }
55915727
5592
- return split[1];
5728
+ return fullname.bump = split[1];
55935729 }
55945730
55955731 // Windows
55965732 assert(split.length == 4);
55975733
5598
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
55995735 }
56005736
56015737 String GetPigmentTexture()
....@@ -5678,6 +5814,9 @@
56785814 texname = "";
56795815
56805816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
56815820 Touch();
56825821 }
56835822
....@@ -5751,6 +5890,8 @@
57515890
57525891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57535892
5893
+ GetTextures().bump = null;
5894
+
57545895 Touch();
57555896 }
57565897
....@@ -5771,6 +5912,38 @@
57715912
57725913 blockloop = true;
57735914 child.ResetBumpTexture();
5915
+ blockloop = false;
5916
+ }
5917
+ }
5918
+
5919
+ void EmbedTextures(boolean embed)
5920
+ {
5921
+ if (blockloop)
5922
+ return;
5923
+
5924
+ //if (GetTextures() != null)
5925
+ if (embed)
5926
+ CameraPane.EmbedTextures(GetTextures());
5927
+ else
5928
+ {
5929
+ GetTextures().pigmentdata = null;
5930
+ GetTextures().bumpdata = null;
5931
+ GetTextures().pw = 0;
5932
+ GetTextures().ph = 0;
5933
+ GetTextures().bw = 0;
5934
+ GetTextures().bh = 0;
5935
+ }
5936
+
5937
+ int nb = Size();
5938
+ for (int i = 0; i < nb; i++)
5939
+ {
5940
+ Object3D child = (Object3D) get(i);
5941
+
5942
+ if (child == null)
5943
+ continue;
5944
+
5945
+ blockloop = true;
5946
+ child.EmbedTextures(embed);
57745947 blockloop = false;
57755948 }
57765949 }
....@@ -5861,8 +6034,10 @@
58616034 if (support != null)
58626035 support = support;
58636036
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);
6037
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6038
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6039
+
6040
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58666041
58676042 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58686043 {
....@@ -5872,8 +6047,9 @@
58726047 // usecalllists &= !(parent instanceof RandomNode);
58736048 // usecalllists = false;
58746049
5875
- if (GetBRep() != null)
5876
- usecalllists = usecalllists;
6050
+ if (display.DrawMode() == display.SHADOW)
6051
+ //GetBRep() != null)
6052
+ usecalllists = !!usecalllists;
58776053 //System.out.println("draw " + this);
58786054 //new Exception().printStackTrace();
58796055
....@@ -5895,7 +6071,7 @@
58956071 if (!(this instanceof Composite))
58966072 touched = false;
58976073 //if (displaylist == -1 && usecalllists)
5898
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6074
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58996075 {
59006076 bRep.displaylist = display.GenList();
59016077 assert(bRep.displaylist != 0);
....@@ -5906,7 +6082,7 @@
59066082
59076083 //System.out.println("\tnew list " + list);
59086084 //gl.glDrawBuffer(gl.GL_NONE);
5909
- if (usecalllists)
6085
+ if (usecalllists && bRep.displaylist > 0)
59106086 {
59116087 // System.err.println("new list " + bRep.displaylist + " for " + this);
59126088 display.NewList(bRep.displaylist);
....@@ -5915,7 +6091,7 @@
59156091 CallList(display, root, selected, blocked);
59166092
59176093 // compiled = true;
5918
- if (usecalllists)
6094
+ if (usecalllists && bRep.displaylist > 0)
59196095 {
59206096 // System.err.println("end list " + bRep.displaylist + " for " + this);
59216097 display.EndList();
....@@ -7266,20 +7442,23 @@
72667442 }
72677443 }
72687444
7269
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7445
+ static ClickInfo clickInfo = new ClickInfo();
7446
+
7447
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7448
+ Point outPt, Rectangle outRec)
72707449 {
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;
7450
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7451
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7452
+ double[][] toscreen = clickInfo.toScreen;
72747453 if (toscreen == null)
72757454 {
7276
- toscreen = new Camera(info.camera.viewCode).toScreen;
7455
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72777456 }
72787457 cVector vec = in;
72797458 LA.xformPos(in, toscreen, in);
72807459 //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();
7460
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7461
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72837462 outPt.x = hc + (int) vec.x;
72847463 outPt.y = vc - (int) vec.y;
72857464 outRec.x = outPt.x - 3;
....@@ -7287,15 +7466,18 @@
72877466 outRec.width = outRec.height = 6;
72887467 }
72897468
7290
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7469
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7470
+ )
72917471 {
72927472 Point pt = new Point(0, 0);
72937473 Rectangle rec = new Rectangle();
7294
- calcHotSpot(in, info, pt, rec);
7474
+ calcHotSpot(in, //clickInfo,
7475
+ pt, rec);
72957476 return rec;
72967477 }
72977478
7298
- void drawEditHandles0(ClickInfo info, int level)
7479
+ void drawEditHandles0(//ClickInfo clickInfo,
7480
+ int level)
72997481 {
73007482 if (level == 0)
73017483 {
....@@ -7304,16 +7486,19 @@
73047486 {
73057487 cVector origin = new cVector();
73067488 //LA.xformPos(origin, toParent, origin);
7307
- Rectangle spot = calcHotSpot(origin, info);
7489
+ if (this.clickInfo == null)
7490
+ this.clickInfo = new ClickInfo();
7491
+
7492
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73087493 Rectangle boundary = new Rectangle();
73097494 boundary.x = spot.x - 30;
73107495 boundary.y = spot.y - 30;
73117496 boundary.width = spot.width + 60;
73127497 boundary.height = spot.height + 60;
7313
- info.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
73147499 int spotw = spot.x + spot.width;
73157500 int spoth = spot.y + spot.height;
7316
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7501
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73177502 // if (CameraPane.Xmin > spot.x)
73187503 // {
73197504 // CameraPane.Xmin = spot.x;
....@@ -7330,11 +7515,6 @@
73307515 // {
73317516 // CameraPane.Ymax = spoth;
73327517 // }
7333
- spot.translate(32, 32);
7334
- spotw = spot.x + spot.width;
7335
- spoth = spot.y + spot.height;
7336
- info.g.setColor(Color.cyan);
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387518 // if (CameraPane.Xmin > spot.x)
73397519 // {
73407520 // CameraPane.Xmin = spot.x;
....@@ -7353,10 +7533,15 @@
73537533 // }
73547534 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73557535 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7356
- 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);
7536
+ spot.translate(32, 0);
7537
+ clickInfo.g.setColor(Color.yellow);
7538
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7539
+
7540
+ spot.translate(32, 64);
7541
+ spotw = spot.x + spot.width;
7542
+ spoth = spot.y + spot.height;
7543
+ clickInfo.g.setColor(Color.cyan);
7544
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73607545 // if (CameraPane.Xmin > spot.x)
73617546 // {
73627547 // CameraPane.Xmin = spot.x;
....@@ -7373,8 +7558,9 @@
73737558 // {
73747559 // CameraPane.Ymax = spoth;
73757560 // }
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);
7561
+ clickInfo.g.setColor(Color.green);
7562
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7563
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73787564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73797565 // if (CameraPane.Xmin > boundary.x)
73807566 // {
....@@ -7396,7 +7582,8 @@
73967582 }
73977583 }
73987584
7399
- boolean doEditClick0(ClickInfo info, int level)
7585
+ boolean doEditClick0(//ClickInfo clickInfo,
7586
+ int level)
74007587 {
74017588 if (level == 0)
74027589 {
....@@ -7405,8 +7592,8 @@
74057592
74067593 boolean retval = false;
74077594
7408
- startX = info.x;
7409
- startY = info.y;
7595
+ startX = clickInfo.x;
7596
+ startY = clickInfo.y;
74107597
74117598 hitSomething = -1;
74127599 cVector origin = new cVector();
....@@ -7416,22 +7603,53 @@
74167603 {
74177604 centerPt = new Point(0, 0);
74187605 }
7419
- calcHotSpot(origin, info, centerPt, spot);
7420
- if (spot.contains(info.x, info.y))
7606
+ calcHotSpot(origin, //info,
7607
+ centerPt, spot);
7608
+ if (spot.contains(clickInfo.x, clickInfo.y))
74217609 {
74227610 hitSomething = hitCenter;
74237611 retval = true;
74247612 }
74257613 spot.translate(32, 0);
7426
- if (spot.contains(info.x, info.y))
7614
+ if (spot.contains(clickInfo.x, clickInfo.y))
74277615 {
74287616 hitSomething = hitRotate;
74297617 retval = true;
74307618 }
74317619 spot.translate(0, 32);
7432
- if (spot.contains(info.x, info.y))
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
7622
+ if (spot.contains(clickInfo.x, clickInfo.y))
74337623 {
74347624 hitSomething = hitScale;
7625
+
7626
+ double scale = 0.005f * clickInfo.camera.Distance();
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7628
+ double sign = 1;
7629
+ if (hScale < 0)
7630
+ {
7631
+ sign = -1;
7632
+ }
7633
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7634
+ if (hScale < 0.01)
7635
+ {
7636
+ //hScale = 0.01;
7637
+ }
7638
+
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7640
+ sign = 1;
7641
+ if (vScale < 0)
7642
+ {
7643
+ sign = -1;
7644
+ }
7645
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7646
+ if (vScale < 0.01)
7647
+ {
7648
+ //vScale = 0.01;
7649
+ }
7650
+
7651
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7652
+
74357653 retval = true;
74367654 }
74377655
....@@ -7441,7 +7659,7 @@
74417659 }
74427660
74437661 //System.out.println("info.modifiers = " + info.modifiers);
7444
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7662
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74457663 //System.out.println("modified = " + modified);
74467664 //new Exception().printStackTrace();
74477665 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7469,7 +7687,8 @@
74697687 return true;
74707688 }
74717689
7472
- void doEditDrag0(ClickInfo info, boolean opposite)
7690
+ void doEditDrag0(//ClickInfo info,
7691
+ boolean opposite)
74737692 {
74747693 if (hitSomething == 0)
74757694 {
....@@ -7483,7 +7702,7 @@
74837702
74847703 //System.out.println("hitSomething = " + hitSomething);
74857704
7486
- double scale = 0.005f * info.camera.Distance();
7705
+ double scale = 0.005f * clickInfo.camera.Distance();
74877706
74887707 cVector xlate = new cVector();
74897708 //cVector xlate2 = new cVector();
....@@ -7517,8 +7736,8 @@
75177736 toParent[3][i] = xlate.get(i);
75187737 LA.matInvert(toParent, fromParent);
75197738 */
7520
- cVector delta = LA.newVector(0, 0, startY - info.y);
7521
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7739
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7740
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75227741
75237742 LA.matCopy(startMat, toParent);
75247743 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7527,7 +7746,7 @@
75277746 } else
75287747 {
75297748 //LA.xformDir(delta, info.camera.fromScreen, delta);
7530
- cVector up = new cVector(info.camera.up);
7749
+ cVector up = new cVector(clickInfo.camera.up);
75317750 cVector away = new cVector();
75327751 //cVector right2 = new cVector();
75337752 //LA.vecCross(up, cVector.Z, right);
....@@ -7544,19 +7763,19 @@
75447763 LA.xformDir(up, ClickInfo.matbuffer, up);
75457764 // if (!CameraPane.LOCALTRANSFORM)
75467765 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7547
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7766
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75487767 // if (!CameraPane.LOCALTRANSFORM)
75497768 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75507769 //LA.vecCross(up, cVector.Z, right2);
75517770
7552
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7771
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75537772
75547773 //System.out.println("DELTA0 = " + delta);
75557774 //System.out.println("AWAY = " + info.camera.away);
75567775 //System.out.println("UP = " + info.camera.up);
75577776 if (away.z > 0)
75587777 {
7559
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7778
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75607779 {
75617780 delta.x = -delta.x;
75627781 } else
....@@ -7571,7 +7790,7 @@
75717790 //System.out.println("DELTA1 = " + delta);
75727791 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75737792 //System.out.println("DELTA2 = " + delta);
7574
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7793
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75757794 LA.matCopy(startMat, toParent);
75767795 //System.out.println("DELTA3 = " + delta);
75777796 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7581,8 +7800,8 @@
75817800 break;
75827801
75837802 case hitRotate: // rotate
7584
- int dx = info.x - centerPt.x;
7585
- int dy = -(info.y - centerPt.y);
7803
+ int dx = clickInfo.x - centerPt.x;
7804
+ int dy = -(clickInfo.y - centerPt.y);
75867805 double angle = (double) Math.atan2(dx, dy);
75877806 angle = -(1.570796 - angle);
75887807
....@@ -7605,7 +7824,7 @@
76057824 }
76067825 /**/
76077826
7608
- switch (info.pane.RenderCamera().viewCode)
7827
+ switch (clickInfo.pane.RenderCamera().viewCode)
76097828 {
76107829 case 1: // '\001'
76117830 LA.matZRotate(toParent, angle);
....@@ -7632,7 +7851,7 @@
76327851 break;
76337852
76347853 case hitScale: // scale
7635
- double hScale = (double) (info.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
76367855 double sign = 1;
76377856 if (hScale < 0)
76387857 {
....@@ -7644,7 +7863,7 @@
76447863 //hScale = 0.01;
76457864 }
76467865
7647
- double vScale = (double) (info.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76487867 sign = 1;
76497868 if (vScale < 0)
76507869 {
....@@ -7655,6 +7874,7 @@
76557874 {
76567875 //vScale = 0.01;
76577876 }
7877
+
76587878 LA.matCopy(startMat, toParent);
76597879 /**/
76607880 for (int i = 0; i < 3; i++)
....@@ -7664,33 +7884,39 @@
76647884 }
76657885 /**/
76667886
7667
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7887
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76687888
76697889 if (totalScale < 0.01)
76707890 {
76717891 totalScale = 0.01;
76727892 }
76737893
7674
- switch (info.pane.RenderCamera().viewCode)
7894
+ switch (clickInfo.pane.RenderCamera().viewCode)
76757895 {
76767896 case 3: // '\001'
76777897 if (modified || opposite)
76787898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
76797902 //LA.matScale(toParent, 1, hScale, vScale);
7680
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
76817904 } // vScale, 1);
76827905 else
76837906 {
76847907 // EXCEPTION!
7685
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
76867909 } // vScale, 1);
76877910 break;
76887911
76897912 case 2: // '\002'
76907913 if (modified || opposite)
76917914 {
7692
- //LA.matScale(toParent, hScale, 1, vScale);
7693
- LA.matScale(toParent, 1, totalScale, 1);
7915
+ if (modified && opposite)
7916
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7917
+ else
7918
+ //LA.matScale(toParent, hScale, 1, vScale);
7919
+ LA.matScale(toParent, 1, totalScale, 1);
76947920 } else
76957921 {
76967922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7700,8 +7926,11 @@
77007926 case 1: // '\003'
77017927 if (modified || opposite)
77027928 {
7703
- //LA.matScale(toParent, hScale, vScale, 1);
7704
- LA.matScale(toParent, 1, 1, totalScale);
7929
+ if (modified && opposite)
7930
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7931
+ else
7932
+ //LA.matScale(toParent, hScale, vScale, 1);
7933
+ LA.matScale(toParent, 1, 1, totalScale);
77057934 } else
77067935 {
77077936 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7738,7 +7967,7 @@
77387967 } // NEW ...
77397968
77407969
7741
- info.pane.repaint();
7970
+ clickInfo.pane.repaint();
77427971 }
77437972
77447973 boolean overflow = false;