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
....@@ -5775,12 +5916,23 @@
57755916 }
57765917 }
57775918
5778
- void EmbedTextures()
5919
+ void EmbedTextures(boolean embed)
57795920 {
57805921 if (blockloop)
57815922 return;
57825923
5783
- CameraPane.EmbedTextures(texture);
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
+ }
57845936
57855937 int nb = Size();
57865938 for (int i = 0; i < nb; i++)
....@@ -5791,7 +5943,7 @@
57915943 continue;
57925944
57935945 blockloop = true;
5794
- child.EmbedTextures();
5946
+ child.EmbedTextures(embed);
57955947 blockloop = false;
57965948 }
57975949 }
....@@ -5882,8 +6034,10 @@
58826034 if (support != null)
58836035 support = support;
58846036
5885
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5886
- 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.
58876041
58886042 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58896043 {
....@@ -5893,8 +6047,9 @@
58936047 // usecalllists &= !(parent instanceof RandomNode);
58946048 // usecalllists = false;
58956049
5896
- if (GetBRep() != null)
5897
- usecalllists = usecalllists;
6050
+ if (display.DrawMode() == display.SHADOW)
6051
+ //GetBRep() != null)
6052
+ usecalllists = !!usecalllists;
58986053 //System.out.println("draw " + this);
58996054 //new Exception().printStackTrace();
59006055
....@@ -5916,7 +6071,7 @@
59166071 if (!(this instanceof Composite))
59176072 touched = false;
59186073 //if (displaylist == -1 && usecalllists)
5919
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6074
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59206075 {
59216076 bRep.displaylist = display.GenList();
59226077 assert(bRep.displaylist != 0);
....@@ -5927,7 +6082,7 @@
59276082
59286083 //System.out.println("\tnew list " + list);
59296084 //gl.glDrawBuffer(gl.GL_NONE);
5930
- if (usecalllists)
6085
+ if (usecalllists && bRep.displaylist > 0)
59316086 {
59326087 // System.err.println("new list " + bRep.displaylist + " for " + this);
59336088 display.NewList(bRep.displaylist);
....@@ -5936,7 +6091,7 @@
59366091 CallList(display, root, selected, blocked);
59376092
59386093 // compiled = true;
5939
- if (usecalllists)
6094
+ if (usecalllists && bRep.displaylist > 0)
59406095 {
59416096 // System.err.println("end list " + bRep.displaylist + " for " + this);
59426097 display.EndList();
....@@ -7287,20 +7442,23 @@
72877442 }
72887443 }
72897444
7290
- 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)
72917449 {
7292
- int hc = info.bounds.x + info.bounds.width / 2;
7293
- int vc = info.bounds.y + info.bounds.height / 2;
7294
- 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;
72957453 if (toscreen == null)
72967454 {
7297
- toscreen = new Camera(info.camera.viewCode).toScreen;
7455
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72987456 }
72997457 cVector vec = in;
73007458 LA.xformPos(in, toscreen, in);
73017459 //System.out.println("Distance = " + info.camera.Distance());
7302
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7303
- 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();
73047462 outPt.x = hc + (int) vec.x;
73057463 outPt.y = vc - (int) vec.y;
73067464 outRec.x = outPt.x - 3;
....@@ -7308,15 +7466,18 @@
73087466 outRec.width = outRec.height = 6;
73097467 }
73107468
7311
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7469
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7470
+ )
73127471 {
73137472 Point pt = new Point(0, 0);
73147473 Rectangle rec = new Rectangle();
7315
- calcHotSpot(in, info, pt, rec);
7474
+ calcHotSpot(in, //clickInfo,
7475
+ pt, rec);
73167476 return rec;
73177477 }
73187478
7319
- void drawEditHandles0(ClickInfo info, int level)
7479
+ void drawEditHandles0(//ClickInfo clickInfo,
7480
+ int level)
73207481 {
73217482 if (level == 0)
73227483 {
....@@ -7325,16 +7486,19 @@
73257486 {
73267487 cVector origin = new cVector();
73277488 //LA.xformPos(origin, toParent, origin);
7328
- Rectangle spot = calcHotSpot(origin, info);
7489
+ if (this.clickInfo == null)
7490
+ this.clickInfo = new ClickInfo();
7491
+
7492
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73297493 Rectangle boundary = new Rectangle();
73307494 boundary.x = spot.x - 30;
73317495 boundary.y = spot.y - 30;
73327496 boundary.width = spot.width + 60;
73337497 boundary.height = spot.height + 60;
7334
- info.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
73357499 int spotw = spot.x + spot.width;
73367500 int spoth = spot.y + spot.height;
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7501
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387502 // if (CameraPane.Xmin > spot.x)
73397503 // {
73407504 // CameraPane.Xmin = spot.x;
....@@ -7351,11 +7515,6 @@
73517515 // {
73527516 // CameraPane.Ymax = spoth;
73537517 // }
7354
- spot.translate(32, 32);
7355
- spotw = spot.x + spot.width;
7356
- spoth = spot.y + spot.height;
7357
- info.g.setColor(Color.cyan);
7358
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73597518 // if (CameraPane.Xmin > spot.x)
73607519 // {
73617520 // CameraPane.Xmin = spot.x;
....@@ -7374,10 +7533,15 @@
73747533 // }
73757534 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73767535 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7377
- spot.translate(0, -32);
7378
- info.g.setColor(Color.yellow);
7379
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7380
- 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);
73817545 // if (CameraPane.Xmin > spot.x)
73827546 // {
73837547 // CameraPane.Xmin = spot.x;
....@@ -7394,8 +7558,9 @@
73947558 // {
73957559 // CameraPane.Ymax = spoth;
73967560 // }
7397
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7398
- (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);
73997564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74007565 // if (CameraPane.Xmin > boundary.x)
74017566 // {
....@@ -7417,7 +7582,8 @@
74177582 }
74187583 }
74197584
7420
- boolean doEditClick0(ClickInfo info, int level)
7585
+ boolean doEditClick0(//ClickInfo clickInfo,
7586
+ int level)
74217587 {
74227588 if (level == 0)
74237589 {
....@@ -7426,8 +7592,8 @@
74267592
74277593 boolean retval = false;
74287594
7429
- startX = info.x;
7430
- startY = info.y;
7595
+ startX = clickInfo.x;
7596
+ startY = clickInfo.y;
74317597
74327598 hitSomething = -1;
74337599 cVector origin = new cVector();
....@@ -7437,22 +7603,53 @@
74377603 {
74387604 centerPt = new Point(0, 0);
74397605 }
7440
- calcHotSpot(origin, info, centerPt, spot);
7441
- if (spot.contains(info.x, info.y))
7606
+ calcHotSpot(origin, //info,
7607
+ centerPt, spot);
7608
+ if (spot.contains(clickInfo.x, clickInfo.y))
74427609 {
74437610 hitSomething = hitCenter;
74447611 retval = true;
74457612 }
74467613 spot.translate(32, 0);
7447
- if (spot.contains(info.x, info.y))
7614
+ if (spot.contains(clickInfo.x, clickInfo.y))
74487615 {
74497616 hitSomething = hitRotate;
74507617 retval = true;
74517618 }
74527619 spot.translate(0, 32);
7453
- 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))
74547623 {
74557624 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
+
74567653 retval = true;
74577654 }
74587655
....@@ -7462,7 +7659,7 @@
74627659 }
74637660
74647661 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7662
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74667663 //System.out.println("modified = " + modified);
74677664 //new Exception().printStackTrace();
74687665 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7687,8 @@
74907687 return true;
74917688 }
74927689
7493
- void doEditDrag0(ClickInfo info, boolean opposite)
7690
+ void doEditDrag0(//ClickInfo info,
7691
+ boolean opposite)
74947692 {
74957693 if (hitSomething == 0)
74967694 {
....@@ -7504,7 +7702,7 @@
75047702
75057703 //System.out.println("hitSomething = " + hitSomething);
75067704
7507
- double scale = 0.005f * info.camera.Distance();
7705
+ double scale = 0.005f * clickInfo.camera.Distance();
75087706
75097707 cVector xlate = new cVector();
75107708 //cVector xlate2 = new cVector();
....@@ -7538,8 +7736,8 @@
75387736 toParent[3][i] = xlate.get(i);
75397737 LA.matInvert(toParent, fromParent);
75407738 */
7541
- cVector delta = LA.newVector(0, 0, startY - info.y);
7542
- 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);
75437741
75447742 LA.matCopy(startMat, toParent);
75457743 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7548,7 +7746,7 @@
75487746 } else
75497747 {
75507748 //LA.xformDir(delta, info.camera.fromScreen, delta);
7551
- cVector up = new cVector(info.camera.up);
7749
+ cVector up = new cVector(clickInfo.camera.up);
75527750 cVector away = new cVector();
75537751 //cVector right2 = new cVector();
75547752 //LA.vecCross(up, cVector.Z, right);
....@@ -7565,19 +7763,19 @@
75657763 LA.xformDir(up, ClickInfo.matbuffer, up);
75667764 // if (!CameraPane.LOCALTRANSFORM)
75677765 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7568
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7766
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75697767 // if (!CameraPane.LOCALTRANSFORM)
75707768 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75717769 //LA.vecCross(up, cVector.Z, right2);
75727770
7573
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7771
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75747772
75757773 //System.out.println("DELTA0 = " + delta);
75767774 //System.out.println("AWAY = " + info.camera.away);
75777775 //System.out.println("UP = " + info.camera.up);
75787776 if (away.z > 0)
75797777 {
7580
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7778
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75817779 {
75827780 delta.x = -delta.x;
75837781 } else
....@@ -7592,7 +7790,7 @@
75927790 //System.out.println("DELTA1 = " + delta);
75937791 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75947792 //System.out.println("DELTA2 = " + delta);
7595
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7793
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75967794 LA.matCopy(startMat, toParent);
75977795 //System.out.println("DELTA3 = " + delta);
75987796 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7602,8 +7800,8 @@
76027800 break;
76037801
76047802 case hitRotate: // rotate
7605
- int dx = info.x - centerPt.x;
7606
- int dy = -(info.y - centerPt.y);
7803
+ int dx = clickInfo.x - centerPt.x;
7804
+ int dy = -(clickInfo.y - centerPt.y);
76077805 double angle = (double) Math.atan2(dx, dy);
76087806 angle = -(1.570796 - angle);
76097807
....@@ -7626,7 +7824,7 @@
76267824 }
76277825 /**/
76287826
7629
- switch (info.pane.RenderCamera().viewCode)
7827
+ switch (clickInfo.pane.RenderCamera().viewCode)
76307828 {
76317829 case 1: // '\001'
76327830 LA.matZRotate(toParent, angle);
....@@ -7653,7 +7851,7 @@
76537851 break;
76547852
76557853 case hitScale: // scale
7656
- double hScale = (double) (info.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
76577855 double sign = 1;
76587856 if (hScale < 0)
76597857 {
....@@ -7665,7 +7863,7 @@
76657863 //hScale = 0.01;
76667864 }
76677865
7668
- double vScale = (double) (info.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76697867 sign = 1;
76707868 if (vScale < 0)
76717869 {
....@@ -7676,6 +7874,7 @@
76767874 {
76777875 //vScale = 0.01;
76787876 }
7877
+
76797878 LA.matCopy(startMat, toParent);
76807879 /**/
76817880 for (int i = 0; i < 3; i++)
....@@ -7685,33 +7884,39 @@
76857884 }
76867885 /**/
76877886
7688
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7887
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76897888
76907889 if (totalScale < 0.01)
76917890 {
76927891 totalScale = 0.01;
76937892 }
76947893
7695
- switch (info.pane.RenderCamera().viewCode)
7894
+ switch (clickInfo.pane.RenderCamera().viewCode)
76967895 {
76977896 case 3: // '\001'
76987897 if (modified || opposite)
76997898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
77007902 //LA.matScale(toParent, 1, hScale, vScale);
7701
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
77027904 } // vScale, 1);
77037905 else
77047906 {
77057907 // EXCEPTION!
7706
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
77077909 } // vScale, 1);
77087910 break;
77097911
77107912 case 2: // '\002'
77117913 if (modified || opposite)
77127914 {
7713
- //LA.matScale(toParent, hScale, 1, vScale);
7714
- 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);
77157920 } else
77167921 {
77177922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7721,8 +7926,11 @@
77217926 case 1: // '\003'
77227927 if (modified || opposite)
77237928 {
7724
- //LA.matScale(toParent, hScale, vScale, 1);
7725
- 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);
77267934 } else
77277935 {
77287936 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7759,7 +7967,7 @@
77597967 } // NEW ...
77607968
77617969
7762
- info.pane.repaint();
7970
+ clickInfo.pane.repaint();
77637971 }
77647972
77657973 boolean overflow = false;