.. | .. |
---|
816 | 816 | frame.validate(); |
---|
817 | 817 | } |
---|
818 | 818 | |
---|
| 819 | + private byte[] CompressCopy() |
---|
| 820 | + { |
---|
| 821 | + boolean temp = CameraPane.SWITCH; |
---|
| 822 | + CameraPane.SWITCH = false; |
---|
| 823 | + |
---|
| 824 | + copy.ExtractBigData(versiontable); |
---|
| 825 | + // if (copy == client) |
---|
| 826 | + |
---|
| 827 | + byte[] versions[] = copy.versions; |
---|
| 828 | + copy.versions = null; |
---|
| 829 | + |
---|
| 830 | + byte[] compress = Compress(copy); |
---|
| 831 | + |
---|
| 832 | + copy.versions = versions; |
---|
| 833 | + |
---|
| 834 | + copy.RestoreBigData(versiontable); |
---|
| 835 | + |
---|
| 836 | + CameraPane.SWITCH = temp; |
---|
| 837 | + |
---|
| 838 | + return compress; |
---|
| 839 | + } |
---|
| 840 | + |
---|
819 | 841 | private JTextPane createTextPane() |
---|
820 | 842 | { |
---|
821 | 843 | // TEXTAREA String[] initString = |
---|
.. | .. |
---|
1174 | 1196 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1175 | 1197 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1176 | 1198 | |
---|
| 1199 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1200 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1201 | + |
---|
1177 | 1202 | if (Globals.ADVANCED) |
---|
1178 | 1203 | { |
---|
1179 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1180 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1181 | 1204 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1182 | 1205 | speedupCB.setToolTipText("Option motion capture"); |
---|
1183 | 1206 | } |
---|
.. | .. |
---|
1979 | 2002 | // 3D models |
---|
1980 | 2003 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1981 | 2004 | { |
---|
1982 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1983 | | - LoadFile(filename, lastConverter); |
---|
| 2005 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2006 | + //LoadFile(filename, lastConverter); |
---|
| 2007 | + LoadObjFile(filename); // New 3ds loader |
---|
1984 | 2008 | continue; |
---|
1985 | 2009 | } |
---|
1986 | 2010 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2706 | 2730 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2707 | 2731 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2708 | 2732 | } |
---|
| 2733 | + |
---|
2709 | 2734 | //cJME.count++; |
---|
2710 | 2735 | //cJME.count %= 12; |
---|
2711 | 2736 | if (gc) |
---|
.. | .. |
---|
2889 | 2914 | } |
---|
2890 | 2915 | } |
---|
2891 | 2916 | } |
---|
| 2917 | + |
---|
2892 | 2918 | cFileSystemPane FSPane; |
---|
2893 | 2919 | |
---|
2894 | 2920 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2942 | 2968 | } |
---|
2943 | 2969 | } |
---|
2944 | 2970 | } |
---|
| 2971 | + |
---|
2945 | 2972 | freezematerial = false; |
---|
2946 | 2973 | } |
---|
2947 | 2974 | |
---|
.. | .. |
---|
3476 | 3503 | try |
---|
3477 | 3504 | { |
---|
3478 | 3505 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3479 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3480 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3506 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3507 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3481 | 3508 | |
---|
3482 | 3509 | Object3D parent = o.parent; |
---|
3483 | 3510 | o.parent = null; |
---|
.. | .. |
---|
3488 | 3515 | |
---|
3489 | 3516 | out.flush(); |
---|
3490 | 3517 | |
---|
3491 | | - zstream.close(); |
---|
| 3518 | + baos //zstream |
---|
| 3519 | + .close(); |
---|
3492 | 3520 | out.close(); |
---|
3493 | 3521 | |
---|
3494 | | - return baos.toByteArray(); |
---|
| 3522 | + byte[] bytes = baos.toByteArray(); |
---|
| 3523 | + |
---|
| 3524 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3525 | + return bytes; |
---|
3495 | 3526 | } catch (Exception e) |
---|
3496 | 3527 | { |
---|
3497 | 3528 | System.err.println(e); |
---|
.. | .. |
---|
3501 | 3532 | |
---|
3502 | 3533 | static public Object Uncompress(byte[] bytes) |
---|
3503 | 3534 | { |
---|
3504 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3535 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3505 | 3536 | try |
---|
3506 | 3537 | { |
---|
3507 | 3538 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3508 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3509 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3539 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3540 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3510 | 3541 | Object obj = in.readObject(); |
---|
| 3542 | + |
---|
| 3543 | + bais //istream |
---|
| 3544 | + .close(); |
---|
3511 | 3545 | in.close(); |
---|
3512 | 3546 | |
---|
3513 | 3547 | return obj; |
---|
.. | .. |
---|
3562 | 3596 | return null; |
---|
3563 | 3597 | } |
---|
3564 | 3598 | |
---|
3565 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3566 | 3599 | |
---|
3567 | 3600 | public void Save() |
---|
| 3601 | + { |
---|
| 3602 | + //Save(true); |
---|
| 3603 | + Replace(); |
---|
| 3604 | + } |
---|
| 3605 | + |
---|
| 3606 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3607 | + { |
---|
| 3608 | + if (compress.length != name.length) |
---|
| 3609 | + { |
---|
| 3610 | + return false; |
---|
| 3611 | + } |
---|
| 3612 | + |
---|
| 3613 | + for (int i=compress.length; --i>=0;) |
---|
| 3614 | + { |
---|
| 3615 | + if (compress[i] != name[i]) |
---|
| 3616 | + return false; |
---|
| 3617 | + } |
---|
| 3618 | + |
---|
| 3619 | + return true; |
---|
| 3620 | + } |
---|
| 3621 | + |
---|
| 3622 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3623 | + |
---|
| 3624 | + public boolean Save(boolean user) |
---|
3568 | 3625 | { |
---|
3569 | 3626 | System.err.println("Save"); |
---|
3570 | 3627 | |
---|
3571 | 3628 | cRadio tab = GetCurrentTab(); |
---|
3572 | 3629 | |
---|
3573 | | - boolean temp = CameraPane.SWITCH; |
---|
3574 | | - CameraPane.SWITCH = false; |
---|
| 3630 | + byte[] compress = CompressCopy(); |
---|
3575 | 3631 | |
---|
3576 | | - copy.ExtractBigData(hashtable); |
---|
| 3632 | + boolean thesame = false; |
---|
3577 | 3633 | |
---|
3578 | | - byte[] compress = Compress(copy); |
---|
| 3634 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3635 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3636 | + { |
---|
| 3637 | + thesame = true; |
---|
| 3638 | + } |
---|
3579 | 3639 | |
---|
3580 | 3640 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3581 | | - tab.graphs[tab.undoindex++] = compress; |
---|
| 3641 | + if (!thesame) |
---|
| 3642 | + { |
---|
| 3643 | + //tab.user[tab.versionindex] = user; |
---|
| 3644 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3645 | + |
---|
| 3646 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3647 | + |
---|
| 3648 | + // if (increment) |
---|
| 3649 | + // tab.versionindex++; |
---|
| 3650 | + } |
---|
3582 | 3651 | |
---|
3583 | | - copy.RestoreBigData(hashtable); |
---|
| 3652 | + //copy.RestoreBigData(versiontable); |
---|
3584 | 3653 | |
---|
3585 | | - CameraPane.SWITCH = temp; |
---|
3586 | | - |
---|
3587 | 3654 | //assert(hashtable.isEmpty()); |
---|
3588 | 3655 | |
---|
3589 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3590 | 3657 | { |
---|
3591 | | - tab.graphs[i] = null; |
---|
| 3658 | + //tab.user[i] = false; |
---|
| 3659 | + copy.versions[i] = null; |
---|
3592 | 3660 | } |
---|
3593 | 3661 | |
---|
3594 | 3662 | SetUndoStates(); |
---|
.. | .. |
---|
3598 | 3666 | { |
---|
3599 | 3667 | try |
---|
3600 | 3668 | { |
---|
3601 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3669 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3602 | 3670 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3603 | 3671 | |
---|
3604 | 3672 | p.writeObject(copy); |
---|
.. | .. |
---|
3611 | 3679 | e.printStackTrace(); |
---|
3612 | 3680 | } |
---|
3613 | 3681 | } |
---|
| 3682 | + |
---|
| 3683 | + return !thesame; |
---|
3614 | 3684 | } |
---|
3615 | 3685 | |
---|
3616 | 3686 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3620 | 3690 | boolean temp = CameraPane.SWITCH; |
---|
3621 | 3691 | CameraPane.SWITCH = false; |
---|
3622 | 3692 | |
---|
3623 | | - copy.ExtractBigData(hashtable); |
---|
| 3693 | + copy.ExtractBigData(versiontable); |
---|
3624 | 3694 | |
---|
3625 | 3695 | copy.clear(); |
---|
3626 | 3696 | |
---|
.. | .. |
---|
3629 | 3699 | copy.add(obj.get(i)); |
---|
3630 | 3700 | } |
---|
3631 | 3701 | |
---|
3632 | | - copy.RestoreBigData(hashtable); |
---|
| 3702 | + copy.RestoreBigData(versiontable); |
---|
3633 | 3703 | |
---|
3634 | 3704 | CameraPane.SWITCH = temp; |
---|
3635 | 3705 | |
---|
.. | .. |
---|
3657 | 3727 | } |
---|
3658 | 3728 | |
---|
3659 | 3729 | cButton undoButton; |
---|
| 3730 | + cButton restoreButton; |
---|
| 3731 | + cButton replaceButton; |
---|
3660 | 3732 | cButton redoButton; |
---|
3661 | 3733 | |
---|
3662 | 3734 | void SetUndoStates() |
---|
3663 | 3735 | { |
---|
3664 | 3736 | cRadio tab = GetCurrentTab(); |
---|
3665 | 3737 | |
---|
3666 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3667 | | - redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3738 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3739 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3740 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3741 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
3668 | 3742 | } |
---|
3669 | 3743 | |
---|
3670 | | - public void Undo() |
---|
| 3744 | + public boolean Undo() |
---|
3671 | 3745 | { |
---|
3672 | 3746 | System.err.println("Undo"); |
---|
3673 | 3747 | |
---|
3674 | 3748 | cRadio tab = GetCurrentTab(); |
---|
3675 | 3749 | |
---|
3676 | | - if (tab.undoindex == 0) |
---|
| 3750 | + if (copy.versionindex == 0) |
---|
3677 | 3751 | { |
---|
3678 | 3752 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3679 | | - return; |
---|
| 3753 | + return false; |
---|
3680 | 3754 | } |
---|
3681 | 3755 | |
---|
3682 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3756 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3757 | +// { |
---|
| 3758 | +// if (Save(false)) |
---|
| 3759 | +// tab.versionindex -= 1; |
---|
| 3760 | +// else |
---|
| 3761 | +// { |
---|
| 3762 | +// if (tab.versionindex <= 0) |
---|
| 3763 | +// return false; |
---|
| 3764 | +// else |
---|
| 3765 | +// tab.versionindex -= 1; |
---|
| 3766 | +// } |
---|
| 3767 | +// } |
---|
| 3768 | + |
---|
| 3769 | + copy.versionindex -= 1; |
---|
| 3770 | + |
---|
| 3771 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3772 | + |
---|
| 3773 | + return true; |
---|
| 3774 | + } |
---|
| 3775 | + |
---|
| 3776 | + public boolean Restore() |
---|
| 3777 | + { |
---|
| 3778 | + System.err.println("Restore"); |
---|
| 3779 | + |
---|
| 3780 | + cRadio tab = GetCurrentTab(); |
---|
| 3781 | + |
---|
| 3782 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3683 | 3783 | { |
---|
3684 | | - Save(); |
---|
3685 | | - tab.undoindex -= 1; |
---|
| 3784 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3785 | + return false; |
---|
3686 | 3786 | } |
---|
3687 | 3787 | |
---|
3688 | | - tab.undoindex -= 1; |
---|
| 3788 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3789 | + |
---|
| 3790 | + return true; |
---|
| 3791 | + } |
---|
3689 | 3792 | |
---|
3690 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3793 | + public boolean Replace() |
---|
| 3794 | + { |
---|
| 3795 | + System.err.println("Replace"); |
---|
| 3796 | + |
---|
| 3797 | + cRadio tab = GetCurrentTab(); |
---|
| 3798 | + |
---|
| 3799 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3800 | + { |
---|
| 3801 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3802 | + return false; |
---|
| 3803 | + } |
---|
| 3804 | + |
---|
| 3805 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
| 3806 | + |
---|
| 3807 | + return true; |
---|
3691 | 3808 | } |
---|
3692 | 3809 | |
---|
3693 | 3810 | public void Redo() |
---|
3694 | 3811 | { |
---|
3695 | 3812 | cRadio tab = GetCurrentTab(); |
---|
3696 | 3813 | |
---|
3697 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3814 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3698 | 3815 | { |
---|
3699 | 3816 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3700 | 3817 | return; |
---|
3701 | 3818 | } |
---|
3702 | 3819 | |
---|
3703 | | - tab.undoindex += 1; |
---|
| 3820 | + copy.versionindex += 1; |
---|
3704 | 3821 | |
---|
3705 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3822 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3823 | + |
---|
| 3824 | + //if (!tab.user[tab.versionindex]) |
---|
| 3825 | + // tab.graphs[tab.versionindex] = null; |
---|
3706 | 3826 | } |
---|
3707 | 3827 | |
---|
3708 | 3828 | void ImportGFD() |
---|
.. | .. |
---|
3998 | 4118 | //copy.Touch(); |
---|
3999 | 4119 | } |
---|
4000 | 4120 | |
---|
| 4121 | + cNumberSlider versionField; |
---|
| 4122 | + |
---|
4001 | 4123 | public void stateChanged(ChangeEvent e) |
---|
4002 | 4124 | { |
---|
4003 | 4125 | // assert(false); |
---|
| 4126 | + if (e.getSource() == versionField) |
---|
| 4127 | + { |
---|
| 4128 | + int version = versionField.getInteger(); |
---|
| 4129 | + |
---|
| 4130 | + if (copy.versions[version] != null) |
---|
| 4131 | + { |
---|
| 4132 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4133 | + } |
---|
| 4134 | + |
---|
| 4135 | + return; |
---|
| 4136 | + } |
---|
4004 | 4137 | |
---|
4005 | 4138 | if (freezematerial) |
---|
4006 | 4139 | { |
---|
.. | .. |
---|
4349 | 4482 | |
---|
4350 | 4483 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4351 | 4484 | { |
---|
4352 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4485 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4353 | 4486 | Save(); |
---|
4354 | 4487 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4355 | 4488 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4665 | 4798 | |
---|
4666 | 4799 | if (readobj != null) |
---|
4667 | 4800 | { |
---|
4668 | | - if (Globals.SAVEONMAKE) |
---|
4669 | | - Save(); |
---|
| 4801 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4802 | + // Save(); |
---|
4670 | 4803 | try |
---|
4671 | 4804 | { |
---|
4672 | 4805 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4721 | 4854 | c.addChild(csg); |
---|
4722 | 4855 | } |
---|
4723 | 4856 | |
---|
| 4857 | + copy.versions = readobj.versions; |
---|
| 4858 | + copy.versionindex = readobj.versionindex; |
---|
| 4859 | + |
---|
| 4860 | + SetUndoStates(); |
---|
| 4861 | + |
---|
4724 | 4862 | ResetModel(); |
---|
4725 | 4863 | copy.HardTouch(); // recompile? |
---|
4726 | 4864 | refreshContents(); |
---|