Normand Briere
2019-06-24 c67da2e5d8655704601d6d06e8bc60aabe212253
Object3D.java
....@@ -14,11 +14,20 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
24
+
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
2231
2332 ScriptNode scriptnode;
2433
....@@ -100,64 +109,136 @@
100109
101110 // transient boolean reduced; // for morph reduction
102111
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105114
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
108117
109
-void SaveSupports()
110
-{
111
- if (blockloop)
112
- return;
113
-
114
- transientsupport = support;
115
- transientlink2master = link2master;
116
-
117
- support = null;
118
- link2master = false;
119
-
120
- if (bRep != null)
118
+ void SaveSupports()
121119 {
122
- bRep.SaveSupports();
123
- }
124
-
125
- for (int i = 0; i < Size(); i++)
126
- {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
130
- blockloop = true;
131
- child.SaveSupports();
132
- blockloop = false;
133
- }
134
-}
120
+ if (blockloop)
121
+ return;
135122
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
140125
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
147
- {
148
- bRep.RestoreSupports();
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
149143 }
150
-
151
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
152146 {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
159169 }
160
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
161242
162243 // MOCAP SUPPORT
163244 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +381,7 @@
300381 }
301382
302383 boolean live = false;
384
+ boolean dontselect = false;
303385 boolean hide = false;
304386 boolean link2master = false; // performs reset support/master at each frame
305387 boolean marked = false; // animation node
....@@ -481,12 +563,14 @@
481563 toParent = LA.newMatrix();
482564 fromParent = LA.newMatrix();
483565 }
566
+
484567 if (toParentMarked == null)
485568 {
486569 if (maxcount != 1)
487570 {
488571 new Exception().printStackTrace();
489572 }
573
+
490574 toParentMarked = LA.newMatrix();
491575 fromParentMarked = LA.newMatrix();
492576 }
....@@ -774,7 +858,7 @@
774858 if (step == 0)
775859 step = 1;
776860 if (maxcount == 0)
777
- maxcount = 2048; // 4;
861
+ maxcount = 128; // 2048; // 4;
778862 // if (acceleration == 0)
779863 // acceleration = 10;
780864 if (delay == 0) // serial
....@@ -797,7 +881,7 @@
797881
798882 if (marked && Globals.isLIVE() && live &&
799883 //TEMP21aug2018
800
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801885 currentframe != Globals.framecount)
802886 {
803887 currentframe = Globals.framecount;
....@@ -809,7 +893,8 @@
809893
810894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811895
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
813898 {
814899 countdown = 1;
815900 delay = speedup?8:1;
....@@ -881,6 +966,7 @@
881966 if (material == null || material.multiply)
882967 return true;
883968
969
+ // Transparent objects are dynamic because we have to sort the triangles.
884970 return material.opacity > 0.99;
885971 }
886972
....@@ -1834,12 +1920,15 @@
18341920 if (obj.name == null)
18351921 continue; // can't be a null one
18361922
1923
+ // Try perfect match first.
18371924 if (n.equals(obj.name))
18381925 {
18391926 theobj = obj;
18401927 count++;
18411928 }
18421929 }
1930
+
1931
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18431932
18441933 if (count != 1)
18451934 for (int i=Size(); --i>=0;)
....@@ -2299,6 +2388,10 @@
22992388 }
23002389 */
23012390 }
2391
+ else
2392
+ {
2393
+ //((ObjEditor)editWindow).SetupUI2(null);
2394
+ }
23022395 }
23032396
23042397 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2624,6 +2717,18 @@
26242717 //Touch();
26252718 }
26262719
2720
+ void GenNormalsMeshS()
2721
+ {
2722
+ selection.GenNormalsMesh();
2723
+// for (int i=0; i<selection.size(); i++)
2724
+// {
2725
+// Object3D selectee = (Object3D) selection.elementAt(i);
2726
+// selectee.GenNormals(crease);
2727
+// }
2728
+
2729
+ //Touch();
2730
+ }
2731
+
26272732 void ClearColorsS()
26282733 {
26292734 selection.ClearColors();
....@@ -2755,6 +2860,24 @@
27552860 if (child == null)
27562861 continue;
27572862 child.GenNormals(crease);
2863
+// Children().release(i);
2864
+ }
2865
+ blockloop = false;
2866
+ }
2867
+
2868
+ void GenNormalsMesh()
2869
+ {
2870
+ if (blockloop)
2871
+ return;
2872
+
2873
+ blockloop = true;
2874
+ GenNormalsMesh0();
2875
+ for (int i = 0; i < Children().Size(); i++)
2876
+ {
2877
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2878
+ if (child == null)
2879
+ continue;
2880
+ child.GenNormalsMesh();
27582881 // Children().release(i);
27592882 }
27602883 blockloop = false;
....@@ -2927,6 +3050,15 @@
29273050 }
29283051 }
29293052
3053
+ void GenNormalsMesh0()
3054
+ {
3055
+ if (bRep != null)
3056
+ {
3057
+ bRep.GenerateNormalsMesh();
3058
+ Touch();
3059
+ }
3060
+ }
3061
+
29303062 void GenNormalsMINE0()
29313063 {
29323064 if (bRep != null)
....@@ -3002,8 +3134,10 @@
30023134 v.fromParent = LA.newMatrix();
30033135 }
30043136
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3137
+// LA.matConcat(v.toParent, toParent, v.toParent);
3138
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3139
+ LA.matConcat(toParent, v.toParent, v.toParent);
3140
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073141 }
30083142
30093143 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3370,9 @@
32363370 bRep.support = null;
32373371 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383372 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3373
+
3374
+ while(temprep.SplitInTwo(reduction34, onlyone));
3375
+
32403376 bRep = temprep;
32413377 bRep.support = sup;
32423378 Touch();
....@@ -3373,7 +3509,8 @@
33733509 if (blockloop)
33743510 return;
33753511
3376
- if (marked || (bRep != null && material != null)) // borderline...
3512
+ if (//marked || // does not make sense
3513
+ (bRep != null || material != null)) // borderline...
33773514 live = h;
33783515
33793516 for (int i = 0; i < Size(); i++)
....@@ -3394,7 +3531,8 @@
33943531 return;
33953532
33963533 //if (bRep != null)
3397
- if (marked || (bRep != null && material != null)) // borderline...
3534
+ if (//marked || // does not make sense
3535
+ (bRep != null || material != null)) // borderline...
33983536 link2master = h;
33993537
34003538 for (int i = 0; i < Size(); i++)
....@@ -3414,7 +3552,8 @@
34143552 if (blockloop)
34153553 return;
34163554
3417
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
34183557 hide = h;
34193558
34203559 for (int i = 0; i < Size(); i++)
....@@ -3434,7 +3573,7 @@
34343573 if (blockloop)
34353574 return;
34363575
3437
- if (bRep != null && material != null) // borderline...
3576
+ if (bRep != null || material != null) // borderline...
34383577 marked = h;
34393578
34403579 for (int i = 0; i < Size(); i++)
....@@ -3444,6 +3583,46 @@
34443583 continue;
34453584 blockloop = true;
34463585 child.MarkLeaves(h);
3586
+ blockloop = false;
3587
+ // release(i);
3588
+ }
3589
+ }
3590
+
3591
+ void RewindLeaves(boolean h)
3592
+ {
3593
+ if (blockloop)
3594
+ return;
3595
+
3596
+ if (bRep != null || material != null) // borderline...
3597
+ rewind = h;
3598
+
3599
+ for (int i = 0; i < Size(); i++)
3600
+ {
3601
+ Object3D child = (Object3D) get(i); // reserve(i);
3602
+ if (child == null)
3603
+ continue;
3604
+ blockloop = true;
3605
+ child.RewindLeaves(h);
3606
+ blockloop = false;
3607
+ // release(i);
3608
+ }
3609
+ }
3610
+
3611
+ void RandomLeaves(boolean h)
3612
+ {
3613
+ if (blockloop)
3614
+ return;
3615
+
3616
+ if (bRep != null || material != null) // borderline...
3617
+ random = h;
3618
+
3619
+ for (int i = 0; i < Size(); i++)
3620
+ {
3621
+ Object3D child = (Object3D) get(i); // reserve(i);
3622
+ if (child == null)
3623
+ continue;
3624
+ blockloop = true;
3625
+ child.RandomLeaves(h);
34473626 blockloop = false;
34483627 // release(i);
34493628 }
....@@ -4221,6 +4400,55 @@
42214400 }
42224401 }
42234402
4403
+ void RepairSOV()
4404
+ {
4405
+ if (blockloop)
4406
+ return;
4407
+
4408
+ String texname = this.GetPigmentTexture();
4409
+
4410
+ if (texname.startsWith("sov"))
4411
+ {
4412
+ String[] s = texname.split("/");
4413
+
4414
+ String[] sname = s[1].split("Color.pn");
4415
+
4416
+ texname = sname[0];
4417
+
4418
+ if (sname.length > 1)
4419
+ {
4420
+ texname += "Color.jpg";
4421
+ }
4422
+
4423
+ this.SetPigmentTexture("sov/" + texname);
4424
+ }
4425
+
4426
+ texname = this.GetBumpTexture();
4427
+
4428
+ if (texname.startsWith("sov"))
4429
+ {
4430
+ String[] s = texname.split("/");
4431
+
4432
+ String[] sname = s[1].split("Bump.pn");
4433
+
4434
+ texname = sname[0];
4435
+
4436
+ if (sname.length > 1)
4437
+ {
4438
+ texname += "Bump.jpg";
4439
+ }
4440
+
4441
+ this.SetBumpTexture("sov/" + texname);
4442
+ }
4443
+
4444
+ for (int i=0; i<Size(); i++)
4445
+ {
4446
+ blockloop = true;
4447
+ get(i).RepairSOV();
4448
+ blockloop = false;
4449
+ }
4450
+ }
4451
+
42244452 void RepairTexture()
42254453 {
42264454 if (this instanceof FileObject || blockloop)
....@@ -4711,7 +4939,7 @@
47114939
47124940 cTreePath SelectLeaf(int indexcount, boolean deselect)
47134941 {
4714
- if (hide)
4942
+ if (hide || dontselect)
47154943 return null;
47164944
47174945 if (count <= 0)
....@@ -4737,7 +4965,7 @@
47374965
47384966 cTreePath Select(int indexcount, boolean deselect)
47394967 {
4740
- if (hide)
4968
+ if (hide || dontselect)
47414969 return null;
47424970
47434971 if (count <= 0)
....@@ -5363,6 +5591,43 @@
53635591 }
53645592 }
53655593
5594
+ UUID GetUUID()
5595
+ {
5596
+ if (uuid == null)
5597
+ {
5598
+ // Serial
5599
+ uuid = UUID.randomUUID();
5600
+ }
5601
+
5602
+ return uuid;
5603
+ }
5604
+
5605
+ Object3D GetObject(UUID uid)
5606
+ {
5607
+ if (blockloop)
5608
+ return null;
5609
+
5610
+ if (GetUUID().equals(uid))
5611
+ return this;
5612
+
5613
+ int nb = Size();
5614
+ for (int i = 0; i < nb; i++)
5615
+ {
5616
+ Object3D child = (Object3D) get(i);
5617
+
5618
+ if (child == null)
5619
+ continue;
5620
+
5621
+ blockloop = true;
5622
+ Object3D obj = child.GetObject(uid);
5623
+ blockloop = false;
5624
+ if (obj != null)
5625
+ return obj;
5626
+ }
5627
+
5628
+ return null;
5629
+ }
5630
+
53665631 void SetBumpTexture(String tex)
53675632 {
53685633 if (GetTextures() == null)
....@@ -5407,12 +5672,23 @@
54075672 boolean NeedSupport()
54085673 {
54095674 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5675
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54115676 // PROBLEM with CROWD!!
54125677 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135678 }
54145679
54155680 static boolean DEBUG_SELECTION = false;
5681
+
5682
+ boolean IsLive()
5683
+ {
5684
+ if (live)
5685
+ return true;
5686
+
5687
+ if (parent == null)
5688
+ return false;
5689
+
5690
+ return parent.IsLive();
5691
+ }
54165692
54175693 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54185694 {
....@@ -5424,7 +5700,7 @@
54245700 }
54255701
54265702 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5703
+ (hide || dontselect))
54285704 return;
54295705
54305706 if (name != null && name.contains("sclera"))
....@@ -5475,7 +5751,7 @@
54755751 support = support;
54765752
54775753 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5478
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5754
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54795755
54805756 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54815757 {
....@@ -5495,10 +5771,12 @@
54955771 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54965772
54975773 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5498
- (touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5775
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
54995776 {
55005777 Globals.lighttouched = true;
55015778 } // all panes...
5779
+
55025780 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55035781 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55045782 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5666,7 +5944,28 @@
56665944 tex = GetTextures();
56675945 }
56685946
5669
- display.BindTextures(tex, texres);
5947
+ boolean failedPigment = false;
5948
+ boolean failedBump = false;
5949
+
5950
+ try
5951
+ {
5952
+ display.BindPigmentTexture(tex, texres);
5953
+ }
5954
+ catch (Exception e)
5955
+ {
5956
+ System.err.println("FAILED: " + this);
5957
+ failedPigment = true;
5958
+ }
5959
+
5960
+ try
5961
+ {
5962
+ display.BindBumpTexture(tex, texres);
5963
+ }
5964
+ catch (Exception e)
5965
+ {
5966
+ //System.err.println("FAILED: " + this);
5967
+ failedBump = true;
5968
+ }
56705969
56715970 if (!compiled)
56725971 {
....@@ -5688,7 +5987,11 @@
56885987 }
56895988 }
56905989
5691
- display.ReleaseTextures(tex);
5990
+ if (!failedBump)
5991
+ display.ReleaseBumpTexture(tex);
5992
+
5993
+ if (!failedPigment)
5994
+ display.ReleasePigmentTexture(tex);
56925995
56935996 display.PopMaterial(this, selected);
56945997 }
....@@ -5817,6 +6120,9 @@
58176120
58186121 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58196122 {
6123
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6124
+ return;
6125
+
58206126 if (hide)
58216127 return;
58226128 // shadow optimisation
....@@ -5942,6 +6248,9 @@
59426248 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59436249 return; // no shadow for transparent objects
59446250
6251
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6252
+ return;
6253
+
59456254 if (hide)
59466255 return;
59476256
....@@ -6055,6 +6364,11 @@
60556364 // dec 2012
60566365 new Exception().printStackTrace();
60576366 return;
6367
+ }
6368
+
6369
+ if (dontselect)
6370
+ {
6371
+ //bRep.GenerateNormalsMINE();
60586372 }
60596373
60606374 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6907,7 +7221,7 @@
69077221 spot.translate(32, 32);
69087222 spotw = spot.x + spot.width;
69097223 spoth = spot.y + spot.height;
6910
- info.g.setColor(Color.blue);
7224
+ info.g.setColor(Color.cyan);
69117225 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69127226 // if (CameraPane.Xmin > spot.x)
69137227 // {
....@@ -6925,11 +7239,12 @@
69257239 // {
69267240 // CameraPane.Ymax = spoth;
69277241 // }
6928
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6929
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7242
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7243
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69307244 spot.translate(0, -32);
6931
- info.g.setColor(Color.green);
7245
+ info.g.setColor(Color.yellow);
69327246 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7247
+ info.g.setColor(Color.green);
69337248 // if (CameraPane.Xmin > spot.x)
69347249 // {
69357250 // CameraPane.Xmin = spot.x;
....@@ -6981,7 +7296,7 @@
69817296 startX = info.x;
69827297 startY = info.y;
69837298
6984
- hitSomething = 0;
7299
+ hitSomething = -1;
69857300 cVector origin = new cVector();
69867301 //LA.xformPos(origin, toParent, origin);
69877302 Rectangle spot = new Rectangle();
....@@ -7057,6 +7372,7 @@
70577372 //System.out.println("hitSomething = " + hitSomething);
70587373
70597374 double scale = 0.005f * info.camera.Distance();
7375
+
70607376 cVector xlate = new cVector();
70617377 //cVector xlate2 = new cVector();
70627378 switch (hitSomething)
....@@ -7205,24 +7521,27 @@
72057521
72067522 case hitScale: // scale
72077523 double hScale = (double) (info.x - centerPt.x) / 32;
7524
+ double sign = 1;
7525
+ if (hScale < 0)
7526
+ {
7527
+ sign = -1;
7528
+ }
7529
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
72087530 if (hScale < 0.01)
72097531 {
7210
- hScale = 0.01;
7532
+ //hScale = 0.01;
72117533 }
7212
- hScale = Math.pow(hScale, scale * 50);
7213
- if (hScale < 0.01)
7214
- {
7215
- hScale = 0.01;
7216
- }
7534
+
72177535 double vScale = (double) (info.y - centerPt.y) / 32;
7218
- if (vScale < 0.01)
7536
+ sign = 1;
7537
+ if (vScale < 0)
72197538 {
7220
- vScale = 0.01;
7539
+ sign = -1;
72217540 }
7222
- vScale = Math.pow(vScale, scale * 50);
7541
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
72237542 if (vScale < 0.01)
72247543 {
7225
- vScale = 0.01;
7544
+ //vScale = 0.01;
72267545 }
72277546 LA.matCopy(startMat, toParent);
72287547 /**/
....@@ -7233,39 +7552,47 @@
72337552 }
72347553 /**/
72357554
7555
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7556
+
7557
+ if (totalScale < 0.01)
7558
+ {
7559
+ totalScale = 0.01;
7560
+ }
7561
+
72367562 switch (info.pane.RenderCamera().viewCode)
72377563 {
72387564 case 3: // '\001'
7239
- if (modified)
7565
+ if (modified || opposite)
72407566 {
72417567 //LA.matScale(toParent, 1, hScale, vScale);
7242
- LA.matScale(toParent, vScale, 1, 1);
7568
+ LA.matScale(toParent, totalScale, 1, 1);
72437569 } // vScale, 1);
72447570 else
72457571 {
7246
- LA.matScale(toParent, vScale, vScale, vScale);
7572
+ // EXCEPTION!
7573
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72477574 } // vScale, 1);
72487575 break;
72497576
72507577 case 2: // '\002'
7251
- if (modified)
7578
+ if (modified || opposite)
72527579 {
72537580 //LA.matScale(toParent, hScale, 1, vScale);
7254
- LA.matScale(toParent, 1, vScale, 1);
7581
+ LA.matScale(toParent, 1, totalScale, 1);
72557582 } else
72567583 {
7257
- LA.matScale(toParent, vScale, 1, vScale);
7584
+ LA.matScale(toParent, totalScale, 1, totalScale);
72587585 }
72597586 break;
72607587
72617588 case 1: // '\003'
7262
- if (modified)
7589
+ if (modified || opposite)
72637590 {
72647591 //LA.matScale(toParent, hScale, vScale, 1);
7265
- LA.matScale(toParent, 1, 1, vScale);
7592
+ LA.matScale(toParent, 1, 1, totalScale);
72667593 } else
72677594 {
7268
- LA.matScale(toParent, vScale, vScale, 1);
7595
+ LA.matScale(toParent, totalScale, totalScale, 1);
72697596 }
72707597 break;
72717598 }
....@@ -7406,7 +7733,7 @@
74067733 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
74077734 } else
74087735 {
7409
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
7736
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
74107737 } // + super.toString();
74117738 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
74127739
....@@ -7479,6 +7806,10 @@
74797806 editWindow = null;
74807807 } // ?
74817808 }
7809
+ else
7810
+ {
7811
+ //editWindow.closeUI();
7812
+ }
74827813 }
74837814
74847815 boolean root; // patch for edit windows
....@@ -7490,7 +7821,7 @@
74907821 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
74917822
74927823 Object3D /*Composite*/ parent;
7493
- Object3D /*Composite*/ fileparent;
7824
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
74947825
74957826 double[][] toParent; // dynamic matrix
74967827 double[][] fromParent;
....@@ -7654,9 +7985,9 @@
76547985 private static cVector edge2 = new cVector();
76557986 //private static cVector norm = new cVector();
76567987 /*transient private*/ int hitSomething;
7657
- private static final int hitCenter = 1;
7658
- private static final int hitScale = 2;
7659
- private static final int hitRotate = 3;
7988
+ static final int hitCenter = 1;
7989
+ static final int hitScale = 2;
7990
+ static final int hitRotate = 3;
76607991 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76617992 /*transient*/ private Point centerPt;
76627993 /*transient*/ private int startX;