Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
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;
....@@ -614,7 +687,7 @@
614687 {
615688 if (maxcount != 1)
616689 {
617
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
618691 }
619692
620693 toParentMarked = LA.newMatrix();
....@@ -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;
....@@ -2293,11 +2369,6 @@
22932369
22942370 InitOthers();
22952371
2296
- if (this instanceof Camera)
2297
- {
2298
- material.shift = 90;
2299
- }
2300
-
23012372 material.multiply = multiply;
23022373
23032374 if (multiply)
....@@ -2438,6 +2509,11 @@
24382509 else
24392510 {
24402511 //((ObjEditor)editWindow).SetupUI2(null);
2512
+ if (objectUI != null)
2513
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2514
+ else
2515
+ //new Exception().printStackTrace();
2516
+ System.err.println("objectUI is null");
24412517 }
24422518 }
24432519
....@@ -2567,7 +2643,8 @@
25672643 private static final int editSelf = 1;
25682644 private static final int editChild = 2;
25692645
2570
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25712648 {
25722649 if (level == 0)
25732650 {
....@@ -2575,7 +2652,8 @@
25752652 return;
25762653
25772654 Object3D selectee;
2578
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2655
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2656
+ level + 1))
25792657 {
25802658 selectee = (Object3D) e.nextElement();
25812659 }
....@@ -2583,19 +2661,22 @@
25832661 } else
25842662 {
25852663 //super.
2586
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25872666 }
25882667 }
25892668
2590
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25912671 {
25922672 doSomething = 0;
25932673 if (level == 0)
25942674 {
2595
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25962676 }
25972677 if (//super.
2598
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25992680 {
26002681 doSomething = 1;
26012682 return true;
....@@ -2605,7 +2686,7 @@
26052686 }
26062687 }
26072688
2608
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
26092690 {
26102691 if (selection == null)
26112692 {
....@@ -2618,7 +2699,8 @@
26182699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192700 {
26202701 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
26222704 {
26232705 childToDrag = selectee;
26242706 doSomething = 2;
....@@ -2630,13 +2712,15 @@
26302712 return retval;
26312713 }
26322714
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
26342717 {
26352718 switch (doSomething)
26362719 {
26372720 case 1: // '\001'
26382721 //super.
2639
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26402724 break;
26412725
26422726 case 2: // '\002'
....@@ -2649,11 +2733,13 @@
26492733 {
26502734 //sel.hitSomething = childToDrag.hitSomething;
26512735 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26532738 } else
26542739 {
26552740 //super.
2656
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26572743 }
26582744 }
26592745 break;
....@@ -2671,6 +2757,9 @@
26712757 {
26722758 deselectAll();
26732759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26742763 ClickInfo newInfo = new ClickInfo();
26752764 newInfo.flags = info.flags;
26762765 newInfo.bounds = info.bounds;
....@@ -3528,15 +3617,47 @@
35283617
35293618 void ClearMaterials()
35303619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35313625 ClearMaterial();
3532
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35333627 {
3534
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35353629 if (child == null)
35363630 continue;
35373631 child.ClearMaterials();
3538
- release(i);
35393632 }
3633
+
3634
+ blockloop = false;
3635
+ }
3636
+
3637
+ void ClearVersionList()
3638
+ {
3639
+ this.versionlist = null;
3640
+ this.versionindex = -1;
3641
+ this.versiontable = null;
3642
+ }
3643
+
3644
+ void ClearVersions()
3645
+ {
3646
+ if (blockloop)
3647
+ return;
3648
+
3649
+ blockloop = true;
3650
+
3651
+ ClearVersionList();
3652
+ for (int i = 0; i < Size(); i++)
3653
+ {
3654
+ Object3D child = (Object3D) get(i);
3655
+ if (child == null)
3656
+ continue;
3657
+ child.ClearVersions();
3658
+ }
3659
+
3660
+ blockloop = false;
35403661 }
35413662
35423663 void FlipV(boolean flip)
....@@ -5526,6 +5647,11 @@
55265647 if (fullname == null)
55275648 return "";
55285649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55295655 // System.out.println("Fullname = " + fullname);
55305656
55315657 // Does not work on Windows due to C:
....@@ -5538,7 +5664,7 @@
55385664
55395665 if (split.length == 0)
55405666 {
5541
- return "";
5667
+ return fullname.pigment = "";
55425668 }
55435669
55445670 if (split.length <= 2)
....@@ -5546,22 +5672,27 @@
55465672 if (fullname.name.endsWith(":"))
55475673 {
55485674 // Windows
5549
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55505676 }
55515677
5552
- return split[0];
5678
+ return fullname.pigment = split[0];
55535679 }
55545680
55555681 // Windows
55565682 assert(split.length == 4);
55575683
5558
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55595685 }
55605686
55615687 static String GetBump(cTexture fullname)
55625688 {
55635689 if (fullname == null)
55645690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55655696
55665697 // System.out.println("Fullname = " + fullname);
55675698 // Does not work on Windows due to C:
....@@ -5573,12 +5704,12 @@
55735704
55745705 if (split.length == 0)
55755706 {
5576
- return "";
5707
+ return fullname.bump = "";
55775708 }
55785709
55795710 if (split.length == 1)
55805711 {
5581
- return "";
5712
+ return fullname.bump = "";
55825713 }
55835714
55845715 if (split.length == 2)
....@@ -5586,16 +5717,16 @@
55865717 if (fullname.name.endsWith(":"))
55875718 {
55885719 // Windows
5589
- return "";
5720
+ return fullname.bump = "";
55905721 }
55915722
5592
- return split[1];
5723
+ return fullname.bump = split[1];
55935724 }
55945725
55955726 // Windows
55965727 assert(split.length == 4);
55975728
5598
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55995730 }
56005731
56015732 String GetPigmentTexture()
....@@ -5678,6 +5809,9 @@
56785809 texname = "";
56795810
56805811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56815815 Touch();
56825816 }
56835817
....@@ -5751,6 +5885,8 @@
57515885
57525886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57535887
5888
+ GetTextures().bump = null;
5889
+
57545890 Touch();
57555891 }
57565892
....@@ -5771,6 +5907,38 @@
57715907
57725908 blockloop = true;
57735909 child.ResetBumpTexture();
5910
+ blockloop = false;
5911
+ }
5912
+ }
5913
+
5914
+ void EmbedTextures(boolean embed)
5915
+ {
5916
+ if (blockloop)
5917
+ return;
5918
+
5919
+ //if (GetTextures() != null)
5920
+ if (embed)
5921
+ CameraPane.EmbedTextures(GetTextures());
5922
+ else
5923
+ {
5924
+ GetTextures().pigmentdata = null;
5925
+ GetTextures().bumpdata = null;
5926
+ GetTextures().pw = 0;
5927
+ GetTextures().ph = 0;
5928
+ GetTextures().bw = 0;
5929
+ GetTextures().bh = 0;
5930
+ }
5931
+
5932
+ int nb = Size();
5933
+ for (int i = 0; i < nb; i++)
5934
+ {
5935
+ Object3D child = (Object3D) get(i);
5936
+
5937
+ if (child == null)
5938
+ continue;
5939
+
5940
+ blockloop = true;
5941
+ child.EmbedTextures(embed);
57745942 blockloop = false;
57755943 }
57765944 }
....@@ -5861,8 +6029,10 @@
58616029 if (support != null)
58626030 support = support;
58636031
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);
6032
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6033
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6034
+
6035
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58666036
58676037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58686038 {
....@@ -5872,8 +6042,9 @@
58726042 // usecalllists &= !(parent instanceof RandomNode);
58736043 // usecalllists = false;
58746044
5875
- if (GetBRep() != null)
5876
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
58776048 //System.out.println("draw " + this);
58786049 //new Exception().printStackTrace();
58796050
....@@ -5895,7 +6066,7 @@
58956066 if (!(this instanceof Composite))
58966067 touched = false;
58976068 //if (displaylist == -1 && usecalllists)
5898
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58996070 {
59006071 bRep.displaylist = display.GenList();
59016072 assert(bRep.displaylist != 0);
....@@ -5906,7 +6077,7 @@
59066077
59076078 //System.out.println("\tnew list " + list);
59086079 //gl.glDrawBuffer(gl.GL_NONE);
5909
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
59106081 {
59116082 // System.err.println("new list " + bRep.displaylist + " for " + this);
59126083 display.NewList(bRep.displaylist);
....@@ -5915,7 +6086,7 @@
59156086 CallList(display, root, selected, blocked);
59166087
59176088 // compiled = true;
5918
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
59196090 {
59206091 // System.err.println("end list " + bRep.displaylist + " for " + this);
59216092 display.EndList();
....@@ -7266,20 +7437,23 @@
72667437 }
72677438 }
72687439
7269
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7440
+ static ClickInfo clickInfo = new ClickInfo();
7441
+
7442
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7443
+ Point outPt, Rectangle outRec)
72707444 {
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;
7445
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7446
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7447
+ double[][] toscreen = clickInfo.toScreen;
72747448 if (toscreen == null)
72757449 {
7276
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72777451 }
72787452 cVector vec = in;
72797453 LA.xformPos(in, toscreen, in);
72807454 //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();
7455
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7456
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72837457 outPt.x = hc + (int) vec.x;
72847458 outPt.y = vc - (int) vec.y;
72857459 outRec.x = outPt.x - 3;
....@@ -7287,15 +7461,18 @@
72877461 outRec.width = outRec.height = 6;
72887462 }
72897463
7290
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
72917466 {
72927467 Point pt = new Point(0, 0);
72937468 Rectangle rec = new Rectangle();
7294
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
72957471 return rec;
72967472 }
72977473
7298
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
72997476 {
73007477 if (level == 0)
73017478 {
....@@ -7304,16 +7481,19 @@
73047481 {
73057482 cVector origin = new cVector();
73067483 //LA.xformPos(origin, toParent, origin);
7307
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73087488 Rectangle boundary = new Rectangle();
73097489 boundary.x = spot.x - 30;
73107490 boundary.y = spot.y - 30;
73117491 boundary.width = spot.width + 60;
73127492 boundary.height = spot.height + 60;
7313
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
73147494 int spotw = spot.x + spot.width;
73157495 int spoth = spot.y + spot.height;
7316
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73177497 // if (CameraPane.Xmin > spot.x)
73187498 // {
73197499 // CameraPane.Xmin = spot.x;
....@@ -7330,11 +7510,6 @@
73307510 // {
73317511 // CameraPane.Ymax = spoth;
73327512 // }
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);
73387513 // if (CameraPane.Xmin > spot.x)
73397514 // {
73407515 // CameraPane.Xmin = spot.x;
....@@ -7353,10 +7528,15 @@
73537528 // }
73547529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73557530 //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);
7531
+ spot.translate(32, 0);
7532
+ clickInfo.g.setColor(Color.yellow);
7533
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7534
+
7535
+ spot.translate(32, 64);
7536
+ spotw = spot.x + spot.width;
7537
+ spoth = spot.y + spot.height;
7538
+ clickInfo.g.setColor(Color.cyan);
7539
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73607540 // if (CameraPane.Xmin > spot.x)
73617541 // {
73627542 // CameraPane.Xmin = spot.x;
....@@ -7373,8 +7553,9 @@
73737553 // {
73747554 // CameraPane.Ymax = spoth;
73757555 // }
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);
7556
+ clickInfo.g.setColor(Color.green);
7557
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7558
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73787559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73797560 // if (CameraPane.Xmin > boundary.x)
73807561 // {
....@@ -7396,7 +7577,8 @@
73967577 }
73977578 }
73987579
7399
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
74007582 {
74017583 if (level == 0)
74027584 {
....@@ -7405,8 +7587,8 @@
74057587
74067588 boolean retval = false;
74077589
7408
- startX = info.x;
7409
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
74107592
74117593 hitSomething = -1;
74127594 cVector origin = new cVector();
....@@ -7416,22 +7598,53 @@
74167598 {
74177599 centerPt = new Point(0, 0);
74187600 }
7419
- calcHotSpot(origin, info, centerPt, spot);
7420
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
74217604 {
74227605 hitSomething = hitCenter;
74237606 retval = true;
74247607 }
74257608 spot.translate(32, 0);
7426
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
74277610 {
74287611 hitSomething = hitRotate;
74297612 retval = true;
74307613 }
74317614 spot.translate(0, 32);
7432
- if (spot.contains(info.x, info.y))
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
7617
+ if (spot.contains(clickInfo.x, clickInfo.y))
74337618 {
74347619 hitSomething = hitScale;
7620
+
7621
+ double scale = 0.005f * clickInfo.camera.Distance();
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7623
+ double sign = 1;
7624
+ if (hScale < 0)
7625
+ {
7626
+ sign = -1;
7627
+ }
7628
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7629
+ if (hScale < 0.01)
7630
+ {
7631
+ //hScale = 0.01;
7632
+ }
7633
+
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7635
+ sign = 1;
7636
+ if (vScale < 0)
7637
+ {
7638
+ sign = -1;
7639
+ }
7640
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7641
+ if (vScale < 0.01)
7642
+ {
7643
+ //vScale = 0.01;
7644
+ }
7645
+
7646
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7647
+
74357648 retval = true;
74367649 }
74377650
....@@ -7441,7 +7654,7 @@
74417654 }
74427655
74437656 //System.out.println("info.modifiers = " + info.modifiers);
7444
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74457658 //System.out.println("modified = " + modified);
74467659 //new Exception().printStackTrace();
74477660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7469,7 +7682,8 @@
74697682 return true;
74707683 }
74717684
7472
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
74737687 {
74747688 if (hitSomething == 0)
74757689 {
....@@ -7483,7 +7697,7 @@
74837697
74847698 //System.out.println("hitSomething = " + hitSomething);
74857699
7486
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
74877701
74887702 cVector xlate = new cVector();
74897703 //cVector xlate2 = new cVector();
....@@ -7497,7 +7711,9 @@
74977711
74987712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74997713
7500
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
75017717 {
75027718 //assert(false);
75037719 /*
....@@ -7517,8 +7733,8 @@
75177733 toParent[3][i] = xlate.get(i);
75187734 LA.matInvert(toParent, fromParent);
75197735 */
7520
- cVector delta = LA.newVector(0, 0, startY - info.y);
7521
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7736
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7737
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75227738
75237739 LA.matCopy(startMat, toParent);
75247740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7527,7 +7743,7 @@
75277743 } else
75287744 {
75297745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7530
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
75317747 cVector away = new cVector();
75327748 //cVector right2 = new cVector();
75337749 //LA.vecCross(up, cVector.Z, right);
....@@ -7544,19 +7760,19 @@
75447760 LA.xformDir(up, ClickInfo.matbuffer, up);
75457761 // if (!CameraPane.LOCALTRANSFORM)
75467762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7547
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75487764 // if (!CameraPane.LOCALTRANSFORM)
75497765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75507766 //LA.vecCross(up, cVector.Z, right2);
75517767
7552
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75537769
75547770 //System.out.println("DELTA0 = " + delta);
75557771 //System.out.println("AWAY = " + info.camera.away);
75567772 //System.out.println("UP = " + info.camera.up);
75577773 if (away.z > 0)
75587774 {
7559
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75607776 {
75617777 delta.x = -delta.x;
75627778 } else
....@@ -7571,7 +7787,7 @@
75717787 //System.out.println("DELTA1 = " + delta);
75727788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75737789 //System.out.println("DELTA2 = " + delta);
7574
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75757791 LA.matCopy(startMat, toParent);
75767792 //System.out.println("DELTA3 = " + delta);
75777793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7581,8 +7797,8 @@
75817797 break;
75827798
75837799 case hitRotate: // rotate
7584
- int dx = info.x - centerPt.x;
7585
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
75867802 double angle = (double) Math.atan2(dx, dy);
75877803 angle = -(1.570796 - angle);
75887804
....@@ -7591,7 +7807,7 @@
75917807
75927808 if (modified)
75937809 {
7594
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
75957811 angle /= (Math.PI / 4);
75967812 angle = Math.floor(angle + 0.5);
75977813 angle *= (Math.PI / 4);
....@@ -7605,7 +7821,7 @@
76057821 }
76067822 /**/
76077823
7608
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
76097825 {
76107826 case 1: // '\001'
76117827 LA.matZRotate(toParent, angle);
....@@ -7632,7 +7848,7 @@
76327848 break;
76337849
76347850 case hitScale: // scale
7635
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
76367852 double sign = 1;
76377853 if (hScale < 0)
76387854 {
....@@ -7644,7 +7860,7 @@
76447860 //hScale = 0.01;
76457861 }
76467862
7647
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76487864 sign = 1;
76497865 if (vScale < 0)
76507866 {
....@@ -7655,6 +7871,7 @@
76557871 {
76567872 //vScale = 0.01;
76577873 }
7874
+
76587875 LA.matCopy(startMat, toParent);
76597876 /**/
76607877 for (int i = 0; i < 3; i++)
....@@ -7664,33 +7881,39 @@
76647881 }
76657882 /**/
76667883
7667
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76687885
76697886 if (totalScale < 0.01)
76707887 {
76717888 totalScale = 0.01;
76727889 }
76737890
7674
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
76757892 {
76767893 case 3: // '\001'
76777894 if (modified || opposite)
76787895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
76797899 //LA.matScale(toParent, 1, hScale, vScale);
7680
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
76817901 } // vScale, 1);
76827902 else
76837903 {
76847904 // EXCEPTION!
7685
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
76867906 } // vScale, 1);
76877907 break;
76887908
76897909 case 2: // '\002'
76907910 if (modified || opposite)
76917911 {
7692
- //LA.matScale(toParent, hScale, 1, vScale);
7693
- LA.matScale(toParent, 1, totalScale, 1);
7912
+ if (modified) // && opposite)
7913
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7914
+ else
7915
+ //LA.matScale(toParent, hScale, 1, vScale);
7916
+ LA.matScale(toParent, 1, totalScale, 1);
76947917 } else
76957918 {
76967919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7700,8 +7923,11 @@
77007923 case 1: // '\003'
77017924 if (modified || opposite)
77027925 {
7703
- //LA.matScale(toParent, hScale, vScale, 1);
7704
- LA.matScale(toParent, 1, 1, totalScale);
7926
+ if (modified) // && opposite)
7927
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7928
+ else
7929
+ //LA.matScale(toParent, hScale, vScale, 1);
7930
+ LA.matScale(toParent, 1, 1, totalScale);
77057931 } else
77067932 {
77077933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7738,7 +7964,7 @@
77387964 } // NEW ...
77397965
77407966
7741
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
77427968 }
77437969
77447970 boolean overflow = false;