Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
Object3D.java
....@@ -22,12 +22,21 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
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 //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
3140
3241 ScriptNode scriptnode;
3342
....@@ -170,24 +179,35 @@
170179
171180 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172181 {
182
+ Object3D o;
183
+
173184 if (hashtable.containsKey(GetUUID()))
174185 {
175
- Object3D o = hashtable.get(GetUUID());
186
+ o = hashtable.get(GetUUID());
176187
177188 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
180197
181
- return;
198
+ hashtable.put(GetUUID(), o);
182199 }
183200
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
201
+ if (!blockloop)
189202 {
190
- get(i).ExtractBigData(hashtable);
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
191211 }
192212
193213 ExtractBigData(o);
....@@ -195,11 +215,26 @@
195215
196216 void ExtractBigData(Object3D o)
197217 {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
198221 o.bRep = this.bRep;
199
- if (this.bRep != null)
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
200232 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
203238 }
204239
205240 // o.support = this.support;
....@@ -214,6 +249,29 @@
214249 // this.fileparent = null;
215250 }
216251
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
217275 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218276 {
219277 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +281,35 @@
223281
224282 RestoreBigData(o);
225283
226
- hashtable.remove(GetUUID());
284
+ if (blockloop)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ //hashtable.remove(GetUUID());
227290
228291 for (int i=0; i<Size(); i++)
229292 {
230293 get(i).RestoreBigData(hashtable);
231294 }
295
+
296
+ blockloop = false;
232297 }
233298
234299 void RestoreBigData(Object3D o)
235300 {
236301 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
302
+ if (this.support != null && o.transientrep != null)
303
+ {
304
+ this.support.bRep = o.transientrep;
305
+ }
306
+
307
+ this.selection = o.selection;
308
+
309
+ this.versionlist = o.versionlist;
310
+ this.versionindex = o.versionindex;
311
+// July 2019 if (this.bRep != null)
312
+// this.bRep.support = o.transientrep;
239313 // this.support = o.support;
240314 // this.fileparent = o.fileparent;
241315 }
....@@ -381,6 +455,7 @@
381455 }
382456
383457 boolean live = false;
458
+ transient boolean keepdontselect;
384459 boolean dontselect = false;
385460 boolean hide = false;
386461 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +956,7 @@
881956
882957 if (marked && Globals.isLIVE() && live &&
883958 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
959
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885960 currentframe != Globals.framecount)
886961 {
887962 currentframe = Globals.framecount;
....@@ -966,6 +1041,10 @@
9661041 if (material == null || material.multiply)
9671042 return true;
9681043
1044
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1045
+ return false;
1046
+
1047
+ // Transparent objects are dynamic because we have to sort the triangles.
9691048 return material.opacity > 0.99;
9701049 }
9711050
....@@ -1366,6 +1445,7 @@
13661445 toParent = LA.newMatrix();
13671446 fromParent = LA.newMatrix();
13681447 }
1448
+
13691449 LA.matCopy(other.toParent, toParent);
13701450 LA.matCopy(other.fromParent, fromParent);
13711451
....@@ -2390,6 +2470,11 @@
23902470 else
23912471 {
23922472 //((ObjEditor)editWindow).SetupUI2(null);
2473
+ if (objectUI != null)
2474
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2475
+ else
2476
+ //new Exception().printStackTrace();
2477
+ System.err.println("objectUI is null");
23932478 }
23942479 }
23952480
....@@ -2432,6 +2517,14 @@
24322517 {
24332518 editWindow.refreshContents();
24342519 }
2520
+ else
2521
+ {
2522
+ if (manipWindow != null)
2523
+ {
2524
+ manipWindow.refreshContents();
2525
+ }
2526
+ }
2527
+
24352528 //if (parent != null)
24362529 //parent.refreshEditWindow();
24372530 }
....@@ -2511,7 +2604,8 @@
25112604 private static final int editSelf = 1;
25122605 private static final int editChild = 2;
25132606
2514
- void drawEditHandles(ClickInfo info, int level)
2607
+ void drawEditHandles(//ClickInfo info,
2608
+ int level)
25152609 {
25162610 if (level == 0)
25172611 {
....@@ -2519,7 +2613,8 @@
25192613 return;
25202614
25212615 Object3D selectee;
2522
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2616
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2617
+ level + 1))
25232618 {
25242619 selectee = (Object3D) e.nextElement();
25252620 }
....@@ -2527,19 +2622,22 @@
25272622 } else
25282623 {
25292624 //super.
2530
- drawEditHandles0(info, level + 1);
2625
+ drawEditHandles0(//info,
2626
+ level + 1);
25312627 }
25322628 }
25332629
2534
- boolean doEditClick(ClickInfo info, int level)
2630
+ boolean doEditClick(//ClickInfo info,
2631
+ int level)
25352632 {
25362633 doSomething = 0;
25372634 if (level == 0)
25382635 {
2539
- return doParentClick(info);
2636
+ return doParentClick(); //info);
25402637 }
25412638 if (//super.
2542
- doEditClick0(info, level))
2639
+ doEditClick0(//info,
2640
+ level))
25432641 {
25442642 doSomething = 1;
25452643 return true;
....@@ -2549,7 +2647,7 @@
25492647 }
25502648 }
25512649
2552
- boolean doParentClick(ClickInfo info)
2650
+ boolean doParentClick() //ClickInfo info)
25532651 {
25542652 if (selection == null)
25552653 {
....@@ -2562,7 +2660,8 @@
25622660 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25632661 {
25642662 Object3D selectee = (Object3D) e.nextElement();
2565
- if (selectee.doEditClick(info, 1))
2663
+ if (selectee.doEditClick(//info,
2664
+ 1))
25662665 {
25672666 childToDrag = selectee;
25682667 doSomething = 2;
....@@ -2574,13 +2673,15 @@
25742673 return retval;
25752674 }
25762675
2577
- void doEditDrag(ClickInfo info, boolean opposite)
2676
+ void doEditDrag(//ClickInfo clickInfo,
2677
+ boolean opposite)
25782678 {
25792679 switch (doSomething)
25802680 {
25812681 case 1: // '\001'
25822682 //super.
2583
- doEditDrag0(info, opposite);
2683
+ doEditDrag0(//clickInfo,
2684
+ opposite);
25842685 break;
25852686
25862687 case 2: // '\002'
....@@ -2593,11 +2694,13 @@
25932694 {
25942695 //sel.hitSomething = childToDrag.hitSomething;
25952696 //childToDrag.doEditDrag(info);
2596
- sel.doEditDrag(info, opposite);
2697
+ sel.doEditDrag(//clickInfo,
2698
+ opposite);
25972699 } else
25982700 {
25992701 //super.
2600
- doEditDrag0(info, opposite);
2702
+ doEditDrag0(//clickInfo,
2703
+ opposite);
26012704 }
26022705 }
26032706 break;
....@@ -2615,6 +2718,9 @@
26152718 {
26162719 deselectAll();
26172720 }
2721
+
2722
+ new Exception().printStackTrace();
2723
+
26182724 ClickInfo newInfo = new ClickInfo();
26192725 newInfo.flags = info.flags;
26202726 newInfo.bounds = info.bounds;
....@@ -3062,7 +3168,7 @@
30623168 {
30633169 if (bRep != null)
30643170 {
3065
- bRep.GenerateNormalsMINE();
3171
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30663172 Touch();
30673173 }
30683174 }
....@@ -4962,6 +5068,14 @@
49625068 }
49635069 }
49645070
5071
+ ObjEditor GetWindow()
5072
+ {
5073
+ if (editWindow != null)
5074
+ return editWindow;
5075
+
5076
+ return manipWindow;
5077
+ }
5078
+
49655079 cTreePath Select(int indexcount, boolean deselect)
49665080 {
49675081 if (hide || dontselect)
....@@ -4998,10 +5112,11 @@
49985112 if (leaf != null)
49995113 {
50005114 cTreePath tp = new cTreePath(this, leaf);
5001
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
50025117 {
50035118 //System.out.println("editWindow = " + editWindow + " vs " + this);
5004
- editWindow.Select(tp, deselect, true);
5119
+ window.Select(tp, deselect, true);
50055120 }
50065121
50075122 return tp;
....@@ -5018,6 +5133,7 @@
50185133
50195134 if (child == null)
50205135 continue;
5136
+
50215137 if (child.HasTransparency() && child.size() != 0)
50225138 {
50235139 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5027,9 +5143,10 @@
50275143 if (leaf != null)
50285144 {
50295145 cTreePath tp = new cTreePath(this, leaf);
5030
- if (editWindow != null)
5146
+ ObjEditor window = GetWindow();
5147
+ if (window != null)
50315148 {
5032
- editWindow.Select(tp, deselect, true);
5149
+ window.Select(tp, deselect, true);
50335150 }
50345151
50355152 return tp;
....@@ -5354,6 +5471,51 @@
53545471 blockloop = false;
53555472 }
53565473
5474
+ void ResetSelectable()
5475
+ {
5476
+ if (blockloop)
5477
+ return;
5478
+
5479
+ blockloop = true;
5480
+
5481
+ keepdontselect = dontselect;
5482
+ dontselect = true;
5483
+
5484
+ Object3D child;
5485
+ int nb = Size();
5486
+ for (int i = 0; i < nb; i++)
5487
+ {
5488
+ child = (Object3D) get(i);
5489
+ if (child == null)
5490
+ continue;
5491
+ child.ResetSelectable();
5492
+ }
5493
+
5494
+ blockloop = false;
5495
+ }
5496
+
5497
+ void RestoreSelectable()
5498
+ {
5499
+ if (blockloop)
5500
+ return;
5501
+
5502
+ blockloop = true;
5503
+
5504
+ dontselect = keepdontselect;
5505
+
5506
+ Object3D child;
5507
+ int nb = Size();
5508
+ for (int i = 0; i < nb; i++)
5509
+ {
5510
+ child = (Object3D) get(i);
5511
+ if (child == null)
5512
+ continue;
5513
+ child.RestoreSelectable();
5514
+ }
5515
+
5516
+ blockloop = false;
5517
+ }
5518
+
53575519 boolean IsSelected()
53585520 {
53595521 if (parent == null)
....@@ -5414,6 +5576,11 @@
54145576 if (fullname == null)
54155577 return "";
54165578
5579
+ if (fullname.pigment != null)
5580
+ {
5581
+ return fullname.pigment;
5582
+ }
5583
+
54175584 // System.out.println("Fullname = " + fullname);
54185585
54195586 // Does not work on Windows due to C:
....@@ -5426,7 +5593,7 @@
54265593
54275594 if (split.length == 0)
54285595 {
5429
- return "";
5596
+ return fullname.pigment = "";
54305597 }
54315598
54325599 if (split.length <= 2)
....@@ -5434,22 +5601,27 @@
54345601 if (fullname.name.endsWith(":"))
54355602 {
54365603 // Windows
5437
- return fullname.name.substring(0, fullname.name.length()-1);
5604
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54385605 }
54395606
5440
- return split[0];
5607
+ return fullname.pigment = split[0];
54415608 }
54425609
54435610 // Windows
54445611 assert(split.length == 4);
54455612
5446
- return split[0] + ":" + split[1];
5613
+ return fullname.pigment = split[0] + ":" + split[1];
54475614 }
54485615
54495616 static String GetBump(cTexture fullname)
54505617 {
54515618 if (fullname == null)
54525619 return "";
5620
+
5621
+ if (fullname.bump != null)
5622
+ {
5623
+ return fullname.bump;
5624
+ }
54535625
54545626 // System.out.println("Fullname = " + fullname);
54555627 // Does not work on Windows due to C:
....@@ -5461,12 +5633,12 @@
54615633
54625634 if (split.length == 0)
54635635 {
5464
- return "";
5636
+ return fullname.bump = "";
54655637 }
54665638
54675639 if (split.length == 1)
54685640 {
5469
- return "";
5641
+ return fullname.bump = "";
54705642 }
54715643
54725644 if (split.length == 2)
....@@ -5474,16 +5646,16 @@
54745646 if (fullname.name.endsWith(":"))
54755647 {
54765648 // Windows
5477
- return "";
5649
+ return fullname.bump = "";
54785650 }
54795651
5480
- return split[1];
5652
+ return fullname.bump = split[1];
54815653 }
54825654
54835655 // Windows
54845656 assert(split.length == 4);
54855657
5486
- return split[2] + ":" + split[3];
5658
+ return fullname.bump = split[2] + ":" + split[3];
54875659 }
54885660
54895661 String GetPigmentTexture()
....@@ -5566,6 +5738,9 @@
55665738 texname = "";
55675739
55685740 GetTextures().name = texname + ":" + GetBump(GetTextures());
5741
+
5742
+ GetTextures().pigment = null;
5743
+
55695744 Touch();
55705745 }
55715746
....@@ -5639,6 +5814,8 @@
56395814
56405815 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56415816
5817
+ GetTextures().bump = null;
5818
+
56425819 Touch();
56435820 }
56445821
....@@ -5659,6 +5836,38 @@
56595836
56605837 blockloop = true;
56615838 child.ResetBumpTexture();
5839
+ blockloop = false;
5840
+ }
5841
+ }
5842
+
5843
+ void EmbedTextures(boolean embed)
5844
+ {
5845
+ if (blockloop)
5846
+ return;
5847
+
5848
+ //if (GetTextures() != null)
5849
+ if (embed)
5850
+ CameraPane.EmbedTextures(GetTextures());
5851
+ else
5852
+ {
5853
+ GetTextures().pigmentdata = null;
5854
+ GetTextures().bumpdata = null;
5855
+ GetTextures().pw = 0;
5856
+ GetTextures().ph = 0;
5857
+ GetTextures().bw = 0;
5858
+ GetTextures().bh = 0;
5859
+ }
5860
+
5861
+ int nb = Size();
5862
+ for (int i = 0; i < nb; i++)
5863
+ {
5864
+ Object3D child = (Object3D) get(i);
5865
+
5866
+ if (child == null)
5867
+ continue;
5868
+
5869
+ blockloop = true;
5870
+ child.EmbedTextures(embed);
56625871 blockloop = false;
56635872 }
56645873 }
....@@ -5749,8 +5958,10 @@
57495958 if (support != null)
57505959 support = support;
57515960
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);
5961
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5962
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5963
+
5964
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57545965
57555966 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57565967 {
....@@ -5760,8 +5971,9 @@
57605971 // usecalllists &= !(parent instanceof RandomNode);
57615972 // usecalllists = false;
57625973
5763
- if (GetBRep() != null)
5764
- usecalllists = usecalllists;
5974
+ if (display.DrawMode() == display.SHADOW)
5975
+ //GetBRep() != null)
5976
+ usecalllists = !!usecalllists;
57655977 //System.out.println("draw " + this);
57665978 //new Exception().printStackTrace();
57675979
....@@ -5771,7 +5983,7 @@
57715983
57725984 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57735985 //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5986
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57755987 {
57765988 Globals.lighttouched = true;
57775989 } // all panes...
....@@ -5783,7 +5995,7 @@
57835995 if (!(this instanceof Composite))
57845996 touched = false;
57855997 //if (displaylist == -1 && usecalllists)
5786
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5998
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57875999 {
57886000 bRep.displaylist = display.GenList();
57896001 assert(bRep.displaylist != 0);
....@@ -5794,7 +6006,7 @@
57946006
57956007 //System.out.println("\tnew list " + list);
57966008 //gl.glDrawBuffer(gl.GL_NONE);
5797
- if (usecalllists)
6009
+ if (usecalllists && bRep.displaylist > 0)
57986010 {
57996011 // System.err.println("new list " + bRep.displaylist + " for " + this);
58006012 display.NewList(bRep.displaylist);
....@@ -5803,7 +6015,7 @@
58036015 CallList(display, root, selected, blocked);
58046016
58056017 // compiled = true;
5806
- if (usecalllists)
6018
+ if (usecalllists && bRep.displaylist > 0)
58076019 {
58086020 // System.err.println("end list " + bRep.displaylist + " for " + this);
58096021 display.EndList();
....@@ -5903,6 +6115,7 @@
59036115 if (GetBRep() != null)
59046116 {
59056117 display.NextIndex();
6118
+
59066119 // vertex color conflict : gl.glCallList(list);
59076120 DrawNode(display, root, selected);
59086121 if (this instanceof BezierPatch)
....@@ -7153,20 +7366,23 @@
71537366 }
71547367 }
71557368
7156
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7369
+ static ClickInfo clickInfo = new ClickInfo();
7370
+
7371
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7372
+ Point outPt, Rectangle outRec)
71577373 {
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;
7374
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7375
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7376
+ double[][] toscreen = clickInfo.toScreen;
71617377 if (toscreen == null)
71627378 {
7163
- toscreen = new Camera(info.camera.viewCode).toScreen;
7379
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71647380 }
71657381 cVector vec = in;
71667382 LA.xformPos(in, toscreen, in);
71677383 //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();
7384
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7385
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71707386 outPt.x = hc + (int) vec.x;
71717387 outPt.y = vc - (int) vec.y;
71727388 outRec.x = outPt.x - 3;
....@@ -7174,15 +7390,18 @@
71747390 outRec.width = outRec.height = 6;
71757391 }
71767392
7177
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7393
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7394
+ )
71787395 {
71797396 Point pt = new Point(0, 0);
71807397 Rectangle rec = new Rectangle();
7181
- calcHotSpot(in, info, pt, rec);
7398
+ calcHotSpot(in, //clickInfo,
7399
+ pt, rec);
71827400 return rec;
71837401 }
71847402
7185
- void drawEditHandles0(ClickInfo info, int level)
7403
+ void drawEditHandles0(//ClickInfo clickInfo,
7404
+ int level)
71867405 {
71877406 if (level == 0)
71887407 {
....@@ -7191,16 +7410,19 @@
71917410 {
71927411 cVector origin = new cVector();
71937412 //LA.xformPos(origin, toParent, origin);
7194
- Rectangle spot = calcHotSpot(origin, info);
7413
+ if (this.clickInfo == null)
7414
+ this.clickInfo = new ClickInfo();
7415
+
7416
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71957417 Rectangle boundary = new Rectangle();
71967418 boundary.x = spot.x - 30;
71977419 boundary.y = spot.y - 30;
71987420 boundary.width = spot.width + 60;
71997421 boundary.height = spot.height + 60;
7200
- info.g.setColor(Color.red);
7422
+ clickInfo.g.setColor(Color.white);
72017423 int spotw = spot.x + spot.width;
72027424 int spoth = spot.y + spot.height;
7203
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72047426 // if (CameraPane.Xmin > spot.x)
72057427 // {
72067428 // CameraPane.Xmin = spot.x;
....@@ -7217,11 +7439,6 @@
72177439 // {
72187440 // CameraPane.Ymax = spoth;
72197441 // }
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);
72257442 // if (CameraPane.Xmin > spot.x)
72267443 // {
72277444 // CameraPane.Xmin = spot.x;
....@@ -7240,10 +7457,15 @@
72407457 // }
72417458 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72427459 //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);
7460
+ spot.translate(32, 0);
7461
+ clickInfo.g.setColor(Color.yellow);
7462
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7463
+
7464
+ spot.translate(32, 64);
7465
+ spotw = spot.x + spot.width;
7466
+ spoth = spot.y + spot.height;
7467
+ clickInfo.g.setColor(Color.cyan);
7468
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72477469 // if (CameraPane.Xmin > spot.x)
72487470 // {
72497471 // CameraPane.Xmin = spot.x;
....@@ -7260,8 +7482,9 @@
72607482 // {
72617483 // CameraPane.Ymax = spoth;
72627484 // }
7263
- info.g.drawArc(boundary.x, boundary.y,
7264
- boundary.width, boundary.height, 0, 360);
7485
+ clickInfo.g.setColor(Color.green);
7486
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7487
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72657488 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72667489 // if (CameraPane.Xmin > boundary.x)
72677490 // {
....@@ -7283,7 +7506,8 @@
72837506 }
72847507 }
72857508
7286
- boolean doEditClick0(ClickInfo info, int level)
7509
+ boolean doEditClick0(//ClickInfo clickInfo,
7510
+ int level)
72877511 {
72887512 if (level == 0)
72897513 {
....@@ -7292,8 +7516,8 @@
72927516
72937517 boolean retval = false;
72947518
7295
- startX = info.x;
7296
- startY = info.y;
7519
+ startX = clickInfo.x;
7520
+ startY = clickInfo.y;
72977521
72987522 hitSomething = -1;
72997523 cVector origin = new cVector();
....@@ -7303,22 +7527,53 @@
73037527 {
73047528 centerPt = new Point(0, 0);
73057529 }
7306
- calcHotSpot(origin, info, centerPt, spot);
7307
- if (spot.contains(info.x, info.y))
7530
+ calcHotSpot(origin, //info,
7531
+ centerPt, spot);
7532
+ if (spot.contains(clickInfo.x, clickInfo.y))
73087533 {
73097534 hitSomething = hitCenter;
73107535 retval = true;
73117536 }
73127537 spot.translate(32, 0);
7313
- if (spot.contains(info.x, info.y))
7538
+ if (spot.contains(clickInfo.x, clickInfo.y))
73147539 {
73157540 hitSomething = hitRotate;
73167541 retval = true;
73177542 }
73187543 spot.translate(0, 32);
7319
- if (spot.contains(info.x, info.y))
7544
+ spot.translate(32, 0);
7545
+ spot.translate(0, 32);
7546
+ if (spot.contains(clickInfo.x, clickInfo.y))
73207547 {
73217548 hitSomething = hitScale;
7549
+
7550
+ double scale = 0.005f * clickInfo.camera.Distance();
7551
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7552
+ double sign = 1;
7553
+ if (hScale < 0)
7554
+ {
7555
+ sign = -1;
7556
+ }
7557
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7558
+ if (hScale < 0.01)
7559
+ {
7560
+ //hScale = 0.01;
7561
+ }
7562
+
7563
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7564
+ sign = 1;
7565
+ if (vScale < 0)
7566
+ {
7567
+ sign = -1;
7568
+ }
7569
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7570
+ if (vScale < 0.01)
7571
+ {
7572
+ //vScale = 0.01;
7573
+ }
7574
+
7575
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7576
+
73227577 retval = true;
73237578 }
73247579
....@@ -7328,7 +7583,7 @@
73287583 }
73297584
73307585 //System.out.println("info.modifiers = " + info.modifiers);
7331
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7586
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73327587 //System.out.println("modified = " + modified);
73337588 //new Exception().printStackTrace();
73347589 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7356,7 +7611,8 @@
73567611 return true;
73577612 }
73587613
7359
- void doEditDrag0(ClickInfo info, boolean opposite)
7614
+ void doEditDrag0(//ClickInfo info,
7615
+ boolean opposite)
73607616 {
73617617 if (hitSomething == 0)
73627618 {
....@@ -7370,7 +7626,7 @@
73707626
73717627 //System.out.println("hitSomething = " + hitSomething);
73727628
7373
- double scale = 0.005f * info.camera.Distance();
7629
+ double scale = 0.005f * clickInfo.camera.Distance();
73747630
73757631 cVector xlate = new cVector();
73767632 //cVector xlate2 = new cVector();
....@@ -7404,8 +7660,8 @@
74047660 toParent[3][i] = xlate.get(i);
74057661 LA.matInvert(toParent, fromParent);
74067662 */
7407
- cVector delta = LA.newVector(0, 0, startY - info.y);
7408
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7663
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7664
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74097665
74107666 LA.matCopy(startMat, toParent);
74117667 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7414,7 +7670,7 @@
74147670 } else
74157671 {
74167672 //LA.xformDir(delta, info.camera.fromScreen, delta);
7417
- cVector up = new cVector(info.camera.up);
7673
+ cVector up = new cVector(clickInfo.camera.up);
74187674 cVector away = new cVector();
74197675 //cVector right2 = new cVector();
74207676 //LA.vecCross(up, cVector.Z, right);
....@@ -7431,19 +7687,19 @@
74317687 LA.xformDir(up, ClickInfo.matbuffer, up);
74327688 // if (!CameraPane.LOCALTRANSFORM)
74337689 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7434
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7690
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74357691 // if (!CameraPane.LOCALTRANSFORM)
74367692 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74377693 //LA.vecCross(up, cVector.Z, right2);
74387694
7439
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7695
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74407696
74417697 //System.out.println("DELTA0 = " + delta);
74427698 //System.out.println("AWAY = " + info.camera.away);
74437699 //System.out.println("UP = " + info.camera.up);
74447700 if (away.z > 0)
74457701 {
7446
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7702
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74477703 {
74487704 delta.x = -delta.x;
74497705 } else
....@@ -7458,7 +7714,7 @@
74587714 //System.out.println("DELTA1 = " + delta);
74597715 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74607716 //System.out.println("DELTA2 = " + delta);
7461
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7717
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74627718 LA.matCopy(startMat, toParent);
74637719 //System.out.println("DELTA3 = " + delta);
74647720 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7468,8 +7724,8 @@
74687724 break;
74697725
74707726 case hitRotate: // rotate
7471
- int dx = info.x - centerPt.x;
7472
- int dy = -(info.y - centerPt.y);
7727
+ int dx = clickInfo.x - centerPt.x;
7728
+ int dy = -(clickInfo.y - centerPt.y);
74737729 double angle = (double) Math.atan2(dx, dy);
74747730 angle = -(1.570796 - angle);
74757731
....@@ -7492,7 +7748,7 @@
74927748 }
74937749 /**/
74947750
7495
- switch (info.pane.RenderCamera().viewCode)
7751
+ switch (clickInfo.pane.RenderCamera().viewCode)
74967752 {
74977753 case 1: // '\001'
74987754 LA.matZRotate(toParent, angle);
....@@ -7519,7 +7775,7 @@
75197775 break;
75207776
75217777 case hitScale: // scale
7522
- double hScale = (double) (info.x - centerPt.x) / 32;
7778
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75237779 double sign = 1;
75247780 if (hScale < 0)
75257781 {
....@@ -7531,7 +7787,7 @@
75317787 //hScale = 0.01;
75327788 }
75337789
7534
- double vScale = (double) (info.y - centerPt.y) / 32;
7790
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75357791 sign = 1;
75367792 if (vScale < 0)
75377793 {
....@@ -7542,6 +7798,7 @@
75427798 {
75437799 //vScale = 0.01;
75447800 }
7801
+
75457802 LA.matCopy(startMat, toParent);
75467803 /**/
75477804 for (int i = 0; i < 3; i++)
....@@ -7551,33 +7808,39 @@
75517808 }
75527809 /**/
75537810
7554
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7811
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75557812
75567813 if (totalScale < 0.01)
75577814 {
75587815 totalScale = 0.01;
75597816 }
75607817
7561
- switch (info.pane.RenderCamera().viewCode)
7818
+ switch (clickInfo.pane.RenderCamera().viewCode)
75627819 {
75637820 case 3: // '\001'
75647821 if (modified || opposite)
75657822 {
7823
+ if (modified && opposite)
7824
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7825
+ else
75667826 //LA.matScale(toParent, 1, hScale, vScale);
7567
- LA.matScale(toParent, totalScale, 1, 1);
7827
+ LA.matScale(toParent, totalScale, 1, 1);
75687828 } // vScale, 1);
75697829 else
75707830 {
75717831 // EXCEPTION!
7572
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7832
+ LA.matScale(toParent, 1, totalScale, totalScale);
75737833 } // vScale, 1);
75747834 break;
75757835
75767836 case 2: // '\002'
75777837 if (modified || opposite)
75787838 {
7579
- //LA.matScale(toParent, hScale, 1, vScale);
7580
- LA.matScale(toParent, 1, totalScale, 1);
7839
+ if (modified && opposite)
7840
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7841
+ else
7842
+ //LA.matScale(toParent, hScale, 1, vScale);
7843
+ LA.matScale(toParent, 1, totalScale, 1);
75817844 } else
75827845 {
75837846 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7587,8 +7850,11 @@
75877850 case 1: // '\003'
75887851 if (modified || opposite)
75897852 {
7590
- //LA.matScale(toParent, hScale, vScale, 1);
7591
- LA.matScale(toParent, 1, 1, totalScale);
7853
+ if (modified && opposite)
7854
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7855
+ else
7856
+ //LA.matScale(toParent, hScale, vScale, 1);
7857
+ LA.matScale(toParent, 1, 1, totalScale);
75927858 } else
75937859 {
75947860 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7625,7 +7891,7 @@
76257891 } // NEW ...
76267892
76277893
7628
- info.pane.repaint();
7894
+ clickInfo.pane.repaint();
76297895 }
76307896
76317897 boolean overflow = false;
....@@ -7966,6 +8232,10 @@
79668232 }
79678233
79688234 transient ObjEditor editWindow;
8235
+ transient ObjEditor manipWindow;
8236
+
8237
+ transient boolean pinned;
8238
+
79698239 transient ObjectUI objectUI;
79708240 public static int povDepth = 0;
79718241 private static cVector tbMin = new cVector();