Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -22,6 +22,7 @@
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
2728 // TEMPORARY for mocap undo. No need to be transient.
....@@ -29,11 +30,29 @@
2930 Object3D saveskeleton;
3031 //
3132
32
- byte[] versions[];
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
3337 int versionindex = -1;
3438
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3541 ScriptNode scriptnode;
3642
43
+ int VersionCount()
44
+ {
45
+ int count = 0;
46
+
47
+ for (int i = versionlist.length; --i >= 0;)
48
+ {
49
+ if (versionlist[i] != null)
50
+ count++;
51
+ }
52
+
53
+ return count;
54
+ }
55
+
3756 void InitOthers()
3857 {
3958 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -219,7 +238,7 @@
219238 // o.bRep.support = null;
220239 // }
221240 o.selection = this.selection;
222
- o.versions = this.versions;
241
+ o.versionlist = this.versionlist;
223242 o.versionindex = this.versionindex;
224243
225244 if (this.support != null)
....@@ -241,6 +260,73 @@
241260 // this.bRep.support = null;
242261 // this.support = null;
243262 // this.fileparent = null;
263
+ }
264
+
265
+// Object3D GetObject(java.util.UUID uuid)
266
+// {
267
+// if (this.uuid.equals(uuid))
268
+// return this;
269
+//
270
+// if (blockloop)
271
+// return null;
272
+//
273
+// blockloop = true;
274
+//
275
+// for (int i=0; i<Size(); i++)
276
+// {
277
+// Object3D o = get(i).GetObject(uuid);
278
+//
279
+// if (o != null)
280
+// return o;
281
+// }
282
+//
283
+// blockloop = false;
284
+//
285
+// return null;
286
+// }
287
+
288
+ transient boolean tag;
289
+
290
+ void TagObjects(Object3D o, boolean tag)
291
+ {
292
+ if (blockloop)
293
+ return;
294
+
295
+ o.tag = tag;
296
+
297
+ if (o == this)
298
+ return;
299
+
300
+ blockloop = true;
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
307
+ blockloop = false;
308
+ }
309
+
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
314
+
315
+ blockloop = true;
316
+
317
+ boolean hasTags = false;
318
+
319
+ for (int i=0; i<Size(); i++)
320
+ {
321
+ hasTags |= get(i).tag || get(i).HasTags();
322
+
323
+ if (hasTags)
324
+ break;
325
+ }
326
+
327
+ blockloop = false;
328
+
329
+ return hasTags;
244330 }
245331
246332 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -277,7 +363,7 @@
277363
278364 this.selection = o.selection;
279365
280
- this.versions = o.versions;
366
+ this.versionlist = o.versionlist;
281367 this.versionindex = o.versionindex;
282368 // July 2019 if (this.bRep != null)
283369 // this.bRep.support = o.transientrep;
....@@ -495,11 +581,11 @@
495581 }
496582 }
497583
498
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
499585
500586 int MemorySize()
501587 {
502
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
503589 {
504590 try
505591 {
....@@ -614,7 +700,7 @@
614700 {
615701 if (maxcount != 1)
616702 {
617
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
618704 }
619705
620706 toParentMarked = LA.newMatrix();
....@@ -1011,6 +1097,9 @@
10111097
10121098 if (material == null || material.multiply)
10131099 return true;
1100
+
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
10141103
10151104 // Transparent objects are dynamic because we have to sort the triangles.
10161105 return material.opacity > 0.99;
....@@ -2293,11 +2382,6 @@
22932382
22942383 InitOthers();
22952384
2296
- if (this instanceof Camera)
2297
- {
2298
- material.shift = 90;
2299
- }
2300
-
23012385 material.multiply = multiply;
23022386
23032387 if (multiply)
....@@ -2438,6 +2522,11 @@
24382522 else
24392523 {
24402524 //((ObjEditor)editWindow).SetupUI2(null);
2525
+ if (objectUI != null)
2526
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2527
+ else
2528
+ //new Exception().printStackTrace();
2529
+ System.err.println("objectUI is null");
24412530 }
24422531 }
24432532
....@@ -2567,7 +2656,8 @@
25672656 private static final int editSelf = 1;
25682657 private static final int editChild = 2;
25692658
2570
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
25712661 {
25722662 if (level == 0)
25732663 {
....@@ -2575,7 +2665,8 @@
25752665 return;
25762666
25772667 Object3D selectee;
2578
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2668
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2669
+ level + 1))
25792670 {
25802671 selectee = (Object3D) e.nextElement();
25812672 }
....@@ -2583,19 +2674,22 @@
25832674 } else
25842675 {
25852676 //super.
2586
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
25872679 }
25882680 }
25892681
2590
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
25912684 {
25922685 doSomething = 0;
25932686 if (level == 0)
25942687 {
2595
- return doParentClick(info);
2688
+ return doParentClick(); //info);
25962689 }
25972690 if (//super.
2598
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
25992693 {
26002694 doSomething = 1;
26012695 return true;
....@@ -2605,7 +2699,7 @@
26052699 }
26062700 }
26072701
2608
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
26092703 {
26102704 if (selection == null)
26112705 {
....@@ -2618,7 +2712,8 @@
26182712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192713 {
26202714 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
26222717 {
26232718 childToDrag = selectee;
26242719 doSomething = 2;
....@@ -2630,13 +2725,15 @@
26302725 return retval;
26312726 }
26322727
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
26342730 {
26352731 switch (doSomething)
26362732 {
26372733 case 1: // '\001'
26382734 //super.
2639
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
26402737 break;
26412738
26422739 case 2: // '\002'
....@@ -2649,11 +2746,13 @@
26492746 {
26502747 //sel.hitSomething = childToDrag.hitSomething;
26512748 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
26532751 } else
26542752 {
26552753 //super.
2656
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
26572756 }
26582757 }
26592758 break;
....@@ -2671,6 +2770,9 @@
26712770 {
26722771 deselectAll();
26732772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
26742776 ClickInfo newInfo = new ClickInfo();
26752777 newInfo.flags = info.flags;
26762778 newInfo.bounds = info.bounds;
....@@ -3175,6 +3277,93 @@
31753277 blockloop = false;
31763278 }
31773279
3280
+ public void ResetTransform(int mask)
3281
+ {
3282
+ Object3D obj = this;
3283
+
3284
+ if (mask == -1)
3285
+ {
3286
+ if (obj instanceof Camera) // jan 2014
3287
+ {
3288
+ LA.matIdentity(obj.toParent);
3289
+ LA.matIdentity(obj.fromParent);
3290
+ }
3291
+ else
3292
+ {
3293
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3294
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3295
+ }
3296
+ return;
3297
+ }
3298
+
3299
+ if ((mask&2) != 0) // Scale/rotation
3300
+ {
3301
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3302
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3303
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3304
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3305
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3306
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3307
+ }
3308
+ if ((mask&1) != 0) // Translation
3309
+ {
3310
+ if (obj.toParent != null)
3311
+ {
3312
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3313
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3314
+ }
3315
+ }
3316
+ }
3317
+
3318
+ public void TextureRatioTransform(int axis)
3319
+ {
3320
+ cTexture tex = GetTextures();
3321
+
3322
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3323
+
3324
+ try
3325
+ {
3326
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3327
+ }
3328
+ catch (Exception e)
3329
+ {
3330
+ System.err.println("FAIL TextureRatio: " + this);
3331
+ }
3332
+
3333
+ LA.matIdentity(Object3D.mat);
3334
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3335
+
3336
+ if (toParent == null)
3337
+ {
3338
+ toParent = LA.newMatrix();
3339
+ fromParent = LA.newMatrix();
3340
+ }
3341
+
3342
+ ResetTransform(2);
3343
+
3344
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3345
+ LA.matInvert(fromParent, toParent);
3346
+ }
3347
+
3348
+ void TextureRatio(int axis)
3349
+ {
3350
+ if (blockloop)
3351
+ return;
3352
+
3353
+ blockloop = true;
3354
+
3355
+ TextureRatioTransform(axis);
3356
+
3357
+ for (int i=Size(); --i>=0;)
3358
+ {
3359
+ Object3D v = get(i);
3360
+
3361
+ v.TextureRatio(axis);
3362
+ }
3363
+
3364
+ blockloop = false;
3365
+ }
3366
+
31783367 void TransformChildren()
31793368 {
31803369 if (toParent != null)
....@@ -3528,15 +3717,47 @@
35283717
35293718 void ClearMaterials()
35303719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
35313725 ClearMaterial();
3532
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
35333727 {
3534
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
35353729 if (child == null)
35363730 continue;
35373731 child.ClearMaterials();
3538
- release(i);
35393732 }
3733
+
3734
+ blockloop = false;
3735
+ }
3736
+
3737
+ void ClearVersionList()
3738
+ {
3739
+ this.versionlist = null;
3740
+ this.versionindex = -1;
3741
+ this.versiontable = null;
3742
+ }
3743
+
3744
+ void ClearVersions()
3745
+ {
3746
+ if (blockloop)
3747
+ return;
3748
+
3749
+ blockloop = true;
3750
+
3751
+ ClearVersionList();
3752
+ for (int i = 0; i < Size(); i++)
3753
+ {
3754
+ Object3D child = (Object3D) get(i);
3755
+ if (child == null)
3756
+ continue;
3757
+ child.ClearVersions();
3758
+ }
3759
+
3760
+ blockloop = false;
35403761 }
35413762
35423763 void FlipV(boolean flip)
....@@ -5526,6 +5747,11 @@
55265747 if (fullname == null)
55275748 return "";
55285749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
55295755 // System.out.println("Fullname = " + fullname);
55305756
55315757 // Does not work on Windows due to C:
....@@ -5538,7 +5764,7 @@
55385764
55395765 if (split.length == 0)
55405766 {
5541
- return "";
5767
+ return fullname.pigment = "";
55425768 }
55435769
55445770 if (split.length <= 2)
....@@ -5546,22 +5772,27 @@
55465772 if (fullname.name.endsWith(":"))
55475773 {
55485774 // Windows
5549
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55505776 }
55515777
5552
- return split[0];
5778
+ return fullname.pigment = split[0];
55535779 }
55545780
55555781 // Windows
55565782 assert(split.length == 4);
55575783
5558
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
55595785 }
55605786
55615787 static String GetBump(cTexture fullname)
55625788 {
55635789 if (fullname == null)
55645790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
55655796
55665797 // System.out.println("Fullname = " + fullname);
55675798 // Does not work on Windows due to C:
....@@ -5573,12 +5804,12 @@
55735804
55745805 if (split.length == 0)
55755806 {
5576
- return "";
5807
+ return fullname.bump = "";
55775808 }
55785809
55795810 if (split.length == 1)
55805811 {
5581
- return "";
5812
+ return fullname.bump = "";
55825813 }
55835814
55845815 if (split.length == 2)
....@@ -5586,16 +5817,16 @@
55865817 if (fullname.name.endsWith(":"))
55875818 {
55885819 // Windows
5589
- return "";
5820
+ return fullname.bump = "";
55905821 }
55915822
5592
- return split[1];
5823
+ return fullname.bump = split[1];
55935824 }
55945825
55955826 // Windows
55965827 assert(split.length == 4);
55975828
5598
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
55995830 }
56005831
56015832 String GetPigmentTexture()
....@@ -5678,6 +5909,9 @@
56785909 texname = "";
56795910
56805911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
56815915 Touch();
56825916 }
56835917
....@@ -5751,6 +5985,8 @@
57515985
57525986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57535987
5988
+ GetTextures().bump = null;
5989
+
57545990 Touch();
57555991 }
57565992
....@@ -5771,6 +6007,38 @@
57716007
57726008 blockloop = true;
57736009 child.ResetBumpTexture();
6010
+ blockloop = false;
6011
+ }
6012
+ }
6013
+
6014
+ void EmbedTextures(boolean embed)
6015
+ {
6016
+ if (blockloop)
6017
+ return;
6018
+
6019
+ //if (GetTextures() != null)
6020
+ if (embed)
6021
+ CameraPane.EmbedTextures(GetTextures());
6022
+ else
6023
+ {
6024
+ GetTextures().pigmentdata = null;
6025
+ GetTextures().bumpdata = null;
6026
+ GetTextures().pw = 0;
6027
+ GetTextures().ph = 0;
6028
+ GetTextures().bw = 0;
6029
+ GetTextures().bh = 0;
6030
+ }
6031
+
6032
+ int nb = Size();
6033
+ for (int i = 0; i < nb; i++)
6034
+ {
6035
+ Object3D child = (Object3D) get(i);
6036
+
6037
+ if (child == null)
6038
+ continue;
6039
+
6040
+ blockloop = true;
6041
+ child.EmbedTextures(embed);
57746042 blockloop = false;
57756043 }
57766044 }
....@@ -5799,6 +6067,11 @@
57996067 return false;
58006068
58016069 return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
58026075 }
58036076
58046077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
....@@ -5861,8 +6134,11 @@
58616134 if (support != null)
58626135 support = support;
58636136
5864
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5865
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6137
+ boolean usecalllists = !IsDynamic() &&
6138
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6139
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6140
+
6141
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58666142
58676143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58686144 {
....@@ -5872,8 +6148,9 @@
58726148 // usecalllists &= !(parent instanceof RandomNode);
58736149 // usecalllists = false;
58746150
5875
- if (GetBRep() != null)
5876
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
58776154 //System.out.println("draw " + this);
58786155 //new Exception().printStackTrace();
58796156
....@@ -5895,7 +6172,7 @@
58956172 if (!(this instanceof Composite))
58966173 touched = false;
58976174 //if (displaylist == -1 && usecalllists)
5898
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58996176 {
59006177 bRep.displaylist = display.GenList();
59016178 assert(bRep.displaylist != 0);
....@@ -5906,7 +6183,7 @@
59066183
59076184 //System.out.println("\tnew list " + list);
59086185 //gl.glDrawBuffer(gl.GL_NONE);
5909
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
59106187 {
59116188 // System.err.println("new list " + bRep.displaylist + " for " + this);
59126189 display.NewList(bRep.displaylist);
....@@ -5915,7 +6192,7 @@
59156192 CallList(display, root, selected, blocked);
59166193
59176194 // compiled = true;
5918
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
59196196 {
59206197 // System.err.println("end list " + bRep.displaylist + " for " + this);
59216198 display.EndList();
....@@ -7266,20 +7543,23 @@
72667543 }
72677544 }
72687545
7269
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7546
+ static ClickInfo clickInfo = new ClickInfo();
7547
+
7548
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7549
+ Point outPt, Rectangle outRec)
72707550 {
7271
- int hc = info.bounds.x + info.bounds.width / 2;
7272
- int vc = info.bounds.y + info.bounds.height / 2;
7273
- double[][] toscreen = info.toScreen;
7551
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7552
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7553
+ double[][] toscreen = clickInfo.toScreen;
72747554 if (toscreen == null)
72757555 {
7276
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72777557 }
72787558 cVector vec = in;
72797559 LA.xformPos(in, toscreen, in);
72807560 //System.out.println("Distance = " + info.camera.Distance());
7281
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7282
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72837563 outPt.x = hc + (int) vec.x;
72847564 outPt.y = vc - (int) vec.y;
72857565 outRec.x = outPt.x - 3;
....@@ -7287,15 +7567,18 @@
72877567 outRec.width = outRec.height = 6;
72887568 }
72897569
7290
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
72917572 {
72927573 Point pt = new Point(0, 0);
72937574 Rectangle rec = new Rectangle();
7294
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
72957577 return rec;
72967578 }
72977579
7298
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
72997582 {
73007583 if (level == 0)
73017584 {
....@@ -7304,16 +7587,19 @@
73047587 {
73057588 cVector origin = new cVector();
73067589 //LA.xformPos(origin, toParent, origin);
7307
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73087594 Rectangle boundary = new Rectangle();
73097595 boundary.x = spot.x - 30;
73107596 boundary.y = spot.y - 30;
73117597 boundary.width = spot.width + 60;
73127598 boundary.height = spot.height + 60;
7313
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
73147600 int spotw = spot.x + spot.width;
73157601 int spoth = spot.y + spot.height;
7316
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73177603 // if (CameraPane.Xmin > spot.x)
73187604 // {
73197605 // CameraPane.Xmin = spot.x;
....@@ -7330,11 +7616,6 @@
73307616 // {
73317617 // CameraPane.Ymax = spoth;
73327618 // }
7333
- spot.translate(32, 32);
7334
- spotw = spot.x + spot.width;
7335
- spoth = spot.y + spot.height;
7336
- info.g.setColor(Color.cyan);
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387619 // if (CameraPane.Xmin > spot.x)
73397620 // {
73407621 // CameraPane.Xmin = spot.x;
....@@ -7353,10 +7634,15 @@
73537634 // }
73547635 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73557636 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7356
- spot.translate(0, -32);
7357
- info.g.setColor(Color.yellow);
7358
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7359
- info.g.setColor(Color.green);
7637
+ spot.translate(32, 0);
7638
+ clickInfo.g.setColor(Color.yellow);
7639
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7640
+
7641
+ spot.translate(32, 64);
7642
+ spotw = spot.x + spot.width;
7643
+ spoth = spot.y + spot.height;
7644
+ clickInfo.g.setColor(Color.cyan);
7645
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73607646 // if (CameraPane.Xmin > spot.x)
73617647 // {
73627648 // CameraPane.Xmin = spot.x;
....@@ -7373,8 +7659,9 @@
73737659 // {
73747660 // CameraPane.Ymax = spoth;
73757661 // }
7376
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7377
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
7662
+ clickInfo.g.setColor(Color.green);
7663
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7664
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73787665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73797666 // if (CameraPane.Xmin > boundary.x)
73807667 // {
....@@ -7396,7 +7683,8 @@
73967683 }
73977684 }
73987685
7399
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
74007688 {
74017689 if (level == 0)
74027690 {
....@@ -7405,8 +7693,8 @@
74057693
74067694 boolean retval = false;
74077695
7408
- startX = info.x;
7409
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
74107698
74117699 hitSomething = -1;
74127700 cVector origin = new cVector();
....@@ -7416,22 +7704,53 @@
74167704 {
74177705 centerPt = new Point(0, 0);
74187706 }
7419
- calcHotSpot(origin, info, centerPt, spot);
7420
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
74217710 {
74227711 hitSomething = hitCenter;
74237712 retval = true;
74247713 }
74257714 spot.translate(32, 0);
7426
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
74277716 {
74287717 hitSomething = hitRotate;
74297718 retval = true;
74307719 }
74317720 spot.translate(0, 32);
7432
- if (spot.contains(info.x, info.y))
7721
+ spot.translate(32, 0);
7722
+ spot.translate(0, 32);
7723
+ if (spot.contains(clickInfo.x, clickInfo.y))
74337724 {
74347725 hitSomething = hitScale;
7726
+
7727
+ double scale = 0.005f * clickInfo.camera.Distance();
7728
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7729
+ double sign = 1;
7730
+ if (hScale < 0)
7731
+ {
7732
+ sign = -1;
7733
+ }
7734
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7735
+ if (hScale < 0.01)
7736
+ {
7737
+ //hScale = 0.01;
7738
+ }
7739
+
7740
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7741
+ sign = 1;
7742
+ if (vScale < 0)
7743
+ {
7744
+ sign = -1;
7745
+ }
7746
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7747
+ if (vScale < 0.01)
7748
+ {
7749
+ //vScale = 0.01;
7750
+ }
7751
+
7752
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7753
+
74357754 retval = true;
74367755 }
74377756
....@@ -7441,7 +7760,7 @@
74417760 }
74427761
74437762 //System.out.println("info.modifiers = " + info.modifiers);
7444
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74457764 //System.out.println("modified = " + modified);
74467765 //new Exception().printStackTrace();
74477766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7469,7 +7788,8 @@
74697788 return true;
74707789 }
74717790
7472
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
74737793 {
74747794 if (hitSomething == 0)
74757795 {
....@@ -7483,7 +7803,7 @@
74837803
74847804 //System.out.println("hitSomething = " + hitSomething);
74857805
7486
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
74877807
74887808 cVector xlate = new cVector();
74897809 //cVector xlate2 = new cVector();
....@@ -7497,7 +7817,9 @@
74977817
74987818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74997819
7500
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
75017823 {
75027824 //assert(false);
75037825 /*
....@@ -7517,8 +7839,8 @@
75177839 toParent[3][i] = xlate.get(i);
75187840 LA.matInvert(toParent, fromParent);
75197841 */
7520
- cVector delta = LA.newVector(0, 0, startY - info.y);
7521
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7842
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7843
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75227844
75237845 LA.matCopy(startMat, toParent);
75247846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7527,7 +7849,7 @@
75277849 } else
75287850 {
75297851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7530
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
75317853 cVector away = new cVector();
75327854 //cVector right2 = new cVector();
75337855 //LA.vecCross(up, cVector.Z, right);
....@@ -7544,19 +7866,19 @@
75447866 LA.xformDir(up, ClickInfo.matbuffer, up);
75457867 // if (!CameraPane.LOCALTRANSFORM)
75467868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7547
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75487870 // if (!CameraPane.LOCALTRANSFORM)
75497871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75507872 //LA.vecCross(up, cVector.Z, right2);
75517873
7552
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75537875
75547876 //System.out.println("DELTA0 = " + delta);
75557877 //System.out.println("AWAY = " + info.camera.away);
75567878 //System.out.println("UP = " + info.camera.up);
75577879 if (away.z > 0)
75587880 {
7559
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75607882 {
75617883 delta.x = -delta.x;
75627884 } else
....@@ -7571,7 +7893,7 @@
75717893 //System.out.println("DELTA1 = " + delta);
75727894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75737895 //System.out.println("DELTA2 = " + delta);
7574
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75757897 LA.matCopy(startMat, toParent);
75767898 //System.out.println("DELTA3 = " + delta);
75777899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7581,8 +7903,8 @@
75817903 break;
75827904
75837905 case hitRotate: // rotate
7584
- int dx = info.x - centerPt.x;
7585
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
75867908 double angle = (double) Math.atan2(dx, dy);
75877909 angle = -(1.570796 - angle);
75887910
....@@ -7591,7 +7913,7 @@
75917913
75927914 if (modified)
75937915 {
7594
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
75957917 angle /= (Math.PI / 4);
75967918 angle = Math.floor(angle + 0.5);
75977919 angle *= (Math.PI / 4);
....@@ -7605,7 +7927,7 @@
76057927 }
76067928 /**/
76077929
7608
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
76097931 {
76107932 case 1: // '\001'
76117933 LA.matZRotate(toParent, angle);
....@@ -7632,7 +7954,7 @@
76327954 break;
76337955
76347956 case hitScale: // scale
7635
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
76367958 double sign = 1;
76377959 if (hScale < 0)
76387960 {
....@@ -7644,7 +7966,7 @@
76447966 //hScale = 0.01;
76457967 }
76467968
7647
- double vScale = (double) (info.y - centerPt.y) / 32;
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76487970 sign = 1;
76497971 if (vScale < 0)
76507972 {
....@@ -7655,6 +7977,7 @@
76557977 {
76567978 //vScale = 0.01;
76577979 }
7980
+
76587981 LA.matCopy(startMat, toParent);
76597982 /**/
76607983 for (int i = 0; i < 3; i++)
....@@ -7664,33 +7987,39 @@
76647987 }
76657988 /**/
76667989
7667
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76687991
76697992 if (totalScale < 0.01)
76707993 {
76717994 totalScale = 0.01;
76727995 }
76737996
7674
- switch (info.pane.RenderCamera().viewCode)
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
76757998 {
76767999 case 3: // '\001'
76778000 if (modified || opposite)
76788001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
76798005 //LA.matScale(toParent, 1, hScale, vScale);
7680
- LA.matScale(toParent, totalScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
76818007 } // vScale, 1);
76828008 else
76838009 {
76848010 // EXCEPTION!
7685
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
76868012 } // vScale, 1);
76878013 break;
76888014
76898015 case 2: // '\002'
76908016 if (modified || opposite)
76918017 {
7692
- //LA.matScale(toParent, hScale, 1, vScale);
7693
- LA.matScale(toParent, 1, totalScale, 1);
8018
+ if (modified) // && opposite)
8019
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8020
+ else
8021
+ //LA.matScale(toParent, hScale, 1, vScale);
8022
+ LA.matScale(toParent, 1, totalScale, 1);
76948023 } else
76958024 {
76968025 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7700,8 +8029,11 @@
77008029 case 1: // '\003'
77018030 if (modified || opposite)
77028031 {
7703
- //LA.matScale(toParent, hScale, vScale, 1);
7704
- LA.matScale(toParent, 1, 1, totalScale);
8032
+ if (modified) // && opposite)
8033
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8034
+ else
8035
+ //LA.matScale(toParent, hScale, vScale, 1);
8036
+ LA.matScale(toParent, 1, 1, totalScale);
77058037 } else
77068038 {
77078039 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7738,7 +8070,7 @@
77388070 } // NEW ...
77398071
77408072
7741
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
77428074 }
77438075
77448076 boolean overflow = false;
....@@ -7849,10 +8181,10 @@
78498181 } // + super.toString();
78508182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
78518183
7852
- if (!Globals.ADVANCED)
7853
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
78548186
7855
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
78568188 }
78578189
78588190 public int hashCode()