Normand Briere
2019-08-14 0c1f740dd6ddd6432dc29266e42ef851e26027bb
Object3D.java
....@@ -22,13 +22,20 @@
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
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
3132
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
3239 ScriptNode scriptnode;
3340
3441 void InitOthers()
....@@ -170,24 +177,35 @@
170177
171178 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172179 {
180
+ Object3D o;
181
+
173182 if (hashtable.containsKey(GetUUID()))
174183 {
175
- Object3D o = hashtable.get(GetUUID());
184
+ o = hashtable.get(GetUUID());
176185
177186 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
180195
181
- return;
196
+ hashtable.put(GetUUID(), o);
182197 }
183198
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
199
+ if (!blockloop)
189200 {
190
- get(i).ExtractBigData(hashtable);
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
191209 }
192210
193211 ExtractBigData(o);
....@@ -195,11 +213,26 @@
195213
196214 void ExtractBigData(Object3D o)
197215 {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
198219 o.bRep = this.bRep;
199
- if (this.bRep != null)
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
200230 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
203236 }
204237
205238 // o.support = this.support;
....@@ -214,6 +247,29 @@
214247 // this.fileparent = null;
215248 }
216249
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
217273 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218274 {
219275 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +279,35 @@
223279
224280 RestoreBigData(o);
225281
226
- hashtable.remove(GetUUID());
282
+ if (blockloop)
283
+ return;
284
+
285
+ blockloop = true;
286
+
287
+ //hashtable.remove(GetUUID());
227288
228289 for (int i=0; i<Size(); i++)
229290 {
230291 get(i).RestoreBigData(hashtable);
231292 }
293
+
294
+ blockloop = false;
232295 }
233296
234297 void RestoreBigData(Object3D o)
235298 {
236299 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
239311 // this.support = o.support;
240312 // this.fileparent = o.fileparent;
241313 }
....@@ -381,6 +453,7 @@
381453 }
382454
383455 boolean live = false;
456
+ transient boolean keepdontselect;
384457 boolean dontselect = false;
385458 boolean hide = false;
386459 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +954,7 @@
881954
882955 if (marked && Globals.isLIVE() && live &&
883956 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885958 currentframe != Globals.framecount)
886959 {
887960 currentframe = Globals.framecount;
....@@ -966,6 +1039,10 @@
9661039 if (material == null || material.multiply)
9671040 return true;
9681041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
9691046 return material.opacity > 0.99;
9701047 }
9711048
....@@ -1366,6 +1443,7 @@
13661443 toParent = LA.newMatrix();
13671444 fromParent = LA.newMatrix();
13681445 }
1446
+
13691447 LA.matCopy(other.toParent, toParent);
13701448 LA.matCopy(other.fromParent, fromParent);
13711449
....@@ -2387,6 +2465,15 @@
23872465 }
23882466 */
23892467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ if (objectUI != null)
2472
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2473
+ else
2474
+ //new Exception().printStackTrace();
2475
+ System.err.println("objectUI is null");
2476
+ }
23902477 }
23912478
23922479 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2428,6 +2515,14 @@
24282515 {
24292516 editWindow.refreshContents();
24302517 }
2518
+ else
2519
+ {
2520
+ if (manipWindow != null)
2521
+ {
2522
+ manipWindow.refreshContents();
2523
+ }
2524
+ }
2525
+
24312526 //if (parent != null)
24322527 //parent.refreshEditWindow();
24332528 }
....@@ -2507,7 +2602,8 @@
25072602 private static final int editSelf = 1;
25082603 private static final int editChild = 2;
25092604
2510
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
25112607 {
25122608 if (level == 0)
25132609 {
....@@ -2515,7 +2611,8 @@
25152611 return;
25162612
25172613 Object3D selectee;
2518
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2614
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2615
+ level + 1))
25192616 {
25202617 selectee = (Object3D) e.nextElement();
25212618 }
....@@ -2523,19 +2620,22 @@
25232620 } else
25242621 {
25252622 //super.
2526
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
25272625 }
25282626 }
25292627
2530
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
25312630 {
25322631 doSomething = 0;
25332632 if (level == 0)
25342633 {
2535
- return doParentClick(info);
2634
+ return doParentClick(); //info);
25362635 }
25372636 if (//super.
2538
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
25392639 {
25402640 doSomething = 1;
25412641 return true;
....@@ -2545,7 +2645,7 @@
25452645 }
25462646 }
25472647
2548
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
25492649 {
25502650 if (selection == null)
25512651 {
....@@ -2558,7 +2658,8 @@
25582658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25592659 {
25602660 Object3D selectee = (Object3D) e.nextElement();
2561
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
25622663 {
25632664 childToDrag = selectee;
25642665 doSomething = 2;
....@@ -2570,13 +2671,15 @@
25702671 return retval;
25712672 }
25722673
2573
- void doEditDrag(ClickInfo info, boolean opposite)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
25742676 {
25752677 switch (doSomething)
25762678 {
25772679 case 1: // '\001'
25782680 //super.
2579
- doEditDrag0(info, opposite);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
25802683 break;
25812684
25822685 case 2: // '\002'
....@@ -2589,11 +2692,13 @@
25892692 {
25902693 //sel.hitSomething = childToDrag.hitSomething;
25912694 //childToDrag.doEditDrag(info);
2592
- sel.doEditDrag(info, opposite);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
25932697 } else
25942698 {
25952699 //super.
2596
- doEditDrag0(info, opposite);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
25972702 }
25982703 }
25992704 break;
....@@ -2611,6 +2716,9 @@
26112716 {
26122717 deselectAll();
26132718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
26142722 ClickInfo newInfo = new ClickInfo();
26152723 newInfo.flags = info.flags;
26162724 newInfo.bounds = info.bounds;
....@@ -3058,7 +3166,7 @@
30583166 {
30593167 if (bRep != null)
30603168 {
3061
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30623170 Touch();
30633171 }
30643172 }
....@@ -4958,6 +5066,14 @@
49585066 }
49595067 }
49605068
5069
+ ObjEditor GetWindow()
5070
+ {
5071
+ if (editWindow != null)
5072
+ return editWindow;
5073
+
5074
+ return manipWindow;
5075
+ }
5076
+
49615077 cTreePath Select(int indexcount, boolean deselect)
49625078 {
49635079 if (hide || dontselect)
....@@ -4994,10 +5110,11 @@
49945110 if (leaf != null)
49955111 {
49965112 cTreePath tp = new cTreePath(this, leaf);
4997
- if (editWindow != null)
5113
+ ObjEditor window = GetWindow();
5114
+ if (window != null)
49985115 {
49995116 //System.out.println("editWindow = " + editWindow + " vs " + this);
5000
- editWindow.Select(tp, deselect, true);
5117
+ window.Select(tp, deselect, true);
50015118 }
50025119
50035120 return tp;
....@@ -5014,6 +5131,7 @@
50145131
50155132 if (child == null)
50165133 continue;
5134
+
50175135 if (child.HasTransparency() && child.size() != 0)
50185136 {
50195137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5023,9 +5141,10 @@
50235141 if (leaf != null)
50245142 {
50255143 cTreePath tp = new cTreePath(this, leaf);
5026
- if (editWindow != null)
5144
+ ObjEditor window = GetWindow();
5145
+ if (window != null)
50275146 {
5028
- editWindow.Select(tp, deselect, true);
5147
+ window.Select(tp, deselect, true);
50295148 }
50305149
50315150 return tp;
....@@ -5350,6 +5469,51 @@
53505469 blockloop = false;
53515470 }
53525471
5472
+ void ResetSelectable()
5473
+ {
5474
+ if (blockloop)
5475
+ return;
5476
+
5477
+ blockloop = true;
5478
+
5479
+ keepdontselect = dontselect;
5480
+ dontselect = true;
5481
+
5482
+ Object3D child;
5483
+ int nb = Size();
5484
+ for (int i = 0; i < nb; i++)
5485
+ {
5486
+ child = (Object3D) get(i);
5487
+ if (child == null)
5488
+ continue;
5489
+ child.ResetSelectable();
5490
+ }
5491
+
5492
+ blockloop = false;
5493
+ }
5494
+
5495
+ void RestoreSelectable()
5496
+ {
5497
+ if (blockloop)
5498
+ return;
5499
+
5500
+ blockloop = true;
5501
+
5502
+ dontselect = keepdontselect;
5503
+
5504
+ Object3D child;
5505
+ int nb = Size();
5506
+ for (int i = 0; i < nb; i++)
5507
+ {
5508
+ child = (Object3D) get(i);
5509
+ if (child == null)
5510
+ continue;
5511
+ child.RestoreSelectable();
5512
+ }
5513
+
5514
+ blockloop = false;
5515
+ }
5516
+
53535517 boolean IsSelected()
53545518 {
53555519 if (parent == null)
....@@ -5410,6 +5574,11 @@
54105574 if (fullname == null)
54115575 return "";
54125576
5577
+ if (fullname.pigment != null)
5578
+ {
5579
+ return fullname.pigment;
5580
+ }
5581
+
54135582 // System.out.println("Fullname = " + fullname);
54145583
54155584 // Does not work on Windows due to C:
....@@ -5422,7 +5591,7 @@
54225591
54235592 if (split.length == 0)
54245593 {
5425
- return "";
5594
+ return fullname.pigment = "";
54265595 }
54275596
54285597 if (split.length <= 2)
....@@ -5430,22 +5599,27 @@
54305599 if (fullname.name.endsWith(":"))
54315600 {
54325601 // Windows
5433
- return fullname.name.substring(0, fullname.name.length()-1);
5602
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54345603 }
54355604
5436
- return split[0];
5605
+ return fullname.pigment = split[0];
54375606 }
54385607
54395608 // Windows
54405609 assert(split.length == 4);
54415610
5442
- return split[0] + ":" + split[1];
5611
+ return fullname.pigment = split[0] + ":" + split[1];
54435612 }
54445613
54455614 static String GetBump(cTexture fullname)
54465615 {
54475616 if (fullname == null)
54485617 return "";
5618
+
5619
+ if (fullname.bump != null)
5620
+ {
5621
+ return fullname.bump;
5622
+ }
54495623
54505624 // System.out.println("Fullname = " + fullname);
54515625 // Does not work on Windows due to C:
....@@ -5457,12 +5631,12 @@
54575631
54585632 if (split.length == 0)
54595633 {
5460
- return "";
5634
+ return fullname.bump = "";
54615635 }
54625636
54635637 if (split.length == 1)
54645638 {
5465
- return "";
5639
+ return fullname.bump = "";
54665640 }
54675641
54685642 if (split.length == 2)
....@@ -5470,16 +5644,16 @@
54705644 if (fullname.name.endsWith(":"))
54715645 {
54725646 // Windows
5473
- return "";
5647
+ return fullname.bump = "";
54745648 }
54755649
5476
- return split[1];
5650
+ return fullname.bump = split[1];
54775651 }
54785652
54795653 // Windows
54805654 assert(split.length == 4);
54815655
5482
- return split[2] + ":" + split[3];
5656
+ return fullname.bump = split[2] + ":" + split[3];
54835657 }
54845658
54855659 String GetPigmentTexture()
....@@ -5562,6 +5736,9 @@
55625736 texname = "";
55635737
55645738 GetTextures().name = texname + ":" + GetBump(GetTextures());
5739
+
5740
+ GetTextures().pigment = null;
5741
+
55655742 Touch();
55665743 }
55675744
....@@ -5635,6 +5812,8 @@
56355812
56365813 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56375814
5815
+ GetTextures().bump = null;
5816
+
56385817 Touch();
56395818 }
56405819
....@@ -5655,6 +5834,38 @@
56555834
56565835 blockloop = true;
56575836 child.ResetBumpTexture();
5837
+ blockloop = false;
5838
+ }
5839
+ }
5840
+
5841
+ void EmbedTextures(boolean embed)
5842
+ {
5843
+ if (blockloop)
5844
+ return;
5845
+
5846
+ //if (GetTextures() != null)
5847
+ if (embed)
5848
+ CameraPane.EmbedTextures(GetTextures());
5849
+ else
5850
+ {
5851
+ GetTextures().pigmentdata = null;
5852
+ GetTextures().bumpdata = null;
5853
+ GetTextures().pw = 0;
5854
+ GetTextures().ph = 0;
5855
+ GetTextures().bw = 0;
5856
+ GetTextures().bh = 0;
5857
+ }
5858
+
5859
+ int nb = Size();
5860
+ for (int i = 0; i < nb; i++)
5861
+ {
5862
+ Object3D child = (Object3D) get(i);
5863
+
5864
+ if (child == null)
5865
+ continue;
5866
+
5867
+ blockloop = true;
5868
+ child.EmbedTextures(embed);
56585869 blockloop = false;
56595870 }
56605871 }
....@@ -5745,8 +5956,10 @@
57455956 if (support != null)
57465957 support = support;
57475958
5748
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5749
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5959
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5960
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5961
+
5962
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57505963
57515964 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57525965 {
....@@ -5756,8 +5969,9 @@
57565969 // usecalllists &= !(parent instanceof RandomNode);
57575970 // usecalllists = false;
57585971
5759
- if (GetBRep() != null)
5760
- usecalllists = usecalllists;
5972
+ if (display.DrawMode() == display.SHADOW)
5973
+ //GetBRep() != null)
5974
+ usecalllists = !!usecalllists;
57615975 //System.out.println("draw " + this);
57625976 //new Exception().printStackTrace();
57635977
....@@ -5767,7 +5981,7 @@
57675981
57685982 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57695983 //(touched || (bRep != null && bRep.displaylist <= 0)))
5770
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5984
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57715985 {
57725986 Globals.lighttouched = true;
57735987 } // all panes...
....@@ -5779,7 +5993,7 @@
57795993 if (!(this instanceof Composite))
57805994 touched = false;
57815995 //if (displaylist == -1 && usecalllists)
5782
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5996
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57835997 {
57845998 bRep.displaylist = display.GenList();
57855999 assert(bRep.displaylist != 0);
....@@ -5790,7 +6004,7 @@
57906004
57916005 //System.out.println("\tnew list " + list);
57926006 //gl.glDrawBuffer(gl.GL_NONE);
5793
- if (usecalllists)
6007
+ if (usecalllists && bRep.displaylist > 0)
57946008 {
57956009 // System.err.println("new list " + bRep.displaylist + " for " + this);
57966010 display.NewList(bRep.displaylist);
....@@ -5799,7 +6013,7 @@
57996013 CallList(display, root, selected, blocked);
58006014
58016015 // compiled = true;
5802
- if (usecalllists)
6016
+ if (usecalllists && bRep.displaylist > 0)
58036017 {
58046018 // System.err.println("end list " + bRep.displaylist + " for " + this);
58056019 display.EndList();
....@@ -5899,6 +6113,7 @@
58996113 if (GetBRep() != null)
59006114 {
59016115 display.NextIndex();
6116
+
59026117 // vertex color conflict : gl.glCallList(list);
59036118 DrawNode(display, root, selected);
59046119 if (this instanceof BezierPatch)
....@@ -6359,6 +6574,11 @@
63596574 // dec 2012
63606575 new Exception().printStackTrace();
63616576 return;
6577
+ }
6578
+
6579
+ if (dontselect)
6580
+ {
6581
+ //bRep.GenerateNormalsMINE();
63626582 }
63636583
63646584 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7144,20 +7364,23 @@
71447364 }
71457365 }
71467366
7147
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7367
+ static ClickInfo clickInfo = new ClickInfo();
7368
+
7369
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7370
+ Point outPt, Rectangle outRec)
71487371 {
7149
- int hc = info.bounds.x + info.bounds.width / 2;
7150
- int vc = info.bounds.y + info.bounds.height / 2;
7151
- double[][] toscreen = info.toScreen;
7372
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7373
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7374
+ double[][] toscreen = clickInfo.toScreen;
71527375 if (toscreen == null)
71537376 {
7154
- toscreen = new Camera(info.camera.viewCode).toScreen;
7377
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71557378 }
71567379 cVector vec = in;
71577380 LA.xformPos(in, toscreen, in);
71587381 //System.out.println("Distance = " + info.camera.Distance());
7159
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7160
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7382
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7383
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71617384 outPt.x = hc + (int) vec.x;
71627385 outPt.y = vc - (int) vec.y;
71637386 outRec.x = outPt.x - 3;
....@@ -7165,15 +7388,18 @@
71657388 outRec.width = outRec.height = 6;
71667389 }
71677390
7168
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7391
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7392
+ )
71697393 {
71707394 Point pt = new Point(0, 0);
71717395 Rectangle rec = new Rectangle();
7172
- calcHotSpot(in, info, pt, rec);
7396
+ calcHotSpot(in, //clickInfo,
7397
+ pt, rec);
71737398 return rec;
71747399 }
71757400
7176
- void drawEditHandles0(ClickInfo info, int level)
7401
+ void drawEditHandles0(//ClickInfo clickInfo,
7402
+ int level)
71777403 {
71787404 if (level == 0)
71797405 {
....@@ -7182,16 +7408,19 @@
71827408 {
71837409 cVector origin = new cVector();
71847410 //LA.xformPos(origin, toParent, origin);
7185
- Rectangle spot = calcHotSpot(origin, info);
7411
+ if (this.clickInfo == null)
7412
+ this.clickInfo = new ClickInfo();
7413
+
7414
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71867415 Rectangle boundary = new Rectangle();
71877416 boundary.x = spot.x - 30;
71887417 boundary.y = spot.y - 30;
71897418 boundary.width = spot.width + 60;
71907419 boundary.height = spot.height + 60;
7191
- info.g.setColor(Color.red);
7420
+ clickInfo.g.setColor(Color.red);
71927421 int spotw = spot.x + spot.width;
71937422 int spoth = spot.y + spot.height;
7194
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71957424 // if (CameraPane.Xmin > spot.x)
71967425 // {
71977426 // CameraPane.Xmin = spot.x;
....@@ -7208,11 +7437,6 @@
72087437 // {
72097438 // CameraPane.Ymax = spoth;
72107439 // }
7211
- spot.translate(32, 32);
7212
- spotw = spot.x + spot.width;
7213
- spoth = spot.y + spot.height;
7214
- info.g.setColor(Color.cyan);
7215
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72167440 // if (CameraPane.Xmin > spot.x)
72177441 // {
72187442 // CameraPane.Xmin = spot.x;
....@@ -7231,10 +7455,15 @@
72317455 // }
72327456 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72337457 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7234
- spot.translate(0, -32);
7235
- info.g.setColor(Color.yellow);
7236
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7237
- info.g.setColor(Color.green);
7458
+ spot.translate(32, 0);
7459
+ clickInfo.g.setColor(Color.yellow);
7460
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7461
+
7462
+ spot.translate(32, 64);
7463
+ spotw = spot.x + spot.width;
7464
+ spoth = spot.y + spot.height;
7465
+ clickInfo.g.setColor(Color.cyan);
7466
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72387467 // if (CameraPane.Xmin > spot.x)
72397468 // {
72407469 // CameraPane.Xmin = spot.x;
....@@ -7251,8 +7480,9 @@
72517480 // {
72527481 // CameraPane.Ymax = spoth;
72537482 // }
7254
- info.g.drawArc(boundary.x, boundary.y,
7255
- boundary.width, boundary.height, 0, 360);
7483
+ clickInfo.g.setColor(Color.green);
7484
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7485
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72567486 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72577487 // if (CameraPane.Xmin > boundary.x)
72587488 // {
....@@ -7274,7 +7504,8 @@
72747504 }
72757505 }
72767506
7277
- boolean doEditClick0(ClickInfo info, int level)
7507
+ boolean doEditClick0(//ClickInfo clickInfo,
7508
+ int level)
72787509 {
72797510 if (level == 0)
72807511 {
....@@ -7283,8 +7514,8 @@
72837514
72847515 boolean retval = false;
72857516
7286
- startX = info.x;
7287
- startY = info.y;
7517
+ startX = clickInfo.x;
7518
+ startY = clickInfo.y;
72887519
72897520 hitSomething = -1;
72907521 cVector origin = new cVector();
....@@ -7294,22 +7525,53 @@
72947525 {
72957526 centerPt = new Point(0, 0);
72967527 }
7297
- calcHotSpot(origin, info, centerPt, spot);
7298
- if (spot.contains(info.x, info.y))
7528
+ calcHotSpot(origin, //info,
7529
+ centerPt, spot);
7530
+ if (spot.contains(clickInfo.x, clickInfo.y))
72997531 {
73007532 hitSomething = hitCenter;
73017533 retval = true;
73027534 }
73037535 spot.translate(32, 0);
7304
- if (spot.contains(info.x, info.y))
7536
+ if (spot.contains(clickInfo.x, clickInfo.y))
73057537 {
73067538 hitSomething = hitRotate;
73077539 retval = true;
73087540 }
73097541 spot.translate(0, 32);
7310
- if (spot.contains(info.x, info.y))
7542
+ spot.translate(32, 0);
7543
+ spot.translate(0, 32);
7544
+ if (spot.contains(clickInfo.x, clickInfo.y))
73117545 {
73127546 hitSomething = hitScale;
7547
+
7548
+ double scale = 0.005f * clickInfo.camera.Distance();
7549
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7550
+ double sign = 1;
7551
+ if (hScale < 0)
7552
+ {
7553
+ sign = -1;
7554
+ }
7555
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7556
+ if (hScale < 0.01)
7557
+ {
7558
+ //hScale = 0.01;
7559
+ }
7560
+
7561
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7562
+ sign = 1;
7563
+ if (vScale < 0)
7564
+ {
7565
+ sign = -1;
7566
+ }
7567
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7568
+ if (vScale < 0.01)
7569
+ {
7570
+ //vScale = 0.01;
7571
+ }
7572
+
7573
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7574
+
73137575 retval = true;
73147576 }
73157577
....@@ -7319,7 +7581,7 @@
73197581 }
73207582
73217583 //System.out.println("info.modifiers = " + info.modifiers);
7322
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7584
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73237585 //System.out.println("modified = " + modified);
73247586 //new Exception().printStackTrace();
73257587 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7347,7 +7609,8 @@
73477609 return true;
73487610 }
73497611
7350
- void doEditDrag0(ClickInfo info, boolean opposite)
7612
+ void doEditDrag0(//ClickInfo info,
7613
+ boolean opposite)
73517614 {
73527615 if (hitSomething == 0)
73537616 {
....@@ -7361,7 +7624,7 @@
73617624
73627625 //System.out.println("hitSomething = " + hitSomething);
73637626
7364
- double scale = 0.005f * info.camera.Distance();
7627
+ double scale = 0.005f * clickInfo.camera.Distance();
73657628
73667629 cVector xlate = new cVector();
73677630 //cVector xlate2 = new cVector();
....@@ -7395,8 +7658,8 @@
73957658 toParent[3][i] = xlate.get(i);
73967659 LA.matInvert(toParent, fromParent);
73977660 */
7398
- cVector delta = LA.newVector(0, 0, startY - info.y);
7399
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7661
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74007663
74017664 LA.matCopy(startMat, toParent);
74027665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7405,7 +7668,7 @@
74057668 } else
74067669 {
74077670 //LA.xformDir(delta, info.camera.fromScreen, delta);
7408
- cVector up = new cVector(info.camera.up);
7671
+ cVector up = new cVector(clickInfo.camera.up);
74097672 cVector away = new cVector();
74107673 //cVector right2 = new cVector();
74117674 //LA.vecCross(up, cVector.Z, right);
....@@ -7422,19 +7685,19 @@
74227685 LA.xformDir(up, ClickInfo.matbuffer, up);
74237686 // if (!CameraPane.LOCALTRANSFORM)
74247687 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7425
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7688
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74267689 // if (!CameraPane.LOCALTRANSFORM)
74277690 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74287691 //LA.vecCross(up, cVector.Z, right2);
74297692
7430
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7693
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74317694
74327695 //System.out.println("DELTA0 = " + delta);
74337696 //System.out.println("AWAY = " + info.camera.away);
74347697 //System.out.println("UP = " + info.camera.up);
74357698 if (away.z > 0)
74367699 {
7437
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7700
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74387701 {
74397702 delta.x = -delta.x;
74407703 } else
....@@ -7449,7 +7712,7 @@
74497712 //System.out.println("DELTA1 = " + delta);
74507713 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74517714 //System.out.println("DELTA2 = " + delta);
7452
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7715
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74537716 LA.matCopy(startMat, toParent);
74547717 //System.out.println("DELTA3 = " + delta);
74557718 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7459,8 +7722,8 @@
74597722 break;
74607723
74617724 case hitRotate: // rotate
7462
- int dx = info.x - centerPt.x;
7463
- int dy = -(info.y - centerPt.y);
7725
+ int dx = clickInfo.x - centerPt.x;
7726
+ int dy = -(clickInfo.y - centerPt.y);
74647727 double angle = (double) Math.atan2(dx, dy);
74657728 angle = -(1.570796 - angle);
74667729
....@@ -7483,7 +7746,7 @@
74837746 }
74847747 /**/
74857748
7486
- switch (info.pane.RenderCamera().viewCode)
7749
+ switch (clickInfo.pane.RenderCamera().viewCode)
74877750 {
74887751 case 1: // '\001'
74897752 LA.matZRotate(toParent, angle);
....@@ -7510,7 +7773,7 @@
75107773 break;
75117774
75127775 case hitScale: // scale
7513
- double hScale = (double) (info.x - centerPt.x) / 32;
7776
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75147777 double sign = 1;
75157778 if (hScale < 0)
75167779 {
....@@ -7522,7 +7785,7 @@
75227785 //hScale = 0.01;
75237786 }
75247787
7525
- double vScale = (double) (info.y - centerPt.y) / 32;
7788
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75267789 sign = 1;
75277790 if (vScale < 0)
75287791 {
....@@ -7533,6 +7796,7 @@
75337796 {
75347797 //vScale = 0.01;
75357798 }
7799
+
75367800 LA.matCopy(startMat, toParent);
75377801 /**/
75387802 for (int i = 0; i < 3; i++)
....@@ -7542,14 +7806,14 @@
75427806 }
75437807 /**/
75447808
7545
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7809
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75467810
75477811 if (totalScale < 0.01)
75487812 {
75497813 totalScale = 0.01;
75507814 }
75517815
7552
- switch (info.pane.RenderCamera().viewCode)
7816
+ switch (clickInfo.pane.RenderCamera().viewCode)
75537817 {
75547818 case 3: // '\001'
75557819 if (modified || opposite)
....@@ -7616,7 +7880,7 @@
76167880 } // NEW ...
76177881
76187882
7619
- info.pane.repaint();
7883
+ clickInfo.pane.repaint();
76207884 }
76217885
76227886 boolean overflow = false;
....@@ -7796,6 +8060,10 @@
77968060 editWindow = null;
77978061 } // ?
77988062 }
8063
+ else
8064
+ {
8065
+ //editWindow.closeUI();
8066
+ }
77998067 }
78008068
78018069 boolean root; // patch for edit windows
....@@ -7953,6 +8221,10 @@
79538221 }
79548222
79558223 transient ObjEditor editWindow;
8224
+ transient ObjEditor manipWindow;
8225
+
8226
+ transient boolean pinned;
8227
+
79568228 transient ObjectUI objectUI;
79578229 public static int povDepth = 0;
79588230 private static cVector tbMin = new cVector();