.. | .. |
---|
41 | 41 | |
---|
42 | 42 | java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
43 | 43 | |
---|
| 44 | + transient int tabIndex; // Tabs can change between sessions. |
---|
| 45 | + |
---|
44 | 46 | ScriptNode scriptnode; |
---|
45 | 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 | + |
---|
46 | 62 | void deepCopyNode(Object3D other) |
---|
47 | 63 | { |
---|
48 | 64 | other.skyboxname = skyboxname; |
---|
.. | .. |
---|
100 | 116 | other.softtouched = softtouched; |
---|
101 | 117 | |
---|
102 | 118 | other.random = random; |
---|
103 | | - other.link2master = link2master; |
---|
| 119 | + other.link2master = Link2Support(); |
---|
104 | 120 | other.transformcount = transformcount; |
---|
105 | 121 | other.marked = marked; |
---|
106 | 122 | other.skip = skip; |
---|
.. | .. |
---|
140 | 156 | projectedVertices[i] = new cVector2(); // Others |
---|
141 | 157 | } |
---|
142 | 158 | projectedVertices[0].x = 100; // bump |
---|
| 159 | + projectedVertices[1].y = 1000; // punchthrough. only for png |
---|
143 | 160 | } |
---|
144 | 161 | |
---|
145 | 162 | void MinMax(cVector minima, cVector maxima) |
---|
.. | .. |
---|
219 | 236 | return; |
---|
220 | 237 | |
---|
221 | 238 | transientsupport = support; |
---|
222 | | - transientlink2master = link2master; |
---|
| 239 | + transientlink2master = Link2Support(); |
---|
223 | 240 | |
---|
224 | 241 | support = null; |
---|
225 | 242 | link2master = false; |
---|
.. | .. |
---|
632 | 649 | transient boolean keepdontselect; |
---|
633 | 650 | boolean dontselect = false; |
---|
634 | 651 | boolean hide = false; |
---|
635 | | - 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 | + |
---|
636 | 656 | boolean marked = false; // animation node |
---|
637 | 657 | boolean skip = false; // centroid issue |
---|
638 | 658 | boolean skipmocap = false; // mocap data |
---|
.. | .. |
---|
640 | 660 | boolean random = false; |
---|
641 | 661 | boolean speedup = false; |
---|
642 | 662 | boolean rewind = false; |
---|
| 663 | + |
---|
| 664 | + // Option to sort triangles, e.g. for transparency. |
---|
| 665 | + boolean sort = false; |
---|
643 | 666 | |
---|
644 | 667 | float NORMALPUSH = 0; |
---|
645 | 668 | |
---|
.. | .. |
---|
650 | 673 | return this; |
---|
651 | 674 | } |
---|
652 | 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 | + |
---|
653 | 697 | void SortBySize() |
---|
654 | 698 | { |
---|
655 | | - 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(); |
---|
656 | 721 | |
---|
657 | | - while (!sorted) |
---|
| 722 | + if (sizecompare == null || sizecompare.length != count) |
---|
658 | 723 | { |
---|
659 | | - sorted = true; |
---|
660 | | - |
---|
661 | | - for (int i=0; i<size()-1; i++) |
---|
| 724 | + sizecompare = new SizeCompare[count]; |
---|
| 725 | + |
---|
| 726 | + for (int k=0; k<count; k++) |
---|
662 | 727 | { |
---|
663 | | - Object3D obji = get(i); |
---|
664 | | - Object3D objj = get(i+1); |
---|
665 | | - |
---|
666 | | - if (obji.MemorySize() < objj.MemorySize()) |
---|
667 | | - { |
---|
668 | | - set(i, objj); |
---|
669 | | - set(i+1, obji); |
---|
670 | | - |
---|
671 | | - sorted = false; |
---|
672 | | - } |
---|
| 728 | + sizecompare[k] = new SizeCompare(get(k)); |
---|
673 | 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); |
---|
674 | 744 | } |
---|
675 | 745 | } |
---|
676 | 746 | |
---|
.. | .. |
---|
682 | 752 | { |
---|
683 | 753 | sorted = true; |
---|
684 | 754 | |
---|
685 | | - for (int i=0; i<size()-1; i++) |
---|
| 755 | + for (int i=0; i<Size()-1; i++) |
---|
686 | 756 | { |
---|
687 | 757 | Object3D obji = get(i); |
---|
688 | 758 | Object3D objj = get(i+1); |
---|
.. | .. |
---|
702 | 772 | |
---|
703 | 773 | int MemorySize() |
---|
704 | 774 | { |
---|
705 | | - if (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) |
---|
706 | 805 | { |
---|
707 | | - try |
---|
708 | | - { |
---|
709 | | - Object3D obj = this; |
---|
| 806 | + return 0; |
---|
| 807 | + } |
---|
710 | 808 | |
---|
711 | | - Object3D parent = obj.parent; |
---|
712 | | - obj.parent = null; |
---|
713 | | - Object3D support = obj.support; |
---|
714 | | - obj.support = null; |
---|
715 | | - |
---|
716 | | - java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); |
---|
717 | | - java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos); |
---|
718 | | - |
---|
719 | | - out.writeObject(obj); |
---|
720 | | - |
---|
721 | | - obj.parent = parent; |
---|
722 | | - obj.support = support; |
---|
723 | | - |
---|
724 | | - memorysize = baos.toByteArray().length; |
---|
725 | | - } |
---|
726 | | - catch (Exception e) |
---|
727 | | - { |
---|
728 | | - e.printStackTrace(); |
---|
729 | | - } |
---|
| 809 | + int memory = 0; |
---|
| 810 | + |
---|
| 811 | + if (bRep != null) |
---|
| 812 | + { |
---|
| 813 | + memory = bRep.VertexCount(); |
---|
730 | 814 | } |
---|
731 | 815 | |
---|
732 | | - 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; |
---|
733 | 828 | } |
---|
734 | 829 | |
---|
735 | 830 | void Slower() |
---|
.. | .. |
---|
1019 | 1114 | |
---|
1020 | 1115 | void Step() |
---|
1021 | 1116 | { |
---|
1022 | | - // marde pour serialization de Texture |
---|
| 1117 | + // patch pour serialization de Texture |
---|
1023 | 1118 | resetmaxcount(); |
---|
1024 | 1119 | resettransformcount(); |
---|
1025 | 1120 | resetstep(); |
---|
.. | .. |
---|
1054 | 1149 | transformcount++; |
---|
1055 | 1150 | } |
---|
1056 | 1151 | |
---|
1057 | | - int maxcount; |
---|
| 1152 | + int maxcount = 128; |
---|
1058 | 1153 | int transformcount; |
---|
1059 | 1154 | int step; |
---|
1060 | 1155 | |
---|
.. | .. |
---|
1107 | 1202 | if (step == 0) |
---|
1108 | 1203 | step = 1; |
---|
1109 | 1204 | if (maxcount == 0) |
---|
1110 | | - maxcount = 128; // 2048; // 4; |
---|
| 1205 | + { |
---|
| 1206 | + System.out.println("maxcount == 0"); |
---|
| 1207 | + System.exit(0); // maxcount = 128; // 2048; // 4; |
---|
| 1208 | + } |
---|
1111 | 1209 | // if (acceleration == 0) |
---|
1112 | 1210 | // acceleration = 10; |
---|
1113 | 1211 | if (delay == 0) // serial |
---|
.. | .. |
---|
1133 | 1231 | (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
1134 | 1232 | currentframe != Globals.framecount) |
---|
1135 | 1233 | { |
---|
| 1234 | + Globals.lighttouched = true; |
---|
| 1235 | + |
---|
1136 | 1236 | currentframe = Globals.framecount; |
---|
1137 | 1237 | |
---|
1138 | 1238 | // System.err.println("transformcount = " + transformcount); |
---|
.. | .. |
---|
1212 | 1312 | { |
---|
1213 | 1313 | // return true; |
---|
1214 | 1314 | |
---|
1215 | | - if (material == null || material.multiply) |
---|
1216 | | - 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; |
---|
1217 | 1323 | |
---|
1218 | | - if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
1219 | | - return false; |
---|
1220 | | - |
---|
1221 | | - // Transparent objects are dynamic because we have to sort the triangles. |
---|
1222 | | - return material.opacity > 0.99; |
---|
| 1324 | + return !sort; |
---|
1223 | 1325 | } |
---|
1224 | 1326 | |
---|
1225 | 1327 | boolean IsOpaque() |
---|
1226 | 1328 | { |
---|
1227 | 1329 | // return true; |
---|
1228 | 1330 | |
---|
1229 | | - if (material == null || material.multiply) |
---|
1230 | | - return true; |
---|
| 1331 | +// if (material == null || material.multiply) |
---|
| 1332 | +// return true; |
---|
| 1333 | +// |
---|
| 1334 | +// return material.opacity > 0.99; |
---|
1231 | 1335 | |
---|
1232 | | - return material.opacity > 0.99; |
---|
| 1336 | + return !sort; |
---|
1233 | 1337 | } |
---|
1234 | 1338 | |
---|
1235 | 1339 | Object3D() |
---|
.. | .. |
---|
1413 | 1517 | |
---|
1414 | 1518 | blockloop = true; |
---|
1415 | 1519 | |
---|
1416 | | - other.parent = parent; |
---|
| 1520 | + // other.parent = parent; |
---|
1417 | 1521 | |
---|
1418 | 1522 | //System.out.println("COPY " + this + " to " + other); |
---|
1419 | 1523 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1449 | 1553 | Object3D obj = (Object3D)Children().get(i); |
---|
1450 | 1554 | if (IsContainedIn(obj)) |
---|
1451 | 1555 | { |
---|
1452 | | -// assert(false); // ?!?!?!?!?! |
---|
| 1556 | + assert(false); // ?!?!?!?!?! |
---|
1453 | 1557 | c.Children().setElementAt(c, i); |
---|
1454 | 1558 | } |
---|
1455 | 1559 | else |
---|
.. | .. |
---|
2547 | 2651 | return b; |
---|
2548 | 2652 | } |
---|
2549 | 2653 | |
---|
2550 | | - void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate) |
---|
| 2654 | + void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate, boolean colorparallax) |
---|
2551 | 2655 | { |
---|
2552 | 2656 | if (blockloop) |
---|
2553 | 2657 | { |
---|
.. | .. |
---|
2557 | 2661 | // super.UpdateMaterial(anchor, current, false); |
---|
2558 | 2662 | if (material != null) |
---|
2559 | 2663 | { |
---|
2560 | | - material.UpdateMaterial(anchor, current); |
---|
| 2664 | + material.UpdateMaterial(anchor, current, colorparallax); |
---|
2561 | 2665 | } |
---|
2562 | 2666 | |
---|
2563 | 2667 | if (!propagate) |
---|
.. | .. |
---|
2571 | 2675 | if (child == null) |
---|
2572 | 2676 | continue; |
---|
2573 | 2677 | blockloop = true; |
---|
2574 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2678 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2575 | 2679 | blockloop = false; |
---|
2576 | 2680 | Children().release(i); |
---|
2577 | 2681 | } |
---|
.. | .. |
---|
2585 | 2689 | if (child == null) |
---|
2586 | 2690 | continue; |
---|
2587 | 2691 | blockloop = true; |
---|
2588 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2692 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2589 | 2693 | blockloop = false; |
---|
2590 | 2694 | Children().release(i); |
---|
2591 | 2695 | } |
---|
.. | .. |
---|
3406 | 3510 | } |
---|
3407 | 3511 | } |
---|
3408 | 3512 | |
---|
3409 | | - public void Scale(int scale) |
---|
| 3513 | + public void Scale(float scale) |
---|
3410 | 3514 | { |
---|
3411 | 3515 | Object3D obj = this; |
---|
3412 | 3516 | |
---|
.. | .. |
---|
4040 | 4144 | |
---|
4041 | 4145 | void RevertMeshes() |
---|
4042 | 4146 | { |
---|
| 4147 | + // BLOCKLOOP |
---|
4043 | 4148 | if (this instanceof cMesh) |
---|
4044 | 4149 | { |
---|
4045 | 4150 | ((cMesh)this).Revert(); |
---|
.. | .. |
---|
4070 | 4175 | Touch(); |
---|
4071 | 4176 | } |
---|
4072 | 4177 | |
---|
4073 | | - ResetRecur(); |
---|
4074 | | - } |
---|
4075 | | - |
---|
4076 | | - void ResetRecur() |
---|
4077 | | - { |
---|
4078 | 4178 | for (int i = 0; i < size(); i++) |
---|
4079 | 4179 | { |
---|
4080 | 4180 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
4097 | 4197 | Step(); |
---|
4098 | 4198 | Touch(); |
---|
4099 | 4199 | |
---|
4100 | | - StepRecur(); |
---|
4101 | | - } |
---|
4102 | | - |
---|
4103 | | - void StepRecur() |
---|
4104 | | - { |
---|
4105 | 4200 | for (int i = 0; i < size(); i++) |
---|
4106 | 4201 | { |
---|
4107 | 4202 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
4288 | 4383 | Touch(); |
---|
4289 | 4384 | } |
---|
4290 | 4385 | |
---|
4291 | | - transient cVector min = new cVector(); |
---|
4292 | | - transient cVector max = new cVector(); |
---|
| 4386 | + transient cVector min; |
---|
| 4387 | + transient cVector max; |
---|
4293 | 4388 | |
---|
4294 | 4389 | void getBounds(cVector minima, cVector maxima, boolean xform) |
---|
4295 | 4390 | { |
---|
.. | .. |
---|
4305 | 4400 | if (blockloop) |
---|
4306 | 4401 | return; |
---|
4307 | 4402 | |
---|
4308 | | - if (min == null) // ??? |
---|
| 4403 | + if (min == null) |
---|
4309 | 4404 | { |
---|
4310 | 4405 | min = new cVector(); |
---|
4311 | 4406 | max = new cVector(); |
---|
.. | .. |
---|
4346 | 4441 | |
---|
4347 | 4442 | if (bRep != null) |
---|
4348 | 4443 | { |
---|
4349 | | - bRep.getBounds(minima,maxima,this); |
---|
| 4444 | + bRep.getBounds(minima, maxima, xform?this:null); |
---|
4350 | 4445 | } |
---|
4351 | 4446 | |
---|
4352 | 4447 | if (false) // xform) |
---|
.. | .. |
---|
5619 | 5714 | { |
---|
5620 | 5715 | } |
---|
5621 | 5716 | // transient int displaylist = 0; // -1; |
---|
5622 | | - transient boolean touched = true; |
---|
5623 | | - 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 |
---|
5624 | 5720 | |
---|
5625 | 5721 | void Touch() |
---|
5626 | 5722 | { |
---|
.. | .. |
---|
5673 | 5769 | { |
---|
5674 | 5770 | //System.out.println("HardTouch " + this); // new Exception().printStackTrace(); |
---|
5675 | 5771 | //new Exception().printStackTrace(); |
---|
| 5772 | + reset = true; |
---|
5676 | 5773 | touched = true; |
---|
5677 | 5774 | CameraPane.touched = true; |
---|
5678 | 5775 | //if (parent != null) |
---|
.. | .. |
---|
6155 | 6252 | boolean NeedSupport() |
---|
6156 | 6253 | { |
---|
6157 | 6254 | return |
---|
6158 | | - 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 |
---|
6159 | 6256 | // PROBLEM with CROWD!! |
---|
6160 | 6257 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
6161 | 6258 | } |
---|
.. | .. |
---|
6178 | 6275 | return live && bRep != null; |
---|
6179 | 6276 | } |
---|
6180 | 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 | + |
---|
6181 | 6289 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
6182 | 6290 | { |
---|
6183 | 6291 | Invariants(); // june 2013 |
---|
.. | .. |
---|
6185 | 6293 | if (support != null) |
---|
6186 | 6294 | { |
---|
6187 | 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 | + } |
---|
6188 | 6319 | } |
---|
6189 | 6320 | |
---|
6190 | 6321 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
.. | .. |
---|
6239 | 6370 | support = support; |
---|
6240 | 6371 | |
---|
6241 | 6372 | boolean usecalllists = !IsDynamic() && |
---|
6242 | | - IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
6243 | | - //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 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); |
---|
6244 | 6376 | |
---|
6245 | 6377 | //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
6246 | 6378 | |
---|
.. | .. |
---|
6250 | 6382 | bRep.displaylist = 0; |
---|
6251 | 6383 | } |
---|
6252 | 6384 | // usecalllists &= !(parent instanceof RandomNode); |
---|
6253 | | - // usecalllists = false; |
---|
| 6385 | + if (CameraPane.BOXMODE) // Too dynamic |
---|
| 6386 | + usecalllists = false; |
---|
6254 | 6387 | |
---|
6255 | 6388 | if (display.DrawMode() == display.SHADOW) |
---|
6256 | 6389 | //GetBRep() != null) |
---|
.. | .. |
---|
6264 | 6397 | |
---|
6265 | 6398 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
6266 | 6399 | //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
6267 | | - (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
| 6400 | + ((Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE) || touched)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
6268 | 6401 | { |
---|
6269 | 6402 | Globals.lighttouched = true; |
---|
6270 | 6403 | } // all panes... |
---|
.. | .. |
---|
6293 | 6426 | display.NewList(bRep.displaylist); |
---|
6294 | 6427 | } |
---|
6295 | 6428 | |
---|
| 6429 | + compiling = true; |
---|
6296 | 6430 | CallList(display, root, selected, blocked); |
---|
| 6431 | + compiling = false; |
---|
6297 | 6432 | |
---|
6298 | 6433 | // compiled = true; |
---|
6299 | 6434 | if (usecalllists && bRep.displaylist > 0) |
---|
.. | .. |
---|
6306 | 6441 | Globals.lighttouched = true; // all panes... |
---|
6307 | 6442 | } |
---|
6308 | 6443 | |
---|
6309 | | - touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
6310 | | - //touched = false; |
---|
| 6444 | + //touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
| 6445 | + touched = false; |
---|
6311 | 6446 | |
---|
6312 | 6447 | if (this instanceof Texture || this instanceof TextureNode) |
---|
6313 | 6448 | { |
---|
.. | .. |
---|
6346 | 6481 | { |
---|
6347 | 6482 | if (display.DrawMode() == iCameraPane.SHADOW) |
---|
6348 | 6483 | { |
---|
6349 | | - if (!link2master // tricky to cull in shadow mode. |
---|
| 6484 | + if (!Link2Support() // tricky to cull in shadow mode. |
---|
6350 | 6485 | && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
6351 | 6486 | { |
---|
6352 | 6487 | //System.out.print("CULLED"); |
---|
.. | .. |
---|
6454 | 6589 | boolean failedPigment = false; |
---|
6455 | 6590 | boolean failedBump = false; |
---|
6456 | 6591 | |
---|
| 6592 | + CameraPane.lastObject = this; |
---|
6457 | 6593 | try |
---|
6458 | 6594 | { |
---|
6459 | 6595 | display.BindPigmentTexture(tex, texres); |
---|
.. | .. |
---|
6493 | 6629 | } |
---|
6494 | 6630 | } |
---|
6495 | 6631 | |
---|
6496 | | - assert (!(this instanceof Composite)); |
---|
| 6632 | + // Bezier surface: assert (!(this instanceof Composite)); |
---|
6497 | 6633 | { |
---|
6498 | 6634 | // CRASH MOCAP!! for (int i = 0; i < size(); i++) |
---|
6499 | 6635 | // { |
---|
.. | .. |
---|
6767 | 6903 | |
---|
6768 | 6904 | void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
6769 | 6905 | { |
---|
6770 | | - if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
6771 | | - return; // no shadow for transparent objects |
---|
6772 | | - |
---|
6773 | | - if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
6774 | | - 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 | + } |
---|
6775 | 6914 | |
---|
6776 | 6915 | if (hide) |
---|
6777 | 6916 | return; |
---|
6778 | | - |
---|
| 6917 | + |
---|
6779 | 6918 | if (scriptnode != null) |
---|
6780 | 6919 | { |
---|
6781 | 6920 | scriptnode.DrawNode(display, root, selected); |
---|
.. | .. |
---|
6818 | 6957 | |
---|
6819 | 6958 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
6820 | 6959 | |
---|
6821 | | - if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
| 6960 | + if (CameraPane.BOXMODE && !Link2Support()) // |
---|
| 6961 | + //!selected) // || CameraPane.movingcamera) |
---|
6822 | 6962 | { |
---|
6823 | 6963 | int fc = bRep.FaceCount(); |
---|
6824 | 6964 | int vc = bRep.VertexCount(); |
---|
.. | .. |
---|
6980 | 7120 | facescompare[k] = new FaceCompare(k); |
---|
6981 | 7121 | } |
---|
6982 | 7122 | |
---|
6983 | | - center = new cVector(); |
---|
| 7123 | + centertriangle = new cVector(); |
---|
6984 | 7124 | } |
---|
6985 | 7125 | else |
---|
6986 | 7126 | { |
---|
.. | .. |
---|
7103 | 7243 | */ |
---|
7104 | 7244 | } |
---|
7105 | 7245 | |
---|
7106 | | - transient cVector center; |
---|
| 7246 | + transient cVector centertriangle; |
---|
7107 | 7247 | |
---|
7108 | 7248 | class FaceCompare implements Comparable |
---|
7109 | 7249 | { |
---|
.. | .. |
---|
7132 | 7272 | Vertex q = bRep.GetVertex(face.q); |
---|
7133 | 7273 | Vertex r = bRep.GetVertex(face.r); |
---|
7134 | 7274 | |
---|
7135 | | - center.set(p); |
---|
7136 | | - center.add(q); |
---|
7137 | | - center.add(r); |
---|
7138 | | - center.mul(1.0/3); |
---|
| 7275 | + centertriangle.set(p); |
---|
| 7276 | + centertriangle.add(q); |
---|
| 7277 | + centertriangle.add(r); |
---|
| 7278 | + centertriangle.mul(1.0/3); |
---|
7139 | 7279 | |
---|
7140 | | - center.sub(Globals.theRenderer.EyeCamera().location); |
---|
| 7280 | + centertriangle.sub(Globals.theRenderer.EyeCamera().location); |
---|
7141 | 7281 | |
---|
7142 | | - distance = center.dot(center); |
---|
| 7282 | + distance = centertriangle.dot(centertriangle); |
---|
7143 | 7283 | } |
---|
7144 | 7284 | |
---|
7145 | 7285 | return distance; |
---|
.. | .. |
---|
8310 | 8450 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
8311 | 8451 | } else |
---|
8312 | 8452 | { |
---|
8313 | | - 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) ":"") */ ""; |
---|
8314 | 8454 | } // + super.toString(); |
---|
8315 | 8455 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
8316 | 8456 | |
---|
.. | .. |
---|
8322 | 8462 | |
---|
8323 | 8463 | public int hashCode() |
---|
8324 | 8464 | { |
---|
8325 | | - // Fuck Vector... |
---|
| 8465 | + // Do not use Vector... |
---|
8326 | 8466 | return System.identityHashCode(this); |
---|
8327 | 8467 | } |
---|
8328 | 8468 | |
---|
.. | .. |
---|
8562 | 8702 | private static cVector2 qq2 = new cVector2(); |
---|
8563 | 8703 | private static cVector2 rr2 = new cVector2(); |
---|
8564 | 8704 | private static cVector2 ss2 = new cVector2(); |
---|
8565 | | - private static cVector edge1 = new cVector(); |
---|
8566 | | - private static cVector edge2 = new cVector(); |
---|
| 8705 | +// private static cVector edge1 = new cVector(); |
---|
| 8706 | +// private static cVector edge2 = new cVector(); |
---|
8567 | 8707 | //private static cVector norm = new cVector(); |
---|
8568 | 8708 | /*transient private*/ int hitSomething; |
---|
8569 | 8709 | static final int hitCenter = 1; |
---|
.. | .. |
---|
8761 | 8901 | |
---|
8762 | 8902 | Touch(); |
---|
8763 | 8903 | } |
---|
| 8904 | + |
---|
| 8905 | + static Vertex s1 = new Vertex(); |
---|
| 8906 | + static Vertex s2 = new Vertex(); |
---|
| 8907 | + static Vertex s3 = new Vertex(); |
---|
8764 | 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 | + } |
---|
8765 | 9173 | |
---|
8766 | 9174 | public int Size() |
---|
8767 | 9175 | { |
---|
.. | .. |
---|
8858 | 9266 | return -1; |
---|
8859 | 9267 | } |
---|
8860 | 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 | + } |
---|
8861 | 9281 | } |
---|
8862 | 9282 | |
---|