Normand Briere
2019-08-19 22e8ab6479334206f97b0093f6c5ffd14610cce3
Object3D.java
....@@ -22,12 +22,21 @@
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.
2829 mocap.reader.BVHReader.BVHResult savebvh;
2930 Object3D saveskeleton;
3031 //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
3140
3241 ScriptNode scriptnode;
3342
....@@ -215,6 +224,9 @@
215224 // o.transientrep = this.bRep.support;
216225 // o.bRep.support = null;
217226 // }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
218230
219231 if (this.support != null)
220232 {
....@@ -235,6 +247,73 @@
235247 // this.bRep.support = null;
236248 // this.support = null;
237249 // 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;
238317 }
239318
240319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -268,6 +347,11 @@
268347 {
269348 this.support.bRep = o.transientrep;
270349 }
350
+
351
+ this.selection = o.selection;
352
+
353
+ this.versionlist = o.versionlist;
354
+ this.versionindex = o.versionindex;
271355 // July 2019 if (this.bRep != null)
272356 // this.bRep.support = o.transientrep;
273357 // this.support = o.support;
....@@ -415,6 +499,7 @@
415499 }
416500
417501 boolean live = false;
502
+ transient boolean keepdontselect;
418503 boolean dontselect = false;
419504 boolean hide = false;
420505 boolean link2master = false; // performs reset support/master at each frame
....@@ -999,6 +1084,9 @@
9991084
10001085 if (material == null || material.multiply)
10011086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10021090
10031091 // Transparent objects are dynamic because we have to sort the triangles.
10041092 return material.opacity > 0.99;
....@@ -2426,6 +2514,11 @@
24262514 else
24272515 {
24282516 //((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");
24292522 }
24302523 }
24312524
....@@ -2555,7 +2648,8 @@
25552648 private static final int editSelf = 1;
25562649 private static final int editChild = 2;
25572650
2558
- void drawEditHandles(ClickInfo info, int level)
2651
+ void drawEditHandles(//ClickInfo info,
2652
+ int level)
25592653 {
25602654 if (level == 0)
25612655 {
....@@ -2563,7 +2657,8 @@
25632657 return;
25642658
25652659 Object3D selectee;
2566
- 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))
25672662 {
25682663 selectee = (Object3D) e.nextElement();
25692664 }
....@@ -2571,19 +2666,22 @@
25712666 } else
25722667 {
25732668 //super.
2574
- drawEditHandles0(info, level + 1);
2669
+ drawEditHandles0(//info,
2670
+ level + 1);
25752671 }
25762672 }
25772673
2578
- boolean doEditClick(ClickInfo info, int level)
2674
+ boolean doEditClick(//ClickInfo info,
2675
+ int level)
25792676 {
25802677 doSomething = 0;
25812678 if (level == 0)
25822679 {
2583
- return doParentClick(info);
2680
+ return doParentClick(); //info);
25842681 }
25852682 if (//super.
2586
- doEditClick0(info, level))
2683
+ doEditClick0(//info,
2684
+ level))
25872685 {
25882686 doSomething = 1;
25892687 return true;
....@@ -2593,7 +2691,7 @@
25932691 }
25942692 }
25952693
2596
- boolean doParentClick(ClickInfo info)
2694
+ boolean doParentClick() //ClickInfo info)
25972695 {
25982696 if (selection == null)
25992697 {
....@@ -2606,7 +2704,8 @@
26062704 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26072705 {
26082706 Object3D selectee = (Object3D) e.nextElement();
2609
- if (selectee.doEditClick(info, 1))
2707
+ if (selectee.doEditClick(//info,
2708
+ 1))
26102709 {
26112710 childToDrag = selectee;
26122711 doSomething = 2;
....@@ -2618,13 +2717,15 @@
26182717 return retval;
26192718 }
26202719
2621
- void doEditDrag(ClickInfo info, boolean opposite)
2720
+ void doEditDrag(//ClickInfo clickInfo,
2721
+ boolean opposite)
26222722 {
26232723 switch (doSomething)
26242724 {
26252725 case 1: // '\001'
26262726 //super.
2627
- doEditDrag0(info, opposite);
2727
+ doEditDrag0(//clickInfo,
2728
+ opposite);
26282729 break;
26292730
26302731 case 2: // '\002'
....@@ -2637,11 +2738,13 @@
26372738 {
26382739 //sel.hitSomething = childToDrag.hitSomething;
26392740 //childToDrag.doEditDrag(info);
2640
- sel.doEditDrag(info, opposite);
2741
+ sel.doEditDrag(//clickInfo,
2742
+ opposite);
26412743 } else
26422744 {
26432745 //super.
2644
- doEditDrag0(info, opposite);
2746
+ doEditDrag0(//clickInfo,
2747
+ opposite);
26452748 }
26462749 }
26472750 break;
....@@ -2659,6 +2762,9 @@
26592762 {
26602763 deselectAll();
26612764 }
2765
+
2766
+ new Exception().printStackTrace();
2767
+
26622768 ClickInfo newInfo = new ClickInfo();
26632769 newInfo.flags = info.flags;
26642770 newInfo.bounds = info.bounds;
....@@ -3106,7 +3212,7 @@
31063212 {
31073213 if (bRep != null)
31083214 {
3109
- bRep.GenerateNormalsMINE();
3215
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31103216 Touch();
31113217 }
31123218 }
....@@ -5409,6 +5515,51 @@
54095515 blockloop = false;
54105516 }
54115517
5518
+ void ResetSelectable()
5519
+ {
5520
+ if (blockloop)
5521
+ return;
5522
+
5523
+ blockloop = true;
5524
+
5525
+ keepdontselect = dontselect;
5526
+ dontselect = true;
5527
+
5528
+ Object3D child;
5529
+ int nb = Size();
5530
+ for (int i = 0; i < nb; i++)
5531
+ {
5532
+ child = (Object3D) get(i);
5533
+ if (child == null)
5534
+ continue;
5535
+ child.ResetSelectable();
5536
+ }
5537
+
5538
+ blockloop = false;
5539
+ }
5540
+
5541
+ void RestoreSelectable()
5542
+ {
5543
+ if (blockloop)
5544
+ return;
5545
+
5546
+ blockloop = true;
5547
+
5548
+ dontselect = keepdontselect;
5549
+
5550
+ Object3D child;
5551
+ int nb = Size();
5552
+ for (int i = 0; i < nb; i++)
5553
+ {
5554
+ child = (Object3D) get(i);
5555
+ if (child == null)
5556
+ continue;
5557
+ child.RestoreSelectable();
5558
+ }
5559
+
5560
+ blockloop = false;
5561
+ }
5562
+
54125563 boolean IsSelected()
54135564 {
54145565 if (parent == null)
....@@ -5469,6 +5620,11 @@
54695620 if (fullname == null)
54705621 return "";
54715622
5623
+ if (fullname.pigment != null)
5624
+ {
5625
+ return fullname.pigment;
5626
+ }
5627
+
54725628 // System.out.println("Fullname = " + fullname);
54735629
54745630 // Does not work on Windows due to C:
....@@ -5481,7 +5637,7 @@
54815637
54825638 if (split.length == 0)
54835639 {
5484
- return "";
5640
+ return fullname.pigment = "";
54855641 }
54865642
54875643 if (split.length <= 2)
....@@ -5489,22 +5645,27 @@
54895645 if (fullname.name.endsWith(":"))
54905646 {
54915647 // Windows
5492
- return fullname.name.substring(0, fullname.name.length()-1);
5648
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54935649 }
54945650
5495
- return split[0];
5651
+ return fullname.pigment = split[0];
54965652 }
54975653
54985654 // Windows
54995655 assert(split.length == 4);
55005656
5501
- return split[0] + ":" + split[1];
5657
+ return fullname.pigment = split[0] + ":" + split[1];
55025658 }
55035659
55045660 static String GetBump(cTexture fullname)
55055661 {
55065662 if (fullname == null)
55075663 return "";
5664
+
5665
+ if (fullname.bump != null)
5666
+ {
5667
+ return fullname.bump;
5668
+ }
55085669
55095670 // System.out.println("Fullname = " + fullname);
55105671 // Does not work on Windows due to C:
....@@ -5516,12 +5677,12 @@
55165677
55175678 if (split.length == 0)
55185679 {
5519
- return "";
5680
+ return fullname.bump = "";
55205681 }
55215682
55225683 if (split.length == 1)
55235684 {
5524
- return "";
5685
+ return fullname.bump = "";
55255686 }
55265687
55275688 if (split.length == 2)
....@@ -5529,16 +5690,16 @@
55295690 if (fullname.name.endsWith(":"))
55305691 {
55315692 // Windows
5532
- return "";
5693
+ return fullname.bump = "";
55335694 }
55345695
5535
- return split[1];
5696
+ return fullname.bump = split[1];
55365697 }
55375698
55385699 // Windows
55395700 assert(split.length == 4);
55405701
5541
- return split[2] + ":" + split[3];
5702
+ return fullname.bump = split[2] + ":" + split[3];
55425703 }
55435704
55445705 String GetPigmentTexture()
....@@ -5621,6 +5782,9 @@
56215782 texname = "";
56225783
56235784 GetTextures().name = texname + ":" + GetBump(GetTextures());
5785
+
5786
+ GetTextures().pigment = null;
5787
+
56245788 Touch();
56255789 }
56265790
....@@ -5694,6 +5858,8 @@
56945858
56955859 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56965860
5861
+ GetTextures().bump = null;
5862
+
56975863 Touch();
56985864 }
56995865
....@@ -5714,6 +5880,38 @@
57145880
57155881 blockloop = true;
57165882 child.ResetBumpTexture();
5883
+ blockloop = false;
5884
+ }
5885
+ }
5886
+
5887
+ void EmbedTextures(boolean embed)
5888
+ {
5889
+ if (blockloop)
5890
+ return;
5891
+
5892
+ //if (GetTextures() != null)
5893
+ if (embed)
5894
+ CameraPane.EmbedTextures(GetTextures());
5895
+ else
5896
+ {
5897
+ GetTextures().pigmentdata = null;
5898
+ GetTextures().bumpdata = null;
5899
+ GetTextures().pw = 0;
5900
+ GetTextures().ph = 0;
5901
+ GetTextures().bw = 0;
5902
+ GetTextures().bh = 0;
5903
+ }
5904
+
5905
+ int nb = Size();
5906
+ for (int i = 0; i < nb; i++)
5907
+ {
5908
+ Object3D child = (Object3D) get(i);
5909
+
5910
+ if (child == null)
5911
+ continue;
5912
+
5913
+ blockloop = true;
5914
+ child.EmbedTextures(embed);
57175915 blockloop = false;
57185916 }
57195917 }
....@@ -5804,8 +6002,10 @@
58046002 if (support != null)
58056003 support = support;
58066004
5807
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5808
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6005
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6006
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6007
+
6008
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58096009
58106010 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58116011 {
....@@ -5815,8 +6015,9 @@
58156015 // usecalllists &= !(parent instanceof RandomNode);
58166016 // usecalllists = false;
58176017
5818
- if (GetBRep() != null)
5819
- usecalllists = usecalllists;
6018
+ if (display.DrawMode() == display.SHADOW)
6019
+ //GetBRep() != null)
6020
+ usecalllists = !!usecalllists;
58206021 //System.out.println("draw " + this);
58216022 //new Exception().printStackTrace();
58226023
....@@ -5838,7 +6039,7 @@
58386039 if (!(this instanceof Composite))
58396040 touched = false;
58406041 //if (displaylist == -1 && usecalllists)
5841
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6042
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58426043 {
58436044 bRep.displaylist = display.GenList();
58446045 assert(bRep.displaylist != 0);
....@@ -5849,7 +6050,7 @@
58496050
58506051 //System.out.println("\tnew list " + list);
58516052 //gl.glDrawBuffer(gl.GL_NONE);
5852
- if (usecalllists)
6053
+ if (usecalllists && bRep.displaylist > 0)
58536054 {
58546055 // System.err.println("new list " + bRep.displaylist + " for " + this);
58556056 display.NewList(bRep.displaylist);
....@@ -5858,7 +6059,7 @@
58586059 CallList(display, root, selected, blocked);
58596060
58606061 // compiled = true;
5861
- if (usecalllists)
6062
+ if (usecalllists && bRep.displaylist > 0)
58626063 {
58636064 // System.err.println("end list " + bRep.displaylist + " for " + this);
58646065 display.EndList();
....@@ -7209,20 +7410,23 @@
72097410 }
72107411 }
72117412
7212
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7413
+ static ClickInfo clickInfo = new ClickInfo();
7414
+
7415
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7416
+ Point outPt, Rectangle outRec)
72137417 {
7214
- int hc = info.bounds.x + info.bounds.width / 2;
7215
- int vc = info.bounds.y + info.bounds.height / 2;
7216
- double[][] toscreen = info.toScreen;
7418
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7419
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7420
+ double[][] toscreen = clickInfo.toScreen;
72177421 if (toscreen == null)
72187422 {
7219
- toscreen = new Camera(info.camera.viewCode).toScreen;
7423
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72207424 }
72217425 cVector vec = in;
72227426 LA.xformPos(in, toscreen, in);
72237427 //System.out.println("Distance = " + info.camera.Distance());
7224
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7225
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7428
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7429
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72267430 outPt.x = hc + (int) vec.x;
72277431 outPt.y = vc - (int) vec.y;
72287432 outRec.x = outPt.x - 3;
....@@ -7230,15 +7434,18 @@
72307434 outRec.width = outRec.height = 6;
72317435 }
72327436
7233
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7437
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7438
+ )
72347439 {
72357440 Point pt = new Point(0, 0);
72367441 Rectangle rec = new Rectangle();
7237
- calcHotSpot(in, info, pt, rec);
7442
+ calcHotSpot(in, //clickInfo,
7443
+ pt, rec);
72387444 return rec;
72397445 }
72407446
7241
- void drawEditHandles0(ClickInfo info, int level)
7447
+ void drawEditHandles0(//ClickInfo clickInfo,
7448
+ int level)
72427449 {
72437450 if (level == 0)
72447451 {
....@@ -7247,16 +7454,19 @@
72477454 {
72487455 cVector origin = new cVector();
72497456 //LA.xformPos(origin, toParent, origin);
7250
- Rectangle spot = calcHotSpot(origin, info);
7457
+ if (this.clickInfo == null)
7458
+ this.clickInfo = new ClickInfo();
7459
+
7460
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72517461 Rectangle boundary = new Rectangle();
72527462 boundary.x = spot.x - 30;
72537463 boundary.y = spot.y - 30;
72547464 boundary.width = spot.width + 60;
72557465 boundary.height = spot.height + 60;
7256
- info.g.setColor(Color.red);
7466
+ clickInfo.g.setColor(Color.white);
72577467 int spotw = spot.x + spot.width;
72587468 int spoth = spot.y + spot.height;
7259
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7469
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72607470 // if (CameraPane.Xmin > spot.x)
72617471 // {
72627472 // CameraPane.Xmin = spot.x;
....@@ -7273,11 +7483,6 @@
72737483 // {
72747484 // CameraPane.Ymax = spoth;
72757485 // }
7276
- spot.translate(32, 32);
7277
- spotw = spot.x + spot.width;
7278
- spoth = spot.y + spot.height;
7279
- info.g.setColor(Color.cyan);
7280
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72817486 // if (CameraPane.Xmin > spot.x)
72827487 // {
72837488 // CameraPane.Xmin = spot.x;
....@@ -7296,10 +7501,15 @@
72967501 // }
72977502 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72987503 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7299
- spot.translate(0, -32);
7300
- info.g.setColor(Color.yellow);
7301
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
- info.g.setColor(Color.green);
7504
+ spot.translate(32, 0);
7505
+ clickInfo.g.setColor(Color.yellow);
7506
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7507
+
7508
+ spot.translate(32, 64);
7509
+ spotw = spot.x + spot.width;
7510
+ spoth = spot.y + spot.height;
7511
+ clickInfo.g.setColor(Color.cyan);
7512
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73037513 // if (CameraPane.Xmin > spot.x)
73047514 // {
73057515 // CameraPane.Xmin = spot.x;
....@@ -7316,8 +7526,9 @@
73167526 // {
73177527 // CameraPane.Ymax = spoth;
73187528 // }
7319
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
7529
+ clickInfo.g.setColor(Color.green);
7530
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7531
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73217532 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73227533 // if (CameraPane.Xmin > boundary.x)
73237534 // {
....@@ -7339,7 +7550,8 @@
73397550 }
73407551 }
73417552
7342
- boolean doEditClick0(ClickInfo info, int level)
7553
+ boolean doEditClick0(//ClickInfo clickInfo,
7554
+ int level)
73437555 {
73447556 if (level == 0)
73457557 {
....@@ -7348,8 +7560,8 @@
73487560
73497561 boolean retval = false;
73507562
7351
- startX = info.x;
7352
- startY = info.y;
7563
+ startX = clickInfo.x;
7564
+ startY = clickInfo.y;
73537565
73547566 hitSomething = -1;
73557567 cVector origin = new cVector();
....@@ -7359,22 +7571,53 @@
73597571 {
73607572 centerPt = new Point(0, 0);
73617573 }
7362
- calcHotSpot(origin, info, centerPt, spot);
7363
- if (spot.contains(info.x, info.y))
7574
+ calcHotSpot(origin, //info,
7575
+ centerPt, spot);
7576
+ if (spot.contains(clickInfo.x, clickInfo.y))
73647577 {
73657578 hitSomething = hitCenter;
73667579 retval = true;
73677580 }
73687581 spot.translate(32, 0);
7369
- if (spot.contains(info.x, info.y))
7582
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707583 {
73717584 hitSomething = hitRotate;
73727585 retval = true;
73737586 }
73747587 spot.translate(0, 32);
7375
- if (spot.contains(info.x, info.y))
7588
+ spot.translate(32, 0);
7589
+ spot.translate(0, 32);
7590
+ if (spot.contains(clickInfo.x, clickInfo.y))
73767591 {
73777592 hitSomething = hitScale;
7593
+
7594
+ double scale = 0.005f * clickInfo.camera.Distance();
7595
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7596
+ double sign = 1;
7597
+ if (hScale < 0)
7598
+ {
7599
+ sign = -1;
7600
+ }
7601
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7602
+ if (hScale < 0.01)
7603
+ {
7604
+ //hScale = 0.01;
7605
+ }
7606
+
7607
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7608
+ sign = 1;
7609
+ if (vScale < 0)
7610
+ {
7611
+ sign = -1;
7612
+ }
7613
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7614
+ if (vScale < 0.01)
7615
+ {
7616
+ //vScale = 0.01;
7617
+ }
7618
+
7619
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7620
+
73787621 retval = true;
73797622 }
73807623
....@@ -7384,7 +7627,7 @@
73847627 }
73857628
73867629 //System.out.println("info.modifiers = " + info.modifiers);
7387
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7630
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73887631 //System.out.println("modified = " + modified);
73897632 //new Exception().printStackTrace();
73907633 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7412,7 +7655,8 @@
74127655 return true;
74137656 }
74147657
7415
- void doEditDrag0(ClickInfo info, boolean opposite)
7658
+ void doEditDrag0(//ClickInfo info,
7659
+ boolean opposite)
74167660 {
74177661 if (hitSomething == 0)
74187662 {
....@@ -7426,7 +7670,7 @@
74267670
74277671 //System.out.println("hitSomething = " + hitSomething);
74287672
7429
- double scale = 0.005f * info.camera.Distance();
7673
+ double scale = 0.005f * clickInfo.camera.Distance();
74307674
74317675 cVector xlate = new cVector();
74327676 //cVector xlate2 = new cVector();
....@@ -7460,8 +7704,8 @@
74607704 toParent[3][i] = xlate.get(i);
74617705 LA.matInvert(toParent, fromParent);
74627706 */
7463
- cVector delta = LA.newVector(0, 0, startY - info.y);
7464
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7707
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7708
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74657709
74667710 LA.matCopy(startMat, toParent);
74677711 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7470,7 +7714,7 @@
74707714 } else
74717715 {
74727716 //LA.xformDir(delta, info.camera.fromScreen, delta);
7473
- cVector up = new cVector(info.camera.up);
7717
+ cVector up = new cVector(clickInfo.camera.up);
74747718 cVector away = new cVector();
74757719 //cVector right2 = new cVector();
74767720 //LA.vecCross(up, cVector.Z, right);
....@@ -7487,19 +7731,19 @@
74877731 LA.xformDir(up, ClickInfo.matbuffer, up);
74887732 // if (!CameraPane.LOCALTRANSFORM)
74897733 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7490
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7734
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74917735 // if (!CameraPane.LOCALTRANSFORM)
74927736 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74937737 //LA.vecCross(up, cVector.Z, right2);
74947738
7495
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7739
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74967740
74977741 //System.out.println("DELTA0 = " + delta);
74987742 //System.out.println("AWAY = " + info.camera.away);
74997743 //System.out.println("UP = " + info.camera.up);
75007744 if (away.z > 0)
75017745 {
7502
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7746
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75037747 {
75047748 delta.x = -delta.x;
75057749 } else
....@@ -7514,7 +7758,7 @@
75147758 //System.out.println("DELTA1 = " + delta);
75157759 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75167760 //System.out.println("DELTA2 = " + delta);
7517
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7761
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75187762 LA.matCopy(startMat, toParent);
75197763 //System.out.println("DELTA3 = " + delta);
75207764 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7524,8 +7768,8 @@
75247768 break;
75257769
75267770 case hitRotate: // rotate
7527
- int dx = info.x - centerPt.x;
7528
- int dy = -(info.y - centerPt.y);
7771
+ int dx = clickInfo.x - centerPt.x;
7772
+ int dy = -(clickInfo.y - centerPt.y);
75297773 double angle = (double) Math.atan2(dx, dy);
75307774 angle = -(1.570796 - angle);
75317775
....@@ -7548,7 +7792,7 @@
75487792 }
75497793 /**/
75507794
7551
- switch (info.pane.RenderCamera().viewCode)
7795
+ switch (clickInfo.pane.RenderCamera().viewCode)
75527796 {
75537797 case 1: // '\001'
75547798 LA.matZRotate(toParent, angle);
....@@ -7575,7 +7819,7 @@
75757819 break;
75767820
75777821 case hitScale: // scale
7578
- double hScale = (double) (info.x - centerPt.x) / 32;
7822
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75797823 double sign = 1;
75807824 if (hScale < 0)
75817825 {
....@@ -7587,7 +7831,7 @@
75877831 //hScale = 0.01;
75887832 }
75897833
7590
- double vScale = (double) (info.y - centerPt.y) / 32;
7834
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75917835 sign = 1;
75927836 if (vScale < 0)
75937837 {
....@@ -7598,6 +7842,7 @@
75987842 {
75997843 //vScale = 0.01;
76007844 }
7845
+
76017846 LA.matCopy(startMat, toParent);
76027847 /**/
76037848 for (int i = 0; i < 3; i++)
....@@ -7607,33 +7852,39 @@
76077852 }
76087853 /**/
76097854
7610
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7855
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76117856
76127857 if (totalScale < 0.01)
76137858 {
76147859 totalScale = 0.01;
76157860 }
76167861
7617
- switch (info.pane.RenderCamera().viewCode)
7862
+ switch (clickInfo.pane.RenderCamera().viewCode)
76187863 {
76197864 case 3: // '\001'
76207865 if (modified || opposite)
76217866 {
7867
+ if (modified && opposite)
7868
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7869
+ else
76227870 //LA.matScale(toParent, 1, hScale, vScale);
7623
- LA.matScale(toParent, totalScale, 1, 1);
7871
+ LA.matScale(toParent, totalScale, 1, 1);
76247872 } // vScale, 1);
76257873 else
76267874 {
76277875 // EXCEPTION!
7628
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7876
+ LA.matScale(toParent, 1, totalScale, totalScale);
76297877 } // vScale, 1);
76307878 break;
76317879
76327880 case 2: // '\002'
76337881 if (modified || opposite)
76347882 {
7635
- //LA.matScale(toParent, hScale, 1, vScale);
7636
- LA.matScale(toParent, 1, totalScale, 1);
7883
+ if (modified && opposite)
7884
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7885
+ else
7886
+ //LA.matScale(toParent, hScale, 1, vScale);
7887
+ LA.matScale(toParent, 1, totalScale, 1);
76377888 } else
76387889 {
76397890 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7643,8 +7894,11 @@
76437894 case 1: // '\003'
76447895 if (modified || opposite)
76457896 {
7646
- //LA.matScale(toParent, hScale, vScale, 1);
7647
- LA.matScale(toParent, 1, 1, totalScale);
7897
+ if (modified && opposite)
7898
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7899
+ else
7900
+ //LA.matScale(toParent, hScale, vScale, 1);
7901
+ LA.matScale(toParent, 1, 1, totalScale);
76487902 } else
76497903 {
76507904 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7681,7 +7935,7 @@
76817935 } // NEW ...
76827936
76837937
7684
- info.pane.repaint();
7938
+ clickInfo.pane.repaint();
76857939 }
76867940
76877941 boolean overflow = false;