Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
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("copy of " + this.name);
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,19 +247,42 @@
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()))
220276 return;
221277
278
+ Object3D o = hashtable.get(GetUUID());
279
+
280
+ RestoreBigData(o);
281
+
222282 if (blockloop)
223283 return;
224284
225285 blockloop = true;
226
-
227
- Object3D o = hashtable.get(GetUUID());
228
-
229
- RestoreBigData(o);
230286
231287 //hashtable.remove(GetUUID());
232288
....@@ -241,8 +297,17 @@
241297 void RestoreBigData(Object3D o)
242298 {
243299 this.bRep = o.bRep;
244
- if (this.bRep != null)
245
- 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;
246311 // this.support = o.support;
247312 // this.fileparent = o.fileparent;
248313 }
....@@ -388,6 +453,7 @@
388453 }
389454
390455 boolean live = false;
456
+ transient boolean keepdontselect;
391457 boolean dontselect = false;
392458 boolean hide = false;
393459 boolean link2master = false; // performs reset support/master at each frame
....@@ -973,6 +1039,9 @@
9731039 if (material == null || material.multiply)
9741040 return true;
9751041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
9761045 // Transparent objects are dynamic because we have to sort the triangles.
9771046 return material.opacity > 0.99;
9781047 }
....@@ -1374,6 +1443,7 @@
13741443 toParent = LA.newMatrix();
13751444 fromParent = LA.newMatrix();
13761445 }
1446
+
13771447 LA.matCopy(other.toParent, toParent);
13781448 LA.matCopy(other.fromParent, fromParent);
13791449
....@@ -2398,6 +2468,11 @@
23982468 else
23992469 {
24002470 //((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");
24012476 }
24022477 }
24032478
....@@ -2527,7 +2602,8 @@
25272602 private static final int editSelf = 1;
25282603 private static final int editChild = 2;
25292604
2530
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
25312607 {
25322608 if (level == 0)
25332609 {
....@@ -2535,7 +2611,8 @@
25352611 return;
25362612
25372613 Object3D selectee;
2538
- 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))
25392616 {
25402617 selectee = (Object3D) e.nextElement();
25412618 }
....@@ -2543,19 +2620,22 @@
25432620 } else
25442621 {
25452622 //super.
2546
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
25472625 }
25482626 }
25492627
2550
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
25512630 {
25522631 doSomething = 0;
25532632 if (level == 0)
25542633 {
2555
- return doParentClick(info);
2634
+ return doParentClick(); //info);
25562635 }
25572636 if (//super.
2558
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
25592639 {
25602640 doSomething = 1;
25612641 return true;
....@@ -2565,7 +2645,7 @@
25652645 }
25662646 }
25672647
2568
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
25692649 {
25702650 if (selection == null)
25712651 {
....@@ -2578,7 +2658,8 @@
25782658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25792659 {
25802660 Object3D selectee = (Object3D) e.nextElement();
2581
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
25822663 {
25832664 childToDrag = selectee;
25842665 doSomething = 2;
....@@ -2590,13 +2671,15 @@
25902671 return retval;
25912672 }
25922673
2593
- void doEditDrag(ClickInfo info, boolean opposite)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
25942676 {
25952677 switch (doSomething)
25962678 {
25972679 case 1: // '\001'
25982680 //super.
2599
- doEditDrag0(info, opposite);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
26002683 break;
26012684
26022685 case 2: // '\002'
....@@ -2609,11 +2692,13 @@
26092692 {
26102693 //sel.hitSomething = childToDrag.hitSomething;
26112694 //childToDrag.doEditDrag(info);
2612
- sel.doEditDrag(info, opposite);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
26132697 } else
26142698 {
26152699 //super.
2616
- doEditDrag0(info, opposite);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
26172702 }
26182703 }
26192704 break;
....@@ -2631,6 +2716,9 @@
26312716 {
26322717 deselectAll();
26332718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
26342722 ClickInfo newInfo = new ClickInfo();
26352723 newInfo.flags = info.flags;
26362724 newInfo.bounds = info.bounds;
....@@ -3078,7 +3166,7 @@
30783166 {
30793167 if (bRep != null)
30803168 {
3081
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30823170 Touch();
30833171 }
30843172 }
....@@ -5043,6 +5131,7 @@
50435131
50445132 if (child == null)
50455133 continue;
5134
+
50465135 if (child.HasTransparency() && child.size() != 0)
50475136 {
50485137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5380,6 +5469,51 @@
53805469 blockloop = false;
53815470 }
53825471
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
+
53835517 boolean IsSelected()
53845518 {
53855519 if (parent == null)
....@@ -5440,6 +5574,11 @@
54405574 if (fullname == null)
54415575 return "";
54425576
5577
+ if (fullname.pigment != null)
5578
+ {
5579
+ return fullname.pigment;
5580
+ }
5581
+
54435582 // System.out.println("Fullname = " + fullname);
54445583
54455584 // Does not work on Windows due to C:
....@@ -5452,7 +5591,7 @@
54525591
54535592 if (split.length == 0)
54545593 {
5455
- return "";
5594
+ return fullname.pigment = "";
54565595 }
54575596
54585597 if (split.length <= 2)
....@@ -5460,22 +5599,27 @@
54605599 if (fullname.name.endsWith(":"))
54615600 {
54625601 // Windows
5463
- return fullname.name.substring(0, fullname.name.length()-1);
5602
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54645603 }
54655604
5466
- return split[0];
5605
+ return fullname.pigment = split[0];
54675606 }
54685607
54695608 // Windows
54705609 assert(split.length == 4);
54715610
5472
- return split[0] + ":" + split[1];
5611
+ return fullname.pigment = split[0] + ":" + split[1];
54735612 }
54745613
54755614 static String GetBump(cTexture fullname)
54765615 {
54775616 if (fullname == null)
54785617 return "";
5618
+
5619
+ if (fullname.bump != null)
5620
+ {
5621
+ return fullname.bump;
5622
+ }
54795623
54805624 // System.out.println("Fullname = " + fullname);
54815625 // Does not work on Windows due to C:
....@@ -5487,12 +5631,12 @@
54875631
54885632 if (split.length == 0)
54895633 {
5490
- return "";
5634
+ return fullname.bump = "";
54915635 }
54925636
54935637 if (split.length == 1)
54945638 {
5495
- return "";
5639
+ return fullname.bump = "";
54965640 }
54975641
54985642 if (split.length == 2)
....@@ -5500,16 +5644,16 @@
55005644 if (fullname.name.endsWith(":"))
55015645 {
55025646 // Windows
5503
- return "";
5647
+ return fullname.bump = "";
55045648 }
55055649
5506
- return split[1];
5650
+ return fullname.bump = split[1];
55075651 }
55085652
55095653 // Windows
55105654 assert(split.length == 4);
55115655
5512
- return split[2] + ":" + split[3];
5656
+ return fullname.bump = split[2] + ":" + split[3];
55135657 }
55145658
55155659 String GetPigmentTexture()
....@@ -5592,6 +5736,9 @@
55925736 texname = "";
55935737
55945738 GetTextures().name = texname + ":" + GetBump(GetTextures());
5739
+
5740
+ GetTextures().pigment = null;
5741
+
55955742 Touch();
55965743 }
55975744
....@@ -5665,6 +5812,8 @@
56655812
56665813 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56675814
5815
+ GetTextures().bump = null;
5816
+
56685817 Touch();
56695818 }
56705819
....@@ -5685,6 +5834,38 @@
56855834
56865835 blockloop = true;
56875836 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);
56885869 blockloop = false;
56895870 }
56905871 }
....@@ -5775,8 +5956,10 @@
57755956 if (support != null)
57765957 support = support;
57775958
5778
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5779
- 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.
57805963
57815964 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57825965 {
....@@ -5786,8 +5969,9 @@
57865969 // usecalllists &= !(parent instanceof RandomNode);
57875970 // usecalllists = false;
57885971
5789
- if (GetBRep() != null)
5790
- usecalllists = usecalllists;
5972
+ if (display.DrawMode() == display.SHADOW)
5973
+ //GetBRep() != null)
5974
+ usecalllists = !!usecalllists;
57915975 //System.out.println("draw " + this);
57925976 //new Exception().printStackTrace();
57935977
....@@ -5797,7 +5981,7 @@
57975981
57985982 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57995983 //(touched || (bRep != null && bRep.displaylist <= 0)))
5800
- (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
5984
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
58015985 {
58025986 Globals.lighttouched = true;
58035987 } // all panes...
....@@ -5809,7 +5993,7 @@
58095993 if (!(this instanceof Composite))
58105994 touched = false;
58115995 //if (displaylist == -1 && usecalllists)
5812
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5996
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58135997 {
58145998 bRep.displaylist = display.GenList();
58155999 assert(bRep.displaylist != 0);
....@@ -5820,7 +6004,7 @@
58206004
58216005 //System.out.println("\tnew list " + list);
58226006 //gl.glDrawBuffer(gl.GL_NONE);
5823
- if (usecalllists)
6007
+ if (usecalllists && bRep.displaylist > 0)
58246008 {
58256009 // System.err.println("new list " + bRep.displaylist + " for " + this);
58266010 display.NewList(bRep.displaylist);
....@@ -5829,7 +6013,7 @@
58296013 CallList(display, root, selected, blocked);
58306014
58316015 // compiled = true;
5832
- if (usecalllists)
6016
+ if (usecalllists && bRep.displaylist > 0)
58336017 {
58346018 // System.err.println("end list " + bRep.displaylist + " for " + this);
58356019 display.EndList();
....@@ -5929,6 +6113,7 @@
59296113 if (GetBRep() != null)
59306114 {
59316115 display.NextIndex();
6116
+
59326117 // vertex color conflict : gl.glCallList(list);
59336118 DrawNode(display, root, selected);
59346119 if (this instanceof BezierPatch)
....@@ -7179,20 +7364,23 @@
71797364 }
71807365 }
71817366
7182
- 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)
71837371 {
7184
- int hc = info.bounds.x + info.bounds.width / 2;
7185
- int vc = info.bounds.y + info.bounds.height / 2;
7186
- 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;
71877375 if (toscreen == null)
71887376 {
7189
- toscreen = new Camera(info.camera.viewCode).toScreen;
7377
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71907378 }
71917379 cVector vec = in;
71927380 LA.xformPos(in, toscreen, in);
71937381 //System.out.println("Distance = " + info.camera.Distance());
7194
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7195
- 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();
71967384 outPt.x = hc + (int) vec.x;
71977385 outPt.y = vc - (int) vec.y;
71987386 outRec.x = outPt.x - 3;
....@@ -7200,15 +7388,18 @@
72007388 outRec.width = outRec.height = 6;
72017389 }
72027390
7203
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7391
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7392
+ )
72047393 {
72057394 Point pt = new Point(0, 0);
72067395 Rectangle rec = new Rectangle();
7207
- calcHotSpot(in, info, pt, rec);
7396
+ calcHotSpot(in, //clickInfo,
7397
+ pt, rec);
72087398 return rec;
72097399 }
72107400
7211
- void drawEditHandles0(ClickInfo info, int level)
7401
+ void drawEditHandles0(//ClickInfo clickInfo,
7402
+ int level)
72127403 {
72137404 if (level == 0)
72147405 {
....@@ -7217,16 +7408,19 @@
72177408 {
72187409 cVector origin = new cVector();
72197410 //LA.xformPos(origin, toParent, origin);
7220
- Rectangle spot = calcHotSpot(origin, info);
7411
+ if (this.clickInfo == null)
7412
+ this.clickInfo = new ClickInfo();
7413
+
7414
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72217415 Rectangle boundary = new Rectangle();
72227416 boundary.x = spot.x - 30;
72237417 boundary.y = spot.y - 30;
72247418 boundary.width = spot.width + 60;
72257419 boundary.height = spot.height + 60;
7226
- info.g.setColor(Color.red);
7420
+ clickInfo.g.setColor(Color.red);
72277421 int spotw = spot.x + spot.width;
72287422 int spoth = spot.y + spot.height;
7229
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72307424 // if (CameraPane.Xmin > spot.x)
72317425 // {
72327426 // CameraPane.Xmin = spot.x;
....@@ -7243,11 +7437,6 @@
72437437 // {
72447438 // CameraPane.Ymax = spoth;
72457439 // }
7246
- spot.translate(32, 32);
7247
- spotw = spot.x + spot.width;
7248
- spoth = spot.y + spot.height;
7249
- info.g.setColor(Color.cyan);
7250
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72517440 // if (CameraPane.Xmin > spot.x)
72527441 // {
72537442 // CameraPane.Xmin = spot.x;
....@@ -7266,10 +7455,15 @@
72667455 // }
72677456 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72687457 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7269
- spot.translate(0, -32);
7270
- info.g.setColor(Color.yellow);
7271
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7272
- 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);
72737467 // if (CameraPane.Xmin > spot.x)
72747468 // {
72757469 // CameraPane.Xmin = spot.x;
....@@ -7286,8 +7480,9 @@
72867480 // {
72877481 // CameraPane.Ymax = spoth;
72887482 // }
7289
- info.g.drawArc(boundary.x, boundary.y,
7290
- 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);
72917486 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72927487 // if (CameraPane.Xmin > boundary.x)
72937488 // {
....@@ -7309,7 +7504,8 @@
73097504 }
73107505 }
73117506
7312
- boolean doEditClick0(ClickInfo info, int level)
7507
+ boolean doEditClick0(//ClickInfo clickInfo,
7508
+ int level)
73137509 {
73147510 if (level == 0)
73157511 {
....@@ -7318,8 +7514,8 @@
73187514
73197515 boolean retval = false;
73207516
7321
- startX = info.x;
7322
- startY = info.y;
7517
+ startX = clickInfo.x;
7518
+ startY = clickInfo.y;
73237519
73247520 hitSomething = -1;
73257521 cVector origin = new cVector();
....@@ -7329,22 +7525,53 @@
73297525 {
73307526 centerPt = new Point(0, 0);
73317527 }
7332
- calcHotSpot(origin, info, centerPt, spot);
7333
- if (spot.contains(info.x, info.y))
7528
+ calcHotSpot(origin, //info,
7529
+ centerPt, spot);
7530
+ if (spot.contains(clickInfo.x, clickInfo.y))
73347531 {
73357532 hitSomething = hitCenter;
73367533 retval = true;
73377534 }
73387535 spot.translate(32, 0);
7339
- if (spot.contains(info.x, info.y))
7536
+ if (spot.contains(clickInfo.x, clickInfo.y))
73407537 {
73417538 hitSomething = hitRotate;
73427539 retval = true;
73437540 }
73447541 spot.translate(0, 32);
7345
- 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))
73467545 {
73477546 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
+
73487575 retval = true;
73497576 }
73507577
....@@ -7354,7 +7581,7 @@
73547581 }
73557582
73567583 //System.out.println("info.modifiers = " + info.modifiers);
7357
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7584
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73587585 //System.out.println("modified = " + modified);
73597586 //new Exception().printStackTrace();
73607587 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7382,7 +7609,8 @@
73827609 return true;
73837610 }
73847611
7385
- void doEditDrag0(ClickInfo info, boolean opposite)
7612
+ void doEditDrag0(//ClickInfo info,
7613
+ boolean opposite)
73867614 {
73877615 if (hitSomething == 0)
73887616 {
....@@ -7396,7 +7624,7 @@
73967624
73977625 //System.out.println("hitSomething = " + hitSomething);
73987626
7399
- double scale = 0.005f * info.camera.Distance();
7627
+ double scale = 0.005f * clickInfo.camera.Distance();
74007628
74017629 cVector xlate = new cVector();
74027630 //cVector xlate2 = new cVector();
....@@ -7430,8 +7658,8 @@
74307658 toParent[3][i] = xlate.get(i);
74317659 LA.matInvert(toParent, fromParent);
74327660 */
7433
- cVector delta = LA.newVector(0, 0, startY - info.y);
7434
- 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);
74357663
74367664 LA.matCopy(startMat, toParent);
74377665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7440,7 +7668,7 @@
74407668 } else
74417669 {
74427670 //LA.xformDir(delta, info.camera.fromScreen, delta);
7443
- cVector up = new cVector(info.camera.up);
7671
+ cVector up = new cVector(clickInfo.camera.up);
74447672 cVector away = new cVector();
74457673 //cVector right2 = new cVector();
74467674 //LA.vecCross(up, cVector.Z, right);
....@@ -7457,19 +7685,19 @@
74577685 LA.xformDir(up, ClickInfo.matbuffer, up);
74587686 // if (!CameraPane.LOCALTRANSFORM)
74597687 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7460
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7688
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74617689 // if (!CameraPane.LOCALTRANSFORM)
74627690 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74637691 //LA.vecCross(up, cVector.Z, right2);
74647692
7465
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7693
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74667694
74677695 //System.out.println("DELTA0 = " + delta);
74687696 //System.out.println("AWAY = " + info.camera.away);
74697697 //System.out.println("UP = " + info.camera.up);
74707698 if (away.z > 0)
74717699 {
7472
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7700
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74737701 {
74747702 delta.x = -delta.x;
74757703 } else
....@@ -7484,7 +7712,7 @@
74847712 //System.out.println("DELTA1 = " + delta);
74857713 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74867714 //System.out.println("DELTA2 = " + delta);
7487
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7715
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74887716 LA.matCopy(startMat, toParent);
74897717 //System.out.println("DELTA3 = " + delta);
74907718 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7494,8 +7722,8 @@
74947722 break;
74957723
74967724 case hitRotate: // rotate
7497
- int dx = info.x - centerPt.x;
7498
- int dy = -(info.y - centerPt.y);
7725
+ int dx = clickInfo.x - centerPt.x;
7726
+ int dy = -(clickInfo.y - centerPt.y);
74997727 double angle = (double) Math.atan2(dx, dy);
75007728 angle = -(1.570796 - angle);
75017729
....@@ -7518,7 +7746,7 @@
75187746 }
75197747 /**/
75207748
7521
- switch (info.pane.RenderCamera().viewCode)
7749
+ switch (clickInfo.pane.RenderCamera().viewCode)
75227750 {
75237751 case 1: // '\001'
75247752 LA.matZRotate(toParent, angle);
....@@ -7545,7 +7773,7 @@
75457773 break;
75467774
75477775 case hitScale: // scale
7548
- double hScale = (double) (info.x - centerPt.x) / 32;
7776
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75497777 double sign = 1;
75507778 if (hScale < 0)
75517779 {
....@@ -7557,7 +7785,7 @@
75577785 //hScale = 0.01;
75587786 }
75597787
7560
- double vScale = (double) (info.y - centerPt.y) / 32;
7788
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75617789 sign = 1;
75627790 if (vScale < 0)
75637791 {
....@@ -7568,6 +7796,7 @@
75687796 {
75697797 //vScale = 0.01;
75707798 }
7799
+
75717800 LA.matCopy(startMat, toParent);
75727801 /**/
75737802 for (int i = 0; i < 3; i++)
....@@ -7577,14 +7806,14 @@
75777806 }
75787807 /**/
75797808
7580
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7809
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75817810
75827811 if (totalScale < 0.01)
75837812 {
75847813 totalScale = 0.01;
75857814 }
75867815
7587
- switch (info.pane.RenderCamera().viewCode)
7816
+ switch (clickInfo.pane.RenderCamera().viewCode)
75887817 {
75897818 case 3: // '\001'
75907819 if (modified || opposite)
....@@ -7651,7 +7880,7 @@
76517880 } // NEW ...
76527881
76537882
7654
- info.pane.repaint();
7883
+ clickInfo.pane.repaint();
76557884 }
76567885
76577886 boolean overflow = false;
....@@ -7994,6 +8223,8 @@
79948223 transient ObjEditor editWindow;
79958224 transient ObjEditor manipWindow;
79968225
8226
+ transient boolean pinned;
8227
+
79978228 transient ObjectUI objectUI;
79988229 public static int povDepth = 0;
79998230 private static cVector tbMin = new cVector();