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[] = new byte[100][];
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;
....@@ -426,6 +499,7 @@
426499 }
427500
428501 boolean live = false;
502
+ transient boolean keepdontselect;
429503 boolean dontselect = false;
430504 boolean hide = false;
431505 boolean link2master = false; // performs reset support/master at each frame
....@@ -1010,6 +1084,9 @@
10101084
10111085 if (material == null || material.multiply)
10121086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10131090
10141091 // Transparent objects are dynamic because we have to sort the triangles.
10151092 return material.opacity > 0.99;
....@@ -2437,6 +2514,11 @@
24372514 else
24382515 {
24392516 //((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");
24402522 }
24412523 }
24422524
....@@ -2566,7 +2648,8 @@
25662648 private static final int editSelf = 1;
25672649 private static final int editChild = 2;
25682650
2569
- void drawEditHandles(ClickInfo info, int level)
2651
+ void drawEditHandles(//ClickInfo info,
2652
+ int level)
25702653 {
25712654 if (level == 0)
25722655 {
....@@ -2574,7 +2657,8 @@
25742657 return;
25752658
25762659 Object3D selectee;
2577
- 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))
25782662 {
25792663 selectee = (Object3D) e.nextElement();
25802664 }
....@@ -2582,19 +2666,22 @@
25822666 } else
25832667 {
25842668 //super.
2585
- drawEditHandles0(info, level + 1);
2669
+ drawEditHandles0(//info,
2670
+ level + 1);
25862671 }
25872672 }
25882673
2589
- boolean doEditClick(ClickInfo info, int level)
2674
+ boolean doEditClick(//ClickInfo info,
2675
+ int level)
25902676 {
25912677 doSomething = 0;
25922678 if (level == 0)
25932679 {
2594
- return doParentClick(info);
2680
+ return doParentClick(); //info);
25952681 }
25962682 if (//super.
2597
- doEditClick0(info, level))
2683
+ doEditClick0(//info,
2684
+ level))
25982685 {
25992686 doSomething = 1;
26002687 return true;
....@@ -2604,7 +2691,7 @@
26042691 }
26052692 }
26062693
2607
- boolean doParentClick(ClickInfo info)
2694
+ boolean doParentClick() //ClickInfo info)
26082695 {
26092696 if (selection == null)
26102697 {
....@@ -2617,7 +2704,8 @@
26172704 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26182705 {
26192706 Object3D selectee = (Object3D) e.nextElement();
2620
- if (selectee.doEditClick(info, 1))
2707
+ if (selectee.doEditClick(//info,
2708
+ 1))
26212709 {
26222710 childToDrag = selectee;
26232711 doSomething = 2;
....@@ -2629,13 +2717,15 @@
26292717 return retval;
26302718 }
26312719
2632
- void doEditDrag(ClickInfo info, boolean opposite)
2720
+ void doEditDrag(//ClickInfo clickInfo,
2721
+ boolean opposite)
26332722 {
26342723 switch (doSomething)
26352724 {
26362725 case 1: // '\001'
26372726 //super.
2638
- doEditDrag0(info, opposite);
2727
+ doEditDrag0(//clickInfo,
2728
+ opposite);
26392729 break;
26402730
26412731 case 2: // '\002'
....@@ -2648,11 +2738,13 @@
26482738 {
26492739 //sel.hitSomething = childToDrag.hitSomething;
26502740 //childToDrag.doEditDrag(info);
2651
- sel.doEditDrag(info, opposite);
2741
+ sel.doEditDrag(//clickInfo,
2742
+ opposite);
26522743 } else
26532744 {
26542745 //super.
2655
- doEditDrag0(info, opposite);
2746
+ doEditDrag0(//clickInfo,
2747
+ opposite);
26562748 }
26572749 }
26582750 break;
....@@ -2670,6 +2762,9 @@
26702762 {
26712763 deselectAll();
26722764 }
2765
+
2766
+ new Exception().printStackTrace();
2767
+
26732768 ClickInfo newInfo = new ClickInfo();
26742769 newInfo.flags = info.flags;
26752770 newInfo.bounds = info.bounds;
....@@ -3527,15 +3622,47 @@
35273622
35283623 void ClearMaterials()
35293624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35303630 ClearMaterial();
3531
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35323632 {
3533
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35343634 if (child == null)
35353635 continue;
35363636 child.ClearMaterials();
3537
- release(i);
35383637 }
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;
35393666 }
35403667
35413668 void FlipV(boolean flip)
....@@ -5420,6 +5547,51 @@
54205547 blockloop = false;
54215548 }
54225549
5550
+ void ResetSelectable()
5551
+ {
5552
+ if (blockloop)
5553
+ return;
5554
+
5555
+ blockloop = true;
5556
+
5557
+ keepdontselect = dontselect;
5558
+ dontselect = true;
5559
+
5560
+ Object3D child;
5561
+ int nb = Size();
5562
+ for (int i = 0; i < nb; i++)
5563
+ {
5564
+ child = (Object3D) get(i);
5565
+ if (child == null)
5566
+ continue;
5567
+ child.ResetSelectable();
5568
+ }
5569
+
5570
+ blockloop = false;
5571
+ }
5572
+
5573
+ void RestoreSelectable()
5574
+ {
5575
+ if (blockloop)
5576
+ return;
5577
+
5578
+ blockloop = true;
5579
+
5580
+ dontselect = keepdontselect;
5581
+
5582
+ Object3D child;
5583
+ int nb = Size();
5584
+ for (int i = 0; i < nb; i++)
5585
+ {
5586
+ child = (Object3D) get(i);
5587
+ if (child == null)
5588
+ continue;
5589
+ child.RestoreSelectable();
5590
+ }
5591
+
5592
+ blockloop = false;
5593
+ }
5594
+
54235595 boolean IsSelected()
54245596 {
54255597 if (parent == null)
....@@ -5480,6 +5652,11 @@
54805652 if (fullname == null)
54815653 return "";
54825654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
54835660 // System.out.println("Fullname = " + fullname);
54845661
54855662 // Does not work on Windows due to C:
....@@ -5492,7 +5669,7 @@
54925669
54935670 if (split.length == 0)
54945671 {
5495
- return "";
5672
+ return fullname.pigment = "";
54965673 }
54975674
54985675 if (split.length <= 2)
....@@ -5500,22 +5677,27 @@
55005677 if (fullname.name.endsWith(":"))
55015678 {
55025679 // Windows
5503
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55045681 }
55055682
5506
- return split[0];
5683
+ return fullname.pigment = split[0];
55075684 }
55085685
55095686 // Windows
55105687 assert(split.length == 4);
55115688
5512
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
55135690 }
55145691
55155692 static String GetBump(cTexture fullname)
55165693 {
55175694 if (fullname == null)
55185695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
55195701
55205702 // System.out.println("Fullname = " + fullname);
55215703 // Does not work on Windows due to C:
....@@ -5527,12 +5709,12 @@
55275709
55285710 if (split.length == 0)
55295711 {
5530
- return "";
5712
+ return fullname.bump = "";
55315713 }
55325714
55335715 if (split.length == 1)
55345716 {
5535
- return "";
5717
+ return fullname.bump = "";
55365718 }
55375719
55385720 if (split.length == 2)
....@@ -5540,16 +5722,16 @@
55405722 if (fullname.name.endsWith(":"))
55415723 {
55425724 // Windows
5543
- return "";
5725
+ return fullname.bump = "";
55445726 }
55455727
5546
- return split[1];
5728
+ return fullname.bump = split[1];
55475729 }
55485730
55495731 // Windows
55505732 assert(split.length == 4);
55515733
5552
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
55535735 }
55545736
55555737 String GetPigmentTexture()
....@@ -5632,6 +5814,9 @@
56325814 texname = "";
56335815
56345816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
56355820 Touch();
56365821 }
56375822
....@@ -5705,6 +5890,8 @@
57055890
57065891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57075892
5893
+ GetTextures().bump = null;
5894
+
57085895 Touch();
57095896 }
57105897
....@@ -5725,6 +5912,38 @@
57255912
57265913 blockloop = true;
57275914 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);
57285947 blockloop = false;
57295948 }
57305949 }
....@@ -5815,8 +6034,10 @@
58156034 if (support != null)
58166035 support = support;
58176036
5818
- //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);
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.
58206041
58216042 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58226043 {
....@@ -5826,8 +6047,9 @@
58266047 // usecalllists &= !(parent instanceof RandomNode);
58276048 // usecalllists = false;
58286049
5829
- if (GetBRep() != null)
5830
- usecalllists = usecalllists;
6050
+ if (display.DrawMode() == display.SHADOW)
6051
+ //GetBRep() != null)
6052
+ usecalllists = !!usecalllists;
58316053 //System.out.println("draw " + this);
58326054 //new Exception().printStackTrace();
58336055
....@@ -5849,7 +6071,7 @@
58496071 if (!(this instanceof Composite))
58506072 touched = false;
58516073 //if (displaylist == -1 && usecalllists)
5852
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6074
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58536075 {
58546076 bRep.displaylist = display.GenList();
58556077 assert(bRep.displaylist != 0);
....@@ -5860,7 +6082,7 @@
58606082
58616083 //System.out.println("\tnew list " + list);
58626084 //gl.glDrawBuffer(gl.GL_NONE);
5863
- if (usecalllists)
6085
+ if (usecalllists && bRep.displaylist > 0)
58646086 {
58656087 // System.err.println("new list " + bRep.displaylist + " for " + this);
58666088 display.NewList(bRep.displaylist);
....@@ -5869,7 +6091,7 @@
58696091 CallList(display, root, selected, blocked);
58706092
58716093 // compiled = true;
5872
- if (usecalllists)
6094
+ if (usecalllists && bRep.displaylist > 0)
58736095 {
58746096 // System.err.println("end list " + bRep.displaylist + " for " + this);
58756097 display.EndList();
....@@ -7220,20 +7442,23 @@
72207442 }
72217443 }
72227444
7223
- 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)
72247449 {
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;
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;
72287453 if (toscreen == null)
72297454 {
7230
- toscreen = new Camera(info.camera.viewCode).toScreen;
7455
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72317456 }
72327457 cVector vec = in;
72337458 LA.xformPos(in, toscreen, in);
72347459 //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();
7460
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7461
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72377462 outPt.x = hc + (int) vec.x;
72387463 outPt.y = vc - (int) vec.y;
72397464 outRec.x = outPt.x - 3;
....@@ -7241,15 +7466,18 @@
72417466 outRec.width = outRec.height = 6;
72427467 }
72437468
7244
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7469
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7470
+ )
72457471 {
72467472 Point pt = new Point(0, 0);
72477473 Rectangle rec = new Rectangle();
7248
- calcHotSpot(in, info, pt, rec);
7474
+ calcHotSpot(in, //clickInfo,
7475
+ pt, rec);
72497476 return rec;
72507477 }
72517478
7252
- void drawEditHandles0(ClickInfo info, int level)
7479
+ void drawEditHandles0(//ClickInfo clickInfo,
7480
+ int level)
72537481 {
72547482 if (level == 0)
72557483 {
....@@ -7258,16 +7486,19 @@
72587486 {
72597487 cVector origin = new cVector();
72607488 //LA.xformPos(origin, toParent, origin);
7261
- Rectangle spot = calcHotSpot(origin, info);
7489
+ if (this.clickInfo == null)
7490
+ this.clickInfo = new ClickInfo();
7491
+
7492
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72627493 Rectangle boundary = new Rectangle();
72637494 boundary.x = spot.x - 30;
72647495 boundary.y = spot.y - 30;
72657496 boundary.width = spot.width + 60;
72667497 boundary.height = spot.height + 60;
7267
- info.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
72687499 int spotw = spot.x + spot.width;
72697500 int spoth = spot.y + spot.height;
7270
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7501
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72717502 // if (CameraPane.Xmin > spot.x)
72727503 // {
72737504 // CameraPane.Xmin = spot.x;
....@@ -7284,11 +7515,6 @@
72847515 // {
72857516 // CameraPane.Ymax = spoth;
72867517 // }
7287
- spot.translate(32, 32);
7288
- spotw = spot.x + spot.width;
7289
- spoth = spot.y + spot.height;
7290
- info.g.setColor(Color.cyan);
7291
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72927518 // if (CameraPane.Xmin > spot.x)
72937519 // {
72947520 // CameraPane.Xmin = spot.x;
....@@ -7307,10 +7533,15 @@
73077533 // }
73087534 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73097535 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7310
- 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);
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);
73147545 // if (CameraPane.Xmin > spot.x)
73157546 // {
73167547 // CameraPane.Xmin = spot.x;
....@@ -7327,8 +7558,9 @@
73277558 // {
73287559 // CameraPane.Ymax = spoth;
73297560 // }
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);
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);
73327564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73337565 // if (CameraPane.Xmin > boundary.x)
73347566 // {
....@@ -7350,7 +7582,8 @@
73507582 }
73517583 }
73527584
7353
- boolean doEditClick0(ClickInfo info, int level)
7585
+ boolean doEditClick0(//ClickInfo clickInfo,
7586
+ int level)
73547587 {
73557588 if (level == 0)
73567589 {
....@@ -7359,8 +7592,8 @@
73597592
73607593 boolean retval = false;
73617594
7362
- startX = info.x;
7363
- startY = info.y;
7595
+ startX = clickInfo.x;
7596
+ startY = clickInfo.y;
73647597
73657598 hitSomething = -1;
73667599 cVector origin = new cVector();
....@@ -7370,22 +7603,53 @@
73707603 {
73717604 centerPt = new Point(0, 0);
73727605 }
7373
- calcHotSpot(origin, info, centerPt, spot);
7374
- if (spot.contains(info.x, info.y))
7606
+ calcHotSpot(origin, //info,
7607
+ centerPt, spot);
7608
+ if (spot.contains(clickInfo.x, clickInfo.y))
73757609 {
73767610 hitSomething = hitCenter;
73777611 retval = true;
73787612 }
73797613 spot.translate(32, 0);
7380
- if (spot.contains(info.x, info.y))
7614
+ if (spot.contains(clickInfo.x, clickInfo.y))
73817615 {
73827616 hitSomething = hitRotate;
73837617 retval = true;
73847618 }
73857619 spot.translate(0, 32);
7386
- 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))
73877623 {
73887624 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
+
73897653 retval = true;
73907654 }
73917655
....@@ -7395,7 +7659,7 @@
73957659 }
73967660
73977661 //System.out.println("info.modifiers = " + info.modifiers);
7398
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7662
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73997663 //System.out.println("modified = " + modified);
74007664 //new Exception().printStackTrace();
74017665 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7423,7 +7687,8 @@
74237687 return true;
74247688 }
74257689
7426
- void doEditDrag0(ClickInfo info, boolean opposite)
7690
+ void doEditDrag0(//ClickInfo info,
7691
+ boolean opposite)
74277692 {
74287693 if (hitSomething == 0)
74297694 {
....@@ -7437,7 +7702,7 @@
74377702
74387703 //System.out.println("hitSomething = " + hitSomething);
74397704
7440
- double scale = 0.005f * info.camera.Distance();
7705
+ double scale = 0.005f * clickInfo.camera.Distance();
74417706
74427707 cVector xlate = new cVector();
74437708 //cVector xlate2 = new cVector();
....@@ -7471,8 +7736,8 @@
74717736 toParent[3][i] = xlate.get(i);
74727737 LA.matInvert(toParent, fromParent);
74737738 */
7474
- cVector delta = LA.newVector(0, 0, startY - info.y);
7475
- 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);
74767741
74777742 LA.matCopy(startMat, toParent);
74787743 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7481,7 +7746,7 @@
74817746 } else
74827747 {
74837748 //LA.xformDir(delta, info.camera.fromScreen, delta);
7484
- cVector up = new cVector(info.camera.up);
7749
+ cVector up = new cVector(clickInfo.camera.up);
74857750 cVector away = new cVector();
74867751 //cVector right2 = new cVector();
74877752 //LA.vecCross(up, cVector.Z, right);
....@@ -7498,19 +7763,19 @@
74987763 LA.xformDir(up, ClickInfo.matbuffer, up);
74997764 // if (!CameraPane.LOCALTRANSFORM)
75007765 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7501
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7766
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75027767 // if (!CameraPane.LOCALTRANSFORM)
75037768 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75047769 //LA.vecCross(up, cVector.Z, right2);
75057770
7506
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7771
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75077772
75087773 //System.out.println("DELTA0 = " + delta);
75097774 //System.out.println("AWAY = " + info.camera.away);
75107775 //System.out.println("UP = " + info.camera.up);
75117776 if (away.z > 0)
75127777 {
7513
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7778
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75147779 {
75157780 delta.x = -delta.x;
75167781 } else
....@@ -7525,7 +7790,7 @@
75257790 //System.out.println("DELTA1 = " + delta);
75267791 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75277792 //System.out.println("DELTA2 = " + delta);
7528
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7793
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75297794 LA.matCopy(startMat, toParent);
75307795 //System.out.println("DELTA3 = " + delta);
75317796 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7535,8 +7800,8 @@
75357800 break;
75367801
75377802 case hitRotate: // rotate
7538
- int dx = info.x - centerPt.x;
7539
- int dy = -(info.y - centerPt.y);
7803
+ int dx = clickInfo.x - centerPt.x;
7804
+ int dy = -(clickInfo.y - centerPt.y);
75407805 double angle = (double) Math.atan2(dx, dy);
75417806 angle = -(1.570796 - angle);
75427807
....@@ -7559,7 +7824,7 @@
75597824 }
75607825 /**/
75617826
7562
- switch (info.pane.RenderCamera().viewCode)
7827
+ switch (clickInfo.pane.RenderCamera().viewCode)
75637828 {
75647829 case 1: // '\001'
75657830 LA.matZRotate(toParent, angle);
....@@ -7586,7 +7851,7 @@
75867851 break;
75877852
75887853 case hitScale: // scale
7589
- double hScale = (double) (info.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75907855 double sign = 1;
75917856 if (hScale < 0)
75927857 {
....@@ -7598,7 +7863,7 @@
75987863 //hScale = 0.01;
75997864 }
76007865
7601
- double vScale = (double) (info.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76027867 sign = 1;
76037868 if (vScale < 0)
76047869 {
....@@ -7609,6 +7874,7 @@
76097874 {
76107875 //vScale = 0.01;
76117876 }
7877
+
76127878 LA.matCopy(startMat, toParent);
76137879 /**/
76147880 for (int i = 0; i < 3; i++)
....@@ -7618,33 +7884,39 @@
76187884 }
76197885 /**/
76207886
7621
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7887
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76227888
76237889 if (totalScale < 0.01)
76247890 {
76257891 totalScale = 0.01;
76267892 }
76277893
7628
- switch (info.pane.RenderCamera().viewCode)
7894
+ switch (clickInfo.pane.RenderCamera().viewCode)
76297895 {
76307896 case 3: // '\001'
76317897 if (modified || opposite)
76327898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
76337902 //LA.matScale(toParent, 1, hScale, vScale);
7634
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
76357904 } // vScale, 1);
76367905 else
76377906 {
76387907 // EXCEPTION!
7639
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
76407909 } // vScale, 1);
76417910 break;
76427911
76437912 case 2: // '\002'
76447913 if (modified || opposite)
76457914 {
7646
- //LA.matScale(toParent, hScale, 1, vScale);
7647
- 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);
76487920 } else
76497921 {
76507922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7654,8 +7926,11 @@
76547926 case 1: // '\003'
76557927 if (modified || opposite)
76567928 {
7657
- //LA.matScale(toParent, hScale, vScale, 1);
7658
- 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);
76597934 } else
76607935 {
76617936 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7692,7 +7967,7 @@
76927967 } // NEW ...
76937968
76947969
7695
- info.pane.repaint();
7970
+ clickInfo.pane.repaint();
76967971 }
76977972
76987973 boolean overflow = false;