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,8 +30,29 @@
2930 Object3D saveskeleton;
3031 //
3132
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>();
40
+
3241 ScriptNode scriptnode;
3342
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
+
3456 void InitOthers()
3557 {
3658 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -215,6 +237,9 @@
215237 // o.transientrep = this.bRep.support;
216238 // o.bRep.support = null;
217239 // }
240
+ o.selection = this.selection;
241
+ o.versionlist = this.versionlist;
242
+ o.versionindex = this.versionindex;
218243
219244 if (this.support != null)
220245 {
....@@ -235,6 +260,73 @@
235260 // this.bRep.support = null;
236261 // this.support = null;
237262 // 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;
238330 }
239331
240332 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -268,6 +360,11 @@
268360 {
269361 this.support.bRep = o.transientrep;
270362 }
363
+
364
+ this.selection = o.selection;
365
+
366
+ this.versionlist = o.versionlist;
367
+ this.versionindex = o.versionindex;
271368 // July 2019 if (this.bRep != null)
272369 // this.bRep.support = o.transientrep;
273370 // this.support = o.support;
....@@ -415,6 +512,7 @@
415512 }
416513
417514 boolean live = false;
515
+ transient boolean keepdontselect;
418516 boolean dontselect = false;
419517 boolean hide = false;
420518 boolean link2master = false; // performs reset support/master at each frame
....@@ -483,11 +581,11 @@
483581 }
484582 }
485583
486
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
487585
488586 int MemorySize()
489587 {
490
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
491589 {
492590 try
493591 {
....@@ -602,7 +700,7 @@
602700 {
603701 if (maxcount != 1)
604702 {
605
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
606704 }
607705
608706 toParentMarked = LA.newMatrix();
....@@ -999,6 +1097,9 @@
9991097
10001098 if (material == null || material.multiply)
10011099 return true;
1100
+
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
10021103
10031104 // Transparent objects are dynamic because we have to sort the triangles.
10041105 return material.opacity > 0.99;
....@@ -2281,11 +2382,6 @@
22812382
22822383 InitOthers();
22832384
2284
- if (this instanceof Camera)
2285
- {
2286
- material.shift = 90;
2287
- }
2288
-
22892385 material.multiply = multiply;
22902386
22912387 if (multiply)
....@@ -2426,6 +2522,11 @@
24262522 else
24272523 {
24282524 //((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");
24292530 }
24302531 }
24312532
....@@ -2555,7 +2656,8 @@
25552656 private static final int editSelf = 1;
25562657 private static final int editChild = 2;
25572658
2558
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
25592661 {
25602662 if (level == 0)
25612663 {
....@@ -2563,7 +2665,8 @@
25632665 return;
25642666
25652667 Object3D selectee;
2566
- 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))
25672670 {
25682671 selectee = (Object3D) e.nextElement();
25692672 }
....@@ -2571,19 +2674,22 @@
25712674 } else
25722675 {
25732676 //super.
2574
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
25752679 }
25762680 }
25772681
2578
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
25792684 {
25802685 doSomething = 0;
25812686 if (level == 0)
25822687 {
2583
- return doParentClick(info);
2688
+ return doParentClick(); //info);
25842689 }
25852690 if (//super.
2586
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
25872693 {
25882694 doSomething = 1;
25892695 return true;
....@@ -2593,7 +2699,7 @@
25932699 }
25942700 }
25952701
2596
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
25972703 {
25982704 if (selection == null)
25992705 {
....@@ -2606,7 +2712,8 @@
26062712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26072713 {
26082714 Object3D selectee = (Object3D) e.nextElement();
2609
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
26102717 {
26112718 childToDrag = selectee;
26122719 doSomething = 2;
....@@ -2618,13 +2725,15 @@
26182725 return retval;
26192726 }
26202727
2621
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
26222730 {
26232731 switch (doSomething)
26242732 {
26252733 case 1: // '\001'
26262734 //super.
2627
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
26282737 break;
26292738
26302739 case 2: // '\002'
....@@ -2637,11 +2746,13 @@
26372746 {
26382747 //sel.hitSomething = childToDrag.hitSomething;
26392748 //childToDrag.doEditDrag(info);
2640
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
26412751 } else
26422752 {
26432753 //super.
2644
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
26452756 }
26462757 }
26472758 break;
....@@ -2659,6 +2770,9 @@
26592770 {
26602771 deselectAll();
26612772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
26622776 ClickInfo newInfo = new ClickInfo();
26632777 newInfo.flags = info.flags;
26642778 newInfo.bounds = info.bounds;
....@@ -3106,7 +3220,7 @@
31063220 {
31073221 if (bRep != null)
31083222 {
3109
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31103224 Touch();
31113225 }
31123226 }
....@@ -3163,6 +3277,93 @@
31633277 blockloop = false;
31643278 }
31653279
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
+
31663367 void TransformChildren()
31673368 {
31683369 if (toParent != null)
....@@ -3516,15 +3717,47 @@
35163717
35173718 void ClearMaterials()
35183719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
35193725 ClearMaterial();
3520
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
35213727 {
3522
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
35233729 if (child == null)
35243730 continue;
35253731 child.ClearMaterials();
3526
- release(i);
35273732 }
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;
35283761 }
35293762
35303763 void FlipV(boolean flip)
....@@ -5409,6 +5642,51 @@
54095642 blockloop = false;
54105643 }
54115644
5645
+ void ResetSelectable()
5646
+ {
5647
+ if (blockloop)
5648
+ return;
5649
+
5650
+ blockloop = true;
5651
+
5652
+ keepdontselect = dontselect;
5653
+ dontselect = true;
5654
+
5655
+ Object3D child;
5656
+ int nb = Size();
5657
+ for (int i = 0; i < nb; i++)
5658
+ {
5659
+ child = (Object3D) get(i);
5660
+ if (child == null)
5661
+ continue;
5662
+ child.ResetSelectable();
5663
+ }
5664
+
5665
+ blockloop = false;
5666
+ }
5667
+
5668
+ void RestoreSelectable()
5669
+ {
5670
+ if (blockloop)
5671
+ return;
5672
+
5673
+ blockloop = true;
5674
+
5675
+ dontselect = keepdontselect;
5676
+
5677
+ Object3D child;
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ child = (Object3D) get(i);
5682
+ if (child == null)
5683
+ continue;
5684
+ child.RestoreSelectable();
5685
+ }
5686
+
5687
+ blockloop = false;
5688
+ }
5689
+
54125690 boolean IsSelected()
54135691 {
54145692 if (parent == null)
....@@ -5469,6 +5747,11 @@
54695747 if (fullname == null)
54705748 return "";
54715749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
54725755 // System.out.println("Fullname = " + fullname);
54735756
54745757 // Does not work on Windows due to C:
....@@ -5481,7 +5764,7 @@
54815764
54825765 if (split.length == 0)
54835766 {
5484
- return "";
5767
+ return fullname.pigment = "";
54855768 }
54865769
54875770 if (split.length <= 2)
....@@ -5489,22 +5772,27 @@
54895772 if (fullname.name.endsWith(":"))
54905773 {
54915774 // Windows
5492
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54935776 }
54945777
5495
- return split[0];
5778
+ return fullname.pigment = split[0];
54965779 }
54975780
54985781 // Windows
54995782 assert(split.length == 4);
55005783
5501
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
55025785 }
55035786
55045787 static String GetBump(cTexture fullname)
55055788 {
55065789 if (fullname == null)
55075790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
55085796
55095797 // System.out.println("Fullname = " + fullname);
55105798 // Does not work on Windows due to C:
....@@ -5516,12 +5804,12 @@
55165804
55175805 if (split.length == 0)
55185806 {
5519
- return "";
5807
+ return fullname.bump = "";
55205808 }
55215809
55225810 if (split.length == 1)
55235811 {
5524
- return "";
5812
+ return fullname.bump = "";
55255813 }
55265814
55275815 if (split.length == 2)
....@@ -5529,16 +5817,16 @@
55295817 if (fullname.name.endsWith(":"))
55305818 {
55315819 // Windows
5532
- return "";
5820
+ return fullname.bump = "";
55335821 }
55345822
5535
- return split[1];
5823
+ return fullname.bump = split[1];
55365824 }
55375825
55385826 // Windows
55395827 assert(split.length == 4);
55405828
5541
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
55425830 }
55435831
55445832 String GetPigmentTexture()
....@@ -5621,6 +5909,9 @@
56215909 texname = "";
56225910
56235911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
56245915 Touch();
56255916 }
56265917
....@@ -5694,6 +5985,8 @@
56945985
56955986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56965987
5988
+ GetTextures().bump = null;
5989
+
56975990 Touch();
56985991 }
56995992
....@@ -5714,6 +6007,38 @@
57146007
57156008 blockloop = true;
57166009 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);
57176042 blockloop = false;
57186043 }
57196044 }
....@@ -5742,6 +6067,11 @@
57426067 return false;
57436068
57446069 return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
57456075 }
57466076
57476077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
....@@ -5804,8 +6134,11 @@
58046134 if (support != null)
58056135 support = support;
58066136
5807
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5808
- 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.
58096142
58106143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58116144 {
....@@ -5815,8 +6148,9 @@
58156148 // usecalllists &= !(parent instanceof RandomNode);
58166149 // usecalllists = false;
58176150
5818
- if (GetBRep() != null)
5819
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
58206154 //System.out.println("draw " + this);
58216155 //new Exception().printStackTrace();
58226156
....@@ -5838,7 +6172,7 @@
58386172 if (!(this instanceof Composite))
58396173 touched = false;
58406174 //if (displaylist == -1 && usecalllists)
5841
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58426176 {
58436177 bRep.displaylist = display.GenList();
58446178 assert(bRep.displaylist != 0);
....@@ -5849,7 +6183,7 @@
58496183
58506184 //System.out.println("\tnew list " + list);
58516185 //gl.glDrawBuffer(gl.GL_NONE);
5852
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
58536187 {
58546188 // System.err.println("new list " + bRep.displaylist + " for " + this);
58556189 display.NewList(bRep.displaylist);
....@@ -5858,7 +6192,7 @@
58586192 CallList(display, root, selected, blocked);
58596193
58606194 // compiled = true;
5861
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
58626196 {
58636197 // System.err.println("end list " + bRep.displaylist + " for " + this);
58646198 display.EndList();
....@@ -7209,20 +7543,23 @@
72097543 }
72107544 }
72117545
7212
- 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)
72137550 {
7214
- int hc = info.bounds.x + info.bounds.width / 2;
7215
- int vc = info.bounds.y + info.bounds.height / 2;
7216
- 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;
72177554 if (toscreen == null)
72187555 {
7219
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72207557 }
72217558 cVector vec = in;
72227559 LA.xformPos(in, toscreen, in);
72237560 //System.out.println("Distance = " + info.camera.Distance());
7224
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7225
- 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();
72267563 outPt.x = hc + (int) vec.x;
72277564 outPt.y = vc - (int) vec.y;
72287565 outRec.x = outPt.x - 3;
....@@ -7230,15 +7567,18 @@
72307567 outRec.width = outRec.height = 6;
72317568 }
72327569
7233
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
72347572 {
72357573 Point pt = new Point(0, 0);
72367574 Rectangle rec = new Rectangle();
7237
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
72387577 return rec;
72397578 }
72407579
7241
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
72427582 {
72437583 if (level == 0)
72447584 {
....@@ -7247,16 +7587,19 @@
72477587 {
72487588 cVector origin = new cVector();
72497589 //LA.xformPos(origin, toParent, origin);
7250
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72517594 Rectangle boundary = new Rectangle();
72527595 boundary.x = spot.x - 30;
72537596 boundary.y = spot.y - 30;
72547597 boundary.width = spot.width + 60;
72557598 boundary.height = spot.height + 60;
7256
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
72577600 int spotw = spot.x + spot.width;
72587601 int spoth = spot.y + spot.height;
7259
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72607603 // if (CameraPane.Xmin > spot.x)
72617604 // {
72627605 // CameraPane.Xmin = spot.x;
....@@ -7273,11 +7616,6 @@
72737616 // {
72747617 // CameraPane.Ymax = spoth;
72757618 // }
7276
- spot.translate(32, 32);
7277
- spotw = spot.x + spot.width;
7278
- spoth = spot.y + spot.height;
7279
- info.g.setColor(Color.cyan);
7280
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72817619 // if (CameraPane.Xmin > spot.x)
72827620 // {
72837621 // CameraPane.Xmin = spot.x;
....@@ -7296,10 +7634,15 @@
72967634 // }
72977635 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72987636 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7299
- spot.translate(0, -32);
7300
- info.g.setColor(Color.yellow);
7301
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
- 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);
73037646 // if (CameraPane.Xmin > spot.x)
73047647 // {
73057648 // CameraPane.Xmin = spot.x;
....@@ -7316,8 +7659,9 @@
73167659 // {
73177660 // CameraPane.Ymax = spoth;
73187661 // }
7319
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
- (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);
73217665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73227666 // if (CameraPane.Xmin > boundary.x)
73237667 // {
....@@ -7339,7 +7683,8 @@
73397683 }
73407684 }
73417685
7342
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
73437688 {
73447689 if (level == 0)
73457690 {
....@@ -7348,8 +7693,8 @@
73487693
73497694 boolean retval = false;
73507695
7351
- startX = info.x;
7352
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
73537698
73547699 hitSomething = -1;
73557700 cVector origin = new cVector();
....@@ -7359,22 +7704,53 @@
73597704 {
73607705 centerPt = new Point(0, 0);
73617706 }
7362
- calcHotSpot(origin, info, centerPt, spot);
7363
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
73647710 {
73657711 hitSomething = hitCenter;
73667712 retval = true;
73677713 }
73687714 spot.translate(32, 0);
7369
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707716 {
73717717 hitSomething = hitRotate;
73727718 retval = true;
73737719 }
73747720 spot.translate(0, 32);
7375
- 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))
73767724 {
73777725 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
+
73787754 retval = true;
73797755 }
73807756
....@@ -7384,7 +7760,7 @@
73847760 }
73857761
73867762 //System.out.println("info.modifiers = " + info.modifiers);
7387
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73887764 //System.out.println("modified = " + modified);
73897765 //new Exception().printStackTrace();
73907766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7412,7 +7788,8 @@
74127788 return true;
74137789 }
74147790
7415
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
74167793 {
74177794 if (hitSomething == 0)
74187795 {
....@@ -7426,7 +7803,7 @@
74267803
74277804 //System.out.println("hitSomething = " + hitSomething);
74287805
7429
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
74307807
74317808 cVector xlate = new cVector();
74327809 //cVector xlate2 = new cVector();
....@@ -7440,7 +7817,9 @@
74407817
74417818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74427819
7443
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
74447823 {
74457824 //assert(false);
74467825 /*
....@@ -7460,8 +7839,8 @@
74607839 toParent[3][i] = xlate.get(i);
74617840 LA.matInvert(toParent, fromParent);
74627841 */
7463
- cVector delta = LA.newVector(0, 0, startY - info.y);
7464
- 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);
74657844
74667845 LA.matCopy(startMat, toParent);
74677846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7470,7 +7849,7 @@
74707849 } else
74717850 {
74727851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7473
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
74747853 cVector away = new cVector();
74757854 //cVector right2 = new cVector();
74767855 //LA.vecCross(up, cVector.Z, right);
....@@ -7487,19 +7866,19 @@
74877866 LA.xformDir(up, ClickInfo.matbuffer, up);
74887867 // if (!CameraPane.LOCALTRANSFORM)
74897868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7490
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74917870 // if (!CameraPane.LOCALTRANSFORM)
74927871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74937872 //LA.vecCross(up, cVector.Z, right2);
74947873
7495
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74967875
74977876 //System.out.println("DELTA0 = " + delta);
74987877 //System.out.println("AWAY = " + info.camera.away);
74997878 //System.out.println("UP = " + info.camera.up);
75007879 if (away.z > 0)
75017880 {
7502
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75037882 {
75047883 delta.x = -delta.x;
75057884 } else
....@@ -7514,7 +7893,7 @@
75147893 //System.out.println("DELTA1 = " + delta);
75157894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75167895 //System.out.println("DELTA2 = " + delta);
7517
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75187897 LA.matCopy(startMat, toParent);
75197898 //System.out.println("DELTA3 = " + delta);
75207899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7524,8 +7903,8 @@
75247903 break;
75257904
75267905 case hitRotate: // rotate
7527
- int dx = info.x - centerPt.x;
7528
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
75297908 double angle = (double) Math.atan2(dx, dy);
75307909 angle = -(1.570796 - angle);
75317910
....@@ -7534,7 +7913,7 @@
75347913
75357914 if (modified)
75367915 {
7537
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
75387917 angle /= (Math.PI / 4);
75397918 angle = Math.floor(angle + 0.5);
75407919 angle *= (Math.PI / 4);
....@@ -7548,7 +7927,7 @@
75487927 }
75497928 /**/
75507929
7551
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
75527931 {
75537932 case 1: // '\001'
75547933 LA.matZRotate(toParent, angle);
....@@ -7575,7 +7954,7 @@
75757954 break;
75767955
75777956 case hitScale: // scale
7578
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75797958 double sign = 1;
75807959 if (hScale < 0)
75817960 {
....@@ -7587,7 +7966,7 @@
75877966 //hScale = 0.01;
75887967 }
75897968
7590
- double vScale = (double) (info.y - centerPt.y) / 32;
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75917970 sign = 1;
75927971 if (vScale < 0)
75937972 {
....@@ -7598,6 +7977,7 @@
75987977 {
75997978 //vScale = 0.01;
76007979 }
7980
+
76017981 LA.matCopy(startMat, toParent);
76027982 /**/
76037983 for (int i = 0; i < 3; i++)
....@@ -7607,33 +7987,39 @@
76077987 }
76087988 /**/
76097989
7610
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76117991
76127992 if (totalScale < 0.01)
76137993 {
76147994 totalScale = 0.01;
76157995 }
76167996
7617
- switch (info.pane.RenderCamera().viewCode)
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
76187998 {
76197999 case 3: // '\001'
76208000 if (modified || opposite)
76218001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
76228005 //LA.matScale(toParent, 1, hScale, vScale);
7623
- LA.matScale(toParent, totalScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
76248007 } // vScale, 1);
76258008 else
76268009 {
76278010 // EXCEPTION!
7628
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
76298012 } // vScale, 1);
76308013 break;
76318014
76328015 case 2: // '\002'
76338016 if (modified || opposite)
76348017 {
7635
- //LA.matScale(toParent, hScale, 1, vScale);
7636
- 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);
76378023 } else
76388024 {
76398025 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7643,8 +8029,11 @@
76438029 case 1: // '\003'
76448030 if (modified || opposite)
76458031 {
7646
- //LA.matScale(toParent, hScale, vScale, 1);
7647
- 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);
76488037 } else
76498038 {
76508039 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7681,7 +8070,7 @@
76818070 } // NEW ...
76828071
76838072
7684
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
76858074 }
76868075
76878076 boolean overflow = false;
....@@ -7792,10 +8181,10 @@
77928181 } // + super.toString();
77938182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
77948183
7795
- if (!Globals.ADVANCED)
7796
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
77978186
7798
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
77998188 }
78008189
78018190 public int hashCode()