.. | .. |
---|
309 | 309 | //localCopy.parent = null; |
---|
310 | 310 | |
---|
311 | 311 | frame = new JFrame(); |
---|
312 | | - frame.setUndecorated(true); |
---|
| 312 | + frame.setUndecorated(false); |
---|
313 | 313 | objEditor = this; |
---|
314 | 314 | this.callee = callee; |
---|
315 | 315 | |
---|
.. | .. |
---|
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()); |
---|
.. | .. |
---|
699 | 699 | } |
---|
700 | 700 | } |
---|
701 | 701 | |
---|
702 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
703 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 702 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 703 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
704 | 704 | |
---|
705 | 705 | Rectangle keeprect; |
---|
706 | 706 | cRadio radio; |
---|
.. | .. |
---|
741 | 741 | else |
---|
742 | 742 | { |
---|
743 | 743 | keeprect = frame.getBounds(); |
---|
744 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
745 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
746 | | - frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 744 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 745 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 746 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
747 | 747 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 748 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
748 | 749 | } |
---|
749 | 750 | |
---|
750 | 751 | maximized ^= true; |
---|
.. | .. |
---|
758 | 759 | |
---|
759 | 760 | void ToggleFullScreen() |
---|
760 | 761 | { |
---|
| 762 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 763 | + |
---|
761 | 764 | cameraView.ToggleFullScreen(); |
---|
762 | 765 | |
---|
763 | 766 | if (!CameraPane.FULLSCREEN) |
---|
764 | 767 | { |
---|
765 | 768 | device.setFullScreenWindow(null); |
---|
| 769 | + frame.dispose(); |
---|
| 770 | + frame.setUndecorated(false); |
---|
766 | 771 | frame.validate(); |
---|
| 772 | + frame.setVisible(true); |
---|
767 | 773 | |
---|
768 | 774 | //frame.setVisible(false); |
---|
769 | 775 | // frame.removeNotify(); |
---|
.. | .. |
---|
774 | 780 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
775 | 781 | // X framePanel.add(bigThree); |
---|
776 | 782 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
777 | | - framePanel.setDividerLocation(1); |
---|
| 783 | + framePanel.setDividerLocation(46); |
---|
778 | 784 | |
---|
779 | 785 | //frame.setVisible(true); |
---|
780 | 786 | radio.layout = keepButton; |
---|
.. | .. |
---|
789 | 795 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
790 | 796 | // frame.getToolkit().getScreenSize().height); |
---|
791 | 797 | //frame.setVisible(false); |
---|
| 798 | + |
---|
| 799 | + frame.dispose(); |
---|
| 800 | + frame.setUndecorated(true); |
---|
792 | 801 | device.setFullScreenWindow(frame); |
---|
793 | 802 | frame.validate(); |
---|
| 803 | + frame.setVisible(true); |
---|
794 | 804 | // frame.removeNotify(); |
---|
795 | 805 | // frame.setUndecorated(true); |
---|
796 | 806 | // frame.addNotify(); |
---|
.. | .. |
---|
1164 | 1174 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1165 | 1175 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1166 | 1176 | |
---|
| 1177 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1178 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1179 | + |
---|
1167 | 1180 | if (Globals.ADVANCED) |
---|
1168 | 1181 | { |
---|
1169 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1170 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1171 | 1182 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1172 | 1183 | speedupCB.setToolTipText("Option motion capture"); |
---|
1173 | 1184 | } |
---|
.. | .. |
---|
1483 | 1494 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1484 | 1495 | // objectPanel.add(north); |
---|
1485 | 1496 | objectPanel.add(editPanel); |
---|
1486 | | - objectPanel.add(infoPanel); |
---|
| 1497 | + |
---|
| 1498 | + //if (Globals.ADVANCED) |
---|
| 1499 | + objectPanel.add(infoPanel); |
---|
| 1500 | + |
---|
1487 | 1501 | objectPanel.add(toolboxPanel); |
---|
1488 | 1502 | |
---|
1489 | 1503 | /* |
---|
.. | .. |
---|
1592 | 1606 | // aConstraints.gridheight = 1; |
---|
1593 | 1607 | |
---|
1594 | 1608 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1595 | | - framePanel.setContinuousLayout(true); |
---|
1596 | | - framePanel.setOneTouchExpandable(true); |
---|
1597 | | - framePanel.setDividerLocation(0.8); |
---|
| 1609 | + framePanel.setContinuousLayout(false); |
---|
| 1610 | + framePanel.setOneTouchExpandable(false); |
---|
| 1611 | + //.setDividerLocation(0.8); |
---|
1598 | 1612 | //framePanel.setDividerSize(15); |
---|
1599 | 1613 | //framePanel.setResizeWeight(0.15); |
---|
1600 | 1614 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1613 | 1627 | |
---|
1614 | 1628 | frame.setSize(1280, 860); |
---|
1615 | 1629 | |
---|
1616 | | - frame.validate(); |
---|
1617 | | - frame.setVisible(true); |
---|
1618 | | - |
---|
1619 | 1630 | cameraView.requestFocusInWindow(); |
---|
1620 | 1631 | |
---|
1621 | 1632 | gridPanel.setDividerLocation(1.0); |
---|
| 1633 | + |
---|
| 1634 | + frame.validate(); |
---|
| 1635 | + |
---|
| 1636 | + frame.setVisible(true); |
---|
1622 | 1637 | |
---|
1623 | 1638 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1624 | 1639 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1965 | 1980 | // 3D models |
---|
1966 | 1981 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1967 | 1982 | { |
---|
1968 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1969 | | - LoadFile(filename, lastConverter); |
---|
| 1983 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1984 | + //LoadFile(filename, lastConverter); |
---|
| 1985 | + LoadObjFile(filename); // New 3ds loader |
---|
1970 | 1986 | continue; |
---|
1971 | 1987 | } |
---|
1972 | 1988 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2692 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2693 | 2709 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2694 | 2710 | } |
---|
| 2711 | + |
---|
2695 | 2712 | //cJME.count++; |
---|
2696 | 2713 | //cJME.count %= 12; |
---|
2697 | 2714 | if (gc) |
---|
.. | .. |
---|
2875 | 2892 | } |
---|
2876 | 2893 | } |
---|
2877 | 2894 | } |
---|
| 2895 | + |
---|
2878 | 2896 | cFileSystemPane FSPane; |
---|
2879 | 2897 | |
---|
2880 | 2898 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2928 | 2946 | } |
---|
2929 | 2947 | } |
---|
2930 | 2948 | } |
---|
| 2949 | + |
---|
2931 | 2950 | freezematerial = false; |
---|
2932 | 2951 | } |
---|
2933 | 2952 | |
---|
.. | .. |
---|
3380 | 3399 | { |
---|
3381 | 3400 | Close(); |
---|
3382 | 3401 | //return true; |
---|
3383 | | - } else if (source == loadItem) |
---|
| 3402 | + } else if (source == openItem) |
---|
3384 | 3403 | { |
---|
3385 | | - load(); |
---|
| 3404 | + Open(); |
---|
3386 | 3405 | //return true; |
---|
3387 | 3406 | } else if (source == newItem) |
---|
3388 | 3407 | { |
---|
.. | .. |
---|
3407 | 3426 | { |
---|
3408 | 3427 | generatePOV(); |
---|
3409 | 3428 | //return true; |
---|
| 3429 | + } else if (event.getSource() == archiveItem) |
---|
| 3430 | + { |
---|
| 3431 | + cTools.Archive(frame); |
---|
| 3432 | + return; |
---|
3410 | 3433 | } else if (source == zBufferItem) |
---|
3411 | 3434 | { |
---|
3412 | 3435 | try |
---|
.. | .. |
---|
3458 | 3481 | try |
---|
3459 | 3482 | { |
---|
3460 | 3483 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3461 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3462 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3484 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3485 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3463 | 3486 | |
---|
3464 | 3487 | Object3D parent = o.parent; |
---|
3465 | 3488 | o.parent = null; |
---|
.. | .. |
---|
3470 | 3493 | |
---|
3471 | 3494 | out.flush(); |
---|
3472 | 3495 | |
---|
3473 | | - zstream.close(); |
---|
| 3496 | + baos //zstream |
---|
| 3497 | + .close(); |
---|
3474 | 3498 | out.close(); |
---|
3475 | 3499 | |
---|
3476 | | - return baos.toByteArray(); |
---|
| 3500 | + byte[] bytes = baos.toByteArray(); |
---|
| 3501 | + |
---|
| 3502 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3503 | + return bytes; |
---|
3477 | 3504 | } catch (Exception e) |
---|
3478 | 3505 | { |
---|
3479 | 3506 | System.err.println(e); |
---|
.. | .. |
---|
3483 | 3510 | |
---|
3484 | 3511 | static public Object Uncompress(byte[] bytes) |
---|
3485 | 3512 | { |
---|
3486 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3513 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3487 | 3514 | try |
---|
3488 | 3515 | { |
---|
3489 | 3516 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3490 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3491 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3517 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3518 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3492 | 3519 | Object obj = in.readObject(); |
---|
| 3520 | + |
---|
| 3521 | + bais //istream |
---|
| 3522 | + .close(); |
---|
3493 | 3523 | in.close(); |
---|
3494 | 3524 | |
---|
3495 | 3525 | return obj; |
---|
.. | .. |
---|
3548 | 3578 | |
---|
3549 | 3579 | public void Save() |
---|
3550 | 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 | + { |
---|
3551 | 3602 | System.err.println("Save"); |
---|
3552 | 3603 | |
---|
3553 | 3604 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3558 | 3609 | copy.ExtractBigData(hashtable); |
---|
3559 | 3610 | |
---|
3560 | 3611 | byte[] compress = Compress(copy); |
---|
3561 | | - |
---|
3562 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3563 | | - tab.graphs[tab.undoindex++] = compress; |
---|
3564 | | - |
---|
3565 | | - copy.RestoreBigData(hashtable); |
---|
3566 | 3612 | |
---|
3567 | 3613 | CameraPane.SWITCH = temp; |
---|
3568 | 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 | + |
---|
3569 | 3637 | //assert(hashtable.isEmpty()); |
---|
3570 | 3638 | |
---|
3571 | 3639 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3572 | 3640 | { |
---|
3573 | | - tab.graphs[i] = null; |
---|
| 3641 | + //tab.user[i] = false; |
---|
| 3642 | + // tab.graphs[i] = null; |
---|
3574 | 3643 | } |
---|
3575 | 3644 | |
---|
3576 | 3645 | SetUndoStates(); |
---|
.. | .. |
---|
3593 | 3662 | e.printStackTrace(); |
---|
3594 | 3663 | } |
---|
3595 | 3664 | } |
---|
| 3665 | + |
---|
| 3666 | + return !thesame; |
---|
3596 | 3667 | } |
---|
3597 | 3668 | |
---|
3598 | 3669 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3649 | 3720 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3650 | 3721 | } |
---|
3651 | 3722 | |
---|
3652 | | - public void Undo() |
---|
| 3723 | + public boolean Undo() |
---|
3653 | 3724 | { |
---|
3654 | 3725 | System.err.println("Undo"); |
---|
3655 | 3726 | |
---|
.. | .. |
---|
3658 | 3729 | if (tab.undoindex == 0) |
---|
3659 | 3730 | { |
---|
3660 | 3731 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3661 | | - return; |
---|
| 3732 | + return false; |
---|
3662 | 3733 | } |
---|
3663 | 3734 | |
---|
3664 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3735 | + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
3665 | 3736 | { |
---|
3666 | | - Save(); |
---|
3667 | | - 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 | + } |
---|
3668 | 3746 | } |
---|
3669 | 3747 | |
---|
3670 | 3748 | tab.undoindex -= 1; |
---|
3671 | 3749 | |
---|
3672 | 3750 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3751 | + |
---|
| 3752 | + return true; |
---|
3673 | 3753 | } |
---|
3674 | 3754 | |
---|
3675 | 3755 | public void Redo() |
---|
.. | .. |
---|
3685 | 3765 | tab.undoindex += 1; |
---|
3686 | 3766 | |
---|
3687 | 3767 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3768 | + |
---|
| 3769 | + //if (!tab.user[tab.undoindex]) |
---|
| 3770 | + // tab.graphs[tab.undoindex] = null; |
---|
3688 | 3771 | } |
---|
3689 | 3772 | |
---|
3690 | 3773 | void ImportGFD() |
---|
.. | .. |
---|
4647 | 4730 | |
---|
4648 | 4731 | if (readobj != null) |
---|
4649 | 4732 | { |
---|
4650 | | - if (Globals.SAVEONMAKE) |
---|
4651 | | - Save(); |
---|
| 4733 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4734 | + // Save(); |
---|
4652 | 4735 | try |
---|
4653 | 4736 | { |
---|
4654 | 4737 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4709 | 4792 | } |
---|
4710 | 4793 | } |
---|
4711 | 4794 | |
---|
4712 | | - void load() // throws ClassNotFoundException |
---|
| 4795 | + void Open() // throws ClassNotFoundException |
---|
4713 | 4796 | { |
---|
4714 | 4797 | if (Grafreed.standAlone) |
---|
4715 | 4798 | { |
---|
.. | .. |
---|
4994 | 5077 | MenuBar menuBar; |
---|
4995 | 5078 | Menu fileMenu; |
---|
4996 | 5079 | MenuItem newItem; |
---|
4997 | | - MenuItem loadItem; |
---|
| 5080 | + MenuItem openItem; |
---|
4998 | 5081 | MenuItem saveItem; |
---|
4999 | 5082 | MenuItem saveAsItem; |
---|
5000 | 5083 | MenuItem exportAsItem; |
---|
.. | .. |
---|
5017 | 5100 | CheckboxMenuItem toggleSwitchItem; |
---|
5018 | 5101 | CheckboxMenuItem toggleRootItem; |
---|
5019 | 5102 | CheckboxMenuItem animationItem; |
---|
| 5103 | + MenuItem archiveItem; |
---|
5020 | 5104 | CheckboxMenuItem toggleHandleItem; |
---|
5021 | 5105 | CheckboxMenuItem togglePaintItem; |
---|
5022 | 5106 | JSplitPane mainPanel; |
---|