.. | .. |
---|
4 | 4 | |
---|
5 | 5 | import java.awt.*; |
---|
6 | 6 | import java.awt.event.*; |
---|
| 7 | +import java.awt.image.BufferedImage; |
---|
7 | 8 | import javax.swing.*; |
---|
8 | 9 | import javax.swing.event.*; |
---|
9 | 10 | import javax.swing.text.*; |
---|
.. | .. |
---|
13 | 14 | import javax.swing.plaf.metal.MetalLookAndFeel; |
---|
14 | 15 | //import javax.swing.plaf.ColorUIResource; |
---|
15 | 16 | //import javax.swing.plaf.metal.DefaultMetalTheme; |
---|
| 17 | + |
---|
| 18 | +import javax.swing.plaf.basic.BasicSplitPaneDivider; |
---|
| 19 | +import javax.swing.plaf.basic.BasicSplitPaneUI; |
---|
16 | 20 | |
---|
17 | 21 | //import javax.media.opengl.GLCanvas; |
---|
18 | 22 | |
---|
.. | .. |
---|
35 | 39 | |
---|
36 | 40 | GroupEditor callee; |
---|
37 | 41 | JFrame frame; |
---|
| 42 | + |
---|
| 43 | + static ObjEditor theFrame; |
---|
| 44 | + |
---|
| 45 | + cButton GetButton(String name, boolean border) |
---|
| 46 | + { |
---|
| 47 | + try |
---|
| 48 | + { |
---|
| 49 | + ImageIcon icon = GetIcon(name); |
---|
| 50 | + return new cButton(icon, border); |
---|
| 51 | + } |
---|
| 52 | + catch (Exception e) |
---|
| 53 | + { |
---|
| 54 | + return new cButton(name, border); |
---|
| 55 | + } |
---|
| 56 | + } |
---|
| 57 | + |
---|
| 58 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 59 | + { |
---|
| 60 | + try |
---|
| 61 | + { |
---|
| 62 | + ImageIcon icon = GetIcon(name); |
---|
| 63 | + return new cToggleButton(icon, border); |
---|
| 64 | + } |
---|
| 65 | + catch (Exception e) |
---|
| 66 | + { |
---|
| 67 | + return new cToggleButton(name, border); |
---|
| 68 | + } |
---|
| 69 | + } |
---|
| 70 | + |
---|
| 71 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 72 | + { |
---|
| 73 | + try |
---|
| 74 | + { |
---|
| 75 | + ImageIcon icon = GetIcon(name); |
---|
| 76 | + return new cCheckBox(icon, border); |
---|
| 77 | + } |
---|
| 78 | + catch (Exception e) |
---|
| 79 | + { |
---|
| 80 | + return new cCheckBox(name, border); |
---|
| 81 | + } |
---|
| 82 | + } |
---|
| 83 | + |
---|
| 84 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 85 | + { |
---|
| 86 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 87 | + |
---|
| 88 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 89 | + { |
---|
| 90 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 91 | + Graphics2D g = resized.createGraphics(); |
---|
| 92 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 93 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 94 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 95 | + g.dispose(); |
---|
| 96 | + |
---|
| 97 | + image = resized; |
---|
| 98 | + } |
---|
| 99 | + |
---|
| 100 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 101 | + return icon; |
---|
| 102 | + } |
---|
38 | 103 | |
---|
39 | 104 | // SCRIPT |
---|
40 | 105 | |
---|
.. | .. |
---|
145 | 210 | |
---|
146 | 211 | objEditor.ctrlPanel.remove(namePanel); |
---|
147 | 212 | |
---|
148 | | - if (!GroupEditor.allparams) |
---|
| 213 | + if (!allparams) |
---|
149 | 214 | return; |
---|
150 | 215 | |
---|
151 | 216 | // objEditor.ctrlPanel.remove(liveCB); |
---|
.. | .. |
---|
168 | 233 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 234 | |
---|
170 | 235 | objEditor.ctrlPanel.remove(setupPanel); |
---|
171 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 236 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
| 237 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
172 | 238 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 239 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
174 | 240 | |
---|
.. | .. |
---|
243 | 309 | //localCopy.parent = null; |
---|
244 | 310 | |
---|
245 | 311 | frame = new JFrame(); |
---|
| 312 | + frame.setUndecorated(false); |
---|
246 | 313 | objEditor = this; |
---|
247 | 314 | this.callee = callee; |
---|
248 | 315 | |
---|
.. | .. |
---|
273 | 340 | return frame.action(event, obj); |
---|
274 | 341 | } |
---|
275 | 342 | |
---|
| 343 | + // Cannot work without static |
---|
| 344 | + static boolean allparams = true; |
---|
| 345 | + |
---|
| 346 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 347 | + |
---|
276 | 348 | void SetupMenu() |
---|
277 | 349 | { |
---|
278 | 350 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 351 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 352 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 353 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
282 | 354 | |
---|
283 | 355 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 356 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
310 | 382 | } |
---|
311 | 383 | |
---|
312 | 384 | newItem.addActionListener(this); |
---|
313 | | - loadItem.addActionListener(this); |
---|
| 385 | + openItem.addActionListener(this); |
---|
314 | 386 | saveItem.addActionListener(this); |
---|
315 | 387 | saveAsItem.addActionListener(this); |
---|
316 | 388 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
319 | 391 | closeItem.addActionListener(this); |
---|
320 | 392 | |
---|
321 | 393 | objectPanel = new JTabbedPane(); |
---|
| 394 | + |
---|
| 395 | + ChangeListener changeListener = new ChangeListener() |
---|
| 396 | + { |
---|
| 397 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 398 | + { |
---|
| 399 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 400 | +// { |
---|
| 401 | +// if (latestObject != null) |
---|
| 402 | +// { |
---|
| 403 | +// refreshContents(true); |
---|
| 404 | +// SetMaterial(latestObject); |
---|
| 405 | +// } |
---|
| 406 | +// |
---|
| 407 | +// materialFlushed = true; |
---|
| 408 | +// } |
---|
| 409 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) |
---|
| 410 | +// { |
---|
| 411 | +// if (listUI.size() == 0) |
---|
| 412 | +// EditSelection(false); |
---|
| 413 | +// } |
---|
| 414 | + |
---|
| 415 | + refreshContents(false); // To refresh Info tab |
---|
| 416 | + } |
---|
| 417 | + }; |
---|
| 418 | + objectPanel.addChangeListener(changeListener); |
---|
| 419 | + |
---|
322 | 420 | toolbarPanel = new JPanel(); |
---|
323 | 421 | toolbarPanel.setName("Toolbar"); |
---|
324 | 422 | treePanel = new cGridBag(); |
---|
325 | 423 | treePanel.setName("Tree"); |
---|
| 424 | + |
---|
| 425 | + editPanel = new cGridBag().setVertical(true); |
---|
| 426 | + editPanel.setName("Edit"); |
---|
| 427 | + |
---|
326 | 428 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
327 | | - ctrlPanel.setName("Edit"); |
---|
| 429 | + |
---|
| 430 | + editCommandsPanel = new cGridBag(); |
---|
| 431 | + editPanel.add(editCommandsPanel); |
---|
| 432 | + editPanel.add(ctrlPanel); |
---|
| 433 | + |
---|
| 434 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 435 | + toolboxPanel.setName("Toolbox"); |
---|
| 436 | + |
---|
328 | 437 | materialPanel = new cGridBag().setVertical(true); |
---|
329 | 438 | materialPanel.setName("Material"); |
---|
| 439 | + |
---|
330 | 440 | /*JTextPane*/ |
---|
331 | 441 | infoarea = createTextPane(); |
---|
332 | 442 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
339 | 449 | // TEXTAREA infoarea.setLineWrap(true); |
---|
340 | 450 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
341 | 451 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
342 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 452 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
343 | 453 | infoPanel.setName("Info"); |
---|
344 | 454 | //infoPanel.setLayout(new BorderLayout()); |
---|
345 | 455 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
351 | 461 | mainPanel.setDividerSize(9); |
---|
352 | 462 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
353 | 463 | mainPanel.setResizeWeight(0.5); |
---|
354 | | - |
---|
| 464 | + |
---|
| 465 | +//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5)); |
---|
| 466 | + BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider(); |
---|
| 467 | + divider.setDividerSize(15); |
---|
| 468 | + divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!")); |
---|
| 469 | + |
---|
| 470 | + mainPanel.setUI(new BasicSplitPaneUI()); |
---|
| 471 | + |
---|
355 | 472 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
356 | 473 | //mainPanel.setLayout(new GridBagLayout()); |
---|
357 | 474 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
419 | 536 | e.printStackTrace(); |
---|
420 | 537 | } |
---|
421 | 538 | |
---|
422 | | - String selection = infoarea.getText(); |
---|
423 | | - java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
424 | | - java.awt.datatransfer.Clipboard clipboard = |
---|
425 | | - Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 539 | +// String selection = infoarea.getText(); |
---|
| 540 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 541 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 542 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 543 | //clipboard.setContents(data, data); |
---|
427 | 544 | } |
---|
428 | 545 | |
---|
.. | .. |
---|
582 | 699 | } |
---|
583 | 700 | } |
---|
584 | 701 | |
---|
| 702 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 703 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 704 | + |
---|
| 705 | + Rectangle keeprect; |
---|
| 706 | + cRadio radio; |
---|
| 707 | + |
---|
| 708 | +cButton keepButton; |
---|
| 709 | + cButton twoButton; // Full 3D |
---|
| 710 | + cButton sixButton; |
---|
| 711 | + cButton threeButton; |
---|
| 712 | + cButton sevenButton; |
---|
| 713 | + cButton fourButton; // full panel |
---|
| 714 | + cButton oneButton; // full XYZ |
---|
| 715 | + //cButton currentLayout; |
---|
| 716 | + |
---|
| 717 | + boolean maximized; |
---|
| 718 | + |
---|
| 719 | + cButton fullscreenLayout; |
---|
| 720 | + |
---|
| 721 | + void Minimize() |
---|
| 722 | + { |
---|
| 723 | + frame.setState(Frame.ICONIFIED); |
---|
| 724 | + frame.validate(); |
---|
| 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={} |
---|
| 730 | + void Maximize() |
---|
| 731 | + { |
---|
| 732 | + if (CameraPane.FULLSCREEN) |
---|
| 733 | + { |
---|
| 734 | + ToggleFullScreen(); |
---|
| 735 | + } |
---|
| 736 | + |
---|
| 737 | + if (maximized) |
---|
| 738 | + { |
---|
| 739 | + frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 740 | + } |
---|
| 741 | + else |
---|
| 742 | + { |
---|
| 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); |
---|
| 747 | +// frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 748 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
| 749 | + } |
---|
| 750 | + |
---|
| 751 | + maximized ^= true; |
---|
| 752 | + |
---|
| 753 | + frame.validate(); |
---|
| 754 | + } |
---|
| 755 | + |
---|
| 756 | + cButton minButton; |
---|
| 757 | + cButton maxButton; |
---|
| 758 | + cButton fullButton; |
---|
| 759 | + |
---|
585 | 760 | void ToggleFullScreen() |
---|
586 | 761 | { |
---|
587 | | - if (CameraPane.FULLSCREEN) |
---|
| 762 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 763 | + |
---|
| 764 | + cameraView.ToggleFullScreen(); |
---|
| 765 | + |
---|
| 766 | + if (!CameraPane.FULLSCREEN) |
---|
588 | 767 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 768 | + device.setFullScreenWindow(null); |
---|
| 769 | + frame.dispose(); |
---|
| 770 | + frame.setUndecorated(false); |
---|
| 771 | + frame.validate(); |
---|
| 772 | + frame.setVisible(true); |
---|
| 773 | + |
---|
| 774 | + //frame.setVisible(false); |
---|
| 775 | +// frame.removeNotify(); |
---|
| 776 | +// frame.setUndecorated(false); |
---|
| 777 | +// frame.addNotify(); |
---|
| 778 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 779 | + |
---|
| 780 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 781 | +// X framePanel.add(bigThree); |
---|
| 782 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 783 | + framePanel.setDividerLocation(46); |
---|
| 784 | + |
---|
| 785 | + //frame.setVisible(true); |
---|
| 786 | + radio.layout = keepButton; |
---|
| 787 | + //theFrame = null; |
---|
| 788 | + keepButton = null; |
---|
| 789 | + radio.layout.doClick(); |
---|
| 790 | + |
---|
592 | 791 | } else |
---|
593 | 792 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 793 | + keepButton = radio.layout; |
---|
| 794 | + //keeprect = frame.getBounds(); |
---|
| 795 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 796 | +// frame.getToolkit().getScreenSize().height); |
---|
| 797 | + //frame.setVisible(false); |
---|
| 798 | + |
---|
| 799 | + frame.dispose(); |
---|
| 800 | + frame.setUndecorated(true); |
---|
| 801 | + device.setFullScreenWindow(frame); |
---|
| 802 | + frame.validate(); |
---|
| 803 | + frame.setVisible(true); |
---|
| 804 | +// frame.removeNotify(); |
---|
| 805 | +// frame.setUndecorated(true); |
---|
| 806 | +// frame.addNotify(); |
---|
| 807 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 808 | +// X framePanel.remove(bigThree); |
---|
| 809 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 810 | + framePanel.setDividerLocation(0); |
---|
| 811 | + |
---|
| 812 | + radio.layout = fullscreenLayout; |
---|
| 813 | + radio.layout.doClick(); |
---|
| 814 | + //frame.setVisible(true); |
---|
597 | 815 | } |
---|
598 | | - cameraView.ToggleFullScreen(); |
---|
| 816 | + frame.validate(); |
---|
599 | 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 | + } |
---|
600 | 840 | |
---|
601 | 841 | private JTextPane createTextPane() |
---|
602 | 842 | { |
---|
.. | .. |
---|
736 | 976 | JCheckBox speedupCB; |
---|
737 | 977 | JCheckBox rewindCB; |
---|
738 | 978 | JCheckBox flipVCB; |
---|
| 979 | + |
---|
| 980 | + cCheckBox toggleTextureCB; |
---|
| 981 | + cCheckBox toggleSwitchCB; |
---|
| 982 | + |
---|
739 | 983 | JComboBox texresMenu; |
---|
| 984 | + |
---|
740 | 985 | JButton resetButton; |
---|
741 | 986 | JButton stepButton; |
---|
742 | 987 | JButton stepAllButton; |
---|
.. | .. |
---|
745 | 990 | JButton fasterButton; |
---|
746 | 991 | JButton remarkButton; |
---|
747 | 992 | |
---|
| 993 | + cGridBag editPanel; |
---|
| 994 | + cGridBag editCommandsPanel; |
---|
| 995 | + |
---|
748 | 996 | cGridBag namePanel; |
---|
749 | 997 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 998 | + cGridBag setupPanel2; |
---|
| 999 | + cGridBag objectCommandsPanel; |
---|
751 | 1000 | cGridBag pushPanel; |
---|
752 | 1001 | cGridBag fillPanel; |
---|
753 | 1002 | |
---|
.. | .. |
---|
919 | 1168 | namePanel = new cGridBag(); |
---|
920 | 1169 | |
---|
921 | 1170 | nameField = AddText(namePanel, copy.GetName()); |
---|
922 | | - namePanel.add(nameField); |
---|
| 1171 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
923 | 1172 | oe.ctrlPanel.add(namePanel); |
---|
924 | 1173 | |
---|
925 | 1174 | oe.ctrlPanel.Return(); |
---|
926 | 1175 | |
---|
927 | | - if (!GroupEditor.allparams) |
---|
| 1176 | + if (!allparams) |
---|
928 | 1177 | return; |
---|
929 | 1178 | |
---|
930 | 1179 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
937 | 1186 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
938 | 1187 | hideCB.setToolTipText("Hide object"); |
---|
939 | 1188 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1189 | + markCB.setToolTipText("As animation target transform"); |
---|
941 | 1190 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1191 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1192 | + |
---|
| 1193 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1194 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1195 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1196 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
| 1197 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
947 | 1198 | |
---|
| 1199 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1200 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1201 | + |
---|
948 | 1202 | if (Globals.ADVANCED) |
---|
949 | 1203 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
951 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1204 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1205 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1206 | } |
---|
955 | 1207 | |
---|
956 | 1208 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1209 | oe.ctrlPanel.Return(); |
---|
| 1210 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1211 | + oe.ctrlPanel.Return(); |
---|
958 | 1212 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1213 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1214 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1215 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1216 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1217 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1218 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1219 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1220 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1221 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1222 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1223 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1224 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1225 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1226 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1227 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1228 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1229 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1230 | oe.ctrlPanel.Return(); |
---|
977 | 1231 | |
---|
978 | 1232 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1432 | //worldPanel.setName("World"); |
---|
1179 | 1433 | centralPanel = new cGridBag(); |
---|
1180 | 1434 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1435 | + |
---|
| 1436 | + if (Globals.ADVANCED) |
---|
| 1437 | + { |
---|
| 1438 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1439 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1440 | |
---|
1184 | 1441 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1442 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1445 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1446 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1447 | |
---|
| 1448 | + } |
---|
| 1449 | + |
---|
1191 | 1450 | centralPanel.add(cameraView); |
---|
| 1451 | + centralPanel.setFocusable(true); |
---|
1192 | 1452 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1453 | //centralPanel.add(timelinePanel); |
---|
1194 | 1454 | |
---|
.. | .. |
---|
1255 | 1515 | // north.setName("Edit"); |
---|
1256 | 1516 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1517 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
1259 | | - objectPanel.add(infoPanel); |
---|
| 1518 | + objectPanel.add(editPanel); |
---|
| 1519 | + |
---|
| 1520 | + //if (Globals.ADVANCED) |
---|
| 1521 | + objectPanel.add(infoPanel); |
---|
| 1522 | + |
---|
| 1523 | + objectPanel.add(toolboxPanel); |
---|
1260 | 1524 | |
---|
1261 | 1525 | /* |
---|
1262 | 1526 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1265 | 1529 | aConstraints.gridy += 1; |
---|
1266 | 1530 | aConstraints.gridwidth = 1; |
---|
1267 | 1531 | mainPanel.add(objectPanel, aConstraints); |
---|
1268 | | - */ |
---|
| 1532 | + */ |
---|
1269 | 1533 | |
---|
1270 | 1534 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1271 | 1535 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1282 | 1546 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1283 | 1547 | tabbedPane.add(scrollpane); |
---|
1284 | 1548 | |
---|
1285 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1286 | | - |
---|
1287 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1549 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1288 | 1550 | |
---|
1289 | 1551 | optionsPanel.setName("Options"); |
---|
1290 | 1552 | |
---|
.. | .. |
---|
1292 | 1554 | |
---|
1293 | 1555 | tabbedPane.add(optionsPanel); |
---|
1294 | 1556 | |
---|
| 1557 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1558 | + |
---|
1295 | 1559 | scenePanel.add(tabbedPane); |
---|
1296 | 1560 | |
---|
1297 | 1561 | /* |
---|
.. | .. |
---|
1364 | 1628 | // aConstraints.gridheight = 1; |
---|
1365 | 1629 | |
---|
1366 | 1630 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1367 | | - framePanel.setContinuousLayout(true); |
---|
1368 | | - framePanel.setOneTouchExpandable(true); |
---|
1369 | | - framePanel.setDividerLocation(0.8); |
---|
| 1631 | + framePanel.setContinuousLayout(false); |
---|
| 1632 | + framePanel.setOneTouchExpandable(false); |
---|
| 1633 | + //.setDividerLocation(0.8); |
---|
1370 | 1634 | //framePanel.setDividerSize(15); |
---|
1371 | 1635 | //framePanel.setResizeWeight(0.15); |
---|
1372 | 1636 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1384 | 1648 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1385 | 1649 | |
---|
1386 | 1650 | frame.setSize(1280, 860); |
---|
1387 | | - frame.setVisible(true); |
---|
1388 | | - |
---|
| 1651 | + |
---|
| 1652 | + cameraView.requestFocusInWindow(); |
---|
| 1653 | + |
---|
1389 | 1654 | gridPanel.setDividerLocation(1.0); |
---|
| 1655 | + |
---|
| 1656 | + frame.validate(); |
---|
| 1657 | + |
---|
| 1658 | + frame.setVisible(true); |
---|
1390 | 1659 | |
---|
1391 | 1660 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1392 | 1661 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1473 | 1742 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1474 | 1743 | colorSection.add(texture); |
---|
1475 | 1744 | |
---|
1476 | | - cGridBag anisoU = new cGridBag(); |
---|
1477 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1478 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1479 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1480 | | - colorSection.add(anisoU); |
---|
1481 | | - |
---|
1482 | | - cGridBag anisoV = new cGridBag(); |
---|
1483 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1484 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1485 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1486 | | - colorSection.add(anisoV); |
---|
1487 | | - |
---|
1488 | | - cGridBag shadowbias = new cGridBag(); |
---|
1489 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1490 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1491 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1492 | | - colorSection.add(shadowbias); |
---|
1493 | | - |
---|
1494 | 1745 | panel.add(new JSeparator()); |
---|
1495 | 1746 | |
---|
1496 | 1747 | panel.add(colorSection); |
---|
.. | .. |
---|
1540 | 1791 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1541 | 1792 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1542 | 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); |
---|
1543 | 1800 | |
---|
1544 | 1801 | panel.add(new JSeparator()); |
---|
1545 | 1802 | |
---|
.. | .. |
---|
1591 | 1848 | // aConstraints.gridy += 1; |
---|
1592 | 1849 | // aConstraints.gridwidth = 1; |
---|
1593 | 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 | + |
---|
1594 | 1863 | |
---|
1595 | 1864 | panel.add(new JSeparator()); |
---|
1596 | 1865 | |
---|
.. | .. |
---|
1598 | 1867 | |
---|
1599 | 1868 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1600 | 1869 | |
---|
1601 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1870 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1602 | 1871 | |
---|
1603 | 1872 | cGridBag camera = new cGridBag(); |
---|
1604 | 1873 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1605 | 1874 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1606 | 1875 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1607 | | - globalSection.add(camera); |
---|
| 1876 | + colorSection.add(camera); |
---|
1608 | 1877 | |
---|
1609 | 1878 | cGridBag ambient = new cGridBag(); |
---|
1610 | 1879 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1611 | 1880 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1612 | 1881 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1613 | | - globalSection.add(ambient); |
---|
| 1882 | + colorSection.add(ambient); |
---|
1614 | 1883 | |
---|
1615 | 1884 | cGridBag backlit = new cGridBag(); |
---|
1616 | 1885 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1617 | 1886 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1618 | 1887 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1619 | | - globalSection.add(backlit); |
---|
| 1888 | + colorSection.add(backlit); |
---|
1620 | 1889 | |
---|
1621 | 1890 | cGridBag opacity = new cGridBag(); |
---|
1622 | 1891 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1623 | 1892 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1624 | 1893 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1625 | | - globalSection.add(opacity); |
---|
| 1894 | + colorSection.add(opacity); |
---|
1626 | 1895 | |
---|
1627 | | - panel.add(new JSeparator()); |
---|
| 1896 | + //panel.add(new JSeparator()); |
---|
1628 | 1897 | |
---|
1629 | | - panel.add(globalSection); |
---|
| 1898 | + //panel.add(globalSection); |
---|
1630 | 1899 | |
---|
1631 | 1900 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1632 | 1901 | |
---|
.. | .. |
---|
1733 | 2002 | // 3D models |
---|
1734 | 2003 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1735 | 2004 | { |
---|
1736 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1737 | | - LoadFile(filename, lastConverter); |
---|
| 2005 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2006 | + //LoadFile(filename, lastConverter); |
---|
| 2007 | + LoadObjFile(filename); // New 3ds loader |
---|
1738 | 2008 | continue; |
---|
1739 | 2009 | } |
---|
1740 | 2010 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2460 | 2730 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2461 | 2731 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2462 | 2732 | } |
---|
| 2733 | + |
---|
2463 | 2734 | //cJME.count++; |
---|
2464 | 2735 | //cJME.count %= 12; |
---|
2465 | 2736 | if (gc) |
---|
.. | .. |
---|
2643 | 2914 | } |
---|
2644 | 2915 | } |
---|
2645 | 2916 | } |
---|
| 2917 | + |
---|
2646 | 2918 | cFileSystemPane FSPane; |
---|
2647 | 2919 | |
---|
2648 | 2920 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2696 | 2968 | } |
---|
2697 | 2969 | } |
---|
2698 | 2970 | } |
---|
| 2971 | + |
---|
2699 | 2972 | freezematerial = false; |
---|
2700 | 2973 | } |
---|
2701 | 2974 | |
---|
2702 | 2975 | void SetMaterial(Object3D object) |
---|
2703 | 2976 | { |
---|
| 2977 | + latestObject = object; |
---|
| 2978 | + |
---|
2704 | 2979 | cMaterial mat = object.material; |
---|
2705 | 2980 | |
---|
2706 | 2981 | if (mat == null) |
---|
.. | .. |
---|
2812 | 3087 | // } |
---|
2813 | 3088 | |
---|
2814 | 3089 | /**/ |
---|
2815 | | - if (deselect) |
---|
| 3090 | + if (deselect || child == null) |
---|
2816 | 3091 | { |
---|
2817 | 3092 | //group.deselectAll(); |
---|
2818 | 3093 | //freeze = true; |
---|
2819 | 3094 | GetTree().clearSelection(); |
---|
2820 | 3095 | //freeze = false; |
---|
| 3096 | + |
---|
| 3097 | + if (child == null) |
---|
| 3098 | + { |
---|
| 3099 | + return; |
---|
| 3100 | + } |
---|
2821 | 3101 | } |
---|
2822 | 3102 | |
---|
2823 | 3103 | //group.addSelectee(child); |
---|
.. | .. |
---|
2886 | 3166 | cameraView.ToggleDL(); |
---|
2887 | 3167 | cameraView.repaint(); |
---|
2888 | 3168 | return; |
---|
2889 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3169 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2890 | 3170 | { |
---|
2891 | 3171 | cameraView.ToggleTexture(); |
---|
2892 | 3172 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
2925 | 3205 | frame.validate(); |
---|
2926 | 3206 | |
---|
2927 | 3207 | return; |
---|
2928 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3208 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
2929 | 3209 | { |
---|
2930 | 3210 | cameraView.ToggleSwitch(); |
---|
2931 | 3211 | cameraView.repaint(); |
---|
.. | .. |
---|
3141 | 3421 | { |
---|
3142 | 3422 | Close(); |
---|
3143 | 3423 | //return true; |
---|
3144 | | - } else if (source == loadItem) |
---|
| 3424 | + } else if (source == openItem) |
---|
3145 | 3425 | { |
---|
3146 | | - load(); |
---|
| 3426 | + Open(); |
---|
3147 | 3427 | //return true; |
---|
3148 | 3428 | } else if (source == newItem) |
---|
3149 | 3429 | { |
---|
.. | .. |
---|
3168 | 3448 | { |
---|
3169 | 3449 | generatePOV(); |
---|
3170 | 3450 | //return true; |
---|
| 3451 | + } else if (event.getSource() == archiveItem) |
---|
| 3452 | + { |
---|
| 3453 | + cTools.Archive(frame); |
---|
| 3454 | + return; |
---|
3171 | 3455 | } else if (source == zBufferItem) |
---|
3172 | 3456 | { |
---|
3173 | 3457 | try |
---|
.. | .. |
---|
3219 | 3503 | try |
---|
3220 | 3504 | { |
---|
3221 | 3505 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3222 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3506 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3507 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3224 | 3508 | |
---|
3225 | 3509 | Object3D parent = o.parent; |
---|
3226 | 3510 | o.parent = null; |
---|
.. | .. |
---|
3231 | 3515 | |
---|
3232 | 3516 | out.flush(); |
---|
3233 | 3517 | |
---|
3234 | | - zstream.close(); |
---|
| 3518 | + baos //zstream |
---|
| 3519 | + .close(); |
---|
3235 | 3520 | out.close(); |
---|
3236 | 3521 | |
---|
3237 | | - return baos.toByteArray(); |
---|
| 3522 | + byte[] bytes = baos.toByteArray(); |
---|
| 3523 | + |
---|
| 3524 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3525 | + return bytes; |
---|
3238 | 3526 | } catch (Exception e) |
---|
3239 | 3527 | { |
---|
3240 | 3528 | System.err.println(e); |
---|
.. | .. |
---|
3244 | 3532 | |
---|
3245 | 3533 | static public Object Uncompress(byte[] bytes) |
---|
3246 | 3534 | { |
---|
3247 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3535 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3248 | 3536 | try |
---|
3249 | 3537 | { |
---|
3250 | 3538 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3251 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3252 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3539 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3540 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3253 | 3541 | Object obj = in.readObject(); |
---|
| 3542 | + |
---|
| 3543 | + bais //istream |
---|
| 3544 | + .close(); |
---|
3254 | 3545 | in.close(); |
---|
3255 | 3546 | |
---|
3256 | 3547 | return obj; |
---|
.. | .. |
---|
3305 | 3596 | return null; |
---|
3306 | 3597 | } |
---|
3307 | 3598 | |
---|
3308 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3309 | 3599 | |
---|
3310 | 3600 | public void Save() |
---|
3311 | 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) |
---|
| 3625 | + { |
---|
| 3626 | + System.err.println("Save"); |
---|
| 3627 | + |
---|
3312 | 3628 | cRadio tab = GetCurrentTab(); |
---|
3313 | 3629 | |
---|
3314 | | - boolean temp = CameraPane.SWITCH; |
---|
3315 | | - CameraPane.SWITCH = false; |
---|
| 3630 | + byte[] compress = CompressCopy(); |
---|
3316 | 3631 | |
---|
3317 | | - 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 | + } |
---|
3318 | 3639 | |
---|
3319 | 3640 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3320 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3321 | | - |
---|
3322 | | - copy.RestoreBigData(hashtable); |
---|
3323 | | - |
---|
3324 | | - CameraPane.SWITCH = temp; |
---|
3325 | | - |
---|
3326 | | - //assert(hashtable.isEmpty()); |
---|
3327 | | - |
---|
3328 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3641 | + if (!thesame) |
---|
3329 | 3642 | { |
---|
3330 | | - tab.graphs[i] = null; |
---|
| 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++; |
---|
3331 | 3650 | } |
---|
3332 | 3651 | |
---|
| 3652 | + //copy.RestoreBigData(versiontable); |
---|
| 3653 | + |
---|
| 3654 | + //assert(hashtable.isEmpty()); |
---|
| 3655 | + |
---|
| 3656 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
| 3657 | + { |
---|
| 3658 | + //tab.user[i] = false; |
---|
| 3659 | + copy.versions[i] = null; |
---|
| 3660 | + } |
---|
| 3661 | + |
---|
| 3662 | + SetUndoStates(); |
---|
| 3663 | + |
---|
3333 | 3664 | // test save |
---|
3334 | 3665 | if (false) |
---|
3335 | 3666 | { |
---|
3336 | 3667 | try |
---|
3337 | 3668 | { |
---|
3338 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3669 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3339 | 3670 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3340 | 3671 | |
---|
3341 | 3672 | p.writeObject(copy); |
---|
.. | .. |
---|
3348 | 3679 | e.printStackTrace(); |
---|
3349 | 3680 | } |
---|
3350 | 3681 | } |
---|
| 3682 | + |
---|
| 3683 | + return !thesame; |
---|
3351 | 3684 | } |
---|
3352 | 3685 | |
---|
3353 | 3686 | void CopyChanged(Object3D obj) |
---|
3354 | 3687 | { |
---|
| 3688 | + SetUndoStates(); |
---|
| 3689 | + |
---|
3355 | 3690 | boolean temp = CameraPane.SWITCH; |
---|
3356 | 3691 | CameraPane.SWITCH = false; |
---|
3357 | 3692 | |
---|
3358 | | - copy.ExtractBigData(hashtable); |
---|
| 3693 | + copy.ExtractBigData(versiontable); |
---|
3359 | 3694 | |
---|
3360 | 3695 | copy.clear(); |
---|
3361 | 3696 | |
---|
.. | .. |
---|
3364 | 3699 | copy.add(obj.get(i)); |
---|
3365 | 3700 | } |
---|
3366 | 3701 | |
---|
3367 | | - copy.RestoreBigData(hashtable); |
---|
| 3702 | + copy.RestoreBigData(versiontable); |
---|
3368 | 3703 | |
---|
3369 | 3704 | CameraPane.SWITCH = temp; |
---|
3370 | 3705 | |
---|
.. | .. |
---|
3391 | 3726 | refreshContents(); |
---|
3392 | 3727 | } |
---|
3393 | 3728 | |
---|
3394 | | - public void Undo() |
---|
| 3729 | + cButton undoButton; |
---|
| 3730 | + cButton restoreButton; |
---|
| 3731 | + cButton replaceButton; |
---|
| 3732 | + cButton redoButton; |
---|
| 3733 | + |
---|
| 3734 | + void SetUndoStates() |
---|
3395 | 3735 | { |
---|
3396 | 3736 | cRadio tab = GetCurrentTab(); |
---|
3397 | 3737 | |
---|
3398 | | - if (tab.undoindex == 0) |
---|
| 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); |
---|
| 3742 | + } |
---|
| 3743 | + |
---|
| 3744 | + public boolean Undo() |
---|
| 3745 | + { |
---|
| 3746 | + System.err.println("Undo"); |
---|
| 3747 | + |
---|
| 3748 | + cRadio tab = GetCurrentTab(); |
---|
| 3749 | + |
---|
| 3750 | + if (copy.versionindex == 0) |
---|
3399 | 3751 | { |
---|
3400 | 3752 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3401 | | - return; |
---|
| 3753 | + return false; |
---|
3402 | 3754 | } |
---|
3403 | 3755 | |
---|
3404 | | - 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) |
---|
3405 | 3783 | { |
---|
3406 | | - Save(); |
---|
3407 | | - tab.undoindex -= 1; |
---|
| 3784 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3785 | + return false; |
---|
3408 | 3786 | } |
---|
3409 | 3787 | |
---|
3410 | | - tab.undoindex -= 1; |
---|
| 3788 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3789 | + |
---|
| 3790 | + return true; |
---|
| 3791 | + } |
---|
3411 | 3792 | |
---|
3412 | | - 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; |
---|
3413 | 3808 | } |
---|
3414 | 3809 | |
---|
3415 | 3810 | public void Redo() |
---|
3416 | 3811 | { |
---|
3417 | 3812 | cRadio tab = GetCurrentTab(); |
---|
3418 | 3813 | |
---|
3419 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3814 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3420 | 3815 | { |
---|
3421 | 3816 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3422 | 3817 | return; |
---|
3423 | 3818 | } |
---|
3424 | 3819 | |
---|
3425 | | - tab.undoindex += 1; |
---|
| 3820 | + copy.versionindex += 1; |
---|
3426 | 3821 | |
---|
3427 | | - 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; |
---|
3428 | 3826 | } |
---|
3429 | 3827 | |
---|
3430 | 3828 | void ImportGFD() |
---|
.. | .. |
---|
3576 | 3974 | assert false; |
---|
3577 | 3975 | } |
---|
3578 | 3976 | |
---|
3579 | | - void EditSelection() |
---|
| 3977 | + void EditSelection(boolean newWindow) |
---|
3580 | 3978 | { |
---|
3581 | 3979 | } |
---|
3582 | 3980 | |
---|
.. | .. |
---|
3720 | 4118 | //copy.Touch(); |
---|
3721 | 4119 | } |
---|
3722 | 4120 | |
---|
| 4121 | + cNumberSlider versionField; |
---|
| 4122 | + |
---|
3723 | 4123 | public void stateChanged(ChangeEvent e) |
---|
3724 | 4124 | { |
---|
3725 | 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 | + } |
---|
3726 | 4137 | |
---|
3727 | 4138 | if (freezematerial) |
---|
3728 | 4139 | { |
---|
.. | .. |
---|
4071 | 4482 | |
---|
4072 | 4483 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4073 | 4484 | { |
---|
4074 | | - Save(); |
---|
| 4485 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
| 4486 | + Save(); |
---|
4075 | 4487 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4076 | 4488 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4077 | 4489 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4158 | 4570 | { |
---|
4159 | 4571 | ResetModel(); |
---|
4160 | 4572 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4573 | + |
---|
| 4574 | + if (thing.Size() == 0) |
---|
| 4575 | + { |
---|
| 4576 | + //EditSelection(false); |
---|
| 4577 | + } |
---|
| 4578 | + |
---|
4161 | 4579 | refreshContents(); |
---|
4162 | 4580 | } |
---|
4163 | 4581 | |
---|
.. | .. |
---|
4295 | 4713 | |
---|
4296 | 4714 | try |
---|
4297 | 4715 | { |
---|
| 4716 | + // Try compressed version first. |
---|
4298 | 4717 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4299 | 4718 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4300 | 4719 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4364 | 4783 | |
---|
4365 | 4784 | void LoadIt(Object obj) |
---|
4366 | 4785 | { |
---|
| 4786 | + if (obj == null) |
---|
| 4787 | + { |
---|
| 4788 | + // Invalid file |
---|
| 4789 | + return; |
---|
| 4790 | + } |
---|
| 4791 | + |
---|
4367 | 4792 | System.out.println("Loaded " + obj); |
---|
4368 | 4793 | //new Exception().printStackTrace(); |
---|
4369 | 4794 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4373 | 4798 | |
---|
4374 | 4799 | if (readobj != null) |
---|
4375 | 4800 | { |
---|
4376 | | - Save(); |
---|
| 4801 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4802 | + // Save(); |
---|
4377 | 4803 | try |
---|
4378 | 4804 | { |
---|
4379 | 4805 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4428 | 4854 | c.addChild(csg); |
---|
4429 | 4855 | } |
---|
4430 | 4856 | |
---|
| 4857 | + copy.versions = readobj.versions; |
---|
| 4858 | + copy.versionindex = readobj.versionindex; |
---|
| 4859 | + |
---|
| 4860 | + SetUndoStates(); |
---|
| 4861 | + |
---|
4431 | 4862 | ResetModel(); |
---|
4432 | 4863 | copy.HardTouch(); // recompile? |
---|
4433 | 4864 | refreshContents(); |
---|
4434 | 4865 | } |
---|
4435 | 4866 | } |
---|
4436 | 4867 | |
---|
4437 | | - void load() // throws ClassNotFoundException |
---|
| 4868 | + void Open() // throws ClassNotFoundException |
---|
4438 | 4869 | { |
---|
4439 | 4870 | if (Grafreed.standAlone) |
---|
4440 | 4871 | { |
---|
.. | .. |
---|
4551 | 4982 | String filename = browser.getFile(); |
---|
4552 | 4983 | if (filename != null && filename.length() > 0) |
---|
4553 | 4984 | { |
---|
| 4985 | + if (!filename.endsWith(".gfd")) |
---|
| 4986 | + filename += ".gfd"; |
---|
4554 | 4987 | lastname = browser.getDirectory() + filename; |
---|
4555 | 4988 | save(); |
---|
4556 | 4989 | } |
---|
.. | .. |
---|
4717 | 5150 | MenuBar menuBar; |
---|
4718 | 5151 | Menu fileMenu; |
---|
4719 | 5152 | MenuItem newItem; |
---|
4720 | | - MenuItem loadItem; |
---|
| 5153 | + MenuItem openItem; |
---|
4721 | 5154 | MenuItem saveItem; |
---|
4722 | 5155 | MenuItem saveAsItem; |
---|
4723 | 5156 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4740 | 5173 | CheckboxMenuItem toggleSwitchItem; |
---|
4741 | 5174 | CheckboxMenuItem toggleRootItem; |
---|
4742 | 5175 | CheckboxMenuItem animationItem; |
---|
| 5176 | + MenuItem archiveItem; |
---|
4743 | 5177 | CheckboxMenuItem toggleHandleItem; |
---|
4744 | 5178 | CheckboxMenuItem togglePaintItem; |
---|
4745 | 5179 | JSplitPane mainPanel; |
---|
4746 | 5180 | JScrollPane scrollpane; |
---|
| 5181 | + |
---|
4747 | 5182 | JPanel toolbarPanel; |
---|
| 5183 | + |
---|
4748 | 5184 | cGridBag treePanel; |
---|
| 5185 | + |
---|
4749 | 5186 | JPanel radioPanel; |
---|
4750 | 5187 | ButtonGroup buttonGroup; |
---|
4751 | | - cGridBag ctrlPanel; |
---|
| 5188 | + |
---|
| 5189 | + cGridBag toolboxPanel; |
---|
4752 | 5190 | cGridBag materialPanel; |
---|
| 5191 | + cGridBag ctrlPanel; |
---|
| 5192 | + |
---|
4753 | 5193 | JScrollPane infoPanel; |
---|
| 5194 | + |
---|
4754 | 5195 | cGridBag optionsPanel; |
---|
| 5196 | + |
---|
4755 | 5197 | JTabbedPane objectPanel; |
---|
| 5198 | + boolean materialFlushed; |
---|
| 5199 | + Object3D latestObject; |
---|
| 5200 | + |
---|
4756 | 5201 | cGridBag XYZPanel; |
---|
| 5202 | + |
---|
4757 | 5203 | JSplitPane gridPanel; |
---|
4758 | 5204 | JSplitPane bigPanel; |
---|
| 5205 | + |
---|
4759 | 5206 | cGridBag bigThree; |
---|
4760 | 5207 | cGridBag scenePanel; |
---|
4761 | 5208 | cGridBag centralPanel; |
---|
.. | .. |
---|
4870 | 5317 | cNumberSlider fogField; |
---|
4871 | 5318 | JLabel opacityPowerLabel; |
---|
4872 | 5319 | cNumberSlider opacityPowerField; |
---|
4873 | | - JTree jTree; |
---|
| 5320 | + cTree jTree; |
---|
4874 | 5321 | //ObjectUI parent; |
---|
4875 | 5322 | |
---|
4876 | 5323 | cNumberSlider normalpushField; |
---|