.. | .. |
---|
1979 | 1979 | // 3D models |
---|
1980 | 1980 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1981 | 1981 | { |
---|
1982 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1983 | | - LoadFile(filename, lastConverter); |
---|
| 1982 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1983 | + //LoadFile(filename, lastConverter); |
---|
| 1984 | + LoadObjFile(filename); // New 3ds loader |
---|
1984 | 1985 | continue; |
---|
1985 | 1986 | } |
---|
1986 | 1987 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2706 | 2707 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2707 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2708 | 2709 | } |
---|
| 2710 | + |
---|
2709 | 2711 | //cJME.count++; |
---|
2710 | 2712 | //cJME.count %= 12; |
---|
2711 | 2713 | if (gc) |
---|
.. | .. |
---|
2889 | 2891 | } |
---|
2890 | 2892 | } |
---|
2891 | 2893 | } |
---|
| 2894 | + |
---|
2892 | 2895 | cFileSystemPane FSPane; |
---|
2893 | 2896 | |
---|
2894 | 2897 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2942 | 2945 | } |
---|
2943 | 2946 | } |
---|
2944 | 2947 | } |
---|
| 2948 | + |
---|
2945 | 2949 | freezematerial = false; |
---|
2946 | 2950 | } |
---|
2947 | 2951 | |
---|
.. | .. |
---|
3566 | 3570 | |
---|
3567 | 3571 | public void Save() |
---|
3568 | 3572 | { |
---|
| 3573 | + // Default reduces the probability of heuristics errors. |
---|
| 3574 | + Save(true); |
---|
| 3575 | + } |
---|
| 3576 | + |
---|
| 3577 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3578 | + { |
---|
| 3579 | + if (compress.length != name.length) |
---|
| 3580 | + { |
---|
| 3581 | + return false; |
---|
| 3582 | + } |
---|
| 3583 | + |
---|
| 3584 | + for (int i=compress.length; --i>=0;) |
---|
| 3585 | + { |
---|
| 3586 | + if (compress[i] != name[i]) |
---|
| 3587 | + return false; |
---|
| 3588 | + } |
---|
| 3589 | + |
---|
| 3590 | + return true; |
---|
| 3591 | + } |
---|
| 3592 | + |
---|
| 3593 | + public boolean Save(boolean user) |
---|
| 3594 | + { |
---|
3569 | 3595 | System.err.println("Save"); |
---|
3570 | 3596 | |
---|
3571 | 3597 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3576 | 3602 | copy.ExtractBigData(hashtable); |
---|
3577 | 3603 | |
---|
3578 | 3604 | byte[] compress = Compress(copy); |
---|
3579 | | - |
---|
3580 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3581 | | - tab.graphs[tab.undoindex++] = compress; |
---|
3582 | | - |
---|
3583 | | - copy.RestoreBigData(hashtable); |
---|
3584 | 3605 | |
---|
3585 | 3606 | CameraPane.SWITCH = temp; |
---|
3586 | 3607 | |
---|
| 3608 | + boolean thesame = false; |
---|
| 3609 | + |
---|
| 3610 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3611 | + if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) |
---|
| 3612 | + { |
---|
| 3613 | + thesame = true; |
---|
| 3614 | + } |
---|
| 3615 | + |
---|
| 3616 | + //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
| 3617 | + if (!thesame) |
---|
| 3618 | + { |
---|
| 3619 | + tab.user[tab.undoindex] = user; |
---|
| 3620 | + tab.graphs[tab.undoindex++] = compress; |
---|
| 3621 | + } |
---|
| 3622 | + |
---|
| 3623 | + copy.RestoreBigData(hashtable); |
---|
| 3624 | + |
---|
3587 | 3625 | //assert(hashtable.isEmpty()); |
---|
3588 | 3626 | |
---|
3589 | 3627 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3590 | 3628 | { |
---|
| 3629 | + tab.user[i] = false; |
---|
3591 | 3630 | tab.graphs[i] = null; |
---|
3592 | 3631 | } |
---|
3593 | 3632 | |
---|
.. | .. |
---|
3611 | 3650 | e.printStackTrace(); |
---|
3612 | 3651 | } |
---|
3613 | 3652 | } |
---|
| 3653 | + |
---|
| 3654 | + return !thesame; |
---|
3614 | 3655 | } |
---|
3615 | 3656 | |
---|
3616 | 3657 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3667 | 3708 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3668 | 3709 | } |
---|
3669 | 3710 | |
---|
3670 | | - public void Undo() |
---|
| 3711 | + public boolean Undo() |
---|
3671 | 3712 | { |
---|
3672 | 3713 | System.err.println("Undo"); |
---|
3673 | 3714 | |
---|
.. | .. |
---|
3676 | 3717 | if (tab.undoindex == 0) |
---|
3677 | 3718 | { |
---|
3678 | 3719 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3679 | | - return; |
---|
| 3720 | + return false; |
---|
3680 | 3721 | } |
---|
3681 | 3722 | |
---|
3682 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3723 | + if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex]) |
---|
3683 | 3724 | { |
---|
3684 | | - Save(); |
---|
3685 | | - tab.undoindex -= 1; |
---|
| 3725 | + if (Save(false)) |
---|
| 3726 | + tab.undoindex -= 1; |
---|
| 3727 | + else |
---|
| 3728 | + { |
---|
| 3729 | + if (tab.undoindex <= 0) |
---|
| 3730 | + return false; |
---|
| 3731 | + else |
---|
| 3732 | + tab.undoindex -= 1; |
---|
| 3733 | + } |
---|
3686 | 3734 | } |
---|
3687 | 3735 | |
---|
3688 | 3736 | tab.undoindex -= 1; |
---|
3689 | 3737 | |
---|
3690 | 3738 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3739 | + |
---|
| 3740 | + return true; |
---|
3691 | 3741 | } |
---|
3692 | 3742 | |
---|
3693 | 3743 | public void Redo() |
---|
.. | .. |
---|
3703 | 3753 | tab.undoindex += 1; |
---|
3704 | 3754 | |
---|
3705 | 3755 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3756 | + |
---|
| 3757 | + if (!tab.user[tab.undoindex]) |
---|
| 3758 | + tab.graphs[tab.undoindex] = null; |
---|
3706 | 3759 | } |
---|
3707 | 3760 | |
---|
3708 | 3761 | void ImportGFD() |
---|