.. | .. |
---|
350 | 350 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
351 | 351 | menuBar.add(fileMenu = new Menu("File")); |
---|
352 | 352 | fileMenu.add(newItem = new MenuItem("New")); |
---|
353 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 353 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
354 | 354 | |
---|
355 | 355 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
356 | 356 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
382 | 382 | } |
---|
383 | 383 | |
---|
384 | 384 | newItem.addActionListener(this); |
---|
385 | | - loadItem.addActionListener(this); |
---|
| 385 | + openItem.addActionListener(this); |
---|
386 | 386 | saveItem.addActionListener(this); |
---|
387 | 387 | saveAsItem.addActionListener(this); |
---|
388 | 388 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
449 | 449 | // TEXTAREA infoarea.setLineWrap(true); |
---|
450 | 450 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 451 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | | - //infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 452 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | 453 | infoPanel.setName("Info"); |
---|
454 | 454 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 455 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
780 | 780 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
781 | 781 | // X framePanel.add(bigThree); |
---|
782 | 782 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
783 | | - framePanel.setDividerLocation(1); |
---|
| 783 | + framePanel.setDividerLocation(46); |
---|
784 | 784 | |
---|
785 | 785 | //frame.setVisible(true); |
---|
786 | 786 | radio.layout = keepButton; |
---|
.. | .. |
---|
1493 | 1493 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1494 | 1494 | // objectPanel.add(north); |
---|
1495 | 1495 | objectPanel.add(editPanel); |
---|
1496 | | - objectPanel.add(infoPanel); |
---|
| 1496 | + |
---|
| 1497 | + //if (Globals.ADVANCED) |
---|
| 1498 | + objectPanel.add(infoPanel); |
---|
| 1499 | + |
---|
1497 | 1500 | objectPanel.add(toolboxPanel); |
---|
1498 | 1501 | |
---|
1499 | 1502 | /* |
---|
.. | .. |
---|
1602 | 1605 | // aConstraints.gridheight = 1; |
---|
1603 | 1606 | |
---|
1604 | 1607 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1605 | | - framePanel.setContinuousLayout(true); |
---|
1606 | | - framePanel.setOneTouchExpandable(true); |
---|
1607 | | - framePanel.setDividerLocation(0.8); |
---|
| 1608 | + framePanel.setContinuousLayout(false); |
---|
| 1609 | + framePanel.setOneTouchExpandable(false); |
---|
| 1610 | + //.setDividerLocation(0.8); |
---|
1608 | 1611 | //framePanel.setDividerSize(15); |
---|
1609 | 1612 | //framePanel.setResizeWeight(0.15); |
---|
1610 | 1613 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1976 | 1979 | // 3D models |
---|
1977 | 1980 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1978 | 1981 | { |
---|
1979 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1980 | | - LoadFile(filename, lastConverter); |
---|
| 1982 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1983 | + //LoadFile(filename, lastConverter); |
---|
| 1984 | + LoadObjFile(filename); // New 3ds loader |
---|
1981 | 1985 | continue; |
---|
1982 | 1986 | } |
---|
1983 | 1987 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2703 | 2707 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2704 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2705 | 2709 | } |
---|
| 2710 | + |
---|
2706 | 2711 | //cJME.count++; |
---|
2707 | 2712 | //cJME.count %= 12; |
---|
2708 | 2713 | if (gc) |
---|
.. | .. |
---|
2886 | 2891 | } |
---|
2887 | 2892 | } |
---|
2888 | 2893 | } |
---|
| 2894 | + |
---|
2889 | 2895 | cFileSystemPane FSPane; |
---|
2890 | 2896 | |
---|
2891 | 2897 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2939 | 2945 | } |
---|
2940 | 2946 | } |
---|
2941 | 2947 | } |
---|
| 2948 | + |
---|
2942 | 2949 | freezematerial = false; |
---|
2943 | 2950 | } |
---|
2944 | 2951 | |
---|
.. | .. |
---|
3391 | 3398 | { |
---|
3392 | 3399 | Close(); |
---|
3393 | 3400 | //return true; |
---|
3394 | | - } else if (source == loadItem) |
---|
| 3401 | + } else if (source == openItem) |
---|
3395 | 3402 | { |
---|
3396 | | - load(); |
---|
| 3403 | + Open(); |
---|
3397 | 3404 | //return true; |
---|
3398 | 3405 | } else if (source == newItem) |
---|
3399 | 3406 | { |
---|
.. | .. |
---|
3418 | 3425 | { |
---|
3419 | 3426 | generatePOV(); |
---|
3420 | 3427 | //return true; |
---|
| 3428 | + } else if (event.getSource() == archiveItem) |
---|
| 3429 | + { |
---|
| 3430 | + cTools.Archive(frame); |
---|
| 3431 | + return; |
---|
3421 | 3432 | } else if (source == zBufferItem) |
---|
3422 | 3433 | { |
---|
3423 | 3434 | try |
---|
.. | .. |
---|
3559 | 3570 | |
---|
3560 | 3571 | public void Save() |
---|
3561 | 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 | + { |
---|
3562 | 3595 | System.err.println("Save"); |
---|
3563 | 3596 | |
---|
3564 | 3597 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3569 | 3602 | copy.ExtractBigData(hashtable); |
---|
3570 | 3603 | |
---|
3571 | 3604 | byte[] compress = Compress(copy); |
---|
3572 | | - |
---|
3573 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3574 | | - tab.graphs[tab.undoindex++] = compress; |
---|
3575 | | - |
---|
3576 | | - copy.RestoreBigData(hashtable); |
---|
3577 | 3605 | |
---|
3578 | 3606 | CameraPane.SWITCH = temp; |
---|
3579 | 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 | + |
---|
3580 | 3625 | //assert(hashtable.isEmpty()); |
---|
3581 | 3626 | |
---|
3582 | 3627 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3583 | 3628 | { |
---|
| 3629 | + tab.user[i] = false; |
---|
3584 | 3630 | tab.graphs[i] = null; |
---|
3585 | 3631 | } |
---|
3586 | 3632 | |
---|
.. | .. |
---|
3604 | 3650 | e.printStackTrace(); |
---|
3605 | 3651 | } |
---|
3606 | 3652 | } |
---|
| 3653 | + |
---|
| 3654 | + return !thesame; |
---|
3607 | 3655 | } |
---|
3608 | 3656 | |
---|
3609 | 3657 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3660 | 3708 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3661 | 3709 | } |
---|
3662 | 3710 | |
---|
3663 | | - public void Undo() |
---|
| 3711 | + public boolean Undo() |
---|
3664 | 3712 | { |
---|
3665 | 3713 | System.err.println("Undo"); |
---|
3666 | 3714 | |
---|
.. | .. |
---|
3669 | 3717 | if (tab.undoindex == 0) |
---|
3670 | 3718 | { |
---|
3671 | 3719 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3672 | | - return; |
---|
| 3720 | + return false; |
---|
3673 | 3721 | } |
---|
3674 | 3722 | |
---|
3675 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3723 | + if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex]) |
---|
3676 | 3724 | { |
---|
3677 | | - Save(); |
---|
3678 | | - 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 | + } |
---|
3679 | 3734 | } |
---|
3680 | 3735 | |
---|
3681 | 3736 | tab.undoindex -= 1; |
---|
3682 | 3737 | |
---|
3683 | 3738 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3739 | + |
---|
| 3740 | + return true; |
---|
3684 | 3741 | } |
---|
3685 | 3742 | |
---|
3686 | 3743 | public void Redo() |
---|
.. | .. |
---|
3696 | 3753 | tab.undoindex += 1; |
---|
3697 | 3754 | |
---|
3698 | 3755 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3756 | + |
---|
| 3757 | + if (!tab.user[tab.undoindex]) |
---|
| 3758 | + tab.graphs[tab.undoindex] = null; |
---|
3699 | 3759 | } |
---|
3700 | 3760 | |
---|
3701 | 3761 | void ImportGFD() |
---|
.. | .. |
---|
4720 | 4780 | } |
---|
4721 | 4781 | } |
---|
4722 | 4782 | |
---|
4723 | | - void load() // throws ClassNotFoundException |
---|
| 4783 | + void Open() // throws ClassNotFoundException |
---|
4724 | 4784 | { |
---|
4725 | 4785 | if (Grafreed.standAlone) |
---|
4726 | 4786 | { |
---|
.. | .. |
---|
5005 | 5065 | MenuBar menuBar; |
---|
5006 | 5066 | Menu fileMenu; |
---|
5007 | 5067 | MenuItem newItem; |
---|
5008 | | - MenuItem loadItem; |
---|
| 5068 | + MenuItem openItem; |
---|
5009 | 5069 | MenuItem saveItem; |
---|
5010 | 5070 | MenuItem saveAsItem; |
---|
5011 | 5071 | MenuItem exportAsItem; |
---|
.. | .. |
---|
5028 | 5088 | CheckboxMenuItem toggleSwitchItem; |
---|
5029 | 5089 | CheckboxMenuItem toggleRootItem; |
---|
5030 | 5090 | CheckboxMenuItem animationItem; |
---|
| 5091 | + MenuItem archiveItem; |
---|
5031 | 5092 | CheckboxMenuItem toggleHandleItem; |
---|
5032 | 5093 | CheckboxMenuItem togglePaintItem; |
---|
5033 | 5094 | JSplitPane mainPanel; |
---|