.. | .. |
---|
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; |
---|
.. | .. |
---|
657 | 673 | return this; |
---|
658 | 674 | } |
---|
659 | 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 | + |
---|
660 | 697 | void SortBySize() |
---|
661 | 698 | { |
---|
662 | | - 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(); |
---|
663 | 721 | |
---|
664 | | - while (!sorted) |
---|
| 722 | + if (sizecompare == null || sizecompare.length != count) |
---|
665 | 723 | { |
---|
666 | | - sorted = true; |
---|
667 | | - |
---|
668 | | - for (int i=0; i<Size()-1; i++) |
---|
| 724 | + sizecompare = new SizeCompare[count]; |
---|
| 725 | + |
---|
| 726 | + for (int k=0; k<count; k++) |
---|
669 | 727 | { |
---|
670 | | - Object3D obji = get(i); |
---|
671 | | - Object3D objj = get(i+1); |
---|
672 | | - |
---|
673 | | - if (obji.MemorySize() < objj.MemorySize()) |
---|
674 | | - { |
---|
675 | | - set(i, objj); |
---|
676 | | - set(i+1, obji); |
---|
677 | | - |
---|
678 | | - sorted = false; |
---|
679 | | - } |
---|
| 728 | + sizecompare[k] = new SizeCompare(get(k)); |
---|
680 | 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); |
---|
681 | 744 | } |
---|
682 | 745 | } |
---|
683 | 746 | |
---|
.. | .. |
---|
709 | 772 | |
---|
710 | 773 | int MemorySize() |
---|
711 | 774 | { |
---|
712 | | - 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) |
---|
713 | 805 | { |
---|
714 | | - try |
---|
715 | | - { |
---|
716 | | - Object3D obj = this; |
---|
| 806 | + return 0; |
---|
| 807 | + } |
---|
717 | 808 | |
---|
718 | | - Object3D parent = obj.parent; |
---|
719 | | - obj.parent = null; |
---|
720 | | - Object3D support = obj.support; |
---|
721 | | - obj.support = null; |
---|
722 | | - |
---|
723 | | - java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); |
---|
724 | | - java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos); |
---|
725 | | - |
---|
726 | | - out.writeObject(obj); |
---|
727 | | - |
---|
728 | | - obj.parent = parent; |
---|
729 | | - obj.support = support; |
---|
730 | | - |
---|
731 | | - memorysize = baos.toByteArray().length; |
---|
732 | | - } |
---|
733 | | - catch (Exception e) |
---|
734 | | - { |
---|
735 | | - e.printStackTrace(); |
---|
736 | | - } |
---|
| 809 | + int memory = 0; |
---|
| 810 | + |
---|
| 811 | + if (bRep != null) |
---|
| 812 | + { |
---|
| 813 | + memory = bRep.VertexCount(); |
---|
737 | 814 | } |
---|
738 | 815 | |
---|
739 | | - 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; |
---|
740 | 828 | } |
---|
741 | 829 | |
---|
742 | 830 | void Slower() |
---|
.. | .. |
---|
1061 | 1149 | transformcount++; |
---|
1062 | 1150 | } |
---|
1063 | 1151 | |
---|
1064 | | - int maxcount; |
---|
| 1152 | + int maxcount = 128; |
---|
1065 | 1153 | int transformcount; |
---|
1066 | 1154 | int step; |
---|
1067 | 1155 | |
---|
.. | .. |
---|
1114 | 1202 | if (step == 0) |
---|
1115 | 1203 | step = 1; |
---|
1116 | 1204 | if (maxcount == 0) |
---|
1117 | | - maxcount = 128; // 2048; // 4; |
---|
| 1205 | + { |
---|
| 1206 | + System.out.println("maxcount == 0"); |
---|
| 1207 | + System.exit(0); // maxcount = 128; // 2048; // 4; |
---|
| 1208 | + } |
---|
1118 | 1209 | // if (acceleration == 0) |
---|
1119 | 1210 | // acceleration = 10; |
---|
1120 | 1211 | if (delay == 0) // serial |
---|
.. | .. |
---|
1140 | 1231 | (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
1141 | 1232 | currentframe != Globals.framecount) |
---|
1142 | 1233 | { |
---|
| 1234 | + Globals.lighttouched = true; |
---|
| 1235 | + |
---|
1143 | 1236 | currentframe = Globals.framecount; |
---|
1144 | 1237 | |
---|
1145 | 1238 | // System.err.println("transformcount = " + transformcount); |
---|
.. | .. |
---|
1424 | 1517 | |
---|
1425 | 1518 | blockloop = true; |
---|
1426 | 1519 | |
---|
1427 | | - other.parent = parent; |
---|
| 1520 | + // other.parent = parent; |
---|
1428 | 1521 | |
---|
1429 | 1522 | //System.out.println("COPY " + this + " to " + other); |
---|
1430 | 1523 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1460 | 1553 | Object3D obj = (Object3D)Children().get(i); |
---|
1461 | 1554 | if (IsContainedIn(obj)) |
---|
1462 | 1555 | { |
---|
1463 | | -// assert(false); // ?!?!?!?!?! |
---|
| 1556 | + assert(false); // ?!?!?!?!?! |
---|
1464 | 1557 | c.Children().setElementAt(c, i); |
---|
1465 | 1558 | } |
---|
1466 | 1559 | else |
---|
.. | .. |
---|
2558 | 2651 | return b; |
---|
2559 | 2652 | } |
---|
2560 | 2653 | |
---|
2561 | | - void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate) |
---|
| 2654 | + void UpdateMaterial(cMaterial anchor, cMaterial current, boolean propagate, boolean colorparallax) |
---|
2562 | 2655 | { |
---|
2563 | 2656 | if (blockloop) |
---|
2564 | 2657 | { |
---|
.. | .. |
---|
2568 | 2661 | // super.UpdateMaterial(anchor, current, false); |
---|
2569 | 2662 | if (material != null) |
---|
2570 | 2663 | { |
---|
2571 | | - material.UpdateMaterial(anchor, current); |
---|
| 2664 | + material.UpdateMaterial(anchor, current, colorparallax); |
---|
2572 | 2665 | } |
---|
2573 | 2666 | |
---|
2574 | 2667 | if (!propagate) |
---|
.. | .. |
---|
2582 | 2675 | if (child == null) |
---|
2583 | 2676 | continue; |
---|
2584 | 2677 | blockloop = true; |
---|
2585 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2678 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2586 | 2679 | blockloop = false; |
---|
2587 | 2680 | Children().release(i); |
---|
2588 | 2681 | } |
---|
.. | .. |
---|
2596 | 2689 | if (child == null) |
---|
2597 | 2690 | continue; |
---|
2598 | 2691 | blockloop = true; |
---|
2599 | | - child.UpdateMaterial(anchor, current, propagate); |
---|
| 2692 | + child.UpdateMaterial(anchor, current, propagate, false); |
---|
2600 | 2693 | blockloop = false; |
---|
2601 | 2694 | Children().release(i); |
---|
2602 | 2695 | } |
---|
.. | .. |
---|
3417 | 3510 | } |
---|
3418 | 3511 | } |
---|
3419 | 3512 | |
---|
3420 | | - public void Scale(int scale) |
---|
| 3513 | + public void Scale(float scale) |
---|
3421 | 3514 | { |
---|
3422 | 3515 | Object3D obj = this; |
---|
3423 | 3516 | |
---|
.. | .. |
---|
5621 | 5714 | { |
---|
5622 | 5715 | } |
---|
5623 | 5716 | // transient int displaylist = 0; // -1; |
---|
5624 | | - transient boolean touched = true; |
---|
5625 | | - 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 |
---|
5626 | 5720 | |
---|
5627 | 5721 | void Touch() |
---|
5628 | 5722 | { |
---|
.. | .. |
---|
5675 | 5769 | { |
---|
5676 | 5770 | //System.out.println("HardTouch " + this); // new Exception().printStackTrace(); |
---|
5677 | 5771 | //new Exception().printStackTrace(); |
---|
| 5772 | + reset = true; |
---|
5678 | 5773 | touched = true; |
---|
5679 | 5774 | CameraPane.touched = true; |
---|
5680 | 5775 | //if (parent != null) |
---|
.. | .. |
---|
6189 | 6284 | static cVector maxima = new cVector(); |
---|
6190 | 6285 | static javax.vecmath.Point3d center = new javax.vecmath.Point3d(); |
---|
6191 | 6286 | |
---|
| 6287 | + boolean compiling; |
---|
| 6288 | + |
---|
6192 | 6289 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
6193 | 6290 | { |
---|
6194 | 6291 | Invariants(); // june 2013 |
---|
.. | .. |
---|
6198 | 6295 | // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame); |
---|
6199 | 6296 | } |
---|
6200 | 6297 | |
---|
6201 | | - if (live && Link2Support() && support == null && !this.marked) // project on ground |
---|
| 6298 | + if (false) // live && Link2Support() && support == null && !this.marked) // project on ground |
---|
6202 | 6299 | { |
---|
6203 | 6300 | getBounds(minima, maxima, true); |
---|
6204 | 6301 | center.x = (minima.x + maxima.x) / 2; |
---|
.. | .. |
---|
6274 | 6371 | |
---|
6275 | 6372 | boolean usecalllists = !IsDynamic() && |
---|
6276 | 6373 | IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !Link2Support()); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
6277 | | - //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(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); |
---|
6278 | 6376 | |
---|
6279 | 6377 | //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
6280 | 6378 | |
---|
.. | .. |
---|
6299 | 6397 | |
---|
6300 | 6398 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
6301 | 6399 | //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
6302 | | - (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
| 6400 | + ((Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE) || touched)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
6303 | 6401 | { |
---|
6304 | 6402 | Globals.lighttouched = true; |
---|
6305 | 6403 | } // all panes... |
---|
.. | .. |
---|
6328 | 6426 | display.NewList(bRep.displaylist); |
---|
6329 | 6427 | } |
---|
6330 | 6428 | |
---|
| 6429 | + compiling = true; |
---|
6331 | 6430 | CallList(display, root, selected, blocked); |
---|
| 6431 | + compiling = false; |
---|
6332 | 6432 | |
---|
6333 | 6433 | // compiled = true; |
---|
6334 | 6434 | if (usecalllists && bRep.displaylist > 0) |
---|
.. | .. |
---|
6529 | 6629 | } |
---|
6530 | 6630 | } |
---|
6531 | 6631 | |
---|
6532 | | - assert (!(this instanceof Composite)); |
---|
| 6632 | + // Bezier surface: assert (!(this instanceof Composite)); |
---|
6533 | 6633 | { |
---|
6534 | 6634 | // CRASH MOCAP!! for (int i = 0; i < size(); i++) |
---|
6535 | 6635 | // { |
---|
.. | .. |
---|
6803 | 6903 | |
---|
6804 | 6904 | void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
6805 | 6905 | { |
---|
6806 | | - if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
6807 | | - return; // no shadow for transparent objects |
---|
6808 | | - |
---|
6809 | | - if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
6810 | | - 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 | + } |
---|
6811 | 6914 | |
---|
6812 | 6915 | if (hide) |
---|
6813 | 6916 | return; |
---|
6814 | | - |
---|
| 6917 | + |
---|
6815 | 6918 | if (scriptnode != null) |
---|
6816 | 6919 | { |
---|
6817 | 6920 | scriptnode.DrawNode(display, root, selected); |
---|
.. | .. |
---|
6854 | 6957 | |
---|
6855 | 6958 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
6856 | 6959 | |
---|
6857 | | - if (CameraPane.BOXMODE && !Link2Support()) //selected) // || CameraPane.movingcamera) |
---|
| 6960 | + if (CameraPane.BOXMODE && !Link2Support()) // |
---|
| 6961 | + //!selected) // || CameraPane.movingcamera) |
---|
6858 | 6962 | { |
---|
6859 | 6963 | int fc = bRep.FaceCount(); |
---|
6860 | 6964 | int vc = bRep.VertexCount(); |
---|
.. | .. |
---|
8346 | 8450 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
8347 | 8451 | } else |
---|
8348 | 8452 | { |
---|
8349 | | - 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) ":"") */ ""; |
---|
8350 | 8454 | } // + super.toString(); |
---|
8351 | 8455 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
8352 | 8456 | |
---|
.. | .. |
---|
9162 | 9266 | return -1; |
---|
9163 | 9267 | } |
---|
9164 | 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 | + } |
---|
9165 | 9281 | } |
---|
9166 | 9282 | |
---|