Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
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
....@@ -2390,6 +2468,11 @@
23902468 else
23912469 {
23922470 //((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");
23932476 }
23942477 }
23952478
....@@ -2432,6 +2515,14 @@
24322515 {
24332516 editWindow.refreshContents();
24342517 }
2518
+ else
2519
+ {
2520
+ if (manipWindow != null)
2521
+ {
2522
+ manipWindow.refreshContents();
2523
+ }
2524
+ }
2525
+
24352526 //if (parent != null)
24362527 //parent.refreshEditWindow();
24372528 }
....@@ -2511,7 +2602,8 @@
25112602 private static final int editSelf = 1;
25122603 private static final int editChild = 2;
25132604
2514
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
25152607 {
25162608 if (level == 0)
25172609 {
....@@ -2519,7 +2611,8 @@
25192611 return;
25202612
25212613 Object3D selectee;
2522
- 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))
25232616 {
25242617 selectee = (Object3D) e.nextElement();
25252618 }
....@@ -2527,19 +2620,22 @@
25272620 } else
25282621 {
25292622 //super.
2530
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
25312625 }
25322626 }
25332627
2534
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
25352630 {
25362631 doSomething = 0;
25372632 if (level == 0)
25382633 {
2539
- return doParentClick(info);
2634
+ return doParentClick(); //info);
25402635 }
25412636 if (//super.
2542
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
25432639 {
25442640 doSomething = 1;
25452641 return true;
....@@ -2549,7 +2645,7 @@
25492645 }
25502646 }
25512647
2552
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
25532649 {
25542650 if (selection == null)
25552651 {
....@@ -2562,7 +2658,8 @@
25622658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25632659 {
25642660 Object3D selectee = (Object3D) e.nextElement();
2565
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
25662663 {
25672664 childToDrag = selectee;
25682665 doSomething = 2;
....@@ -2574,13 +2671,15 @@
25742671 return retval;
25752672 }
25762673
2577
- void doEditDrag(ClickInfo info, boolean opposite)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
25782676 {
25792677 switch (doSomething)
25802678 {
25812679 case 1: // '\001'
25822680 //super.
2583
- doEditDrag0(info, opposite);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
25842683 break;
25852684
25862685 case 2: // '\002'
....@@ -2593,11 +2692,13 @@
25932692 {
25942693 //sel.hitSomething = childToDrag.hitSomething;
25952694 //childToDrag.doEditDrag(info);
2596
- sel.doEditDrag(info, opposite);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
25972697 } else
25982698 {
25992699 //super.
2600
- doEditDrag0(info, opposite);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
26012702 }
26022703 }
26032704 break;
....@@ -2615,6 +2716,9 @@
26152716 {
26162717 deselectAll();
26172718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
26182722 ClickInfo newInfo = new ClickInfo();
26192723 newInfo.flags = info.flags;
26202724 newInfo.bounds = info.bounds;
....@@ -3062,7 +3166,7 @@
30623166 {
30633167 if (bRep != null)
30643168 {
3065
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30663170 Touch();
30673171 }
30683172 }
....@@ -4962,6 +5066,14 @@
49625066 }
49635067 }
49645068
5069
+ ObjEditor GetWindow()
5070
+ {
5071
+ if (editWindow != null)
5072
+ return editWindow;
5073
+
5074
+ return manipWindow;
5075
+ }
5076
+
49655077 cTreePath Select(int indexcount, boolean deselect)
49665078 {
49675079 if (hide || dontselect)
....@@ -4998,10 +5110,11 @@
49985110 if (leaf != null)
49995111 {
50005112 cTreePath tp = new cTreePath(this, leaf);
5001
- if (editWindow != null)
5113
+ ObjEditor window = GetWindow();
5114
+ if (window != null)
50025115 {
50035116 //System.out.println("editWindow = " + editWindow + " vs " + this);
5004
- editWindow.Select(tp, deselect, true);
5117
+ window.Select(tp, deselect, true);
50055118 }
50065119
50075120 return tp;
....@@ -5018,6 +5131,7 @@
50185131
50195132 if (child == null)
50205133 continue;
5134
+
50215135 if (child.HasTransparency() && child.size() != 0)
50225136 {
50235137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5027,9 +5141,10 @@
50275141 if (leaf != null)
50285142 {
50295143 cTreePath tp = new cTreePath(this, leaf);
5030
- if (editWindow != null)
5144
+ ObjEditor window = GetWindow();
5145
+ if (window != null)
50315146 {
5032
- editWindow.Select(tp, deselect, true);
5147
+ window.Select(tp, deselect, true);
50335148 }
50345149
50355150 return tp;
....@@ -5354,6 +5469,51 @@
53545469 blockloop = false;
53555470 }
53565471
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
+
53575517 boolean IsSelected()
53585518 {
53595519 if (parent == null)
....@@ -5414,6 +5574,11 @@
54145574 if (fullname == null)
54155575 return "";
54165576
5577
+ if (fullname.pigment != null)
5578
+ {
5579
+ return fullname.pigment;
5580
+ }
5581
+
54175582 // System.out.println("Fullname = " + fullname);
54185583
54195584 // Does not work on Windows due to C:
....@@ -5426,7 +5591,7 @@
54265591
54275592 if (split.length == 0)
54285593 {
5429
- return "";
5594
+ return fullname.pigment = "";
54305595 }
54315596
54325597 if (split.length <= 2)
....@@ -5434,22 +5599,27 @@
54345599 if (fullname.name.endsWith(":"))
54355600 {
54365601 // Windows
5437
- return fullname.name.substring(0, fullname.name.length()-1);
5602
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54385603 }
54395604
5440
- return split[0];
5605
+ return fullname.pigment = split[0];
54415606 }
54425607
54435608 // Windows
54445609 assert(split.length == 4);
54455610
5446
- return split[0] + ":" + split[1];
5611
+ return fullname.pigment = split[0] + ":" + split[1];
54475612 }
54485613
54495614 static String GetBump(cTexture fullname)
54505615 {
54515616 if (fullname == null)
54525617 return "";
5618
+
5619
+ if (fullname.bump != null)
5620
+ {
5621
+ return fullname.bump;
5622
+ }
54535623
54545624 // System.out.println("Fullname = " + fullname);
54555625 // Does not work on Windows due to C:
....@@ -5461,12 +5631,12 @@
54615631
54625632 if (split.length == 0)
54635633 {
5464
- return "";
5634
+ return fullname.bump = "";
54655635 }
54665636
54675637 if (split.length == 1)
54685638 {
5469
- return "";
5639
+ return fullname.bump = "";
54705640 }
54715641
54725642 if (split.length == 2)
....@@ -5474,16 +5644,16 @@
54745644 if (fullname.name.endsWith(":"))
54755645 {
54765646 // Windows
5477
- return "";
5647
+ return fullname.bump = "";
54785648 }
54795649
5480
- return split[1];
5650
+ return fullname.bump = split[1];
54815651 }
54825652
54835653 // Windows
54845654 assert(split.length == 4);
54855655
5486
- return split[2] + ":" + split[3];
5656
+ return fullname.bump = split[2] + ":" + split[3];
54875657 }
54885658
54895659 String GetPigmentTexture()
....@@ -5566,6 +5736,9 @@
55665736 texname = "";
55675737
55685738 GetTextures().name = texname + ":" + GetBump(GetTextures());
5739
+
5740
+ GetTextures().pigment = null;
5741
+
55695742 Touch();
55705743 }
55715744
....@@ -5639,6 +5812,8 @@
56395812
56405813 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56415814
5815
+ GetTextures().bump = null;
5816
+
56425817 Touch();
56435818 }
56445819
....@@ -5659,6 +5834,38 @@
56595834
56605835 blockloop = true;
56615836 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);
56625869 blockloop = false;
56635870 }
56645871 }
....@@ -5749,8 +5956,10 @@
57495956 if (support != null)
57505957 support = support;
57515958
5752
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5753
- 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.
57545963
57555964 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57565965 {
....@@ -5760,8 +5969,9 @@
57605969 // usecalllists &= !(parent instanceof RandomNode);
57615970 // usecalllists = false;
57625971
5763
- if (GetBRep() != null)
5764
- usecalllists = usecalllists;
5972
+ if (display.DrawMode() == display.SHADOW)
5973
+ //GetBRep() != null)
5974
+ usecalllists = !!usecalllists;
57655975 //System.out.println("draw " + this);
57665976 //new Exception().printStackTrace();
57675977
....@@ -5771,7 +5981,7 @@
57715981
57725982 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57735983 //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5984
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57755985 {
57765986 Globals.lighttouched = true;
57775987 } // all panes...
....@@ -5783,7 +5993,7 @@
57835993 if (!(this instanceof Composite))
57845994 touched = false;
57855995 //if (displaylist == -1 && usecalllists)
5786
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5996
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57875997 {
57885998 bRep.displaylist = display.GenList();
57895999 assert(bRep.displaylist != 0);
....@@ -5794,7 +6004,7 @@
57946004
57956005 //System.out.println("\tnew list " + list);
57966006 //gl.glDrawBuffer(gl.GL_NONE);
5797
- if (usecalllists)
6007
+ if (usecalllists && bRep.displaylist > 0)
57986008 {
57996009 // System.err.println("new list " + bRep.displaylist + " for " + this);
58006010 display.NewList(bRep.displaylist);
....@@ -5803,7 +6013,7 @@
58036013 CallList(display, root, selected, blocked);
58046014
58056015 // compiled = true;
5806
- if (usecalllists)
6016
+ if (usecalllists && bRep.displaylist > 0)
58076017 {
58086018 // System.err.println("end list " + bRep.displaylist + " for " + this);
58096019 display.EndList();
....@@ -5903,6 +6113,7 @@
59036113 if (GetBRep() != null)
59046114 {
59056115 display.NextIndex();
6116
+
59066117 // vertex color conflict : gl.glCallList(list);
59076118 DrawNode(display, root, selected);
59086119 if (this instanceof BezierPatch)
....@@ -7153,20 +7364,23 @@
71537364 }
71547365 }
71557366
7156
- 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)
71577371 {
7158
- int hc = info.bounds.x + info.bounds.width / 2;
7159
- int vc = info.bounds.y + info.bounds.height / 2;
7160
- 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;
71617375 if (toscreen == null)
71627376 {
7163
- toscreen = new Camera(info.camera.viewCode).toScreen;
7377
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71647378 }
71657379 cVector vec = in;
71667380 LA.xformPos(in, toscreen, in);
71677381 //System.out.println("Distance = " + info.camera.Distance());
7168
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7169
- 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();
71707384 outPt.x = hc + (int) vec.x;
71717385 outPt.y = vc - (int) vec.y;
71727386 outRec.x = outPt.x - 3;
....@@ -7174,15 +7388,18 @@
71747388 outRec.width = outRec.height = 6;
71757389 }
71767390
7177
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7391
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7392
+ )
71787393 {
71797394 Point pt = new Point(0, 0);
71807395 Rectangle rec = new Rectangle();
7181
- calcHotSpot(in, info, pt, rec);
7396
+ calcHotSpot(in, //clickInfo,
7397
+ pt, rec);
71827398 return rec;
71837399 }
71847400
7185
- void drawEditHandles0(ClickInfo info, int level)
7401
+ void drawEditHandles0(//ClickInfo clickInfo,
7402
+ int level)
71867403 {
71877404 if (level == 0)
71887405 {
....@@ -7191,16 +7408,19 @@
71917408 {
71927409 cVector origin = new cVector();
71937410 //LA.xformPos(origin, toParent, origin);
7194
- Rectangle spot = calcHotSpot(origin, info);
7411
+ if (this.clickInfo == null)
7412
+ this.clickInfo = new ClickInfo();
7413
+
7414
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71957415 Rectangle boundary = new Rectangle();
71967416 boundary.x = spot.x - 30;
71977417 boundary.y = spot.y - 30;
71987418 boundary.width = spot.width + 60;
71997419 boundary.height = spot.height + 60;
7200
- info.g.setColor(Color.red);
7420
+ clickInfo.g.setColor(Color.red);
72017421 int spotw = spot.x + spot.width;
72027422 int spoth = spot.y + spot.height;
7203
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72047424 // if (CameraPane.Xmin > spot.x)
72057425 // {
72067426 // CameraPane.Xmin = spot.x;
....@@ -7217,11 +7437,6 @@
72177437 // {
72187438 // CameraPane.Ymax = spoth;
72197439 // }
7220
- spot.translate(32, 32);
7221
- spotw = spot.x + spot.width;
7222
- spoth = spot.y + spot.height;
7223
- info.g.setColor(Color.cyan);
7224
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72257440 // if (CameraPane.Xmin > spot.x)
72267441 // {
72277442 // CameraPane.Xmin = spot.x;
....@@ -7240,10 +7455,15 @@
72407455 // }
72417456 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72427457 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7243
- spot.translate(0, -32);
7244
- info.g.setColor(Color.yellow);
7245
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
- 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);
72477467 // if (CameraPane.Xmin > spot.x)
72487468 // {
72497469 // CameraPane.Xmin = spot.x;
....@@ -7260,8 +7480,9 @@
72607480 // {
72617481 // CameraPane.Ymax = spoth;
72627482 // }
7263
- info.g.drawArc(boundary.x, boundary.y,
7264
- 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);
72657486 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72667487 // if (CameraPane.Xmin > boundary.x)
72677488 // {
....@@ -7283,7 +7504,8 @@
72837504 }
72847505 }
72857506
7286
- boolean doEditClick0(ClickInfo info, int level)
7507
+ boolean doEditClick0(//ClickInfo clickInfo,
7508
+ int level)
72877509 {
72887510 if (level == 0)
72897511 {
....@@ -7292,8 +7514,8 @@
72927514
72937515 boolean retval = false;
72947516
7295
- startX = info.x;
7296
- startY = info.y;
7517
+ startX = clickInfo.x;
7518
+ startY = clickInfo.y;
72977519
72987520 hitSomething = -1;
72997521 cVector origin = new cVector();
....@@ -7303,22 +7525,53 @@
73037525 {
73047526 centerPt = new Point(0, 0);
73057527 }
7306
- calcHotSpot(origin, info, centerPt, spot);
7307
- if (spot.contains(info.x, info.y))
7528
+ calcHotSpot(origin, //info,
7529
+ centerPt, spot);
7530
+ if (spot.contains(clickInfo.x, clickInfo.y))
73087531 {
73097532 hitSomething = hitCenter;
73107533 retval = true;
73117534 }
73127535 spot.translate(32, 0);
7313
- if (spot.contains(info.x, info.y))
7536
+ if (spot.contains(clickInfo.x, clickInfo.y))
73147537 {
73157538 hitSomething = hitRotate;
73167539 retval = true;
73177540 }
73187541 spot.translate(0, 32);
7319
- 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))
73207545 {
73217546 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
+
73227575 retval = true;
73237576 }
73247577
....@@ -7328,7 +7581,7 @@
73287581 }
73297582
73307583 //System.out.println("info.modifiers = " + info.modifiers);
7331
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7584
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73327585 //System.out.println("modified = " + modified);
73337586 //new Exception().printStackTrace();
73347587 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7356,7 +7609,8 @@
73567609 return true;
73577610 }
73587611
7359
- void doEditDrag0(ClickInfo info, boolean opposite)
7612
+ void doEditDrag0(//ClickInfo info,
7613
+ boolean opposite)
73607614 {
73617615 if (hitSomething == 0)
73627616 {
....@@ -7370,7 +7624,7 @@
73707624
73717625 //System.out.println("hitSomething = " + hitSomething);
73727626
7373
- double scale = 0.005f * info.camera.Distance();
7627
+ double scale = 0.005f * clickInfo.camera.Distance();
73747628
73757629 cVector xlate = new cVector();
73767630 //cVector xlate2 = new cVector();
....@@ -7404,8 +7658,8 @@
74047658 toParent[3][i] = xlate.get(i);
74057659 LA.matInvert(toParent, fromParent);
74067660 */
7407
- cVector delta = LA.newVector(0, 0, startY - info.y);
7408
- 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);
74097663
74107664 LA.matCopy(startMat, toParent);
74117665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7414,7 +7668,7 @@
74147668 } else
74157669 {
74167670 //LA.xformDir(delta, info.camera.fromScreen, delta);
7417
- cVector up = new cVector(info.camera.up);
7671
+ cVector up = new cVector(clickInfo.camera.up);
74187672 cVector away = new cVector();
74197673 //cVector right2 = new cVector();
74207674 //LA.vecCross(up, cVector.Z, right);
....@@ -7431,19 +7685,19 @@
74317685 LA.xformDir(up, ClickInfo.matbuffer, up);
74327686 // if (!CameraPane.LOCALTRANSFORM)
74337687 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7434
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7688
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74357689 // if (!CameraPane.LOCALTRANSFORM)
74367690 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74377691 //LA.vecCross(up, cVector.Z, right2);
74387692
7439
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7693
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74407694
74417695 //System.out.println("DELTA0 = " + delta);
74427696 //System.out.println("AWAY = " + info.camera.away);
74437697 //System.out.println("UP = " + info.camera.up);
74447698 if (away.z > 0)
74457699 {
7446
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7700
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74477701 {
74487702 delta.x = -delta.x;
74497703 } else
....@@ -7458,7 +7712,7 @@
74587712 //System.out.println("DELTA1 = " + delta);
74597713 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74607714 //System.out.println("DELTA2 = " + delta);
7461
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7715
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74627716 LA.matCopy(startMat, toParent);
74637717 //System.out.println("DELTA3 = " + delta);
74647718 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7468,8 +7722,8 @@
74687722 break;
74697723
74707724 case hitRotate: // rotate
7471
- int dx = info.x - centerPt.x;
7472
- int dy = -(info.y - centerPt.y);
7725
+ int dx = clickInfo.x - centerPt.x;
7726
+ int dy = -(clickInfo.y - centerPt.y);
74737727 double angle = (double) Math.atan2(dx, dy);
74747728 angle = -(1.570796 - angle);
74757729
....@@ -7492,7 +7746,7 @@
74927746 }
74937747 /**/
74947748
7495
- switch (info.pane.RenderCamera().viewCode)
7749
+ switch (clickInfo.pane.RenderCamera().viewCode)
74967750 {
74977751 case 1: // '\001'
74987752 LA.matZRotate(toParent, angle);
....@@ -7519,7 +7773,7 @@
75197773 break;
75207774
75217775 case hitScale: // scale
7522
- double hScale = (double) (info.x - centerPt.x) / 32;
7776
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75237777 double sign = 1;
75247778 if (hScale < 0)
75257779 {
....@@ -7531,7 +7785,7 @@
75317785 //hScale = 0.01;
75327786 }
75337787
7534
- double vScale = (double) (info.y - centerPt.y) / 32;
7788
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75357789 sign = 1;
75367790 if (vScale < 0)
75377791 {
....@@ -7542,6 +7796,7 @@
75427796 {
75437797 //vScale = 0.01;
75447798 }
7799
+
75457800 LA.matCopy(startMat, toParent);
75467801 /**/
75477802 for (int i = 0; i < 3; i++)
....@@ -7551,14 +7806,14 @@
75517806 }
75527807 /**/
75537808
7554
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7809
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75557810
75567811 if (totalScale < 0.01)
75577812 {
75587813 totalScale = 0.01;
75597814 }
75607815
7561
- switch (info.pane.RenderCamera().viewCode)
7816
+ switch (clickInfo.pane.RenderCamera().viewCode)
75627817 {
75637818 case 3: // '\001'
75647819 if (modified || opposite)
....@@ -7625,7 +7880,7 @@
76257880 } // NEW ...
76267881
76277882
7628
- info.pane.repaint();
7883
+ clickInfo.pane.repaint();
76297884 }
76307885
76317886 boolean overflow = false;
....@@ -7966,6 +8221,10 @@
79668221 }
79678222
79688223 transient ObjEditor editWindow;
8224
+ transient ObjEditor manipWindow;
8225
+
8226
+ transient boolean pinned;
8227
+
79698228 transient ObjectUI objectUI;
79708229 public static int povDepth = 0;
79718230 private static cVector tbMin = new cVector();