.. | .. |
---|
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 | 36 | String skyboxname; |
---|
33 | 37 | String skyboxext; |
---|
34 | 38 | |
---|
35 | | - byte[] versions[]; |
---|
| 39 | + Object3D[] versionlist; |
---|
36 | 40 | int versionindex = -1; |
---|
37 | 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 | + |
---|
38 | 46 | ScriptNode scriptnode; |
---|
39 | 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 | + |
---|
40 | 148 | void InitOthers() |
---|
41 | 149 | { |
---|
42 | 150 | if (projectedVertices == null || projectedVertices.length <= 2) |
---|
.. | .. |
---|
48 | 156 | projectedVertices[i] = new cVector2(); // Others |
---|
49 | 157 | } |
---|
50 | 158 | projectedVertices[0].x = 100; // bump |
---|
| 159 | + projectedVertices[1].y = 1000; // punchthrough. only for png |
---|
51 | 160 | } |
---|
52 | 161 | |
---|
53 | 162 | void MinMax(cVector minima, cVector maxima) |
---|
.. | .. |
---|
127 | 236 | return; |
---|
128 | 237 | |
---|
129 | 238 | transientsupport = support; |
---|
130 | | - transientlink2master = link2master; |
---|
| 239 | + transientlink2master = Link2Support(); |
---|
131 | 240 | |
---|
132 | 241 | support = null; |
---|
133 | 242 | link2master = false; |
---|
.. | .. |
---|
174 | 283 | } |
---|
175 | 284 | } |
---|
176 | 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 | + |
---|
177 | 314 | void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
178 | 315 | { |
---|
| 316 | + if (blockloop) |
---|
| 317 | + return; |
---|
| 318 | + |
---|
179 | 319 | Object3D o; |
---|
| 320 | + |
---|
| 321 | + boolean isnew = false; |
---|
180 | 322 | |
---|
181 | 323 | if (hashtable.containsKey(GetUUID())) |
---|
182 | 324 | { |
---|
.. | .. |
---|
190 | 332 | } |
---|
191 | 333 | else |
---|
192 | 334 | { |
---|
| 335 | + isnew = true; |
---|
| 336 | + |
---|
193 | 337 | o = new Object3D("copy of " + this.name); |
---|
194 | 338 | |
---|
195 | 339 | hashtable.put(GetUUID(), o); |
---|
196 | 340 | } |
---|
197 | 341 | |
---|
198 | | - if (!blockloop) |
---|
| 342 | + //if (!blockloop) |
---|
199 | 343 | { |
---|
200 | 344 | blockloop = true; |
---|
201 | 345 | |
---|
.. | .. |
---|
206 | 350 | |
---|
207 | 351 | blockloop = false; |
---|
208 | 352 | } |
---|
209 | | - |
---|
210 | | - ExtractBigData(o); |
---|
| 353 | + |
---|
| 354 | + //if (isnew) |
---|
| 355 | + ExtractBigData(o); |
---|
211 | 356 | } |
---|
212 | 357 | |
---|
213 | 358 | void ExtractBigData(Object3D o) |
---|
214 | 359 | { |
---|
| 360 | + //System.err.println("ExtractBigData : " + this + " --> " + o); |
---|
| 361 | + |
---|
215 | 362 | if (o.bRep != null) |
---|
216 | 363 | Grafreed.Assert(o.bRep == this.bRep); |
---|
217 | 364 | |
---|
.. | .. |
---|
222 | 369 | // o.bRep.support = null; |
---|
223 | 370 | // } |
---|
224 | 371 | o.selection = this.selection; |
---|
225 | | - o.versions = this.versions; |
---|
226 | | - o.versionindex = this.versionindex; |
---|
| 372 | + //o.versionlist = this.versionlist; |
---|
| 373 | + //o.versionindex = this.versionindex; |
---|
227 | 374 | |
---|
228 | 375 | if (this.support != null) |
---|
229 | 376 | { |
---|
.. | .. |
---|
246 | 393 | // this.fileparent = null; |
---|
247 | 394 | } |
---|
248 | 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 | + |
---|
249 | 463 | void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
250 | 464 | { |
---|
| 465 | + if (blockloop) |
---|
| 466 | + return; |
---|
| 467 | + |
---|
251 | 468 | if (!hashtable.containsKey(GetUUID())) |
---|
252 | 469 | return; |
---|
253 | 470 | |
---|
254 | 471 | Object3D o = hashtable.get(GetUUID()); |
---|
255 | 472 | |
---|
256 | 473 | RestoreBigData(o); |
---|
257 | | - |
---|
258 | | - if (blockloop) |
---|
259 | | - return; |
---|
260 | 474 | |
---|
261 | 475 | blockloop = true; |
---|
262 | 476 | |
---|
.. | .. |
---|
272 | 486 | |
---|
273 | 487 | void RestoreBigData(Object3D o) |
---|
274 | 488 | { |
---|
| 489 | + //System.err.println("RestoreBigData : " + this + " <-- " + o); |
---|
| 490 | + Grafreed.Assert(this.bRep == null); |
---|
| 491 | + |
---|
275 | 492 | this.bRep = o.bRep; |
---|
276 | 493 | if (this.support != null && o.transientrep != null) |
---|
277 | 494 | { |
---|
.. | .. |
---|
280 | 497 | |
---|
281 | 498 | this.selection = o.selection; |
---|
282 | 499 | |
---|
283 | | - this.versions = o.versions; |
---|
284 | | - this.versionindex = o.versionindex; |
---|
| 500 | + //this.versionlist = o.versionlist; |
---|
| 501 | + //this.versionindex = o.versionindex; |
---|
285 | 502 | // July 2019 if (this.bRep != null) |
---|
286 | 503 | // this.bRep.support = o.transientrep; |
---|
287 | 504 | // this.support = o.support; |
---|
.. | .. |
---|
432 | 649 | transient boolean keepdontselect; |
---|
433 | 650 | boolean dontselect = false; |
---|
434 | 651 | boolean hide = false; |
---|
435 | | - 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 | + |
---|
436 | 656 | boolean marked = false; // animation node |
---|
437 | 657 | boolean skip = false; // centroid issue |
---|
438 | 658 | boolean skipmocap = false; // mocap data |
---|
.. | .. |
---|
440 | 660 | boolean random = false; |
---|
441 | 661 | boolean speedup = false; |
---|
442 | 662 | boolean rewind = false; |
---|
| 663 | + |
---|
| 664 | + // Option to sort triangles, e.g. for transparency. |
---|
| 665 | + boolean sort = false; |
---|
443 | 666 | |
---|
444 | 667 | float NORMALPUSH = 0; |
---|
445 | 668 | |
---|
.. | .. |
---|
450 | 673 | return this; |
---|
451 | 674 | } |
---|
452 | 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 | + |
---|
453 | 697 | void SortBySize() |
---|
454 | 698 | { |
---|
455 | | - 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(); |
---|
456 | 721 | |
---|
457 | | - while (!sorted) |
---|
| 722 | + if (sizecompare == null || sizecompare.length != count) |
---|
458 | 723 | { |
---|
459 | | - sorted = true; |
---|
460 | | - |
---|
461 | | - for (int i=0; i<size()-1; i++) |
---|
| 724 | + sizecompare = new SizeCompare[count]; |
---|
| 725 | + |
---|
| 726 | + for (int k=0; k<count; k++) |
---|
462 | 727 | { |
---|
463 | | - Object3D obji = get(i); |
---|
464 | | - Object3D objj = get(i+1); |
---|
465 | | - |
---|
466 | | - if (obji.MemorySize() < objj.MemorySize()) |
---|
467 | | - { |
---|
468 | | - set(i, objj); |
---|
469 | | - set(i+1, obji); |
---|
470 | | - |
---|
471 | | - sorted = false; |
---|
472 | | - } |
---|
| 728 | + sizecompare[k] = new SizeCompare(get(k)); |
---|
473 | 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); |
---|
474 | 744 | } |
---|
475 | 745 | } |
---|
476 | 746 | |
---|
.. | .. |
---|
482 | 752 | { |
---|
483 | 753 | sorted = true; |
---|
484 | 754 | |
---|
485 | | - for (int i=0; i<size()-1; i++) |
---|
| 755 | + for (int i=0; i<Size()-1; i++) |
---|
486 | 756 | { |
---|
487 | 757 | Object3D obji = get(i); |
---|
488 | 758 | Object3D objj = get(i+1); |
---|
.. | .. |
---|
498 | 768 | } |
---|
499 | 769 | } |
---|
500 | 770 | |
---|
501 | | - int memorysize; |
---|
| 771 | + transient int memorysize; // needs to be transient, dunno why |
---|
502 | 772 | |
---|
503 | 773 | int MemorySize() |
---|
504 | 774 | { |
---|
505 | | - 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) |
---|
506 | 805 | { |
---|
507 | | - try |
---|
508 | | - { |
---|
509 | | - Object3D obj = this; |
---|
| 806 | + return 0; |
---|
| 807 | + } |
---|
510 | 808 | |
---|
511 | | - Object3D parent = obj.parent; |
---|
512 | | - obj.parent = null; |
---|
513 | | - Object3D support = obj.support; |
---|
514 | | - obj.support = null; |
---|
515 | | - |
---|
516 | | - java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); |
---|
517 | | - java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos); |
---|
518 | | - |
---|
519 | | - out.writeObject(obj); |
---|
520 | | - |
---|
521 | | - obj.parent = parent; |
---|
522 | | - obj.support = support; |
---|
523 | | - |
---|
524 | | - memorysize = baos.toByteArray().length; |
---|
525 | | - } |
---|
526 | | - catch (Exception e) |
---|
527 | | - { |
---|
528 | | - e.printStackTrace(); |
---|
529 | | - } |
---|
| 809 | + int memory = 0; |
---|
| 810 | + |
---|
| 811 | + if (bRep != null) |
---|
| 812 | + { |
---|
| 813 | + memory = bRep.VertexCount(); |
---|
530 | 814 | } |
---|
531 | 815 | |
---|
532 | | - 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; |
---|
533 | 828 | } |
---|
534 | 829 | |
---|
535 | 830 | void Slower() |
---|
.. | .. |
---|
617 | 912 | { |
---|
618 | 913 | if (maxcount != 1) |
---|
619 | 914 | { |
---|
620 | | - new Exception().printStackTrace(); |
---|
| 915 | + //new Exception().printStackTrace(); |
---|
621 | 916 | } |
---|
622 | 917 | |
---|
623 | 918 | toParentMarked = LA.newMatrix(); |
---|
.. | .. |
---|
819 | 1114 | |
---|
820 | 1115 | void Step() |
---|
821 | 1116 | { |
---|
822 | | - // marde pour serialization de Texture |
---|
| 1117 | + // patch pour serialization de Texture |
---|
823 | 1118 | resetmaxcount(); |
---|
824 | 1119 | resettransformcount(); |
---|
825 | 1120 | resetstep(); |
---|
.. | .. |
---|
854 | 1149 | transformcount++; |
---|
855 | 1150 | } |
---|
856 | 1151 | |
---|
857 | | - int maxcount; |
---|
| 1152 | + int maxcount = 128; |
---|
858 | 1153 | int transformcount; |
---|
859 | 1154 | int step; |
---|
860 | 1155 | |
---|
.. | .. |
---|
907 | 1202 | if (step == 0) |
---|
908 | 1203 | step = 1; |
---|
909 | 1204 | if (maxcount == 0) |
---|
910 | | - maxcount = 128; // 2048; // 4; |
---|
| 1205 | + { |
---|
| 1206 | + System.out.println("maxcount == 0"); |
---|
| 1207 | + System.exit(0); // maxcount = 128; // 2048; // 4; |
---|
| 1208 | + } |
---|
911 | 1209 | // if (acceleration == 0) |
---|
912 | 1210 | // acceleration = 10; |
---|
913 | 1211 | if (delay == 0) // serial |
---|
.. | .. |
---|
933 | 1231 | (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
934 | 1232 | currentframe != Globals.framecount) |
---|
935 | 1233 | { |
---|
| 1234 | + Globals.lighttouched = true; |
---|
| 1235 | + |
---|
936 | 1236 | currentframe = Globals.framecount; |
---|
937 | 1237 | |
---|
938 | 1238 | // System.err.println("transformcount = " + transformcount); |
---|
.. | .. |
---|
1012 | 1312 | { |
---|
1013 | 1313 | // return true; |
---|
1014 | 1314 | |
---|
1015 | | - if (material == null || material.multiply) |
---|
1016 | | - 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; |
---|
1017 | 1323 | |
---|
1018 | | - if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
1019 | | - return false; |
---|
1020 | | - |
---|
1021 | | - // Transparent objects are dynamic because we have to sort the triangles. |
---|
1022 | | - return material.opacity > 0.99; |
---|
| 1324 | + return !sort; |
---|
1023 | 1325 | } |
---|
1024 | 1326 | |
---|
1025 | 1327 | boolean IsOpaque() |
---|
1026 | 1328 | { |
---|
1027 | 1329 | // return true; |
---|
1028 | 1330 | |
---|
1029 | | - if (material == null || material.multiply) |
---|
1030 | | - return true; |
---|
| 1331 | +// if (material == null || material.multiply) |
---|
| 1332 | +// return true; |
---|
| 1333 | +// |
---|
| 1334 | +// return material.opacity > 0.99; |
---|
1031 | 1335 | |
---|
1032 | | - return material.opacity > 0.99; |
---|
| 1336 | + return !sort; |
---|
1033 | 1337 | } |
---|
1034 | 1338 | |
---|
1035 | 1339 | Object3D() |
---|
.. | .. |
---|
1107 | 1411 | |
---|
1108 | 1412 | // will share the geometry |
---|
1109 | 1413 | assert (!(this instanceof Composite)); |
---|
1110 | | - return deepCopy(); // Never called for Composite |
---|
1111 | | - |
---|
| 1414 | + |
---|
| 1415 | + Object3D obj = deepCopy(); // Never called for Composite |
---|
| 1416 | + obj.count = 2; |
---|
| 1417 | + return obj; |
---|
1112 | 1418 | } |
---|
1113 | 1419 | |
---|
1114 | 1420 | boolean HasLoops() |
---|
.. | .. |
---|
1116 | 1422 | return false; |
---|
1117 | 1423 | } |
---|
1118 | 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 | + |
---|
1119 | 1449 | boolean IsInfinite() |
---|
1120 | 1450 | { |
---|
1121 | 1451 | if (blockloop) |
---|
.. | .. |
---|
1186 | 1516 | return; |
---|
1187 | 1517 | |
---|
1188 | 1518 | blockloop = true; |
---|
| 1519 | + |
---|
| 1520 | + // other.parent = parent; |
---|
| 1521 | + |
---|
1189 | 1522 | //System.out.println("COPY " + this + " to " + other); |
---|
1190 | 1523 | //new Exception().printStackTrace(); |
---|
| 1524 | + deepCopyNode(other); |
---|
1191 | 1525 | |
---|
1192 | | - other.parent = parent; |
---|
1193 | | - if (toParent != null) |
---|
1194 | | - { |
---|
1195 | | - other.toParent = LA.newMatrix(); |
---|
1196 | | - other.fromParent = LA.newMatrix(); |
---|
1197 | | - LA.matCopy(toParent, other.toParent); |
---|
1198 | | - LA.matCopy(fromParent, other.fromParent); |
---|
1199 | | - if (toParentMarked != null) |
---|
1200 | | - { |
---|
1201 | | - other.toParentMarked = LA.newMatrix(); |
---|
1202 | | - other.fromParentMarked = LA.newMatrix(); |
---|
1203 | | - LA.matCopy(toParentMarked, other.toParentMarked); |
---|
1204 | | - LA.matCopy(fromParentMarked, other.fromParentMarked); |
---|
1205 | | - } |
---|
1206 | | - } |
---|
1207 | | - else |
---|
1208 | | - { |
---|
1209 | | - if (other.toParent == null) |
---|
1210 | | -// assert(other.toParent == null); |
---|
1211 | | -// new Exception().printStackTrace(); |
---|
1212 | | - System.err.println("null parent: " + other); |
---|
1213 | | - } |
---|
1214 | | - /* |
---|
1215 | | - double ident[][] = LA.newMatrix(); |
---|
1216 | | - if (bRep == null) |
---|
1217 | | - other.bRep = null; |
---|
1218 | | - else |
---|
1219 | | - other.bRep = new BoundaryRep(bRep, ident); |
---|
1220 | | - */ |
---|
1221 | | - // Really new... |
---|
1222 | 1526 | other.bRep = bRep; // Share the geometry |
---|
1223 | 1527 | |
---|
1224 | 1528 | other.support = support; // Share the support |
---|
1225 | | - |
---|
1226 | | - //other.editWindow = null; |
---|
1227 | | - if (name == null) |
---|
1228 | | - other.name = null; |
---|
1229 | | - else |
---|
1230 | | - other.name = new String(name); |
---|
1231 | | - |
---|
1232 | | - if (material != null) |
---|
1233 | | - { |
---|
1234 | | - other.material = new cMaterial(material); |
---|
1235 | | - } else |
---|
1236 | | - { |
---|
1237 | | - other.material = null; |
---|
1238 | | - } |
---|
1239 | | - |
---|
1240 | | - other.GetTextures().name = GetTextures().name; |
---|
1241 | | - |
---|
1242 | | - CopyExtraMaterial(other); |
---|
1243 | | - |
---|
1244 | | - other.touched = touched; |
---|
1245 | | - other.softtouched = softtouched; |
---|
1246 | | - |
---|
1247 | | - other.random = random; |
---|
1248 | | - other.link2master = link2master; |
---|
1249 | | - other.transformcount = transformcount; |
---|
1250 | | - other.marked = marked; |
---|
1251 | | - other.skip = skip; |
---|
1252 | | - other.count = count; |
---|
1253 | | - other.flipV = flipV; |
---|
1254 | | - other.live = live; |
---|
1255 | | - other.rewind = rewind; |
---|
1256 | | - other.hide = hide; |
---|
1257 | | - other.texres = texres; |
---|
1258 | | - other.speedup = speedup; |
---|
1259 | | - other.height = height; |
---|
1260 | | - other.depth = depth; |
---|
1261 | 1529 | |
---|
1262 | 1530 | // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist) |
---|
1263 | 1531 | // { |
---|
.. | .. |
---|
1285 | 1553 | Object3D obj = (Object3D)Children().get(i); |
---|
1286 | 1554 | if (IsContainedIn(obj)) |
---|
1287 | 1555 | { |
---|
1288 | | -// assert(false); // ?!?!?!?!?! |
---|
| 1556 | + assert(false); // ?!?!?!?!?! |
---|
1289 | 1557 | c.Children().setElementAt(c, i); |
---|
1290 | 1558 | } |
---|
1291 | 1559 | else |
---|
.. | .. |
---|
1313 | 1581 | if ((mask & GEOMETRY) != 0) |
---|
1314 | 1582 | { |
---|
1315 | 1583 | if (bRep != null) |
---|
1316 | | - bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); |
---|
1317 | | - else |
---|
1318 | | - assert(other.bRep == null); |
---|
1319 | | - |
---|
1320 | | - if (bRep != null) |
---|
1321 | 1584 | { |
---|
| 1585 | + bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); |
---|
1322 | 1586 | CameraPane.RemoveList(bRep.displaylist); |
---|
1323 | 1587 | bRep.displaylist = 0; // june 2013 -1; |
---|
1324 | 1588 | } |
---|
1325 | 1589 | else |
---|
1326 | | - 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; |
---|
1327 | 1602 | } |
---|
1328 | 1603 | |
---|
1329 | 1604 | /* Use a MASK = GEO/MAT |
---|
.. | .. |
---|
2299 | 2574 | |
---|
2300 | 2575 | InitOthers(); |
---|
2301 | 2576 | |
---|
2302 | | - if (this instanceof Camera) |
---|
2303 | | - { |
---|
2304 | | - material.shift = 90; |
---|
2305 | | - } |
---|
2306 | | - |
---|
2307 | 2577 | material.multiply = multiply; |
---|
2308 | 2578 | |
---|
2309 | 2579 | if (multiply) |
---|
.. | .. |
---|
2381 | 2651 | return b; |
---|
2382 | 2652 | } |
---|
2383 | 2653 | |
---|
2384 | | - void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate) |
---|
| 2654 | + void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate, boolean colorparallax) |
---|
2385 | 2655 | { |
---|
2386 | 2656 | if (blockloop) |
---|
2387 | 2657 | { |
---|
.. | .. |
---|
2391 | 2661 | // super.UpdateMaterial(anchor, current, false); |
---|
2392 | 2662 | if (material != null) |
---|
2393 | 2663 | { |
---|
2394 | | - material.UpdateMaterial(anchor, current); |
---|
| 2664 | + material.UpdateMaterial(anchor, current, colorparallax); |
---|
2395 | 2665 | } |
---|
2396 | 2666 | |
---|
2397 | 2667 | if (!propagate) |
---|
.. | .. |
---|
2405 | 2675 | if (child == null) |
---|
2406 | 2676 | continue; |
---|
2407 | 2677 | blockloop = true; |
---|
2408 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2678 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2409 | 2679 | blockloop = false; |
---|
2410 | 2680 | Children().release(i); |
---|
2411 | 2681 | } |
---|
.. | .. |
---|
2419 | 2689 | if (child == null) |
---|
2420 | 2690 | continue; |
---|
2421 | 2691 | blockloop = true; |
---|
2422 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2692 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2423 | 2693 | blockloop = false; |
---|
2424 | 2694 | Children().release(i); |
---|
2425 | 2695 | } |
---|
.. | .. |
---|
2444 | 2714 | else |
---|
2445 | 2715 | { |
---|
2446 | 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"); |
---|
2447 | 2722 | } |
---|
2448 | 2723 | } |
---|
2449 | 2724 | |
---|
.. | .. |
---|
3119 | 3394 | { |
---|
3120 | 3395 | if (bRep != null) |
---|
3121 | 3396 | { |
---|
| 3397 | + //bRep.GenerateNormals2(crease); // in-place doesn't work. it gives wrong normals (diamond artifact). |
---|
3122 | 3398 | bRep.GenerateNormals(crease); |
---|
| 3399 | + if (!bRep.trimmed) |
---|
| 3400 | + bRep.MergeNormals(); |
---|
3123 | 3401 | Touch(); |
---|
3124 | 3402 | } |
---|
3125 | 3403 | } |
---|
.. | .. |
---|
3194 | 3472 | blockloop = false; |
---|
3195 | 3473 | } |
---|
3196 | 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 | + |
---|
3197 | 3574 | void TransformChildren() |
---|
3198 | 3575 | { |
---|
3199 | 3576 | if (toParent != null) |
---|
.. | .. |
---|
3436 | 3813 | if (bRep != null) |
---|
3437 | 3814 | { |
---|
3438 | 3815 | //bRep.RemoveOneTriangle(); |
---|
| 3816 | + System.out.println(); |
---|
3439 | 3817 | System.out.println("Reducing " + this); |
---|
3440 | 3818 | if (name != null && name.contains("lockpickstraps")) |
---|
3441 | 3819 | name = name; |
---|
.. | .. |
---|
3547 | 3925 | |
---|
3548 | 3926 | void ClearMaterials() |
---|
3549 | 3927 | { |
---|
| 3928 | + if (blockloop) |
---|
| 3929 | + return; |
---|
| 3930 | + |
---|
| 3931 | + blockloop = true; |
---|
| 3932 | + |
---|
3550 | 3933 | ClearMaterial(); |
---|
3551 | | - for (int i = 0; i < size(); i++) |
---|
| 3934 | + for (int i = 0; i < Size(); i++) |
---|
3552 | 3935 | { |
---|
3553 | | - Object3D child = (Object3D) reserve(i); |
---|
| 3936 | + Object3D child = (Object3D) get(i); |
---|
3554 | 3937 | if (child == null) |
---|
3555 | 3938 | continue; |
---|
3556 | 3939 | child.ClearMaterials(); |
---|
3557 | | - release(i); |
---|
3558 | 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; |
---|
3559 | 3969 | } |
---|
3560 | 3970 | |
---|
3561 | 3971 | void FlipV(boolean flip) |
---|
.. | .. |
---|
3734 | 4144 | |
---|
3735 | 4145 | void RevertMeshes() |
---|
3736 | 4146 | { |
---|
| 4147 | + // BLOCKLOOP |
---|
3737 | 4148 | if (this instanceof cMesh) |
---|
3738 | 4149 | { |
---|
3739 | 4150 | ((cMesh)this).Revert(); |
---|
.. | .. |
---|
3764 | 4175 | Touch(); |
---|
3765 | 4176 | } |
---|
3766 | 4177 | |
---|
3767 | | - ResetRecur(); |
---|
3768 | | - } |
---|
3769 | | - |
---|
3770 | | - void ResetRecur() |
---|
3771 | | - { |
---|
3772 | 4178 | for (int i = 0; i < size(); i++) |
---|
3773 | 4179 | { |
---|
3774 | 4180 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
3791 | 4197 | Step(); |
---|
3792 | 4198 | Touch(); |
---|
3793 | 4199 | |
---|
3794 | | - StepRecur(); |
---|
3795 | | - } |
---|
3796 | | - |
---|
3797 | | - void StepRecur() |
---|
3798 | | - { |
---|
3799 | 4200 | for (int i = 0; i < size(); i++) |
---|
3800 | 4201 | { |
---|
3801 | 4202 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
3982 | 4383 | Touch(); |
---|
3983 | 4384 | } |
---|
3984 | 4385 | |
---|
3985 | | - transient cVector min = new cVector(); |
---|
3986 | | - transient cVector max = new cVector(); |
---|
| 4386 | + transient cVector min; |
---|
| 4387 | + transient cVector max; |
---|
3987 | 4388 | |
---|
3988 | 4389 | void getBounds(cVector minima, cVector maxima, boolean xform) |
---|
3989 | 4390 | { |
---|
.. | .. |
---|
3999 | 4400 | if (blockloop) |
---|
4000 | 4401 | return; |
---|
4001 | 4402 | |
---|
4002 | | - if (min == null) // ??? |
---|
| 4403 | + if (min == null) |
---|
4003 | 4404 | { |
---|
4004 | 4405 | min = new cVector(); |
---|
4005 | 4406 | max = new cVector(); |
---|
4006 | 4407 | } |
---|
4007 | 4408 | |
---|
4008 | | - for (int i = 0; i<size(); i++) |
---|
| 4409 | + for (int i = 0; i<Size(); i++) |
---|
4009 | 4410 | { |
---|
4010 | | - Object3D child = (Object3D) reserve(i); |
---|
| 4411 | + Object3D child = (Object3D) get(i); //reserve(i); |
---|
4011 | 4412 | if (child == null) |
---|
4012 | 4413 | continue; |
---|
4013 | 4414 | |
---|
.. | .. |
---|
4026 | 4427 | if (child.hide && !(child instanceof Merge) || child.skip) |
---|
4027 | 4428 | //if (child.hide) |
---|
4028 | 4429 | { |
---|
4029 | | - release(i); |
---|
| 4430 | + //release(i); |
---|
4030 | 4431 | continue; |
---|
4031 | 4432 | } |
---|
4032 | 4433 | |
---|
4033 | 4434 | blockloop = true; |
---|
4034 | 4435 | child.getBounds(min, max, true); // xform); |
---|
4035 | 4436 | blockloop = false; |
---|
4036 | | - release(i); |
---|
| 4437 | + //release(i); |
---|
4037 | 4438 | |
---|
4038 | 4439 | MinMax(minima, maxima); |
---|
4039 | 4440 | } |
---|
4040 | 4441 | |
---|
4041 | 4442 | if (bRep != null) |
---|
4042 | 4443 | { |
---|
4043 | | - bRep.getBounds(minima,maxima,this); |
---|
| 4444 | + bRep.getBounds(minima, maxima, xform?this:null); |
---|
4044 | 4445 | } |
---|
4045 | 4446 | |
---|
4046 | 4447 | if (false) // xform) |
---|
.. | .. |
---|
5313 | 5714 | { |
---|
5314 | 5715 | } |
---|
5315 | 5716 | // transient int displaylist = 0; // -1; |
---|
5316 | | - transient boolean touched = true; |
---|
5317 | | - 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 |
---|
5318 | 5720 | |
---|
5319 | 5721 | void Touch() |
---|
5320 | 5722 | { |
---|
.. | .. |
---|
5367 | 5769 | { |
---|
5368 | 5770 | //System.out.println("HardTouch " + this); // new Exception().printStackTrace(); |
---|
5369 | 5771 | //new Exception().printStackTrace(); |
---|
| 5772 | + reset = true; |
---|
5370 | 5773 | touched = true; |
---|
5371 | 5774 | CameraPane.touched = true; |
---|
5372 | 5775 | //if (parent != null) |
---|
.. | .. |
---|
5545 | 5948 | if (fullname == null) |
---|
5546 | 5949 | return ""; |
---|
5547 | 5950 | |
---|
| 5951 | + if (fullname.pigment != null) |
---|
| 5952 | + { |
---|
| 5953 | + return fullname.pigment; |
---|
| 5954 | + } |
---|
| 5955 | + |
---|
5548 | 5956 | // System.out.println("Fullname = " + fullname); |
---|
5549 | 5957 | |
---|
5550 | 5958 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5557 | 5965 | |
---|
5558 | 5966 | if (split.length == 0) |
---|
5559 | 5967 | { |
---|
5560 | | - return ""; |
---|
| 5968 | + return fullname.pigment = ""; |
---|
5561 | 5969 | } |
---|
5562 | 5970 | |
---|
5563 | 5971 | if (split.length <= 2) |
---|
.. | .. |
---|
5565 | 5973 | if (fullname.name.endsWith(":")) |
---|
5566 | 5974 | { |
---|
5567 | 5975 | // Windows |
---|
5568 | | - return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5976 | + return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1); |
---|
5569 | 5977 | } |
---|
5570 | 5978 | |
---|
5571 | | - return split[0]; |
---|
| 5979 | + return fullname.pigment = split[0]; |
---|
5572 | 5980 | } |
---|
5573 | 5981 | |
---|
5574 | 5982 | // Windows |
---|
5575 | 5983 | assert(split.length == 4); |
---|
5576 | 5984 | |
---|
5577 | | - return split[0] + ":" + split[1]; |
---|
| 5985 | + return fullname.pigment = split[0] + ":" + split[1]; |
---|
5578 | 5986 | } |
---|
5579 | 5987 | |
---|
5580 | 5988 | static String GetBump(cTexture fullname) |
---|
5581 | 5989 | { |
---|
5582 | 5990 | if (fullname == null) |
---|
5583 | 5991 | return ""; |
---|
| 5992 | + |
---|
| 5993 | + if (fullname.bump != null) |
---|
| 5994 | + { |
---|
| 5995 | + return fullname.bump; |
---|
| 5996 | + } |
---|
5584 | 5997 | |
---|
5585 | 5998 | // System.out.println("Fullname = " + fullname); |
---|
5586 | 5999 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5592 | 6005 | |
---|
5593 | 6006 | if (split.length == 0) |
---|
5594 | 6007 | { |
---|
5595 | | - return ""; |
---|
| 6008 | + return fullname.bump = ""; |
---|
5596 | 6009 | } |
---|
5597 | 6010 | |
---|
5598 | 6011 | if (split.length == 1) |
---|
5599 | 6012 | { |
---|
5600 | | - return ""; |
---|
| 6013 | + return fullname.bump = ""; |
---|
5601 | 6014 | } |
---|
5602 | 6015 | |
---|
5603 | 6016 | if (split.length == 2) |
---|
.. | .. |
---|
5605 | 6018 | if (fullname.name.endsWith(":")) |
---|
5606 | 6019 | { |
---|
5607 | 6020 | // Windows |
---|
5608 | | - return ""; |
---|
| 6021 | + return fullname.bump = ""; |
---|
5609 | 6022 | } |
---|
5610 | 6023 | |
---|
5611 | | - return split[1]; |
---|
| 6024 | + return fullname.bump = split[1]; |
---|
5612 | 6025 | } |
---|
5613 | 6026 | |
---|
5614 | 6027 | // Windows |
---|
5615 | 6028 | assert(split.length == 4); |
---|
5616 | 6029 | |
---|
5617 | | - return split[2] + ":" + split[3]; |
---|
| 6030 | + return fullname.bump = split[2] + ":" + split[3]; |
---|
5618 | 6031 | } |
---|
5619 | 6032 | |
---|
5620 | 6033 | String GetPigmentTexture() |
---|
.. | .. |
---|
5697 | 6110 | texname = ""; |
---|
5698 | 6111 | |
---|
5699 | 6112 | GetTextures().name = texname + ":" + GetBump(GetTextures()); |
---|
| 6113 | + |
---|
| 6114 | + GetTextures().pigment = null; |
---|
| 6115 | + |
---|
5700 | 6116 | Touch(); |
---|
5701 | 6117 | } |
---|
5702 | 6118 | |
---|
.. | .. |
---|
5770 | 6186 | |
---|
5771 | 6187 | GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname; |
---|
5772 | 6188 | |
---|
| 6189 | + GetTextures().bump = null; |
---|
| 6190 | + |
---|
5773 | 6191 | Touch(); |
---|
5774 | 6192 | } |
---|
5775 | 6193 | |
---|
.. | .. |
---|
5834 | 6252 | boolean NeedSupport() |
---|
5835 | 6253 | { |
---|
5836 | 6254 | return |
---|
5837 | | - 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 |
---|
5838 | 6256 | // PROBLEM with CROWD!! |
---|
5839 | 6257 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5840 | 6258 | } |
---|
.. | .. |
---|
5852 | 6270 | return parent.IsLive(); |
---|
5853 | 6271 | } |
---|
5854 | 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 | + |
---|
5855 | 6289 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5856 | 6290 | { |
---|
5857 | 6291 | Invariants(); // june 2013 |
---|
.. | .. |
---|
5859 | 6293 | if (support != null) |
---|
5860 | 6294 | { |
---|
5861 | 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 | + } |
---|
5862 | 6319 | } |
---|
5863 | 6320 | |
---|
5864 | 6321 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
.. | .. |
---|
5912 | 6369 | if (support != null) |
---|
5913 | 6370 | support = support; |
---|
5914 | 6371 | |
---|
5915 | | - boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5916 | | - //boolean usecalllists = false; //!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); |
---|
5917 | 6376 | |
---|
5918 | 6377 | //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
5919 | 6378 | |
---|
.. | .. |
---|
5923 | 6382 | bRep.displaylist = 0; |
---|
5924 | 6383 | } |
---|
5925 | 6384 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5926 | | - // usecalllists = false; |
---|
| 6385 | + if (CameraPane.BOXMODE) // Too dynamic |
---|
| 6386 | + usecalllists = false; |
---|
5927 | 6387 | |
---|
5928 | 6388 | if (display.DrawMode() == display.SHADOW) |
---|
5929 | 6389 | //GetBRep() != null) |
---|
.. | .. |
---|
5937 | 6397 | |
---|
5938 | 6398 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5939 | 6399 | //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
5940 | | - (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
| 6400 | + ((Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE) || touched)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5941 | 6401 | { |
---|
5942 | 6402 | Globals.lighttouched = true; |
---|
5943 | 6403 | } // all panes... |
---|
.. | .. |
---|
5966 | 6426 | display.NewList(bRep.displaylist); |
---|
5967 | 6427 | } |
---|
5968 | 6428 | |
---|
| 6429 | + compiling = true; |
---|
5969 | 6430 | CallList(display, root, selected, blocked); |
---|
| 6431 | + compiling = false; |
---|
5970 | 6432 | |
---|
5971 | 6433 | // compiled = true; |
---|
5972 | 6434 | if (usecalllists && bRep.displaylist > 0) |
---|
.. | .. |
---|
5979 | 6441 | Globals.lighttouched = true; // all panes... |
---|
5980 | 6442 | } |
---|
5981 | 6443 | |
---|
5982 | | - touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
5983 | | - //touched = false; |
---|
| 6444 | + //touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
| 6445 | + touched = false; |
---|
5984 | 6446 | |
---|
5985 | 6447 | if (this instanceof Texture || this instanceof TextureNode) |
---|
5986 | 6448 | { |
---|
.. | .. |
---|
6019 | 6481 | { |
---|
6020 | 6482 | if (display.DrawMode() == iCameraPane.SHADOW) |
---|
6021 | 6483 | { |
---|
6022 | | - if (!link2master // tricky to cull in shadow mode. |
---|
| 6484 | + if (!Link2Support() // tricky to cull in shadow mode. |
---|
6023 | 6485 | && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
6024 | 6486 | { |
---|
6025 | 6487 | //System.out.print("CULLED"); |
---|
.. | .. |
---|
6081 | 6543 | { |
---|
6082 | 6544 | drawSelf(display, root, selected, blocked); |
---|
6083 | 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 | +// } |
---|
6084 | 6560 | } else |
---|
6085 | 6561 | { |
---|
6086 | 6562 | /* |
---|
.. | .. |
---|
6113 | 6589 | boolean failedPigment = false; |
---|
6114 | 6590 | boolean failedBump = false; |
---|
6115 | 6591 | |
---|
| 6592 | + CameraPane.lastObject = this; |
---|
6116 | 6593 | try |
---|
6117 | 6594 | { |
---|
6118 | 6595 | display.BindPigmentTexture(tex, texres); |
---|
6119 | 6596 | } |
---|
6120 | 6597 | catch (Exception e) |
---|
6121 | 6598 | { |
---|
6122 | | - System.err.println("FAILED: " + this); |
---|
| 6599 | + // System.err.println("FAILED: " + this); |
---|
6123 | 6600 | failedPigment = true; |
---|
6124 | 6601 | } |
---|
6125 | 6602 | |
---|
.. | .. |
---|
6150 | 6627 | display.CallList(bRep.displaylist); |
---|
6151 | 6628 | // june 2013 drawSelf(display, root, selected); |
---|
6152 | 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 | +// } |
---|
6153 | 6644 | } |
---|
6154 | 6645 | } |
---|
6155 | 6646 | |
---|
.. | .. |
---|
6203 | 6694 | |
---|
6204 | 6695 | void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
6205 | 6696 | { |
---|
6206 | | - if (GetBRep() == null) |
---|
6207 | | - { |
---|
6208 | | - drawSelf(display, root, selected, blocked); |
---|
6209 | | - } else |
---|
| 6697 | + if (GetBRep() != null) |
---|
6210 | 6698 | { |
---|
6211 | 6699 | DrawNode(display, root, selected); |
---|
6212 | 6700 | if (this instanceof BezierPatch) |
---|
6213 | 6701 | { |
---|
6214 | 6702 | //drawSelf(display, root, selected); |
---|
6215 | 6703 | } |
---|
| 6704 | + } |
---|
| 6705 | + else |
---|
| 6706 | + { |
---|
| 6707 | + drawSelf(display, root, selected, blocked); |
---|
6216 | 6708 | } |
---|
6217 | 6709 | } |
---|
6218 | 6710 | |
---|
.. | .. |
---|
6411 | 6903 | |
---|
6412 | 6904 | void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
6413 | 6905 | { |
---|
6414 | | - if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
6415 | | - return; // no shadow for transparent objects |
---|
6416 | | - |
---|
6417 | | - if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
6418 | | - 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 | + } |
---|
6419 | 6914 | |
---|
6420 | 6915 | if (hide) |
---|
6421 | 6916 | return; |
---|
6422 | | - |
---|
| 6917 | + |
---|
6423 | 6918 | if (scriptnode != null) |
---|
6424 | 6919 | { |
---|
6425 | 6920 | scriptnode.DrawNode(display, root, selected); |
---|
.. | .. |
---|
6462 | 6957 | |
---|
6463 | 6958 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
6464 | 6959 | |
---|
6465 | | - if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
| 6960 | + if (CameraPane.BOXMODE && !Link2Support()) // |
---|
| 6961 | + //!selected) // || CameraPane.movingcamera) |
---|
6466 | 6962 | { |
---|
6467 | 6963 | int fc = bRep.FaceCount(); |
---|
6468 | 6964 | int vc = bRep.VertexCount(); |
---|
.. | .. |
---|
6624 | 7120 | facescompare[k] = new FaceCompare(k); |
---|
6625 | 7121 | } |
---|
6626 | 7122 | |
---|
6627 | | - center = new cVector(); |
---|
| 7123 | + centertriangle = new cVector(); |
---|
6628 | 7124 | } |
---|
6629 | 7125 | else |
---|
6630 | 7126 | { |
---|
.. | .. |
---|
6747 | 7243 | */ |
---|
6748 | 7244 | } |
---|
6749 | 7245 | |
---|
6750 | | - transient cVector center; |
---|
| 7246 | + transient cVector centertriangle; |
---|
6751 | 7247 | |
---|
6752 | 7248 | class FaceCompare implements Comparable |
---|
6753 | 7249 | { |
---|
.. | .. |
---|
6776 | 7272 | Vertex q = bRep.GetVertex(face.q); |
---|
6777 | 7273 | Vertex r = bRep.GetVertex(face.r); |
---|
6778 | 7274 | |
---|
6779 | | - center.set(p); |
---|
6780 | | - center.add(q); |
---|
6781 | | - center.add(r); |
---|
6782 | | - center.mul(1.0/3); |
---|
| 7275 | + centertriangle.set(p); |
---|
| 7276 | + centertriangle.add(q); |
---|
| 7277 | + centertriangle.add(r); |
---|
| 7278 | + centertriangle.mul(1.0/3); |
---|
6783 | 7279 | |
---|
6784 | | - center.sub(Globals.theRenderer.EyeCamera().location); |
---|
| 7280 | + centertriangle.sub(Globals.theRenderer.EyeCamera().location); |
---|
6785 | 7281 | |
---|
6786 | | - distance = center.dot(center); |
---|
| 7282 | + distance = centertriangle.dot(centertriangle); |
---|
6787 | 7283 | } |
---|
6788 | 7284 | |
---|
6789 | 7285 | return distance; |
---|
.. | .. |
---|
7373 | 7869 | boundary.y = spot.y - 30; |
---|
7374 | 7870 | boundary.width = spot.width + 60; |
---|
7375 | 7871 | boundary.height = spot.height + 60; |
---|
7376 | | - clickInfo.g.setColor(Color.red); |
---|
| 7872 | + clickInfo.g.setColor(Color.white); |
---|
7377 | 7873 | int spotw = spot.x + spot.width; |
---|
7378 | 7874 | int spoth = spot.y + spot.height; |
---|
7379 | 7875 | clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
7393 | 7889 | // { |
---|
7394 | 7890 | // CameraPane.Ymax = spoth; |
---|
7395 | 7891 | // } |
---|
7396 | | - spot.translate(32, 32); |
---|
| 7892 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7893 | +// { |
---|
| 7894 | +// CameraPane.Xmin = spot.x; |
---|
| 7895 | +// } |
---|
| 7896 | +// if (CameraPane.Xmax < spotw) |
---|
| 7897 | +// { |
---|
| 7898 | +// CameraPane.Xmax = spotw; |
---|
| 7899 | +// } |
---|
| 7900 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7901 | +// { |
---|
| 7902 | +// CameraPane.Ymin = spot.y; |
---|
| 7903 | +// } |
---|
| 7904 | +// if (CameraPane.Ymax < spoth) |
---|
| 7905 | +// { |
---|
| 7906 | +// CameraPane.Ymax = spoth; |
---|
| 7907 | +// } |
---|
| 7908 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7909 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
| 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); |
---|
7397 | 7915 | spotw = spot.x + spot.width; |
---|
7398 | 7916 | spoth = spot.y + spot.height; |
---|
7399 | 7917 | clickInfo.g.setColor(Color.cyan); |
---|
.. | .. |
---|
7414 | 7932 | // { |
---|
7415 | 7933 | // CameraPane.Ymax = spoth; |
---|
7416 | 7934 | // } |
---|
7417 | | - // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
7418 | | - //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
7419 | | - spot.translate(0, -32); |
---|
7420 | | - clickInfo.g.setColor(Color.yellow); |
---|
7421 | | - clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7422 | 7935 | clickInfo.g.setColor(Color.green); |
---|
7423 | | -// if (CameraPane.Xmin > spot.x) |
---|
7424 | | -// { |
---|
7425 | | -// CameraPane.Xmin = spot.x; |
---|
7426 | | -// } |
---|
7427 | | -// if (CameraPane.Xmax < spotw) |
---|
7428 | | -// { |
---|
7429 | | -// CameraPane.Xmax = spotw; |
---|
7430 | | -// } |
---|
7431 | | -// if (CameraPane.Ymin > spot.y) |
---|
7432 | | -// { |
---|
7433 | | -// CameraPane.Ymin = spot.y; |
---|
7434 | | -// } |
---|
7435 | | -// if (CameraPane.Ymax < spoth) |
---|
7436 | | -// { |
---|
7437 | | -// CameraPane.Ymax = spoth; |
---|
7438 | | -// } |
---|
7439 | 7936 | clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
7440 | 7937 | (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
7441 | 7938 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
.. | .. |
---|
7494 | 7991 | retval = true; |
---|
7495 | 7992 | } |
---|
7496 | 7993 | spot.translate(0, 32); |
---|
| 7994 | + spot.translate(32, 0); |
---|
| 7995 | + spot.translate(0, 32); |
---|
7497 | 7996 | if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7498 | 7997 | { |
---|
7499 | 7998 | hitSomething = hitScale; |
---|
7500 | 7999 | |
---|
7501 | 8000 | double scale = 0.005f * clickInfo.camera.Distance(); |
---|
7502 | | - double hScale = (double) (clickInfo.x - centerPt.x) / 32; |
---|
| 8001 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
7503 | 8002 | double sign = 1; |
---|
7504 | 8003 | if (hScale < 0) |
---|
7505 | 8004 | { |
---|
.. | .. |
---|
7511 | 8010 | //hScale = 0.01; |
---|
7512 | 8011 | } |
---|
7513 | 8012 | |
---|
7514 | | - double vScale = (double) (clickInfo.y - centerPt.y) / 32; |
---|
| 8013 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
7515 | 8014 | sign = 1; |
---|
7516 | 8015 | if (vScale < 0) |
---|
7517 | 8016 | { |
---|
.. | .. |
---|
7591 | 8090 | |
---|
7592 | 8091 | scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7593 | 8092 | |
---|
7594 | | - if (modified || opposite) |
---|
| 8093 | + // Modified could snap |
---|
| 8094 | + if (//modified || |
---|
| 8095 | + opposite) |
---|
7595 | 8096 | { |
---|
7596 | 8097 | //assert(false); |
---|
7597 | 8098 | /* |
---|
.. | .. |
---|
7685 | 8186 | |
---|
7686 | 8187 | if (modified) |
---|
7687 | 8188 | { |
---|
7688 | | - // Rotate 90 degrees |
---|
| 8189 | + // Rotate 45 degrees |
---|
7689 | 8190 | angle /= (Math.PI / 4); |
---|
7690 | 8191 | angle = Math.floor(angle + 0.5); |
---|
7691 | 8192 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7726 | 8227 | break; |
---|
7727 | 8228 | |
---|
7728 | 8229 | case hitScale: // scale |
---|
7729 | | - double hScale = (double) (clickInfo.x - centerPt.x) / 32; |
---|
| 8230 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
7730 | 8231 | double sign = 1; |
---|
7731 | 8232 | if (hScale < 0) |
---|
7732 | 8233 | { |
---|
.. | .. |
---|
7738 | 8239 | //hScale = 0.01; |
---|
7739 | 8240 | } |
---|
7740 | 8241 | |
---|
7741 | | - double vScale = (double) (clickInfo.y - centerPt.y) / 32; |
---|
| 8242 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
7742 | 8243 | sign = 1; |
---|
7743 | 8244 | if (vScale < 0) |
---|
7744 | 8245 | { |
---|
.. | .. |
---|
7771 | 8272 | case 3: // '\001' |
---|
7772 | 8273 | if (modified || opposite) |
---|
7773 | 8274 | { |
---|
| 8275 | + if (modified) // && opposite) |
---|
| 8276 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8277 | + else |
---|
7774 | 8278 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7775 | | - LA.matScale(toParent, totalScale, 1, 1); |
---|
| 8279 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7776 | 8280 | } // vScale, 1); |
---|
7777 | 8281 | else |
---|
7778 | 8282 | { |
---|
7779 | 8283 | // EXCEPTION! |
---|
7780 | | - LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8284 | + LA.matScale(toParent, 1, totalScale, totalScale); |
---|
7781 | 8285 | } // vScale, 1); |
---|
7782 | 8286 | break; |
---|
7783 | 8287 | |
---|
7784 | 8288 | case 2: // '\002' |
---|
7785 | 8289 | if (modified || opposite) |
---|
7786 | 8290 | { |
---|
7787 | | - //LA.matScale(toParent, hScale, 1, vScale); |
---|
7788 | | - 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); |
---|
7789 | 8296 | } else |
---|
7790 | 8297 | { |
---|
7791 | 8298 | LA.matScale(toParent, totalScale, 1, totalScale); |
---|
.. | .. |
---|
7795 | 8302 | case 1: // '\003' |
---|
7796 | 8303 | if (modified || opposite) |
---|
7797 | 8304 | { |
---|
7798 | | - //LA.matScale(toParent, hScale, vScale, 1); |
---|
7799 | | - 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); |
---|
7800 | 8310 | } else |
---|
7801 | 8311 | { |
---|
7802 | 8312 | LA.matScale(toParent, totalScale, totalScale, 1); |
---|
.. | .. |
---|
7940 | 8450 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7941 | 8451 | } else |
---|
7942 | 8452 | { |
---|
7943 | | - 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) ":"") */ ""; |
---|
7944 | 8454 | } // + super.toString(); |
---|
7945 | 8455 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7946 | 8456 | |
---|
7947 | 8457 | if (!Globals.ADVANCED) |
---|
7948 | 8458 | return objname; |
---|
7949 | 8459 | |
---|
7950 | | - return objname + " " + System.identityHashCode(this); |
---|
| 8460 | + return objname + " " + System.identityHashCode(this) + " " + GetUUID(); |
---|
7951 | 8461 | } |
---|
7952 | 8462 | |
---|
7953 | 8463 | public int hashCode() |
---|
7954 | 8464 | { |
---|
7955 | | - // Fuck Vector... |
---|
| 8465 | + // Do not use Vector... |
---|
7956 | 8466 | return System.identityHashCode(this); |
---|
7957 | 8467 | } |
---|
7958 | 8468 | |
---|
.. | .. |
---|
8192 | 8702 | private static cVector2 qq2 = new cVector2(); |
---|
8193 | 8703 | private static cVector2 rr2 = new cVector2(); |
---|
8194 | 8704 | private static cVector2 ss2 = new cVector2(); |
---|
8195 | | - private static cVector edge1 = new cVector(); |
---|
8196 | | - private static cVector edge2 = new cVector(); |
---|
| 8705 | +// private static cVector edge1 = new cVector(); |
---|
| 8706 | +// private static cVector edge2 = new cVector(); |
---|
8197 | 8707 | //private static cVector norm = new cVector(); |
---|
8198 | 8708 | /*transient private*/ int hitSomething; |
---|
8199 | 8709 | static final int hitCenter = 1; |
---|
.. | .. |
---|
8391 | 8901 | |
---|
8392 | 8902 | Touch(); |
---|
8393 | 8903 | } |
---|
| 8904 | + |
---|
| 8905 | + static Vertex s1 = new Vertex(); |
---|
| 8906 | + static Vertex s2 = new Vertex(); |
---|
| 8907 | + static Vertex s3 = new Vertex(); |
---|
8394 | 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 | + } |
---|
8395 | 9173 | |
---|
8396 | 9174 | public int Size() |
---|
8397 | 9175 | { |
---|
.. | .. |
---|
8488 | 9266 | return -1; |
---|
8489 | 9267 | } |
---|
8490 | 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 | + } |
---|
8491 | 9281 | } |
---|
8492 | 9282 | |
---|