Normand Briere
2019-09-15 d5fac992bb6a91e52a90e8318060f5f26ddab982
Object3D.java
....@@ -22,18 +22,113 @@
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. No need to be transient.
28
+ // TEMPORARY for versions. No need to be transient.
2829 mocap.reader.BVHReader.BVHResult savebvh;
2930 Object3D saveskeleton;
31
+
32
+ // FileObject
33
+ Object3D savefilecontent;
3034 //
3135
32
- byte[] versions[] = new byte[100][];
36
+ String skyboxname;
37
+ String skyboxext;
38
+
39
+ Object3D[] versionlist;
3340 int versionindex = -1;
3441
42
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
43
+
3544 ScriptNode scriptnode;
3645
46
+ void deepCopyNode(Object3D other)
47
+ {
48
+ other.skyboxname = skyboxname;
49
+ other.skyboxext = skyboxext;
50
+
51
+ if (toParent != null)
52
+ {
53
+ other.toParent = LA.newMatrix();
54
+ other.fromParent = LA.newMatrix();
55
+ LA.matCopy(toParent, other.toParent);
56
+ LA.matCopy(fromParent, other.fromParent);
57
+ if (toParentMarked != null)
58
+ {
59
+ other.toParentMarked = LA.newMatrix();
60
+ other.fromParentMarked = LA.newMatrix();
61
+ LA.matCopy(toParentMarked, other.toParentMarked);
62
+ LA.matCopy(fromParentMarked, other.fromParentMarked);
63
+ }
64
+ }
65
+ else
66
+ {
67
+ if (other.toParent == null)
68
+// assert(other.toParent == null);
69
+// new Exception().printStackTrace();
70
+ System.err.println("null parent: " + other);
71
+ }
72
+
73
+ /*
74
+ double ident[][] = LA.newMatrix();
75
+ if (bRep == null)
76
+ other.bRep = null;
77
+ else
78
+ other.bRep = new BoundaryRep(bRep, ident);
79
+ */
80
+ // Really new...
81
+ //other.editWindow = null;
82
+ if (name == null)
83
+ other.name = null;
84
+ else
85
+ other.name = new String(name);
86
+
87
+ if (material != null)
88
+ {
89
+ other.material = new cMaterial(material);
90
+ } else
91
+ {
92
+ other.material = null;
93
+ }
94
+
95
+ other.GetTextures().name = GetTextures().name;
96
+
97
+ CopyExtraMaterial(other);
98
+
99
+ other.touched = touched;
100
+ other.softtouched = softtouched;
101
+
102
+ other.random = random;
103
+ other.link2master = link2master;
104
+ other.transformcount = transformcount;
105
+ other.marked = marked;
106
+ other.skip = skip;
107
+ other.count = count;
108
+ other.flipV = flipV;
109
+ other.live = live;
110
+ other.rewind = rewind;
111
+ other.hide = hide;
112
+ other.texres = texres;
113
+ other.speedup = speedup;
114
+ other.height = height;
115
+ other.depth = depth;
116
+ }
117
+
118
+ int VersionCount()
119
+ {
120
+ int count = 0;
121
+
122
+ if (versionlist != null)
123
+ for (int i = versionlist.length; --i >= 0;)
124
+ {
125
+ if (versionlist[i] != null)
126
+ count++;
127
+ }
128
+
129
+ return count;
130
+ }
131
+
37132 void InitOthers()
38133 {
39134 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -45,6 +140,7 @@
45140 projectedVertices[i] = new cVector2(); // Others
46141 }
47142 projectedVertices[0].x = 100; // bump
143
+ projectedVertices[1].y = 1000; // punchthrough. only for png
48144 }
49145
50146 void MinMax(cVector minima, cVector maxima)
....@@ -171,9 +267,42 @@
171267 }
172268 }
173269
270
+ boolean HasBigData()
271
+ {
272
+ if (blockloop)
273
+ return false;
274
+
275
+ if (bRep != null)
276
+ {
277
+ return true;
278
+ }
279
+
280
+ blockloop = true;
281
+
282
+ for (int i = 0; i < Size(); i++)
283
+ {
284
+ Object3D child = (Object3D) get(i);
285
+ if (child == null)
286
+ continue;
287
+ if (child.HasBigData())
288
+ {
289
+ blockloop = false;
290
+ return true;
291
+ }
292
+ }
293
+
294
+ blockloop = false;
295
+ return false;
296
+ }
297
+
174298 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175299 {
300
+ if (blockloop)
301
+ return;
302
+
176303 Object3D o;
304
+
305
+ boolean isnew = false;
177306
178307 if (hashtable.containsKey(GetUUID()))
179308 {
....@@ -187,12 +316,14 @@
187316 }
188317 else
189318 {
319
+ isnew = true;
320
+
190321 o = new Object3D("copy of " + this.name);
191322
192323 hashtable.put(GetUUID(), o);
193324 }
194325
195
- if (!blockloop)
326
+ //if (!blockloop)
196327 {
197328 blockloop = true;
198329
....@@ -203,12 +334,15 @@
203334
204335 blockloop = false;
205336 }
206
-
207
- ExtractBigData(o);
337
+
338
+ //if (isnew)
339
+ ExtractBigData(o);
208340 }
209341
210342 void ExtractBigData(Object3D o)
211343 {
344
+ //System.err.println("ExtractBigData : " + this + " --> " + o);
345
+
212346 if (o.bRep != null)
213347 Grafreed.Assert(o.bRep == this.bRep);
214348
....@@ -219,8 +353,8 @@
219353 // o.bRep.support = null;
220354 // }
221355 o.selection = this.selection;
222
- o.versions = this.versions;
223
- o.versionindex = this.versionindex;
356
+ //o.versionlist = this.versionlist;
357
+ //o.versionindex = this.versionindex;
224358
225359 if (this.support != null)
226360 {
....@@ -243,17 +377,84 @@
243377 // this.fileparent = null;
244378 }
245379
380
+// Object3D GetObject(java.util.UUID uuid)
381
+// {
382
+// if (this.uuid.equals(uuid))
383
+// return this;
384
+//
385
+// if (blockloop)
386
+// return null;
387
+//
388
+// blockloop = true;
389
+//
390
+// for (int i=0; i<Size(); i++)
391
+// {
392
+// Object3D o = get(i).GetObject(uuid);
393
+//
394
+// if (o != null)
395
+// return o;
396
+// }
397
+//
398
+// blockloop = false;
399
+//
400
+// return null;
401
+// }
402
+
403
+ transient boolean tag;
404
+
405
+ void TagObjects(Object3D o, boolean tag)
406
+ {
407
+ if (blockloop)
408
+ return;
409
+
410
+ o.tag = tag;
411
+
412
+ if (o == this)
413
+ return;
414
+
415
+ blockloop = true;
416
+
417
+ for (int i=0; i<Size(); i++)
418
+ {
419
+ get(i).TagObjects(o, tag);
420
+ }
421
+
422
+ blockloop = false;
423
+ }
424
+
425
+ boolean HasTags()
426
+ {
427
+ if (blockloop)
428
+ return false;
429
+
430
+ blockloop = true;
431
+
432
+ boolean hasTags = false;
433
+
434
+ for (int i=0; i<Size(); i++)
435
+ {
436
+ hasTags |= get(i).tag || get(i).HasTags();
437
+
438
+ if (hasTags)
439
+ break;
440
+ }
441
+
442
+ blockloop = false;
443
+
444
+ return hasTags;
445
+ }
446
+
246447 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247448 {
449
+ if (blockloop)
450
+ return;
451
+
248452 if (!hashtable.containsKey(GetUUID()))
249453 return;
250454
251455 Object3D o = hashtable.get(GetUUID());
252456
253457 RestoreBigData(o);
254
-
255
- if (blockloop)
256
- return;
257458
258459 blockloop = true;
259460
....@@ -269,6 +470,9 @@
269470
270471 void RestoreBigData(Object3D o)
271472 {
473
+ //System.err.println("RestoreBigData : " + this + " <-- " + o);
474
+ Grafreed.Assert(this.bRep == null);
475
+
272476 this.bRep = o.bRep;
273477 if (this.support != null && o.transientrep != null)
274478 {
....@@ -277,8 +481,8 @@
277481
278482 this.selection = o.selection;
279483
280
- this.versions = o.versions;
281
- this.versionindex = o.versionindex;
484
+ //this.versionlist = o.versionlist;
485
+ //this.versionindex = o.versionindex;
282486 // July 2019 if (this.bRep != null)
283487 // this.bRep.support = o.transientrep;
284488 // this.support = o.support;
....@@ -426,6 +630,7 @@
426630 }
427631
428632 boolean live = false;
633
+ transient boolean keepdontselect;
429634 boolean dontselect = false;
430635 boolean hide = false;
431636 boolean link2master = false; // performs reset support/master at each frame
....@@ -436,6 +641,9 @@
436641 boolean random = false;
437642 boolean speedup = false;
438643 boolean rewind = false;
644
+
645
+ // Option to sort triangles, e.g. for transparency.
646
+ boolean sort = false;
439647
440648 float NORMALPUSH = 0;
441649
....@@ -494,11 +702,11 @@
494702 }
495703 }
496704
497
- int memorysize;
705
+ transient int memorysize; // needs to be transient, dunno why
498706
499707 int MemorySize()
500708 {
501
- if (true) // memorysize == 0)
709
+ if (memorysize == 0)
502710 {
503711 try
504712 {
....@@ -613,7 +821,7 @@
613821 {
614822 if (maxcount != 1)
615823 {
616
- new Exception().printStackTrace();
824
+ //new Exception().printStackTrace();
617825 }
618826
619827 toParentMarked = LA.newMatrix();
....@@ -1008,21 +1216,28 @@
10081216 {
10091217 // return true;
10101218
1011
- if (material == null || material.multiply)
1012
- return true;
1219
+// if (material == null || material.multiply)
1220
+// return true;
1221
+//
1222
+// if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1223
+// return false;
1224
+//
1225
+// // Transparent objects are dynamic because we have to sort the triangles.
1226
+// return material.opacity > 0.99;
10131227
1014
- // Transparent objects are dynamic because we have to sort the triangles.
1015
- return material.opacity > 0.99;
1228
+ return !sort;
10161229 }
10171230
10181231 boolean IsOpaque()
10191232 {
10201233 // return true;
10211234
1022
- if (material == null || material.multiply)
1023
- return true;
1235
+// if (material == null || material.multiply)
1236
+// return true;
1237
+//
1238
+// return material.opacity > 0.99;
10241239
1025
- return material.opacity > 0.99;
1240
+ return !sort;
10261241 }
10271242
10281243 Object3D()
....@@ -1100,8 +1315,10 @@
11001315
11011316 // will share the geometry
11021317 assert (!(this instanceof Composite));
1103
- return deepCopy(); // Never called for Composite
1104
-
1318
+
1319
+ Object3D obj = deepCopy(); // Never called for Composite
1320
+ obj.count = 2;
1321
+ return obj;
11051322 }
11061323
11071324 boolean HasLoops()
....@@ -1109,6 +1326,30 @@
11091326 return false;
11101327 }
11111328
1329
+ void ResetUUIDs()
1330
+ {
1331
+ if (blockloop)
1332
+ {
1333
+ return;
1334
+ }
1335
+
1336
+ this.uuid = null;
1337
+
1338
+ blockloop = true;
1339
+
1340
+ for (int i = 0; i < Size(); i++)
1341
+ {
1342
+ Object3D obj = (Object3D) Children().get(i);
1343
+
1344
+ if (obj != null)
1345
+ {
1346
+ obj.ResetUUIDs();
1347
+ }
1348
+ }
1349
+
1350
+ blockloop = false;
1351
+ }
1352
+
11121353 boolean IsInfinite()
11131354 {
11141355 if (blockloop)
....@@ -1179,78 +1420,16 @@
11791420 return;
11801421
11811422 blockloop = true;
1423
+
1424
+ other.parent = parent;
1425
+
11821426 //System.out.println("COPY " + this + " to " + other);
11831427 //new Exception().printStackTrace();
1428
+ deepCopyNode(other);
11841429
1185
- other.parent = parent;
1186
- if (toParent != null)
1187
- {
1188
- other.toParent = LA.newMatrix();
1189
- other.fromParent = LA.newMatrix();
1190
- LA.matCopy(toParent, other.toParent);
1191
- LA.matCopy(fromParent, other.fromParent);
1192
- if (toParentMarked != null)
1193
- {
1194
- other.toParentMarked = LA.newMatrix();
1195
- other.fromParentMarked = LA.newMatrix();
1196
- LA.matCopy(toParentMarked, other.toParentMarked);
1197
- LA.matCopy(fromParentMarked, other.fromParentMarked);
1198
- }
1199
- }
1200
- else
1201
- {
1202
- if (other.toParent == null)
1203
-// assert(other.toParent == null);
1204
-// new Exception().printStackTrace();
1205
- System.err.println("null parent: " + other);
1206
- }
1207
- /*
1208
- double ident[][] = LA.newMatrix();
1209
- if (bRep == null)
1210
- other.bRep = null;
1211
- else
1212
- other.bRep = new BoundaryRep(bRep, ident);
1213
- */
1214
- // Really new...
12151430 other.bRep = bRep; // Share the geometry
12161431
12171432 other.support = support; // Share the support
1218
-
1219
- //other.editWindow = null;
1220
- if (name == null)
1221
- other.name = null;
1222
- else
1223
- other.name = new String(name);
1224
-
1225
- if (material != null)
1226
- {
1227
- other.material = new cMaterial(material);
1228
- } else
1229
- {
1230
- other.material = null;
1231
- }
1232
-
1233
- other.GetTextures().name = GetTextures().name;
1234
-
1235
- CopyExtraMaterial(other);
1236
-
1237
- other.touched = touched;
1238
- other.softtouched = softtouched;
1239
-
1240
- other.random = random;
1241
- other.link2master = link2master;
1242
- other.transformcount = transformcount;
1243
- other.marked = marked;
1244
- other.skip = skip;
1245
- other.count = count;
1246
- other.flipV = flipV;
1247
- other.live = live;
1248
- other.rewind = rewind;
1249
- other.hide = hide;
1250
- other.texres = texres;
1251
- other.speedup = speedup;
1252
- other.height = height;
1253
- other.depth = depth;
12541433
12551434 // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist)
12561435 // {
....@@ -1306,17 +1485,24 @@
13061485 if ((mask & GEOMETRY) != 0)
13071486 {
13081487 if (bRep != null)
1309
- bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
1310
- else
1311
- assert(other.bRep == null);
1312
-
1313
- if (bRep != null)
13141488 {
1489
+ bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
13151490 CameraPane.RemoveList(bRep.displaylist);
13161491 bRep.displaylist = 0; // june 2013 -1;
13171492 }
13181493 else
1319
- bRep = bRep;
1494
+ {
1495
+ //assert(other.bRep == null);
1496
+ bRep = other.bRep;
1497
+ }
1498
+
1499
+// if (bRep != null)
1500
+// {
1501
+// CameraPane.RemoveList(bRep.displaylist);
1502
+// bRep.displaylist = 0; // june 2013 -1;
1503
+// }
1504
+// else
1505
+// bRep = bRep;
13201506 }
13211507
13221508 /* Use a MASK = GEO/MAT
....@@ -2292,11 +2478,6 @@
22922478
22932479 InitOthers();
22942480
2295
- if (this instanceof Camera)
2296
- {
2297
- material.shift = 90;
2298
- }
2299
-
23002481 material.multiply = multiply;
23012482
23022483 if (multiply)
....@@ -2437,6 +2618,11 @@
24372618 else
24382619 {
24392620 //((ObjEditor)editWindow).SetupUI2(null);
2621
+ if (objectUI != null)
2622
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2623
+ else
2624
+ //new Exception().printStackTrace();
2625
+ System.err.println("objectUI is null");
24402626 }
24412627 }
24422628
....@@ -2566,7 +2752,8 @@
25662752 private static final int editSelf = 1;
25672753 private static final int editChild = 2;
25682754
2569
- void drawEditHandles(ClickInfo info, int level)
2755
+ void drawEditHandles(//ClickInfo info,
2756
+ int level)
25702757 {
25712758 if (level == 0)
25722759 {
....@@ -2574,7 +2761,8 @@
25742761 return;
25752762
25762763 Object3D selectee;
2577
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2764
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2765
+ level + 1))
25782766 {
25792767 selectee = (Object3D) e.nextElement();
25802768 }
....@@ -2582,19 +2770,22 @@
25822770 } else
25832771 {
25842772 //super.
2585
- drawEditHandles0(info, level + 1);
2773
+ drawEditHandles0(//info,
2774
+ level + 1);
25862775 }
25872776 }
25882777
2589
- boolean doEditClick(ClickInfo info, int level)
2778
+ boolean doEditClick(//ClickInfo info,
2779
+ int level)
25902780 {
25912781 doSomething = 0;
25922782 if (level == 0)
25932783 {
2594
- return doParentClick(info);
2784
+ return doParentClick(); //info);
25952785 }
25962786 if (//super.
2597
- doEditClick0(info, level))
2787
+ doEditClick0(//info,
2788
+ level))
25982789 {
25992790 doSomething = 1;
26002791 return true;
....@@ -2604,7 +2795,7 @@
26042795 }
26052796 }
26062797
2607
- boolean doParentClick(ClickInfo info)
2798
+ boolean doParentClick() //ClickInfo info)
26082799 {
26092800 if (selection == null)
26102801 {
....@@ -2617,7 +2808,8 @@
26172808 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26182809 {
26192810 Object3D selectee = (Object3D) e.nextElement();
2620
- if (selectee.doEditClick(info, 1))
2811
+ if (selectee.doEditClick(//info,
2812
+ 1))
26212813 {
26222814 childToDrag = selectee;
26232815 doSomething = 2;
....@@ -2629,13 +2821,15 @@
26292821 return retval;
26302822 }
26312823
2632
- void doEditDrag(ClickInfo info, boolean opposite)
2824
+ void doEditDrag(//ClickInfo clickInfo,
2825
+ boolean opposite)
26332826 {
26342827 switch (doSomething)
26352828 {
26362829 case 1: // '\001'
26372830 //super.
2638
- doEditDrag0(info, opposite);
2831
+ doEditDrag0(//clickInfo,
2832
+ opposite);
26392833 break;
26402834
26412835 case 2: // '\002'
....@@ -2648,11 +2842,13 @@
26482842 {
26492843 //sel.hitSomething = childToDrag.hitSomething;
26502844 //childToDrag.doEditDrag(info);
2651
- sel.doEditDrag(info, opposite);
2845
+ sel.doEditDrag(//clickInfo,
2846
+ opposite);
26522847 } else
26532848 {
26542849 //super.
2655
- doEditDrag0(info, opposite);
2850
+ doEditDrag0(//clickInfo,
2851
+ opposite);
26562852 }
26572853 }
26582854 break;
....@@ -2670,6 +2866,9 @@
26702866 {
26712867 deselectAll();
26722868 }
2869
+
2870
+ new Exception().printStackTrace();
2871
+
26732872 ClickInfo newInfo = new ClickInfo();
26742873 newInfo.flags = info.flags;
26752874 newInfo.bounds = info.bounds;
....@@ -3099,7 +3298,10 @@
30993298 {
31003299 if (bRep != null)
31013300 {
3301
+ //bRep.GenerateNormals2(crease); // in-place doesn't work. it gives wrong normals (diamond artifact).
31023302 bRep.GenerateNormals(crease);
3303
+ if (!bRep.trimmed)
3304
+ bRep.MergeNormals();
31033305 Touch();
31043306 }
31053307 }
....@@ -3117,7 +3319,7 @@
31173319 {
31183320 if (bRep != null)
31193321 {
3120
- bRep.GenerateNormalsMINE();
3322
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31213323 Touch();
31223324 }
31233325 }
....@@ -3174,6 +3376,105 @@
31743376 blockloop = false;
31753377 }
31763378
3379
+ public void ResetTransform(int mask)
3380
+ {
3381
+ Object3D obj = this;
3382
+
3383
+ if (mask == -1)
3384
+ {
3385
+ if (obj instanceof Camera) // jan 2014
3386
+ {
3387
+ LA.matIdentity(obj.toParent);
3388
+ LA.matIdentity(obj.fromParent);
3389
+ }
3390
+ else
3391
+ {
3392
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3393
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3394
+ }
3395
+ return;
3396
+ }
3397
+
3398
+ if ((mask&2) != 0) // Scale/rotation
3399
+ {
3400
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3401
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3402
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3403
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3404
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3405
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3406
+ }
3407
+ if ((mask&1) != 0) // Translation
3408
+ {
3409
+ if (obj.toParent != null)
3410
+ {
3411
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3412
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3413
+ }
3414
+ }
3415
+ }
3416
+
3417
+ public void Scale(int scale)
3418
+ {
3419
+ Object3D obj = this;
3420
+
3421
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = scale;
3422
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3423
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3424
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1/scale;
3425
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3426
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3427
+ }
3428
+
3429
+ public void TextureRatioTransform(int axis)
3430
+ {
3431
+ cTexture tex = GetTextures();
3432
+
3433
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3434
+
3435
+ try
3436
+ {
3437
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3438
+ }
3439
+ catch (Exception e)
3440
+ {
3441
+ System.err.println("FAIL TextureRatio: " + this);
3442
+ }
3443
+
3444
+ LA.matIdentity(Object3D.mat);
3445
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3446
+
3447
+ if (toParent == null)
3448
+ {
3449
+ toParent = LA.newMatrix();
3450
+ fromParent = LA.newMatrix();
3451
+ }
3452
+
3453
+ ResetTransform(2);
3454
+
3455
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3456
+ LA.matInvert(fromParent, toParent);
3457
+ }
3458
+
3459
+ void TextureRatio(int axis)
3460
+ {
3461
+ if (blockloop)
3462
+ return;
3463
+
3464
+ blockloop = true;
3465
+
3466
+ TextureRatioTransform(axis);
3467
+
3468
+ for (int i=Size(); --i>=0;)
3469
+ {
3470
+ Object3D v = get(i);
3471
+
3472
+ v.TextureRatio(axis);
3473
+ }
3474
+
3475
+ blockloop = false;
3476
+ }
3477
+
31773478 void TransformChildren()
31783479 {
31793480 if (toParent != null)
....@@ -3416,6 +3717,7 @@
34163717 if (bRep != null)
34173718 {
34183719 //bRep.RemoveOneTriangle();
3720
+ System.out.println();
34193721 System.out.println("Reducing " + this);
34203722 if (name != null && name.contains("lockpickstraps"))
34213723 name = name;
....@@ -3527,15 +3829,47 @@
35273829
35283830 void ClearMaterials()
35293831 {
3832
+ if (blockloop)
3833
+ return;
3834
+
3835
+ blockloop = true;
3836
+
35303837 ClearMaterial();
3531
- for (int i = 0; i < size(); i++)
3838
+ for (int i = 0; i < Size(); i++)
35323839 {
3533
- Object3D child = (Object3D) reserve(i);
3840
+ Object3D child = (Object3D) get(i);
35343841 if (child == null)
35353842 continue;
35363843 child.ClearMaterials();
3537
- release(i);
35383844 }
3845
+
3846
+ blockloop = false;
3847
+ }
3848
+
3849
+ void ClearVersionList()
3850
+ {
3851
+ this.versionlist = null;
3852
+ this.versionindex = -1;
3853
+ this.versiontable = null;
3854
+ }
3855
+
3856
+ void ClearVersions()
3857
+ {
3858
+ if (blockloop)
3859
+ return;
3860
+
3861
+ blockloop = true;
3862
+
3863
+ ClearVersionList();
3864
+ for (int i = 0; i < Size(); i++)
3865
+ {
3866
+ Object3D child = (Object3D) get(i);
3867
+ if (child == null)
3868
+ continue;
3869
+ child.ClearVersions();
3870
+ }
3871
+
3872
+ blockloop = false;
35393873 }
35403874
35413875 void FlipV(boolean flip)
....@@ -3985,9 +4319,9 @@
39854319 max = new cVector();
39864320 }
39874321
3988
- for (int i = 0; i<size(); i++)
4322
+ for (int i = 0; i<Size(); i++)
39894323 {
3990
- Object3D child = (Object3D) reserve(i);
4324
+ Object3D child = (Object3D) get(i); //reserve(i);
39914325 if (child == null)
39924326 continue;
39934327
....@@ -4006,14 +4340,14 @@
40064340 if (child.hide && !(child instanceof Merge) || child.skip)
40074341 //if (child.hide)
40084342 {
4009
- release(i);
4343
+ //release(i);
40104344 continue;
40114345 }
40124346
40134347 blockloop = true;
40144348 child.getBounds(min, max, true); // xform);
40154349 blockloop = false;
4016
- release(i);
4350
+ //release(i);
40174351
40184352 MinMax(minima, maxima);
40194353 }
....@@ -5420,6 +5754,51 @@
54205754 blockloop = false;
54215755 }
54225756
5757
+ void ResetSelectable()
5758
+ {
5759
+ if (blockloop)
5760
+ return;
5761
+
5762
+ blockloop = true;
5763
+
5764
+ keepdontselect = dontselect;
5765
+ dontselect = true;
5766
+
5767
+ Object3D child;
5768
+ int nb = Size();
5769
+ for (int i = 0; i < nb; i++)
5770
+ {
5771
+ child = (Object3D) get(i);
5772
+ if (child == null)
5773
+ continue;
5774
+ child.ResetSelectable();
5775
+ }
5776
+
5777
+ blockloop = false;
5778
+ }
5779
+
5780
+ void RestoreSelectable()
5781
+ {
5782
+ if (blockloop)
5783
+ return;
5784
+
5785
+ blockloop = true;
5786
+
5787
+ dontselect = keepdontselect;
5788
+
5789
+ Object3D child;
5790
+ int nb = Size();
5791
+ for (int i = 0; i < nb; i++)
5792
+ {
5793
+ child = (Object3D) get(i);
5794
+ if (child == null)
5795
+ continue;
5796
+ child.RestoreSelectable();
5797
+ }
5798
+
5799
+ blockloop = false;
5800
+ }
5801
+
54235802 boolean IsSelected()
54245803 {
54255804 if (parent == null)
....@@ -5480,6 +5859,11 @@
54805859 if (fullname == null)
54815860 return "";
54825861
5862
+ if (fullname.pigment != null)
5863
+ {
5864
+ return fullname.pigment;
5865
+ }
5866
+
54835867 // System.out.println("Fullname = " + fullname);
54845868
54855869 // Does not work on Windows due to C:
....@@ -5492,7 +5876,7 @@
54925876
54935877 if (split.length == 0)
54945878 {
5495
- return "";
5879
+ return fullname.pigment = "";
54965880 }
54975881
54985882 if (split.length <= 2)
....@@ -5500,22 +5884,27 @@
55005884 if (fullname.name.endsWith(":"))
55015885 {
55025886 // Windows
5503
- return fullname.name.substring(0, fullname.name.length()-1);
5887
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55045888 }
55055889
5506
- return split[0];
5890
+ return fullname.pigment = split[0];
55075891 }
55085892
55095893 // Windows
55105894 assert(split.length == 4);
55115895
5512
- return split[0] + ":" + split[1];
5896
+ return fullname.pigment = split[0] + ":" + split[1];
55135897 }
55145898
55155899 static String GetBump(cTexture fullname)
55165900 {
55175901 if (fullname == null)
55185902 return "";
5903
+
5904
+ if (fullname.bump != null)
5905
+ {
5906
+ return fullname.bump;
5907
+ }
55195908
55205909 // System.out.println("Fullname = " + fullname);
55215910 // Does not work on Windows due to C:
....@@ -5527,12 +5916,12 @@
55275916
55285917 if (split.length == 0)
55295918 {
5530
- return "";
5919
+ return fullname.bump = "";
55315920 }
55325921
55335922 if (split.length == 1)
55345923 {
5535
- return "";
5924
+ return fullname.bump = "";
55365925 }
55375926
55385927 if (split.length == 2)
....@@ -5540,16 +5929,16 @@
55405929 if (fullname.name.endsWith(":"))
55415930 {
55425931 // Windows
5543
- return "";
5932
+ return fullname.bump = "";
55445933 }
55455934
5546
- return split[1];
5935
+ return fullname.bump = split[1];
55475936 }
55485937
55495938 // Windows
55505939 assert(split.length == 4);
55515940
5552
- return split[2] + ":" + split[3];
5941
+ return fullname.bump = split[2] + ":" + split[3];
55535942 }
55545943
55555944 String GetPigmentTexture()
....@@ -5632,6 +6021,9 @@
56326021 texname = "";
56336022
56346023 GetTextures().name = texname + ":" + GetBump(GetTextures());
6024
+
6025
+ GetTextures().pigment = null;
6026
+
56356027 Touch();
56366028 }
56376029
....@@ -5705,6 +6097,8 @@
57056097
57066098 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57076099
6100
+ GetTextures().bump = null;
6101
+
57086102 Touch();
57096103 }
57106104
....@@ -5725,6 +6119,38 @@
57256119
57266120 blockloop = true;
57276121 child.ResetBumpTexture();
6122
+ blockloop = false;
6123
+ }
6124
+ }
6125
+
6126
+ void EmbedTextures(boolean embed)
6127
+ {
6128
+ if (blockloop)
6129
+ return;
6130
+
6131
+ //if (GetTextures() != null)
6132
+ if (embed)
6133
+ CameraPane.EmbedTextures(GetTextures());
6134
+ else
6135
+ {
6136
+ GetTextures().pigmentdata = null;
6137
+ GetTextures().bumpdata = null;
6138
+ GetTextures().pw = 0;
6139
+ GetTextures().ph = 0;
6140
+ GetTextures().bw = 0;
6141
+ GetTextures().bh = 0;
6142
+ }
6143
+
6144
+ int nb = Size();
6145
+ for (int i = 0; i < nb; i++)
6146
+ {
6147
+ Object3D child = (Object3D) get(i);
6148
+
6149
+ if (child == null)
6150
+ continue;
6151
+
6152
+ blockloop = true;
6153
+ child.EmbedTextures(embed);
57286154 blockloop = false;
57296155 }
57306156 }
....@@ -5753,6 +6179,11 @@
57536179 return false;
57546180
57556181 return parent.IsLive();
6182
+ }
6183
+
6184
+ boolean IsDynamic()
6185
+ {
6186
+ return live && bRep != null;
57566187 }
57576188
57586189 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
....@@ -5815,8 +6246,11 @@
58156246 if (support != null)
58166247 support = support;
58176248
5818
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5819
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6249
+ boolean usecalllists = !IsDynamic() &&
6250
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6251
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6252
+
6253
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58206254
58216255 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58226256 {
....@@ -5826,8 +6260,9 @@
58266260 // usecalllists &= !(parent instanceof RandomNode);
58276261 // usecalllists = false;
58286262
5829
- if (GetBRep() != null)
5830
- usecalllists = usecalllists;
6263
+ if (display.DrawMode() == display.SHADOW)
6264
+ //GetBRep() != null)
6265
+ usecalllists = !!usecalllists;
58316266 //System.out.println("draw " + this);
58326267 //new Exception().printStackTrace();
58336268
....@@ -5849,7 +6284,7 @@
58496284 if (!(this instanceof Composite))
58506285 touched = false;
58516286 //if (displaylist == -1 && usecalllists)
5852
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6287
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58536288 {
58546289 bRep.displaylist = display.GenList();
58556290 assert(bRep.displaylist != 0);
....@@ -5860,7 +6295,7 @@
58606295
58616296 //System.out.println("\tnew list " + list);
58626297 //gl.glDrawBuffer(gl.GL_NONE);
5863
- if (usecalllists)
6298
+ if (usecalllists && bRep.displaylist > 0)
58646299 {
58656300 // System.err.println("new list " + bRep.displaylist + " for " + this);
58666301 display.NewList(bRep.displaylist);
....@@ -5869,7 +6304,7 @@
58696304 CallList(display, root, selected, blocked);
58706305
58716306 // compiled = true;
5872
- if (usecalllists)
6307
+ if (usecalllists && bRep.displaylist > 0)
58736308 {
58746309 // System.err.println("end list " + bRep.displaylist + " for " + this);
58756310 display.EndList();
....@@ -5879,8 +6314,8 @@
58796314 Globals.lighttouched = true; // all panes...
58806315 }
58816316
5882
- touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
5883
- //touched = false;
6317
+ //touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
6318
+ touched = false;
58846319
58856320 if (this instanceof Texture || this instanceof TextureNode)
58866321 {
....@@ -5981,6 +6416,20 @@
59816416 {
59826417 drawSelf(display, root, selected, blocked);
59836418 }
6419
+
6420
+// if (!(this instanceof Composite))
6421
+// {
6422
+// for (int i = 0; i < size(); i++)
6423
+// {
6424
+// Object3D child = (Object3D) reserve(i);
6425
+// if (child == null)
6426
+// continue;
6427
+//
6428
+// child.draw(display, root, selected, blocked);
6429
+//
6430
+// release(i);
6431
+// }
6432
+// }
59846433 } else
59856434 {
59866435 /*
....@@ -6013,13 +6462,14 @@
60136462 boolean failedPigment = false;
60146463 boolean failedBump = false;
60156464
6465
+ CameraPane.lastObject = this;
60166466 try
60176467 {
60186468 display.BindPigmentTexture(tex, texres);
60196469 }
60206470 catch (Exception e)
60216471 {
6022
- System.err.println("FAILED: " + this);
6472
+ // System.err.println("FAILED: " + this);
60236473 failedPigment = true;
60246474 }
60256475
....@@ -6050,6 +6500,20 @@
60506500 display.CallList(bRep.displaylist);
60516501 // june 2013 drawSelf(display, root, selected);
60526502 }
6503
+ }
6504
+
6505
+ assert (!(this instanceof Composite));
6506
+ {
6507
+// CRASH MOCAP!! for (int i = 0; i < size(); i++)
6508
+// {
6509
+// Object3D child = (Object3D) reserve(i);
6510
+// if (child == null)
6511
+// continue;
6512
+//
6513
+// child.draw(display, root, selected, blocked);
6514
+//
6515
+// release(i);
6516
+// }
60536517 }
60546518 }
60556519
....@@ -6103,16 +6567,17 @@
61036567
61046568 void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
61056569 {
6106
- if (GetBRep() == null)
6107
- {
6108
- drawSelf(display, root, selected, blocked);
6109
- } else
6570
+ if (GetBRep() != null)
61106571 {
61116572 DrawNode(display, root, selected);
61126573 if (this instanceof BezierPatch)
61136574 {
61146575 //drawSelf(display, root, selected);
61156576 }
6577
+ }
6578
+ else
6579
+ {
6580
+ drawSelf(display, root, selected, blocked);
61166581 }
61176582 }
61186583
....@@ -7220,20 +7685,23 @@
72207685 }
72217686 }
72227687
7223
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7688
+ static ClickInfo clickInfo = new ClickInfo();
7689
+
7690
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7691
+ Point outPt, Rectangle outRec)
72247692 {
7225
- int hc = info.bounds.x + info.bounds.width / 2;
7226
- int vc = info.bounds.y + info.bounds.height / 2;
7227
- double[][] toscreen = info.toScreen;
7693
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7694
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7695
+ double[][] toscreen = clickInfo.toScreen;
72287696 if (toscreen == null)
72297697 {
7230
- toscreen = new Camera(info.camera.viewCode).toScreen;
7698
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72317699 }
72327700 cVector vec = in;
72337701 LA.xformPos(in, toscreen, in);
72347702 //System.out.println("Distance = " + info.camera.Distance());
7235
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7236
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7703
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7704
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72377705 outPt.x = hc + (int) vec.x;
72387706 outPt.y = vc - (int) vec.y;
72397707 outRec.x = outPt.x - 3;
....@@ -7241,15 +7709,18 @@
72417709 outRec.width = outRec.height = 6;
72427710 }
72437711
7244
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7712
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7713
+ )
72457714 {
72467715 Point pt = new Point(0, 0);
72477716 Rectangle rec = new Rectangle();
7248
- calcHotSpot(in, info, pt, rec);
7717
+ calcHotSpot(in, //clickInfo,
7718
+ pt, rec);
72497719 return rec;
72507720 }
72517721
7252
- void drawEditHandles0(ClickInfo info, int level)
7722
+ void drawEditHandles0(//ClickInfo clickInfo,
7723
+ int level)
72537724 {
72547725 if (level == 0)
72557726 {
....@@ -7258,16 +7729,19 @@
72587729 {
72597730 cVector origin = new cVector();
72607731 //LA.xformPos(origin, toParent, origin);
7261
- Rectangle spot = calcHotSpot(origin, info);
7732
+ if (this.clickInfo == null)
7733
+ this.clickInfo = new ClickInfo();
7734
+
7735
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72627736 Rectangle boundary = new Rectangle();
72637737 boundary.x = spot.x - 30;
72647738 boundary.y = spot.y - 30;
72657739 boundary.width = spot.width + 60;
72667740 boundary.height = spot.height + 60;
7267
- info.g.setColor(Color.red);
7741
+ clickInfo.g.setColor(Color.white);
72687742 int spotw = spot.x + spot.width;
72697743 int spoth = spot.y + spot.height;
7270
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7744
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72717745 // if (CameraPane.Xmin > spot.x)
72727746 // {
72737747 // CameraPane.Xmin = spot.x;
....@@ -7284,11 +7758,6 @@
72847758 // {
72857759 // CameraPane.Ymax = spoth;
72867760 // }
7287
- spot.translate(32, 32);
7288
- spotw = spot.x + spot.width;
7289
- spoth = spot.y + spot.height;
7290
- info.g.setColor(Color.cyan);
7291
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72927761 // if (CameraPane.Xmin > spot.x)
72937762 // {
72947763 // CameraPane.Xmin = spot.x;
....@@ -7307,10 +7776,15 @@
73077776 // }
73087777 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73097778 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7310
- spot.translate(0, -32);
7311
- info.g.setColor(Color.yellow);
7312
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
- info.g.setColor(Color.green);
7779
+ spot.translate(32, 0);
7780
+ clickInfo.g.setColor(Color.yellow);
7781
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7782
+
7783
+ spot.translate(32, 64);
7784
+ spotw = spot.x + spot.width;
7785
+ spoth = spot.y + spot.height;
7786
+ clickInfo.g.setColor(Color.cyan);
7787
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73147788 // if (CameraPane.Xmin > spot.x)
73157789 // {
73167790 // CameraPane.Xmin = spot.x;
....@@ -7327,8 +7801,9 @@
73277801 // {
73287802 // CameraPane.Ymax = spoth;
73297803 // }
7330
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
7804
+ clickInfo.g.setColor(Color.green);
7805
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7806
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73327807 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73337808 // if (CameraPane.Xmin > boundary.x)
73347809 // {
....@@ -7350,7 +7825,8 @@
73507825 }
73517826 }
73527827
7353
- boolean doEditClick0(ClickInfo info, int level)
7828
+ boolean doEditClick0(//ClickInfo clickInfo,
7829
+ int level)
73547830 {
73557831 if (level == 0)
73567832 {
....@@ -7359,8 +7835,8 @@
73597835
73607836 boolean retval = false;
73617837
7362
- startX = info.x;
7363
- startY = info.y;
7838
+ startX = clickInfo.x;
7839
+ startY = clickInfo.y;
73647840
73657841 hitSomething = -1;
73667842 cVector origin = new cVector();
....@@ -7370,22 +7846,53 @@
73707846 {
73717847 centerPt = new Point(0, 0);
73727848 }
7373
- calcHotSpot(origin, info, centerPt, spot);
7374
- if (spot.contains(info.x, info.y))
7849
+ calcHotSpot(origin, //info,
7850
+ centerPt, spot);
7851
+ if (spot.contains(clickInfo.x, clickInfo.y))
73757852 {
73767853 hitSomething = hitCenter;
73777854 retval = true;
73787855 }
73797856 spot.translate(32, 0);
7380
- if (spot.contains(info.x, info.y))
7857
+ if (spot.contains(clickInfo.x, clickInfo.y))
73817858 {
73827859 hitSomething = hitRotate;
73837860 retval = true;
73847861 }
73857862 spot.translate(0, 32);
7386
- if (spot.contains(info.x, info.y))
7863
+ spot.translate(32, 0);
7864
+ spot.translate(0, 32);
7865
+ if (spot.contains(clickInfo.x, clickInfo.y))
73877866 {
73887867 hitSomething = hitScale;
7868
+
7869
+ double scale = 0.005f * clickInfo.camera.Distance();
7870
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7871
+ double sign = 1;
7872
+ if (hScale < 0)
7873
+ {
7874
+ sign = -1;
7875
+ }
7876
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7877
+ if (hScale < 0.01)
7878
+ {
7879
+ //hScale = 0.01;
7880
+ }
7881
+
7882
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7883
+ sign = 1;
7884
+ if (vScale < 0)
7885
+ {
7886
+ sign = -1;
7887
+ }
7888
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7889
+ if (vScale < 0.01)
7890
+ {
7891
+ //vScale = 0.01;
7892
+ }
7893
+
7894
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7895
+
73897896 retval = true;
73907897 }
73917898
....@@ -7395,7 +7902,7 @@
73957902 }
73967903
73977904 //System.out.println("info.modifiers = " + info.modifiers);
7398
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7905
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73997906 //System.out.println("modified = " + modified);
74007907 //new Exception().printStackTrace();
74017908 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7423,7 +7930,8 @@
74237930 return true;
74247931 }
74257932
7426
- void doEditDrag0(ClickInfo info, boolean opposite)
7933
+ void doEditDrag0(//ClickInfo info,
7934
+ boolean opposite)
74277935 {
74287936 if (hitSomething == 0)
74297937 {
....@@ -7437,7 +7945,7 @@
74377945
74387946 //System.out.println("hitSomething = " + hitSomething);
74397947
7440
- double scale = 0.005f * info.camera.Distance();
7948
+ double scale = 0.005f * clickInfo.camera.Distance();
74417949
74427950 cVector xlate = new cVector();
74437951 //cVector xlate2 = new cVector();
....@@ -7451,7 +7959,9 @@
74517959
74527960 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74537961
7454
- if (modified || opposite)
7962
+ // Modified could snap
7963
+ if (//modified ||
7964
+ opposite)
74557965 {
74567966 //assert(false);
74577967 /*
....@@ -7471,8 +7981,8 @@
74717981 toParent[3][i] = xlate.get(i);
74727982 LA.matInvert(toParent, fromParent);
74737983 */
7474
- cVector delta = LA.newVector(0, 0, startY - info.y);
7475
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7984
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7985
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74767986
74777987 LA.matCopy(startMat, toParent);
74787988 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7481,7 +7991,7 @@
74817991 } else
74827992 {
74837993 //LA.xformDir(delta, info.camera.fromScreen, delta);
7484
- cVector up = new cVector(info.camera.up);
7994
+ cVector up = new cVector(clickInfo.camera.up);
74857995 cVector away = new cVector();
74867996 //cVector right2 = new cVector();
74877997 //LA.vecCross(up, cVector.Z, right);
....@@ -7498,19 +8008,19 @@
74988008 LA.xformDir(up, ClickInfo.matbuffer, up);
74998009 // if (!CameraPane.LOCALTRANSFORM)
75008010 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7501
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
8011
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75028012 // if (!CameraPane.LOCALTRANSFORM)
75038013 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75048014 //LA.vecCross(up, cVector.Z, right2);
75058015
7506
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
8016
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75078017
75088018 //System.out.println("DELTA0 = " + delta);
75098019 //System.out.println("AWAY = " + info.camera.away);
75108020 //System.out.println("UP = " + info.camera.up);
75118021 if (away.z > 0)
75128022 {
7513
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
8023
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75148024 {
75158025 delta.x = -delta.x;
75168026 } else
....@@ -7525,7 +8035,7 @@
75258035 //System.out.println("DELTA1 = " + delta);
75268036 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75278037 //System.out.println("DELTA2 = " + delta);
7528
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
8038
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75298039 LA.matCopy(startMat, toParent);
75308040 //System.out.println("DELTA3 = " + delta);
75318041 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7535,8 +8045,8 @@
75358045 break;
75368046
75378047 case hitRotate: // rotate
7538
- int dx = info.x - centerPt.x;
7539
- int dy = -(info.y - centerPt.y);
8048
+ int dx = clickInfo.x - centerPt.x;
8049
+ int dy = -(clickInfo.y - centerPt.y);
75408050 double angle = (double) Math.atan2(dx, dy);
75418051 angle = -(1.570796 - angle);
75428052
....@@ -7545,7 +8055,7 @@
75458055
75468056 if (modified)
75478057 {
7548
- // Rotate 90 degrees
8058
+ // Rotate 45 degrees
75498059 angle /= (Math.PI / 4);
75508060 angle = Math.floor(angle + 0.5);
75518061 angle *= (Math.PI / 4);
....@@ -7559,7 +8069,7 @@
75598069 }
75608070 /**/
75618071
7562
- switch (info.pane.RenderCamera().viewCode)
8072
+ switch (clickInfo.pane.RenderCamera().viewCode)
75638073 {
75648074 case 1: // '\001'
75658075 LA.matZRotate(toParent, angle);
....@@ -7586,7 +8096,7 @@
75868096 break;
75878097
75888098 case hitScale: // scale
7589
- double hScale = (double) (info.x - centerPt.x) / 32;
8099
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75908100 double sign = 1;
75918101 if (hScale < 0)
75928102 {
....@@ -7598,7 +8108,7 @@
75988108 //hScale = 0.01;
75998109 }
76008110
7601
- double vScale = (double) (info.y - centerPt.y) / 32;
8111
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76028112 sign = 1;
76038113 if (vScale < 0)
76048114 {
....@@ -7609,6 +8119,7 @@
76098119 {
76108120 //vScale = 0.01;
76118121 }
8122
+
76128123 LA.matCopy(startMat, toParent);
76138124 /**/
76148125 for (int i = 0; i < 3; i++)
....@@ -7618,33 +8129,39 @@
76188129 }
76198130 /**/
76208131
7621
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
8132
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76228133
76238134 if (totalScale < 0.01)
76248135 {
76258136 totalScale = 0.01;
76268137 }
76278138
7628
- switch (info.pane.RenderCamera().viewCode)
8139
+ switch (clickInfo.pane.RenderCamera().viewCode)
76298140 {
76308141 case 3: // '\001'
76318142 if (modified || opposite)
76328143 {
8144
+ if (modified) // && opposite)
8145
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8146
+ else
76338147 //LA.matScale(toParent, 1, hScale, vScale);
7634
- LA.matScale(toParent, totalScale, 1, 1);
8148
+ LA.matScale(toParent, totalScale, 1, 1);
76358149 } // vScale, 1);
76368150 else
76378151 {
76388152 // EXCEPTION!
7639
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8153
+ LA.matScale(toParent, 1, totalScale, totalScale);
76408154 } // vScale, 1);
76418155 break;
76428156
76438157 case 2: // '\002'
76448158 if (modified || opposite)
76458159 {
7646
- //LA.matScale(toParent, hScale, 1, vScale);
7647
- LA.matScale(toParent, 1, totalScale, 1);
8160
+ if (modified) // && opposite)
8161
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8162
+ else
8163
+ //LA.matScale(toParent, hScale, 1, vScale);
8164
+ LA.matScale(toParent, 1, totalScale, 1);
76488165 } else
76498166 {
76508167 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7654,8 +8171,11 @@
76548171 case 1: // '\003'
76558172 if (modified || opposite)
76568173 {
7657
- //LA.matScale(toParent, hScale, vScale, 1);
7658
- LA.matScale(toParent, 1, 1, totalScale);
8174
+ if (modified) // && opposite)
8175
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8176
+ else
8177
+ //LA.matScale(toParent, hScale, vScale, 1);
8178
+ LA.matScale(toParent, 1, 1, totalScale);
76598179 } else
76608180 {
76618181 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7692,7 +8212,7 @@
76928212 } // NEW ...
76938213
76948214
7695
- info.pane.repaint();
8215
+ clickInfo.pane.repaint();
76968216 }
76978217
76988218 boolean overflow = false;
....@@ -7806,7 +8326,7 @@
78068326 if (!Globals.ADVANCED)
78078327 return objname;
78088328
7809
- return objname + " " + System.identityHashCode(this);
8329
+ return objname + " " + System.identityHashCode(this) + " " + GetUUID();
78108330 }
78118331
78128332 public int hashCode()