.. | .. |
---|
282 | 282 | client = inClient; |
---|
283 | 283 | copy = client; |
---|
284 | 284 | |
---|
| 285 | + if (copy.versions == null) |
---|
| 286 | + { |
---|
| 287 | + copy.versions = new byte[100][]; |
---|
| 288 | + copy.versionindex = -1; |
---|
| 289 | + } |
---|
| 290 | + |
---|
285 | 291 | // "this" is not called: SetupUI2(objEditor); |
---|
286 | 292 | } |
---|
287 | 293 | |
---|
.. | .. |
---|
295 | 301 | client = inClient; |
---|
296 | 302 | copy = client; |
---|
297 | 303 | |
---|
| 304 | + if (copy.versions == null) |
---|
| 305 | + { |
---|
| 306 | + copy.versions = new byte[100][]; |
---|
| 307 | + copy.versionindex = -1; |
---|
| 308 | + } |
---|
| 309 | + |
---|
298 | 310 | SetupUI2(callee.GetEditor()); |
---|
299 | 311 | } |
---|
300 | 312 | |
---|
.. | .. |
---|
309 | 321 | //localCopy.parent = null; |
---|
310 | 322 | |
---|
311 | 323 | frame = new JFrame(); |
---|
312 | | - frame.setUndecorated(true); |
---|
| 324 | + frame.setUndecorated(false); |
---|
313 | 325 | objEditor = this; |
---|
314 | 326 | this.callee = callee; |
---|
315 | 327 | |
---|
.. | .. |
---|
327 | 339 | copy = localCopy; |
---|
328 | 340 | copy.editWindow = this; |
---|
329 | 341 | |
---|
| 342 | + if (copy.versions == null) |
---|
| 343 | + { |
---|
| 344 | + copy.versions = new byte[100][]; |
---|
| 345 | + copy.versionindex = -1; |
---|
| 346 | + } |
---|
| 347 | + |
---|
330 | 348 | SetupMenu(); |
---|
331 | 349 | |
---|
332 | 350 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
350 | 368 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
351 | 369 | menuBar.add(fileMenu = new Menu("File")); |
---|
352 | 370 | fileMenu.add(newItem = new MenuItem("New")); |
---|
353 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 371 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
354 | 372 | |
---|
355 | 373 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
356 | 374 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
382 | 400 | } |
---|
383 | 401 | |
---|
384 | 402 | newItem.addActionListener(this); |
---|
385 | | - loadItem.addActionListener(this); |
---|
| 403 | + openItem.addActionListener(this); |
---|
386 | 404 | saveItem.addActionListener(this); |
---|
387 | 405 | saveAsItem.addActionListener(this); |
---|
388 | 406 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
449 | 467 | // TEXTAREA infoarea.setLineWrap(true); |
---|
450 | 468 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 469 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 470 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | 471 | infoPanel.setName("Info"); |
---|
454 | 472 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 473 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
699 | 717 | } |
---|
700 | 718 | } |
---|
701 | 719 | |
---|
702 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
703 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 720 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 721 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
704 | 722 | |
---|
705 | 723 | Rectangle keeprect; |
---|
706 | 724 | cRadio radio; |
---|
.. | .. |
---|
721 | 739 | void Minimize() |
---|
722 | 740 | { |
---|
723 | 741 | frame.setState(Frame.ICONIFIED); |
---|
| 742 | + frame.validate(); |
---|
724 | 743 | } |
---|
725 | 744 | |
---|
| 745 | +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} |
---|
| 746 | +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} |
---|
| 747 | +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} |
---|
726 | 748 | void Maximize() |
---|
727 | 749 | { |
---|
| 750 | + if (CameraPane.FULLSCREEN) |
---|
| 751 | + { |
---|
| 752 | + ToggleFullScreen(); |
---|
| 753 | + } |
---|
| 754 | + |
---|
728 | 755 | if (maximized) |
---|
729 | 756 | { |
---|
730 | 757 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
732 | 759 | else |
---|
733 | 760 | { |
---|
734 | 761 | 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); |
---|
| 762 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 763 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 764 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
738 | 765 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 766 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
739 | 767 | } |
---|
740 | 768 | |
---|
741 | 769 | maximized ^= true; |
---|
| 770 | + |
---|
| 771 | + frame.validate(); |
---|
742 | 772 | } |
---|
| 773 | + |
---|
| 774 | + cButton minButton; |
---|
| 775 | + cButton maxButton; |
---|
| 776 | + cButton fullButton; |
---|
743 | 777 | |
---|
744 | 778 | void ToggleFullScreen() |
---|
745 | 779 | { |
---|
| 780 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 781 | + |
---|
746 | 782 | cameraView.ToggleFullScreen(); |
---|
747 | 783 | |
---|
748 | 784 | if (!CameraPane.FULLSCREEN) |
---|
749 | 785 | { |
---|
750 | 786 | device.setFullScreenWindow(null); |
---|
| 787 | + frame.dispose(); |
---|
| 788 | + frame.setUndecorated(false); |
---|
| 789 | + frame.validate(); |
---|
| 790 | + frame.setVisible(true); |
---|
| 791 | + |
---|
751 | 792 | //frame.setVisible(false); |
---|
752 | 793 | // frame.removeNotify(); |
---|
753 | 794 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
757 | 798 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
758 | 799 | // X framePanel.add(bigThree); |
---|
759 | 800 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
760 | | - framePanel.setDividerLocation(1); |
---|
| 801 | + framePanel.setDividerLocation(46); |
---|
761 | 802 | |
---|
762 | 803 | //frame.setVisible(true); |
---|
763 | 804 | radio.layout = keepButton; |
---|
.. | .. |
---|
772 | 813 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
773 | 814 | // frame.getToolkit().getScreenSize().height); |
---|
774 | 815 | //frame.setVisible(false); |
---|
| 816 | + |
---|
| 817 | + frame.dispose(); |
---|
| 818 | + frame.setUndecorated(true); |
---|
775 | 819 | device.setFullScreenWindow(frame); |
---|
| 820 | + frame.validate(); |
---|
| 821 | + frame.setVisible(true); |
---|
776 | 822 | // frame.removeNotify(); |
---|
777 | 823 | // frame.setUndecorated(true); |
---|
778 | 824 | // frame.addNotify(); |
---|
.. | .. |
---|
785 | 831 | radio.layout.doClick(); |
---|
786 | 832 | //frame.setVisible(true); |
---|
787 | 833 | } |
---|
| 834 | + frame.validate(); |
---|
788 | 835 | } |
---|
| 836 | + |
---|
| 837 | + private byte[] CompressCopy() |
---|
| 838 | + { |
---|
| 839 | + boolean temp = CameraPane.SWITCH; |
---|
| 840 | + CameraPane.SWITCH = false; |
---|
| 841 | + |
---|
| 842 | + copy.ExtractBigData(versiontable); |
---|
| 843 | + // if (copy == client) |
---|
| 844 | + |
---|
| 845 | + byte[] versions[] = copy.versions; |
---|
| 846 | + copy.versions = null; |
---|
| 847 | + |
---|
| 848 | + byte[] compress = Compress(copy); |
---|
| 849 | + |
---|
| 850 | + copy.versions = versions; |
---|
| 851 | + |
---|
| 852 | + copy.RestoreBigData(versiontable); |
---|
| 853 | + |
---|
| 854 | + CameraPane.SWITCH = temp; |
---|
| 855 | + |
---|
| 856 | + return compress; |
---|
| 857 | + } |
---|
789 | 858 | |
---|
790 | 859 | private JTextPane createTextPane() |
---|
791 | 860 | { |
---|
.. | .. |
---|
1117 | 1186 | namePanel = new cGridBag(); |
---|
1118 | 1187 | |
---|
1119 | 1188 | nameField = AddText(namePanel, copy.GetName()); |
---|
1120 | | - namePanel.add(nameField); |
---|
| 1189 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
1121 | 1190 | oe.ctrlPanel.add(namePanel); |
---|
1122 | 1191 | |
---|
1123 | 1192 | oe.ctrlPanel.Return(); |
---|
.. | .. |
---|
1142 | 1211 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1143 | 1212 | rewindCB.setToolTipText("Rewind animation"); |
---|
1144 | 1213 | |
---|
1145 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1214 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1146 | 1215 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1147 | 1216 | |
---|
| 1217 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1218 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1219 | + |
---|
1148 | 1220 | if (Globals.ADVANCED) |
---|
1149 | 1221 | { |
---|
1150 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1151 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1152 | 1222 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1153 | 1223 | speedupCB.setToolTipText("Option motion capture"); |
---|
1154 | 1224 | } |
---|
.. | .. |
---|
1464 | 1534 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1465 | 1535 | // objectPanel.add(north); |
---|
1466 | 1536 | objectPanel.add(editPanel); |
---|
1467 | | - objectPanel.add(infoPanel); |
---|
| 1537 | + |
---|
| 1538 | + //if (Globals.ADVANCED) |
---|
| 1539 | + objectPanel.add(infoPanel); |
---|
| 1540 | + |
---|
1468 | 1541 | objectPanel.add(toolboxPanel); |
---|
1469 | 1542 | |
---|
1470 | 1543 | /* |
---|
.. | .. |
---|
1573 | 1646 | // aConstraints.gridheight = 1; |
---|
1574 | 1647 | |
---|
1575 | 1648 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1576 | | - framePanel.setContinuousLayout(true); |
---|
1577 | | - framePanel.setOneTouchExpandable(true); |
---|
1578 | | - framePanel.setDividerLocation(0.8); |
---|
| 1649 | + framePanel.setContinuousLayout(false); |
---|
| 1650 | + framePanel.setOneTouchExpandable(false); |
---|
| 1651 | + //.setDividerLocation(0.8); |
---|
1579 | 1652 | //framePanel.setDividerSize(15); |
---|
1580 | 1653 | //framePanel.setResizeWeight(0.15); |
---|
1581 | 1654 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1594 | 1667 | |
---|
1595 | 1668 | frame.setSize(1280, 860); |
---|
1596 | 1669 | |
---|
1597 | | - frame.validate(); |
---|
1598 | | - frame.setVisible(true); |
---|
1599 | | - |
---|
1600 | 1670 | cameraView.requestFocusInWindow(); |
---|
1601 | 1671 | |
---|
1602 | 1672 | gridPanel.setDividerLocation(1.0); |
---|
| 1673 | + |
---|
| 1674 | + frame.validate(); |
---|
| 1675 | + |
---|
| 1676 | + frame.setVisible(true); |
---|
1603 | 1677 | |
---|
1604 | 1678 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1605 | 1679 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1686 | 1760 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1687 | 1761 | colorSection.add(texture); |
---|
1688 | 1762 | |
---|
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 | 1763 | panel.add(new JSeparator()); |
---|
1708 | 1764 | |
---|
1709 | 1765 | panel.add(colorSection); |
---|
.. | .. |
---|
1753 | 1809 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1754 | 1810 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1755 | 1811 | diffuseSection.add(fakedepth); |
---|
| 1812 | + |
---|
| 1813 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1814 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1815 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1816 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1817 | + diffuseSection.add(shadowbias); |
---|
1756 | 1818 | |
---|
1757 | 1819 | panel.add(new JSeparator()); |
---|
1758 | 1820 | |
---|
.. | .. |
---|
1804 | 1866 | // aConstraints.gridy += 1; |
---|
1805 | 1867 | // aConstraints.gridwidth = 1; |
---|
1806 | 1868 | |
---|
| 1869 | + cGridBag anisoU = new cGridBag(); |
---|
| 1870 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1871 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1872 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1873 | + specularSection.add(anisoU); |
---|
| 1874 | + |
---|
| 1875 | + cGridBag anisoV = new cGridBag(); |
---|
| 1876 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1877 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1878 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1879 | + specularSection.add(anisoV); |
---|
| 1880 | + |
---|
1807 | 1881 | |
---|
1808 | 1882 | panel.add(new JSeparator()); |
---|
1809 | 1883 | |
---|
.. | .. |
---|
1811 | 1885 | |
---|
1812 | 1886 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1813 | 1887 | |
---|
1814 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1888 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1815 | 1889 | |
---|
1816 | 1890 | cGridBag camera = new cGridBag(); |
---|
1817 | 1891 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1818 | 1892 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1819 | 1893 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1820 | | - globalSection.add(camera); |
---|
| 1894 | + colorSection.add(camera); |
---|
1821 | 1895 | |
---|
1822 | 1896 | cGridBag ambient = new cGridBag(); |
---|
1823 | 1897 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1824 | 1898 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1825 | 1899 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1826 | | - globalSection.add(ambient); |
---|
| 1900 | + colorSection.add(ambient); |
---|
1827 | 1901 | |
---|
1828 | 1902 | cGridBag backlit = new cGridBag(); |
---|
1829 | 1903 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1830 | 1904 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1831 | 1905 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1832 | | - globalSection.add(backlit); |
---|
| 1906 | + colorSection.add(backlit); |
---|
1833 | 1907 | |
---|
1834 | 1908 | cGridBag opacity = new cGridBag(); |
---|
1835 | 1909 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1836 | 1910 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1837 | 1911 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1838 | | - globalSection.add(opacity); |
---|
| 1912 | + colorSection.add(opacity); |
---|
1839 | 1913 | |
---|
1840 | | - panel.add(new JSeparator()); |
---|
| 1914 | + //panel.add(new JSeparator()); |
---|
1841 | 1915 | |
---|
1842 | | - panel.add(globalSection); |
---|
| 1916 | + //panel.add(globalSection); |
---|
1843 | 1917 | |
---|
1844 | 1918 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1845 | 1919 | |
---|
.. | .. |
---|
1946 | 2020 | // 3D models |
---|
1947 | 2021 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1948 | 2022 | { |
---|
1949 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1950 | | - LoadFile(filename, lastConverter); |
---|
| 2023 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2024 | + //LoadFile(filename, lastConverter); |
---|
| 2025 | + LoadObjFile(filename); // New 3ds loader |
---|
1951 | 2026 | continue; |
---|
1952 | 2027 | } |
---|
1953 | 2028 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2673 | 2748 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2674 | 2749 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2675 | 2750 | } |
---|
| 2751 | + |
---|
2676 | 2752 | //cJME.count++; |
---|
2677 | 2753 | //cJME.count %= 12; |
---|
2678 | 2754 | if (gc) |
---|
.. | .. |
---|
2856 | 2932 | } |
---|
2857 | 2933 | } |
---|
2858 | 2934 | } |
---|
| 2935 | + |
---|
2859 | 2936 | cFileSystemPane FSPane; |
---|
2860 | 2937 | |
---|
2861 | 2938 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2909 | 2986 | } |
---|
2910 | 2987 | } |
---|
2911 | 2988 | } |
---|
| 2989 | + |
---|
2912 | 2990 | freezematerial = false; |
---|
2913 | 2991 | } |
---|
2914 | 2992 | |
---|
.. | .. |
---|
3361 | 3439 | { |
---|
3362 | 3440 | Close(); |
---|
3363 | 3441 | //return true; |
---|
3364 | | - } else if (source == loadItem) |
---|
| 3442 | + } else if (source == openItem) |
---|
3365 | 3443 | { |
---|
3366 | | - load(); |
---|
| 3444 | + Open(); |
---|
3367 | 3445 | //return true; |
---|
3368 | 3446 | } else if (source == newItem) |
---|
3369 | 3447 | { |
---|
.. | .. |
---|
3388 | 3466 | { |
---|
3389 | 3467 | generatePOV(); |
---|
3390 | 3468 | //return true; |
---|
| 3469 | + } else if (event.getSource() == archiveItem) |
---|
| 3470 | + { |
---|
| 3471 | + cTools.Archive(frame); |
---|
| 3472 | + return; |
---|
3391 | 3473 | } else if (source == zBufferItem) |
---|
3392 | 3474 | { |
---|
3393 | 3475 | try |
---|
.. | .. |
---|
3439 | 3521 | try |
---|
3440 | 3522 | { |
---|
3441 | 3523 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3442 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3443 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3524 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3525 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3444 | 3526 | |
---|
3445 | 3527 | Object3D parent = o.parent; |
---|
3446 | 3528 | o.parent = null; |
---|
.. | .. |
---|
3451 | 3533 | |
---|
3452 | 3534 | out.flush(); |
---|
3453 | 3535 | |
---|
3454 | | - zstream.close(); |
---|
| 3536 | + baos //zstream |
---|
| 3537 | + .close(); |
---|
3455 | 3538 | out.close(); |
---|
3456 | 3539 | |
---|
3457 | | - return baos.toByteArray(); |
---|
| 3540 | + byte[] bytes = baos.toByteArray(); |
---|
| 3541 | + |
---|
| 3542 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3543 | + return bytes; |
---|
3458 | 3544 | } catch (Exception e) |
---|
3459 | 3545 | { |
---|
3460 | 3546 | System.err.println(e); |
---|
.. | .. |
---|
3464 | 3550 | |
---|
3465 | 3551 | static public Object Uncompress(byte[] bytes) |
---|
3466 | 3552 | { |
---|
3467 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3553 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3468 | 3554 | try |
---|
3469 | 3555 | { |
---|
3470 | 3556 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3471 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3472 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3557 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3558 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3473 | 3559 | Object obj = in.readObject(); |
---|
| 3560 | + |
---|
| 3561 | + bais //istream |
---|
| 3562 | + .close(); |
---|
3474 | 3563 | in.close(); |
---|
3475 | 3564 | |
---|
3476 | 3565 | return obj; |
---|
.. | .. |
---|
3525 | 3614 | return null; |
---|
3526 | 3615 | } |
---|
3527 | 3616 | |
---|
3528 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3529 | 3617 | |
---|
3530 | 3618 | public void Save() |
---|
| 3619 | + { |
---|
| 3620 | + //Save(true); |
---|
| 3621 | + Replace(); |
---|
| 3622 | + } |
---|
| 3623 | + |
---|
| 3624 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3625 | + { |
---|
| 3626 | + if (compress.length != name.length) |
---|
| 3627 | + { |
---|
| 3628 | + return false; |
---|
| 3629 | + } |
---|
| 3630 | + |
---|
| 3631 | + for (int i=compress.length; --i>=0;) |
---|
| 3632 | + { |
---|
| 3633 | + if (compress[i] != name[i]) |
---|
| 3634 | + return false; |
---|
| 3635 | + } |
---|
| 3636 | + |
---|
| 3637 | + return true; |
---|
| 3638 | + } |
---|
| 3639 | + |
---|
| 3640 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3641 | + |
---|
| 3642 | + public boolean Save(boolean user) |
---|
3531 | 3643 | { |
---|
3532 | 3644 | System.err.println("Save"); |
---|
3533 | 3645 | |
---|
3534 | 3646 | cRadio tab = GetCurrentTab(); |
---|
3535 | 3647 | |
---|
3536 | | - boolean temp = CameraPane.SWITCH; |
---|
3537 | | - CameraPane.SWITCH = false; |
---|
| 3648 | + byte[] compress = CompressCopy(); |
---|
3538 | 3649 | |
---|
3539 | | - copy.ExtractBigData(hashtable); |
---|
| 3650 | + boolean thesame = false; |
---|
| 3651 | + |
---|
| 3652 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3653 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3654 | + { |
---|
| 3655 | + thesame = true; |
---|
| 3656 | + } |
---|
3540 | 3657 | |
---|
3541 | 3658 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3542 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
| 3659 | + if (!thesame) |
---|
| 3660 | + { |
---|
| 3661 | + //tab.user[tab.versionindex] = user; |
---|
| 3662 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3663 | + |
---|
| 3664 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3665 | + |
---|
| 3666 | + // if (increment) |
---|
| 3667 | + // tab.versionindex++; |
---|
| 3668 | + } |
---|
3543 | 3669 | |
---|
3544 | | - copy.RestoreBigData(hashtable); |
---|
| 3670 | + //copy.RestoreBigData(versiontable); |
---|
3545 | 3671 | |
---|
3546 | | - CameraPane.SWITCH = temp; |
---|
3547 | | - |
---|
3548 | 3672 | //assert(hashtable.isEmpty()); |
---|
3549 | 3673 | |
---|
3550 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3674 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3551 | 3675 | { |
---|
3552 | | - tab.graphs[i] = null; |
---|
| 3676 | + //tab.user[i] = false; |
---|
| 3677 | + copy.versions[i] = null; |
---|
3553 | 3678 | } |
---|
3554 | 3679 | |
---|
3555 | 3680 | SetUndoStates(); |
---|
.. | .. |
---|
3559 | 3684 | { |
---|
3560 | 3685 | try |
---|
3561 | 3686 | { |
---|
3562 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3687 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3563 | 3688 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3564 | 3689 | |
---|
3565 | 3690 | p.writeObject(copy); |
---|
.. | .. |
---|
3572 | 3697 | e.printStackTrace(); |
---|
3573 | 3698 | } |
---|
3574 | 3699 | } |
---|
| 3700 | + |
---|
| 3701 | + return !thesame; |
---|
3575 | 3702 | } |
---|
3576 | 3703 | |
---|
3577 | 3704 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3581 | 3708 | boolean temp = CameraPane.SWITCH; |
---|
3582 | 3709 | CameraPane.SWITCH = false; |
---|
3583 | 3710 | |
---|
3584 | | - copy.ExtractBigData(hashtable); |
---|
| 3711 | + copy.ExtractBigData(versiontable); |
---|
3585 | 3712 | |
---|
3586 | 3713 | copy.clear(); |
---|
3587 | 3714 | |
---|
.. | .. |
---|
3590 | 3717 | copy.add(obj.get(i)); |
---|
3591 | 3718 | } |
---|
3592 | 3719 | |
---|
3593 | | - copy.RestoreBigData(hashtable); |
---|
| 3720 | + copy.RestoreBigData(versiontable); |
---|
3594 | 3721 | |
---|
3595 | 3722 | CameraPane.SWITCH = temp; |
---|
3596 | 3723 | |
---|
.. | .. |
---|
3618 | 3745 | } |
---|
3619 | 3746 | |
---|
3620 | 3747 | cButton undoButton; |
---|
| 3748 | + cButton restoreButton; |
---|
| 3749 | + cButton replaceButton; |
---|
3621 | 3750 | cButton redoButton; |
---|
3622 | 3751 | |
---|
| 3752 | + boolean muteSlider; |
---|
| 3753 | + |
---|
| 3754 | + int VersionCount() |
---|
| 3755 | + { |
---|
| 3756 | + int count = 0; |
---|
| 3757 | + |
---|
| 3758 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3759 | + { |
---|
| 3760 | + if (copy.versions[i] != null) |
---|
| 3761 | + count++; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
| 3764 | + return count; |
---|
| 3765 | + } |
---|
| 3766 | + |
---|
3623 | 3767 | void SetUndoStates() |
---|
3624 | 3768 | { |
---|
3625 | 3769 | cRadio tab = GetCurrentTab(); |
---|
3626 | 3770 | |
---|
3627 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3628 | | - redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3771 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3772 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3773 | + |
---|
| 3774 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3775 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3776 | + |
---|
| 3777 | + muteSlider = true; |
---|
| 3778 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3779 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3780 | + muteSlider = false; |
---|
3629 | 3781 | } |
---|
3630 | 3782 | |
---|
3631 | | - public void Undo() |
---|
| 3783 | + public boolean Undo() |
---|
3632 | 3784 | { |
---|
| 3785 | + // Option? |
---|
| 3786 | + Replace(); |
---|
| 3787 | + |
---|
3633 | 3788 | System.err.println("Undo"); |
---|
3634 | 3789 | |
---|
3635 | 3790 | cRadio tab = GetCurrentTab(); |
---|
3636 | 3791 | |
---|
3637 | | - if (tab.undoindex == 0) |
---|
| 3792 | + if (copy.versionindex == 0) |
---|
3638 | 3793 | { |
---|
3639 | 3794 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3640 | | - return; |
---|
| 3795 | + return false; |
---|
3641 | 3796 | } |
---|
3642 | 3797 | |
---|
3643 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3798 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3799 | +// { |
---|
| 3800 | +// if (Save(false)) |
---|
| 3801 | +// tab.versionindex -= 1; |
---|
| 3802 | +// else |
---|
| 3803 | +// { |
---|
| 3804 | +// if (tab.versionindex <= 0) |
---|
| 3805 | +// return false; |
---|
| 3806 | +// else |
---|
| 3807 | +// tab.versionindex -= 1; |
---|
| 3808 | +// } |
---|
| 3809 | +// } |
---|
| 3810 | + |
---|
| 3811 | + copy.versionindex -= 1; |
---|
| 3812 | + |
---|
| 3813 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3814 | + |
---|
| 3815 | + return true; |
---|
| 3816 | + } |
---|
| 3817 | + |
---|
| 3818 | + public boolean Restore() |
---|
| 3819 | + { |
---|
| 3820 | + System.err.println("Restore"); |
---|
| 3821 | + |
---|
| 3822 | + cRadio tab = GetCurrentTab(); |
---|
| 3823 | + |
---|
| 3824 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3644 | 3825 | { |
---|
3645 | | - Save(); |
---|
3646 | | - tab.undoindex -= 1; |
---|
| 3826 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3827 | + return false; |
---|
3647 | 3828 | } |
---|
3648 | 3829 | |
---|
3649 | | - tab.undoindex -= 1; |
---|
| 3830 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3831 | + |
---|
| 3832 | + return true; |
---|
| 3833 | + } |
---|
3650 | 3834 | |
---|
3651 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3835 | + public boolean Replace() |
---|
| 3836 | + { |
---|
| 3837 | + System.err.println("Replace"); |
---|
| 3838 | + |
---|
| 3839 | + cRadio tab = GetCurrentTab(); |
---|
| 3840 | + |
---|
| 3841 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3842 | + { |
---|
| 3843 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3844 | + return false; |
---|
| 3845 | + } |
---|
| 3846 | + |
---|
| 3847 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
| 3848 | + |
---|
| 3849 | + return true; |
---|
3652 | 3850 | } |
---|
3653 | 3851 | |
---|
3654 | 3852 | public void Redo() |
---|
3655 | 3853 | { |
---|
| 3854 | + // Option? |
---|
| 3855 | + Replace(); |
---|
| 3856 | + |
---|
3656 | 3857 | cRadio tab = GetCurrentTab(); |
---|
3657 | 3858 | |
---|
3658 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3859 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3659 | 3860 | { |
---|
3660 | 3861 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3661 | 3862 | return; |
---|
3662 | 3863 | } |
---|
3663 | 3864 | |
---|
3664 | | - tab.undoindex += 1; |
---|
| 3865 | + copy.versionindex += 1; |
---|
3665 | 3866 | |
---|
3666 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3867 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3868 | + |
---|
| 3869 | + //if (!tab.user[tab.versionindex]) |
---|
| 3870 | + // tab.graphs[tab.versionindex] = null; |
---|
3667 | 3871 | } |
---|
3668 | 3872 | |
---|
3669 | 3873 | void ImportGFD() |
---|
.. | .. |
---|
3959 | 4163 | //copy.Touch(); |
---|
3960 | 4164 | } |
---|
3961 | 4165 | |
---|
| 4166 | + cNumberSlider versionSlider; |
---|
| 4167 | + |
---|
3962 | 4168 | public void stateChanged(ChangeEvent e) |
---|
3963 | 4169 | { |
---|
3964 | 4170 | // assert(false); |
---|
| 4171 | + if (e.getSource() == versionSlider) |
---|
| 4172 | + { |
---|
| 4173 | + if (muteSlider) |
---|
| 4174 | + return; |
---|
| 4175 | + |
---|
| 4176 | + int version = versionSlider.getInteger(); |
---|
| 4177 | + |
---|
| 4178 | + if (copy.versions[version] != null) |
---|
| 4179 | + { |
---|
| 4180 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4181 | + } |
---|
| 4182 | + |
---|
| 4183 | + return; |
---|
| 4184 | + } |
---|
3965 | 4185 | |
---|
3966 | 4186 | if (freezematerial) |
---|
3967 | 4187 | { |
---|
.. | .. |
---|
4310 | 4530 | |
---|
4311 | 4531 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4312 | 4532 | { |
---|
4313 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4533 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4314 | 4534 | Save(); |
---|
4315 | 4535 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4316 | 4536 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4626 | 4846 | |
---|
4627 | 4847 | if (readobj != null) |
---|
4628 | 4848 | { |
---|
4629 | | - if (Globals.SAVEONMAKE) |
---|
4630 | | - Save(); |
---|
| 4849 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4850 | + // Save(); |
---|
4631 | 4851 | try |
---|
4632 | 4852 | { |
---|
4633 | 4853 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4682 | 4902 | c.addChild(csg); |
---|
4683 | 4903 | } |
---|
4684 | 4904 | |
---|
| 4905 | + copy.versions = readobj.versions; |
---|
| 4906 | + copy.versionindex = readobj.versionindex; |
---|
| 4907 | + |
---|
| 4908 | + if (copy.versions == null) |
---|
| 4909 | + { |
---|
| 4910 | + copy.versions = new byte[100][]; |
---|
| 4911 | + copy.versionindex = -1; |
---|
| 4912 | + } |
---|
| 4913 | + |
---|
| 4914 | + //? SetUndoStates(); |
---|
| 4915 | + |
---|
4685 | 4916 | ResetModel(); |
---|
4686 | 4917 | copy.HardTouch(); // recompile? |
---|
4687 | 4918 | refreshContents(); |
---|
4688 | 4919 | } |
---|
4689 | 4920 | } |
---|
4690 | 4921 | |
---|
4691 | | - void load() // throws ClassNotFoundException |
---|
| 4922 | + void Open() // throws ClassNotFoundException |
---|
4692 | 4923 | { |
---|
4693 | 4924 | if (Grafreed.standAlone) |
---|
4694 | 4925 | { |
---|
.. | .. |
---|
4973 | 5204 | MenuBar menuBar; |
---|
4974 | 5205 | Menu fileMenu; |
---|
4975 | 5206 | MenuItem newItem; |
---|
4976 | | - MenuItem loadItem; |
---|
| 5207 | + MenuItem openItem; |
---|
4977 | 5208 | MenuItem saveItem; |
---|
4978 | 5209 | MenuItem saveAsItem; |
---|
4979 | 5210 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4996 | 5227 | CheckboxMenuItem toggleSwitchItem; |
---|
4997 | 5228 | CheckboxMenuItem toggleRootItem; |
---|
4998 | 5229 | CheckboxMenuItem animationItem; |
---|
| 5230 | + MenuItem archiveItem; |
---|
4999 | 5231 | CheckboxMenuItem toggleHandleItem; |
---|
5000 | 5232 | CheckboxMenuItem togglePaintItem; |
---|
5001 | 5233 | JSplitPane mainPanel; |
---|