.. | .. |
---|
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 | |
---|
.. | .. |
---|
216 | 282 | client = inClient; |
---|
217 | 283 | copy = client; |
---|
218 | 284 | |
---|
| 285 | + if (copy.versions == null) |
---|
| 286 | + { |
---|
| 287 | + copy.versions = new byte[100][]; |
---|
| 288 | + copy.versionindex = -1; |
---|
| 289 | + } |
---|
| 290 | + |
---|
219 | 291 | // "this" is not called: SetupUI2(objEditor); |
---|
220 | 292 | } |
---|
221 | 293 | |
---|
.. | .. |
---|
229 | 301 | client = inClient; |
---|
230 | 302 | copy = client; |
---|
231 | 303 | |
---|
| 304 | + if (copy.versions == null) |
---|
| 305 | + { |
---|
| 306 | + copy.versions = new byte[100][]; |
---|
| 307 | + copy.versionindex = -1; |
---|
| 308 | + } |
---|
| 309 | + |
---|
232 | 310 | SetupUI2(callee.GetEditor()); |
---|
233 | 311 | } |
---|
234 | 312 | |
---|
.. | .. |
---|
243 | 321 | //localCopy.parent = null; |
---|
244 | 322 | |
---|
245 | 323 | frame = new JFrame(); |
---|
| 324 | + frame.setUndecorated(false); |
---|
246 | 325 | objEditor = this; |
---|
247 | 326 | this.callee = callee; |
---|
248 | 327 | |
---|
.. | .. |
---|
260 | 339 | copy = localCopy; |
---|
261 | 340 | copy.editWindow = this; |
---|
262 | 341 | |
---|
| 342 | + if (copy.versions == null) |
---|
| 343 | + { |
---|
| 344 | + copy.versions = new byte[100][]; |
---|
| 345 | + copy.versionindex = -1; |
---|
| 346 | + } |
---|
| 347 | + |
---|
263 | 348 | SetupMenu(); |
---|
264 | 349 | |
---|
265 | 350 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
273 | 358 | return frame.action(event, obj); |
---|
274 | 359 | } |
---|
275 | 360 | |
---|
| 361 | + // Cannot work without static |
---|
| 362 | + static boolean allparams = true; |
---|
| 363 | + |
---|
| 364 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 365 | + |
---|
276 | 366 | void SetupMenu() |
---|
277 | 367 | { |
---|
278 | 368 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 369 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 370 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 371 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
282 | 372 | |
---|
283 | 373 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 374 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
310 | 400 | } |
---|
311 | 401 | |
---|
312 | 402 | newItem.addActionListener(this); |
---|
313 | | - loadItem.addActionListener(this); |
---|
| 403 | + openItem.addActionListener(this); |
---|
314 | 404 | saveItem.addActionListener(this); |
---|
315 | 405 | saveAsItem.addActionListener(this); |
---|
316 | 406 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
319 | 409 | closeItem.addActionListener(this); |
---|
320 | 410 | |
---|
321 | 411 | objectPanel = new JTabbedPane(); |
---|
| 412 | + |
---|
| 413 | + ChangeListener changeListener = new ChangeListener() |
---|
| 414 | + { |
---|
| 415 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 416 | + { |
---|
| 417 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 418 | +// { |
---|
| 419 | +// if (latestObject != null) |
---|
| 420 | +// { |
---|
| 421 | +// refreshContents(true); |
---|
| 422 | +// SetMaterial(latestObject); |
---|
| 423 | +// } |
---|
| 424 | +// |
---|
| 425 | +// materialFlushed = true; |
---|
| 426 | +// } |
---|
| 427 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) |
---|
| 428 | +// { |
---|
| 429 | +// if (listUI.size() == 0) |
---|
| 430 | +// EditSelection(false); |
---|
| 431 | +// } |
---|
| 432 | + |
---|
| 433 | + refreshContents(false); // To refresh Info tab |
---|
| 434 | + } |
---|
| 435 | + }; |
---|
| 436 | + objectPanel.addChangeListener(changeListener); |
---|
| 437 | + |
---|
322 | 438 | toolbarPanel = new JPanel(); |
---|
323 | 439 | toolbarPanel.setName("Toolbar"); |
---|
324 | 440 | treePanel = new cGridBag(); |
---|
325 | 441 | treePanel.setName("Tree"); |
---|
| 442 | + |
---|
| 443 | + editPanel = new cGridBag().setVertical(true); |
---|
| 444 | + editPanel.setName("Edit"); |
---|
| 445 | + |
---|
326 | 446 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
327 | | - ctrlPanel.setName("Edit"); |
---|
| 447 | + |
---|
| 448 | + editCommandsPanel = new cGridBag(); |
---|
| 449 | + editPanel.add(editCommandsPanel); |
---|
| 450 | + editPanel.add(ctrlPanel); |
---|
| 451 | + |
---|
| 452 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 453 | + toolboxPanel.setName("Toolbox"); |
---|
| 454 | + |
---|
328 | 455 | materialPanel = new cGridBag().setVertical(true); |
---|
329 | 456 | materialPanel.setName("Material"); |
---|
| 457 | + |
---|
330 | 458 | /*JTextPane*/ |
---|
331 | 459 | infoarea = createTextPane(); |
---|
332 | 460 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
339 | 467 | // TEXTAREA infoarea.setLineWrap(true); |
---|
340 | 468 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
341 | 469 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
342 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 470 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
343 | 471 | infoPanel.setName("Info"); |
---|
344 | 472 | //infoPanel.setLayout(new BorderLayout()); |
---|
345 | 473 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
351 | 479 | mainPanel.setDividerSize(9); |
---|
352 | 480 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
353 | 481 | mainPanel.setResizeWeight(0.5); |
---|
354 | | - |
---|
| 482 | + |
---|
| 483 | +//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5)); |
---|
| 484 | + BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider(); |
---|
| 485 | + divider.setDividerSize(15); |
---|
| 486 | + divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!")); |
---|
| 487 | + |
---|
| 488 | + mainPanel.setUI(new BasicSplitPaneUI()); |
---|
| 489 | + |
---|
355 | 490 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
356 | 491 | //mainPanel.setLayout(new GridBagLayout()); |
---|
357 | 492 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
582 | 717 | } |
---|
583 | 718 | } |
---|
584 | 719 | |
---|
| 720 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 721 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 722 | + |
---|
| 723 | + Rectangle keeprect; |
---|
| 724 | + cRadio radio; |
---|
| 725 | + |
---|
| 726 | +cButton keepButton; |
---|
| 727 | + cButton twoButton; // Full 3D |
---|
| 728 | + cButton sixButton; |
---|
| 729 | + cButton threeButton; |
---|
| 730 | + cButton sevenButton; |
---|
| 731 | + cButton fourButton; // full panel |
---|
| 732 | + cButton oneButton; // full XYZ |
---|
| 733 | + //cButton currentLayout; |
---|
| 734 | + |
---|
| 735 | + boolean maximized; |
---|
| 736 | + |
---|
| 737 | + cButton fullscreenLayout; |
---|
| 738 | + |
---|
| 739 | + void Minimize() |
---|
| 740 | + { |
---|
| 741 | + frame.setState(Frame.ICONIFIED); |
---|
| 742 | + frame.validate(); |
---|
| 743 | + } |
---|
| 744 | + |
---|
| 745 | +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} |
---|
| 746 | +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} |
---|
| 747 | +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} |
---|
| 748 | + void Maximize() |
---|
| 749 | + { |
---|
| 750 | + if (CameraPane.FULLSCREEN) |
---|
| 751 | + { |
---|
| 752 | + ToggleFullScreen(); |
---|
| 753 | + } |
---|
| 754 | + |
---|
| 755 | + if (maximized) |
---|
| 756 | + { |
---|
| 757 | + frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 758 | + } |
---|
| 759 | + else |
---|
| 760 | + { |
---|
| 761 | + keeprect = frame.getBounds(); |
---|
| 762 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 763 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 764 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 765 | +// frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 766 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
| 767 | + } |
---|
| 768 | + |
---|
| 769 | + maximized ^= true; |
---|
| 770 | + |
---|
| 771 | + frame.validate(); |
---|
| 772 | + } |
---|
| 773 | + |
---|
| 774 | + cButton minButton; |
---|
| 775 | + cButton maxButton; |
---|
| 776 | + cButton fullButton; |
---|
| 777 | + |
---|
585 | 778 | void ToggleFullScreen() |
---|
586 | 779 | { |
---|
587 | | - if (CameraPane.FULLSCREEN) |
---|
| 780 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 781 | + |
---|
| 782 | + cameraView.ToggleFullScreen(); |
---|
| 783 | + |
---|
| 784 | + if (!CameraPane.FULLSCREEN) |
---|
588 | 785 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 786 | + device.setFullScreenWindow(null); |
---|
| 787 | + frame.dispose(); |
---|
| 788 | + frame.setUndecorated(false); |
---|
| 789 | + frame.validate(); |
---|
| 790 | + frame.setVisible(true); |
---|
| 791 | + |
---|
| 792 | + //frame.setVisible(false); |
---|
| 793 | +// frame.removeNotify(); |
---|
| 794 | +// frame.setUndecorated(false); |
---|
| 795 | +// frame.addNotify(); |
---|
| 796 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 797 | + |
---|
| 798 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 799 | +// X framePanel.add(bigThree); |
---|
| 800 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 801 | + framePanel.setDividerLocation(46); |
---|
| 802 | + |
---|
| 803 | + //frame.setVisible(true); |
---|
| 804 | + radio.layout = keepButton; |
---|
| 805 | + //theFrame = null; |
---|
| 806 | + keepButton = null; |
---|
| 807 | + radio.layout.doClick(); |
---|
| 808 | + |
---|
592 | 809 | } else |
---|
593 | 810 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 811 | + keepButton = radio.layout; |
---|
| 812 | + //keeprect = frame.getBounds(); |
---|
| 813 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 814 | +// frame.getToolkit().getScreenSize().height); |
---|
| 815 | + //frame.setVisible(false); |
---|
| 816 | + |
---|
| 817 | + frame.dispose(); |
---|
| 818 | + frame.setUndecorated(true); |
---|
| 819 | + device.setFullScreenWindow(frame); |
---|
| 820 | + frame.validate(); |
---|
| 821 | + frame.setVisible(true); |
---|
| 822 | +// frame.removeNotify(); |
---|
| 823 | +// frame.setUndecorated(true); |
---|
| 824 | +// frame.addNotify(); |
---|
| 825 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 826 | +// X framePanel.remove(bigThree); |
---|
| 827 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 828 | + framePanel.setDividerLocation(0); |
---|
| 829 | + |
---|
| 830 | + radio.layout = fullscreenLayout; |
---|
| 831 | + radio.layout.doClick(); |
---|
| 832 | + //frame.setVisible(true); |
---|
597 | 833 | } |
---|
598 | | - cameraView.ToggleFullScreen(); |
---|
| 834 | + frame.validate(); |
---|
599 | 835 | } |
---|
| 836 | + |
---|
| 837 | + private byte[] CompressCopy() |
---|
| 838 | + { |
---|
| 839 | + boolean temp = CameraPane.SWITCH; |
---|
| 840 | + CameraPane.SWITCH = false; |
---|
| 841 | + |
---|
| 842 | + copy.ExtractBigData(versiontable); |
---|
| 843 | + // if (copy == client) |
---|
| 844 | + |
---|
| 845 | + byte[] versions[] = copy.versions; |
---|
| 846 | + copy.versions = null; |
---|
| 847 | + |
---|
| 848 | + byte[] compress = Compress(copy); |
---|
| 849 | + |
---|
| 850 | + copy.versions = versions; |
---|
| 851 | + |
---|
| 852 | + copy.RestoreBigData(versiontable); |
---|
| 853 | + |
---|
| 854 | + CameraPane.SWITCH = temp; |
---|
| 855 | + |
---|
| 856 | + return compress; |
---|
| 857 | + } |
---|
600 | 858 | |
---|
601 | 859 | private JTextPane createTextPane() |
---|
602 | 860 | { |
---|
.. | .. |
---|
736 | 994 | JCheckBox speedupCB; |
---|
737 | 995 | JCheckBox rewindCB; |
---|
738 | 996 | JCheckBox flipVCB; |
---|
| 997 | + |
---|
| 998 | + cCheckBox toggleTextureCB; |
---|
| 999 | + cCheckBox toggleSwitchCB; |
---|
| 1000 | + |
---|
739 | 1001 | JComboBox texresMenu; |
---|
| 1002 | + |
---|
740 | 1003 | JButton resetButton; |
---|
741 | 1004 | JButton stepButton; |
---|
742 | 1005 | JButton stepAllButton; |
---|
.. | .. |
---|
745 | 1008 | JButton fasterButton; |
---|
746 | 1009 | JButton remarkButton; |
---|
747 | 1010 | |
---|
| 1011 | + cGridBag editPanel; |
---|
| 1012 | + cGridBag editCommandsPanel; |
---|
| 1013 | + |
---|
748 | 1014 | cGridBag namePanel; |
---|
749 | 1015 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 1016 | + cGridBag setupPanel2; |
---|
| 1017 | + cGridBag objectCommandsPanel; |
---|
751 | 1018 | cGridBag pushPanel; |
---|
752 | 1019 | cGridBag fillPanel; |
---|
753 | 1020 | |
---|
.. | .. |
---|
919 | 1186 | namePanel = new cGridBag(); |
---|
920 | 1187 | |
---|
921 | 1188 | nameField = AddText(namePanel, copy.GetName()); |
---|
922 | | - namePanel.add(nameField); |
---|
| 1189 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
923 | 1190 | oe.ctrlPanel.add(namePanel); |
---|
924 | 1191 | |
---|
925 | 1192 | oe.ctrlPanel.Return(); |
---|
926 | 1193 | |
---|
927 | | - if (!GroupEditor.allparams) |
---|
| 1194 | + if (!allparams) |
---|
928 | 1195 | return; |
---|
929 | 1196 | |
---|
930 | 1197 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
937 | 1204 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
938 | 1205 | hideCB.setToolTipText("Hide object"); |
---|
939 | 1206 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1207 | + markCB.setToolTipText("As animation target transform"); |
---|
941 | 1208 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1209 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1210 | + |
---|
| 1211 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1212 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1213 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1214 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
| 1215 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
947 | 1216 | |
---|
| 1217 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1218 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1219 | + |
---|
948 | 1220 | if (Globals.ADVANCED) |
---|
949 | 1221 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
951 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1222 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1223 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1224 | } |
---|
955 | 1225 | |
---|
956 | 1226 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1227 | oe.ctrlPanel.Return(); |
---|
| 1228 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1229 | + oe.ctrlPanel.Return(); |
---|
958 | 1230 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1231 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1232 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1233 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1234 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1235 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1236 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1237 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1238 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1239 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1240 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1241 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1242 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1243 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1244 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1245 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1246 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1247 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1248 | oe.ctrlPanel.Return(); |
---|
977 | 1249 | |
---|
978 | 1250 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1450 | //worldPanel.setName("World"); |
---|
1179 | 1451 | centralPanel = new cGridBag(); |
---|
1180 | 1452 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1453 | + |
---|
| 1454 | + if (Globals.ADVANCED) |
---|
| 1455 | + { |
---|
| 1456 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1457 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1458 | |
---|
1184 | 1459 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1460 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1463 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1464 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1465 | |
---|
| 1466 | + } |
---|
| 1467 | + |
---|
1191 | 1468 | centralPanel.add(cameraView); |
---|
| 1469 | + centralPanel.setFocusable(true); |
---|
1192 | 1470 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1471 | //centralPanel.add(timelinePanel); |
---|
1194 | 1472 | |
---|
.. | .. |
---|
1255 | 1533 | // north.setName("Edit"); |
---|
1256 | 1534 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1535 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
1259 | | - objectPanel.add(infoPanel); |
---|
| 1536 | + objectPanel.add(editPanel); |
---|
| 1537 | + |
---|
| 1538 | + //if (Globals.ADVANCED) |
---|
| 1539 | + objectPanel.add(infoPanel); |
---|
| 1540 | + |
---|
| 1541 | + objectPanel.add(toolboxPanel); |
---|
1260 | 1542 | |
---|
1261 | 1543 | /* |
---|
1262 | 1544 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1265 | 1547 | aConstraints.gridy += 1; |
---|
1266 | 1548 | aConstraints.gridwidth = 1; |
---|
1267 | 1549 | mainPanel.add(objectPanel, aConstraints); |
---|
1268 | | - */ |
---|
| 1550 | + */ |
---|
1269 | 1551 | |
---|
1270 | 1552 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1271 | 1553 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1282 | 1564 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1283 | 1565 | tabbedPane.add(scrollpane); |
---|
1284 | 1566 | |
---|
1285 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1286 | | - |
---|
1287 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1567 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1288 | 1568 | |
---|
1289 | 1569 | optionsPanel.setName("Options"); |
---|
1290 | 1570 | |
---|
.. | .. |
---|
1292 | 1572 | |
---|
1293 | 1573 | tabbedPane.add(optionsPanel); |
---|
1294 | 1574 | |
---|
| 1575 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1576 | + |
---|
1295 | 1577 | scenePanel.add(tabbedPane); |
---|
1296 | 1578 | |
---|
1297 | 1579 | /* |
---|
.. | .. |
---|
1364 | 1646 | // aConstraints.gridheight = 1; |
---|
1365 | 1647 | |
---|
1366 | 1648 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1367 | | - framePanel.setContinuousLayout(true); |
---|
1368 | | - framePanel.setOneTouchExpandable(true); |
---|
1369 | | - framePanel.setDividerLocation(0.8); |
---|
| 1649 | + framePanel.setContinuousLayout(false); |
---|
| 1650 | + framePanel.setOneTouchExpandable(false); |
---|
| 1651 | + //.setDividerLocation(0.8); |
---|
1370 | 1652 | //framePanel.setDividerSize(15); |
---|
1371 | 1653 | //framePanel.setResizeWeight(0.15); |
---|
1372 | 1654 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1384 | 1666 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1385 | 1667 | |
---|
1386 | 1668 | frame.setSize(1280, 860); |
---|
1387 | | - frame.setVisible(true); |
---|
1388 | | - |
---|
| 1669 | + |
---|
| 1670 | + cameraView.requestFocusInWindow(); |
---|
| 1671 | + |
---|
1389 | 1672 | gridPanel.setDividerLocation(1.0); |
---|
| 1673 | + |
---|
| 1674 | + frame.validate(); |
---|
| 1675 | + |
---|
| 1676 | + frame.setVisible(true); |
---|
1390 | 1677 | |
---|
1391 | 1678 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1392 | 1679 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1473 | 1760 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1474 | 1761 | colorSection.add(texture); |
---|
1475 | 1762 | |
---|
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 | 1763 | panel.add(new JSeparator()); |
---|
1495 | 1764 | |
---|
1496 | 1765 | panel.add(colorSection); |
---|
.. | .. |
---|
1540 | 1809 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1541 | 1810 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1542 | 1811 | diffuseSection.add(fakedepth); |
---|
| 1812 | + |
---|
| 1813 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1814 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1815 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1816 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1817 | + diffuseSection.add(shadowbias); |
---|
1543 | 1818 | |
---|
1544 | 1819 | panel.add(new JSeparator()); |
---|
1545 | 1820 | |
---|
.. | .. |
---|
1591 | 1866 | // aConstraints.gridy += 1; |
---|
1592 | 1867 | // aConstraints.gridwidth = 1; |
---|
1593 | 1868 | |
---|
| 1869 | + cGridBag anisoU = new cGridBag(); |
---|
| 1870 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1871 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1872 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1873 | + specularSection.add(anisoU); |
---|
| 1874 | + |
---|
| 1875 | + cGridBag anisoV = new cGridBag(); |
---|
| 1876 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1877 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1878 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1879 | + specularSection.add(anisoV); |
---|
| 1880 | + |
---|
1594 | 1881 | |
---|
1595 | 1882 | panel.add(new JSeparator()); |
---|
1596 | 1883 | |
---|
.. | .. |
---|
1598 | 1885 | |
---|
1599 | 1886 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1600 | 1887 | |
---|
1601 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1888 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1602 | 1889 | |
---|
1603 | 1890 | cGridBag camera = new cGridBag(); |
---|
1604 | 1891 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1605 | 1892 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1606 | 1893 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1607 | | - globalSection.add(camera); |
---|
| 1894 | + colorSection.add(camera); |
---|
1608 | 1895 | |
---|
1609 | 1896 | cGridBag ambient = new cGridBag(); |
---|
1610 | 1897 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1611 | 1898 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1612 | 1899 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1613 | | - globalSection.add(ambient); |
---|
| 1900 | + colorSection.add(ambient); |
---|
1614 | 1901 | |
---|
1615 | 1902 | cGridBag backlit = new cGridBag(); |
---|
1616 | 1903 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1617 | 1904 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1618 | 1905 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1619 | | - globalSection.add(backlit); |
---|
| 1906 | + colorSection.add(backlit); |
---|
1620 | 1907 | |
---|
1621 | 1908 | cGridBag opacity = new cGridBag(); |
---|
1622 | 1909 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1623 | 1910 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1624 | 1911 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1625 | | - globalSection.add(opacity); |
---|
| 1912 | + colorSection.add(opacity); |
---|
1626 | 1913 | |
---|
1627 | | - panel.add(new JSeparator()); |
---|
| 1914 | + //panel.add(new JSeparator()); |
---|
1628 | 1915 | |
---|
1629 | | - panel.add(globalSection); |
---|
| 1916 | + //panel.add(globalSection); |
---|
1630 | 1917 | |
---|
1631 | 1918 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1632 | 1919 | |
---|
.. | .. |
---|
1733 | 2020 | // 3D models |
---|
1734 | 2021 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1735 | 2022 | { |
---|
1736 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1737 | | - LoadFile(filename, lastConverter); |
---|
| 2023 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2024 | + //LoadFile(filename, lastConverter); |
---|
| 2025 | + LoadObjFile(filename); // New 3ds loader |
---|
1738 | 2026 | continue; |
---|
1739 | 2027 | } |
---|
1740 | 2028 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2460 | 2748 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2461 | 2749 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2462 | 2750 | } |
---|
| 2751 | + |
---|
2463 | 2752 | //cJME.count++; |
---|
2464 | 2753 | //cJME.count %= 12; |
---|
2465 | 2754 | if (gc) |
---|
.. | .. |
---|
2643 | 2932 | } |
---|
2644 | 2933 | } |
---|
2645 | 2934 | } |
---|
| 2935 | + |
---|
2646 | 2936 | cFileSystemPane FSPane; |
---|
2647 | 2937 | |
---|
2648 | 2938 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2696 | 2986 | } |
---|
2697 | 2987 | } |
---|
2698 | 2988 | } |
---|
| 2989 | + |
---|
2699 | 2990 | freezematerial = false; |
---|
2700 | 2991 | } |
---|
2701 | 2992 | |
---|
2702 | 2993 | void SetMaterial(Object3D object) |
---|
2703 | 2994 | { |
---|
| 2995 | + latestObject = object; |
---|
| 2996 | + |
---|
2704 | 2997 | cMaterial mat = object.material; |
---|
2705 | 2998 | |
---|
2706 | 2999 | if (mat == null) |
---|
.. | .. |
---|
2812 | 3105 | // } |
---|
2813 | 3106 | |
---|
2814 | 3107 | /**/ |
---|
2815 | | - if (deselect) |
---|
| 3108 | + if (deselect || child == null) |
---|
2816 | 3109 | { |
---|
2817 | 3110 | //group.deselectAll(); |
---|
2818 | 3111 | //freeze = true; |
---|
2819 | 3112 | GetTree().clearSelection(); |
---|
2820 | 3113 | //freeze = false; |
---|
| 3114 | + |
---|
| 3115 | + if (child == null) |
---|
| 3116 | + { |
---|
| 3117 | + return; |
---|
| 3118 | + } |
---|
2821 | 3119 | } |
---|
2822 | 3120 | |
---|
2823 | 3121 | //group.addSelectee(child); |
---|
.. | .. |
---|
2886 | 3184 | cameraView.ToggleDL(); |
---|
2887 | 3185 | cameraView.repaint(); |
---|
2888 | 3186 | return; |
---|
2889 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3187 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2890 | 3188 | { |
---|
2891 | 3189 | cameraView.ToggleTexture(); |
---|
2892 | 3190 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
2925 | 3223 | frame.validate(); |
---|
2926 | 3224 | |
---|
2927 | 3225 | return; |
---|
2928 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3226 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
2929 | 3227 | { |
---|
2930 | 3228 | cameraView.ToggleSwitch(); |
---|
2931 | 3229 | cameraView.repaint(); |
---|
.. | .. |
---|
3141 | 3439 | { |
---|
3142 | 3440 | Close(); |
---|
3143 | 3441 | //return true; |
---|
3144 | | - } else if (source == loadItem) |
---|
| 3442 | + } else if (source == openItem) |
---|
3145 | 3443 | { |
---|
3146 | | - load(); |
---|
| 3444 | + Open(); |
---|
3147 | 3445 | //return true; |
---|
3148 | 3446 | } else if (source == newItem) |
---|
3149 | 3447 | { |
---|
.. | .. |
---|
3168 | 3466 | { |
---|
3169 | 3467 | generatePOV(); |
---|
3170 | 3468 | //return true; |
---|
| 3469 | + } else if (event.getSource() == archiveItem) |
---|
| 3470 | + { |
---|
| 3471 | + cTools.Archive(frame); |
---|
| 3472 | + return; |
---|
3171 | 3473 | } else if (source == zBufferItem) |
---|
3172 | 3474 | { |
---|
3173 | 3475 | try |
---|
.. | .. |
---|
3219 | 3521 | try |
---|
3220 | 3522 | { |
---|
3221 | 3523 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3222 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3524 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3525 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3224 | 3526 | |
---|
3225 | 3527 | Object3D parent = o.parent; |
---|
3226 | 3528 | o.parent = null; |
---|
.. | .. |
---|
3231 | 3533 | |
---|
3232 | 3534 | out.flush(); |
---|
3233 | 3535 | |
---|
3234 | | - zstream.close(); |
---|
| 3536 | + baos //zstream |
---|
| 3537 | + .close(); |
---|
3235 | 3538 | out.close(); |
---|
3236 | 3539 | |
---|
3237 | | - return baos.toByteArray(); |
---|
| 3540 | + byte[] bytes = baos.toByteArray(); |
---|
| 3541 | + |
---|
| 3542 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3543 | + return bytes; |
---|
3238 | 3544 | } catch (Exception e) |
---|
3239 | 3545 | { |
---|
3240 | 3546 | System.err.println(e); |
---|
.. | .. |
---|
3244 | 3550 | |
---|
3245 | 3551 | static public Object Uncompress(byte[] bytes) |
---|
3246 | 3552 | { |
---|
3247 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3553 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3248 | 3554 | try |
---|
3249 | 3555 | { |
---|
3250 | 3556 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3251 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3252 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3557 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3558 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3253 | 3559 | Object obj = in.readObject(); |
---|
| 3560 | + |
---|
| 3561 | + bais //istream |
---|
| 3562 | + .close(); |
---|
3254 | 3563 | in.close(); |
---|
3255 | 3564 | |
---|
3256 | 3565 | return obj; |
---|
.. | .. |
---|
3305 | 3614 | return null; |
---|
3306 | 3615 | } |
---|
3307 | 3616 | |
---|
3308 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3309 | 3617 | |
---|
3310 | 3618 | public void Save() |
---|
3311 | 3619 | { |
---|
| 3620 | + //Save(true); |
---|
| 3621 | + Replace(); |
---|
| 3622 | + } |
---|
| 3623 | + |
---|
| 3624 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3625 | + { |
---|
| 3626 | + if (compress.length != name.length) |
---|
| 3627 | + { |
---|
| 3628 | + return false; |
---|
| 3629 | + } |
---|
| 3630 | + |
---|
| 3631 | + for (int i=compress.length; --i>=0;) |
---|
| 3632 | + { |
---|
| 3633 | + if (compress[i] != name[i]) |
---|
| 3634 | + return false; |
---|
| 3635 | + } |
---|
| 3636 | + |
---|
| 3637 | + return true; |
---|
| 3638 | + } |
---|
| 3639 | + |
---|
| 3640 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3641 | + |
---|
| 3642 | + public boolean Save(boolean user) |
---|
| 3643 | + { |
---|
| 3644 | + System.err.println("Save"); |
---|
| 3645 | + |
---|
3312 | 3646 | cRadio tab = GetCurrentTab(); |
---|
3313 | 3647 | |
---|
3314 | | - boolean temp = CameraPane.SWITCH; |
---|
3315 | | - CameraPane.SWITCH = false; |
---|
| 3648 | + byte[] compress = CompressCopy(); |
---|
3316 | 3649 | |
---|
3317 | | - copy.ExtractBigData(hashtable); |
---|
| 3650 | + boolean thesame = false; |
---|
| 3651 | + |
---|
| 3652 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3653 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3654 | + { |
---|
| 3655 | + thesame = true; |
---|
| 3656 | + } |
---|
3318 | 3657 | |
---|
3319 | 3658 | //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++) |
---|
| 3659 | + if (!thesame) |
---|
3329 | 3660 | { |
---|
3330 | | - tab.graphs[i] = null; |
---|
| 3661 | + //tab.user[tab.versionindex] = user; |
---|
| 3662 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3663 | + |
---|
| 3664 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3665 | + |
---|
| 3666 | + // if (increment) |
---|
| 3667 | + // tab.versionindex++; |
---|
3331 | 3668 | } |
---|
3332 | 3669 | |
---|
| 3670 | + //copy.RestoreBigData(versiontable); |
---|
| 3671 | + |
---|
| 3672 | + //assert(hashtable.isEmpty()); |
---|
| 3673 | + |
---|
| 3674 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
| 3675 | + { |
---|
| 3676 | + //tab.user[i] = false; |
---|
| 3677 | + copy.versions[i] = null; |
---|
| 3678 | + } |
---|
| 3679 | + |
---|
| 3680 | + SetUndoStates(); |
---|
| 3681 | + |
---|
3333 | 3682 | // test save |
---|
3334 | 3683 | if (false) |
---|
3335 | 3684 | { |
---|
3336 | 3685 | try |
---|
3337 | 3686 | { |
---|
3338 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3687 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3339 | 3688 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3340 | 3689 | |
---|
3341 | 3690 | p.writeObject(copy); |
---|
.. | .. |
---|
3348 | 3697 | e.printStackTrace(); |
---|
3349 | 3698 | } |
---|
3350 | 3699 | } |
---|
| 3700 | + |
---|
| 3701 | + return !thesame; |
---|
3351 | 3702 | } |
---|
3352 | 3703 | |
---|
3353 | 3704 | void CopyChanged(Object3D obj) |
---|
3354 | 3705 | { |
---|
| 3706 | + SetUndoStates(); |
---|
| 3707 | + |
---|
3355 | 3708 | boolean temp = CameraPane.SWITCH; |
---|
3356 | 3709 | CameraPane.SWITCH = false; |
---|
3357 | 3710 | |
---|
3358 | | - copy.ExtractBigData(hashtable); |
---|
| 3711 | + copy.ExtractBigData(versiontable); |
---|
3359 | 3712 | |
---|
3360 | 3713 | copy.clear(); |
---|
3361 | 3714 | |
---|
.. | .. |
---|
3364 | 3717 | copy.add(obj.get(i)); |
---|
3365 | 3718 | } |
---|
3366 | 3719 | |
---|
3367 | | - copy.RestoreBigData(hashtable); |
---|
| 3720 | + copy.RestoreBigData(versiontable); |
---|
3368 | 3721 | |
---|
3369 | 3722 | CameraPane.SWITCH = temp; |
---|
3370 | 3723 | |
---|
.. | .. |
---|
3391 | 3744 | refreshContents(); |
---|
3392 | 3745 | } |
---|
3393 | 3746 | |
---|
3394 | | - public void Undo() |
---|
| 3747 | + cButton undoButton; |
---|
| 3748 | + cButton restoreButton; |
---|
| 3749 | + cButton replaceButton; |
---|
| 3750 | + cButton redoButton; |
---|
| 3751 | + |
---|
| 3752 | + boolean muteSlider; |
---|
| 3753 | + |
---|
| 3754 | + int VersionCount() |
---|
| 3755 | + { |
---|
| 3756 | + int count = 0; |
---|
| 3757 | + |
---|
| 3758 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3759 | + { |
---|
| 3760 | + if (copy.versions[i] != null) |
---|
| 3761 | + count++; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
| 3764 | + return count; |
---|
| 3765 | + } |
---|
| 3766 | + |
---|
| 3767 | + void SetUndoStates() |
---|
3395 | 3768 | { |
---|
3396 | 3769 | cRadio tab = GetCurrentTab(); |
---|
3397 | 3770 | |
---|
3398 | | - if (tab.undoindex == 0) |
---|
| 3771 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3772 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3773 | + |
---|
| 3774 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3775 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3776 | + |
---|
| 3777 | + muteSlider = true; |
---|
| 3778 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3779 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3780 | + muteSlider = false; |
---|
| 3781 | + } |
---|
| 3782 | + |
---|
| 3783 | + public boolean Undo() |
---|
| 3784 | + { |
---|
| 3785 | + // Option? |
---|
| 3786 | + Replace(); |
---|
| 3787 | + |
---|
| 3788 | + System.err.println("Undo"); |
---|
| 3789 | + |
---|
| 3790 | + cRadio tab = GetCurrentTab(); |
---|
| 3791 | + |
---|
| 3792 | + if (copy.versionindex == 0) |
---|
3399 | 3793 | { |
---|
3400 | 3794 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3401 | | - return; |
---|
| 3795 | + return false; |
---|
3402 | 3796 | } |
---|
3403 | 3797 | |
---|
3404 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3798 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3799 | +// { |
---|
| 3800 | +// if (Save(false)) |
---|
| 3801 | +// tab.versionindex -= 1; |
---|
| 3802 | +// else |
---|
| 3803 | +// { |
---|
| 3804 | +// if (tab.versionindex <= 0) |
---|
| 3805 | +// return false; |
---|
| 3806 | +// else |
---|
| 3807 | +// tab.versionindex -= 1; |
---|
| 3808 | +// } |
---|
| 3809 | +// } |
---|
| 3810 | + |
---|
| 3811 | + copy.versionindex -= 1; |
---|
| 3812 | + |
---|
| 3813 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3814 | + |
---|
| 3815 | + return true; |
---|
| 3816 | + } |
---|
| 3817 | + |
---|
| 3818 | + public boolean Restore() |
---|
| 3819 | + { |
---|
| 3820 | + System.err.println("Restore"); |
---|
| 3821 | + |
---|
| 3822 | + cRadio tab = GetCurrentTab(); |
---|
| 3823 | + |
---|
| 3824 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3405 | 3825 | { |
---|
3406 | | - Save(); |
---|
3407 | | - tab.undoindex -= 1; |
---|
| 3826 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3827 | + return false; |
---|
3408 | 3828 | } |
---|
3409 | 3829 | |
---|
3410 | | - tab.undoindex -= 1; |
---|
| 3830 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3831 | + |
---|
| 3832 | + return true; |
---|
| 3833 | + } |
---|
3411 | 3834 | |
---|
3412 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3835 | + public boolean Replace() |
---|
| 3836 | + { |
---|
| 3837 | + System.err.println("Replace"); |
---|
| 3838 | + |
---|
| 3839 | + cRadio tab = GetCurrentTab(); |
---|
| 3840 | + |
---|
| 3841 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3842 | + { |
---|
| 3843 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3844 | + return false; |
---|
| 3845 | + } |
---|
| 3846 | + |
---|
| 3847 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
| 3848 | + |
---|
| 3849 | + return true; |
---|
3413 | 3850 | } |
---|
3414 | 3851 | |
---|
3415 | 3852 | public void Redo() |
---|
3416 | 3853 | { |
---|
| 3854 | + // Option? |
---|
| 3855 | + Replace(); |
---|
| 3856 | + |
---|
3417 | 3857 | cRadio tab = GetCurrentTab(); |
---|
3418 | 3858 | |
---|
3419 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3859 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3420 | 3860 | { |
---|
3421 | 3861 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3422 | 3862 | return; |
---|
3423 | 3863 | } |
---|
3424 | 3864 | |
---|
3425 | | - tab.undoindex += 1; |
---|
| 3865 | + copy.versionindex += 1; |
---|
3426 | 3866 | |
---|
3427 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3867 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3868 | + |
---|
| 3869 | + //if (!tab.user[tab.versionindex]) |
---|
| 3870 | + // tab.graphs[tab.versionindex] = null; |
---|
3428 | 3871 | } |
---|
3429 | 3872 | |
---|
3430 | 3873 | void ImportGFD() |
---|
.. | .. |
---|
3576 | 4019 | assert false; |
---|
3577 | 4020 | } |
---|
3578 | 4021 | |
---|
3579 | | - void EditSelection() |
---|
| 4022 | + void EditSelection(boolean newWindow) |
---|
3580 | 4023 | { |
---|
3581 | 4024 | } |
---|
3582 | 4025 | |
---|
.. | .. |
---|
3720 | 4163 | //copy.Touch(); |
---|
3721 | 4164 | } |
---|
3722 | 4165 | |
---|
| 4166 | + cNumberSlider versionSlider; |
---|
| 4167 | + |
---|
3723 | 4168 | public void stateChanged(ChangeEvent e) |
---|
3724 | 4169 | { |
---|
3725 | 4170 | // assert(false); |
---|
| 4171 | + if (e.getSource() == versionSlider) |
---|
| 4172 | + { |
---|
| 4173 | + if (muteSlider) |
---|
| 4174 | + return; |
---|
| 4175 | + |
---|
| 4176 | + int version = versionSlider.getInteger(); |
---|
| 4177 | + |
---|
| 4178 | + if (copy.versions[version] != null) |
---|
| 4179 | + { |
---|
| 4180 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4181 | + } |
---|
| 4182 | + |
---|
| 4183 | + return; |
---|
| 4184 | + } |
---|
3726 | 4185 | |
---|
3727 | 4186 | if (freezematerial) |
---|
3728 | 4187 | { |
---|
.. | .. |
---|
4071 | 4530 | |
---|
4072 | 4531 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4073 | 4532 | { |
---|
4074 | | - Save(); |
---|
| 4533 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
| 4534 | + Save(); |
---|
4075 | 4535 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4076 | 4536 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4077 | 4537 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4158 | 4618 | { |
---|
4159 | 4619 | ResetModel(); |
---|
4160 | 4620 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4621 | + |
---|
| 4622 | + if (thing.Size() == 0) |
---|
| 4623 | + { |
---|
| 4624 | + //EditSelection(false); |
---|
| 4625 | + } |
---|
| 4626 | + |
---|
4161 | 4627 | refreshContents(); |
---|
4162 | 4628 | } |
---|
4163 | 4629 | |
---|
.. | .. |
---|
4380 | 4846 | |
---|
4381 | 4847 | if (readobj != null) |
---|
4382 | 4848 | { |
---|
4383 | | - Save(); |
---|
| 4849 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4850 | + // Save(); |
---|
4384 | 4851 | try |
---|
4385 | 4852 | { |
---|
4386 | 4853 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4435 | 4902 | c.addChild(csg); |
---|
4436 | 4903 | } |
---|
4437 | 4904 | |
---|
| 4905 | + copy.versions = readobj.versions; |
---|
| 4906 | + copy.versionindex = readobj.versionindex; |
---|
| 4907 | + |
---|
| 4908 | + if (copy.versions == null) |
---|
| 4909 | + { |
---|
| 4910 | + copy.versions = new byte[100][]; |
---|
| 4911 | + copy.versionindex = -1; |
---|
| 4912 | + } |
---|
| 4913 | + |
---|
| 4914 | + //? SetUndoStates(); |
---|
| 4915 | + |
---|
4438 | 4916 | ResetModel(); |
---|
4439 | 4917 | copy.HardTouch(); // recompile? |
---|
4440 | 4918 | refreshContents(); |
---|
4441 | 4919 | } |
---|
4442 | 4920 | } |
---|
4443 | 4921 | |
---|
4444 | | - void load() // throws ClassNotFoundException |
---|
| 4922 | + void Open() // throws ClassNotFoundException |
---|
4445 | 4923 | { |
---|
4446 | 4924 | if (Grafreed.standAlone) |
---|
4447 | 4925 | { |
---|
.. | .. |
---|
4558 | 5036 | String filename = browser.getFile(); |
---|
4559 | 5037 | if (filename != null && filename.length() > 0) |
---|
4560 | 5038 | { |
---|
| 5039 | + if (!filename.endsWith(".gfd")) |
---|
| 5040 | + filename += ".gfd"; |
---|
4561 | 5041 | lastname = browser.getDirectory() + filename; |
---|
4562 | 5042 | save(); |
---|
4563 | 5043 | } |
---|
.. | .. |
---|
4724 | 5204 | MenuBar menuBar; |
---|
4725 | 5205 | Menu fileMenu; |
---|
4726 | 5206 | MenuItem newItem; |
---|
4727 | | - MenuItem loadItem; |
---|
| 5207 | + MenuItem openItem; |
---|
4728 | 5208 | MenuItem saveItem; |
---|
4729 | 5209 | MenuItem saveAsItem; |
---|
4730 | 5210 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4747 | 5227 | CheckboxMenuItem toggleSwitchItem; |
---|
4748 | 5228 | CheckboxMenuItem toggleRootItem; |
---|
4749 | 5229 | CheckboxMenuItem animationItem; |
---|
| 5230 | + MenuItem archiveItem; |
---|
4750 | 5231 | CheckboxMenuItem toggleHandleItem; |
---|
4751 | 5232 | CheckboxMenuItem togglePaintItem; |
---|
4752 | 5233 | JSplitPane mainPanel; |
---|
4753 | 5234 | JScrollPane scrollpane; |
---|
| 5235 | + |
---|
4754 | 5236 | JPanel toolbarPanel; |
---|
| 5237 | + |
---|
4755 | 5238 | cGridBag treePanel; |
---|
| 5239 | + |
---|
4756 | 5240 | JPanel radioPanel; |
---|
4757 | 5241 | ButtonGroup buttonGroup; |
---|
4758 | | - cGridBag ctrlPanel; |
---|
| 5242 | + |
---|
| 5243 | + cGridBag toolboxPanel; |
---|
4759 | 5244 | cGridBag materialPanel; |
---|
| 5245 | + cGridBag ctrlPanel; |
---|
| 5246 | + |
---|
4760 | 5247 | JScrollPane infoPanel; |
---|
| 5248 | + |
---|
4761 | 5249 | cGridBag optionsPanel; |
---|
| 5250 | + |
---|
4762 | 5251 | JTabbedPane objectPanel; |
---|
| 5252 | + boolean materialFlushed; |
---|
| 5253 | + Object3D latestObject; |
---|
| 5254 | + |
---|
4763 | 5255 | cGridBag XYZPanel; |
---|
| 5256 | + |
---|
4764 | 5257 | JSplitPane gridPanel; |
---|
4765 | 5258 | JSplitPane bigPanel; |
---|
| 5259 | + |
---|
4766 | 5260 | cGridBag bigThree; |
---|
4767 | 5261 | cGridBag scenePanel; |
---|
4768 | 5262 | cGridBag centralPanel; |
---|
.. | .. |
---|
4877 | 5371 | cNumberSlider fogField; |
---|
4878 | 5372 | JLabel opacityPowerLabel; |
---|
4879 | 5373 | cNumberSlider opacityPowerField; |
---|
4880 | | - JTree jTree; |
---|
| 5374 | + cTree jTree; |
---|
4881 | 5375 | //ObjectUI parent; |
---|
4882 | 5376 | |
---|
4883 | 5377 | cNumberSlider normalpushField; |
---|