.. | .. |
---|
22 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
23 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
24 | 24 | |
---|
| 25 | + // Use GetUUID for backward compatibility with null. |
---|
25 | 26 | private UUID uuid = UUID.randomUUID(); |
---|
26 | 27 | |
---|
27 | | - // TEMPORARY for mocap undo. No need to be transient. |
---|
| 28 | + // TEMPORARY for versions. No need to be transient. |
---|
28 | 29 | mocap.reader.BVHReader.BVHResult savebvh; |
---|
29 | 30 | Object3D saveskeleton; |
---|
| 31 | + |
---|
| 32 | + // FileObject |
---|
| 33 | + Object3D savefilecontent; |
---|
30 | 34 | // |
---|
31 | 35 | |
---|
32 | | - byte[] versions[] = new byte[100][]; |
---|
| 36 | + String skyboxname; |
---|
| 37 | + String skyboxext; |
---|
| 38 | + |
---|
| 39 | + Object3D[] versionlist; |
---|
33 | 40 | int versionindex = -1; |
---|
34 | 41 | |
---|
| 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 | + |
---|
35 | 46 | ScriptNode scriptnode; |
---|
36 | 47 | |
---|
| 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 | + |
---|
37 | 148 | void InitOthers() |
---|
38 | 149 | { |
---|
39 | 150 | if (projectedVertices == null || projectedVertices.length <= 2) |
---|
.. | .. |
---|
45 | 156 | projectedVertices[i] = new cVector2(); // Others |
---|
46 | 157 | } |
---|
47 | 158 | projectedVertices[0].x = 100; // bump |
---|
| 159 | + projectedVertices[1].y = 1000; // punchthrough. only for png |
---|
48 | 160 | } |
---|
49 | 161 | |
---|
50 | 162 | void MinMax(cVector minima, cVector maxima) |
---|
.. | .. |
---|
124 | 236 | return; |
---|
125 | 237 | |
---|
126 | 238 | transientsupport = support; |
---|
127 | | - transientlink2master = link2master; |
---|
| 239 | + transientlink2master = Link2Support(); |
---|
128 | 240 | |
---|
129 | 241 | support = null; |
---|
130 | 242 | link2master = false; |
---|
.. | .. |
---|
171 | 283 | } |
---|
172 | 284 | } |
---|
173 | 285 | |
---|
| 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 | + |
---|
174 | 314 | void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
175 | 315 | { |
---|
| 316 | + if (blockloop) |
---|
| 317 | + return; |
---|
| 318 | + |
---|
176 | 319 | Object3D o; |
---|
| 320 | + |
---|
| 321 | + boolean isnew = false; |
---|
177 | 322 | |
---|
178 | 323 | if (hashtable.containsKey(GetUUID())) |
---|
179 | 324 | { |
---|
.. | .. |
---|
187 | 332 | } |
---|
188 | 333 | else |
---|
189 | 334 | { |
---|
| 335 | + isnew = true; |
---|
| 336 | + |
---|
190 | 337 | o = new Object3D("copy of " + this.name); |
---|
191 | 338 | |
---|
192 | 339 | hashtable.put(GetUUID(), o); |
---|
193 | 340 | } |
---|
194 | 341 | |
---|
195 | | - if (!blockloop) |
---|
| 342 | + //if (!blockloop) |
---|
196 | 343 | { |
---|
197 | 344 | blockloop = true; |
---|
198 | 345 | |
---|
.. | .. |
---|
203 | 350 | |
---|
204 | 351 | blockloop = false; |
---|
205 | 352 | } |
---|
206 | | - |
---|
207 | | - ExtractBigData(o); |
---|
| 353 | + |
---|
| 354 | + //if (isnew) |
---|
| 355 | + ExtractBigData(o); |
---|
208 | 356 | } |
---|
209 | 357 | |
---|
210 | 358 | void ExtractBigData(Object3D o) |
---|
211 | 359 | { |
---|
| 360 | + //System.err.println("ExtractBigData : " + this + " --> " + o); |
---|
| 361 | + |
---|
212 | 362 | if (o.bRep != null) |
---|
213 | 363 | Grafreed.Assert(o.bRep == this.bRep); |
---|
214 | 364 | |
---|
.. | .. |
---|
219 | 369 | // o.bRep.support = null; |
---|
220 | 370 | // } |
---|
221 | 371 | o.selection = this.selection; |
---|
222 | | - o.versions = this.versions; |
---|
223 | | - o.versionindex = this.versionindex; |
---|
| 372 | + //o.versionlist = this.versionlist; |
---|
| 373 | + //o.versionindex = this.versionindex; |
---|
224 | 374 | |
---|
225 | 375 | if (this.support != null) |
---|
226 | 376 | { |
---|
.. | .. |
---|
243 | 393 | // this.fileparent = null; |
---|
244 | 394 | } |
---|
245 | 395 | |
---|
| 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 | + |
---|
246 | 463 | void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
247 | 464 | { |
---|
| 465 | + if (blockloop) |
---|
| 466 | + return; |
---|
| 467 | + |
---|
248 | 468 | if (!hashtable.containsKey(GetUUID())) |
---|
249 | 469 | return; |
---|
250 | 470 | |
---|
251 | 471 | Object3D o = hashtable.get(GetUUID()); |
---|
252 | 472 | |
---|
253 | 473 | RestoreBigData(o); |
---|
254 | | - |
---|
255 | | - if (blockloop) |
---|
256 | | - return; |
---|
257 | 474 | |
---|
258 | 475 | blockloop = true; |
---|
259 | 476 | |
---|
.. | .. |
---|
269 | 486 | |
---|
270 | 487 | void RestoreBigData(Object3D o) |
---|
271 | 488 | { |
---|
| 489 | + //System.err.println("RestoreBigData : " + this + " <-- " + o); |
---|
| 490 | + Grafreed.Assert(this.bRep == null); |
---|
| 491 | + |
---|
272 | 492 | this.bRep = o.bRep; |
---|
273 | 493 | if (this.support != null && o.transientrep != null) |
---|
274 | 494 | { |
---|
.. | .. |
---|
277 | 497 | |
---|
278 | 498 | this.selection = o.selection; |
---|
279 | 499 | |
---|
280 | | - this.versions = o.versions; |
---|
281 | | - this.versionindex = o.versionindex; |
---|
| 500 | + //this.versionlist = o.versionlist; |
---|
| 501 | + //this.versionindex = o.versionindex; |
---|
282 | 502 | // July 2019 if (this.bRep != null) |
---|
283 | 503 | // this.bRep.support = o.transientrep; |
---|
284 | 504 | // this.support = o.support; |
---|
.. | .. |
---|
426 | 646 | } |
---|
427 | 647 | |
---|
428 | 648 | boolean live = false; |
---|
| 649 | + transient boolean keepdontselect; |
---|
429 | 650 | boolean dontselect = false; |
---|
430 | 651 | 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 | + |
---|
432 | 656 | boolean marked = false; // animation node |
---|
433 | 657 | boolean skip = false; // centroid issue |
---|
434 | 658 | boolean skipmocap = false; // mocap data |
---|
.. | .. |
---|
436 | 660 | boolean random = false; |
---|
437 | 661 | boolean speedup = false; |
---|
438 | 662 | boolean rewind = false; |
---|
| 663 | + |
---|
| 664 | + // Option to sort triangles, e.g. for transparency. |
---|
| 665 | + boolean sort = false; |
---|
439 | 666 | |
---|
440 | 667 | float NORMALPUSH = 0; |
---|
441 | 668 | |
---|
.. | .. |
---|
446 | 673 | return this; |
---|
447 | 674 | } |
---|
448 | 675 | |
---|
| 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 | + |
---|
449 | 697 | void SortBySize() |
---|
450 | 698 | { |
---|
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(); |
---|
452 | 721 | |
---|
453 | | - while (!sorted) |
---|
| 722 | + if (sizecompare == null || sizecompare.length != count) |
---|
454 | 723 | { |
---|
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++) |
---|
458 | 727 | { |
---|
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)); |
---|
469 | 729 | } |
---|
| 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); |
---|
470 | 744 | } |
---|
471 | 745 | } |
---|
472 | 746 | |
---|
.. | .. |
---|
478 | 752 | { |
---|
479 | 753 | sorted = true; |
---|
480 | 754 | |
---|
481 | | - for (int i=0; i<size()-1; i++) |
---|
| 755 | + for (int i=0; i<Size()-1; i++) |
---|
482 | 756 | { |
---|
483 | 757 | Object3D obji = get(i); |
---|
484 | 758 | Object3D objj = get(i+1); |
---|
.. | .. |
---|
494 | 768 | } |
---|
495 | 769 | } |
---|
496 | 770 | |
---|
497 | | - int memorysize; |
---|
| 771 | + transient int memorysize; // needs to be transient, dunno why |
---|
498 | 772 | |
---|
499 | 773 | int MemorySize() |
---|
500 | 774 | { |
---|
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) |
---|
502 | 805 | { |
---|
503 | | - try |
---|
504 | | - { |
---|
505 | | - Object3D obj = this; |
---|
| 806 | + return 0; |
---|
| 807 | + } |
---|
506 | 808 | |
---|
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(); |
---|
526 | 814 | } |
---|
527 | 815 | |
---|
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; |
---|
529 | 828 | } |
---|
530 | 829 | |
---|
531 | 830 | void Slower() |
---|
.. | .. |
---|
613 | 912 | { |
---|
614 | 913 | if (maxcount != 1) |
---|
615 | 914 | { |
---|
616 | | - new Exception().printStackTrace(); |
---|
| 915 | + //new Exception().printStackTrace(); |
---|
617 | 916 | } |
---|
618 | 917 | |
---|
619 | 918 | toParentMarked = LA.newMatrix(); |
---|
.. | .. |
---|
815 | 1114 | |
---|
816 | 1115 | void Step() |
---|
817 | 1116 | { |
---|
818 | | - // marde pour serialization de Texture |
---|
| 1117 | + // patch pour serialization de Texture |
---|
819 | 1118 | resetmaxcount(); |
---|
820 | 1119 | resettransformcount(); |
---|
821 | 1120 | resetstep(); |
---|
.. | .. |
---|
850 | 1149 | transformcount++; |
---|
851 | 1150 | } |
---|
852 | 1151 | |
---|
853 | | - int maxcount; |
---|
| 1152 | + int maxcount = 128; |
---|
854 | 1153 | int transformcount; |
---|
855 | 1154 | int step; |
---|
856 | 1155 | |
---|
.. | .. |
---|
903 | 1202 | if (step == 0) |
---|
904 | 1203 | step = 1; |
---|
905 | 1204 | if (maxcount == 0) |
---|
906 | | - maxcount = 128; // 2048; // 4; |
---|
| 1205 | + { |
---|
| 1206 | + System.out.println("maxcount == 0"); |
---|
| 1207 | + System.exit(0); // maxcount = 128; // 2048; // 4; |
---|
| 1208 | + } |
---|
907 | 1209 | // if (acceleration == 0) |
---|
908 | 1210 | // acceleration = 10; |
---|
909 | 1211 | if (delay == 0) // serial |
---|
.. | .. |
---|
929 | 1231 | (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
930 | 1232 | currentframe != Globals.framecount) |
---|
931 | 1233 | { |
---|
| 1234 | + Globals.lighttouched = true; |
---|
| 1235 | + |
---|
932 | 1236 | currentframe = Globals.framecount; |
---|
933 | 1237 | |
---|
934 | 1238 | // System.err.println("transformcount = " + transformcount); |
---|
.. | .. |
---|
1008 | 1312 | { |
---|
1009 | 1313 | // return true; |
---|
1010 | 1314 | |
---|
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; |
---|
1013 | 1323 | |
---|
1014 | | - // Transparent objects are dynamic because we have to sort the triangles. |
---|
1015 | | - return material.opacity > 0.99; |
---|
| 1324 | + return !sort; |
---|
1016 | 1325 | } |
---|
1017 | 1326 | |
---|
1018 | 1327 | boolean IsOpaque() |
---|
1019 | 1328 | { |
---|
1020 | 1329 | // return true; |
---|
1021 | 1330 | |
---|
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; |
---|
1024 | 1335 | |
---|
1025 | | - return material.opacity > 0.99; |
---|
| 1336 | + return !sort; |
---|
1026 | 1337 | } |
---|
1027 | 1338 | |
---|
1028 | 1339 | Object3D() |
---|
.. | .. |
---|
1100 | 1411 | |
---|
1101 | 1412 | // will share the geometry |
---|
1102 | 1413 | 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; |
---|
1105 | 1418 | } |
---|
1106 | 1419 | |
---|
1107 | 1420 | boolean HasLoops() |
---|
.. | .. |
---|
1109 | 1422 | return false; |
---|
1110 | 1423 | } |
---|
1111 | 1424 | |
---|
| 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 | + |
---|
1112 | 1449 | boolean IsInfinite() |
---|
1113 | 1450 | { |
---|
1114 | 1451 | if (blockloop) |
---|
.. | .. |
---|
1179 | 1516 | return; |
---|
1180 | 1517 | |
---|
1181 | 1518 | blockloop = true; |
---|
| 1519 | + |
---|
| 1520 | + // other.parent = parent; |
---|
| 1521 | + |
---|
1182 | 1522 | //System.out.println("COPY " + this + " to " + other); |
---|
1183 | 1523 | //new Exception().printStackTrace(); |
---|
| 1524 | + deepCopyNode(other); |
---|
1184 | 1525 | |
---|
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... |
---|
1215 | 1526 | other.bRep = bRep; // Share the geometry |
---|
1216 | 1527 | |
---|
1217 | 1528 | 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; |
---|
1254 | 1529 | |
---|
1255 | 1530 | // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist) |
---|
1256 | 1531 | // { |
---|
.. | .. |
---|
1278 | 1553 | Object3D obj = (Object3D)Children().get(i); |
---|
1279 | 1554 | if (IsContainedIn(obj)) |
---|
1280 | 1555 | { |
---|
1281 | | -// assert(false); // ?!?!?!?!?! |
---|
| 1556 | + assert(false); // ?!?!?!?!?! |
---|
1282 | 1557 | c.Children().setElementAt(c, i); |
---|
1283 | 1558 | } |
---|
1284 | 1559 | else |
---|
.. | .. |
---|
1306 | 1581 | if ((mask & GEOMETRY) != 0) |
---|
1307 | 1582 | { |
---|
1308 | 1583 | 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) |
---|
1314 | 1584 | { |
---|
| 1585 | + bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); |
---|
1315 | 1586 | CameraPane.RemoveList(bRep.displaylist); |
---|
1316 | 1587 | bRep.displaylist = 0; // june 2013 -1; |
---|
1317 | 1588 | } |
---|
1318 | 1589 | 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; |
---|
1320 | 1602 | } |
---|
1321 | 1603 | |
---|
1322 | 1604 | /* Use a MASK = GEO/MAT |
---|
.. | .. |
---|
2292 | 2574 | |
---|
2293 | 2575 | InitOthers(); |
---|
2294 | 2576 | |
---|
2295 | | - if (this instanceof Camera) |
---|
2296 | | - { |
---|
2297 | | - material.shift = 90; |
---|
2298 | | - } |
---|
2299 | | - |
---|
2300 | 2577 | material.multiply = multiply; |
---|
2301 | 2578 | |
---|
2302 | 2579 | if (multiply) |
---|
.. | .. |
---|
2374 | 2651 | return b; |
---|
2375 | 2652 | } |
---|
2376 | 2653 | |
---|
2377 | | - void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate) |
---|
| 2654 | + void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate, boolean colorparallax) |
---|
2378 | 2655 | { |
---|
2379 | 2656 | if (blockloop) |
---|
2380 | 2657 | { |
---|
.. | .. |
---|
2384 | 2661 | // super.UpdateMaterial(anchor, current, false); |
---|
2385 | 2662 | if (material != null) |
---|
2386 | 2663 | { |
---|
2387 | | - material.UpdateMaterial(anchor, current); |
---|
| 2664 | + material.UpdateMaterial(anchor, current, colorparallax); |
---|
2388 | 2665 | } |
---|
2389 | 2666 | |
---|
2390 | 2667 | if (!propagate) |
---|
.. | .. |
---|
2398 | 2675 | if (child == null) |
---|
2399 | 2676 | continue; |
---|
2400 | 2677 | blockloop = true; |
---|
2401 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2678 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2402 | 2679 | blockloop = false; |
---|
2403 | 2680 | Children().release(i); |
---|
2404 | 2681 | } |
---|
.. | .. |
---|
2412 | 2689 | if (child == null) |
---|
2413 | 2690 | continue; |
---|
2414 | 2691 | blockloop = true; |
---|
2415 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2692 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2416 | 2693 | blockloop = false; |
---|
2417 | 2694 | Children().release(i); |
---|
2418 | 2695 | } |
---|
.. | .. |
---|
2437 | 2714 | else |
---|
2438 | 2715 | { |
---|
2439 | 2716 | //((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"); |
---|
2440 | 2722 | } |
---|
2441 | 2723 | } |
---|
2442 | 2724 | |
---|
.. | .. |
---|
2566 | 2848 | private static final int editSelf = 1; |
---|
2567 | 2849 | private static final int editChild = 2; |
---|
2568 | 2850 | |
---|
2569 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2851 | + void drawEditHandles(//ClickInfo info, |
---|
| 2852 | + int level) |
---|
2570 | 2853 | { |
---|
2571 | 2854 | if (level == 0) |
---|
2572 | 2855 | { |
---|
.. | .. |
---|
2574 | 2857 | return; |
---|
2575 | 2858 | |
---|
2576 | 2859 | 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)) |
---|
2578 | 2862 | { |
---|
2579 | 2863 | selectee = (Object3D) e.nextElement(); |
---|
2580 | 2864 | } |
---|
.. | .. |
---|
2582 | 2866 | } else |
---|
2583 | 2867 | { |
---|
2584 | 2868 | //super. |
---|
2585 | | - drawEditHandles0(info, level + 1); |
---|
| 2869 | + drawEditHandles0(//info, |
---|
| 2870 | + level + 1); |
---|
2586 | 2871 | } |
---|
2587 | 2872 | } |
---|
2588 | 2873 | |
---|
2589 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2874 | + boolean doEditClick(//ClickInfo info, |
---|
| 2875 | + int level) |
---|
2590 | 2876 | { |
---|
2591 | 2877 | doSomething = 0; |
---|
2592 | 2878 | if (level == 0) |
---|
2593 | 2879 | { |
---|
2594 | | - return doParentClick(info); |
---|
| 2880 | + return doParentClick(); //info); |
---|
2595 | 2881 | } |
---|
2596 | 2882 | if (//super. |
---|
2597 | | - doEditClick0(info, level)) |
---|
| 2883 | + doEditClick0(//info, |
---|
| 2884 | + level)) |
---|
2598 | 2885 | { |
---|
2599 | 2886 | doSomething = 1; |
---|
2600 | 2887 | return true; |
---|
.. | .. |
---|
2604 | 2891 | } |
---|
2605 | 2892 | } |
---|
2606 | 2893 | |
---|
2607 | | - boolean doParentClick(ClickInfo info) |
---|
| 2894 | + boolean doParentClick() //ClickInfo info) |
---|
2608 | 2895 | { |
---|
2609 | 2896 | if (selection == null) |
---|
2610 | 2897 | { |
---|
.. | .. |
---|
2617 | 2904 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2618 | 2905 | { |
---|
2619 | 2906 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2620 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2907 | + if (selectee.doEditClick(//info, |
---|
| 2908 | + 1)) |
---|
2621 | 2909 | { |
---|
2622 | 2910 | childToDrag = selectee; |
---|
2623 | 2911 | doSomething = 2; |
---|
.. | .. |
---|
2629 | 2917 | return retval; |
---|
2630 | 2918 | } |
---|
2631 | 2919 | |
---|
2632 | | - void doEditDrag(ClickInfo info, boolean opposite) |
---|
| 2920 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2921 | + boolean opposite) |
---|
2633 | 2922 | { |
---|
2634 | 2923 | switch (doSomething) |
---|
2635 | 2924 | { |
---|
2636 | 2925 | case 1: // '\001' |
---|
2637 | 2926 | //super. |
---|
2638 | | - doEditDrag0(info, opposite); |
---|
| 2927 | + doEditDrag0(//clickInfo, |
---|
| 2928 | + opposite); |
---|
2639 | 2929 | break; |
---|
2640 | 2930 | |
---|
2641 | 2931 | case 2: // '\002' |
---|
.. | .. |
---|
2648 | 2938 | { |
---|
2649 | 2939 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2650 | 2940 | //childToDrag.doEditDrag(info); |
---|
2651 | | - sel.doEditDrag(info, opposite); |
---|
| 2941 | + sel.doEditDrag(//clickInfo, |
---|
| 2942 | + opposite); |
---|
2652 | 2943 | } else |
---|
2653 | 2944 | { |
---|
2654 | 2945 | //super. |
---|
2655 | | - doEditDrag0(info, opposite); |
---|
| 2946 | + doEditDrag0(//clickInfo, |
---|
| 2947 | + opposite); |
---|
2656 | 2948 | } |
---|
2657 | 2949 | } |
---|
2658 | 2950 | break; |
---|
.. | .. |
---|
2670 | 2962 | { |
---|
2671 | 2963 | deselectAll(); |
---|
2672 | 2964 | } |
---|
| 2965 | + |
---|
| 2966 | + new Exception().printStackTrace(); |
---|
| 2967 | + |
---|
2673 | 2968 | ClickInfo newInfo = new ClickInfo(); |
---|
2674 | 2969 | newInfo.flags = info.flags; |
---|
2675 | 2970 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
3099 | 3394 | { |
---|
3100 | 3395 | if (bRep != null) |
---|
3101 | 3396 | { |
---|
| 3397 | + //bRep.GenerateNormals2(crease); // in-place doesn't work. it gives wrong normals (diamond artifact). |
---|
3102 | 3398 | bRep.GenerateNormals(crease); |
---|
| 3399 | + if (!bRep.trimmed) |
---|
| 3400 | + bRep.MergeNormals(); |
---|
3103 | 3401 | Touch(); |
---|
3104 | 3402 | } |
---|
3105 | 3403 | } |
---|
.. | .. |
---|
3174 | 3472 | blockloop = false; |
---|
3175 | 3473 | } |
---|
3176 | 3474 | |
---|
| 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 | + |
---|
3177 | 3574 | void TransformChildren() |
---|
3178 | 3575 | { |
---|
3179 | 3576 | if (toParent != null) |
---|
.. | .. |
---|
3416 | 3813 | if (bRep != null) |
---|
3417 | 3814 | { |
---|
3418 | 3815 | //bRep.RemoveOneTriangle(); |
---|
| 3816 | + System.out.println(); |
---|
3419 | 3817 | System.out.println("Reducing " + this); |
---|
3420 | 3818 | if (name != null && name.contains("lockpickstraps")) |
---|
3421 | 3819 | name = name; |
---|
.. | .. |
---|
3527 | 3925 | |
---|
3528 | 3926 | void ClearMaterials() |
---|
3529 | 3927 | { |
---|
| 3928 | + if (blockloop) |
---|
| 3929 | + return; |
---|
| 3930 | + |
---|
| 3931 | + blockloop = true; |
---|
| 3932 | + |
---|
3530 | 3933 | ClearMaterial(); |
---|
3531 | | - for (int i = 0; i < size(); i++) |
---|
| 3934 | + for (int i = 0; i < Size(); i++) |
---|
3532 | 3935 | { |
---|
3533 | | - Object3D child = (Object3D) reserve(i); |
---|
| 3936 | + Object3D child = (Object3D) get(i); |
---|
3534 | 3937 | if (child == null) |
---|
3535 | 3938 | continue; |
---|
3536 | 3939 | child.ClearMaterials(); |
---|
3537 | | - release(i); |
---|
3538 | 3940 | } |
---|
| 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; |
---|
3539 | 3969 | } |
---|
3540 | 3970 | |
---|
3541 | 3971 | void FlipV(boolean flip) |
---|
.. | .. |
---|
3714 | 4144 | |
---|
3715 | 4145 | void RevertMeshes() |
---|
3716 | 4146 | { |
---|
| 4147 | + // BLOCKLOOP |
---|
3717 | 4148 | if (this instanceof cMesh) |
---|
3718 | 4149 | { |
---|
3719 | 4150 | ((cMesh)this).Revert(); |
---|
.. | .. |
---|
3744 | 4175 | Touch(); |
---|
3745 | 4176 | } |
---|
3746 | 4177 | |
---|
3747 | | - ResetRecur(); |
---|
3748 | | - } |
---|
3749 | | - |
---|
3750 | | - void ResetRecur() |
---|
3751 | | - { |
---|
3752 | 4178 | for (int i = 0; i < size(); i++) |
---|
3753 | 4179 | { |
---|
3754 | 4180 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
3771 | 4197 | Step(); |
---|
3772 | 4198 | Touch(); |
---|
3773 | 4199 | |
---|
3774 | | - StepRecur(); |
---|
3775 | | - } |
---|
3776 | | - |
---|
3777 | | - void StepRecur() |
---|
3778 | | - { |
---|
3779 | 4200 | for (int i = 0; i < size(); i++) |
---|
3780 | 4201 | { |
---|
3781 | 4202 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
3962 | 4383 | Touch(); |
---|
3963 | 4384 | } |
---|
3964 | 4385 | |
---|
3965 | | - transient cVector min = new cVector(); |
---|
3966 | | - transient cVector max = new cVector(); |
---|
| 4386 | + transient cVector min; |
---|
| 4387 | + transient cVector max; |
---|
3967 | 4388 | |
---|
3968 | 4389 | void getBounds(cVector minima, cVector maxima, boolean xform) |
---|
3969 | 4390 | { |
---|
.. | .. |
---|
3979 | 4400 | if (blockloop) |
---|
3980 | 4401 | return; |
---|
3981 | 4402 | |
---|
3982 | | - if (min == null) // ??? |
---|
| 4403 | + if (min == null) |
---|
3983 | 4404 | { |
---|
3984 | 4405 | min = new cVector(); |
---|
3985 | 4406 | max = new cVector(); |
---|
3986 | 4407 | } |
---|
3987 | 4408 | |
---|
3988 | | - for (int i = 0; i<size(); i++) |
---|
| 4409 | + for (int i = 0; i<Size(); i++) |
---|
3989 | 4410 | { |
---|
3990 | | - Object3D child = (Object3D) reserve(i); |
---|
| 4411 | + Object3D child = (Object3D) get(i); //reserve(i); |
---|
3991 | 4412 | if (child == null) |
---|
3992 | 4413 | continue; |
---|
3993 | 4414 | |
---|
.. | .. |
---|
4006 | 4427 | if (child.hide && !(child instanceof Merge) || child.skip) |
---|
4007 | 4428 | //if (child.hide) |
---|
4008 | 4429 | { |
---|
4009 | | - release(i); |
---|
| 4430 | + //release(i); |
---|
4010 | 4431 | continue; |
---|
4011 | 4432 | } |
---|
4012 | 4433 | |
---|
4013 | 4434 | blockloop = true; |
---|
4014 | 4435 | child.getBounds(min, max, true); // xform); |
---|
4015 | 4436 | blockloop = false; |
---|
4016 | | - release(i); |
---|
| 4437 | + //release(i); |
---|
4017 | 4438 | |
---|
4018 | 4439 | MinMax(minima, maxima); |
---|
4019 | 4440 | } |
---|
4020 | 4441 | |
---|
4021 | 4442 | if (bRep != null) |
---|
4022 | 4443 | { |
---|
4023 | | - bRep.getBounds(minima,maxima,this); |
---|
| 4444 | + bRep.getBounds(minima, maxima, xform?this:null); |
---|
4024 | 4445 | } |
---|
4025 | 4446 | |
---|
4026 | 4447 | if (false) // xform) |
---|
.. | .. |
---|
5293 | 5714 | { |
---|
5294 | 5715 | } |
---|
5295 | 5716 | // 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 |
---|
5298 | 5720 | |
---|
5299 | 5721 | void Touch() |
---|
5300 | 5722 | { |
---|
.. | .. |
---|
5347 | 5769 | { |
---|
5348 | 5770 | //System.out.println("HardTouch " + this); // new Exception().printStackTrace(); |
---|
5349 | 5771 | //new Exception().printStackTrace(); |
---|
| 5772 | + reset = true; |
---|
5350 | 5773 | touched = true; |
---|
5351 | 5774 | CameraPane.touched = true; |
---|
5352 | 5775 | //if (parent != null) |
---|
.. | .. |
---|
5420 | 5843 | blockloop = false; |
---|
5421 | 5844 | } |
---|
5422 | 5845 | |
---|
| 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 | + |
---|
5423 | 5891 | boolean IsSelected() |
---|
5424 | 5892 | { |
---|
5425 | 5893 | if (parent == null) |
---|
.. | .. |
---|
5480 | 5948 | if (fullname == null) |
---|
5481 | 5949 | return ""; |
---|
5482 | 5950 | |
---|
| 5951 | + if (fullname.pigment != null) |
---|
| 5952 | + { |
---|
| 5953 | + return fullname.pigment; |
---|
| 5954 | + } |
---|
| 5955 | + |
---|
5483 | 5956 | // System.out.println("Fullname = " + fullname); |
---|
5484 | 5957 | |
---|
5485 | 5958 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5492 | 5965 | |
---|
5493 | 5966 | if (split.length == 0) |
---|
5494 | 5967 | { |
---|
5495 | | - return ""; |
---|
| 5968 | + return fullname.pigment = ""; |
---|
5496 | 5969 | } |
---|
5497 | 5970 | |
---|
5498 | 5971 | if (split.length <= 2) |
---|
.. | .. |
---|
5500 | 5973 | if (fullname.name.endsWith(":")) |
---|
5501 | 5974 | { |
---|
5502 | 5975 | // Windows |
---|
5503 | | - return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5976 | + return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1); |
---|
5504 | 5977 | } |
---|
5505 | 5978 | |
---|
5506 | | - return split[0]; |
---|
| 5979 | + return fullname.pigment = split[0]; |
---|
5507 | 5980 | } |
---|
5508 | 5981 | |
---|
5509 | 5982 | // Windows |
---|
5510 | 5983 | assert(split.length == 4); |
---|
5511 | 5984 | |
---|
5512 | | - return split[0] + ":" + split[1]; |
---|
| 5985 | + return fullname.pigment = split[0] + ":" + split[1]; |
---|
5513 | 5986 | } |
---|
5514 | 5987 | |
---|
5515 | 5988 | static String GetBump(cTexture fullname) |
---|
5516 | 5989 | { |
---|
5517 | 5990 | if (fullname == null) |
---|
5518 | 5991 | return ""; |
---|
| 5992 | + |
---|
| 5993 | + if (fullname.bump != null) |
---|
| 5994 | + { |
---|
| 5995 | + return fullname.bump; |
---|
| 5996 | + } |
---|
5519 | 5997 | |
---|
5520 | 5998 | // System.out.println("Fullname = " + fullname); |
---|
5521 | 5999 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5527 | 6005 | |
---|
5528 | 6006 | if (split.length == 0) |
---|
5529 | 6007 | { |
---|
5530 | | - return ""; |
---|
| 6008 | + return fullname.bump = ""; |
---|
5531 | 6009 | } |
---|
5532 | 6010 | |
---|
5533 | 6011 | if (split.length == 1) |
---|
5534 | 6012 | { |
---|
5535 | | - return ""; |
---|
| 6013 | + return fullname.bump = ""; |
---|
5536 | 6014 | } |
---|
5537 | 6015 | |
---|
5538 | 6016 | if (split.length == 2) |
---|
.. | .. |
---|
5540 | 6018 | if (fullname.name.endsWith(":")) |
---|
5541 | 6019 | { |
---|
5542 | 6020 | // Windows |
---|
5543 | | - return ""; |
---|
| 6021 | + return fullname.bump = ""; |
---|
5544 | 6022 | } |
---|
5545 | 6023 | |
---|
5546 | | - return split[1]; |
---|
| 6024 | + return fullname.bump = split[1]; |
---|
5547 | 6025 | } |
---|
5548 | 6026 | |
---|
5549 | 6027 | // Windows |
---|
5550 | 6028 | assert(split.length == 4); |
---|
5551 | 6029 | |
---|
5552 | | - return split[2] + ":" + split[3]; |
---|
| 6030 | + return fullname.bump = split[2] + ":" + split[3]; |
---|
5553 | 6031 | } |
---|
5554 | 6032 | |
---|
5555 | 6033 | String GetPigmentTexture() |
---|
.. | .. |
---|
5632 | 6110 | texname = ""; |
---|
5633 | 6111 | |
---|
5634 | 6112 | GetTextures().name = texname + ":" + GetBump(GetTextures()); |
---|
| 6113 | + |
---|
| 6114 | + GetTextures().pigment = null; |
---|
| 6115 | + |
---|
5635 | 6116 | Touch(); |
---|
5636 | 6117 | } |
---|
5637 | 6118 | |
---|
.. | .. |
---|
5705 | 6186 | |
---|
5706 | 6187 | GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname; |
---|
5707 | 6188 | |
---|
| 6189 | + GetTextures().bump = null; |
---|
| 6190 | + |
---|
5708 | 6191 | Touch(); |
---|
5709 | 6192 | } |
---|
5710 | 6193 | |
---|
.. | .. |
---|
5729 | 6212 | } |
---|
5730 | 6213 | } |
---|
5731 | 6214 | |
---|
| 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 | + |
---|
5732 | 6247 | void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5733 | 6248 | { |
---|
5734 | 6249 | Draw(display, root, selected, blocked); |
---|
.. | .. |
---|
5737 | 6252 | boolean NeedSupport() |
---|
5738 | 6253 | { |
---|
5739 | 6254 | 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 |
---|
5741 | 6256 | // PROBLEM with CROWD!! |
---|
5742 | 6257 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5743 | 6258 | } |
---|
.. | .. |
---|
5755 | 6270 | return parent.IsLive(); |
---|
5756 | 6271 | } |
---|
5757 | 6272 | |
---|
| 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 | + |
---|
5758 | 6289 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5759 | 6290 | { |
---|
5760 | 6291 | Invariants(); // june 2013 |
---|
.. | .. |
---|
5762 | 6293 | if (support != null) |
---|
5763 | 6294 | { |
---|
5764 | 6295 | // 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 | + } |
---|
5765 | 6319 | } |
---|
5766 | 6320 | |
---|
5767 | 6321 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
.. | .. |
---|
5815 | 6369 | if (support != null) |
---|
5816 | 6370 | support = support; |
---|
5817 | 6371 | |
---|
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. |
---|
5820 | 6378 | |
---|
5821 | 6379 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5822 | 6380 | { |
---|
.. | .. |
---|
5824 | 6382 | bRep.displaylist = 0; |
---|
5825 | 6383 | } |
---|
5826 | 6384 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5827 | | - // usecalllists = false; |
---|
| 6385 | + if (CameraPane.BOXMODE) // Too dynamic |
---|
| 6386 | + usecalllists = false; |
---|
5828 | 6387 | |
---|
5829 | | - if (GetBRep() != null) |
---|
5830 | | - usecalllists = usecalllists; |
---|
| 6388 | + if (display.DrawMode() == display.SHADOW) |
---|
| 6389 | + //GetBRep() != null) |
---|
| 6390 | + usecalllists = !!usecalllists; |
---|
5831 | 6391 | //System.out.println("draw " + this); |
---|
5832 | 6392 | //new Exception().printStackTrace(); |
---|
5833 | 6393 | |
---|
.. | .. |
---|
5837 | 6397 | |
---|
5838 | 6398 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5839 | 6399 | //(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))) |
---|
5841 | 6401 | { |
---|
5842 | 6402 | Globals.lighttouched = true; |
---|
5843 | 6403 | } // all panes... |
---|
.. | .. |
---|
5849 | 6409 | if (!(this instanceof Composite)) |
---|
5850 | 6410 | touched = false; |
---|
5851 | 6411 | //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 |
---|
5853 | 6413 | { |
---|
5854 | 6414 | bRep.displaylist = display.GenList(); |
---|
5855 | 6415 | assert(bRep.displaylist != 0); |
---|
.. | .. |
---|
5860 | 6420 | |
---|
5861 | 6421 | //System.out.println("\tnew list " + list); |
---|
5862 | 6422 | //gl.glDrawBuffer(gl.GL_NONE); |
---|
5863 | | - if (usecalllists) |
---|
| 6423 | + if (usecalllists && bRep.displaylist > 0) |
---|
5864 | 6424 | { |
---|
5865 | 6425 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5866 | 6426 | display.NewList(bRep.displaylist); |
---|
5867 | 6427 | } |
---|
5868 | 6428 | |
---|
| 6429 | + compiling = true; |
---|
5869 | 6430 | CallList(display, root, selected, blocked); |
---|
| 6431 | + compiling = false; |
---|
5870 | 6432 | |
---|
5871 | 6433 | // compiled = true; |
---|
5872 | | - if (usecalllists) |
---|
| 6434 | + if (usecalllists && bRep.displaylist > 0) |
---|
5873 | 6435 | { |
---|
5874 | 6436 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5875 | 6437 | display.EndList(); |
---|
.. | .. |
---|
5879 | 6441 | Globals.lighttouched = true; // all panes... |
---|
5880 | 6442 | } |
---|
5881 | 6443 | |
---|
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; |
---|
5884 | 6446 | |
---|
5885 | 6447 | if (this instanceof Texture || this instanceof TextureNode) |
---|
5886 | 6448 | { |
---|
.. | .. |
---|
5919 | 6481 | { |
---|
5920 | 6482 | if (display.DrawMode() == iCameraPane.SHADOW) |
---|
5921 | 6483 | { |
---|
5922 | | - if (!link2master // tricky to cull in shadow mode. |
---|
| 6484 | + if (!Link2Support() // tricky to cull in shadow mode. |
---|
5923 | 6485 | && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
5924 | 6486 | { |
---|
5925 | 6487 | //System.out.print("CULLED"); |
---|
.. | .. |
---|
5981 | 6543 | { |
---|
5982 | 6544 | drawSelf(display, root, selected, blocked); |
---|
5983 | 6545 | } |
---|
| 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 | +// } |
---|
5984 | 6560 | } else |
---|
5985 | 6561 | { |
---|
5986 | 6562 | /* |
---|
.. | .. |
---|
6013 | 6589 | boolean failedPigment = false; |
---|
6014 | 6590 | boolean failedBump = false; |
---|
6015 | 6591 | |
---|
| 6592 | + CameraPane.lastObject = this; |
---|
6016 | 6593 | try |
---|
6017 | 6594 | { |
---|
6018 | 6595 | display.BindPigmentTexture(tex, texres); |
---|
6019 | 6596 | } |
---|
6020 | 6597 | catch (Exception e) |
---|
6021 | 6598 | { |
---|
6022 | | - System.err.println("FAILED: " + this); |
---|
| 6599 | + // System.err.println("FAILED: " + this); |
---|
6023 | 6600 | failedPigment = true; |
---|
6024 | 6601 | } |
---|
6025 | 6602 | |
---|
.. | .. |
---|
6050 | 6627 | display.CallList(bRep.displaylist); |
---|
6051 | 6628 | // june 2013 drawSelf(display, root, selected); |
---|
6052 | 6629 | } |
---|
| 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 | +// } |
---|
6053 | 6644 | } |
---|
6054 | 6645 | } |
---|
6055 | 6646 | |
---|
.. | .. |
---|
6103 | 6694 | |
---|
6104 | 6695 | void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
6105 | 6696 | { |
---|
6106 | | - if (GetBRep() == null) |
---|
6107 | | - { |
---|
6108 | | - drawSelf(display, root, selected, blocked); |
---|
6109 | | - } else |
---|
| 6697 | + if (GetBRep() != null) |
---|
6110 | 6698 | { |
---|
6111 | 6699 | DrawNode(display, root, selected); |
---|
6112 | 6700 | if (this instanceof BezierPatch) |
---|
6113 | 6701 | { |
---|
6114 | 6702 | //drawSelf(display, root, selected); |
---|
6115 | 6703 | } |
---|
| 6704 | + } |
---|
| 6705 | + else |
---|
| 6706 | + { |
---|
| 6707 | + drawSelf(display, root, selected, blocked); |
---|
6116 | 6708 | } |
---|
6117 | 6709 | } |
---|
6118 | 6710 | |
---|
.. | .. |
---|
6311 | 6903 | |
---|
6312 | 6904 | void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
6313 | 6905 | { |
---|
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 | + } |
---|
6319 | 6914 | |
---|
6320 | 6915 | if (hide) |
---|
6321 | 6916 | return; |
---|
6322 | | - |
---|
| 6917 | + |
---|
6323 | 6918 | if (scriptnode != null) |
---|
6324 | 6919 | { |
---|
6325 | 6920 | scriptnode.DrawNode(display, root, selected); |
---|
.. | .. |
---|
6362 | 6957 | |
---|
6363 | 6958 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
6364 | 6959 | |
---|
6365 | | - if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
| 6960 | + if (CameraPane.BOXMODE && !Link2Support()) // |
---|
| 6961 | + //!selected) // || CameraPane.movingcamera) |
---|
6366 | 6962 | { |
---|
6367 | 6963 | int fc = bRep.FaceCount(); |
---|
6368 | 6964 | int vc = bRep.VertexCount(); |
---|
.. | .. |
---|
6524 | 7120 | facescompare[k] = new FaceCompare(k); |
---|
6525 | 7121 | } |
---|
6526 | 7122 | |
---|
6527 | | - center = new cVector(); |
---|
| 7123 | + centertriangle = new cVector(); |
---|
6528 | 7124 | } |
---|
6529 | 7125 | else |
---|
6530 | 7126 | { |
---|
.. | .. |
---|
6647 | 7243 | */ |
---|
6648 | 7244 | } |
---|
6649 | 7245 | |
---|
6650 | | - transient cVector center; |
---|
| 7246 | + transient cVector centertriangle; |
---|
6651 | 7247 | |
---|
6652 | 7248 | class FaceCompare implements Comparable |
---|
6653 | 7249 | { |
---|
.. | .. |
---|
6676 | 7272 | Vertex q = bRep.GetVertex(face.q); |
---|
6677 | 7273 | Vertex r = bRep.GetVertex(face.r); |
---|
6678 | 7274 | |
---|
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); |
---|
6683 | 7279 | |
---|
6684 | | - center.sub(Globals.theRenderer.EyeCamera().location); |
---|
| 7280 | + centertriangle.sub(Globals.theRenderer.EyeCamera().location); |
---|
6685 | 7281 | |
---|
6686 | | - distance = center.dot(center); |
---|
| 7282 | + distance = centertriangle.dot(centertriangle); |
---|
6687 | 7283 | } |
---|
6688 | 7284 | |
---|
6689 | 7285 | return distance; |
---|
.. | .. |
---|
7220 | 7816 | } |
---|
7221 | 7817 | } |
---|
7222 | 7818 | |
---|
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) |
---|
7224 | 7823 | { |
---|
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; |
---|
7228 | 7827 | if (toscreen == null) |
---|
7229 | 7828 | { |
---|
7230 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7829 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
7231 | 7830 | } |
---|
7232 | 7831 | cVector vec = in; |
---|
7233 | 7832 | LA.xformPos(in, toscreen, in); |
---|
7234 | 7833 | //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(); |
---|
7237 | 7836 | outPt.x = hc + (int) vec.x; |
---|
7238 | 7837 | outPt.y = vc - (int) vec.y; |
---|
7239 | 7838 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
7241 | 7840 | outRec.width = outRec.height = 6; |
---|
7242 | 7841 | } |
---|
7243 | 7842 | |
---|
7244 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7843 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7844 | + ) |
---|
7245 | 7845 | { |
---|
7246 | 7846 | Point pt = new Point(0, 0); |
---|
7247 | 7847 | Rectangle rec = new Rectangle(); |
---|
7248 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7848 | + calcHotSpot(in, //clickInfo, |
---|
| 7849 | + pt, rec); |
---|
7249 | 7850 | return rec; |
---|
7250 | 7851 | } |
---|
7251 | 7852 | |
---|
7252 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7853 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7854 | + int level) |
---|
7253 | 7855 | { |
---|
7254 | 7856 | if (level == 0) |
---|
7255 | 7857 | { |
---|
.. | .. |
---|
7258 | 7860 | { |
---|
7259 | 7861 | cVector origin = new cVector(); |
---|
7260 | 7862 | //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); |
---|
7262 | 7867 | Rectangle boundary = new Rectangle(); |
---|
7263 | 7868 | boundary.x = spot.x - 30; |
---|
7264 | 7869 | boundary.y = spot.y - 30; |
---|
7265 | 7870 | boundary.width = spot.width + 60; |
---|
7266 | 7871 | boundary.height = spot.height + 60; |
---|
7267 | | - info.g.setColor(Color.red); |
---|
| 7872 | + clickInfo.g.setColor(Color.white); |
---|
7268 | 7873 | int spotw = spot.x + spot.width; |
---|
7269 | 7874 | 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); |
---|
7271 | 7876 | // if (CameraPane.Xmin > spot.x) |
---|
7272 | 7877 | // { |
---|
7273 | 7878 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7284 | 7889 | // { |
---|
7285 | 7890 | // CameraPane.Ymax = spoth; |
---|
7286 | 7891 | // } |
---|
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); |
---|
7292 | 7892 | // if (CameraPane.Xmin > spot.x) |
---|
7293 | 7893 | // { |
---|
7294 | 7894 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7307 | 7907 | // } |
---|
7308 | 7908 | // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
7309 | 7909 | //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); |
---|
7314 | 7919 | // if (CameraPane.Xmin > spot.x) |
---|
7315 | 7920 | // { |
---|
7316 | 7921 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7327 | 7932 | // { |
---|
7328 | 7933 | // CameraPane.Ymax = spoth; |
---|
7329 | 7934 | // } |
---|
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); |
---|
7332 | 7938 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7333 | 7939 | // if (CameraPane.Xmin > boundary.x) |
---|
7334 | 7940 | // { |
---|
.. | .. |
---|
7350 | 7956 | } |
---|
7351 | 7957 | } |
---|
7352 | 7958 | |
---|
7353 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7959 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7960 | + int level) |
---|
7354 | 7961 | { |
---|
7355 | 7962 | if (level == 0) |
---|
7356 | 7963 | { |
---|
.. | .. |
---|
7359 | 7966 | |
---|
7360 | 7967 | boolean retval = false; |
---|
7361 | 7968 | |
---|
7362 | | - startX = info.x; |
---|
7363 | | - startY = info.y; |
---|
| 7969 | + startX = clickInfo.x; |
---|
| 7970 | + startY = clickInfo.y; |
---|
7364 | 7971 | |
---|
7365 | 7972 | hitSomething = -1; |
---|
7366 | 7973 | cVector origin = new cVector(); |
---|
.. | .. |
---|
7370 | 7977 | { |
---|
7371 | 7978 | centerPt = new Point(0, 0); |
---|
7372 | 7979 | } |
---|
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)) |
---|
7375 | 7983 | { |
---|
7376 | 7984 | hitSomething = hitCenter; |
---|
7377 | 7985 | retval = true; |
---|
7378 | 7986 | } |
---|
7379 | 7987 | spot.translate(32, 0); |
---|
7380 | | - if (spot.contains(info.x, info.y)) |
---|
| 7988 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7381 | 7989 | { |
---|
7382 | 7990 | hitSomething = hitRotate; |
---|
7383 | 7991 | retval = true; |
---|
7384 | 7992 | } |
---|
7385 | 7993 | 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)) |
---|
7387 | 7997 | { |
---|
7388 | 7998 | 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 | + |
---|
7389 | 8027 | retval = true; |
---|
7390 | 8028 | } |
---|
7391 | 8029 | |
---|
.. | .. |
---|
7395 | 8033 | } |
---|
7396 | 8034 | |
---|
7397 | 8035 | //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 |
---|
7399 | 8037 | //System.out.println("modified = " + modified); |
---|
7400 | 8038 | //new Exception().printStackTrace(); |
---|
7401 | 8039 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7423 | 8061 | return true; |
---|
7424 | 8062 | } |
---|
7425 | 8063 | |
---|
7426 | | - void doEditDrag0(ClickInfo info, boolean opposite) |
---|
| 8064 | + void doEditDrag0(//ClickInfo info, |
---|
| 8065 | + boolean opposite) |
---|
7427 | 8066 | { |
---|
7428 | 8067 | if (hitSomething == 0) |
---|
7429 | 8068 | { |
---|
.. | .. |
---|
7437 | 8076 | |
---|
7438 | 8077 | //System.out.println("hitSomething = " + hitSomething); |
---|
7439 | 8078 | |
---|
7440 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 8079 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
7441 | 8080 | |
---|
7442 | 8081 | cVector xlate = new cVector(); |
---|
7443 | 8082 | //cVector xlate2 = new cVector(); |
---|
.. | .. |
---|
7451 | 8090 | |
---|
7452 | 8091 | scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7453 | 8092 | |
---|
7454 | | - if (modified || opposite) |
---|
| 8093 | + // Modified could snap |
---|
| 8094 | + if (//modified || |
---|
| 8095 | + opposite) |
---|
7455 | 8096 | { |
---|
7456 | 8097 | //assert(false); |
---|
7457 | 8098 | /* |
---|
.. | .. |
---|
7471 | 8112 | toParent[3][i] = xlate.get(i); |
---|
7472 | 8113 | LA.matInvert(toParent, fromParent); |
---|
7473 | 8114 | */ |
---|
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); |
---|
7476 | 8117 | |
---|
7477 | 8118 | LA.matCopy(startMat, toParent); |
---|
7478 | 8119 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7481 | 8122 | } else |
---|
7482 | 8123 | { |
---|
7483 | 8124 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7484 | | - cVector up = new cVector(info.camera.up); |
---|
| 8125 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7485 | 8126 | cVector away = new cVector(); |
---|
7486 | 8127 | //cVector right2 = new cVector(); |
---|
7487 | 8128 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7498 | 8139 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7499 | 8140 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7500 | 8141 | 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); |
---|
7502 | 8143 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7503 | 8144 | LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7504 | 8145 | //LA.vecCross(up, cVector.Z, right2); |
---|
7505 | 8146 | |
---|
7506 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 8147 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7507 | 8148 | |
---|
7508 | 8149 | //System.out.println("DELTA0 = " + delta); |
---|
7509 | 8150 | //System.out.println("AWAY = " + info.camera.away); |
---|
7510 | 8151 | //System.out.println("UP = " + info.camera.up); |
---|
7511 | 8152 | if (away.z > 0) |
---|
7512 | 8153 | { |
---|
7513 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 8154 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7514 | 8155 | { |
---|
7515 | 8156 | delta.x = -delta.x; |
---|
7516 | 8157 | } else |
---|
.. | .. |
---|
7525 | 8166 | //System.out.println("DELTA1 = " + delta); |
---|
7526 | 8167 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7527 | 8168 | //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); |
---|
7529 | 8170 | LA.matCopy(startMat, toParent); |
---|
7530 | 8171 | //System.out.println("DELTA3 = " + delta); |
---|
7531 | 8172 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7535 | 8176 | break; |
---|
7536 | 8177 | |
---|
7537 | 8178 | 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); |
---|
7540 | 8181 | double angle = (double) Math.atan2(dx, dy); |
---|
7541 | 8182 | angle = -(1.570796 - angle); |
---|
7542 | 8183 | |
---|
.. | .. |
---|
7545 | 8186 | |
---|
7546 | 8187 | if (modified) |
---|
7547 | 8188 | { |
---|
7548 | | - // Rotate 90 degrees |
---|
| 8189 | + // Rotate 45 degrees |
---|
7549 | 8190 | angle /= (Math.PI / 4); |
---|
7550 | 8191 | angle = Math.floor(angle + 0.5); |
---|
7551 | 8192 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7559 | 8200 | } |
---|
7560 | 8201 | /**/ |
---|
7561 | 8202 | |
---|
7562 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 8203 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7563 | 8204 | { |
---|
7564 | 8205 | case 1: // '\001' |
---|
7565 | 8206 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7586 | 8227 | break; |
---|
7587 | 8228 | |
---|
7588 | 8229 | case hitScale: // scale |
---|
7589 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 8230 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
7590 | 8231 | double sign = 1; |
---|
7591 | 8232 | if (hScale < 0) |
---|
7592 | 8233 | { |
---|
.. | .. |
---|
7598 | 8239 | //hScale = 0.01; |
---|
7599 | 8240 | } |
---|
7600 | 8241 | |
---|
7601 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 8242 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
7602 | 8243 | sign = 1; |
---|
7603 | 8244 | if (vScale < 0) |
---|
7604 | 8245 | { |
---|
.. | .. |
---|
7609 | 8250 | { |
---|
7610 | 8251 | //vScale = 0.01; |
---|
7611 | 8252 | } |
---|
| 8253 | + |
---|
7612 | 8254 | LA.matCopy(startMat, toParent); |
---|
7613 | 8255 | /**/ |
---|
7614 | 8256 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7618 | 8260 | } |
---|
7619 | 8261 | /**/ |
---|
7620 | 8262 | |
---|
7621 | | - double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 8263 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
7622 | 8264 | |
---|
7623 | 8265 | if (totalScale < 0.01) |
---|
7624 | 8266 | { |
---|
7625 | 8267 | totalScale = 0.01; |
---|
7626 | 8268 | } |
---|
7627 | 8269 | |
---|
7628 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 8270 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7629 | 8271 | { |
---|
7630 | 8272 | case 3: // '\001' |
---|
7631 | 8273 | if (modified || opposite) |
---|
7632 | 8274 | { |
---|
| 8275 | + if (modified) // && opposite) |
---|
| 8276 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8277 | + else |
---|
7633 | 8278 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7634 | | - LA.matScale(toParent, totalScale, 1, 1); |
---|
| 8279 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7635 | 8280 | } // vScale, 1); |
---|
7636 | 8281 | else |
---|
7637 | 8282 | { |
---|
7638 | 8283 | // EXCEPTION! |
---|
7639 | | - LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8284 | + LA.matScale(toParent, 1, totalScale, totalScale); |
---|
7640 | 8285 | } // vScale, 1); |
---|
7641 | 8286 | break; |
---|
7642 | 8287 | |
---|
7643 | 8288 | case 2: // '\002' |
---|
7644 | 8289 | if (modified || opposite) |
---|
7645 | 8290 | { |
---|
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); |
---|
7648 | 8296 | } else |
---|
7649 | 8297 | { |
---|
7650 | 8298 | LA.matScale(toParent, totalScale, 1, totalScale); |
---|
.. | .. |
---|
7654 | 8302 | case 1: // '\003' |
---|
7655 | 8303 | if (modified || opposite) |
---|
7656 | 8304 | { |
---|
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); |
---|
7659 | 8310 | } else |
---|
7660 | 8311 | { |
---|
7661 | 8312 | LA.matScale(toParent, totalScale, totalScale, 1); |
---|
.. | .. |
---|
7692 | 8343 | } // NEW ... |
---|
7693 | 8344 | |
---|
7694 | 8345 | |
---|
7695 | | - info.pane.repaint(); |
---|
| 8346 | + clickInfo.pane.repaint(); |
---|
7696 | 8347 | } |
---|
7697 | 8348 | |
---|
7698 | 8349 | boolean overflow = false; |
---|
.. | .. |
---|
7799 | 8450 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7800 | 8451 | } else |
---|
7801 | 8452 | { |
---|
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) ":"") */ ""; |
---|
7803 | 8454 | } // + super.toString(); |
---|
7804 | 8455 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7805 | 8456 | |
---|
7806 | 8457 | if (!Globals.ADVANCED) |
---|
7807 | 8458 | return objname; |
---|
7808 | 8459 | |
---|
7809 | | - return objname + " " + System.identityHashCode(this); |
---|
| 8460 | + return objname + " " + System.identityHashCode(this) + " " + GetUUID(); |
---|
7810 | 8461 | } |
---|
7811 | 8462 | |
---|
7812 | 8463 | public int hashCode() |
---|
7813 | 8464 | { |
---|
7814 | | - // Fuck Vector... |
---|
| 8465 | + // Do not use Vector... |
---|
7815 | 8466 | return System.identityHashCode(this); |
---|
7816 | 8467 | } |
---|
7817 | 8468 | |
---|
.. | .. |
---|
8051 | 8702 | private static cVector2 qq2 = new cVector2(); |
---|
8052 | 8703 | private static cVector2 rr2 = new cVector2(); |
---|
8053 | 8704 | 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(); |
---|
8056 | 8707 | //private static cVector norm = new cVector(); |
---|
8057 | 8708 | /*transient private*/ int hitSomething; |
---|
8058 | 8709 | static final int hitCenter = 1; |
---|
.. | .. |
---|
8250 | 8901 | |
---|
8251 | 8902 | Touch(); |
---|
8252 | 8903 | } |
---|
| 8904 | + |
---|
| 8905 | + static Vertex s1 = new Vertex(); |
---|
| 8906 | + static Vertex s2 = new Vertex(); |
---|
| 8907 | + static Vertex s3 = new Vertex(); |
---|
8253 | 8908 | |
---|
| 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 | + } |
---|
8254 | 9173 | |
---|
8255 | 9174 | public int Size() |
---|
8256 | 9175 | { |
---|
.. | .. |
---|
8347 | 9266 | return -1; |
---|
8348 | 9267 | } |
---|
8349 | 9268 | */ |
---|
| 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 | + } |
---|
8350 | 9281 | } |
---|
8351 | 9282 | |
---|