Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -22,15 +22,37 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
32
+
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>();
3140
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)
....@@ -170,24 +192,35 @@
170192
171193 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172194 {
195
+ Object3D o;
196
+
173197 if (hashtable.containsKey(GetUUID()))
174198 {
175
- Object3D o = hashtable.get(GetUUID());
199
+ o = hashtable.get(GetUUID());
176200
177201 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
202
+ //if (this.bRep != null)
203
+ // assert(this.bRep.support == o.transientrep);
204
+ if (this.support != null)
205
+ assert(this.support.bRep == o.transientrep);
206
+ }
207
+ else
208
+ {
209
+ o = new Object3D("copy of " + this.name);
180210
181
- return;
211
+ hashtable.put(GetUUID(), o);
182212 }
183213
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
214
+ if (!blockloop)
189215 {
190
- get(i).ExtractBigData(hashtable);
216
+ blockloop = true;
217
+
218
+ for (int i=0; i<Size(); i++)
219
+ {
220
+ get(i).ExtractBigData(hashtable);
221
+ }
222
+
223
+ blockloop = false;
191224 }
192225
193226 ExtractBigData(o);
....@@ -195,11 +228,26 @@
195228
196229 void ExtractBigData(Object3D o)
197230 {
231
+ if (o.bRep != null)
232
+ Grafreed.Assert(o.bRep == this.bRep);
233
+
198234 o.bRep = this.bRep;
199
- if (this.bRep != null)
235
+// July 2019 if (this.bRep != null)
236
+// {
237
+// o.transientrep = this.bRep.support;
238
+// o.bRep.support = null;
239
+// }
240
+ o.selection = this.selection;
241
+ o.versionlist = this.versionlist;
242
+ o.versionindex = this.versionindex;
243
+
244
+ if (this.support != null)
200245 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
246
+ if (o.transientrep != null)
247
+ Grafreed.Assert(o.transientrep == this.support.bRep);
248
+
249
+ o.transientrep = this.support.bRep;
250
+ this.support.bRep = null;
203251 }
204252
205253 // o.support = this.support;
....@@ -214,6 +262,73 @@
214262 // this.fileparent = null;
215263 }
216264
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;
330
+ }
331
+
217332 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218333 {
219334 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +338,35 @@
223338
224339 RestoreBigData(o);
225340
226
- hashtable.remove(GetUUID());
341
+ if (blockloop)
342
+ return;
343
+
344
+ blockloop = true;
345
+
346
+ //hashtable.remove(GetUUID());
227347
228348 for (int i=0; i<Size(); i++)
229349 {
230350 get(i).RestoreBigData(hashtable);
231351 }
352
+
353
+ blockloop = false;
232354 }
233355
234356 void RestoreBigData(Object3D o)
235357 {
236358 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
359
+ if (this.support != null && o.transientrep != null)
360
+ {
361
+ this.support.bRep = o.transientrep;
362
+ }
363
+
364
+ this.selection = o.selection;
365
+
366
+ this.versionlist = o.versionlist;
367
+ this.versionindex = o.versionindex;
368
+// July 2019 if (this.bRep != null)
369
+// this.bRep.support = o.transientrep;
239370 // this.support = o.support;
240371 // this.fileparent = o.fileparent;
241372 }
....@@ -381,6 +512,7 @@
381512 }
382513
383514 boolean live = false;
515
+ transient boolean keepdontselect;
384516 boolean dontselect = false;
385517 boolean hide = false;
386518 boolean link2master = false; // performs reset support/master at each frame
....@@ -449,11 +581,11 @@
449581 }
450582 }
451583
452
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
453585
454586 int MemorySize()
455587 {
456
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
457589 {
458590 try
459591 {
....@@ -568,7 +700,7 @@
568700 {
569701 if (maxcount != 1)
570702 {
571
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
572704 }
573705
574706 toParentMarked = LA.newMatrix();
....@@ -881,7 +1013,7 @@
8811013
8821014 if (marked && Globals.isLIVE() && live &&
8831015 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
1016
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
8851017 currentframe != Globals.framecount)
8861018 {
8871019 currentframe = Globals.framecount;
....@@ -893,7 +1025,8 @@
8931025
8941026 boolean changedir = random && Math.random() < 0.01; // && !link2master;
8951027
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
1028
+ if (transformcount*factor >= maxcount && (rewind || random) ||
1029
+ (step == 1 && changedir))
8971030 {
8981031 countdown = 1;
8991032 delay = speedup?8:1;
....@@ -965,6 +1098,10 @@
9651098 if (material == null || material.multiply)
9661099 return true;
9671100
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
1103
+
1104
+ // Transparent objects are dynamic because we have to sort the triangles.
9681105 return material.opacity > 0.99;
9691106 }
9701107
....@@ -1365,6 +1502,7 @@
13651502 toParent = LA.newMatrix();
13661503 fromParent = LA.newMatrix();
13671504 }
1505
+
13681506 LA.matCopy(other.toParent, toParent);
13691507 LA.matCopy(other.fromParent, fromParent);
13701508
....@@ -2244,11 +2382,6 @@
22442382
22452383 InitOthers();
22462384
2247
- if (this instanceof Camera)
2248
- {
2249
- material.shift = 90;
2250
- }
2251
-
22522385 material.multiply = multiply;
22532386
22542387 if (multiply)
....@@ -2386,6 +2519,15 @@
23862519 }
23872520 */
23882521 }
2522
+ else
2523
+ {
2524
+ //((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");
2530
+ }
23892531 }
23902532
23912533 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2569,14 @@
24272569 {
24282570 editWindow.refreshContents();
24292571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
24302580 //if (parent != null)
24312581 //parent.refreshEditWindow();
24322582 }
....@@ -2506,7 +2656,8 @@
25062656 private static final int editSelf = 1;
25072657 private static final int editChild = 2;
25082658
2509
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
25102661 {
25112662 if (level == 0)
25122663 {
....@@ -2514,7 +2665,8 @@
25142665 return;
25152666
25162667 Object3D selectee;
2517
- 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))
25182670 {
25192671 selectee = (Object3D) e.nextElement();
25202672 }
....@@ -2522,19 +2674,22 @@
25222674 } else
25232675 {
25242676 //super.
2525
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
25262679 }
25272680 }
25282681
2529
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
25302684 {
25312685 doSomething = 0;
25322686 if (level == 0)
25332687 {
2534
- return doParentClick(info);
2688
+ return doParentClick(); //info);
25352689 }
25362690 if (//super.
2537
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
25382693 {
25392694 doSomething = 1;
25402695 return true;
....@@ -2544,7 +2699,7 @@
25442699 }
25452700 }
25462701
2547
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
25482703 {
25492704 if (selection == null)
25502705 {
....@@ -2557,7 +2712,8 @@
25572712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582713 {
25592714 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
25612717 {
25622718 childToDrag = selectee;
25632719 doSomething = 2;
....@@ -2569,13 +2725,15 @@
25692725 return retval;
25702726 }
25712727
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
25732730 {
25742731 switch (doSomething)
25752732 {
25762733 case 1: // '\001'
25772734 //super.
2578
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
25792737 break;
25802738
25812739 case 2: // '\002'
....@@ -2588,11 +2746,13 @@
25882746 {
25892747 //sel.hitSomething = childToDrag.hitSomething;
25902748 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
25922751 } else
25932752 {
25942753 //super.
2595
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
25962756 }
25972757 }
25982758 break;
....@@ -2610,6 +2770,9 @@
26102770 {
26112771 deselectAll();
26122772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
26132776 ClickInfo newInfo = new ClickInfo();
26142777 newInfo.flags = info.flags;
26152778 newInfo.bounds = info.bounds;
....@@ -3057,7 +3220,7 @@
30573220 {
30583221 if (bRep != null)
30593222 {
3060
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613224 Touch();
30623225 }
30633226 }
....@@ -3114,6 +3277,93 @@
31143277 blockloop = false;
31153278 }
31163279
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
+
31173367 void TransformChildren()
31183368 {
31193369 if (toParent != null)
....@@ -3467,15 +3717,47 @@
34673717
34683718 void ClearMaterials()
34693719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
34703725 ClearMaterial();
3471
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
34723727 {
3473
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
34743729 if (child == null)
34753730 continue;
34763731 child.ClearMaterials();
3477
- release(i);
34783732 }
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;
34793761 }
34803762
34813763 void FlipV(boolean flip)
....@@ -3503,7 +3785,8 @@
35033785 if (blockloop)
35043786 return;
35053787
3506
- if (marked || (bRep != null && material != null)) // borderline...
3788
+ if (//marked || // does not make sense
3789
+ (bRep != null || material != null)) // borderline...
35073790 live = h;
35083791
35093792 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3807,8 @@
35243807 return;
35253808
35263809 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3810
+ if (//marked || // does not make sense
3811
+ (bRep != null || material != null)) // borderline...
35283812 link2master = h;
35293813
35303814 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3828,8 @@
35443828 if (blockloop)
35453829 return;
35463830
3547
- if (marked || (bRep != null && material != null)) // borderline...
3831
+ if (//marked || // does not make sense
3832
+ (bRep != null || material != null)) // borderline...
35483833 hide = h;
35493834
35503835 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3849,7 @@
35643849 if (blockloop)
35653850 return;
35663851
3567
- if (bRep != null && material != null) // borderline...
3852
+ if (bRep != null || material != null) // borderline...
35683853 marked = h;
35693854
35703855 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3859,46 @@
35743859 continue;
35753860 blockloop = true;
35763861 child.MarkLeaves(h);
3862
+ blockloop = false;
3863
+ // release(i);
3864
+ }
3865
+ }
3866
+
3867
+ void RewindLeaves(boolean h)
3868
+ {
3869
+ if (blockloop)
3870
+ return;
3871
+
3872
+ if (bRep != null || material != null) // borderline...
3873
+ rewind = h;
3874
+
3875
+ for (int i = 0; i < Size(); i++)
3876
+ {
3877
+ Object3D child = (Object3D) get(i); // reserve(i);
3878
+ if (child == null)
3879
+ continue;
3880
+ blockloop = true;
3881
+ child.RewindLeaves(h);
3882
+ blockloop = false;
3883
+ // release(i);
3884
+ }
3885
+ }
3886
+
3887
+ void RandomLeaves(boolean h)
3888
+ {
3889
+ if (blockloop)
3890
+ return;
3891
+
3892
+ if (bRep != null || material != null) // borderline...
3893
+ random = h;
3894
+
3895
+ for (int i = 0; i < Size(); i++)
3896
+ {
3897
+ Object3D child = (Object3D) get(i); // reserve(i);
3898
+ if (child == null)
3899
+ continue;
3900
+ blockloop = true;
3901
+ child.RandomLeaves(h);
35773902 blockloop = false;
35783903 // release(i);
35793904 }
....@@ -4351,6 +4676,55 @@
43514676 }
43524677 }
43534678
4679
+ void RepairSOV()
4680
+ {
4681
+ if (blockloop)
4682
+ return;
4683
+
4684
+ String texname = this.GetPigmentTexture();
4685
+
4686
+ if (texname.startsWith("sov"))
4687
+ {
4688
+ String[] s = texname.split("/");
4689
+
4690
+ String[] sname = s[1].split("Color.pn");
4691
+
4692
+ texname = sname[0];
4693
+
4694
+ if (sname.length > 1)
4695
+ {
4696
+ texname += "Color.jpg";
4697
+ }
4698
+
4699
+ this.SetPigmentTexture("sov/" + texname);
4700
+ }
4701
+
4702
+ texname = this.GetBumpTexture();
4703
+
4704
+ if (texname.startsWith("sov"))
4705
+ {
4706
+ String[] s = texname.split("/");
4707
+
4708
+ String[] sname = s[1].split("Bump.pn");
4709
+
4710
+ texname = sname[0];
4711
+
4712
+ if (sname.length > 1)
4713
+ {
4714
+ texname += "Bump.jpg";
4715
+ }
4716
+
4717
+ this.SetBumpTexture("sov/" + texname);
4718
+ }
4719
+
4720
+ for (int i=0; i<Size(); i++)
4721
+ {
4722
+ blockloop = true;
4723
+ get(i).RepairSOV();
4724
+ blockloop = false;
4725
+ }
4726
+ }
4727
+
43544728 void RepairTexture()
43554729 {
43564730 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5239,14 @@
48655239 }
48665240 }
48675241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
48685250 cTreePath Select(int indexcount, boolean deselect)
48695251 {
48705252 if (hide || dontselect)
....@@ -4901,10 +5283,11 @@
49015283 if (leaf != null)
49025284 {
49035285 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
49055288 {
49065289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
49085291 }
49095292
49105293 return tp;
....@@ -4921,6 +5304,7 @@
49215304
49225305 if (child == null)
49235306 continue;
5307
+
49245308 if (child.HasTransparency() && child.size() != 0)
49255309 {
49265310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5314,10 @@
49305314 if (leaf != null)
49315315 {
49325316 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
49345319 {
4935
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
49365321 }
49375322
49385323 return tp;
....@@ -5257,6 +5642,51 @@
52575642 blockloop = false;
52585643 }
52595644
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
+
52605690 boolean IsSelected()
52615691 {
52625692 if (parent == null)
....@@ -5317,6 +5747,11 @@
53175747 if (fullname == null)
53185748 return "";
53195749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
53205755 // System.out.println("Fullname = " + fullname);
53215756
53225757 // Does not work on Windows due to C:
....@@ -5329,7 +5764,7 @@
53295764
53305765 if (split.length == 0)
53315766 {
5332
- return "";
5767
+ return fullname.pigment = "";
53335768 }
53345769
53355770 if (split.length <= 2)
....@@ -5337,22 +5772,27 @@
53375772 if (fullname.name.endsWith(":"))
53385773 {
53395774 // Windows
5340
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
53415776 }
53425777
5343
- return split[0];
5778
+ return fullname.pigment = split[0];
53445779 }
53455780
53465781 // Windows
53475782 assert(split.length == 4);
53485783
5349
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
53505785 }
53515786
53525787 static String GetBump(cTexture fullname)
53535788 {
53545789 if (fullname == null)
53555790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
53565796
53575797 // System.out.println("Fullname = " + fullname);
53585798 // Does not work on Windows due to C:
....@@ -5364,12 +5804,12 @@
53645804
53655805 if (split.length == 0)
53665806 {
5367
- return "";
5807
+ return fullname.bump = "";
53685808 }
53695809
53705810 if (split.length == 1)
53715811 {
5372
- return "";
5812
+ return fullname.bump = "";
53735813 }
53745814
53755815 if (split.length == 2)
....@@ -5377,16 +5817,16 @@
53775817 if (fullname.name.endsWith(":"))
53785818 {
53795819 // Windows
5380
- return "";
5820
+ return fullname.bump = "";
53815821 }
53825822
5383
- return split[1];
5823
+ return fullname.bump = split[1];
53845824 }
53855825
53865826 // Windows
53875827 assert(split.length == 4);
53885828
5389
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
53905830 }
53915831
53925832 String GetPigmentTexture()
....@@ -5469,6 +5909,9 @@
54695909 texname = "";
54705910
54715911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
54725915 Touch();
54735916 }
54745917
....@@ -5542,6 +5985,8 @@
55425985
55435986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
55445987
5988
+ GetTextures().bump = null;
5989
+
55455990 Touch();
55465991 }
55475992
....@@ -5562,6 +6007,38 @@
55626007
55636008 blockloop = true;
55646009 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);
55656042 blockloop = false;
55666043 }
55676044 }
....@@ -5590,6 +6067,11 @@
55906067 return false;
55916068
55926069 return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
55936075 }
55946076
55956077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
....@@ -5652,8 +6134,11 @@
56526134 if (support != null)
56536135 support = support;
56546136
5655
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5656
- 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.
56576142
56586143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56596144 {
....@@ -5663,8 +6148,9 @@
56636148 // usecalllists &= !(parent instanceof RandomNode);
56646149 // usecalllists = false;
56656150
5666
- if (GetBRep() != null)
5667
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
56686154 //System.out.println("draw " + this);
56696155 //new Exception().printStackTrace();
56706156
....@@ -5673,10 +6159,12 @@
56736159 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56746160
56756161 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5676
- (touched || (bRep != null && bRep.displaylist <= 0)))
6162
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
6163
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56776164 {
56786165 Globals.lighttouched = true;
56796166 } // all panes...
6167
+
56806168 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56816169 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56826170 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5684,7 +6172,7 @@
56846172 if (!(this instanceof Composite))
56856173 touched = false;
56866174 //if (displaylist == -1 && usecalllists)
5687
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56886176 {
56896177 bRep.displaylist = display.GenList();
56906178 assert(bRep.displaylist != 0);
....@@ -5695,7 +6183,7 @@
56956183
56966184 //System.out.println("\tnew list " + list);
56976185 //gl.glDrawBuffer(gl.GL_NONE);
5698
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
56996187 {
57006188 // System.err.println("new list " + bRep.displaylist + " for " + this);
57016189 display.NewList(bRep.displaylist);
....@@ -5704,7 +6192,7 @@
57046192 CallList(display, root, selected, blocked);
57056193
57066194 // compiled = true;
5707
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
57086196 {
57096197 // System.err.println("end list " + bRep.displaylist + " for " + this);
57106198 display.EndList();
....@@ -5804,6 +6292,7 @@
58046292 if (GetBRep() != null)
58056293 {
58066294 display.NextIndex();
6295
+
58076296 // vertex color conflict : gl.glCallList(list);
58086297 DrawNode(display, root, selected);
58096298 if (this instanceof BezierPatch)
....@@ -5844,16 +6333,27 @@
58446333 tex = GetTextures();
58456334 }
58466335
5847
- boolean failed = false;
6336
+ boolean failedPigment = false;
6337
+ boolean failedBump = false;
58486338
58496339 try
58506340 {
5851
- display.BindTextures(tex, texres);
6341
+ display.BindPigmentTexture(tex, texres);
58526342 }
58536343 catch (Exception e)
58546344 {
58556345 System.err.println("FAILED: " + this);
5856
- failed = true;
6346
+ failedPigment = true;
6347
+ }
6348
+
6349
+ try
6350
+ {
6351
+ display.BindBumpTexture(tex, texres);
6352
+ }
6353
+ catch (Exception e)
6354
+ {
6355
+ //System.err.println("FAILED: " + this);
6356
+ failedBump = true;
58576357 }
58586358
58596359 if (!compiled)
....@@ -5876,8 +6376,11 @@
58766376 }
58776377 }
58786378
5879
- if (!failed)
5880
- display.ReleaseTextures(tex);
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
58816384
58826385 display.PopMaterial(this, selected);
58836386 }
....@@ -6250,6 +6753,11 @@
62506753 // dec 2012
62516754 new Exception().printStackTrace();
62526755 return;
6756
+ }
6757
+
6758
+ if (dontselect)
6759
+ {
6760
+ //bRep.GenerateNormalsMINE();
62536761 }
62546762
62556763 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7035,20 +7543,23 @@
70357543 }
70367544 }
70377545
7038
- 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)
70397550 {
7040
- int hc = info.bounds.x + info.bounds.width / 2;
7041
- int vc = info.bounds.y + info.bounds.height / 2;
7042
- 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;
70437554 if (toscreen == null)
70447555 {
7045
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70467557 }
70477558 cVector vec = in;
70487559 LA.xformPos(in, toscreen, in);
70497560 //System.out.println("Distance = " + info.camera.Distance());
7050
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7051
- 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();
70527563 outPt.x = hc + (int) vec.x;
70537564 outPt.y = vc - (int) vec.y;
70547565 outRec.x = outPt.x - 3;
....@@ -7056,15 +7567,18 @@
70567567 outRec.width = outRec.height = 6;
70577568 }
70587569
7059
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
70607572 {
70617573 Point pt = new Point(0, 0);
70627574 Rectangle rec = new Rectangle();
7063
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
70647577 return rec;
70657578 }
70667579
7067
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
70687582 {
70697583 if (level == 0)
70707584 {
....@@ -7073,16 +7587,19 @@
70737587 {
70747588 cVector origin = new cVector();
70757589 //LA.xformPos(origin, toParent, origin);
7076
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70777594 Rectangle boundary = new Rectangle();
70787595 boundary.x = spot.x - 30;
70797596 boundary.y = spot.y - 30;
70807597 boundary.width = spot.width + 60;
70817598 boundary.height = spot.height + 60;
7082
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
70837600 int spotw = spot.x + spot.width;
70847601 int spoth = spot.y + spot.height;
7085
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70867603 // if (CameraPane.Xmin > spot.x)
70877604 // {
70887605 // CameraPane.Xmin = spot.x;
....@@ -7099,11 +7616,6 @@
70997616 // {
71007617 // CameraPane.Ymax = spoth;
71017618 // }
7102
- spot.translate(32, 32);
7103
- spotw = spot.x + spot.width;
7104
- spoth = spot.y + spot.height;
7105
- info.g.setColor(Color.cyan);
7106
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71077619 // if (CameraPane.Xmin > spot.x)
71087620 // {
71097621 // CameraPane.Xmin = spot.x;
....@@ -7122,10 +7634,15 @@
71227634 // }
71237635 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
71247636 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7125
- spot.translate(0, -32);
7126
- info.g.setColor(Color.yellow);
7127
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7128
- 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);
71297646 // if (CameraPane.Xmin > spot.x)
71307647 // {
71317648 // CameraPane.Xmin = spot.x;
....@@ -7142,8 +7659,9 @@
71427659 // {
71437660 // CameraPane.Ymax = spoth;
71447661 // }
7145
- info.g.drawArc(boundary.x, boundary.y,
7146
- boundary.width, boundary.height, 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);
71477665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71487666 // if (CameraPane.Xmin > boundary.x)
71497667 // {
....@@ -7165,7 +7683,8 @@
71657683 }
71667684 }
71677685
7168
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
71697688 {
71707689 if (level == 0)
71717690 {
....@@ -7174,8 +7693,8 @@
71747693
71757694 boolean retval = false;
71767695
7177
- startX = info.x;
7178
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
71797698
71807699 hitSomething = -1;
71817700 cVector origin = new cVector();
....@@ -7185,22 +7704,53 @@
71857704 {
71867705 centerPt = new Point(0, 0);
71877706 }
7188
- calcHotSpot(origin, info, centerPt, spot);
7189
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
71907710 {
71917711 hitSomething = hitCenter;
71927712 retval = true;
71937713 }
71947714 spot.translate(32, 0);
7195
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
71967716 {
71977717 hitSomething = hitRotate;
71987718 retval = true;
71997719 }
72007720 spot.translate(0, 32);
7201
- 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))
72027724 {
72037725 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
+
72047754 retval = true;
72057755 }
72067756
....@@ -7210,7 +7760,7 @@
72107760 }
72117761
72127762 //System.out.println("info.modifiers = " + info.modifiers);
7213
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72147764 //System.out.println("modified = " + modified);
72157765 //new Exception().printStackTrace();
72167766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7238,7 +7788,8 @@
72387788 return true;
72397789 }
72407790
7241
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
72427793 {
72437794 if (hitSomething == 0)
72447795 {
....@@ -7252,7 +7803,7 @@
72527803
72537804 //System.out.println("hitSomething = " + hitSomething);
72547805
7255
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
72567807
72577808 cVector xlate = new cVector();
72587809 //cVector xlate2 = new cVector();
....@@ -7266,7 +7817,9 @@
72667817
72677818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
72687819
7269
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
72707823 {
72717824 //assert(false);
72727825 /*
....@@ -7286,8 +7839,8 @@
72867839 toParent[3][i] = xlate.get(i);
72877840 LA.matInvert(toParent, fromParent);
72887841 */
7289
- cVector delta = LA.newVector(0, 0, startY - info.y);
7290
- 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);
72917844
72927845 LA.matCopy(startMat, toParent);
72937846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7296,7 +7849,7 @@
72967849 } else
72977850 {
72987851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7299
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
73007853 cVector away = new cVector();
73017854 //cVector right2 = new cVector();
73027855 //LA.vecCross(up, cVector.Z, right);
....@@ -7313,19 +7866,19 @@
73137866 LA.xformDir(up, ClickInfo.matbuffer, up);
73147867 // if (!CameraPane.LOCALTRANSFORM)
73157868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7316
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73177870 // if (!CameraPane.LOCALTRANSFORM)
73187871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73197872 //LA.vecCross(up, cVector.Z, right2);
73207873
7321
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73227875
73237876 //System.out.println("DELTA0 = " + delta);
73247877 //System.out.println("AWAY = " + info.camera.away);
73257878 //System.out.println("UP = " + info.camera.up);
73267879 if (away.z > 0)
73277880 {
7328
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73297882 {
73307883 delta.x = -delta.x;
73317884 } else
....@@ -7340,7 +7893,7 @@
73407893 //System.out.println("DELTA1 = " + delta);
73417894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73427895 //System.out.println("DELTA2 = " + delta);
7343
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73447897 LA.matCopy(startMat, toParent);
73457898 //System.out.println("DELTA3 = " + delta);
73467899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7350,8 +7903,8 @@
73507903 break;
73517904
73527905 case hitRotate: // rotate
7353
- int dx = info.x - centerPt.x;
7354
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
73557908 double angle = (double) Math.atan2(dx, dy);
73567909 angle = -(1.570796 - angle);
73577910
....@@ -7360,7 +7913,7 @@
73607913
73617914 if (modified)
73627915 {
7363
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
73647917 angle /= (Math.PI / 4);
73657918 angle = Math.floor(angle + 0.5);
73667919 angle *= (Math.PI / 4);
....@@ -7374,7 +7927,7 @@
73747927 }
73757928 /**/
73767929
7377
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
73787931 {
73797932 case 1: // '\001'
73807933 LA.matZRotate(toParent, angle);
....@@ -7401,7 +7954,7 @@
74017954 break;
74027955
74037956 case hitScale: // scale
7404
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74057958 double sign = 1;
74067959 if (hScale < 0)
74077960 {
....@@ -7413,7 +7966,7 @@
74137966 //hScale = 0.01;
74147967 }
74157968
7416
- double vScale = (double) (info.y - centerPt.y) / 32;
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
74177970 sign = 1;
74187971 if (vScale < 0)
74197972 {
....@@ -7424,6 +7977,7 @@
74247977 {
74257978 //vScale = 0.01;
74267979 }
7980
+
74277981 LA.matCopy(startMat, toParent);
74287982 /**/
74297983 for (int i = 0; i < 3; i++)
....@@ -7433,23 +7987,27 @@
74337987 }
74347988 /**/
74357989
7436
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74377991
74387992 if (totalScale < 0.01)
74397993 {
74407994 totalScale = 0.01;
74417995 }
74427996
7443
- switch (info.pane.RenderCamera().viewCode)
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
74447998 {
74457999 case 3: // '\001'
74468000 if (modified || opposite)
74478001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
74488005 //LA.matScale(toParent, 1, hScale, vScale);
7449
- LA.matScale(toParent, totalScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
74508007 } // vScale, 1);
74518008 else
74528009 {
8010
+ // EXCEPTION!
74538011 LA.matScale(toParent, 1, totalScale, totalScale);
74548012 } // vScale, 1);
74558013 break;
....@@ -7457,8 +8015,11 @@
74578015 case 2: // '\002'
74588016 if (modified || opposite)
74598017 {
7460
- //LA.matScale(toParent, hScale, 1, vScale);
7461
- 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);
74628023 } else
74638024 {
74648025 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7468,8 +8029,11 @@
74688029 case 1: // '\003'
74698030 if (modified || opposite)
74708031 {
7471
- //LA.matScale(toParent, hScale, vScale, 1);
7472
- 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);
74738037 } else
74748038 {
74758039 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7506,7 +8070,7 @@
75068070 } // NEW ...
75078071
75088072
7509
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
75108074 }
75118075
75128076 boolean overflow = false;
....@@ -7617,10 +8181,10 @@
76178181 } // + super.toString();
76188182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
76198183
7620
- if (!Globals.ADVANCED)
7621
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
76228186
7623
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
76248188 }
76258189
76268190 public int hashCode()
....@@ -7685,6 +8249,10 @@
76858249 {
76868250 editWindow = null;
76878251 } // ?
8252
+ }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
76888256 }
76898257 }
76908258
....@@ -7843,6 +8411,10 @@
78438411 }
78448412
78458413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
78468418 transient ObjectUI objectUI;
78478419 public static int povDepth = 0;
78488420 private static cVector tbMin = new cVector();