Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
Object3D.java
....@@ -24,11 +24,17 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
3030 //
3131
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ Object3D versions[];
36
+ int versionindex = -1;
37
+
3238 ScriptNode scriptnode;
3339
3440 void InitOthers()
....@@ -170,24 +176,35 @@
170176
171177 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172178 {
179
+ Object3D o;
180
+
173181 if (hashtable.containsKey(GetUUID()))
174182 {
175
- Object3D o = hashtable.get(GetUUID());
183
+ o = hashtable.get(GetUUID());
176184
177185 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
186
+ //if (this.bRep != null)
187
+ // assert(this.bRep.support == o.transientrep);
188
+ if (this.support != null)
189
+ assert(this.support.bRep == o.transientrep);
190
+ }
191
+ else
192
+ {
193
+ o = new Object3D("copy of " + this.name);
180194
181
- return;
195
+ hashtable.put(GetUUID(), o);
182196 }
183197
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
198
+ if (!blockloop)
189199 {
190
- get(i).ExtractBigData(hashtable);
200
+ blockloop = true;
201
+
202
+ for (int i=0; i<Size(); i++)
203
+ {
204
+ get(i).ExtractBigData(hashtable);
205
+ }
206
+
207
+ blockloop = false;
191208 }
192209
193210 ExtractBigData(o);
....@@ -195,11 +212,26 @@
195212
196213 void ExtractBigData(Object3D o)
197214 {
215
+ if (o.bRep != null)
216
+ Grafreed.Assert(o.bRep == this.bRep);
217
+
198218 o.bRep = this.bRep;
199
- if (this.bRep != null)
219
+// July 2019 if (this.bRep != null)
220
+// {
221
+// o.transientrep = this.bRep.support;
222
+// o.bRep.support = null;
223
+// }
224
+ o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
227
+
228
+ if (this.support != null)
200229 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
230
+ if (o.transientrep != null)
231
+ Grafreed.Assert(o.transientrep == this.support.bRep);
232
+
233
+ o.transientrep = this.support.bRep;
234
+ this.support.bRep = null;
203235 }
204236
205237 // o.support = this.support;
....@@ -223,19 +255,35 @@
223255
224256 RestoreBigData(o);
225257
226
- hashtable.remove(GetUUID());
258
+ if (blockloop)
259
+ return;
260
+
261
+ blockloop = true;
262
+
263
+ //hashtable.remove(GetUUID());
227264
228265 for (int i=0; i<Size(); i++)
229266 {
230267 get(i).RestoreBigData(hashtable);
231268 }
269
+
270
+ blockloop = false;
232271 }
233272
234273 void RestoreBigData(Object3D o)
235274 {
236275 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
276
+ if (this.support != null && o.transientrep != null)
277
+ {
278
+ this.support.bRep = o.transientrep;
279
+ }
280
+
281
+ this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
285
+// July 2019 if (this.bRep != null)
286
+// this.bRep.support = o.transientrep;
239287 // this.support = o.support;
240288 // this.fileparent = o.fileparent;
241289 }
....@@ -381,6 +429,7 @@
381429 }
382430
383431 boolean live = false;
432
+ transient boolean keepdontselect;
384433 boolean dontselect = false;
385434 boolean hide = false;
386435 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +930,7 @@
881930
882931 if (marked && Globals.isLIVE() && live &&
883932 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
933
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885934 currentframe != Globals.framecount)
886935 {
887936 currentframe = Globals.framecount;
....@@ -966,6 +1015,10 @@
9661015 if (material == null || material.multiply)
9671016 return true;
9681017
1018
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1019
+ return false;
1020
+
1021
+ // Transparent objects are dynamic because we have to sort the triangles.
9691022 return material.opacity > 0.99;
9701023 }
9711024
....@@ -1366,6 +1419,7 @@
13661419 toParent = LA.newMatrix();
13671420 fromParent = LA.newMatrix();
13681421 }
1422
+
13691423 LA.matCopy(other.toParent, toParent);
13701424 LA.matCopy(other.fromParent, fromParent);
13711425
....@@ -2387,6 +2441,10 @@
23872441 }
23882442 */
23892443 }
2444
+ else
2445
+ {
2446
+ //((ObjEditor)editWindow).SetupUI2(null);
2447
+ }
23902448 }
23912449
23922450 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2428,6 +2486,14 @@
24282486 {
24292487 editWindow.refreshContents();
24302488 }
2489
+ else
2490
+ {
2491
+ if (manipWindow != null)
2492
+ {
2493
+ manipWindow.refreshContents();
2494
+ }
2495
+ }
2496
+
24312497 //if (parent != null)
24322498 //parent.refreshEditWindow();
24332499 }
....@@ -2507,7 +2573,8 @@
25072573 private static final int editSelf = 1;
25082574 private static final int editChild = 2;
25092575
2510
- void drawEditHandles(ClickInfo info, int level)
2576
+ void drawEditHandles(//ClickInfo info,
2577
+ int level)
25112578 {
25122579 if (level == 0)
25132580 {
....@@ -2515,7 +2582,8 @@
25152582 return;
25162583
25172584 Object3D selectee;
2518
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2585
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2586
+ level + 1))
25192587 {
25202588 selectee = (Object3D) e.nextElement();
25212589 }
....@@ -2523,19 +2591,22 @@
25232591 } else
25242592 {
25252593 //super.
2526
- drawEditHandles0(info, level + 1);
2594
+ drawEditHandles0(//info,
2595
+ level + 1);
25272596 }
25282597 }
25292598
2530
- boolean doEditClick(ClickInfo info, int level)
2599
+ boolean doEditClick(//ClickInfo info,
2600
+ int level)
25312601 {
25322602 doSomething = 0;
25332603 if (level == 0)
25342604 {
2535
- return doParentClick(info);
2605
+ return doParentClick(); //info);
25362606 }
25372607 if (//super.
2538
- doEditClick0(info, level))
2608
+ doEditClick0(//info,
2609
+ level))
25392610 {
25402611 doSomething = 1;
25412612 return true;
....@@ -2545,7 +2616,7 @@
25452616 }
25462617 }
25472618
2548
- boolean doParentClick(ClickInfo info)
2619
+ boolean doParentClick() //ClickInfo info)
25492620 {
25502621 if (selection == null)
25512622 {
....@@ -2558,7 +2629,8 @@
25582629 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25592630 {
25602631 Object3D selectee = (Object3D) e.nextElement();
2561
- if (selectee.doEditClick(info, 1))
2632
+ if (selectee.doEditClick(//info,
2633
+ 1))
25622634 {
25632635 childToDrag = selectee;
25642636 doSomething = 2;
....@@ -2570,13 +2642,15 @@
25702642 return retval;
25712643 }
25722644
2573
- void doEditDrag(ClickInfo info, boolean opposite)
2645
+ void doEditDrag(//ClickInfo clickInfo,
2646
+ boolean opposite)
25742647 {
25752648 switch (doSomething)
25762649 {
25772650 case 1: // '\001'
25782651 //super.
2579
- doEditDrag0(info, opposite);
2652
+ doEditDrag0(//clickInfo,
2653
+ opposite);
25802654 break;
25812655
25822656 case 2: // '\002'
....@@ -2589,11 +2663,13 @@
25892663 {
25902664 //sel.hitSomething = childToDrag.hitSomething;
25912665 //childToDrag.doEditDrag(info);
2592
- sel.doEditDrag(info, opposite);
2666
+ sel.doEditDrag(//clickInfo,
2667
+ opposite);
25932668 } else
25942669 {
25952670 //super.
2596
- doEditDrag0(info, opposite);
2671
+ doEditDrag0(//clickInfo,
2672
+ opposite);
25972673 }
25982674 }
25992675 break;
....@@ -2611,6 +2687,9 @@
26112687 {
26122688 deselectAll();
26132689 }
2690
+
2691
+ new Exception().printStackTrace();
2692
+
26142693 ClickInfo newInfo = new ClickInfo();
26152694 newInfo.flags = info.flags;
26162695 newInfo.bounds = info.bounds;
....@@ -3058,7 +3137,7 @@
30583137 {
30593138 if (bRep != null)
30603139 {
3061
- bRep.GenerateNormalsMINE();
3140
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30623141 Touch();
30633142 }
30643143 }
....@@ -4958,6 +5037,14 @@
49585037 }
49595038 }
49605039
5040
+ ObjEditor GetWindow()
5041
+ {
5042
+ if (editWindow != null)
5043
+ return editWindow;
5044
+
5045
+ return manipWindow;
5046
+ }
5047
+
49615048 cTreePath Select(int indexcount, boolean deselect)
49625049 {
49635050 if (hide || dontselect)
....@@ -4994,10 +5081,11 @@
49945081 if (leaf != null)
49955082 {
49965083 cTreePath tp = new cTreePath(this, leaf);
4997
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
49985086 {
49995087 //System.out.println("editWindow = " + editWindow + " vs " + this);
5000
- editWindow.Select(tp, deselect, true);
5088
+ window.Select(tp, deselect, true);
50015089 }
50025090
50035091 return tp;
....@@ -5014,6 +5102,7 @@
50145102
50155103 if (child == null)
50165104 continue;
5105
+
50175106 if (child.HasTransparency() && child.size() != 0)
50185107 {
50195108 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5023,9 +5112,10 @@
50235112 if (leaf != null)
50245113 {
50255114 cTreePath tp = new cTreePath(this, leaf);
5026
- if (editWindow != null)
5115
+ ObjEditor window = GetWindow();
5116
+ if (window != null)
50275117 {
5028
- editWindow.Select(tp, deselect, true);
5118
+ window.Select(tp, deselect, true);
50295119 }
50305120
50315121 return tp;
....@@ -5350,6 +5440,51 @@
53505440 blockloop = false;
53515441 }
53525442
5443
+ void ResetSelectable()
5444
+ {
5445
+ if (blockloop)
5446
+ return;
5447
+
5448
+ blockloop = true;
5449
+
5450
+ keepdontselect = dontselect;
5451
+ dontselect = true;
5452
+
5453
+ Object3D child;
5454
+ int nb = Size();
5455
+ for (int i = 0; i < nb; i++)
5456
+ {
5457
+ child = (Object3D) get(i);
5458
+ if (child == null)
5459
+ continue;
5460
+ child.ResetSelectable();
5461
+ }
5462
+
5463
+ blockloop = false;
5464
+ }
5465
+
5466
+ void RestoreSelectable()
5467
+ {
5468
+ if (blockloop)
5469
+ return;
5470
+
5471
+ blockloop = true;
5472
+
5473
+ dontselect = keepdontselect;
5474
+
5475
+ Object3D child;
5476
+ int nb = Size();
5477
+ for (int i = 0; i < nb; i++)
5478
+ {
5479
+ child = (Object3D) get(i);
5480
+ if (child == null)
5481
+ continue;
5482
+ child.RestoreSelectable();
5483
+ }
5484
+
5485
+ blockloop = false;
5486
+ }
5487
+
53535488 boolean IsSelected()
53545489 {
53555490 if (parent == null)
....@@ -5659,6 +5794,38 @@
56595794 }
56605795 }
56615796
5797
+ void EmbedTextures(boolean embed)
5798
+ {
5799
+ if (blockloop)
5800
+ return;
5801
+
5802
+ //if (GetTextures() != null)
5803
+ if (embed)
5804
+ CameraPane.EmbedTextures(GetTextures());
5805
+ else
5806
+ {
5807
+ GetTextures().pigmentdata = null;
5808
+ GetTextures().bumpdata = null;
5809
+ GetTextures().pw = 0;
5810
+ GetTextures().ph = 0;
5811
+ GetTextures().bw = 0;
5812
+ GetTextures().bh = 0;
5813
+ }
5814
+
5815
+ int nb = Size();
5816
+ for (int i = 0; i < nb; i++)
5817
+ {
5818
+ Object3D child = (Object3D) get(i);
5819
+
5820
+ if (child == null)
5821
+ continue;
5822
+
5823
+ blockloop = true;
5824
+ child.EmbedTextures(embed);
5825
+ blockloop = false;
5826
+ }
5827
+ }
5828
+
56625829 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56635830 {
56645831 Draw(display, root, selected, blocked);
....@@ -5745,8 +5912,10 @@
57455912 if (support != null)
57465913 support = support;
57475914
5748
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5749
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5915
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5916
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5917
+
5918
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57505919
57515920 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57525921 {
....@@ -5756,8 +5925,9 @@
57565925 // usecalllists &= !(parent instanceof RandomNode);
57575926 // usecalllists = false;
57585927
5759
- if (GetBRep() != null)
5760
- usecalllists = usecalllists;
5928
+ if (display.DrawMode() == display.SHADOW)
5929
+ //GetBRep() != null)
5930
+ usecalllists = !!usecalllists;
57615931 //System.out.println("draw " + this);
57625932 //new Exception().printStackTrace();
57635933
....@@ -5767,7 +5937,7 @@
57675937
57685938 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57695939 //(touched || (bRep != null && bRep.displaylist <= 0)))
5770
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5940
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57715941 {
57725942 Globals.lighttouched = true;
57735943 } // all panes...
....@@ -5779,7 +5949,7 @@
57795949 if (!(this instanceof Composite))
57805950 touched = false;
57815951 //if (displaylist == -1 && usecalllists)
5782
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5952
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57835953 {
57845954 bRep.displaylist = display.GenList();
57855955 assert(bRep.displaylist != 0);
....@@ -5790,7 +5960,7 @@
57905960
57915961 //System.out.println("\tnew list " + list);
57925962 //gl.glDrawBuffer(gl.GL_NONE);
5793
- if (usecalllists)
5963
+ if (usecalllists && bRep.displaylist > 0)
57945964 {
57955965 // System.err.println("new list " + bRep.displaylist + " for " + this);
57965966 display.NewList(bRep.displaylist);
....@@ -5799,7 +5969,7 @@
57995969 CallList(display, root, selected, blocked);
58005970
58015971 // compiled = true;
5802
- if (usecalllists)
5972
+ if (usecalllists && bRep.displaylist > 0)
58035973 {
58045974 // System.err.println("end list " + bRep.displaylist + " for " + this);
58055975 display.EndList();
....@@ -5899,6 +6069,7 @@
58996069 if (GetBRep() != null)
59006070 {
59016071 display.NextIndex();
6072
+
59026073 // vertex color conflict : gl.glCallList(list);
59036074 DrawNode(display, root, selected);
59046075 if (this instanceof BezierPatch)
....@@ -6359,6 +6530,11 @@
63596530 // dec 2012
63606531 new Exception().printStackTrace();
63616532 return;
6533
+ }
6534
+
6535
+ if (dontselect)
6536
+ {
6537
+ //bRep.GenerateNormalsMINE();
63626538 }
63636539
63646540 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7144,20 +7320,23 @@
71447320 }
71457321 }
71467322
7147
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7323
+ static ClickInfo clickInfo = new ClickInfo();
7324
+
7325
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7326
+ Point outPt, Rectangle outRec)
71487327 {
7149
- int hc = info.bounds.x + info.bounds.width / 2;
7150
- int vc = info.bounds.y + info.bounds.height / 2;
7151
- double[][] toscreen = info.toScreen;
7328
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7329
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7330
+ double[][] toscreen = clickInfo.toScreen;
71527331 if (toscreen == null)
71537332 {
7154
- toscreen = new Camera(info.camera.viewCode).toScreen;
7333
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71557334 }
71567335 cVector vec = in;
71577336 LA.xformPos(in, toscreen, in);
71587337 //System.out.println("Distance = " + info.camera.Distance());
7159
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7160
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7338
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7339
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71617340 outPt.x = hc + (int) vec.x;
71627341 outPt.y = vc - (int) vec.y;
71637342 outRec.x = outPt.x - 3;
....@@ -7165,15 +7344,18 @@
71657344 outRec.width = outRec.height = 6;
71667345 }
71677346
7168
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7347
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7348
+ )
71697349 {
71707350 Point pt = new Point(0, 0);
71717351 Rectangle rec = new Rectangle();
7172
- calcHotSpot(in, info, pt, rec);
7352
+ calcHotSpot(in, //clickInfo,
7353
+ pt, rec);
71737354 return rec;
71747355 }
71757356
7176
- void drawEditHandles0(ClickInfo info, int level)
7357
+ void drawEditHandles0(//ClickInfo clickInfo,
7358
+ int level)
71777359 {
71787360 if (level == 0)
71797361 {
....@@ -7182,16 +7364,19 @@
71827364 {
71837365 cVector origin = new cVector();
71847366 //LA.xformPos(origin, toParent, origin);
7185
- Rectangle spot = calcHotSpot(origin, info);
7367
+ if (this.clickInfo == null)
7368
+ this.clickInfo = new ClickInfo();
7369
+
7370
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71867371 Rectangle boundary = new Rectangle();
71877372 boundary.x = spot.x - 30;
71887373 boundary.y = spot.y - 30;
71897374 boundary.width = spot.width + 60;
71907375 boundary.height = spot.height + 60;
7191
- info.g.setColor(Color.red);
7376
+ clickInfo.g.setColor(Color.red);
71927377 int spotw = spot.x + spot.width;
71937378 int spoth = spot.y + spot.height;
7194
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71957380 // if (CameraPane.Xmin > spot.x)
71967381 // {
71977382 // CameraPane.Xmin = spot.x;
....@@ -7211,8 +7396,8 @@
72117396 spot.translate(32, 32);
72127397 spotw = spot.x + spot.width;
72137398 spoth = spot.y + spot.height;
7214
- info.g.setColor(Color.cyan);
7215
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7399
+ clickInfo.g.setColor(Color.cyan);
7400
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72167401 // if (CameraPane.Xmin > spot.x)
72177402 // {
72187403 // CameraPane.Xmin = spot.x;
....@@ -7232,9 +7417,9 @@
72327417 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72337418 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
72347419 spot.translate(0, -32);
7235
- info.g.setColor(Color.yellow);
7236
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7237
- info.g.setColor(Color.green);
7420
+ clickInfo.g.setColor(Color.yellow);
7421
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7422
+ clickInfo.g.setColor(Color.green);
72387423 // if (CameraPane.Xmin > spot.x)
72397424 // {
72407425 // CameraPane.Xmin = spot.x;
....@@ -7251,8 +7436,8 @@
72517436 // {
72527437 // CameraPane.Ymax = spoth;
72537438 // }
7254
- info.g.drawArc(boundary.x, boundary.y,
7255
- boundary.width, boundary.height, 0, 360);
7439
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7440
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72567441 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72577442 // if (CameraPane.Xmin > boundary.x)
72587443 // {
....@@ -7274,7 +7459,8 @@
72747459 }
72757460 }
72767461
7277
- boolean doEditClick0(ClickInfo info, int level)
7462
+ boolean doEditClick0(//ClickInfo clickInfo,
7463
+ int level)
72787464 {
72797465 if (level == 0)
72807466 {
....@@ -7283,8 +7469,8 @@
72837469
72847470 boolean retval = false;
72857471
7286
- startX = info.x;
7287
- startY = info.y;
7472
+ startX = clickInfo.x;
7473
+ startY = clickInfo.y;
72887474
72897475 hitSomething = -1;
72907476 cVector origin = new cVector();
....@@ -7294,22 +7480,51 @@
72947480 {
72957481 centerPt = new Point(0, 0);
72967482 }
7297
- calcHotSpot(origin, info, centerPt, spot);
7298
- if (spot.contains(info.x, info.y))
7483
+ calcHotSpot(origin, //info,
7484
+ centerPt, spot);
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
72997486 {
73007487 hitSomething = hitCenter;
73017488 retval = true;
73027489 }
73037490 spot.translate(32, 0);
7304
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
73057492 {
73067493 hitSomething = hitRotate;
73077494 retval = true;
73087495 }
73097496 spot.translate(0, 32);
7310
- if (spot.contains(info.x, info.y))
7497
+ if (spot.contains(clickInfo.x, clickInfo.y))
73117498 {
73127499 hitSomething = hitScale;
7500
+
7501
+ double scale = 0.005f * clickInfo.camera.Distance();
7502
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7503
+ double sign = 1;
7504
+ if (hScale < 0)
7505
+ {
7506
+ sign = -1;
7507
+ }
7508
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7509
+ if (hScale < 0.01)
7510
+ {
7511
+ //hScale = 0.01;
7512
+ }
7513
+
7514
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7515
+ sign = 1;
7516
+ if (vScale < 0)
7517
+ {
7518
+ sign = -1;
7519
+ }
7520
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7521
+ if (vScale < 0.01)
7522
+ {
7523
+ //vScale = 0.01;
7524
+ }
7525
+
7526
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7527
+
73137528 retval = true;
73147529 }
73157530
....@@ -7319,7 +7534,7 @@
73197534 }
73207535
73217536 //System.out.println("info.modifiers = " + info.modifiers);
7322
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7537
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73237538 //System.out.println("modified = " + modified);
73247539 //new Exception().printStackTrace();
73257540 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7347,7 +7562,8 @@
73477562 return true;
73487563 }
73497564
7350
- void doEditDrag0(ClickInfo info, boolean opposite)
7565
+ void doEditDrag0(//ClickInfo info,
7566
+ boolean opposite)
73517567 {
73527568 if (hitSomething == 0)
73537569 {
....@@ -7361,7 +7577,7 @@
73617577
73627578 //System.out.println("hitSomething = " + hitSomething);
73637579
7364
- double scale = 0.005f * info.camera.Distance();
7580
+ double scale = 0.005f * clickInfo.camera.Distance();
73657581
73667582 cVector xlate = new cVector();
73677583 //cVector xlate2 = new cVector();
....@@ -7395,8 +7611,8 @@
73957611 toParent[3][i] = xlate.get(i);
73967612 LA.matInvert(toParent, fromParent);
73977613 */
7398
- cVector delta = LA.newVector(0, 0, startY - info.y);
7399
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7614
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7615
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74007616
74017617 LA.matCopy(startMat, toParent);
74027618 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7405,7 +7621,7 @@
74057621 } else
74067622 {
74077623 //LA.xformDir(delta, info.camera.fromScreen, delta);
7408
- cVector up = new cVector(info.camera.up);
7624
+ cVector up = new cVector(clickInfo.camera.up);
74097625 cVector away = new cVector();
74107626 //cVector right2 = new cVector();
74117627 //LA.vecCross(up, cVector.Z, right);
....@@ -7422,19 +7638,19 @@
74227638 LA.xformDir(up, ClickInfo.matbuffer, up);
74237639 // if (!CameraPane.LOCALTRANSFORM)
74247640 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7425
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7641
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74267642 // if (!CameraPane.LOCALTRANSFORM)
74277643 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74287644 //LA.vecCross(up, cVector.Z, right2);
74297645
7430
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7646
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74317647
74327648 //System.out.println("DELTA0 = " + delta);
74337649 //System.out.println("AWAY = " + info.camera.away);
74347650 //System.out.println("UP = " + info.camera.up);
74357651 if (away.z > 0)
74367652 {
7437
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7653
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74387654 {
74397655 delta.x = -delta.x;
74407656 } else
....@@ -7449,7 +7665,7 @@
74497665 //System.out.println("DELTA1 = " + delta);
74507666 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74517667 //System.out.println("DELTA2 = " + delta);
7452
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7668
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74537669 LA.matCopy(startMat, toParent);
74547670 //System.out.println("DELTA3 = " + delta);
74557671 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7459,8 +7675,8 @@
74597675 break;
74607676
74617677 case hitRotate: // rotate
7462
- int dx = info.x - centerPt.x;
7463
- int dy = -(info.y - centerPt.y);
7678
+ int dx = clickInfo.x - centerPt.x;
7679
+ int dy = -(clickInfo.y - centerPt.y);
74647680 double angle = (double) Math.atan2(dx, dy);
74657681 angle = -(1.570796 - angle);
74667682
....@@ -7483,7 +7699,7 @@
74837699 }
74847700 /**/
74857701
7486
- switch (info.pane.RenderCamera().viewCode)
7702
+ switch (clickInfo.pane.RenderCamera().viewCode)
74877703 {
74887704 case 1: // '\001'
74897705 LA.matZRotate(toParent, angle);
....@@ -7510,7 +7726,7 @@
75107726 break;
75117727
75127728 case hitScale: // scale
7513
- double hScale = (double) (info.x - centerPt.x) / 32;
7729
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
75147730 double sign = 1;
75157731 if (hScale < 0)
75167732 {
....@@ -7522,7 +7738,7 @@
75227738 //hScale = 0.01;
75237739 }
75247740
7525
- double vScale = (double) (info.y - centerPt.y) / 32;
7741
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
75267742 sign = 1;
75277743 if (vScale < 0)
75287744 {
....@@ -7533,6 +7749,7 @@
75337749 {
75347750 //vScale = 0.01;
75357751 }
7752
+
75367753 LA.matCopy(startMat, toParent);
75377754 /**/
75387755 for (int i = 0; i < 3; i++)
....@@ -7542,14 +7759,14 @@
75427759 }
75437760 /**/
75447761
7545
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7762
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75467763
75477764 if (totalScale < 0.01)
75487765 {
75497766 totalScale = 0.01;
75507767 }
75517768
7552
- switch (info.pane.RenderCamera().viewCode)
7769
+ switch (clickInfo.pane.RenderCamera().viewCode)
75537770 {
75547771 case 3: // '\001'
75557772 if (modified || opposite)
....@@ -7616,7 +7833,7 @@
76167833 } // NEW ...
76177834
76187835
7619
- info.pane.repaint();
7836
+ clickInfo.pane.repaint();
76207837 }
76217838
76227839 boolean overflow = false;
....@@ -7796,6 +8013,10 @@
77968013 editWindow = null;
77978014 } // ?
77988015 }
8016
+ else
8017
+ {
8018
+ //editWindow.closeUI();
8019
+ }
77998020 }
78008021
78018022 boolean root; // patch for edit windows
....@@ -7953,6 +8174,10 @@
79538174 }
79548175
79558176 transient ObjEditor editWindow;
8177
+ transient ObjEditor manipWindow;
8178
+
8179
+ transient boolean pinned;
8180
+
79568181 transient ObjectUI objectUI;
79578182 public static int povDepth = 0;
79588183 private static cVector tbMin = new cVector();