.. | .. |
---|
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.link2support = link2support; |
---|
| 119 | + other.link2master = Link2Support(); |
---|
104 | 120 | other.transformcount = transformcount; |
---|
105 | 121 | other.marked = marked; |
---|
106 | 122 | other.skip = skip; |
---|
.. | .. |
---|
220 | 236 | return; |
---|
221 | 237 | |
---|
222 | 238 | transientsupport = support; |
---|
223 | | - transientlink2master = link2support; |
---|
| 239 | + transientlink2master = Link2Support(); |
---|
224 | 240 | |
---|
225 | 241 | support = null; |
---|
226 | | - link2support = false; |
---|
| 242 | + link2master = false; |
---|
227 | 243 | |
---|
228 | 244 | if (bRep != null) |
---|
229 | 245 | { |
---|
.. | .. |
---|
247 | 263 | return; |
---|
248 | 264 | |
---|
249 | 265 | support = transientsupport; |
---|
250 | | - link2support = transientlink2master; |
---|
| 266 | + link2master = transientlink2master; |
---|
251 | 267 | transientsupport = null; |
---|
252 | 268 | transientlink2master = false; |
---|
253 | 269 | |
---|
.. | .. |
---|
633 | 649 | transient boolean keepdontselect; |
---|
634 | 650 | boolean dontselect = false; |
---|
635 | 651 | boolean hide = false; |
---|
636 | | - boolean link2support = 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 | + |
---|
637 | 656 | boolean marked = false; // animation node |
---|
638 | 657 | boolean skip = false; // centroid issue |
---|
639 | 658 | boolean skipmocap = false; // mocap data |
---|
.. | .. |
---|
654 | 673 | return this; |
---|
655 | 674 | } |
---|
656 | 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 | + |
---|
657 | 697 | void SortBySize() |
---|
658 | 698 | { |
---|
659 | | - 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(); |
---|
660 | 721 | |
---|
661 | | - while (!sorted) |
---|
| 722 | + if (sizecompare == null || sizecompare.length != count) |
---|
662 | 723 | { |
---|
663 | | - sorted = true; |
---|
664 | | - |
---|
665 | | - for (int i=0; i<Size()-1; i++) |
---|
| 724 | + sizecompare = new SizeCompare[count]; |
---|
| 725 | + |
---|
| 726 | + for (int k=0; k<count; k++) |
---|
666 | 727 | { |
---|
667 | | - Object3D obji = get(i); |
---|
668 | | - Object3D objj = get(i+1); |
---|
669 | | - |
---|
670 | | - if (obji.MemorySize() < objj.MemorySize()) |
---|
671 | | - { |
---|
672 | | - set(i, objj); |
---|
673 | | - set(i+1, obji); |
---|
674 | | - |
---|
675 | | - sorted = false; |
---|
676 | | - } |
---|
| 728 | + sizecompare[k] = new SizeCompare(get(k)); |
---|
677 | 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); |
---|
678 | 744 | } |
---|
679 | 745 | } |
---|
680 | 746 | |
---|
.. | .. |
---|
706 | 772 | |
---|
707 | 773 | int MemorySize() |
---|
708 | 774 | { |
---|
709 | | - 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) |
---|
710 | 805 | { |
---|
711 | | - try |
---|
712 | | - { |
---|
713 | | - Object3D obj = this; |
---|
| 806 | + return 0; |
---|
| 807 | + } |
---|
714 | 808 | |
---|
715 | | - Object3D parent = obj.parent; |
---|
716 | | - obj.parent = null; |
---|
717 | | - Object3D support = obj.support; |
---|
718 | | - obj.support = null; |
---|
719 | | - |
---|
720 | | - java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); |
---|
721 | | - java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos); |
---|
722 | | - |
---|
723 | | - out.writeObject(obj); |
---|
724 | | - |
---|
725 | | - obj.parent = parent; |
---|
726 | | - obj.support = support; |
---|
727 | | - |
---|
728 | | - memorysize = baos.toByteArray().length; |
---|
729 | | - } |
---|
730 | | - catch (Exception e) |
---|
731 | | - { |
---|
732 | | - e.printStackTrace(); |
---|
733 | | - } |
---|
| 809 | + int memory = 0; |
---|
| 810 | + |
---|
| 811 | + if (bRep != null) |
---|
| 812 | + { |
---|
| 813 | + memory = bRep.VertexCount(); |
---|
734 | 814 | } |
---|
735 | 815 | |
---|
736 | | - 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; |
---|
737 | 828 | } |
---|
738 | 829 | |
---|
739 | 830 | void Slower() |
---|
.. | .. |
---|
1023 | 1114 | |
---|
1024 | 1115 | void Step() |
---|
1025 | 1116 | { |
---|
1026 | | - // marde pour serialization de Texture |
---|
| 1117 | + // patch pour serialization de Texture |
---|
1027 | 1118 | resetmaxcount(); |
---|
1028 | 1119 | resettransformcount(); |
---|
1029 | 1120 | resetstep(); |
---|
.. | .. |
---|
1058 | 1149 | transformcount++; |
---|
1059 | 1150 | } |
---|
1060 | 1151 | |
---|
1061 | | - int maxcount; |
---|
| 1152 | + int maxcount = 128; |
---|
1062 | 1153 | int transformcount; |
---|
1063 | 1154 | int step; |
---|
1064 | 1155 | |
---|
.. | .. |
---|
1111 | 1202 | if (step == 0) |
---|
1112 | 1203 | step = 1; |
---|
1113 | 1204 | if (maxcount == 0) |
---|
1114 | | - maxcount = 128; // 2048; // 4; |
---|
| 1205 | + { |
---|
| 1206 | + System.out.println("maxcount == 0"); |
---|
| 1207 | + System.exit(0); // maxcount = 128; // 2048; // 4; |
---|
| 1208 | + } |
---|
1115 | 1209 | // if (acceleration == 0) |
---|
1116 | 1210 | // acceleration = 10; |
---|
1117 | 1211 | if (delay == 0) // serial |
---|
.. | .. |
---|
1137 | 1231 | (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
1138 | 1232 | currentframe != Globals.framecount) |
---|
1139 | 1233 | { |
---|
| 1234 | + Globals.lighttouched = true; |
---|
| 1235 | + |
---|
1140 | 1236 | currentframe = Globals.framecount; |
---|
1141 | 1237 | |
---|
1142 | 1238 | // System.err.println("transformcount = " + transformcount); |
---|
.. | .. |
---|
1421 | 1517 | |
---|
1422 | 1518 | blockloop = true; |
---|
1423 | 1519 | |
---|
1424 | | - other.parent = parent; |
---|
| 1520 | + // other.parent = parent; |
---|
1425 | 1521 | |
---|
1426 | 1522 | //System.out.println("COPY " + this + " to " + other); |
---|
1427 | 1523 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1457 | 1553 | Object3D obj = (Object3D)Children().get(i); |
---|
1458 | 1554 | if (IsContainedIn(obj)) |
---|
1459 | 1555 | { |
---|
1460 | | -// assert(false); // ?!?!?!?!?! |
---|
| 1556 | + assert(false); // ?!?!?!?!?! |
---|
1461 | 1557 | c.Children().setElementAt(c, i); |
---|
1462 | 1558 | } |
---|
1463 | 1559 | else |
---|
.. | .. |
---|
2202 | 2298 | { |
---|
2203 | 2299 | support = other; |
---|
2204 | 2300 | |
---|
2205 | | - link2support = support != null; |
---|
| 2301 | + link2master = support != null; |
---|
2206 | 2302 | |
---|
2207 | 2303 | if (support != null && bRep.trimmed) |
---|
2208 | 2304 | { |
---|
.. | .. |
---|
2555 | 2651 | return b; |
---|
2556 | 2652 | } |
---|
2557 | 2653 | |
---|
2558 | | - void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate) |
---|
| 2654 | + void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate, boolean colorparallax) |
---|
2559 | 2655 | { |
---|
2560 | 2656 | if (blockloop) |
---|
2561 | 2657 | { |
---|
.. | .. |
---|
2565 | 2661 | // super.UpdateMaterial(anchor, current, false); |
---|
2566 | 2662 | if (material != null) |
---|
2567 | 2663 | { |
---|
2568 | | - material.UpdateMaterial(anchor, current); |
---|
| 2664 | + material.UpdateMaterial(anchor, current, colorparallax); |
---|
2569 | 2665 | } |
---|
2570 | 2666 | |
---|
2571 | 2667 | if (!propagate) |
---|
.. | .. |
---|
2579 | 2675 | if (child == null) |
---|
2580 | 2676 | continue; |
---|
2581 | 2677 | blockloop = true; |
---|
2582 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2678 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2583 | 2679 | blockloop = false; |
---|
2584 | 2680 | Children().release(i); |
---|
2585 | 2681 | } |
---|
.. | .. |
---|
2593 | 2689 | if (child == null) |
---|
2594 | 2690 | continue; |
---|
2595 | 2691 | blockloop = true; |
---|
2596 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2692 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2597 | 2693 | blockloop = false; |
---|
2598 | 2694 | Children().release(i); |
---|
2599 | 2695 | } |
---|
.. | .. |
---|
3414 | 3510 | } |
---|
3415 | 3511 | } |
---|
3416 | 3512 | |
---|
3417 | | - public void Scale(int scale) |
---|
| 3513 | + public void Scale(float scale) |
---|
3418 | 3514 | { |
---|
3419 | 3515 | Object3D obj = this; |
---|
3420 | 3516 | |
---|
.. | .. |
---|
3921 | 4017 | //if (bRep != null) |
---|
3922 | 4018 | if (//marked || // does not make sense |
---|
3923 | 4019 | (bRep != null || material != null)) // borderline... |
---|
3924 | | - link2support = h; |
---|
| 4020 | + link2master = h; |
---|
3925 | 4021 | |
---|
3926 | 4022 | for (int i = 0; i < Size(); i++) |
---|
3927 | 4023 | { |
---|
.. | .. |
---|
4101 | 4197 | Step(); |
---|
4102 | 4198 | Touch(); |
---|
4103 | 4199 | |
---|
4104 | | - StepRecur(); |
---|
4105 | | - } |
---|
4106 | | - |
---|
4107 | | - void StepRecur() |
---|
4108 | | - { |
---|
4109 | 4200 | for (int i = 0; i < size(); i++) |
---|
4110 | 4201 | { |
---|
4111 | 4202 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
5623 | 5714 | { |
---|
5624 | 5715 | } |
---|
5625 | 5716 | // transient int displaylist = 0; // -1; |
---|
5626 | | - transient boolean touched = true; |
---|
5627 | | - 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 |
---|
5628 | 5720 | |
---|
5629 | 5721 | void Touch() |
---|
5630 | 5722 | { |
---|
.. | .. |
---|
5677 | 5769 | { |
---|
5678 | 5770 | //System.out.println("HardTouch " + this); // new Exception().printStackTrace(); |
---|
5679 | 5771 | //new Exception().printStackTrace(); |
---|
| 5772 | + reset = true; |
---|
5680 | 5773 | touched = true; |
---|
5681 | 5774 | CameraPane.touched = true; |
---|
5682 | 5775 | //if (parent != null) |
---|
.. | .. |
---|
6159 | 6252 | boolean NeedSupport() |
---|
6160 | 6253 | { |
---|
6161 | 6254 | return |
---|
6162 | | - CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2support && /*live &&*/ support != null |
---|
| 6255 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && Link2Support() && /*live &&*/ support != null |
---|
6163 | 6256 | // PROBLEM with CROWD!! |
---|
6164 | 6257 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
6165 | 6258 | } |
---|
.. | .. |
---|
6182 | 6275 | return live && bRep != null; |
---|
6183 | 6276 | } |
---|
6184 | 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 | + |
---|
6185 | 6289 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
6186 | 6290 | { |
---|
6187 | 6291 | Invariants(); // june 2013 |
---|
.. | .. |
---|
6189 | 6293 | if (support != null) |
---|
6190 | 6294 | { |
---|
6191 | 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 | + } |
---|
6192 | 6319 | } |
---|
6193 | 6320 | |
---|
6194 | 6321 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
.. | .. |
---|
6243 | 6370 | support = support; |
---|
6244 | 6371 | |
---|
6245 | 6372 | boolean usecalllists = !IsDynamic() && |
---|
6246 | | - IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2support); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
6247 | | - //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); |
---|
6248 | 6376 | |
---|
6249 | 6377 | //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
6250 | 6378 | |
---|
.. | .. |
---|
6254 | 6382 | bRep.displaylist = 0; |
---|
6255 | 6383 | } |
---|
6256 | 6384 | // usecalllists &= !(parent instanceof RandomNode); |
---|
6257 | | - // usecalllists = false; |
---|
| 6385 | + if (CameraPane.BOXMODE) // Too dynamic |
---|
| 6386 | + usecalllists = false; |
---|
6258 | 6387 | |
---|
6259 | 6388 | if (display.DrawMode() == display.SHADOW) |
---|
6260 | 6389 | //GetBRep() != null) |
---|
.. | .. |
---|
6268 | 6397 | |
---|
6269 | 6398 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
6270 | 6399 | //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
6271 | | - (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
| 6400 | + ((Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE) || touched)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
6272 | 6401 | { |
---|
6273 | 6402 | Globals.lighttouched = true; |
---|
6274 | 6403 | } // all panes... |
---|
.. | .. |
---|
6297 | 6426 | display.NewList(bRep.displaylist); |
---|
6298 | 6427 | } |
---|
6299 | 6428 | |
---|
| 6429 | + compiling = true; |
---|
6300 | 6430 | CallList(display, root, selected, blocked); |
---|
| 6431 | + compiling = false; |
---|
6301 | 6432 | |
---|
6302 | 6433 | // compiled = true; |
---|
6303 | 6434 | if (usecalllists && bRep.displaylist > 0) |
---|
.. | .. |
---|
6350 | 6481 | { |
---|
6351 | 6482 | if (display.DrawMode() == iCameraPane.SHADOW) |
---|
6352 | 6483 | { |
---|
6353 | | - if (!link2support // tricky to cull in shadow mode. |
---|
| 6484 | + if (!Link2Support() // tricky to cull in shadow mode. |
---|
6354 | 6485 | && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
6355 | 6486 | { |
---|
6356 | 6487 | //System.out.print("CULLED"); |
---|
.. | .. |
---|
6498 | 6629 | } |
---|
6499 | 6630 | } |
---|
6500 | 6631 | |
---|
6501 | | - assert (!(this instanceof Composite)); |
---|
| 6632 | + // Bezier surface: assert (!(this instanceof Composite)); |
---|
6502 | 6633 | { |
---|
6503 | 6634 | // CRASH MOCAP!! for (int i = 0; i < size(); i++) |
---|
6504 | 6635 | // { |
---|
.. | .. |
---|
6772 | 6903 | |
---|
6773 | 6904 | void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
6774 | 6905 | { |
---|
6775 | | - if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
6776 | | - return; // no shadow for transparent objects |
---|
6777 | | - |
---|
6778 | | - if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
6779 | | - 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 | + } |
---|
6780 | 6914 | |
---|
6781 | 6915 | if (hide) |
---|
6782 | 6916 | return; |
---|
6783 | | - |
---|
| 6917 | + |
---|
6784 | 6918 | if (scriptnode != null) |
---|
6785 | 6919 | { |
---|
6786 | 6920 | scriptnode.DrawNode(display, root, selected); |
---|
.. | .. |
---|
6823 | 6957 | |
---|
6824 | 6958 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
6825 | 6959 | |
---|
6826 | | - if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
| 6960 | + if (CameraPane.BOXMODE && !Link2Support()) // |
---|
| 6961 | + //!selected) // || CameraPane.movingcamera) |
---|
6827 | 6962 | { |
---|
6828 | 6963 | int fc = bRep.FaceCount(); |
---|
6829 | 6964 | int vc = bRep.VertexCount(); |
---|
.. | .. |
---|
6985 | 7120 | facescompare[k] = new FaceCompare(k); |
---|
6986 | 7121 | } |
---|
6987 | 7122 | |
---|
6988 | | - center = new cVector(); |
---|
| 7123 | + centertriangle = new cVector(); |
---|
6989 | 7124 | } |
---|
6990 | 7125 | else |
---|
6991 | 7126 | { |
---|
.. | .. |
---|
7108 | 7243 | */ |
---|
7109 | 7244 | } |
---|
7110 | 7245 | |
---|
7111 | | - transient cVector center; |
---|
| 7246 | + transient cVector centertriangle; |
---|
7112 | 7247 | |
---|
7113 | 7248 | class FaceCompare implements Comparable |
---|
7114 | 7249 | { |
---|
.. | .. |
---|
7137 | 7272 | Vertex q = bRep.GetVertex(face.q); |
---|
7138 | 7273 | Vertex r = bRep.GetVertex(face.r); |
---|
7139 | 7274 | |
---|
7140 | | - center.set(p); |
---|
7141 | | - center.add(q); |
---|
7142 | | - center.add(r); |
---|
7143 | | - center.mul(1.0/3); |
---|
| 7275 | + centertriangle.set(p); |
---|
| 7276 | + centertriangle.add(q); |
---|
| 7277 | + centertriangle.add(r); |
---|
| 7278 | + centertriangle.mul(1.0/3); |
---|
7144 | 7279 | |
---|
7145 | | - center.sub(Globals.theRenderer.EyeCamera().location); |
---|
| 7280 | + centertriangle.sub(Globals.theRenderer.EyeCamera().location); |
---|
7146 | 7281 | |
---|
7147 | | - distance = center.dot(center); |
---|
| 7282 | + distance = centertriangle.dot(centertriangle); |
---|
7148 | 7283 | } |
---|
7149 | 7284 | |
---|
7150 | 7285 | return distance; |
---|
.. | .. |
---|
8315 | 8450 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
8316 | 8451 | } else |
---|
8317 | 8452 | { |
---|
8318 | | - 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) ":"") */ ""; |
---|
8319 | 8454 | } // + super.toString(); |
---|
8320 | 8455 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
8321 | 8456 | |
---|
.. | .. |
---|
8327 | 8462 | |
---|
8328 | 8463 | public int hashCode() |
---|
8329 | 8464 | { |
---|
8330 | | - // Fuck Vector... |
---|
| 8465 | + // Do not use Vector... |
---|
8331 | 8466 | return System.identityHashCode(this); |
---|
8332 | 8467 | } |
---|
8333 | 8468 | |
---|
.. | .. |
---|
8869 | 9004 | double diry = ray.viewDirection.y; |
---|
8870 | 9005 | double dirz = ray.viewDirection.z; |
---|
8871 | 9006 | |
---|
8872 | | - if (this.fromParent != null) |
---|
| 9007 | + if (this.fromParent != null && !(this instanceof TextureNode)) |
---|
8873 | 9008 | { |
---|
8874 | 9009 | eye.x = eyex; |
---|
8875 | 9010 | eye.y = eyey; |
---|
.. | .. |
---|
8894 | 9029 | |
---|
8895 | 9030 | boolean touch = false; |
---|
8896 | 9031 | |
---|
8897 | | - if (bRep != null) |
---|
| 9032 | + if (bRep != null && Link2Support()) |
---|
8898 | 9033 | { |
---|
8899 | 9034 | if (bbox == null) |
---|
8900 | 9035 | { |
---|
.. | .. |
---|
8903 | 9038 | cVector min = new cVector(); |
---|
8904 | 9039 | cVector max = new cVector(); |
---|
8905 | 9040 | |
---|
8906 | | - this.getBounds(min, max, false); |
---|
| 9041 | + this.getBounds(min, max, true); |
---|
8907 | 9042 | |
---|
8908 | 9043 | bbox.min.x = min.x; |
---|
8909 | 9044 | bbox.min.y = min.y; |
---|
.. | .. |
---|
8914 | 9049 | bbox.max.z = max.z; |
---|
8915 | 9050 | } |
---|
8916 | 9051 | |
---|
8917 | | - if (bbox.intersect(ray, result)) |
---|
| 9052 | + if (true) // NOT WORKING bbox.intersect(ray, result)) |
---|
8918 | 9053 | { |
---|
8919 | 9054 | success |= intersectMesh(ray, result); |
---|
8920 | 9055 | } |
---|
.. | .. |
---|
8958 | 9093 | |
---|
8959 | 9094 | private boolean intersectTriangle(Ray ray, IntersectResult result, Vertex v1, Vertex v2, Vertex v3) |
---|
8960 | 9095 | { |
---|
| 9096 | + if (false) |
---|
| 9097 | + { |
---|
| 9098 | + result.t = 0; |
---|
| 9099 | + return true; |
---|
| 9100 | + } |
---|
| 9101 | + |
---|
8961 | 9102 | /* |
---|
8962 | 9103 | Fast, Minimum Storage Ray/Triangle Intersection, Moller et al. |
---|
8963 | 9104 | |
---|
.. | .. |
---|
9125 | 9266 | return -1; |
---|
9126 | 9267 | } |
---|
9127 | 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 | + } |
---|
9128 | 9281 | } |
---|
9129 | 9282 | |
---|