.. | .. |
---|
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; |
---|
.. | .. |
---|
721 | 721 | void Minimize() |
---|
722 | 722 | { |
---|
723 | 723 | frame.setState(Frame.ICONIFIED); |
---|
| 724 | + frame.validate(); |
---|
724 | 725 | } |
---|
725 | 726 | |
---|
| 727 | +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} |
---|
| 728 | +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} |
---|
| 729 | +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} |
---|
726 | 730 | void Maximize() |
---|
727 | 731 | { |
---|
| 732 | + if (CameraPane.FULLSCREEN) |
---|
| 733 | + { |
---|
| 734 | + ToggleFullScreen(); |
---|
| 735 | + } |
---|
| 736 | + |
---|
728 | 737 | if (maximized) |
---|
729 | 738 | { |
---|
730 | 739 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
732 | 741 | else |
---|
733 | 742 | { |
---|
734 | 743 | keeprect = frame.getBounds(); |
---|
735 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
736 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
737 | | - 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); |
---|
738 | 747 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 748 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
739 | 749 | } |
---|
740 | 750 | |
---|
741 | 751 | maximized ^= true; |
---|
| 752 | + |
---|
| 753 | + frame.validate(); |
---|
742 | 754 | } |
---|
| 755 | + |
---|
| 756 | + cButton minButton; |
---|
| 757 | + cButton maxButton; |
---|
| 758 | + cButton fullButton; |
---|
743 | 759 | |
---|
744 | 760 | void ToggleFullScreen() |
---|
745 | 761 | { |
---|
| 762 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 763 | + |
---|
746 | 764 | cameraView.ToggleFullScreen(); |
---|
747 | 765 | |
---|
748 | 766 | if (!CameraPane.FULLSCREEN) |
---|
749 | 767 | { |
---|
750 | 768 | device.setFullScreenWindow(null); |
---|
| 769 | + frame.dispose(); |
---|
| 770 | + frame.setUndecorated(false); |
---|
| 771 | + frame.validate(); |
---|
| 772 | + frame.setVisible(true); |
---|
| 773 | + |
---|
751 | 774 | //frame.setVisible(false); |
---|
752 | 775 | // frame.removeNotify(); |
---|
753 | 776 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
757 | 780 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
758 | 781 | // X framePanel.add(bigThree); |
---|
759 | 782 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
760 | | - framePanel.setDividerLocation(1); |
---|
| 783 | + framePanel.setDividerLocation(46); |
---|
761 | 784 | |
---|
762 | 785 | //frame.setVisible(true); |
---|
763 | 786 | radio.layout = keepButton; |
---|
.. | .. |
---|
772 | 795 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
773 | 796 | // frame.getToolkit().getScreenSize().height); |
---|
774 | 797 | //frame.setVisible(false); |
---|
| 798 | + |
---|
| 799 | + frame.dispose(); |
---|
| 800 | + frame.setUndecorated(true); |
---|
775 | 801 | device.setFullScreenWindow(frame); |
---|
| 802 | + frame.validate(); |
---|
| 803 | + frame.setVisible(true); |
---|
776 | 804 | // frame.removeNotify(); |
---|
777 | 805 | // frame.setUndecorated(true); |
---|
778 | 806 | // frame.addNotify(); |
---|
.. | .. |
---|
785 | 813 | radio.layout.doClick(); |
---|
786 | 814 | //frame.setVisible(true); |
---|
787 | 815 | } |
---|
| 816 | + frame.validate(); |
---|
788 | 817 | } |
---|
| 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 | + } |
---|
789 | 840 | |
---|
790 | 841 | private JTextPane createTextPane() |
---|
791 | 842 | { |
---|
.. | .. |
---|
1117 | 1168 | namePanel = new cGridBag(); |
---|
1118 | 1169 | |
---|
1119 | 1170 | nameField = AddText(namePanel, copy.GetName()); |
---|
1120 | | - namePanel.add(nameField); |
---|
| 1171 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
1121 | 1172 | oe.ctrlPanel.add(namePanel); |
---|
1122 | 1173 | |
---|
1123 | 1174 | oe.ctrlPanel.Return(); |
---|
.. | .. |
---|
1142 | 1193 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1143 | 1194 | rewindCB.setToolTipText("Rewind animation"); |
---|
1144 | 1195 | |
---|
1145 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1196 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1146 | 1197 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1147 | 1198 | |
---|
| 1199 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1200 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1201 | + |
---|
1148 | 1202 | if (Globals.ADVANCED) |
---|
1149 | 1203 | { |
---|
1150 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1151 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1152 | 1204 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1153 | 1205 | speedupCB.setToolTipText("Option motion capture"); |
---|
1154 | 1206 | } |
---|
.. | .. |
---|
1464 | 1516 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1465 | 1517 | // objectPanel.add(north); |
---|
1466 | 1518 | objectPanel.add(editPanel); |
---|
1467 | | - objectPanel.add(infoPanel); |
---|
| 1519 | + |
---|
| 1520 | + //if (Globals.ADVANCED) |
---|
| 1521 | + objectPanel.add(infoPanel); |
---|
| 1522 | + |
---|
1468 | 1523 | objectPanel.add(toolboxPanel); |
---|
1469 | 1524 | |
---|
1470 | 1525 | /* |
---|
.. | .. |
---|
1573 | 1628 | // aConstraints.gridheight = 1; |
---|
1574 | 1629 | |
---|
1575 | 1630 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1576 | | - framePanel.setContinuousLayout(true); |
---|
1577 | | - framePanel.setOneTouchExpandable(true); |
---|
1578 | | - framePanel.setDividerLocation(0.8); |
---|
| 1631 | + framePanel.setContinuousLayout(false); |
---|
| 1632 | + framePanel.setOneTouchExpandable(false); |
---|
| 1633 | + //.setDividerLocation(0.8); |
---|
1579 | 1634 | //framePanel.setDividerSize(15); |
---|
1580 | 1635 | //framePanel.setResizeWeight(0.15); |
---|
1581 | 1636 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1594 | 1649 | |
---|
1595 | 1650 | frame.setSize(1280, 860); |
---|
1596 | 1651 | |
---|
1597 | | - frame.validate(); |
---|
1598 | | - frame.setVisible(true); |
---|
1599 | | - |
---|
1600 | 1652 | cameraView.requestFocusInWindow(); |
---|
1601 | 1653 | |
---|
1602 | 1654 | gridPanel.setDividerLocation(1.0); |
---|
| 1655 | + |
---|
| 1656 | + frame.validate(); |
---|
| 1657 | + |
---|
| 1658 | + frame.setVisible(true); |
---|
1603 | 1659 | |
---|
1604 | 1660 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1605 | 1661 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1686 | 1742 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1687 | 1743 | colorSection.add(texture); |
---|
1688 | 1744 | |
---|
1689 | | - cGridBag anisoU = new cGridBag(); |
---|
1690 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1691 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1692 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1693 | | - colorSection.add(anisoU); |
---|
1694 | | - |
---|
1695 | | - cGridBag anisoV = new cGridBag(); |
---|
1696 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1697 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1698 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1699 | | - colorSection.add(anisoV); |
---|
1700 | | - |
---|
1701 | | - cGridBag shadowbias = new cGridBag(); |
---|
1702 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1703 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1704 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1705 | | - colorSection.add(shadowbias); |
---|
1706 | | - |
---|
1707 | 1745 | panel.add(new JSeparator()); |
---|
1708 | 1746 | |
---|
1709 | 1747 | panel.add(colorSection); |
---|
.. | .. |
---|
1753 | 1791 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1754 | 1792 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1755 | 1793 | diffuseSection.add(fakedepth); |
---|
| 1794 | + |
---|
| 1795 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1796 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1797 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1798 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1799 | + diffuseSection.add(shadowbias); |
---|
1756 | 1800 | |
---|
1757 | 1801 | panel.add(new JSeparator()); |
---|
1758 | 1802 | |
---|
.. | .. |
---|
1804 | 1848 | // aConstraints.gridy += 1; |
---|
1805 | 1849 | // aConstraints.gridwidth = 1; |
---|
1806 | 1850 | |
---|
| 1851 | + cGridBag anisoU = new cGridBag(); |
---|
| 1852 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1853 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1854 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1855 | + specularSection.add(anisoU); |
---|
| 1856 | + |
---|
| 1857 | + cGridBag anisoV = new cGridBag(); |
---|
| 1858 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1859 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1860 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1861 | + specularSection.add(anisoV); |
---|
| 1862 | + |
---|
1807 | 1863 | |
---|
1808 | 1864 | panel.add(new JSeparator()); |
---|
1809 | 1865 | |
---|
.. | .. |
---|
1811 | 1867 | |
---|
1812 | 1868 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1813 | 1869 | |
---|
1814 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1870 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1815 | 1871 | |
---|
1816 | 1872 | cGridBag camera = new cGridBag(); |
---|
1817 | 1873 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1818 | 1874 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1819 | 1875 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1820 | | - globalSection.add(camera); |
---|
| 1876 | + colorSection.add(camera); |
---|
1821 | 1877 | |
---|
1822 | 1878 | cGridBag ambient = new cGridBag(); |
---|
1823 | 1879 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1824 | 1880 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1825 | 1881 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1826 | | - globalSection.add(ambient); |
---|
| 1882 | + colorSection.add(ambient); |
---|
1827 | 1883 | |
---|
1828 | 1884 | cGridBag backlit = new cGridBag(); |
---|
1829 | 1885 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1830 | 1886 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1831 | 1887 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1832 | | - globalSection.add(backlit); |
---|
| 1888 | + colorSection.add(backlit); |
---|
1833 | 1889 | |
---|
1834 | 1890 | cGridBag opacity = new cGridBag(); |
---|
1835 | 1891 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1836 | 1892 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1837 | 1893 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1838 | | - globalSection.add(opacity); |
---|
| 1894 | + colorSection.add(opacity); |
---|
1839 | 1895 | |
---|
1840 | | - panel.add(new JSeparator()); |
---|
| 1896 | + //panel.add(new JSeparator()); |
---|
1841 | 1897 | |
---|
1842 | | - panel.add(globalSection); |
---|
| 1898 | + //panel.add(globalSection); |
---|
1843 | 1899 | |
---|
1844 | 1900 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1845 | 1901 | |
---|
.. | .. |
---|
1946 | 2002 | // 3D models |
---|
1947 | 2003 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1948 | 2004 | { |
---|
1949 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1950 | | - LoadFile(filename, lastConverter); |
---|
| 2005 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2006 | + //LoadFile(filename, lastConverter); |
---|
| 2007 | + LoadObjFile(filename); // New 3ds loader |
---|
1951 | 2008 | continue; |
---|
1952 | 2009 | } |
---|
1953 | 2010 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2673 | 2730 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2674 | 2731 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2675 | 2732 | } |
---|
| 2733 | + |
---|
2676 | 2734 | //cJME.count++; |
---|
2677 | 2735 | //cJME.count %= 12; |
---|
2678 | 2736 | if (gc) |
---|
.. | .. |
---|
2856 | 2914 | } |
---|
2857 | 2915 | } |
---|
2858 | 2916 | } |
---|
| 2917 | + |
---|
2859 | 2918 | cFileSystemPane FSPane; |
---|
2860 | 2919 | |
---|
2861 | 2920 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2909 | 2968 | } |
---|
2910 | 2969 | } |
---|
2911 | 2970 | } |
---|
| 2971 | + |
---|
2912 | 2972 | freezematerial = false; |
---|
2913 | 2973 | } |
---|
2914 | 2974 | |
---|
.. | .. |
---|
3361 | 3421 | { |
---|
3362 | 3422 | Close(); |
---|
3363 | 3423 | //return true; |
---|
3364 | | - } else if (source == loadItem) |
---|
| 3424 | + } else if (source == openItem) |
---|
3365 | 3425 | { |
---|
3366 | | - load(); |
---|
| 3426 | + Open(); |
---|
3367 | 3427 | //return true; |
---|
3368 | 3428 | } else if (source == newItem) |
---|
3369 | 3429 | { |
---|
.. | .. |
---|
3388 | 3448 | { |
---|
3389 | 3449 | generatePOV(); |
---|
3390 | 3450 | //return true; |
---|
| 3451 | + } else if (event.getSource() == archiveItem) |
---|
| 3452 | + { |
---|
| 3453 | + cTools.Archive(frame); |
---|
| 3454 | + return; |
---|
3391 | 3455 | } else if (source == zBufferItem) |
---|
3392 | 3456 | { |
---|
3393 | 3457 | try |
---|
.. | .. |
---|
3439 | 3503 | try |
---|
3440 | 3504 | { |
---|
3441 | 3505 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3442 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3443 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3506 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3507 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3444 | 3508 | |
---|
3445 | 3509 | Object3D parent = o.parent; |
---|
3446 | 3510 | o.parent = null; |
---|
.. | .. |
---|
3451 | 3515 | |
---|
3452 | 3516 | out.flush(); |
---|
3453 | 3517 | |
---|
3454 | | - zstream.close(); |
---|
| 3518 | + baos //zstream |
---|
| 3519 | + .close(); |
---|
3455 | 3520 | out.close(); |
---|
3456 | 3521 | |
---|
3457 | | - return baos.toByteArray(); |
---|
| 3522 | + byte[] bytes = baos.toByteArray(); |
---|
| 3523 | + |
---|
| 3524 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3525 | + return bytes; |
---|
3458 | 3526 | } catch (Exception e) |
---|
3459 | 3527 | { |
---|
3460 | 3528 | System.err.println(e); |
---|
.. | .. |
---|
3464 | 3532 | |
---|
3465 | 3533 | static public Object Uncompress(byte[] bytes) |
---|
3466 | 3534 | { |
---|
3467 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3535 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3468 | 3536 | try |
---|
3469 | 3537 | { |
---|
3470 | 3538 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3471 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3472 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3539 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3540 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3473 | 3541 | Object obj = in.readObject(); |
---|
| 3542 | + |
---|
| 3543 | + bais //istream |
---|
| 3544 | + .close(); |
---|
3474 | 3545 | in.close(); |
---|
3475 | 3546 | |
---|
3476 | 3547 | return obj; |
---|
.. | .. |
---|
3525 | 3596 | return null; |
---|
3526 | 3597 | } |
---|
3527 | 3598 | |
---|
3528 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3529 | 3599 | |
---|
3530 | 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) |
---|
3531 | 3625 | { |
---|
3532 | 3626 | System.err.println("Save"); |
---|
3533 | 3627 | |
---|
3534 | 3628 | cRadio tab = GetCurrentTab(); |
---|
3535 | 3629 | |
---|
3536 | | - boolean temp = CameraPane.SWITCH; |
---|
3537 | | - CameraPane.SWITCH = false; |
---|
| 3630 | + byte[] compress = CompressCopy(); |
---|
3538 | 3631 | |
---|
3539 | | - copy.ExtractBigData(hashtable); |
---|
| 3632 | + boolean thesame = false; |
---|
| 3633 | + |
---|
| 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 | + } |
---|
3540 | 3639 | |
---|
3541 | 3640 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3542 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
| 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 | + } |
---|
3543 | 3651 | |
---|
3544 | | - copy.RestoreBigData(hashtable); |
---|
| 3652 | + //copy.RestoreBigData(versiontable); |
---|
3545 | 3653 | |
---|
3546 | | - CameraPane.SWITCH = temp; |
---|
3547 | | - |
---|
3548 | 3654 | //assert(hashtable.isEmpty()); |
---|
3549 | 3655 | |
---|
3550 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3551 | 3657 | { |
---|
3552 | | - tab.graphs[i] = null; |
---|
| 3658 | + //tab.user[i] = false; |
---|
| 3659 | + copy.versions[i] = null; |
---|
3553 | 3660 | } |
---|
3554 | 3661 | |
---|
3555 | 3662 | SetUndoStates(); |
---|
.. | .. |
---|
3559 | 3666 | { |
---|
3560 | 3667 | try |
---|
3561 | 3668 | { |
---|
3562 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3669 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3563 | 3670 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3564 | 3671 | |
---|
3565 | 3672 | p.writeObject(copy); |
---|
.. | .. |
---|
3572 | 3679 | e.printStackTrace(); |
---|
3573 | 3680 | } |
---|
3574 | 3681 | } |
---|
| 3682 | + |
---|
| 3683 | + return !thesame; |
---|
3575 | 3684 | } |
---|
3576 | 3685 | |
---|
3577 | 3686 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3581 | 3690 | boolean temp = CameraPane.SWITCH; |
---|
3582 | 3691 | CameraPane.SWITCH = false; |
---|
3583 | 3692 | |
---|
3584 | | - copy.ExtractBigData(hashtable); |
---|
| 3693 | + copy.ExtractBigData(versiontable); |
---|
3585 | 3694 | |
---|
3586 | 3695 | copy.clear(); |
---|
3587 | 3696 | |
---|
.. | .. |
---|
3590 | 3699 | copy.add(obj.get(i)); |
---|
3591 | 3700 | } |
---|
3592 | 3701 | |
---|
3593 | | - copy.RestoreBigData(hashtable); |
---|
| 3702 | + copy.RestoreBigData(versiontable); |
---|
3594 | 3703 | |
---|
3595 | 3704 | CameraPane.SWITCH = temp; |
---|
3596 | 3705 | |
---|
.. | .. |
---|
3618 | 3727 | } |
---|
3619 | 3728 | |
---|
3620 | 3729 | cButton undoButton; |
---|
| 3730 | + cButton restoreButton; |
---|
| 3731 | + cButton replaceButton; |
---|
3621 | 3732 | cButton redoButton; |
---|
3622 | 3733 | |
---|
3623 | 3734 | void SetUndoStates() |
---|
3624 | 3735 | { |
---|
3625 | 3736 | cRadio tab = GetCurrentTab(); |
---|
3626 | 3737 | |
---|
3627 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3628 | | - 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); |
---|
3629 | 3742 | } |
---|
3630 | 3743 | |
---|
3631 | | - public void Undo() |
---|
| 3744 | + public boolean Undo() |
---|
3632 | 3745 | { |
---|
3633 | 3746 | System.err.println("Undo"); |
---|
3634 | 3747 | |
---|
3635 | 3748 | cRadio tab = GetCurrentTab(); |
---|
3636 | 3749 | |
---|
3637 | | - if (tab.undoindex == 0) |
---|
| 3750 | + if (copy.versionindex == 0) |
---|
3638 | 3751 | { |
---|
3639 | 3752 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3640 | | - return; |
---|
| 3753 | + return false; |
---|
3641 | 3754 | } |
---|
3642 | 3755 | |
---|
3643 | | - 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) |
---|
3644 | 3783 | { |
---|
3645 | | - Save(); |
---|
3646 | | - tab.undoindex -= 1; |
---|
| 3784 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3785 | + return false; |
---|
3647 | 3786 | } |
---|
3648 | 3787 | |
---|
3649 | | - tab.undoindex -= 1; |
---|
| 3788 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3789 | + |
---|
| 3790 | + return true; |
---|
| 3791 | + } |
---|
3650 | 3792 | |
---|
3651 | | - 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; |
---|
3652 | 3808 | } |
---|
3653 | 3809 | |
---|
3654 | 3810 | public void Redo() |
---|
3655 | 3811 | { |
---|
3656 | 3812 | cRadio tab = GetCurrentTab(); |
---|
3657 | 3813 | |
---|
3658 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3814 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3659 | 3815 | { |
---|
3660 | 3816 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3661 | 3817 | return; |
---|
3662 | 3818 | } |
---|
3663 | 3819 | |
---|
3664 | | - tab.undoindex += 1; |
---|
| 3820 | + copy.versionindex += 1; |
---|
3665 | 3821 | |
---|
3666 | | - 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; |
---|
3667 | 3826 | } |
---|
3668 | 3827 | |
---|
3669 | 3828 | void ImportGFD() |
---|
.. | .. |
---|
3959 | 4118 | //copy.Touch(); |
---|
3960 | 4119 | } |
---|
3961 | 4120 | |
---|
| 4121 | + cNumberSlider versionField; |
---|
| 4122 | + |
---|
3962 | 4123 | public void stateChanged(ChangeEvent e) |
---|
3963 | 4124 | { |
---|
3964 | 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 | + } |
---|
3965 | 4137 | |
---|
3966 | 4138 | if (freezematerial) |
---|
3967 | 4139 | { |
---|
.. | .. |
---|
4310 | 4482 | |
---|
4311 | 4483 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4312 | 4484 | { |
---|
4313 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4485 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4314 | 4486 | Save(); |
---|
4315 | 4487 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4316 | 4488 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4626 | 4798 | |
---|
4627 | 4799 | if (readobj != null) |
---|
4628 | 4800 | { |
---|
4629 | | - if (Globals.SAVEONMAKE) |
---|
4630 | | - Save(); |
---|
| 4801 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4802 | + // Save(); |
---|
4631 | 4803 | try |
---|
4632 | 4804 | { |
---|
4633 | 4805 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4682 | 4854 | c.addChild(csg); |
---|
4683 | 4855 | } |
---|
4684 | 4856 | |
---|
| 4857 | + copy.versions = readobj.versions; |
---|
| 4858 | + copy.versionindex = readobj.versionindex; |
---|
| 4859 | + |
---|
| 4860 | + SetUndoStates(); |
---|
| 4861 | + |
---|
4685 | 4862 | ResetModel(); |
---|
4686 | 4863 | copy.HardTouch(); // recompile? |
---|
4687 | 4864 | refreshContents(); |
---|
4688 | 4865 | } |
---|
4689 | 4866 | } |
---|
4690 | 4867 | |
---|
4691 | | - void load() // throws ClassNotFoundException |
---|
| 4868 | + void Open() // throws ClassNotFoundException |
---|
4692 | 4869 | { |
---|
4693 | 4870 | if (Grafreed.standAlone) |
---|
4694 | 4871 | { |
---|
.. | .. |
---|
4973 | 5150 | MenuBar menuBar; |
---|
4974 | 5151 | Menu fileMenu; |
---|
4975 | 5152 | MenuItem newItem; |
---|
4976 | | - MenuItem loadItem; |
---|
| 5153 | + MenuItem openItem; |
---|
4977 | 5154 | MenuItem saveItem; |
---|
4978 | 5155 | MenuItem saveAsItem; |
---|
4979 | 5156 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4996 | 5173 | CheckboxMenuItem toggleSwitchItem; |
---|
4997 | 5174 | CheckboxMenuItem toggleRootItem; |
---|
4998 | 5175 | CheckboxMenuItem animationItem; |
---|
| 5176 | + MenuItem archiveItem; |
---|
4999 | 5177 | CheckboxMenuItem toggleHandleItem; |
---|
5000 | 5178 | CheckboxMenuItem togglePaintItem; |
---|
5001 | 5179 | JSplitPane mainPanel; |
---|