.. | .. |
---|
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; |
---|
.. | .. |
---|
1174 | 1174 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1175 | 1175 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1176 | 1176 | |
---|
| 1177 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1178 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1179 | + |
---|
1177 | 1180 | if (Globals.ADVANCED) |
---|
1178 | 1181 | { |
---|
1179 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1180 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1181 | 1182 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1182 | 1183 | speedupCB.setToolTipText("Option motion capture"); |
---|
1183 | 1184 | } |
---|
.. | .. |
---|
1493 | 1494 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1494 | 1495 | // objectPanel.add(north); |
---|
1495 | 1496 | objectPanel.add(editPanel); |
---|
1496 | | - objectPanel.add(infoPanel); |
---|
| 1497 | + |
---|
| 1498 | + //if (Globals.ADVANCED) |
---|
| 1499 | + objectPanel.add(infoPanel); |
---|
| 1500 | + |
---|
1497 | 1501 | objectPanel.add(toolboxPanel); |
---|
1498 | 1502 | |
---|
1499 | 1503 | /* |
---|
.. | .. |
---|
1602 | 1606 | // aConstraints.gridheight = 1; |
---|
1603 | 1607 | |
---|
1604 | 1608 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1605 | | - framePanel.setContinuousLayout(true); |
---|
1606 | | - framePanel.setOneTouchExpandable(true); |
---|
1607 | | - framePanel.setDividerLocation(0.8); |
---|
| 1609 | + framePanel.setContinuousLayout(false); |
---|
| 1610 | + framePanel.setOneTouchExpandable(false); |
---|
| 1611 | + //.setDividerLocation(0.8); |
---|
1608 | 1612 | //framePanel.setDividerSize(15); |
---|
1609 | 1613 | //framePanel.setResizeWeight(0.15); |
---|
1610 | 1614 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1976 | 1980 | // 3D models |
---|
1977 | 1981 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1978 | 1982 | { |
---|
1979 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1980 | | - LoadFile(filename, lastConverter); |
---|
| 1983 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1984 | + //LoadFile(filename, lastConverter); |
---|
| 1985 | + LoadObjFile(filename); // New 3ds loader |
---|
1981 | 1986 | continue; |
---|
1982 | 1987 | } |
---|
1983 | 1988 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2703 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2704 | 2709 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2705 | 2710 | } |
---|
| 2711 | + |
---|
2706 | 2712 | //cJME.count++; |
---|
2707 | 2713 | //cJME.count %= 12; |
---|
2708 | 2714 | if (gc) |
---|
.. | .. |
---|
2886 | 2892 | } |
---|
2887 | 2893 | } |
---|
2888 | 2894 | } |
---|
| 2895 | + |
---|
2889 | 2896 | cFileSystemPane FSPane; |
---|
2890 | 2897 | |
---|
2891 | 2898 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2939 | 2946 | } |
---|
2940 | 2947 | } |
---|
2941 | 2948 | } |
---|
| 2949 | + |
---|
2942 | 2950 | freezematerial = false; |
---|
2943 | 2951 | } |
---|
2944 | 2952 | |
---|
.. | .. |
---|
3391 | 3399 | { |
---|
3392 | 3400 | Close(); |
---|
3393 | 3401 | //return true; |
---|
3394 | | - } else if (source == loadItem) |
---|
| 3402 | + } else if (source == openItem) |
---|
3395 | 3403 | { |
---|
3396 | | - load(); |
---|
| 3404 | + Open(); |
---|
3397 | 3405 | //return true; |
---|
3398 | 3406 | } else if (source == newItem) |
---|
3399 | 3407 | { |
---|
.. | .. |
---|
3418 | 3426 | { |
---|
3419 | 3427 | generatePOV(); |
---|
3420 | 3428 | //return true; |
---|
| 3429 | + } else if (event.getSource() == archiveItem) |
---|
| 3430 | + { |
---|
| 3431 | + cTools.Archive(frame); |
---|
| 3432 | + return; |
---|
3421 | 3433 | } else if (source == zBufferItem) |
---|
3422 | 3434 | { |
---|
3423 | 3435 | try |
---|
.. | .. |
---|
3469 | 3481 | try |
---|
3470 | 3482 | { |
---|
3471 | 3483 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3472 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3473 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3484 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3485 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3474 | 3486 | |
---|
3475 | 3487 | Object3D parent = o.parent; |
---|
3476 | 3488 | o.parent = null; |
---|
.. | .. |
---|
3481 | 3493 | |
---|
3482 | 3494 | out.flush(); |
---|
3483 | 3495 | |
---|
3484 | | - zstream.close(); |
---|
| 3496 | + baos //zstream |
---|
| 3497 | + .close(); |
---|
3485 | 3498 | out.close(); |
---|
3486 | 3499 | |
---|
3487 | | - return baos.toByteArray(); |
---|
| 3500 | + byte[] bytes = baos.toByteArray(); |
---|
| 3501 | + |
---|
| 3502 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3503 | + return bytes; |
---|
3488 | 3504 | } catch (Exception e) |
---|
3489 | 3505 | { |
---|
3490 | 3506 | System.err.println(e); |
---|
.. | .. |
---|
3494 | 3510 | |
---|
3495 | 3511 | static public Object Uncompress(byte[] bytes) |
---|
3496 | 3512 | { |
---|
3497 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3513 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3498 | 3514 | try |
---|
3499 | 3515 | { |
---|
3500 | 3516 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3501 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3502 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3517 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3518 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3503 | 3519 | Object obj = in.readObject(); |
---|
| 3520 | + |
---|
| 3521 | + bais //istream |
---|
| 3522 | + .close(); |
---|
3504 | 3523 | in.close(); |
---|
3505 | 3524 | |
---|
3506 | 3525 | return obj; |
---|
.. | .. |
---|
3559 | 3578 | |
---|
3560 | 3579 | public void Save() |
---|
3561 | 3580 | { |
---|
| 3581 | + Save(true); |
---|
| 3582 | + } |
---|
| 3583 | + |
---|
| 3584 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3585 | + { |
---|
| 3586 | + if (compress.length != name.length) |
---|
| 3587 | + { |
---|
| 3588 | + return false; |
---|
| 3589 | + } |
---|
| 3590 | + |
---|
| 3591 | + for (int i=compress.length; --i>=0;) |
---|
| 3592 | + { |
---|
| 3593 | + if (compress[i] != name[i]) |
---|
| 3594 | + return false; |
---|
| 3595 | + } |
---|
| 3596 | + |
---|
| 3597 | + return true; |
---|
| 3598 | + } |
---|
| 3599 | + |
---|
| 3600 | + public boolean Save(boolean user) |
---|
| 3601 | + { |
---|
3562 | 3602 | System.err.println("Save"); |
---|
3563 | 3603 | |
---|
3564 | 3604 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3569 | 3609 | copy.ExtractBigData(hashtable); |
---|
3570 | 3610 | |
---|
3571 | 3611 | byte[] compress = Compress(copy); |
---|
3572 | | - |
---|
3573 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3574 | | - tab.graphs[tab.undoindex++] = compress; |
---|
3575 | | - |
---|
3576 | | - copy.RestoreBigData(hashtable); |
---|
3577 | 3612 | |
---|
3578 | 3613 | CameraPane.SWITCH = temp; |
---|
3579 | 3614 | |
---|
| 3615 | + boolean thesame = false; |
---|
| 3616 | + |
---|
| 3617 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3618 | + if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) |
---|
| 3619 | + { |
---|
| 3620 | + thesame = true; |
---|
| 3621 | + } |
---|
| 3622 | + |
---|
| 3623 | + //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
| 3624 | + if (!thesame) |
---|
| 3625 | + { |
---|
| 3626 | + //tab.user[tab.undoindex] = user; |
---|
| 3627 | + boolean increment = tab.graphs[tab.undoindex] == null; |
---|
| 3628 | + |
---|
| 3629 | + tab.graphs[tab.undoindex] = compress; |
---|
| 3630 | + |
---|
| 3631 | + if (increment) |
---|
| 3632 | + tab.undoindex++; |
---|
| 3633 | + } |
---|
| 3634 | + |
---|
| 3635 | + copy.RestoreBigData(hashtable); |
---|
| 3636 | + |
---|
3580 | 3637 | //assert(hashtable.isEmpty()); |
---|
3581 | 3638 | |
---|
3582 | 3639 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3583 | 3640 | { |
---|
3584 | | - tab.graphs[i] = null; |
---|
| 3641 | + //tab.user[i] = false; |
---|
| 3642 | + // tab.graphs[i] = null; |
---|
3585 | 3643 | } |
---|
3586 | 3644 | |
---|
3587 | 3645 | SetUndoStates(); |
---|
.. | .. |
---|
3604 | 3662 | e.printStackTrace(); |
---|
3605 | 3663 | } |
---|
3606 | 3664 | } |
---|
| 3665 | + |
---|
| 3666 | + return !thesame; |
---|
3607 | 3667 | } |
---|
3608 | 3668 | |
---|
3609 | 3669 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3660 | 3720 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3661 | 3721 | } |
---|
3662 | 3722 | |
---|
3663 | | - public void Undo() |
---|
| 3723 | + public boolean Undo() |
---|
3664 | 3724 | { |
---|
3665 | 3725 | System.err.println("Undo"); |
---|
3666 | 3726 | |
---|
.. | .. |
---|
3669 | 3729 | if (tab.undoindex == 0) |
---|
3670 | 3730 | { |
---|
3671 | 3731 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3672 | | - return; |
---|
| 3732 | + return false; |
---|
3673 | 3733 | } |
---|
3674 | 3734 | |
---|
3675 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3735 | + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
3676 | 3736 | { |
---|
3677 | | - Save(); |
---|
3678 | | - tab.undoindex -= 1; |
---|
| 3737 | + if (Save(false)) |
---|
| 3738 | + tab.undoindex -= 1; |
---|
| 3739 | + else |
---|
| 3740 | + { |
---|
| 3741 | + if (tab.undoindex <= 0) |
---|
| 3742 | + return false; |
---|
| 3743 | + else |
---|
| 3744 | + tab.undoindex -= 1; |
---|
| 3745 | + } |
---|
3679 | 3746 | } |
---|
3680 | 3747 | |
---|
3681 | 3748 | tab.undoindex -= 1; |
---|
3682 | 3749 | |
---|
3683 | 3750 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3751 | + |
---|
| 3752 | + return true; |
---|
3684 | 3753 | } |
---|
3685 | 3754 | |
---|
3686 | 3755 | public void Redo() |
---|
.. | .. |
---|
3696 | 3765 | tab.undoindex += 1; |
---|
3697 | 3766 | |
---|
3698 | 3767 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3768 | + |
---|
| 3769 | + //if (!tab.user[tab.undoindex]) |
---|
| 3770 | + // tab.graphs[tab.undoindex] = null; |
---|
3699 | 3771 | } |
---|
3700 | 3772 | |
---|
3701 | 3773 | void ImportGFD() |
---|
.. | .. |
---|
4658 | 4730 | |
---|
4659 | 4731 | if (readobj != null) |
---|
4660 | 4732 | { |
---|
4661 | | - if (Globals.SAVEONMAKE) |
---|
4662 | | - Save(); |
---|
| 4733 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4734 | + // Save(); |
---|
4663 | 4735 | try |
---|
4664 | 4736 | { |
---|
4665 | 4737 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4720 | 4792 | } |
---|
4721 | 4793 | } |
---|
4722 | 4794 | |
---|
4723 | | - void load() // throws ClassNotFoundException |
---|
| 4795 | + void Open() // throws ClassNotFoundException |
---|
4724 | 4796 | { |
---|
4725 | 4797 | if (Grafreed.standAlone) |
---|
4726 | 4798 | { |
---|
.. | .. |
---|
5005 | 5077 | MenuBar menuBar; |
---|
5006 | 5078 | Menu fileMenu; |
---|
5007 | 5079 | MenuItem newItem; |
---|
5008 | | - MenuItem loadItem; |
---|
| 5080 | + MenuItem openItem; |
---|
5009 | 5081 | MenuItem saveItem; |
---|
5010 | 5082 | MenuItem saveAsItem; |
---|
5011 | 5083 | MenuItem exportAsItem; |
---|
.. | .. |
---|
5028 | 5100 | CheckboxMenuItem toggleSwitchItem; |
---|
5029 | 5101 | CheckboxMenuItem toggleRootItem; |
---|
5030 | 5102 | CheckboxMenuItem animationItem; |
---|
| 5103 | + MenuItem archiveItem; |
---|
5031 | 5104 | CheckboxMenuItem toggleHandleItem; |
---|
5032 | 5105 | CheckboxMenuItem togglePaintItem; |
---|
5033 | 5106 | JSplitPane mainPanel; |
---|