.. | .. |
---|
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("Load...")); |
---|
| 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 | } |
---|
600 | 818 | |
---|
601 | 819 | private JTextPane createTextPane() |
---|
.. | .. |
---|
736 | 954 | JCheckBox speedupCB; |
---|
737 | 955 | JCheckBox rewindCB; |
---|
738 | 956 | JCheckBox flipVCB; |
---|
| 957 | + |
---|
| 958 | + cCheckBox toggleTextureCB; |
---|
| 959 | + cCheckBox toggleSwitchCB; |
---|
| 960 | + |
---|
739 | 961 | JComboBox texresMenu; |
---|
| 962 | + |
---|
740 | 963 | JButton resetButton; |
---|
741 | 964 | JButton stepButton; |
---|
742 | 965 | JButton stepAllButton; |
---|
.. | .. |
---|
745 | 968 | JButton fasterButton; |
---|
746 | 969 | JButton remarkButton; |
---|
747 | 970 | |
---|
| 971 | + cGridBag editPanel; |
---|
| 972 | + cGridBag editCommandsPanel; |
---|
| 973 | + |
---|
748 | 974 | cGridBag namePanel; |
---|
749 | 975 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 976 | + cGridBag setupPanel2; |
---|
| 977 | + cGridBag objectCommandsPanel; |
---|
751 | 978 | cGridBag pushPanel; |
---|
752 | 979 | cGridBag fillPanel; |
---|
753 | 980 | |
---|
.. | .. |
---|
919 | 1146 | namePanel = new cGridBag(); |
---|
920 | 1147 | |
---|
921 | 1148 | nameField = AddText(namePanel, copy.GetName()); |
---|
922 | | - namePanel.add(nameField); |
---|
| 1149 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
923 | 1150 | oe.ctrlPanel.add(namePanel); |
---|
924 | 1151 | |
---|
925 | 1152 | oe.ctrlPanel.Return(); |
---|
926 | 1153 | |
---|
927 | | - if (!GroupEditor.allparams) |
---|
| 1154 | + if (!allparams) |
---|
928 | 1155 | return; |
---|
929 | 1156 | |
---|
930 | 1157 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
937 | 1164 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
938 | 1165 | hideCB.setToolTipText("Hide object"); |
---|
939 | 1166 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1167 | + markCB.setToolTipText("As animation target transform"); |
---|
941 | 1168 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1169 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1170 | + |
---|
| 1171 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1172 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1173 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1174 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
| 1175 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
947 | 1176 | |
---|
| 1177 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1178 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1179 | + |
---|
948 | 1180 | if (Globals.ADVANCED) |
---|
949 | 1181 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
951 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1182 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1183 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1184 | } |
---|
955 | 1185 | |
---|
956 | 1186 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1187 | oe.ctrlPanel.Return(); |
---|
| 1188 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1189 | + oe.ctrlPanel.Return(); |
---|
958 | 1190 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1191 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1192 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1193 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1194 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1195 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1196 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1197 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1198 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1199 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1200 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1201 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1202 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1203 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1204 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1205 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1206 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1207 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1208 | oe.ctrlPanel.Return(); |
---|
977 | 1209 | |
---|
978 | 1210 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1410 | //worldPanel.setName("World"); |
---|
1179 | 1411 | centralPanel = new cGridBag(); |
---|
1180 | 1412 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1413 | + |
---|
| 1414 | + if (Globals.ADVANCED) |
---|
| 1415 | + { |
---|
| 1416 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1417 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1418 | |
---|
1184 | 1419 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1420 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1423 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1424 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1425 | |
---|
| 1426 | + } |
---|
| 1427 | + |
---|
1191 | 1428 | centralPanel.add(cameraView); |
---|
| 1429 | + centralPanel.setFocusable(true); |
---|
1192 | 1430 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1431 | //centralPanel.add(timelinePanel); |
---|
1194 | 1432 | |
---|
.. | .. |
---|
1255 | 1493 | // north.setName("Edit"); |
---|
1256 | 1494 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1495 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
1259 | | - objectPanel.add(infoPanel); |
---|
| 1496 | + objectPanel.add(editPanel); |
---|
| 1497 | + |
---|
| 1498 | + //if (Globals.ADVANCED) |
---|
| 1499 | + objectPanel.add(infoPanel); |
---|
| 1500 | + |
---|
| 1501 | + objectPanel.add(toolboxPanel); |
---|
1260 | 1502 | |
---|
1261 | 1503 | /* |
---|
1262 | 1504 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1265 | 1507 | aConstraints.gridy += 1; |
---|
1266 | 1508 | aConstraints.gridwidth = 1; |
---|
1267 | 1509 | mainPanel.add(objectPanel, aConstraints); |
---|
1268 | | - */ |
---|
| 1510 | + */ |
---|
1269 | 1511 | |
---|
1270 | 1512 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1271 | 1513 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1282 | 1524 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1283 | 1525 | tabbedPane.add(scrollpane); |
---|
1284 | 1526 | |
---|
1285 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1286 | | - |
---|
1287 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1527 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1288 | 1528 | |
---|
1289 | 1529 | optionsPanel.setName("Options"); |
---|
1290 | 1530 | |
---|
.. | .. |
---|
1292 | 1532 | |
---|
1293 | 1533 | tabbedPane.add(optionsPanel); |
---|
1294 | 1534 | |
---|
| 1535 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1536 | + |
---|
1295 | 1537 | scenePanel.add(tabbedPane); |
---|
1296 | 1538 | |
---|
1297 | 1539 | /* |
---|
.. | .. |
---|
1364 | 1606 | // aConstraints.gridheight = 1; |
---|
1365 | 1607 | |
---|
1366 | 1608 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1367 | | - framePanel.setContinuousLayout(true); |
---|
1368 | | - framePanel.setOneTouchExpandable(true); |
---|
1369 | | - framePanel.setDividerLocation(0.8); |
---|
| 1609 | + framePanel.setContinuousLayout(false); |
---|
| 1610 | + framePanel.setOneTouchExpandable(false); |
---|
| 1611 | + //.setDividerLocation(0.8); |
---|
1370 | 1612 | //framePanel.setDividerSize(15); |
---|
1371 | 1613 | //framePanel.setResizeWeight(0.15); |
---|
1372 | 1614 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1384 | 1626 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1385 | 1627 | |
---|
1386 | 1628 | frame.setSize(1280, 860); |
---|
1387 | | - frame.setVisible(true); |
---|
1388 | | - |
---|
| 1629 | + |
---|
| 1630 | + cameraView.requestFocusInWindow(); |
---|
| 1631 | + |
---|
1389 | 1632 | gridPanel.setDividerLocation(1.0); |
---|
| 1633 | + |
---|
| 1634 | + frame.validate(); |
---|
| 1635 | + |
---|
| 1636 | + frame.setVisible(true); |
---|
1390 | 1637 | |
---|
1391 | 1638 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1392 | 1639 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1473 | 1720 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1474 | 1721 | colorSection.add(texture); |
---|
1475 | 1722 | |
---|
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 | 1723 | panel.add(new JSeparator()); |
---|
1495 | 1724 | |
---|
1496 | 1725 | panel.add(colorSection); |
---|
.. | .. |
---|
1540 | 1769 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1541 | 1770 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1542 | 1771 | diffuseSection.add(fakedepth); |
---|
| 1772 | + |
---|
| 1773 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1774 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1775 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1776 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1777 | + diffuseSection.add(shadowbias); |
---|
1543 | 1778 | |
---|
1544 | 1779 | panel.add(new JSeparator()); |
---|
1545 | 1780 | |
---|
.. | .. |
---|
1591 | 1826 | // aConstraints.gridy += 1; |
---|
1592 | 1827 | // aConstraints.gridwidth = 1; |
---|
1593 | 1828 | |
---|
| 1829 | + cGridBag anisoU = new cGridBag(); |
---|
| 1830 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1831 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1832 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1833 | + specularSection.add(anisoU); |
---|
| 1834 | + |
---|
| 1835 | + cGridBag anisoV = new cGridBag(); |
---|
| 1836 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1837 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1838 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1839 | + specularSection.add(anisoV); |
---|
| 1840 | + |
---|
1594 | 1841 | |
---|
1595 | 1842 | panel.add(new JSeparator()); |
---|
1596 | 1843 | |
---|
.. | .. |
---|
1598 | 1845 | |
---|
1599 | 1846 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1600 | 1847 | |
---|
1601 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1848 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1602 | 1849 | |
---|
1603 | 1850 | cGridBag camera = new cGridBag(); |
---|
1604 | 1851 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1605 | 1852 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1606 | 1853 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1607 | | - globalSection.add(camera); |
---|
| 1854 | + colorSection.add(camera); |
---|
1608 | 1855 | |
---|
1609 | 1856 | cGridBag ambient = new cGridBag(); |
---|
1610 | 1857 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1611 | 1858 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1612 | 1859 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1613 | | - globalSection.add(ambient); |
---|
| 1860 | + colorSection.add(ambient); |
---|
1614 | 1861 | |
---|
1615 | 1862 | cGridBag backlit = new cGridBag(); |
---|
1616 | 1863 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1617 | 1864 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1618 | 1865 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1619 | | - globalSection.add(backlit); |
---|
| 1866 | + colorSection.add(backlit); |
---|
1620 | 1867 | |
---|
1621 | 1868 | cGridBag opacity = new cGridBag(); |
---|
1622 | 1869 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1623 | 1870 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1624 | 1871 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1625 | | - globalSection.add(opacity); |
---|
| 1872 | + colorSection.add(opacity); |
---|
1626 | 1873 | |
---|
1627 | | - panel.add(new JSeparator()); |
---|
| 1874 | + //panel.add(new JSeparator()); |
---|
1628 | 1875 | |
---|
1629 | | - panel.add(globalSection); |
---|
| 1876 | + //panel.add(globalSection); |
---|
1630 | 1877 | |
---|
1631 | 1878 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1632 | 1879 | |
---|
.. | .. |
---|
1733 | 1980 | // 3D models |
---|
1734 | 1981 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1735 | 1982 | { |
---|
1736 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1737 | | - LoadFile(filename, lastConverter); |
---|
| 1983 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1984 | + //LoadFile(filename, lastConverter); |
---|
| 1985 | + LoadObjFile(filename); // New 3ds loader |
---|
1738 | 1986 | continue; |
---|
1739 | 1987 | } |
---|
1740 | 1988 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
1935 | 2183 | e2.printStackTrace(); |
---|
1936 | 2184 | } |
---|
1937 | 2185 | } |
---|
| 2186 | + |
---|
1938 | 2187 | LoadJMEThread loadThread; |
---|
1939 | 2188 | |
---|
1940 | 2189 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 2241 | //LoadFile0(filename, converter); |
---|
1993 | 2242 | } |
---|
1994 | 2243 | } |
---|
| 2244 | + |
---|
1995 | 2245 | LoadOBJThread loadObjThread; |
---|
1996 | 2246 | |
---|
1997 | 2247 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
2070 | 2320 | |
---|
2071 | 2321 | void LoadObjFile(String fullname) |
---|
2072 | 2322 | { |
---|
2073 | | - /* |
---|
| 2323 | + System.out.println("Loading " + fullname); |
---|
| 2324 | + /**/ |
---|
2074 | 2325 | //lastFilename = fullname; |
---|
2075 | 2326 | if(loadObjThread == null) |
---|
2076 | 2327 | { |
---|
2077 | | - loadObjThread = new LoadOBJThread(); |
---|
2078 | | - loadObjThread.start(); |
---|
| 2328 | + loadObjThread = new LoadOBJThread(); |
---|
| 2329 | + loadObjThread.start(); |
---|
2079 | 2330 | } |
---|
2080 | 2331 | |
---|
2081 | 2332 | loadObjThread.add(fullname); |
---|
2082 | | - */ |
---|
| 2333 | + /**/ |
---|
2083 | 2334 | |
---|
2084 | | - System.out.println("Loading " + fullname); |
---|
2085 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2335 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2086 | 2336 | } |
---|
2087 | 2337 | |
---|
2088 | 2338 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2458 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2459 | 2709 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2460 | 2710 | } |
---|
| 2711 | + |
---|
2461 | 2712 | //cJME.count++; |
---|
2462 | 2713 | //cJME.count %= 12; |
---|
2463 | 2714 | if (gc) |
---|
.. | .. |
---|
2641 | 2892 | } |
---|
2642 | 2893 | } |
---|
2643 | 2894 | } |
---|
| 2895 | + |
---|
2644 | 2896 | cFileSystemPane FSPane; |
---|
2645 | 2897 | |
---|
2646 | 2898 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2694 | 2946 | } |
---|
2695 | 2947 | } |
---|
2696 | 2948 | } |
---|
| 2949 | + |
---|
2697 | 2950 | freezematerial = false; |
---|
2698 | 2951 | } |
---|
2699 | 2952 | |
---|
2700 | 2953 | void SetMaterial(Object3D object) |
---|
2701 | 2954 | { |
---|
| 2955 | + latestObject = object; |
---|
| 2956 | + |
---|
2702 | 2957 | cMaterial mat = object.material; |
---|
2703 | 2958 | |
---|
2704 | 2959 | if (mat == null) |
---|
.. | .. |
---|
2810 | 3065 | // } |
---|
2811 | 3066 | |
---|
2812 | 3067 | /**/ |
---|
2813 | | - if (deselect) |
---|
| 3068 | + if (deselect || child == null) |
---|
2814 | 3069 | { |
---|
2815 | 3070 | //group.deselectAll(); |
---|
2816 | 3071 | //freeze = true; |
---|
2817 | 3072 | GetTree().clearSelection(); |
---|
2818 | 3073 | //freeze = false; |
---|
| 3074 | + |
---|
| 3075 | + if (child == null) |
---|
| 3076 | + { |
---|
| 3077 | + return; |
---|
| 3078 | + } |
---|
2819 | 3079 | } |
---|
2820 | 3080 | |
---|
2821 | 3081 | //group.addSelectee(child); |
---|
.. | .. |
---|
2884 | 3144 | cameraView.ToggleDL(); |
---|
2885 | 3145 | cameraView.repaint(); |
---|
2886 | 3146 | return; |
---|
2887 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3147 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2888 | 3148 | { |
---|
2889 | 3149 | cameraView.ToggleTexture(); |
---|
2890 | 3150 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
2923 | 3183 | frame.validate(); |
---|
2924 | 3184 | |
---|
2925 | 3185 | return; |
---|
2926 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3186 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
2927 | 3187 | { |
---|
2928 | | - cameraView.ToggleRandom(); |
---|
| 3188 | + cameraView.ToggleSwitch(); |
---|
2929 | 3189 | cameraView.repaint(); |
---|
2930 | 3190 | return; |
---|
2931 | 3191 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3139 | 3399 | { |
---|
3140 | 3400 | Close(); |
---|
3141 | 3401 | //return true; |
---|
3142 | | - } else if (source == loadItem) |
---|
| 3402 | + } else if (source == openItem) |
---|
3143 | 3403 | { |
---|
3144 | | - load(); |
---|
| 3404 | + Open(); |
---|
3145 | 3405 | //return true; |
---|
3146 | 3406 | } else if (source == newItem) |
---|
3147 | 3407 | { |
---|
.. | .. |
---|
3166 | 3426 | { |
---|
3167 | 3427 | generatePOV(); |
---|
3168 | 3428 | //return true; |
---|
| 3429 | + } else if (event.getSource() == archiveItem) |
---|
| 3430 | + { |
---|
| 3431 | + cTools.Archive(frame); |
---|
| 3432 | + return; |
---|
3169 | 3433 | } else if (source == zBufferItem) |
---|
3170 | 3434 | { |
---|
3171 | 3435 | try |
---|
.. | .. |
---|
3212 | 3476 | objEditor.refreshContents(); |
---|
3213 | 3477 | } |
---|
3214 | 3478 | |
---|
3215 | | - Object3D graphs[] = new Object3D[10000]; |
---|
3216 | | - int undoindex = 0; |
---|
3217 | | - |
---|
3218 | | - static public Object clone(Object o) |
---|
| 3479 | + static public byte[] Compress(Object3D o) |
---|
3219 | 3480 | { |
---|
3220 | 3481 | try |
---|
3221 | 3482 | { |
---|
3222 | 3483 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3484 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3485 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3224 | 3486 | |
---|
| 3487 | + Object3D parent = o.parent; |
---|
| 3488 | + o.parent = null; |
---|
| 3489 | + |
---|
3225 | 3490 | out.writeObject(o); |
---|
| 3491 | + |
---|
| 3492 | + o.parent = parent; |
---|
| 3493 | + |
---|
| 3494 | + out.flush(); |
---|
3226 | 3495 | |
---|
3227 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
3228 | | - ObjectInputStream in = new ObjectInputStream(bais); |
---|
3229 | | - Object obj = in.readObject(); |
---|
3230 | | - in.close(); |
---|
| 3496 | + baos //zstream |
---|
| 3497 | + .close(); |
---|
3231 | 3498 | out.close(); |
---|
| 3499 | + |
---|
| 3500 | + byte[] bytes = baos.toByteArray(); |
---|
| 3501 | + |
---|
| 3502 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3503 | + return bytes; |
---|
| 3504 | + } catch (Exception e) |
---|
| 3505 | + { |
---|
| 3506 | + System.err.println(e); |
---|
| 3507 | + return null; |
---|
| 3508 | + } |
---|
| 3509 | + } |
---|
| 3510 | + |
---|
| 3511 | + static public Object Uncompress(byte[] bytes) |
---|
| 3512 | + { |
---|
| 3513 | + System.out.println("restore #bytes = " + bytes.length); |
---|
| 3514 | + try |
---|
| 3515 | + { |
---|
| 3516 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3517 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3518 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
| 3519 | + Object obj = in.readObject(); |
---|
| 3520 | + |
---|
| 3521 | + bais //istream |
---|
| 3522 | + .close(); |
---|
| 3523 | + in.close(); |
---|
| 3524 | + |
---|
3232 | 3525 | return obj; |
---|
3233 | 3526 | } catch (Exception e) |
---|
3234 | 3527 | { |
---|
.. | .. |
---|
3237 | 3530 | } |
---|
3238 | 3531 | } |
---|
3239 | 3532 | |
---|
| 3533 | + static public Object clone(Object o) |
---|
| 3534 | + { |
---|
| 3535 | + try |
---|
| 3536 | + { |
---|
| 3537 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3538 | + ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3539 | + |
---|
| 3540 | + out.writeObject(o); |
---|
| 3541 | + |
---|
| 3542 | + out.flush(); |
---|
| 3543 | + out.close(); |
---|
| 3544 | + |
---|
| 3545 | + byte[] bytes = baos.toByteArray(); |
---|
| 3546 | + |
---|
| 3547 | + System.out.println("clone = " + bytes.length); |
---|
| 3548 | + |
---|
| 3549 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3550 | + ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3551 | + Object obj = in.readObject(); |
---|
| 3552 | + in.close(); |
---|
| 3553 | + |
---|
| 3554 | + return obj; |
---|
| 3555 | + } catch (Exception e) |
---|
| 3556 | + { |
---|
| 3557 | + System.err.println(e); |
---|
| 3558 | + return null; |
---|
| 3559 | + } |
---|
| 3560 | + } |
---|
| 3561 | + |
---|
| 3562 | + cRadio GetCurrentTab() |
---|
| 3563 | + { |
---|
| 3564 | + cRadio ab; |
---|
| 3565 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3566 | + { |
---|
| 3567 | + ab = (cRadio)e.nextElement(); |
---|
| 3568 | + if(ab.GetObject() == copy) |
---|
| 3569 | + { |
---|
| 3570 | + return ab; |
---|
| 3571 | + } |
---|
| 3572 | + } |
---|
| 3573 | + |
---|
| 3574 | + return null; |
---|
| 3575 | + } |
---|
| 3576 | + |
---|
| 3577 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3578 | + |
---|
3240 | 3579 | public void Save() |
---|
3241 | 3580 | { |
---|
3242 | | - if (true) return; |
---|
| 3581 | + Save(true); |
---|
| 3582 | + } |
---|
| 3583 | + |
---|
| 3584 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3585 | + { |
---|
| 3586 | + if (compress.length != name.length) |
---|
| 3587 | + { |
---|
| 3588 | + return false; |
---|
| 3589 | + } |
---|
| 3590 | + |
---|
| 3591 | + for (int i=compress.length; --i>=0;) |
---|
| 3592 | + { |
---|
| 3593 | + if (compress[i] != name[i]) |
---|
| 3594 | + return false; |
---|
| 3595 | + } |
---|
| 3596 | + |
---|
| 3597 | + return true; |
---|
| 3598 | + } |
---|
| 3599 | + |
---|
| 3600 | + public boolean Save(boolean user) |
---|
| 3601 | + { |
---|
| 3602 | + System.err.println("Save"); |
---|
| 3603 | + |
---|
| 3604 | + cRadio tab = GetCurrentTab(); |
---|
| 3605 | + |
---|
| 3606 | + boolean temp = CameraPane.SWITCH; |
---|
| 3607 | + CameraPane.SWITCH = false; |
---|
| 3608 | + |
---|
| 3609 | + copy.ExtractBigData(hashtable); |
---|
| 3610 | + |
---|
| 3611 | + byte[] compress = Compress(copy); |
---|
| 3612 | + |
---|
| 3613 | + CameraPane.SWITCH = temp; |
---|
| 3614 | + |
---|
| 3615 | + boolean thesame = false; |
---|
| 3616 | + |
---|
| 3617 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3618 | + if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) |
---|
| 3619 | + { |
---|
| 3620 | + thesame = true; |
---|
| 3621 | + } |
---|
3243 | 3622 | |
---|
3244 | 3623 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3245 | | - graphs[undoindex++] = (Object3D)clone(copy); |
---|
3246 | | - |
---|
3247 | | - for (int i = undoindex; i < graphs.length; i++) |
---|
| 3624 | + if (!thesame) |
---|
3248 | 3625 | { |
---|
3249 | | - graphs[i] = null; |
---|
| 3626 | + //tab.user[tab.undoindex] = user; |
---|
| 3627 | + boolean increment = tab.graphs[tab.undoindex] == null; |
---|
| 3628 | + |
---|
| 3629 | + tab.graphs[tab.undoindex] = compress; |
---|
| 3630 | + |
---|
| 3631 | + if (increment) |
---|
| 3632 | + tab.undoindex++; |
---|
3250 | 3633 | } |
---|
3251 | 3634 | |
---|
| 3635 | + copy.RestoreBigData(hashtable); |
---|
| 3636 | + |
---|
| 3637 | + //assert(hashtable.isEmpty()); |
---|
| 3638 | + |
---|
| 3639 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3640 | + { |
---|
| 3641 | + //tab.user[i] = false; |
---|
| 3642 | + // tab.graphs[i] = null; |
---|
| 3643 | + } |
---|
| 3644 | + |
---|
| 3645 | + SetUndoStates(); |
---|
| 3646 | + |
---|
3252 | 3647 | // test save |
---|
3253 | 3648 | if (false) |
---|
3254 | 3649 | { |
---|
3255 | 3650 | try |
---|
3256 | 3651 | { |
---|
3257 | | - FileOutputStream ostream = new FileOutputStream("save" + undoindex); |
---|
| 3652 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
3258 | 3653 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3259 | 3654 | |
---|
3260 | 3655 | p.writeObject(copy); |
---|
.. | .. |
---|
3267 | 3662 | e.printStackTrace(); |
---|
3268 | 3663 | } |
---|
3269 | 3664 | } |
---|
| 3665 | + |
---|
| 3666 | + return !thesame; |
---|
3270 | 3667 | } |
---|
3271 | 3668 | |
---|
3272 | | - public void Undo() |
---|
| 3669 | + void CopyChanged(Object3D obj) |
---|
3273 | 3670 | { |
---|
3274 | | - if (undoindex == 0) |
---|
3275 | | - { |
---|
3276 | | - java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3277 | | - return; |
---|
3278 | | - } |
---|
3279 | | - |
---|
3280 | | - if (graphs[undoindex] == null) |
---|
3281 | | - { |
---|
3282 | | - Save(); |
---|
3283 | | - undoindex -= 1; |
---|
3284 | | - } |
---|
3285 | | - |
---|
3286 | | - undoindex -= 1; |
---|
3287 | | - |
---|
3288 | | - copy = graphs[undoindex]; |
---|
| 3671 | + SetUndoStates(); |
---|
3289 | 3672 | |
---|
3290 | | - cameraView.object = copy; |
---|
| 3673 | + boolean temp = CameraPane.SWITCH; |
---|
| 3674 | + CameraPane.SWITCH = false; |
---|
| 3675 | + |
---|
| 3676 | + copy.ExtractBigData(hashtable); |
---|
| 3677 | + |
---|
| 3678 | + copy.clear(); |
---|
| 3679 | + |
---|
| 3680 | + for (int i=0; i<obj.Size(); i++) |
---|
| 3681 | + { |
---|
| 3682 | + copy.add(obj.get(i)); |
---|
| 3683 | + } |
---|
| 3684 | + |
---|
| 3685 | + copy.RestoreBigData(hashtable); |
---|
| 3686 | + |
---|
| 3687 | + CameraPane.SWITCH = temp; |
---|
| 3688 | + |
---|
| 3689 | + //assert(hashtable.isEmpty()); |
---|
| 3690 | + |
---|
3291 | 3691 | copy.Touch(); |
---|
3292 | 3692 | |
---|
3293 | 3693 | ResetModel(); |
---|
| 3694 | + copy.HardTouch(); // recompile? |
---|
| 3695 | + |
---|
| 3696 | + cRadio ab; |
---|
| 3697 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3698 | + { |
---|
| 3699 | + ab = (cRadio)e.nextElement(); |
---|
| 3700 | + Object3D test = copy.GetObject(ab.object.GetUUID()); |
---|
| 3701 | + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); |
---|
| 3702 | + if (test != null) |
---|
| 3703 | + { |
---|
| 3704 | + test.editWindow = ab.object.editWindow; |
---|
| 3705 | + ab.object = test; |
---|
| 3706 | + } |
---|
| 3707 | + } |
---|
| 3708 | + |
---|
3294 | 3709 | refreshContents(); |
---|
| 3710 | + } |
---|
| 3711 | + |
---|
| 3712 | + cButton undoButton; |
---|
| 3713 | + cButton redoButton; |
---|
| 3714 | + |
---|
| 3715 | + void SetUndoStates() |
---|
| 3716 | + { |
---|
| 3717 | + cRadio tab = GetCurrentTab(); |
---|
| 3718 | + |
---|
| 3719 | + undoButton.setEnabled(tab.undoindex > 0); |
---|
| 3720 | + redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3721 | + } |
---|
| 3722 | + |
---|
| 3723 | + public boolean Undo() |
---|
| 3724 | + { |
---|
| 3725 | + System.err.println("Undo"); |
---|
| 3726 | + |
---|
| 3727 | + cRadio tab = GetCurrentTab(); |
---|
| 3728 | + |
---|
| 3729 | + if (tab.undoindex == 0) |
---|
| 3730 | + { |
---|
| 3731 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3732 | + return false; |
---|
| 3733 | + } |
---|
| 3734 | + |
---|
| 3735 | + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
| 3736 | + { |
---|
| 3737 | + if (Save(false)) |
---|
| 3738 | + tab.undoindex -= 1; |
---|
| 3739 | + else |
---|
| 3740 | + { |
---|
| 3741 | + if (tab.undoindex <= 0) |
---|
| 3742 | + return false; |
---|
| 3743 | + else |
---|
| 3744 | + tab.undoindex -= 1; |
---|
| 3745 | + } |
---|
| 3746 | + } |
---|
| 3747 | + |
---|
| 3748 | + tab.undoindex -= 1; |
---|
| 3749 | + |
---|
| 3750 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3751 | + |
---|
| 3752 | + return true; |
---|
3295 | 3753 | } |
---|
3296 | 3754 | |
---|
3297 | 3755 | public void Redo() |
---|
3298 | 3756 | { |
---|
3299 | | - if (graphs[undoindex + 1] == null) |
---|
| 3757 | + cRadio tab = GetCurrentTab(); |
---|
| 3758 | + |
---|
| 3759 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
3300 | 3760 | { |
---|
3301 | 3761 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3302 | 3762 | return; |
---|
3303 | 3763 | } |
---|
3304 | 3764 | |
---|
3305 | | - undoindex += 1; |
---|
| 3765 | + tab.undoindex += 1; |
---|
3306 | 3766 | |
---|
3307 | | - copy = graphs[undoindex]; |
---|
3308 | | - |
---|
3309 | | - cameraView.object = copy; |
---|
3310 | | - copy.Touch(); |
---|
| 3767 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3311 | 3768 | |
---|
3312 | | - ResetModel(); |
---|
3313 | | - refreshContents(); |
---|
| 3769 | + //if (!tab.user[tab.undoindex]) |
---|
| 3770 | + // tab.graphs[tab.undoindex] = null; |
---|
3314 | 3771 | } |
---|
3315 | 3772 | |
---|
3316 | 3773 | void ImportGFD() |
---|
.. | .. |
---|
3462 | 3919 | assert false; |
---|
3463 | 3920 | } |
---|
3464 | 3921 | |
---|
3465 | | - void EditSelection() |
---|
| 3922 | + void EditSelection(boolean newWindow) |
---|
3466 | 3923 | { |
---|
3467 | 3924 | } |
---|
3468 | 3925 | |
---|
.. | .. |
---|
3957 | 4414 | |
---|
3958 | 4415 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3959 | 4416 | { |
---|
3960 | | - Save(); |
---|
| 4417 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4418 | + Save(); |
---|
3961 | 4419 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3962 | 4420 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3963 | 4421 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4044 | 4502 | { |
---|
4045 | 4503 | ResetModel(); |
---|
4046 | 4504 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4505 | + |
---|
| 4506 | + if (thing.Size() == 0) |
---|
| 4507 | + { |
---|
| 4508 | + //EditSelection(false); |
---|
| 4509 | + } |
---|
| 4510 | + |
---|
4047 | 4511 | refreshContents(); |
---|
4048 | 4512 | } |
---|
4049 | 4513 | |
---|
.. | .. |
---|
4181 | 4645 | |
---|
4182 | 4646 | try |
---|
4183 | 4647 | { |
---|
| 4648 | + // Try compressed version first. |
---|
4184 | 4649 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4185 | 4650 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4186 | 4651 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4250 | 4715 | |
---|
4251 | 4716 | void LoadIt(Object obj) |
---|
4252 | 4717 | { |
---|
| 4718 | + if (obj == null) |
---|
| 4719 | + { |
---|
| 4720 | + // Invalid file |
---|
| 4721 | + return; |
---|
| 4722 | + } |
---|
| 4723 | + |
---|
4253 | 4724 | System.out.println("Loaded " + obj); |
---|
4254 | 4725 | //new Exception().printStackTrace(); |
---|
4255 | 4726 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4259 | 4730 | |
---|
4260 | 4731 | if (readobj != null) |
---|
4261 | 4732 | { |
---|
| 4733 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4734 | + // Save(); |
---|
4262 | 4735 | try |
---|
4263 | 4736 | { |
---|
4264 | 4737 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4319 | 4792 | } |
---|
4320 | 4793 | } |
---|
4321 | 4794 | |
---|
4322 | | - void load() // throws ClassNotFoundException |
---|
| 4795 | + void Open() // throws ClassNotFoundException |
---|
4323 | 4796 | { |
---|
4324 | 4797 | if (Grafreed.standAlone) |
---|
4325 | 4798 | { |
---|
.. | .. |
---|
4436 | 4909 | String filename = browser.getFile(); |
---|
4437 | 4910 | if (filename != null && filename.length() > 0) |
---|
4438 | 4911 | { |
---|
| 4912 | + if (!filename.endsWith(".gfd")) |
---|
| 4913 | + filename += ".gfd"; |
---|
4439 | 4914 | lastname = browser.getDirectory() + filename; |
---|
4440 | 4915 | save(); |
---|
4441 | 4916 | } |
---|
.. | .. |
---|
4602 | 5077 | MenuBar menuBar; |
---|
4603 | 5078 | Menu fileMenu; |
---|
4604 | 5079 | MenuItem newItem; |
---|
4605 | | - MenuItem loadItem; |
---|
| 5080 | + MenuItem openItem; |
---|
4606 | 5081 | MenuItem saveItem; |
---|
4607 | 5082 | MenuItem saveAsItem; |
---|
4608 | 5083 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4625 | 5100 | CheckboxMenuItem toggleSwitchItem; |
---|
4626 | 5101 | CheckboxMenuItem toggleRootItem; |
---|
4627 | 5102 | CheckboxMenuItem animationItem; |
---|
| 5103 | + MenuItem archiveItem; |
---|
4628 | 5104 | CheckboxMenuItem toggleHandleItem; |
---|
4629 | 5105 | CheckboxMenuItem togglePaintItem; |
---|
4630 | 5106 | JSplitPane mainPanel; |
---|
4631 | 5107 | JScrollPane scrollpane; |
---|
| 5108 | + |
---|
4632 | 5109 | JPanel toolbarPanel; |
---|
| 5110 | + |
---|
4633 | 5111 | cGridBag treePanel; |
---|
| 5112 | + |
---|
4634 | 5113 | JPanel radioPanel; |
---|
4635 | 5114 | ButtonGroup buttonGroup; |
---|
4636 | | - cGridBag ctrlPanel; |
---|
| 5115 | + |
---|
| 5116 | + cGridBag toolboxPanel; |
---|
4637 | 5117 | cGridBag materialPanel; |
---|
| 5118 | + cGridBag ctrlPanel; |
---|
| 5119 | + |
---|
4638 | 5120 | JScrollPane infoPanel; |
---|
| 5121 | + |
---|
4639 | 5122 | cGridBag optionsPanel; |
---|
| 5123 | + |
---|
4640 | 5124 | JTabbedPane objectPanel; |
---|
| 5125 | + boolean materialFlushed; |
---|
| 5126 | + Object3D latestObject; |
---|
| 5127 | + |
---|
4641 | 5128 | cGridBag XYZPanel; |
---|
| 5129 | + |
---|
4642 | 5130 | JSplitPane gridPanel; |
---|
4643 | 5131 | JSplitPane bigPanel; |
---|
| 5132 | + |
---|
4644 | 5133 | cGridBag bigThree; |
---|
4645 | 5134 | cGridBag scenePanel; |
---|
4646 | 5135 | cGridBag centralPanel; |
---|
.. | .. |
---|
4755 | 5244 | cNumberSlider fogField; |
---|
4756 | 5245 | JLabel opacityPowerLabel; |
---|
4757 | 5246 | cNumberSlider opacityPowerField; |
---|
4758 | | - JTree jTree; |
---|
| 5247 | + cTree jTree; |
---|
4759 | 5248 | //ObjectUI parent; |
---|
4760 | 5249 | |
---|
4761 | 5250 | cNumberSlider normalpushField; |
---|