Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
Object3D.java
....@@ -24,11 +24,17 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
3030 //
3131
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ Object3D versions[];
36
+ int versionindex = -1;
37
+
3238 ScriptNode scriptnode;
3339
3440 void InitOthers()
....@@ -170,24 +176,35 @@
170176
171177 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172178 {
179
+ Object3D o;
180
+
173181 if (hashtable.containsKey(GetUUID()))
174182 {
175
- Object3D o = hashtable.get(GetUUID());
183
+ o = hashtable.get(GetUUID());
176184
177185 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
186
+ //if (this.bRep != null)
187
+ // assert(this.bRep.support == o.transientrep);
188
+ if (this.support != null)
189
+ assert(this.support.bRep == o.transientrep);
190
+ }
191
+ else
192
+ {
193
+ o = new Object3D("copy of " + this.name);
180194
181
- return;
195
+ hashtable.put(GetUUID(), o);
182196 }
183197
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
198
+ if (!blockloop)
189199 {
190
- get(i).ExtractBigData(hashtable);
200
+ blockloop = true;
201
+
202
+ for (int i=0; i<Size(); i++)
203
+ {
204
+ get(i).ExtractBigData(hashtable);
205
+ }
206
+
207
+ blockloop = false;
191208 }
192209
193210 ExtractBigData(o);
....@@ -195,11 +212,26 @@
195212
196213 void ExtractBigData(Object3D o)
197214 {
215
+ if (o.bRep != null)
216
+ Grafreed.Assert(o.bRep == this.bRep);
217
+
198218 o.bRep = this.bRep;
199
- if (this.bRep != null)
219
+// July 2019 if (this.bRep != null)
220
+// {
221
+// o.transientrep = this.bRep.support;
222
+// o.bRep.support = null;
223
+// }
224
+ o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
227
+
228
+ if (this.support != null)
200229 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
230
+ if (o.transientrep != null)
231
+ Grafreed.Assert(o.transientrep == this.support.bRep);
232
+
233
+ o.transientrep = this.support.bRep;
234
+ this.support.bRep = null;
203235 }
204236
205237 // o.support = this.support;
....@@ -223,19 +255,35 @@
223255
224256 RestoreBigData(o);
225257
226
- hashtable.remove(GetUUID());
258
+ if (blockloop)
259
+ return;
260
+
261
+ blockloop = true;
262
+
263
+ //hashtable.remove(GetUUID());
227264
228265 for (int i=0; i<Size(); i++)
229266 {
230267 get(i).RestoreBigData(hashtable);
231268 }
269
+
270
+ blockloop = false;
232271 }
233272
234273 void RestoreBigData(Object3D o)
235274 {
236275 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
276
+ if (this.support != null && o.transientrep != null)
277
+ {
278
+ this.support.bRep = o.transientrep;
279
+ }
280
+
281
+ this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
285
+// July 2019 if (this.bRep != null)
286
+// this.bRep.support = o.transientrep;
239287 // this.support = o.support;
240288 // this.fileparent = o.fileparent;
241289 }
....@@ -381,6 +429,7 @@
381429 }
382430
383431 boolean live = false;
432
+ transient boolean keepdontselect;
384433 boolean dontselect = false;
385434 boolean hide = false;
386435 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +930,7 @@
881930
882931 if (marked && Globals.isLIVE() && live &&
883932 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
933
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885934 currentframe != Globals.framecount)
886935 {
887936 currentframe = Globals.framecount;
....@@ -893,7 +942,8 @@
893942
894943 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895944
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
945
+ if (transformcount*factor >= maxcount && (rewind || random) ||
946
+ (step == 1 && changedir))
897947 {
898948 countdown = 1;
899949 delay = speedup?8:1;
....@@ -965,6 +1015,10 @@
9651015 if (material == null || material.multiply)
9661016 return true;
9671017
1018
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1019
+ return false;
1020
+
1021
+ // Transparent objects are dynamic because we have to sort the triangles.
9681022 return material.opacity > 0.99;
9691023 }
9701024
....@@ -1365,6 +1419,7 @@
13651419 toParent = LA.newMatrix();
13661420 fromParent = LA.newMatrix();
13671421 }
1422
+
13681423 LA.matCopy(other.toParent, toParent);
13691424 LA.matCopy(other.fromParent, fromParent);
13701425
....@@ -2386,6 +2441,10 @@
23862441 }
23872442 */
23882443 }
2444
+ else
2445
+ {
2446
+ //((ObjEditor)editWindow).SetupUI2(null);
2447
+ }
23892448 }
23902449
23912450 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2486,14 @@
24272486 {
24282487 editWindow.refreshContents();
24292488 }
2489
+ else
2490
+ {
2491
+ if (manipWindow != null)
2492
+ {
2493
+ manipWindow.refreshContents();
2494
+ }
2495
+ }
2496
+
24302497 //if (parent != null)
24312498 //parent.refreshEditWindow();
24322499 }
....@@ -2506,7 +2573,8 @@
25062573 private static final int editSelf = 1;
25072574 private static final int editChild = 2;
25082575
2509
- void drawEditHandles(ClickInfo info, int level)
2576
+ void drawEditHandles(//ClickInfo info,
2577
+ int level)
25102578 {
25112579 if (level == 0)
25122580 {
....@@ -2514,7 +2582,8 @@
25142582 return;
25152583
25162584 Object3D selectee;
2517
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2585
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2586
+ level + 1))
25182587 {
25192588 selectee = (Object3D) e.nextElement();
25202589 }
....@@ -2522,19 +2591,22 @@
25222591 } else
25232592 {
25242593 //super.
2525
- drawEditHandles0(info, level + 1);
2594
+ drawEditHandles0(//info,
2595
+ level + 1);
25262596 }
25272597 }
25282598
2529
- boolean doEditClick(ClickInfo info, int level)
2599
+ boolean doEditClick(//ClickInfo info,
2600
+ int level)
25302601 {
25312602 doSomething = 0;
25322603 if (level == 0)
25332604 {
2534
- return doParentClick(info);
2605
+ return doParentClick(); //info);
25352606 }
25362607 if (//super.
2537
- doEditClick0(info, level))
2608
+ doEditClick0(//info,
2609
+ level))
25382610 {
25392611 doSomething = 1;
25402612 return true;
....@@ -2544,7 +2616,7 @@
25442616 }
25452617 }
25462618
2547
- boolean doParentClick(ClickInfo info)
2619
+ boolean doParentClick() //ClickInfo info)
25482620 {
25492621 if (selection == null)
25502622 {
....@@ -2557,7 +2629,8 @@
25572629 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582630 {
25592631 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2632
+ if (selectee.doEditClick(//info,
2633
+ 1))
25612634 {
25622635 childToDrag = selectee;
25632636 doSomething = 2;
....@@ -2569,13 +2642,15 @@
25692642 return retval;
25702643 }
25712644
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2645
+ void doEditDrag(//ClickInfo clickInfo,
2646
+ boolean opposite)
25732647 {
25742648 switch (doSomething)
25752649 {
25762650 case 1: // '\001'
25772651 //super.
2578
- doEditDrag0(info, opposite);
2652
+ doEditDrag0(//clickInfo,
2653
+ opposite);
25792654 break;
25802655
25812656 case 2: // '\002'
....@@ -2588,11 +2663,13 @@
25882663 {
25892664 //sel.hitSomething = childToDrag.hitSomething;
25902665 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2666
+ sel.doEditDrag(//clickInfo,
2667
+ opposite);
25922668 } else
25932669 {
25942670 //super.
2595
- doEditDrag0(info, opposite);
2671
+ doEditDrag0(//clickInfo,
2672
+ opposite);
25962673 }
25972674 }
25982675 break;
....@@ -2610,6 +2687,9 @@
26102687 {
26112688 deselectAll();
26122689 }
2690
+
2691
+ new Exception().printStackTrace();
2692
+
26132693 ClickInfo newInfo = new ClickInfo();
26142694 newInfo.flags = info.flags;
26152695 newInfo.bounds = info.bounds;
....@@ -3057,7 +3137,7 @@
30573137 {
30583138 if (bRep != null)
30593139 {
3060
- bRep.GenerateNormalsMINE();
3140
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613141 Touch();
30623142 }
30633143 }
....@@ -3503,7 +3583,8 @@
35033583 if (blockloop)
35043584 return;
35053585
3506
- if (marked || (bRep != null && material != null)) // borderline...
3586
+ if (//marked || // does not make sense
3587
+ (bRep != null || material != null)) // borderline...
35073588 live = h;
35083589
35093590 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3605,8 @@
35243605 return;
35253606
35263607 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3608
+ if (//marked || // does not make sense
3609
+ (bRep != null || material != null)) // borderline...
35283610 link2master = h;
35293611
35303612 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3626,8 @@
35443626 if (blockloop)
35453627 return;
35463628
3547
- if (marked || (bRep != null && material != null)) // borderline...
3629
+ if (//marked || // does not make sense
3630
+ (bRep != null || material != null)) // borderline...
35483631 hide = h;
35493632
35503633 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3647,7 @@
35643647 if (blockloop)
35653648 return;
35663649
3567
- if (bRep != null && material != null) // borderline...
3650
+ if (bRep != null || material != null) // borderline...
35683651 marked = h;
35693652
35703653 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3657,46 @@
35743657 continue;
35753658 blockloop = true;
35763659 child.MarkLeaves(h);
3660
+ blockloop = false;
3661
+ // release(i);
3662
+ }
3663
+ }
3664
+
3665
+ void RewindLeaves(boolean h)
3666
+ {
3667
+ if (blockloop)
3668
+ return;
3669
+
3670
+ if (bRep != null || material != null) // borderline...
3671
+ rewind = h;
3672
+
3673
+ for (int i = 0; i < Size(); i++)
3674
+ {
3675
+ Object3D child = (Object3D) get(i); // reserve(i);
3676
+ if (child == null)
3677
+ continue;
3678
+ blockloop = true;
3679
+ child.RewindLeaves(h);
3680
+ blockloop = false;
3681
+ // release(i);
3682
+ }
3683
+ }
3684
+
3685
+ void RandomLeaves(boolean h)
3686
+ {
3687
+ if (blockloop)
3688
+ return;
3689
+
3690
+ if (bRep != null || material != null) // borderline...
3691
+ random = h;
3692
+
3693
+ for (int i = 0; i < Size(); i++)
3694
+ {
3695
+ Object3D child = (Object3D) get(i); // reserve(i);
3696
+ if (child == null)
3697
+ continue;
3698
+ blockloop = true;
3699
+ child.RandomLeaves(h);
35773700 blockloop = false;
35783701 // release(i);
35793702 }
....@@ -4914,6 +5037,14 @@
49145037 }
49155038 }
49165039
5040
+ ObjEditor GetWindow()
5041
+ {
5042
+ if (editWindow != null)
5043
+ return editWindow;
5044
+
5045
+ return manipWindow;
5046
+ }
5047
+
49175048 cTreePath Select(int indexcount, boolean deselect)
49185049 {
49195050 if (hide || dontselect)
....@@ -4950,10 +5081,11 @@
49505081 if (leaf != null)
49515082 {
49525083 cTreePath tp = new cTreePath(this, leaf);
4953
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
49545086 {
49555087 //System.out.println("editWindow = " + editWindow + " vs " + this);
4956
- editWindow.Select(tp, deselect, true);
5088
+ window.Select(tp, deselect, true);
49575089 }
49585090
49595091 return tp;
....@@ -4970,6 +5102,7 @@
49705102
49715103 if (child == null)
49725104 continue;
5105
+
49735106 if (child.HasTransparency() && child.size() != 0)
49745107 {
49755108 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4979,9 +5112,10 @@
49795112 if (leaf != null)
49805113 {
49815114 cTreePath tp = new cTreePath(this, leaf);
4982
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
49835117 {
4984
- editWindow.Select(tp, deselect, true);
5118
+ window.Select(tp, deselect, true);
49855119 }
49865120
49875121 return tp;
....@@ -5306,6 +5440,51 @@
53065440 blockloop = false;
53075441 }
53085442
5443
+ void ResetSelectable()
5444
+ {
5445
+ if (blockloop)
5446
+ return;
5447
+
5448
+ blockloop = true;
5449
+
5450
+ keepdontselect = dontselect;
5451
+ dontselect = true;
5452
+
5453
+ Object3D child;
5454
+ int nb = Size();
5455
+ for (int i = 0; i < nb; i++)
5456
+ {
5457
+ child = (Object3D) get(i);
5458
+ if (child == null)
5459
+ continue;
5460
+ child.ResetSelectable();
5461
+ }
5462
+
5463
+ blockloop = false;
5464
+ }
5465
+
5466
+ void RestoreSelectable()
5467
+ {
5468
+ if (blockloop)
5469
+ return;
5470
+
5471
+ blockloop = true;
5472
+
5473
+ dontselect = keepdontselect;
5474
+
5475
+ Object3D child;
5476
+ int nb = Size();
5477
+ for (int i = 0; i < nb; i++)
5478
+ {
5479
+ child = (Object3D) get(i);
5480
+ if (child == null)
5481
+ continue;
5482
+ child.RestoreSelectable();
5483
+ }
5484
+
5485
+ blockloop = false;
5486
+ }
5487
+
53095488 boolean IsSelected()
53105489 {
53115490 if (parent == null)
....@@ -5615,6 +5794,38 @@
56155794 }
56165795 }
56175796
5797
+ void EmbedTextures(boolean embed)
5798
+ {
5799
+ if (blockloop)
5800
+ return;
5801
+
5802
+ //if (GetTextures() != null)
5803
+ if (embed)
5804
+ CameraPane.EmbedTextures(GetTextures());
5805
+ else
5806
+ {
5807
+ GetTextures().pigmentdata = null;
5808
+ GetTextures().bumpdata = null;
5809
+ GetTextures().pw = 0;
5810
+ GetTextures().ph = 0;
5811
+ GetTextures().bw = 0;
5812
+ GetTextures().bh = 0;
5813
+ }
5814
+
5815
+ int nb = Size();
5816
+ for (int i = 0; i < nb; i++)
5817
+ {
5818
+ Object3D child = (Object3D) get(i);
5819
+
5820
+ if (child == null)
5821
+ continue;
5822
+
5823
+ blockloop = true;
5824
+ child.EmbedTextures(embed);
5825
+ blockloop = false;
5826
+ }
5827
+ }
5828
+
56185829 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56195830 {
56205831 Draw(display, root, selected, blocked);
....@@ -5701,8 +5912,10 @@
57015912 if (support != null)
57025913 support = support;
57035914
5704
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5705
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5915
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5916
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5917
+
5918
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57065919
57075920 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57085921 {
....@@ -5712,8 +5925,9 @@
57125925 // usecalllists &= !(parent instanceof RandomNode);
57135926 // usecalllists = false;
57145927
5715
- if (GetBRep() != null)
5716
- usecalllists = usecalllists;
5928
+ if (display.DrawMode() == display.SHADOW)
5929
+ //GetBRep() != null)
5930
+ usecalllists = !!usecalllists;
57175931 //System.out.println("draw " + this);
57185932 //new Exception().printStackTrace();
57195933
....@@ -5723,7 +5937,7 @@
57235937
57245938 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57255939 //(touched || (bRep != null && bRep.displaylist <= 0)))
5726
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5940
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57275941 {
57285942 Globals.lighttouched = true;
57295943 } // all panes...
....@@ -5735,7 +5949,7 @@
57355949 if (!(this instanceof Composite))
57365950 touched = false;
57375951 //if (displaylist == -1 && usecalllists)
5738
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5952
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57395953 {
57405954 bRep.displaylist = display.GenList();
57415955 assert(bRep.displaylist != 0);
....@@ -5746,7 +5960,7 @@
57465960
57475961 //System.out.println("\tnew list " + list);
57485962 //gl.glDrawBuffer(gl.GL_NONE);
5749
- if (usecalllists)
5963
+ if (usecalllists && bRep.displaylist > 0)
57505964 {
57515965 // System.err.println("new list " + bRep.displaylist + " for " + this);
57525966 display.NewList(bRep.displaylist);
....@@ -5755,7 +5969,7 @@
57555969 CallList(display, root, selected, blocked);
57565970
57575971 // compiled = true;
5758
- if (usecalllists)
5972
+ if (usecalllists && bRep.displaylist > 0)
57595973 {
57605974 // System.err.println("end list " + bRep.displaylist + " for " + this);
57615975 display.EndList();
....@@ -5855,6 +6069,7 @@
58556069 if (GetBRep() != null)
58566070 {
58576071 display.NextIndex();
6072
+
58586073 // vertex color conflict : gl.glCallList(list);
58596074 DrawNode(display, root, selected);
58606075 if (this instanceof BezierPatch)
....@@ -6315,6 +6530,11 @@
63156530 // dec 2012
63166531 new Exception().printStackTrace();
63176532 return;
6533
+ }
6534
+
6535
+ if (dontselect)
6536
+ {
6537
+ //bRep.GenerateNormalsMINE();
63186538 }
63196539
63206540 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7100,20 +7320,23 @@
71007320 }
71017321 }
71027322
7103
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7323
+ static ClickInfo clickInfo = new ClickInfo();
7324
+
7325
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7326
+ Point outPt, Rectangle outRec)
71047327 {
7105
- int hc = info.bounds.x + info.bounds.width / 2;
7106
- int vc = info.bounds.y + info.bounds.height / 2;
7107
- double[][] toscreen = info.toScreen;
7328
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7329
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7330
+ double[][] toscreen = clickInfo.toScreen;
71087331 if (toscreen == null)
71097332 {
7110
- toscreen = new Camera(info.camera.viewCode).toScreen;
7333
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71117334 }
71127335 cVector vec = in;
71137336 LA.xformPos(in, toscreen, in);
71147337 //System.out.println("Distance = " + info.camera.Distance());
7115
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7116
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7338
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7339
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71177340 outPt.x = hc + (int) vec.x;
71187341 outPt.y = vc - (int) vec.y;
71197342 outRec.x = outPt.x - 3;
....@@ -7121,15 +7344,18 @@
71217344 outRec.width = outRec.height = 6;
71227345 }
71237346
7124
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7347
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7348
+ )
71257349 {
71267350 Point pt = new Point(0, 0);
71277351 Rectangle rec = new Rectangle();
7128
- calcHotSpot(in, info, pt, rec);
7352
+ calcHotSpot(in, //clickInfo,
7353
+ pt, rec);
71297354 return rec;
71307355 }
71317356
7132
- void drawEditHandles0(ClickInfo info, int level)
7357
+ void drawEditHandles0(//ClickInfo clickInfo,
7358
+ int level)
71337359 {
71347360 if (level == 0)
71357361 {
....@@ -7138,16 +7364,19 @@
71387364 {
71397365 cVector origin = new cVector();
71407366 //LA.xformPos(origin, toParent, origin);
7141
- Rectangle spot = calcHotSpot(origin, info);
7367
+ if (this.clickInfo == null)
7368
+ this.clickInfo = new ClickInfo();
7369
+
7370
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71427371 Rectangle boundary = new Rectangle();
71437372 boundary.x = spot.x - 30;
71447373 boundary.y = spot.y - 30;
71457374 boundary.width = spot.width + 60;
71467375 boundary.height = spot.height + 60;
7147
- info.g.setColor(Color.red);
7376
+ clickInfo.g.setColor(Color.red);
71487377 int spotw = spot.x + spot.width;
71497378 int spoth = spot.y + spot.height;
7150
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71517380 // if (CameraPane.Xmin > spot.x)
71527381 // {
71537382 // CameraPane.Xmin = spot.x;
....@@ -7167,8 +7396,8 @@
71677396 spot.translate(32, 32);
71687397 spotw = spot.x + spot.width;
71697398 spoth = spot.y + spot.height;
7170
- info.g.setColor(Color.cyan);
7171
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7399
+ clickInfo.g.setColor(Color.cyan);
7400
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71727401 // if (CameraPane.Xmin > spot.x)
71737402 // {
71747403 // CameraPane.Xmin = spot.x;
....@@ -7188,9 +7417,9 @@
71887417 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
71897418 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71907419 spot.translate(0, -32);
7191
- info.g.setColor(Color.yellow);
7192
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7193
- info.g.setColor(Color.green);
7420
+ clickInfo.g.setColor(Color.yellow);
7421
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7422
+ clickInfo.g.setColor(Color.green);
71947423 // if (CameraPane.Xmin > spot.x)
71957424 // {
71967425 // CameraPane.Xmin = spot.x;
....@@ -7207,8 +7436,8 @@
72077436 // {
72087437 // CameraPane.Ymax = spoth;
72097438 // }
7210
- info.g.drawArc(boundary.x, boundary.y,
7211
- boundary.width, boundary.height, 0, 360);
7439
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7440
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72127441 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72137442 // if (CameraPane.Xmin > boundary.x)
72147443 // {
....@@ -7230,7 +7459,8 @@
72307459 }
72317460 }
72327461
7233
- boolean doEditClick0(ClickInfo info, int level)
7462
+ boolean doEditClick0(//ClickInfo clickInfo,
7463
+ int level)
72347464 {
72357465 if (level == 0)
72367466 {
....@@ -7239,8 +7469,8 @@
72397469
72407470 boolean retval = false;
72417471
7242
- startX = info.x;
7243
- startY = info.y;
7472
+ startX = clickInfo.x;
7473
+ startY = clickInfo.y;
72447474
72457475 hitSomething = -1;
72467476 cVector origin = new cVector();
....@@ -7250,22 +7480,51 @@
72507480 {
72517481 centerPt = new Point(0, 0);
72527482 }
7253
- calcHotSpot(origin, info, centerPt, spot);
7254
- if (spot.contains(info.x, info.y))
7483
+ calcHotSpot(origin, //info,
7484
+ centerPt, spot);
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
72557486 {
72567487 hitSomething = hitCenter;
72577488 retval = true;
72587489 }
72597490 spot.translate(32, 0);
7260
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
72617492 {
72627493 hitSomething = hitRotate;
72637494 retval = true;
72647495 }
72657496 spot.translate(0, 32);
7266
- if (spot.contains(info.x, info.y))
7497
+ if (spot.contains(clickInfo.x, clickInfo.y))
72677498 {
72687499 hitSomething = hitScale;
7500
+
7501
+ double scale = 0.005f * clickInfo.camera.Distance();
7502
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7503
+ double sign = 1;
7504
+ if (hScale < 0)
7505
+ {
7506
+ sign = -1;
7507
+ }
7508
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7509
+ if (hScale < 0.01)
7510
+ {
7511
+ //hScale = 0.01;
7512
+ }
7513
+
7514
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7515
+ sign = 1;
7516
+ if (vScale < 0)
7517
+ {
7518
+ sign = -1;
7519
+ }
7520
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7521
+ if (vScale < 0.01)
7522
+ {
7523
+ //vScale = 0.01;
7524
+ }
7525
+
7526
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7527
+
72697528 retval = true;
72707529 }
72717530
....@@ -7275,7 +7534,7 @@
72757534 }
72767535
72777536 //System.out.println("info.modifiers = " + info.modifiers);
7278
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7537
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72797538 //System.out.println("modified = " + modified);
72807539 //new Exception().printStackTrace();
72817540 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7303,7 +7562,8 @@
73037562 return true;
73047563 }
73057564
7306
- void doEditDrag0(ClickInfo info, boolean opposite)
7565
+ void doEditDrag0(//ClickInfo info,
7566
+ boolean opposite)
73077567 {
73087568 if (hitSomething == 0)
73097569 {
....@@ -7317,7 +7577,7 @@
73177577
73187578 //System.out.println("hitSomething = " + hitSomething);
73197579
7320
- double scale = 0.005f * info.camera.Distance();
7580
+ double scale = 0.005f * clickInfo.camera.Distance();
73217581
73227582 cVector xlate = new cVector();
73237583 //cVector xlate2 = new cVector();
....@@ -7351,8 +7611,8 @@
73517611 toParent[3][i] = xlate.get(i);
73527612 LA.matInvert(toParent, fromParent);
73537613 */
7354
- cVector delta = LA.newVector(0, 0, startY - info.y);
7355
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7614
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7615
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73567616
73577617 LA.matCopy(startMat, toParent);
73587618 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7361,7 +7621,7 @@
73617621 } else
73627622 {
73637623 //LA.xformDir(delta, info.camera.fromScreen, delta);
7364
- cVector up = new cVector(info.camera.up);
7624
+ cVector up = new cVector(clickInfo.camera.up);
73657625 cVector away = new cVector();
73667626 //cVector right2 = new cVector();
73677627 //LA.vecCross(up, cVector.Z, right);
....@@ -7378,19 +7638,19 @@
73787638 LA.xformDir(up, ClickInfo.matbuffer, up);
73797639 // if (!CameraPane.LOCALTRANSFORM)
73807640 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7381
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7641
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73827642 // if (!CameraPane.LOCALTRANSFORM)
73837643 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73847644 //LA.vecCross(up, cVector.Z, right2);
73857645
7386
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7646
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73877647
73887648 //System.out.println("DELTA0 = " + delta);
73897649 //System.out.println("AWAY = " + info.camera.away);
73907650 //System.out.println("UP = " + info.camera.up);
73917651 if (away.z > 0)
73927652 {
7393
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7653
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73947654 {
73957655 delta.x = -delta.x;
73967656 } else
....@@ -7405,7 +7665,7 @@
74057665 //System.out.println("DELTA1 = " + delta);
74067666 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74077667 //System.out.println("DELTA2 = " + delta);
7408
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7668
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74097669 LA.matCopy(startMat, toParent);
74107670 //System.out.println("DELTA3 = " + delta);
74117671 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7415,8 +7675,8 @@
74157675 break;
74167676
74177677 case hitRotate: // rotate
7418
- int dx = info.x - centerPt.x;
7419
- int dy = -(info.y - centerPt.y);
7678
+ int dx = clickInfo.x - centerPt.x;
7679
+ int dy = -(clickInfo.y - centerPt.y);
74207680 double angle = (double) Math.atan2(dx, dy);
74217681 angle = -(1.570796 - angle);
74227682
....@@ -7439,7 +7699,7 @@
74397699 }
74407700 /**/
74417701
7442
- switch (info.pane.RenderCamera().viewCode)
7702
+ switch (clickInfo.pane.RenderCamera().viewCode)
74437703 {
74447704 case 1: // '\001'
74457705 LA.matZRotate(toParent, angle);
....@@ -7466,7 +7726,7 @@
74667726 break;
74677727
74687728 case hitScale: // scale
7469
- double hScale = (double) (info.x - centerPt.x) / 32;
7729
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
74707730 double sign = 1;
74717731 if (hScale < 0)
74727732 {
....@@ -7478,7 +7738,7 @@
74787738 //hScale = 0.01;
74797739 }
74807740
7481
- double vScale = (double) (info.y - centerPt.y) / 32;
7741
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74827742 sign = 1;
74837743 if (vScale < 0)
74847744 {
....@@ -7489,6 +7749,7 @@
74897749 {
74907750 //vScale = 0.01;
74917751 }
7752
+
74927753 LA.matCopy(startMat, toParent);
74937754 /**/
74947755 for (int i = 0; i < 3; i++)
....@@ -7498,14 +7759,14 @@
74987759 }
74997760 /**/
75007761
7501
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7762
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75027763
75037764 if (totalScale < 0.01)
75047765 {
75057766 totalScale = 0.01;
75067767 }
75077768
7508
- switch (info.pane.RenderCamera().viewCode)
7769
+ switch (clickInfo.pane.RenderCamera().viewCode)
75097770 {
75107771 case 3: // '\001'
75117772 if (modified || opposite)
....@@ -7572,7 +7833,7 @@
75727833 } // NEW ...
75737834
75747835
7575
- info.pane.repaint();
7836
+ clickInfo.pane.repaint();
75767837 }
75777838
75787839 boolean overflow = false;
....@@ -7752,6 +8013,10 @@
77528013 editWindow = null;
77538014 } // ?
77548015 }
8016
+ else
8017
+ {
8018
+ //editWindow.closeUI();
8019
+ }
77558020 }
77568021
77578022 boolean root; // patch for edit windows
....@@ -7909,6 +8174,10 @@
79098174 }
79108175
79118176 transient ObjEditor editWindow;
8177
+ transient ObjEditor manipWindow;
8178
+
8179
+ transient boolean pinned;
8180
+
79128181 transient ObjectUI objectUI;
79138182 public static int povDepth = 0;
79148183 private static cVector tbMin = new cVector();