Normand Briere
2019-11-21 ddb10cb84dddfeef1ef9946f2e13cef3c93e6cc4
Object3D.java
....@@ -22,18 +22,129 @@
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
+
44
+ transient int tabIndex; // Tabs can change between sessions.
45
+
3546 ScriptNode scriptnode;
3647
48
+ void GetOrigin(cVector o)
49
+ {
50
+ o.x = this.toParent[3][0];
51
+ o.y = this.toParent[3][1];
52
+ o.z = this.toParent[3][2];
53
+ }
54
+
55
+ void SetOrigin(cVector o)
56
+ {
57
+ this.toParent[3][0] = o.x;
58
+ this.toParent[3][1] = o.y;
59
+ this.toParent[3][2] = o.z;
60
+ }
61
+
62
+ void deepCopyNode(Object3D other)
63
+ {
64
+ other.skyboxname = skyboxname;
65
+ other.skyboxext = skyboxext;
66
+
67
+ if (toParent != null)
68
+ {
69
+ other.toParent = LA.newMatrix();
70
+ other.fromParent = LA.newMatrix();
71
+ LA.matCopy(toParent, other.toParent);
72
+ LA.matCopy(fromParent, other.fromParent);
73
+ if (toParentMarked != null)
74
+ {
75
+ other.toParentMarked = LA.newMatrix();
76
+ other.fromParentMarked = LA.newMatrix();
77
+ LA.matCopy(toParentMarked, other.toParentMarked);
78
+ LA.matCopy(fromParentMarked, other.fromParentMarked);
79
+ }
80
+ }
81
+ else
82
+ {
83
+ if (other.toParent == null)
84
+// assert(other.toParent == null);
85
+// new Exception().printStackTrace();
86
+ System.err.println("null parent: " + other);
87
+ }
88
+
89
+ /*
90
+ double ident[][] = LA.newMatrix();
91
+ if (bRep == null)
92
+ other.bRep = null;
93
+ else
94
+ other.bRep = new BoundaryRep(bRep, ident);
95
+ */
96
+ // Really new...
97
+ //other.editWindow = null;
98
+ if (name == null)
99
+ other.name = null;
100
+ else
101
+ other.name = new String(name);
102
+
103
+ if (material != null)
104
+ {
105
+ other.material = new cMaterial(material);
106
+ } else
107
+ {
108
+ other.material = null;
109
+ }
110
+
111
+ other.GetTextures().name = GetTextures().name;
112
+
113
+ CopyExtraMaterial(other);
114
+
115
+ other.touched = touched;
116
+ other.softtouched = softtouched;
117
+
118
+ other.random = random;
119
+ other.link2master = Link2Support();
120
+ other.transformcount = transformcount;
121
+ other.marked = marked;
122
+ other.skip = skip;
123
+ other.count = count;
124
+ other.flipV = flipV;
125
+ other.live = live;
126
+ other.rewind = rewind;
127
+ other.hide = hide;
128
+ other.texres = texres;
129
+ other.speedup = speedup;
130
+ other.height = height;
131
+ other.depth = depth;
132
+ }
133
+
134
+ int VersionCount()
135
+ {
136
+ int count = 0;
137
+
138
+ if (versionlist != null)
139
+ for (int i = versionlist.length; --i >= 0;)
140
+ {
141
+ if (versionlist[i] != null)
142
+ count++;
143
+ }
144
+
145
+ return count;
146
+ }
147
+
37148 void InitOthers()
38149 {
39150 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -45,6 +156,7 @@
45156 projectedVertices[i] = new cVector2(); // Others
46157 }
47158 projectedVertices[0].x = 100; // bump
159
+ projectedVertices[1].y = 1000; // punchthrough. only for png
48160 }
49161
50162 void MinMax(cVector minima, cVector maxima)
....@@ -124,7 +236,7 @@
124236 return;
125237
126238 transientsupport = support;
127
- transientlink2master = link2master;
239
+ transientlink2master = Link2Support();
128240
129241 support = null;
130242 link2master = false;
....@@ -171,9 +283,42 @@
171283 }
172284 }
173285
286
+ boolean HasBigData()
287
+ {
288
+ if (blockloop)
289
+ return false;
290
+
291
+ if (bRep != null)
292
+ {
293
+ return true;
294
+ }
295
+
296
+ blockloop = true;
297
+
298
+ for (int i = 0; i < Size(); i++)
299
+ {
300
+ Object3D child = (Object3D) get(i);
301
+ if (child == null)
302
+ continue;
303
+ if (child.HasBigData())
304
+ {
305
+ blockloop = false;
306
+ return true;
307
+ }
308
+ }
309
+
310
+ blockloop = false;
311
+ return false;
312
+ }
313
+
174314 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175315 {
316
+ if (blockloop)
317
+ return;
318
+
176319 Object3D o;
320
+
321
+ boolean isnew = false;
177322
178323 if (hashtable.containsKey(GetUUID()))
179324 {
....@@ -187,12 +332,14 @@
187332 }
188333 else
189334 {
335
+ isnew = true;
336
+
190337 o = new Object3D("copy of " + this.name);
191338
192339 hashtable.put(GetUUID(), o);
193340 }
194341
195
- if (!blockloop)
342
+ //if (!blockloop)
196343 {
197344 blockloop = true;
198345
....@@ -203,12 +350,15 @@
203350
204351 blockloop = false;
205352 }
206
-
207
- ExtractBigData(o);
353
+
354
+ //if (isnew)
355
+ ExtractBigData(o);
208356 }
209357
210358 void ExtractBigData(Object3D o)
211359 {
360
+ //System.err.println("ExtractBigData : " + this + " --> " + o);
361
+
212362 if (o.bRep != null)
213363 Grafreed.Assert(o.bRep == this.bRep);
214364
....@@ -219,8 +369,8 @@
219369 // o.bRep.support = null;
220370 // }
221371 o.selection = this.selection;
222
- o.versions = this.versions;
223
- o.versionindex = this.versionindex;
372
+ //o.versionlist = this.versionlist;
373
+ //o.versionindex = this.versionindex;
224374
225375 if (this.support != null)
226376 {
....@@ -243,17 +393,84 @@
243393 // this.fileparent = null;
244394 }
245395
396
+// Object3D GetObject(java.util.UUID uuid)
397
+// {
398
+// if (this.uuid.equals(uuid))
399
+// return this;
400
+//
401
+// if (blockloop)
402
+// return null;
403
+//
404
+// blockloop = true;
405
+//
406
+// for (int i=0; i<Size(); i++)
407
+// {
408
+// Object3D o = get(i).GetObject(uuid);
409
+//
410
+// if (o != null)
411
+// return o;
412
+// }
413
+//
414
+// blockloop = false;
415
+//
416
+// return null;
417
+// }
418
+
419
+ transient boolean tag;
420
+
421
+ void TagObjects(Object3D o, boolean tag)
422
+ {
423
+ if (blockloop)
424
+ return;
425
+
426
+ o.tag = tag;
427
+
428
+ if (o == this)
429
+ return;
430
+
431
+ blockloop = true;
432
+
433
+ for (int i=0; i<Size(); i++)
434
+ {
435
+ get(i).TagObjects(o, tag);
436
+ }
437
+
438
+ blockloop = false;
439
+ }
440
+
441
+ boolean HasTags()
442
+ {
443
+ if (blockloop)
444
+ return false;
445
+
446
+ blockloop = true;
447
+
448
+ boolean hasTags = false;
449
+
450
+ for (int i=0; i<Size(); i++)
451
+ {
452
+ hasTags |= get(i).tag || get(i).HasTags();
453
+
454
+ if (hasTags)
455
+ break;
456
+ }
457
+
458
+ blockloop = false;
459
+
460
+ return hasTags;
461
+ }
462
+
246463 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247464 {
465
+ if (blockloop)
466
+ return;
467
+
248468 if (!hashtable.containsKey(GetUUID()))
249469 return;
250470
251471 Object3D o = hashtable.get(GetUUID());
252472
253473 RestoreBigData(o);
254
-
255
- if (blockloop)
256
- return;
257474
258475 blockloop = true;
259476
....@@ -269,6 +486,9 @@
269486
270487 void RestoreBigData(Object3D o)
271488 {
489
+ //System.err.println("RestoreBigData : " + this + " <-- " + o);
490
+ Grafreed.Assert(this.bRep == null);
491
+
272492 this.bRep = o.bRep;
273493 if (this.support != null && o.transientrep != null)
274494 {
....@@ -277,8 +497,8 @@
277497
278498 this.selection = o.selection;
279499
280
- this.versions = o.versions;
281
- this.versionindex = o.versionindex;
500
+ //this.versionlist = o.versionlist;
501
+ //this.versionindex = o.versionindex;
282502 // July 2019 if (this.bRep != null)
283503 // this.bRep.support = o.transientrep;
284504 // this.support = o.support;
....@@ -426,9 +646,13 @@
426646 }
427647
428648 boolean live = false;
649
+ transient boolean keepdontselect;
429650 boolean dontselect = false;
430651 boolean hide = false;
431
- boolean link2master = false; // performs reset support/master at each frame
652
+
653
+ boolean link2master = false; // performs reset support/master at each frame (cannot rename due to serialization)
654
+ boolean link2support = false; // (cannot rename due to serialization)
655
+
432656 boolean marked = false; // animation node
433657 boolean skip = false; // centroid issue
434658 boolean skipmocap = false; // mocap data
....@@ -436,6 +660,9 @@
436660 boolean random = false;
437661 boolean speedup = false;
438662 boolean rewind = false;
663
+
664
+ // Option to sort triangles, e.g. for transparency.
665
+ boolean sort = false;
439666
440667 float NORMALPUSH = 0;
441668
....@@ -446,27 +673,74 @@
446673 return this;
447674 }
448675
676
+ class SizeCompare implements Comparable
677
+ {
678
+ int size;
679
+ Object3D child;
680
+
681
+ SizeCompare(Object3D c)
682
+ {
683
+ child = c;
684
+ size = c.MemorySize();
685
+ }
686
+
687
+ public int compareTo(Object o)
688
+ {
689
+ SizeCompare comp = (SizeCompare) o;
690
+
691
+ return comp.size < size ? 1 : -1;
692
+ }
693
+ }
694
+
695
+ transient SizeCompare[] sizecompare = null;
696
+
449697 void SortBySize()
450698 {
451
- boolean sorted = false;
699
+// boolean sorted = false;
700
+//
701
+// while (!sorted)
702
+// {
703
+// sorted = true;
704
+//
705
+// for (int i=0; i<Size()-1; i++)
706
+// {
707
+// Object3D obji = get(i);
708
+// Object3D objj = get(i+1);
709
+//
710
+// if (obji.MemorySize() < objj.MemorySize())
711
+// {
712
+// set(i, objj);
713
+// set(i+1, obji);
714
+//
715
+// sorted = false;
716
+// }
717
+// }
718
+// }
719
+
720
+ int count = Size();
452721
453
- while (!sorted)
722
+ if (sizecompare == null || sizecompare.length != count)
454723 {
455
- sorted = true;
456
-
457
- for (int i=0; i<size()-1; i++)
724
+ sizecompare = new SizeCompare[count];
725
+
726
+ for (int k=0; k<count; k++)
458727 {
459
- Object3D obji = get(i);
460
- Object3D objj = get(i+1);
461
-
462
- if (obji.MemorySize() < objj.MemorySize())
463
- {
464
- set(i, objj);
465
- set(i+1, obji);
466
-
467
- sorted = false;
468
- }
728
+ sizecompare[k] = new SizeCompare(get(k));
469729 }
730
+ }
731
+ else
732
+ {
733
+ for (int k=0; k<count; k++)
734
+ {
735
+ sizecompare[k].size = get(k).MemorySize();
736
+ }
737
+ }
738
+
739
+ java.util.Arrays.sort(sizecompare);
740
+
741
+ for (int i=0; i<count; i++)
742
+ {
743
+ set(i, sizecompare[i].child);
470744 }
471745 }
472746
....@@ -478,7 +752,7 @@
478752 {
479753 sorted = true;
480754
481
- for (int i=0; i<size()-1; i++)
755
+ for (int i=0; i<Size()-1; i++)
482756 {
483757 Object3D obji = get(i);
484758 Object3D objj = get(i+1);
....@@ -494,38 +768,63 @@
494768 }
495769 }
496770
497
- int memorysize;
771
+ transient int memorysize; // needs to be transient, dunno why
498772
499773 int MemorySize()
500774 {
501
- if (true) // memorysize == 0)
775
+// if (memorysize == 0)
776
+// {
777
+// try
778
+// {
779
+// Object3D obj = this;
780
+//
781
+// Object3D parent = obj.parent;
782
+// obj.parent = null;
783
+// Object3D support = obj.support;
784
+// obj.support = null;
785
+//
786
+// java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
787
+// java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos);
788
+//
789
+// out.writeObject(obj);
790
+//
791
+// obj.parent = parent;
792
+// obj.support = support;
793
+//
794
+// memorysize = baos.toByteArray().length;
795
+// }
796
+// catch (Exception e)
797
+// {
798
+// e.printStackTrace();
799
+// }
800
+// }
801
+//
802
+// return memorysize;
803
+
804
+ if (blockloop)
502805 {
503
- try
504
- {
505
- Object3D obj = this;
806
+ return 0;
807
+ }
506808
507
- Object3D parent = obj.parent;
508
- obj.parent = null;
509
- Object3D support = obj.support;
510
- obj.support = null;
511
-
512
- java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
513
- java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos);
514
-
515
- out.writeObject(obj);
516
-
517
- obj.parent = parent;
518
- obj.support = support;
519
-
520
- memorysize = baos.toByteArray().length;
521
- }
522
- catch (Exception e)
523
- {
524
- e.printStackTrace();
525
- }
809
+ int memory = 0;
810
+
811
+ if (bRep != null)
812
+ {
813
+ memory = bRep.VertexCount();
526814 }
527815
528
- return memorysize;
816
+ blockloop = true;
817
+
818
+ for (int i = 0; i < Size(); i++)
819
+ {
820
+ Object3D obj = (Object3D) Children().get(i);
821
+
822
+ memory += obj.MemorySize();
823
+ }
824
+
825
+ blockloop = false;
826
+
827
+ return memory;
529828 }
530829
531830 void Slower()
....@@ -613,7 +912,7 @@
613912 {
614913 if (maxcount != 1)
615914 {
616
- new Exception().printStackTrace();
915
+ //new Exception().printStackTrace();
617916 }
618917
619918 toParentMarked = LA.newMatrix();
....@@ -815,7 +1114,7 @@
8151114
8161115 void Step()
8171116 {
818
- // marde pour serialization de Texture
1117
+ // patch pour serialization de Texture
8191118 resetmaxcount();
8201119 resettransformcount();
8211120 resetstep();
....@@ -850,7 +1149,7 @@
8501149 transformcount++;
8511150 }
8521151
853
- int maxcount;
1152
+ int maxcount = 128;
8541153 int transformcount;
8551154 int step;
8561155
....@@ -903,7 +1202,10 @@
9031202 if (step == 0)
9041203 step = 1;
9051204 if (maxcount == 0)
906
- maxcount = 128; // 2048; // 4;
1205
+ {
1206
+ System.out.println("maxcount == 0");
1207
+ System.exit(0); // maxcount = 128; // 2048; // 4;
1208
+ }
9071209 // if (acceleration == 0)
9081210 // acceleration = 10;
9091211 if (delay == 0) // serial
....@@ -929,6 +1231,8 @@
9291231 (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
9301232 currentframe != Globals.framecount)
9311233 {
1234
+ Globals.lighttouched = true;
1235
+
9321236 currentframe = Globals.framecount;
9331237
9341238 // System.err.println("transformcount = " + transformcount);
....@@ -1008,21 +1312,28 @@
10081312 {
10091313 // return true;
10101314
1011
- if (material == null || material.multiply)
1012
- return true;
1315
+// if (material == null || material.multiply)
1316
+// return true;
1317
+//
1318
+// if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1319
+// return false;
1320
+//
1321
+// // Transparent objects are dynamic because we have to sort the triangles.
1322
+// return material.opacity > 0.99;
10131323
1014
- // Transparent objects are dynamic because we have to sort the triangles.
1015
- return material.opacity > 0.99;
1324
+ return !sort;
10161325 }
10171326
10181327 boolean IsOpaque()
10191328 {
10201329 // return true;
10211330
1022
- if (material == null || material.multiply)
1023
- return true;
1331
+// if (material == null || material.multiply)
1332
+// return true;
1333
+//
1334
+// return material.opacity > 0.99;
10241335
1025
- return material.opacity > 0.99;
1336
+ return !sort;
10261337 }
10271338
10281339 Object3D()
....@@ -1100,8 +1411,10 @@
11001411
11011412 // will share the geometry
11021413 assert (!(this instanceof Composite));
1103
- return deepCopy(); // Never called for Composite
1104
-
1414
+
1415
+ Object3D obj = deepCopy(); // Never called for Composite
1416
+ obj.count = 2;
1417
+ return obj;
11051418 }
11061419
11071420 boolean HasLoops()
....@@ -1109,6 +1422,30 @@
11091422 return false;
11101423 }
11111424
1425
+ void ResetUUIDs()
1426
+ {
1427
+ if (blockloop)
1428
+ {
1429
+ return;
1430
+ }
1431
+
1432
+ this.uuid = null;
1433
+
1434
+ blockloop = true;
1435
+
1436
+ for (int i = 0; i < Size(); i++)
1437
+ {
1438
+ Object3D obj = (Object3D) Children().get(i);
1439
+
1440
+ if (obj != null)
1441
+ {
1442
+ obj.ResetUUIDs();
1443
+ }
1444
+ }
1445
+
1446
+ blockloop = false;
1447
+ }
1448
+
11121449 boolean IsInfinite()
11131450 {
11141451 if (blockloop)
....@@ -1179,78 +1516,16 @@
11791516 return;
11801517
11811518 blockloop = true;
1519
+
1520
+ // other.parent = parent;
1521
+
11821522 //System.out.println("COPY " + this + " to " + other);
11831523 //new Exception().printStackTrace();
1524
+ deepCopyNode(other);
11841525
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...
12151526 other.bRep = bRep; // Share the geometry
12161527
12171528 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;
12541529
12551530 // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist)
12561531 // {
....@@ -1278,7 +1553,7 @@
12781553 Object3D obj = (Object3D)Children().get(i);
12791554 if (IsContainedIn(obj))
12801555 {
1281
-// assert(false); // ?!?!?!?!?!
1556
+ assert(false); // ?!?!?!?!?!
12821557 c.Children().setElementAt(c, i);
12831558 }
12841559 else
....@@ -1306,17 +1581,24 @@
13061581 if ((mask & GEOMETRY) != 0)
13071582 {
13081583 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)
13141584 {
1585
+ bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
13151586 CameraPane.RemoveList(bRep.displaylist);
13161587 bRep.displaylist = 0; // june 2013 -1;
13171588 }
13181589 else
1319
- bRep = bRep;
1590
+ {
1591
+ //assert(other.bRep == null);
1592
+ bRep = other.bRep;
1593
+ }
1594
+
1595
+// if (bRep != null)
1596
+// {
1597
+// CameraPane.RemoveList(bRep.displaylist);
1598
+// bRep.displaylist = 0; // june 2013 -1;
1599
+// }
1600
+// else
1601
+// bRep = bRep;
13201602 }
13211603
13221604 /* Use a MASK = GEO/MAT
....@@ -2292,11 +2574,6 @@
22922574
22932575 InitOthers();
22942576
2295
- if (this instanceof Camera)
2296
- {
2297
- material.shift = 90;
2298
- }
2299
-
23002577 material.multiply = multiply;
23012578
23022579 if (multiply)
....@@ -2374,7 +2651,7 @@
23742651 return b;
23752652 }
23762653
2377
- void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate)
2654
+ void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate, boolean colorparallax)
23782655 {
23792656 if (blockloop)
23802657 {
....@@ -2384,7 +2661,7 @@
23842661 // super.UpdateMaterial(anchor, current, false);
23852662 if (material != null)
23862663 {
2387
- material.UpdateMaterial(anchor, current);
2664
+ material.UpdateMaterial(anchor, current, colorparallax);
23882665 }
23892666
23902667 if (!propagate)
....@@ -2398,7 +2675,7 @@
23982675 if (child == null)
23992676 continue;
24002677 blockloop = true;
2401
- child.UpdateMaterial(anchor, current, propagate);
2678
+ child.UpdateMaterial(anchor, current, propagate, false);
24022679 blockloop = false;
24032680 Children().release(i);
24042681 }
....@@ -2412,7 +2689,7 @@
24122689 if (child == null)
24132690 continue;
24142691 blockloop = true;
2415
- child.UpdateMaterial(anchor, current, propagate);
2692
+ child.UpdateMaterial(anchor, current, propagate, false);
24162693 blockloop = false;
24172694 Children().release(i);
24182695 }
....@@ -2437,6 +2714,11 @@
24372714 else
24382715 {
24392716 //((ObjEditor)editWindow).SetupUI2(null);
2717
+ if (objectUI != null)
2718
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2719
+ else
2720
+ //new Exception().printStackTrace();
2721
+ System.err.println("objectUI is null");
24402722 }
24412723 }
24422724
....@@ -2566,7 +2848,8 @@
25662848 private static final int editSelf = 1;
25672849 private static final int editChild = 2;
25682850
2569
- void drawEditHandles(ClickInfo info, int level)
2851
+ void drawEditHandles(//ClickInfo info,
2852
+ int level)
25702853 {
25712854 if (level == 0)
25722855 {
....@@ -2574,7 +2857,8 @@
25742857 return;
25752858
25762859 Object3D selectee;
2577
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2860
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2861
+ level + 1))
25782862 {
25792863 selectee = (Object3D) e.nextElement();
25802864 }
....@@ -2582,19 +2866,22 @@
25822866 } else
25832867 {
25842868 //super.
2585
- drawEditHandles0(info, level + 1);
2869
+ drawEditHandles0(//info,
2870
+ level + 1);
25862871 }
25872872 }
25882873
2589
- boolean doEditClick(ClickInfo info, int level)
2874
+ boolean doEditClick(//ClickInfo info,
2875
+ int level)
25902876 {
25912877 doSomething = 0;
25922878 if (level == 0)
25932879 {
2594
- return doParentClick(info);
2880
+ return doParentClick(); //info);
25952881 }
25962882 if (//super.
2597
- doEditClick0(info, level))
2883
+ doEditClick0(//info,
2884
+ level))
25982885 {
25992886 doSomething = 1;
26002887 return true;
....@@ -2604,7 +2891,7 @@
26042891 }
26052892 }
26062893
2607
- boolean doParentClick(ClickInfo info)
2894
+ boolean doParentClick() //ClickInfo info)
26082895 {
26092896 if (selection == null)
26102897 {
....@@ -2617,7 +2904,8 @@
26172904 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26182905 {
26192906 Object3D selectee = (Object3D) e.nextElement();
2620
- if (selectee.doEditClick(info, 1))
2907
+ if (selectee.doEditClick(//info,
2908
+ 1))
26212909 {
26222910 childToDrag = selectee;
26232911 doSomething = 2;
....@@ -2629,13 +2917,15 @@
26292917 return retval;
26302918 }
26312919
2632
- void doEditDrag(ClickInfo info, boolean opposite)
2920
+ void doEditDrag(//ClickInfo clickInfo,
2921
+ boolean opposite)
26332922 {
26342923 switch (doSomething)
26352924 {
26362925 case 1: // '\001'
26372926 //super.
2638
- doEditDrag0(info, opposite);
2927
+ doEditDrag0(//clickInfo,
2928
+ opposite);
26392929 break;
26402930
26412931 case 2: // '\002'
....@@ -2648,11 +2938,13 @@
26482938 {
26492939 //sel.hitSomething = childToDrag.hitSomething;
26502940 //childToDrag.doEditDrag(info);
2651
- sel.doEditDrag(info, opposite);
2941
+ sel.doEditDrag(//clickInfo,
2942
+ opposite);
26522943 } else
26532944 {
26542945 //super.
2655
- doEditDrag0(info, opposite);
2946
+ doEditDrag0(//clickInfo,
2947
+ opposite);
26562948 }
26572949 }
26582950 break;
....@@ -2670,6 +2962,9 @@
26702962 {
26712963 deselectAll();
26722964 }
2965
+
2966
+ new Exception().printStackTrace();
2967
+
26732968 ClickInfo newInfo = new ClickInfo();
26742969 newInfo.flags = info.flags;
26752970 newInfo.bounds = info.bounds;
....@@ -3099,7 +3394,10 @@
30993394 {
31003395 if (bRep != null)
31013396 {
3397
+ //bRep.GenerateNormals2(crease); // in-place doesn't work. it gives wrong normals (diamond artifact).
31023398 bRep.GenerateNormals(crease);
3399
+ if (!bRep.trimmed)
3400
+ bRep.MergeNormals();
31033401 Touch();
31043402 }
31053403 }
....@@ -3174,6 +3472,105 @@
31743472 blockloop = false;
31753473 }
31763474
3475
+ public void ResetTransform(int mask)
3476
+ {
3477
+ Object3D obj = this;
3478
+
3479
+ if (mask == -1)
3480
+ {
3481
+ if (obj instanceof Camera) // jan 2014
3482
+ {
3483
+ LA.matIdentity(obj.toParent);
3484
+ LA.matIdentity(obj.fromParent);
3485
+ }
3486
+ else
3487
+ {
3488
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3489
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3490
+ }
3491
+ return;
3492
+ }
3493
+
3494
+ if ((mask&2) != 0) // Scale/rotation
3495
+ {
3496
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3497
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3498
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3499
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3500
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3501
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3502
+ }
3503
+ if ((mask&1) != 0) // Translation
3504
+ {
3505
+ if (obj.toParent != null)
3506
+ {
3507
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3508
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3509
+ }
3510
+ }
3511
+ }
3512
+
3513
+ public void Scale(float scale)
3514
+ {
3515
+ Object3D obj = this;
3516
+
3517
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = scale;
3518
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3519
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3520
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1/scale;
3521
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3522
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3523
+ }
3524
+
3525
+ public void TextureRatioTransform(int axis)
3526
+ {
3527
+ cTexture tex = GetTextures();
3528
+
3529
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3530
+
3531
+ try
3532
+ {
3533
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3534
+ }
3535
+ catch (Exception e)
3536
+ {
3537
+ System.err.println("FAIL TextureRatio: " + this);
3538
+ }
3539
+
3540
+ LA.matIdentity(Object3D.mat);
3541
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3542
+
3543
+ if (toParent == null)
3544
+ {
3545
+ toParent = LA.newMatrix();
3546
+ fromParent = LA.newMatrix();
3547
+ }
3548
+
3549
+ ResetTransform(2);
3550
+
3551
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3552
+ LA.matInvert(fromParent, toParent);
3553
+ }
3554
+
3555
+ void TextureRatio(int axis)
3556
+ {
3557
+ if (blockloop)
3558
+ return;
3559
+
3560
+ blockloop = true;
3561
+
3562
+ TextureRatioTransform(axis);
3563
+
3564
+ for (int i=Size(); --i>=0;)
3565
+ {
3566
+ Object3D v = get(i);
3567
+
3568
+ v.TextureRatio(axis);
3569
+ }
3570
+
3571
+ blockloop = false;
3572
+ }
3573
+
31773574 void TransformChildren()
31783575 {
31793576 if (toParent != null)
....@@ -3416,6 +3813,7 @@
34163813 if (bRep != null)
34173814 {
34183815 //bRep.RemoveOneTriangle();
3816
+ System.out.println();
34193817 System.out.println("Reducing " + this);
34203818 if (name != null && name.contains("lockpickstraps"))
34213819 name = name;
....@@ -3527,15 +3925,47 @@
35273925
35283926 void ClearMaterials()
35293927 {
3928
+ if (blockloop)
3929
+ return;
3930
+
3931
+ blockloop = true;
3932
+
35303933 ClearMaterial();
3531
- for (int i = 0; i < size(); i++)
3934
+ for (int i = 0; i < Size(); i++)
35323935 {
3533
- Object3D child = (Object3D) reserve(i);
3936
+ Object3D child = (Object3D) get(i);
35343937 if (child == null)
35353938 continue;
35363939 child.ClearMaterials();
3537
- release(i);
35383940 }
3941
+
3942
+ blockloop = false;
3943
+ }
3944
+
3945
+ void ClearVersionList()
3946
+ {
3947
+ this.versionlist = null;
3948
+ this.versionindex = -1;
3949
+ this.versiontable = null;
3950
+ }
3951
+
3952
+ void ClearVersions()
3953
+ {
3954
+ if (blockloop)
3955
+ return;
3956
+
3957
+ blockloop = true;
3958
+
3959
+ ClearVersionList();
3960
+ for (int i = 0; i < Size(); i++)
3961
+ {
3962
+ Object3D child = (Object3D) get(i);
3963
+ if (child == null)
3964
+ continue;
3965
+ child.ClearVersions();
3966
+ }
3967
+
3968
+ blockloop = false;
35393969 }
35403970
35413971 void FlipV(boolean flip)
....@@ -3714,6 +4144,7 @@
37144144
37154145 void RevertMeshes()
37164146 {
4147
+ // BLOCKLOOP
37174148 if (this instanceof cMesh)
37184149 {
37194150 ((cMesh)this).Revert();
....@@ -3744,11 +4175,6 @@
37444175 Touch();
37454176 }
37464177
3747
- ResetRecur();
3748
- }
3749
-
3750
- void ResetRecur()
3751
- {
37524178 for (int i = 0; i < size(); i++)
37534179 {
37544180 Object3D child = (Object3D) get(i); // reserve(i);
....@@ -3771,11 +4197,6 @@
37714197 Step();
37724198 Touch();
37734199
3774
- StepRecur();
3775
- }
3776
-
3777
- void StepRecur()
3778
- {
37794200 for (int i = 0; i < size(); i++)
37804201 {
37814202 Object3D child = (Object3D) get(i); // reserve(i);
....@@ -3962,8 +4383,8 @@
39624383 Touch();
39634384 }
39644385
3965
- transient cVector min = new cVector();
3966
- transient cVector max = new cVector();
4386
+ transient cVector min;
4387
+ transient cVector max;
39674388
39684389 void getBounds(cVector minima, cVector maxima, boolean xform)
39694390 {
....@@ -3979,15 +4400,15 @@
39794400 if (blockloop)
39804401 return;
39814402
3982
- if (min == null) // ???
4403
+ if (min == null)
39834404 {
39844405 min = new cVector();
39854406 max = new cVector();
39864407 }
39874408
3988
- for (int i = 0; i<size(); i++)
4409
+ for (int i = 0; i<Size(); i++)
39894410 {
3990
- Object3D child = (Object3D) reserve(i);
4411
+ Object3D child = (Object3D) get(i); //reserve(i);
39914412 if (child == null)
39924413 continue;
39934414
....@@ -4006,21 +4427,21 @@
40064427 if (child.hide && !(child instanceof Merge) || child.skip)
40074428 //if (child.hide)
40084429 {
4009
- release(i);
4430
+ //release(i);
40104431 continue;
40114432 }
40124433
40134434 blockloop = true;
40144435 child.getBounds(min, max, true); // xform);
40154436 blockloop = false;
4016
- release(i);
4437
+ //release(i);
40174438
40184439 MinMax(minima, maxima);
40194440 }
40204441
40214442 if (bRep != null)
40224443 {
4023
- bRep.getBounds(minima,maxima,this);
4444
+ bRep.getBounds(minima, maxima, xform?this:null);
40244445 }
40254446
40264447 if (false) // xform)
....@@ -5293,8 +5714,9 @@
52935714 {
52945715 }
52955716 // transient int displaylist = 0; // -1;
5296
- transient boolean touched = true;
5297
- transient boolean softtouched = true;
5717
+ transient boolean reset = false; // Recalculate
5718
+ transient boolean touched = true; // call list only
5719
+ transient boolean softtouched = true; // aucune idee
52985720
52995721 void Touch()
53005722 {
....@@ -5347,6 +5769,7 @@
53475769 {
53485770 //System.out.println("HardTouch " + this); // new Exception().printStackTrace();
53495771 //new Exception().printStackTrace();
5772
+ reset = true;
53505773 touched = true;
53515774 CameraPane.touched = true;
53525775 //if (parent != null)
....@@ -5420,6 +5843,51 @@
54205843 blockloop = false;
54215844 }
54225845
5846
+ void ResetSelectable()
5847
+ {
5848
+ if (blockloop)
5849
+ return;
5850
+
5851
+ blockloop = true;
5852
+
5853
+ keepdontselect = dontselect;
5854
+ dontselect = true;
5855
+
5856
+ Object3D child;
5857
+ int nb = Size();
5858
+ for (int i = 0; i < nb; i++)
5859
+ {
5860
+ child = (Object3D) get(i);
5861
+ if (child == null)
5862
+ continue;
5863
+ child.ResetSelectable();
5864
+ }
5865
+
5866
+ blockloop = false;
5867
+ }
5868
+
5869
+ void RestoreSelectable()
5870
+ {
5871
+ if (blockloop)
5872
+ return;
5873
+
5874
+ blockloop = true;
5875
+
5876
+ dontselect = keepdontselect;
5877
+
5878
+ Object3D child;
5879
+ int nb = Size();
5880
+ for (int i = 0; i < nb; i++)
5881
+ {
5882
+ child = (Object3D) get(i);
5883
+ if (child == null)
5884
+ continue;
5885
+ child.RestoreSelectable();
5886
+ }
5887
+
5888
+ blockloop = false;
5889
+ }
5890
+
54235891 boolean IsSelected()
54245892 {
54255893 if (parent == null)
....@@ -5480,6 +5948,11 @@
54805948 if (fullname == null)
54815949 return "";
54825950
5951
+ if (fullname.pigment != null)
5952
+ {
5953
+ return fullname.pigment;
5954
+ }
5955
+
54835956 // System.out.println("Fullname = " + fullname);
54845957
54855958 // Does not work on Windows due to C:
....@@ -5492,7 +5965,7 @@
54925965
54935966 if (split.length == 0)
54945967 {
5495
- return "";
5968
+ return fullname.pigment = "";
54965969 }
54975970
54985971 if (split.length <= 2)
....@@ -5500,22 +5973,27 @@
55005973 if (fullname.name.endsWith(":"))
55015974 {
55025975 // Windows
5503
- return fullname.name.substring(0, fullname.name.length()-1);
5976
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55045977 }
55055978
5506
- return split[0];
5979
+ return fullname.pigment = split[0];
55075980 }
55085981
55095982 // Windows
55105983 assert(split.length == 4);
55115984
5512
- return split[0] + ":" + split[1];
5985
+ return fullname.pigment = split[0] + ":" + split[1];
55135986 }
55145987
55155988 static String GetBump(cTexture fullname)
55165989 {
55175990 if (fullname == null)
55185991 return "";
5992
+
5993
+ if (fullname.bump != null)
5994
+ {
5995
+ return fullname.bump;
5996
+ }
55195997
55205998 // System.out.println("Fullname = " + fullname);
55215999 // Does not work on Windows due to C:
....@@ -5527,12 +6005,12 @@
55276005
55286006 if (split.length == 0)
55296007 {
5530
- return "";
6008
+ return fullname.bump = "";
55316009 }
55326010
55336011 if (split.length == 1)
55346012 {
5535
- return "";
6013
+ return fullname.bump = "";
55366014 }
55376015
55386016 if (split.length == 2)
....@@ -5540,16 +6018,16 @@
55406018 if (fullname.name.endsWith(":"))
55416019 {
55426020 // Windows
5543
- return "";
6021
+ return fullname.bump = "";
55446022 }
55456023
5546
- return split[1];
6024
+ return fullname.bump = split[1];
55476025 }
55486026
55496027 // Windows
55506028 assert(split.length == 4);
55516029
5552
- return split[2] + ":" + split[3];
6030
+ return fullname.bump = split[2] + ":" + split[3];
55536031 }
55546032
55556033 String GetPigmentTexture()
....@@ -5632,6 +6110,9 @@
56326110 texname = "";
56336111
56346112 GetTextures().name = texname + ":" + GetBump(GetTextures());
6113
+
6114
+ GetTextures().pigment = null;
6115
+
56356116 Touch();
56366117 }
56376118
....@@ -5705,6 +6186,8 @@
57056186
57066187 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57076188
6189
+ GetTextures().bump = null;
6190
+
57086191 Touch();
57096192 }
57106193
....@@ -5729,6 +6212,38 @@
57296212 }
57306213 }
57316214
6215
+ void EmbedTextures(boolean embed)
6216
+ {
6217
+ if (blockloop)
6218
+ return;
6219
+
6220
+ //if (GetTextures() != null)
6221
+ if (embed)
6222
+ CameraPane.EmbedTextures(GetTextures());
6223
+ else
6224
+ {
6225
+ GetTextures().pigmentdata = null;
6226
+ GetTextures().bumpdata = null;
6227
+ GetTextures().pw = 0;
6228
+ GetTextures().ph = 0;
6229
+ GetTextures().bw = 0;
6230
+ GetTextures().bh = 0;
6231
+ }
6232
+
6233
+ int nb = Size();
6234
+ for (int i = 0; i < nb; i++)
6235
+ {
6236
+ Object3D child = (Object3D) get(i);
6237
+
6238
+ if (child == null)
6239
+ continue;
6240
+
6241
+ blockloop = true;
6242
+ child.EmbedTextures(embed);
6243
+ blockloop = false;
6244
+ }
6245
+ }
6246
+
57326247 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57336248 {
57346249 Draw(display, root, selected, blocked);
....@@ -5737,7 +6252,7 @@
57376252 boolean NeedSupport()
57386253 {
57396254 return
5740
- CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
6255
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && Link2Support() && /*live &&*/ support != null
57416256 // PROBLEM with CROWD!!
57426257 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
57436258 }
....@@ -5755,6 +6270,22 @@
57556270 return parent.IsLive();
57566271 }
57576272
6273
+ boolean IsDynamic()
6274
+ {
6275
+ return live && bRep != null;
6276
+ }
6277
+
6278
+ boolean Link2Support()
6279
+ {
6280
+ return link2master || link2support;
6281
+ }
6282
+
6283
+ static cVector minima = new cVector();
6284
+ static cVector maxima = new cVector();
6285
+ static javax.vecmath.Point3d center = new javax.vecmath.Point3d();
6286
+
6287
+ boolean compiling;
6288
+
57586289 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57596290 {
57606291 Invariants(); // june 2013
....@@ -5762,6 +6293,29 @@
57626293 if (support != null)
57636294 {
57646295 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
6296
+ }
6297
+
6298
+ if (false) // live && Link2Support() && support == null && !this.marked) // project on ground
6299
+ {
6300
+ getBounds(minima, maxima, true);
6301
+ center.x = (minima.x + maxima.x) / 2;
6302
+ center.y = 10000; // (minima.y + maxima.y) / 2;
6303
+ center.z = (minima.z + maxima.z) / 2;
6304
+
6305
+ Ray ray = new Ray(center, new Vector3d(0,-1,0));
6306
+
6307
+ IntersectResult res = new IntersectResult();
6308
+ res.t = Double.POSITIVE_INFINITY;
6309
+
6310
+ if (Grafreed.grafreed.universe.intersect(ray, res))
6311
+ {
6312
+ double resx = ray.eyePoint.x + ray.viewDirection.x * res.t;
6313
+ double resy = ray.eyePoint.y + ray.viewDirection.y * res.t;
6314
+ double resz = ray.eyePoint.z + ray.viewDirection.z * res.t;
6315
+
6316
+ LA.matTranslate(toParent, 0, resy - minima.y, 0);
6317
+ LA.matInvert(toParent, fromParent);
6318
+ }
57656319 }
57666320
57676321 if (display.DrawMode() == iCameraPane.SELECTION &&
....@@ -5815,8 +6369,12 @@
58156369 if (support != null)
58166370 support = support;
58176371
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);
6372
+ boolean usecalllists = !IsDynamic() &&
6373
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !Link2Support()); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6374
+
6375
+ //usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6376
+
6377
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
58206378
58216379 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58226380 {
....@@ -5824,10 +6382,12 @@
58246382 bRep.displaylist = 0;
58256383 }
58266384 // usecalllists &= !(parent instanceof RandomNode);
5827
- // usecalllists = false;
6385
+ if (CameraPane.BOXMODE) // Too dynamic
6386
+ usecalllists = false;
58286387
5829
- if (GetBRep() != null)
5830
- usecalllists = usecalllists;
6388
+ if (display.DrawMode() == display.SHADOW)
6389
+ //GetBRep() != null)
6390
+ usecalllists = !!usecalllists;
58316391 //System.out.println("draw " + this);
58326392 //new Exception().printStackTrace();
58336393
....@@ -5837,7 +6397,7 @@
58376397
58386398 if (!selectmode && //display.DrawMode() != display.SELECTION &&
58396399 //(touched || (bRep != null && bRep.displaylist <= 0)))
5840
- (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
6400
+ ((Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE) || touched)) // || (bRep != null && bRep.displaylist <= 0)))
58416401 {
58426402 Globals.lighttouched = true;
58436403 } // all panes...
....@@ -5849,7 +6409,7 @@
58496409 if (!(this instanceof Composite))
58506410 touched = false;
58516411 //if (displaylist == -1 && usecalllists)
5852
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6412
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58536413 {
58546414 bRep.displaylist = display.GenList();
58556415 assert(bRep.displaylist != 0);
....@@ -5860,16 +6420,18 @@
58606420
58616421 //System.out.println("\tnew list " + list);
58626422 //gl.glDrawBuffer(gl.GL_NONE);
5863
- if (usecalllists)
6423
+ if (usecalllists && bRep.displaylist > 0)
58646424 {
58656425 // System.err.println("new list " + bRep.displaylist + " for " + this);
58666426 display.NewList(bRep.displaylist);
58676427 }
58686428
6429
+ compiling = true;
58696430 CallList(display, root, selected, blocked);
6431
+ compiling = false;
58706432
58716433 // compiled = true;
5872
- if (usecalllists)
6434
+ if (usecalllists && bRep.displaylist > 0)
58736435 {
58746436 // System.err.println("end list " + bRep.displaylist + " for " + this);
58756437 display.EndList();
....@@ -5879,8 +6441,8 @@
58796441 Globals.lighttouched = true; // all panes...
58806442 }
58816443
5882
- touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
5883
- //touched = false;
6444
+ //touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
6445
+ touched = false;
58846446
58856447 if (this instanceof Texture || this instanceof TextureNode)
58866448 {
....@@ -5919,7 +6481,7 @@
59196481 {
59206482 if (display.DrawMode() == iCameraPane.SHADOW)
59216483 {
5922
- if (!link2master // tricky to cull in shadow mode.
6484
+ if (!Link2Support() // tricky to cull in shadow mode.
59236485 && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
59246486 {
59256487 //System.out.print("CULLED");
....@@ -5981,6 +6543,20 @@
59816543 {
59826544 drawSelf(display, root, selected, blocked);
59836545 }
6546
+
6547
+// if (!(this instanceof Composite))
6548
+// {
6549
+// for (int i = 0; i < size(); i++)
6550
+// {
6551
+// Object3D child = (Object3D) reserve(i);
6552
+// if (child == null)
6553
+// continue;
6554
+//
6555
+// child.draw(display, root, selected, blocked);
6556
+//
6557
+// release(i);
6558
+// }
6559
+// }
59846560 } else
59856561 {
59866562 /*
....@@ -6013,13 +6589,14 @@
60136589 boolean failedPigment = false;
60146590 boolean failedBump = false;
60156591
6592
+ CameraPane.lastObject = this;
60166593 try
60176594 {
60186595 display.BindPigmentTexture(tex, texres);
60196596 }
60206597 catch (Exception e)
60216598 {
6022
- System.err.println("FAILED: " + this);
6599
+ // System.err.println("FAILED: " + this);
60236600 failedPigment = true;
60246601 }
60256602
....@@ -6050,6 +6627,20 @@
60506627 display.CallList(bRep.displaylist);
60516628 // june 2013 drawSelf(display, root, selected);
60526629 }
6630
+ }
6631
+
6632
+ // Bezier surface: assert (!(this instanceof Composite));
6633
+ {
6634
+// CRASH MOCAP!! for (int i = 0; i < size(); i++)
6635
+// {
6636
+// Object3D child = (Object3D) reserve(i);
6637
+// if (child == null)
6638
+// continue;
6639
+//
6640
+// child.draw(display, root, selected, blocked);
6641
+//
6642
+// release(i);
6643
+// }
60536644 }
60546645 }
60556646
....@@ -6103,16 +6694,17 @@
61036694
61046695 void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
61056696 {
6106
- if (GetBRep() == null)
6107
- {
6108
- drawSelf(display, root, selected, blocked);
6109
- } else
6697
+ if (GetBRep() != null)
61106698 {
61116699 DrawNode(display, root, selected);
61126700 if (this instanceof BezierPatch)
61136701 {
61146702 //drawSelf(display, root, selected);
61156703 }
6704
+ }
6705
+ else
6706
+ {
6707
+ drawSelf(display, root, selected, blocked);
61166708 }
61176709 }
61186710
....@@ -6311,15 +6903,18 @@
63116903
63126904 void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
63136905 {
6314
- if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6315
- return; // no shadow for transparent objects
6316
-
6317
- if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
- return;
6906
+ if (!compiling)
6907
+ {
6908
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6909
+ return; // no shadow for transparent objects
6910
+
6911
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6912
+ return;
6913
+ }
63196914
63206915 if (hide)
63216916 return;
6322
-
6917
+
63236918 if (scriptnode != null)
63246919 {
63256920 scriptnode.DrawNode(display, root, selected);
....@@ -6362,7 +6957,8 @@
63626957
63636958 //javax.media.opengl.GL gl = display.GetGL();
63646959
6365
- if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
6960
+ if (CameraPane.BOXMODE && !Link2Support()) //
6961
+ //!selected) // || CameraPane.movingcamera)
63666962 {
63676963 int fc = bRep.FaceCount();
63686964 int vc = bRep.VertexCount();
....@@ -6524,7 +7120,7 @@
65247120 facescompare[k] = new FaceCompare(k);
65257121 }
65267122
6527
- center = new cVector();
7123
+ centertriangle = new cVector();
65287124 }
65297125 else
65307126 {
....@@ -6647,7 +7243,7 @@
66477243 */
66487244 }
66497245
6650
- transient cVector center;
7246
+ transient cVector centertriangle;
66517247
66527248 class FaceCompare implements Comparable
66537249 {
....@@ -6676,14 +7272,14 @@
66767272 Vertex q = bRep.GetVertex(face.q);
66777273 Vertex r = bRep.GetVertex(face.r);
66787274
6679
- center.set(p);
6680
- center.add(q);
6681
- center.add(r);
6682
- center.mul(1.0/3);
7275
+ centertriangle.set(p);
7276
+ centertriangle.add(q);
7277
+ centertriangle.add(r);
7278
+ centertriangle.mul(1.0/3);
66837279
6684
- center.sub(Globals.theRenderer.EyeCamera().location);
7280
+ centertriangle.sub(Globals.theRenderer.EyeCamera().location);
66857281
6686
- distance = center.dot(center);
7282
+ distance = centertriangle.dot(centertriangle);
66877283 }
66887284
66897285 return distance;
....@@ -7220,20 +7816,23 @@
72207816 }
72217817 }
72227818
7223
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7819
+ static ClickInfo clickInfo = new ClickInfo();
7820
+
7821
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7822
+ Point outPt, Rectangle outRec)
72247823 {
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;
7824
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7825
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7826
+ double[][] toscreen = clickInfo.toScreen;
72287827 if (toscreen == null)
72297828 {
7230
- toscreen = new Camera(info.camera.viewCode).toScreen;
7829
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72317830 }
72327831 cVector vec = in;
72337832 LA.xformPos(in, toscreen, in);
72347833 //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();
7834
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7835
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72377836 outPt.x = hc + (int) vec.x;
72387837 outPt.y = vc - (int) vec.y;
72397838 outRec.x = outPt.x - 3;
....@@ -7241,15 +7840,18 @@
72417840 outRec.width = outRec.height = 6;
72427841 }
72437842
7244
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7843
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7844
+ )
72457845 {
72467846 Point pt = new Point(0, 0);
72477847 Rectangle rec = new Rectangle();
7248
- calcHotSpot(in, info, pt, rec);
7848
+ calcHotSpot(in, //clickInfo,
7849
+ pt, rec);
72497850 return rec;
72507851 }
72517852
7252
- void drawEditHandles0(ClickInfo info, int level)
7853
+ void drawEditHandles0(//ClickInfo clickInfo,
7854
+ int level)
72537855 {
72547856 if (level == 0)
72557857 {
....@@ -7258,16 +7860,19 @@
72587860 {
72597861 cVector origin = new cVector();
72607862 //LA.xformPos(origin, toParent, origin);
7261
- Rectangle spot = calcHotSpot(origin, info);
7863
+ if (this.clickInfo == null)
7864
+ this.clickInfo = new ClickInfo();
7865
+
7866
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72627867 Rectangle boundary = new Rectangle();
72637868 boundary.x = spot.x - 30;
72647869 boundary.y = spot.y - 30;
72657870 boundary.width = spot.width + 60;
72667871 boundary.height = spot.height + 60;
7267
- info.g.setColor(Color.red);
7872
+ clickInfo.g.setColor(Color.white);
72687873 int spotw = spot.x + spot.width;
72697874 int spoth = spot.y + spot.height;
7270
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7875
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72717876 // if (CameraPane.Xmin > spot.x)
72727877 // {
72737878 // CameraPane.Xmin = spot.x;
....@@ -7284,11 +7889,6 @@
72847889 // {
72857890 // CameraPane.Ymax = spoth;
72867891 // }
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);
72927892 // if (CameraPane.Xmin > spot.x)
72937893 // {
72947894 // CameraPane.Xmin = spot.x;
....@@ -7307,10 +7907,15 @@
73077907 // }
73087908 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73097909 //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);
7910
+ spot.translate(32, 0);
7911
+ clickInfo.g.setColor(Color.yellow);
7912
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7913
+
7914
+ spot.translate(32, 64);
7915
+ spotw = spot.x + spot.width;
7916
+ spoth = spot.y + spot.height;
7917
+ clickInfo.g.setColor(Color.cyan);
7918
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73147919 // if (CameraPane.Xmin > spot.x)
73157920 // {
73167921 // CameraPane.Xmin = spot.x;
....@@ -7327,8 +7932,9 @@
73277932 // {
73287933 // CameraPane.Ymax = spoth;
73297934 // }
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);
7935
+ clickInfo.g.setColor(Color.green);
7936
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7937
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73327938 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73337939 // if (CameraPane.Xmin > boundary.x)
73347940 // {
....@@ -7350,7 +7956,8 @@
73507956 }
73517957 }
73527958
7353
- boolean doEditClick0(ClickInfo info, int level)
7959
+ boolean doEditClick0(//ClickInfo clickInfo,
7960
+ int level)
73547961 {
73557962 if (level == 0)
73567963 {
....@@ -7359,8 +7966,8 @@
73597966
73607967 boolean retval = false;
73617968
7362
- startX = info.x;
7363
- startY = info.y;
7969
+ startX = clickInfo.x;
7970
+ startY = clickInfo.y;
73647971
73657972 hitSomething = -1;
73667973 cVector origin = new cVector();
....@@ -7370,22 +7977,53 @@
73707977 {
73717978 centerPt = new Point(0, 0);
73727979 }
7373
- calcHotSpot(origin, info, centerPt, spot);
7374
- if (spot.contains(info.x, info.y))
7980
+ calcHotSpot(origin, //info,
7981
+ centerPt, spot);
7982
+ if (spot.contains(clickInfo.x, clickInfo.y))
73757983 {
73767984 hitSomething = hitCenter;
73777985 retval = true;
73787986 }
73797987 spot.translate(32, 0);
7380
- if (spot.contains(info.x, info.y))
7988
+ if (spot.contains(clickInfo.x, clickInfo.y))
73817989 {
73827990 hitSomething = hitRotate;
73837991 retval = true;
73847992 }
73857993 spot.translate(0, 32);
7386
- if (spot.contains(info.x, info.y))
7994
+ spot.translate(32, 0);
7995
+ spot.translate(0, 32);
7996
+ if (spot.contains(clickInfo.x, clickInfo.y))
73877997 {
73887998 hitSomething = hitScale;
7999
+
8000
+ double scale = 0.005f * clickInfo.camera.Distance();
8001
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
8002
+ double sign = 1;
8003
+ if (hScale < 0)
8004
+ {
8005
+ sign = -1;
8006
+ }
8007
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
8008
+ if (hScale < 0.01)
8009
+ {
8010
+ //hScale = 0.01;
8011
+ }
8012
+
8013
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
8014
+ sign = 1;
8015
+ if (vScale < 0)
8016
+ {
8017
+ sign = -1;
8018
+ }
8019
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
8020
+ if (vScale < 0.01)
8021
+ {
8022
+ //vScale = 0.01;
8023
+ }
8024
+
8025
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
8026
+
73898027 retval = true;
73908028 }
73918029
....@@ -7395,7 +8033,7 @@
73958033 }
73968034
73978035 //System.out.println("info.modifiers = " + info.modifiers);
7398
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
8036
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73998037 //System.out.println("modified = " + modified);
74008038 //new Exception().printStackTrace();
74018039 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7423,7 +8061,8 @@
74238061 return true;
74248062 }
74258063
7426
- void doEditDrag0(ClickInfo info, boolean opposite)
8064
+ void doEditDrag0(//ClickInfo info,
8065
+ boolean opposite)
74278066 {
74288067 if (hitSomething == 0)
74298068 {
....@@ -7437,7 +8076,7 @@
74378076
74388077 //System.out.println("hitSomething = " + hitSomething);
74398078
7440
- double scale = 0.005f * info.camera.Distance();
8079
+ double scale = 0.005f * clickInfo.camera.Distance();
74418080
74428081 cVector xlate = new cVector();
74438082 //cVector xlate2 = new cVector();
....@@ -7451,7 +8090,9 @@
74518090
74528091 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74538092
7454
- if (modified || opposite)
8093
+ // Modified could snap
8094
+ if (//modified ||
8095
+ opposite)
74558096 {
74568097 //assert(false);
74578098 /*
....@@ -7471,8 +8112,8 @@
74718112 toParent[3][i] = xlate.get(i);
74728113 LA.matInvert(toParent, fromParent);
74738114 */
7474
- cVector delta = LA.newVector(0, 0, startY - info.y);
7475
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
8115
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
8116
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74768117
74778118 LA.matCopy(startMat, toParent);
74788119 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7481,7 +8122,7 @@
74818122 } else
74828123 {
74838124 //LA.xformDir(delta, info.camera.fromScreen, delta);
7484
- cVector up = new cVector(info.camera.up);
8125
+ cVector up = new cVector(clickInfo.camera.up);
74858126 cVector away = new cVector();
74868127 //cVector right2 = new cVector();
74878128 //LA.vecCross(up, cVector.Z, right);
....@@ -7498,19 +8139,19 @@
74988139 LA.xformDir(up, ClickInfo.matbuffer, up);
74998140 // if (!CameraPane.LOCALTRANSFORM)
75008141 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7501
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
8142
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75028143 // if (!CameraPane.LOCALTRANSFORM)
75038144 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75048145 //LA.vecCross(up, cVector.Z, right2);
75058146
7506
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
8147
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75078148
75088149 //System.out.println("DELTA0 = " + delta);
75098150 //System.out.println("AWAY = " + info.camera.away);
75108151 //System.out.println("UP = " + info.camera.up);
75118152 if (away.z > 0)
75128153 {
7513
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
8154
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75148155 {
75158156 delta.x = -delta.x;
75168157 } else
....@@ -7525,7 +8166,7 @@
75258166 //System.out.println("DELTA1 = " + delta);
75268167 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75278168 //System.out.println("DELTA2 = " + delta);
7528
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
8169
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75298170 LA.matCopy(startMat, toParent);
75308171 //System.out.println("DELTA3 = " + delta);
75318172 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7535,8 +8176,8 @@
75358176 break;
75368177
75378178 case hitRotate: // rotate
7538
- int dx = info.x - centerPt.x;
7539
- int dy = -(info.y - centerPt.y);
8179
+ int dx = clickInfo.x - centerPt.x;
8180
+ int dy = -(clickInfo.y - centerPt.y);
75408181 double angle = (double) Math.atan2(dx, dy);
75418182 angle = -(1.570796 - angle);
75428183
....@@ -7545,7 +8186,7 @@
75458186
75468187 if (modified)
75478188 {
7548
- // Rotate 90 degrees
8189
+ // Rotate 45 degrees
75498190 angle /= (Math.PI / 4);
75508191 angle = Math.floor(angle + 0.5);
75518192 angle *= (Math.PI / 4);
....@@ -7559,7 +8200,7 @@
75598200 }
75608201 /**/
75618202
7562
- switch (info.pane.RenderCamera().viewCode)
8203
+ switch (clickInfo.pane.RenderCamera().viewCode)
75638204 {
75648205 case 1: // '\001'
75658206 LA.matZRotate(toParent, angle);
....@@ -7586,7 +8227,7 @@
75868227 break;
75878228
75888229 case hitScale: // scale
7589
- double hScale = (double) (info.x - centerPt.x) / 32;
8230
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75908231 double sign = 1;
75918232 if (hScale < 0)
75928233 {
....@@ -7598,7 +8239,7 @@
75988239 //hScale = 0.01;
75998240 }
76008241
7601
- double vScale = (double) (info.y - centerPt.y) / 32;
8242
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76028243 sign = 1;
76038244 if (vScale < 0)
76048245 {
....@@ -7609,6 +8250,7 @@
76098250 {
76108251 //vScale = 0.01;
76118252 }
8253
+
76128254 LA.matCopy(startMat, toParent);
76138255 /**/
76148256 for (int i = 0; i < 3; i++)
....@@ -7618,33 +8260,39 @@
76188260 }
76198261 /**/
76208262
7621
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
8263
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76228264
76238265 if (totalScale < 0.01)
76248266 {
76258267 totalScale = 0.01;
76268268 }
76278269
7628
- switch (info.pane.RenderCamera().viewCode)
8270
+ switch (clickInfo.pane.RenderCamera().viewCode)
76298271 {
76308272 case 3: // '\001'
76318273 if (modified || opposite)
76328274 {
8275
+ if (modified) // && opposite)
8276
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8277
+ else
76338278 //LA.matScale(toParent, 1, hScale, vScale);
7634
- LA.matScale(toParent, totalScale, 1, 1);
8279
+ LA.matScale(toParent, totalScale, 1, 1);
76358280 } // vScale, 1);
76368281 else
76378282 {
76388283 // EXCEPTION!
7639
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8284
+ LA.matScale(toParent, 1, totalScale, totalScale);
76408285 } // vScale, 1);
76418286 break;
76428287
76438288 case 2: // '\002'
76448289 if (modified || opposite)
76458290 {
7646
- //LA.matScale(toParent, hScale, 1, vScale);
7647
- LA.matScale(toParent, 1, totalScale, 1);
8291
+ if (modified) // && opposite)
8292
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8293
+ else
8294
+ //LA.matScale(toParent, hScale, 1, vScale);
8295
+ LA.matScale(toParent, 1, totalScale, 1);
76488296 } else
76498297 {
76508298 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7654,8 +8302,11 @@
76548302 case 1: // '\003'
76558303 if (modified || opposite)
76568304 {
7657
- //LA.matScale(toParent, hScale, vScale, 1);
7658
- LA.matScale(toParent, 1, 1, totalScale);
8305
+ if (modified) // && opposite)
8306
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8307
+ else
8308
+ //LA.matScale(toParent, hScale, vScale, 1);
8309
+ LA.matScale(toParent, 1, 1, totalScale);
76598310 } else
76608311 {
76618312 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7692,7 +8343,7 @@
76928343 } // NEW ...
76938344
76948345
7695
- info.pane.repaint();
8346
+ clickInfo.pane.repaint();
76968347 }
76978348
76988349 boolean overflow = false;
....@@ -7799,19 +8450,19 @@
77998450 objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78008451 } else
78018452 {
7802
- objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
8453
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + ((bRep==null)?(count - 1):bRep.VertexCount()) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78038454 } // + super.toString();
78048455 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
78058456
78068457 if (!Globals.ADVANCED)
78078458 return objname;
78088459
7809
- return objname + " " + System.identityHashCode(this);
8460
+ return objname + " " + System.identityHashCode(this) + " " + GetUUID();
78108461 }
78118462
78128463 public int hashCode()
78138464 {
7814
- // Fuck Vector...
8465
+ // Do not use Vector...
78158466 return System.identityHashCode(this);
78168467 }
78178468
....@@ -8051,8 +8702,8 @@
80518702 private static cVector2 qq2 = new cVector2();
80528703 private static cVector2 rr2 = new cVector2();
80538704 private static cVector2 ss2 = new cVector2();
8054
- private static cVector edge1 = new cVector();
8055
- private static cVector edge2 = new cVector();
8705
+// private static cVector edge1 = new cVector();
8706
+// private static cVector edge2 = new cVector();
80568707 //private static cVector norm = new cVector();
80578708 /*transient private*/ int hitSomething;
80588709 static final int hitCenter = 1;
....@@ -8250,7 +8901,275 @@
82508901
82518902 Touch();
82528903 }
8904
+
8905
+ static Vertex s1 = new Vertex();
8906
+ static Vertex s2 = new Vertex();
8907
+ static Vertex s3 = new Vertex();
82538908
8909
+ boolean intersectMesh(Ray ray, IntersectResult result)
8910
+ {
8911
+ boolean success = false;
8912
+
8913
+ if (bRep.stripified)
8914
+ {
8915
+ int[] strips = bRep.getRawIndices();
8916
+
8917
+ // TRIANGLE STRIP ARRAY
8918
+ if (bRep.trimmed)
8919
+ {
8920
+ float[] v = bRep.getRawVertices();
8921
+
8922
+ int count3 = 0;
8923
+
8924
+ if (v.length > 0)
8925
+ {
8926
+ for (int i = 0; i < strips.length; i++)
8927
+ {
8928
+ s1.set(v[count3], v[count3 + 1], v[count3 + 2]);
8929
+ count3 += 3;
8930
+
8931
+ s2.set(v[count3], v[count3 + 1], v[count3 + 2]);
8932
+ count3 += 3;
8933
+
8934
+ for (int j = 0; j < strips[i] - 2; j++)
8935
+ {
8936
+ s3.set(v[count3], v[count3 + 1], v[count3 + 2]);
8937
+ count3 += 3;
8938
+
8939
+ if (j%2 == 0)
8940
+ success |= intersectTriangle(ray, result, s1, s2, s3);
8941
+ else
8942
+ success |= intersectTriangle(ray, result, s1, s3, s2);
8943
+
8944
+ s1.set(s2);
8945
+ s2.set(s3);
8946
+ }
8947
+ }
8948
+ }
8949
+
8950
+ assert count3 == v.length;
8951
+ }
8952
+ else // !trimmed
8953
+ {
8954
+ int count = 0;
8955
+ for (int i = 0; i < strips.length; i++)
8956
+ {
8957
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
8958
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
8959
+
8960
+ for (int j = 0; j < strips[i] - 2; j++)
8961
+ {
8962
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
8963
+
8964
+ if (j%2 == 0)
8965
+ success |= intersectTriangle(ray, result, p, q, r);
8966
+ else
8967
+ success |= intersectTriangle(ray, result, p, r, q);
8968
+
8969
+ p = q;
8970
+ q = r;
8971
+ }
8972
+ }
8973
+ }
8974
+ } else // catch (Error e)
8975
+ {
8976
+ int facecount = bRep.FaceCount();
8977
+ for (int i = 0; i < facecount; i++)
8978
+ {
8979
+ Face face = bRep.GetFace(i);
8980
+
8981
+ Vertex p = bRep.GetVertex(face.p);
8982
+ Vertex q = bRep.GetVertex(face.q);
8983
+ Vertex r = bRep.GetVertex(face.r);
8984
+
8985
+ success |= intersectTriangle(ray, result, p, q, r);
8986
+ }
8987
+ }
8988
+
8989
+ return success;
8990
+ }
8991
+
8992
+ static cVector eye = new cVector();
8993
+ static cVector dir = new cVector();
8994
+
8995
+ transient BBox bbox = null;
8996
+
8997
+ boolean intersect(Ray ray, IntersectResult result)
8998
+ {
8999
+ double eyex = ray.eyePoint.x;
9000
+ double eyey = ray.eyePoint.y;
9001
+ double eyez = ray.eyePoint.z;
9002
+
9003
+ double dirx = ray.viewDirection.x;
9004
+ double diry = ray.viewDirection.y;
9005
+ double dirz = ray.viewDirection.z;
9006
+
9007
+ if (this.fromParent != null && !(this instanceof TextureNode))
9008
+ {
9009
+ eye.x = eyex;
9010
+ eye.y = eyey;
9011
+ eye.z = eyez;
9012
+ dir.x = dirx;
9013
+ dir.y = diry;
9014
+ dir.z = dirz;
9015
+
9016
+ LA.xformPos(eye, this.fromParent, eye);
9017
+ LA.xformDir(dir, this.fromParent, dir);
9018
+
9019
+ ray.eyePoint.x = eye.x;
9020
+ ray.eyePoint.y = eye.y;
9021
+ ray.eyePoint.z = eye.z;
9022
+
9023
+ ray.viewDirection.x = dir.x;
9024
+ ray.viewDirection.y = dir.y;
9025
+ ray.viewDirection.z = dir.z;
9026
+ }
9027
+
9028
+ boolean success = false;
9029
+
9030
+ boolean touch = false;
9031
+
9032
+ if (bRep != null && Link2Support())
9033
+ {
9034
+ if (bbox == null)
9035
+ {
9036
+ bbox = new BBox();
9037
+
9038
+ cVector min = new cVector();
9039
+ cVector max = new cVector();
9040
+
9041
+ this.getBounds(min, max, true);
9042
+
9043
+ bbox.min.x = min.x;
9044
+ bbox.min.y = min.y;
9045
+ bbox.min.z = min.z;
9046
+
9047
+ bbox.max.x = max.x;
9048
+ bbox.max.y = max.y;
9049
+ bbox.max.z = max.z;
9050
+ }
9051
+
9052
+ if (true) // NOT WORKING bbox.intersect(ray, result))
9053
+ {
9054
+ success |= intersectMesh(ray, result);
9055
+ }
9056
+ else
9057
+ {
9058
+ //this.hide = true;
9059
+ touch = true;
9060
+ }
9061
+ }
9062
+
9063
+ for (int i=0; i<size(); i++)
9064
+ {
9065
+ Object3D child = (Object3D) reserve(i);
9066
+
9067
+ if (child == null)
9068
+ continue;
9069
+
9070
+ success |= child.intersect(ray, result);
9071
+ release(i);
9072
+ }
9073
+
9074
+ ray.eyePoint.x = eyex;
9075
+ ray.eyePoint.y = eyey;
9076
+ ray.eyePoint.z = eyez;
9077
+
9078
+ ray.viewDirection.x = dirx;
9079
+ ray.viewDirection.y = diry;
9080
+ ray.viewDirection.z = dirz;
9081
+
9082
+// if (touch)
9083
+// this.Touch(); // refresh display list
9084
+
9085
+ return success;
9086
+ }
9087
+
9088
+ static Vector3d edge1 = new Vector3d();
9089
+ static Vector3d edge2 = new Vector3d();
9090
+ static Vector3d P = new Vector3d();
9091
+ static Vector3d T = new Vector3d();
9092
+ static Vector3d Q = new Vector3d();
9093
+
9094
+ private boolean intersectTriangle(Ray ray, IntersectResult result, Vertex v1, Vertex v2, Vertex v3)
9095
+ {
9096
+ if (false)
9097
+ {
9098
+ result.t = 0;
9099
+ return true;
9100
+ }
9101
+
9102
+ /*
9103
+ Fast, Minimum Storage Ray/Triangle Intersection, Moller et al.
9104
+
9105
+ Reference: http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
9106
+ */
9107
+
9108
+ // Calculate edges of the triangle
9109
+ edge1.set(v2.x - v1.x, v2.y - v1.y, v2.z - v1.z);
9110
+ edge2.set(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z);
9111
+
9112
+ // Calculate the determinant (U parameter)
9113
+ P.cross(ray.viewDirection, edge2);
9114
+ double det = edge1.dot(P);
9115
+
9116
+ if (det > -1e-9 && det < 1e-9)
9117
+ {
9118
+ return false;
9119
+ } // Ray lies in plane of triangle
9120
+
9121
+ double invDet = 1 / det;
9122
+
9123
+ // Calculate distance from vertex1 to ray origin
9124
+ T.set(ray.eyePoint.x - v1.x, ray.eyePoint.y - v1.y, ray.eyePoint.z - v1.z);
9125
+
9126
+ double U = (T.dot(P)) * invDet; // Calculate U parameter
9127
+
9128
+ if (U < 0.f || U > 1.f)
9129
+ {
9130
+ return false;
9131
+ } // Intersection lies outside of the triangle
9132
+
9133
+ // Calculate V parameter
9134
+ Q.cross(T, edge1);
9135
+
9136
+ double V = ray.viewDirection.dot(Q) * invDet;
9137
+
9138
+ if (V < 0.f || (U + V) > 1.f)
9139
+ {
9140
+ return false;
9141
+ } // Intersection lies outside of the triangle
9142
+
9143
+ double t = edge2.dot(Q) * invDet;
9144
+
9145
+ if (t > 1e-9) // Triangle and ray intersects
9146
+ {
9147
+ //result.isIntersected = true;
9148
+ //result.id = id;
9149
+
9150
+ if (false) // isShadow)
9151
+ {
9152
+ result.t = t;
9153
+ return true;
9154
+ } else if (t < result.t)
9155
+ {
9156
+ result.object = this;
9157
+
9158
+ result.t = t;
9159
+
9160
+ //result.p.x = ray.eyePoint.x + ray.viewDirection.x * t;
9161
+ //result.p.y = ray.eyePoint.y + ray.viewDirection.y * t;
9162
+ //result.p.z = ray.eyePoint.z + ray.viewDirection.z * t;
9163
+
9164
+ result.n.cross(edge1, edge2);
9165
+ result.n.normalize();
9166
+ }
9167
+
9168
+ return true;
9169
+ }
9170
+
9171
+ return false;
9172
+ }
82549173
82559174 public int Size()
82569175 {
....@@ -8347,5 +9266,17 @@
83479266 return -1;
83489267 }
83499268 */
9269
+
9270
+ void Translate(double x, double y, double z)
9271
+ {
9272
+ if (toParent == null)
9273
+ {
9274
+ toParent = LA.newMatrix();
9275
+ fromParent = LA.newMatrix();
9276
+ }
9277
+
9278
+ LA.matTranslate(toParent, x, y, z);
9279
+ LA.matTranslateInv(fromParent, -x, -y, -z);
9280
+ }
83509281 }
83519282