.. | .. |
---|
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 | |
---|
.. | .. |
---|
37 | 41 | JFrame frame; |
---|
38 | 42 | |
---|
39 | 43 | static ObjEditor theFrame; |
---|
| 44 | + |
---|
| 45 | + cButton GetButton(String name, boolean border) |
---|
| 46 | + { |
---|
| 47 | + ImageIcon icon = GetIcon(name); |
---|
| 48 | + return new cButton(icon, border); |
---|
| 49 | + } |
---|
| 50 | + |
---|
| 51 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 52 | + { |
---|
| 53 | + ImageIcon icon = GetIcon(name); |
---|
| 54 | + return new cToggleButton(icon, border); |
---|
| 55 | + } |
---|
| 56 | + |
---|
| 57 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 58 | + { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cCheckBox(icon, border); |
---|
| 61 | + } |
---|
| 62 | + |
---|
| 63 | + private ImageIcon GetIcon(String name) |
---|
| 64 | + { |
---|
| 65 | + try |
---|
| 66 | + { |
---|
| 67 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 68 | + |
---|
| 69 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 70 | + { |
---|
| 71 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 72 | + Graphics2D g = resized.createGraphics(); |
---|
| 73 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 74 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 75 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 76 | + g.dispose(); |
---|
| 77 | + |
---|
| 78 | + image = resized; |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 82 | + return icon; |
---|
| 83 | + } |
---|
| 84 | + catch (Exception e) |
---|
| 85 | + { |
---|
| 86 | + return null; |
---|
| 87 | + } |
---|
| 88 | + } |
---|
40 | 89 | |
---|
41 | 90 | // SCRIPT |
---|
42 | 91 | |
---|
.. | .. |
---|
147 | 196 | |
---|
148 | 197 | objEditor.ctrlPanel.remove(namePanel); |
---|
149 | 198 | |
---|
150 | | - if (!GroupEditor.allparams) |
---|
| 199 | + if (!allparams) |
---|
151 | 200 | return; |
---|
152 | 201 | |
---|
153 | 202 | // objEditor.ctrlPanel.remove(liveCB); |
---|
.. | .. |
---|
219 | 268 | client = inClient; |
---|
220 | 269 | copy = client; |
---|
221 | 270 | |
---|
| 271 | + if (copy.versions == null) |
---|
| 272 | + { |
---|
| 273 | + copy.versions = new byte[100][]; |
---|
| 274 | + copy.versionindex = -1; |
---|
| 275 | + } |
---|
| 276 | + |
---|
222 | 277 | // "this" is not called: SetupUI2(objEditor); |
---|
223 | 278 | } |
---|
224 | 279 | |
---|
.. | .. |
---|
232 | 287 | client = inClient; |
---|
233 | 288 | copy = client; |
---|
234 | 289 | |
---|
| 290 | + if (copy.versions == null) |
---|
| 291 | + { |
---|
| 292 | + copy.versions = new byte[100][]; |
---|
| 293 | + copy.versionindex = -1; |
---|
| 294 | + } |
---|
| 295 | + |
---|
235 | 296 | SetupUI2(callee.GetEditor()); |
---|
236 | 297 | } |
---|
237 | 298 | |
---|
.. | .. |
---|
246 | 307 | //localCopy.parent = null; |
---|
247 | 308 | |
---|
248 | 309 | frame = new JFrame(); |
---|
249 | | - frame.setUndecorated(true); |
---|
| 310 | + frame.setUndecorated(false); |
---|
250 | 311 | objEditor = this; |
---|
251 | 312 | this.callee = callee; |
---|
252 | 313 | |
---|
.. | .. |
---|
264 | 325 | copy = localCopy; |
---|
265 | 326 | copy.editWindow = this; |
---|
266 | 327 | |
---|
| 328 | + if (copy.versions == null) |
---|
| 329 | + { |
---|
| 330 | +// copy.versions = new byte[100][]; |
---|
| 331 | +// copy.versionindex = -1; |
---|
| 332 | + } |
---|
| 333 | + |
---|
267 | 334 | SetupMenu(); |
---|
268 | 335 | |
---|
269 | 336 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
277 | 344 | return frame.action(event, obj); |
---|
278 | 345 | } |
---|
279 | 346 | |
---|
| 347 | + // Cannot work without static |
---|
| 348 | + static boolean allparams = true; |
---|
| 349 | + |
---|
| 350 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 351 | + |
---|
280 | 352 | void SetupMenu() |
---|
281 | 353 | { |
---|
282 | 354 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
283 | 355 | menuBar.add(fileMenu = new Menu("File")); |
---|
284 | 356 | fileMenu.add(newItem = new MenuItem("New")); |
---|
285 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 357 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
286 | 358 | |
---|
287 | 359 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
288 | 360 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
314 | 386 | } |
---|
315 | 387 | |
---|
316 | 388 | newItem.addActionListener(this); |
---|
317 | | - loadItem.addActionListener(this); |
---|
| 389 | + openItem.addActionListener(this); |
---|
318 | 390 | saveItem.addActionListener(this); |
---|
319 | 391 | saveAsItem.addActionListener(this); |
---|
320 | 392 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
323 | 395 | closeItem.addActionListener(this); |
---|
324 | 396 | |
---|
325 | 397 | objectPanel = new JTabbedPane(); |
---|
| 398 | + |
---|
| 399 | + ChangeListener changeListener = new ChangeListener() |
---|
| 400 | + { |
---|
| 401 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 402 | + { |
---|
| 403 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 404 | +// { |
---|
| 405 | +// if (latestObject != null) |
---|
| 406 | +// { |
---|
| 407 | +// refreshContents(true); |
---|
| 408 | +// SetMaterial(latestObject); |
---|
| 409 | +// } |
---|
| 410 | +// |
---|
| 411 | +// materialFlushed = true; |
---|
| 412 | +// } |
---|
| 413 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) |
---|
| 414 | +// { |
---|
| 415 | +// if (listUI.size() == 0) |
---|
| 416 | +// EditSelection(false); |
---|
| 417 | +// } |
---|
| 418 | + |
---|
| 419 | + refreshContents(false); // To refresh Info tab |
---|
| 420 | + } |
---|
| 421 | + }; |
---|
| 422 | + objectPanel.addChangeListener(changeListener); |
---|
| 423 | + |
---|
326 | 424 | toolbarPanel = new JPanel(); |
---|
327 | 425 | toolbarPanel.setName("Toolbar"); |
---|
| 426 | + |
---|
328 | 427 | treePanel = new cGridBag(); |
---|
329 | 428 | treePanel.setName("Tree"); |
---|
330 | 429 | |
---|
331 | 430 | editPanel = new cGridBag().setVertical(true); |
---|
332 | | - editPanel.setName("Edit"); |
---|
| 431 | + //editPanel.setName("Edit"); |
---|
333 | 432 | |
---|
334 | 433 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
335 | 434 | |
---|
.. | .. |
---|
337 | 436 | editPanel.add(editCommandsPanel); |
---|
338 | 437 | editPanel.add(ctrlPanel); |
---|
339 | 438 | |
---|
340 | | - materialPanel = new cGridBag().setVertical(true); |
---|
| 439 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 440 | + //toolboxPanel.setName("Toolbox"); |
---|
341 | 441 | |
---|
342 | | - materialPanel.setName("Material"); |
---|
| 442 | + materialPanel = new cGridBag().setVertical(true); |
---|
| 443 | + //materialPanel.setName("Material"); |
---|
| 444 | + |
---|
343 | 445 | /*JTextPane*/ |
---|
344 | 446 | infoarea = createTextPane(); |
---|
345 | 447 | doc = infoarea.getStyledDocument(); |
---|
346 | 448 | |
---|
347 | 449 | infoarea.setEditable(true); |
---|
348 | 450 | SetText(); |
---|
| 451 | + |
---|
349 | 452 | // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); |
---|
350 | 453 | // infoarea.setOpaque(false); |
---|
351 | 454 | // //infoarea.setForeground(textcolor); |
---|
352 | 455 | // TEXTAREA infoarea.setLineWrap(true); |
---|
353 | 456 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
354 | 457 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
355 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
356 | | - infoPanel.setName("Info"); |
---|
| 458 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
| 459 | + //infoPanel.setName("Info"); |
---|
357 | 460 | //infoPanel.setLayout(new BorderLayout()); |
---|
358 | 461 | //infoPanel.add(createTextPane()); |
---|
359 | 462 | |
---|
.. | .. |
---|
364 | 467 | mainPanel.setDividerSize(9); |
---|
365 | 468 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
366 | 469 | mainPanel.setResizeWeight(0.5); |
---|
367 | | - |
---|
| 470 | + |
---|
| 471 | +//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5)); |
---|
| 472 | + BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider(); |
---|
| 473 | + divider.setDividerSize(15); |
---|
| 474 | + divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!")); |
---|
| 475 | + |
---|
| 476 | + mainPanel.setUI(new BasicSplitPaneUI()); |
---|
| 477 | + |
---|
368 | 478 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
369 | 479 | //mainPanel.setLayout(new GridBagLayout()); |
---|
370 | 480 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
595 | 705 | } |
---|
596 | 706 | } |
---|
597 | 707 | |
---|
598 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
599 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 708 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 709 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
600 | 710 | |
---|
601 | 711 | Rectangle keeprect; |
---|
602 | 712 | cRadio radio; |
---|
.. | .. |
---|
612 | 722 | |
---|
613 | 723 | boolean maximized; |
---|
614 | 724 | |
---|
| 725 | + cButton fullscreenLayout; |
---|
| 726 | + |
---|
615 | 727 | void Minimize() |
---|
616 | 728 | { |
---|
617 | 729 | frame.setState(Frame.ICONIFIED); |
---|
| 730 | + frame.validate(); |
---|
618 | 731 | } |
---|
619 | 732 | |
---|
| 733 | +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} |
---|
| 734 | +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} |
---|
| 735 | +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} |
---|
620 | 736 | void Maximize() |
---|
621 | 737 | { |
---|
| 738 | + if (CameraPane.FULLSCREEN) |
---|
| 739 | + { |
---|
| 740 | + ToggleFullScreen(); |
---|
| 741 | + } |
---|
| 742 | + |
---|
622 | 743 | if (maximized) |
---|
623 | 744 | { |
---|
624 | 745 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
626 | 747 | else |
---|
627 | 748 | { |
---|
628 | 749 | keeprect = frame.getBounds(); |
---|
629 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
630 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
631 | | - frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 750 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 751 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 752 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
632 | 753 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 754 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
633 | 755 | } |
---|
634 | 756 | |
---|
635 | 757 | maximized ^= true; |
---|
| 758 | + |
---|
| 759 | + frame.validate(); |
---|
636 | 760 | } |
---|
| 761 | + |
---|
| 762 | + cButton minButton; |
---|
| 763 | + cButton maxButton; |
---|
| 764 | + cButton fullButton; |
---|
637 | 765 | |
---|
638 | 766 | void ToggleFullScreen() |
---|
639 | 767 | { |
---|
640 | | - if (CameraPane.FULLSCREEN) |
---|
| 768 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 769 | + |
---|
| 770 | + cameraView.ToggleFullScreen(); |
---|
| 771 | + |
---|
| 772 | + if (!CameraPane.FULLSCREEN) |
---|
641 | 773 | { |
---|
642 | 774 | device.setFullScreenWindow(null); |
---|
| 775 | + frame.dispose(); |
---|
| 776 | + frame.setUndecorated(false); |
---|
| 777 | + frame.validate(); |
---|
| 778 | + frame.setVisible(true); |
---|
| 779 | + |
---|
643 | 780 | //frame.setVisible(false); |
---|
644 | 781 | // frame.removeNotify(); |
---|
645 | 782 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
649 | 786 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
650 | 787 | // X framePanel.add(bigThree); |
---|
651 | 788 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
652 | | - framePanel.setDividerLocation(1); |
---|
| 789 | + framePanel.setDividerLocation(46); |
---|
653 | 790 | |
---|
654 | 791 | //frame.setVisible(true); |
---|
655 | 792 | radio.layout = keepButton; |
---|
.. | .. |
---|
664 | 801 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
665 | 802 | // frame.getToolkit().getScreenSize().height); |
---|
666 | 803 | //frame.setVisible(false); |
---|
| 804 | + |
---|
| 805 | + frame.dispose(); |
---|
| 806 | + frame.setUndecorated(true); |
---|
667 | 807 | device.setFullScreenWindow(frame); |
---|
| 808 | + frame.validate(); |
---|
| 809 | + frame.setVisible(true); |
---|
668 | 810 | // frame.removeNotify(); |
---|
669 | 811 | // frame.setUndecorated(true); |
---|
670 | 812 | // frame.addNotify(); |
---|
.. | .. |
---|
673 | 815 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
674 | 816 | framePanel.setDividerLocation(0); |
---|
675 | 817 | |
---|
676 | | - radio.layout = twoButton; |
---|
| 818 | + radio.layout = fullscreenLayout; |
---|
677 | 819 | radio.layout.doClick(); |
---|
678 | 820 | //frame.setVisible(true); |
---|
679 | 821 | } |
---|
680 | | - |
---|
681 | | - cameraView.ToggleFullScreen(); |
---|
| 822 | + frame.validate(); |
---|
682 | 823 | } |
---|
| 824 | + |
---|
| 825 | + private byte[] CompressCopy() |
---|
| 826 | + { |
---|
| 827 | + boolean temp = CameraPane.SWITCH; |
---|
| 828 | + CameraPane.SWITCH = false; |
---|
| 829 | + |
---|
| 830 | + copy.ExtractBigData(versiontable); |
---|
| 831 | + // if (copy == client) |
---|
| 832 | + |
---|
| 833 | + byte[] versions[] = copy.versions; |
---|
| 834 | + copy.versions = null; |
---|
| 835 | + |
---|
| 836 | + byte[] compress = Compress(copy); |
---|
| 837 | + |
---|
| 838 | + copy.versions = versions; |
---|
| 839 | + |
---|
| 840 | + copy.RestoreBigData(versiontable); |
---|
| 841 | + |
---|
| 842 | + CameraPane.SWITCH = temp; |
---|
| 843 | + |
---|
| 844 | + return compress; |
---|
| 845 | + } |
---|
683 | 846 | |
---|
684 | 847 | private JTextPane createTextPane() |
---|
685 | 848 | { |
---|
.. | .. |
---|
811 | 974 | // NumberSlider vDivsField; |
---|
812 | 975 | // JCheckBox endcaps; |
---|
813 | 976 | JCheckBox liveCB; |
---|
814 | | - JCheckBox selectCB; |
---|
| 977 | + JCheckBox selectableCB; |
---|
815 | 978 | JCheckBox hideCB; |
---|
816 | 979 | JCheckBox link2masterCB; |
---|
817 | 980 | JCheckBox markCB; |
---|
.. | .. |
---|
819 | 982 | JCheckBox speedupCB; |
---|
820 | 983 | JCheckBox rewindCB; |
---|
821 | 984 | JCheckBox flipVCB; |
---|
| 985 | + |
---|
| 986 | + cCheckBox toggleTextureCB; |
---|
| 987 | + cCheckBox toggleSwitchCB; |
---|
| 988 | + |
---|
822 | 989 | JComboBox texresMenu; |
---|
| 990 | + |
---|
823 | 991 | JButton resetButton; |
---|
824 | 992 | JButton stepButton; |
---|
825 | 993 | JButton stepAllButton; |
---|
.. | .. |
---|
1006 | 1174 | namePanel = new cGridBag(); |
---|
1007 | 1175 | |
---|
1008 | 1176 | nameField = AddText(namePanel, copy.GetName()); |
---|
1009 | | - namePanel.add(nameField); |
---|
| 1177 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
1010 | 1178 | oe.ctrlPanel.add(namePanel); |
---|
1011 | 1179 | |
---|
1012 | 1180 | oe.ctrlPanel.Return(); |
---|
1013 | 1181 | |
---|
1014 | | - if (!GroupEditor.allparams) |
---|
| 1182 | + if (!allparams) |
---|
1015 | 1183 | return; |
---|
1016 | 1184 | |
---|
1017 | 1185 | setupPanel = new cGridBag().setVertical(false); |
---|
1018 | 1186 | |
---|
1019 | 1187 | liveCB = AddCheckBox(setupPanel, "Live", copy.live); |
---|
1020 | 1188 | liveCB.setToolTipText("Animate object"); |
---|
1021 | | - selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
1022 | | - selectCB.setToolTipText("Make object selectable"); |
---|
| 1189 | + selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
| 1190 | + selectableCB.setToolTipText("Make object selectable"); |
---|
1023 | 1191 | // Return(); |
---|
| 1192 | + |
---|
1024 | 1193 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1025 | 1194 | hideCB.setToolTipText("Hide object"); |
---|
1026 | 1195 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1027 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1196 | + markCB.setToolTipText("As animation target transform"); |
---|
1028 | 1197 | |
---|
1029 | 1198 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1030 | 1199 | |
---|
1031 | 1200 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1032 | 1201 | rewindCB.setToolTipText("Rewind animation"); |
---|
1033 | 1202 | |
---|
1034 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
1035 | | - randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
| 1203 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
| 1204 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1036 | 1205 | |
---|
| 1206 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1207 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1208 | + |
---|
1037 | 1209 | if (Globals.ADVANCED) |
---|
1038 | 1210 | { |
---|
1039 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1040 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1041 | 1211 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1042 | 1212 | speedupCB.setToolTipText("Option motion capture"); |
---|
1043 | 1213 | } |
---|
.. | .. |
---|
1311 | 1481 | XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); |
---|
1312 | 1482 | XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); |
---|
1313 | 1483 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
| 1484 | + //XYZPanel.setName("XYZ"); |
---|
1314 | 1485 | |
---|
1315 | 1486 | /* |
---|
1316 | 1487 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
.. | .. |
---|
1348 | 1519 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1349 | 1520 | //tmp.setName("Edit"); |
---|
1350 | 1521 | objectPanel.add(materialPanel); |
---|
| 1522 | + objectPanel.setIconAt(0, GetIcon("icons/material.png")); |
---|
1351 | 1523 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1352 | 1524 | // north.setName("Edit"); |
---|
1353 | 1525 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1354 | 1526 | // objectPanel.add(north); |
---|
1355 | 1527 | objectPanel.add(editPanel); |
---|
1356 | | - objectPanel.add(infoPanel); |
---|
| 1528 | + objectPanel.setIconAt(1, GetIcon("icons/write.png")); |
---|
| 1529 | + |
---|
| 1530 | + //if (Globals.ADVANCED) |
---|
| 1531 | + objectPanel.add(infoPanel); |
---|
| 1532 | + objectPanel.setIconAt(2, GetIcon("icons/info.png")); |
---|
| 1533 | + |
---|
| 1534 | + objectPanel.add(XYZPanel); |
---|
| 1535 | + objectPanel.setIconAt(3, GetIcon("icons/XYZ.png")); |
---|
| 1536 | + |
---|
| 1537 | + objectPanel.add(toolboxPanel); |
---|
| 1538 | + objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); |
---|
1357 | 1539 | |
---|
1358 | 1540 | /* |
---|
1359 | 1541 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1362 | 1544 | aConstraints.gridy += 1; |
---|
1363 | 1545 | aConstraints.gridwidth = 1; |
---|
1364 | 1546 | mainPanel.add(objectPanel, aConstraints); |
---|
1365 | | - */ |
---|
| 1547 | + */ |
---|
1366 | 1548 | |
---|
1367 | 1549 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1368 | 1550 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1374 | 1556 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1375 | 1557 | |
---|
1376 | 1558 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1377 | | - scenePanel.preferredWidth = 6; |
---|
| 1559 | + scenePanel.preferredWidth = 5; |
---|
1378 | 1560 | |
---|
1379 | 1561 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1380 | 1562 | tabbedPane.add(scrollpane); |
---|
1381 | 1563 | |
---|
1382 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1383 | | - |
---|
1384 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1564 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1385 | 1565 | |
---|
1386 | 1566 | optionsPanel.setName("Options"); |
---|
1387 | 1567 | |
---|
.. | .. |
---|
1389 | 1569 | |
---|
1390 | 1570 | tabbedPane.add(optionsPanel); |
---|
1391 | 1571 | |
---|
| 1572 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1573 | + |
---|
1392 | 1574 | scenePanel.add(tabbedPane); |
---|
1393 | 1575 | |
---|
1394 | 1576 | /* |
---|
.. | .. |
---|
1450 | 1632 | /**/ |
---|
1451 | 1633 | |
---|
1452 | 1634 | bigThree = new cGridBag(); |
---|
1453 | | - bigThree.addComponent(scenePanel); |
---|
1454 | 1635 | bigThree.addComponent(centralPanel); |
---|
1455 | | - bigThree.addComponent(XYZPanel); |
---|
| 1636 | + bigThree.addComponent(scenePanel); |
---|
| 1637 | + //bigThree.addComponent(XYZPanel); |
---|
1456 | 1638 | |
---|
1457 | 1639 | // // SIDE EFFECT!!! |
---|
1458 | 1640 | // aConstraints.gridx = 0; |
---|
.. | .. |
---|
1461 | 1643 | // aConstraints.gridheight = 1; |
---|
1462 | 1644 | |
---|
1463 | 1645 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1464 | | - framePanel.setContinuousLayout(true); |
---|
1465 | | - framePanel.setOneTouchExpandable(true); |
---|
1466 | | - framePanel.setDividerLocation(0.8); |
---|
| 1646 | + framePanel.setContinuousLayout(false); |
---|
| 1647 | + framePanel.setOneTouchExpandable(false); |
---|
| 1648 | + //.setDividerLocation(0.8); |
---|
1467 | 1649 | //framePanel.setDividerSize(15); |
---|
1468 | 1650 | //framePanel.setResizeWeight(0.15); |
---|
1469 | 1651 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1481 | 1663 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1482 | 1664 | |
---|
1483 | 1665 | frame.setSize(1280, 860); |
---|
1484 | | - frame.setVisible(true); |
---|
1485 | | - |
---|
| 1666 | + |
---|
1486 | 1667 | cameraView.requestFocusInWindow(); |
---|
1487 | 1668 | |
---|
1488 | 1669 | gridPanel.setDividerLocation(1.0); |
---|
| 1670 | + |
---|
| 1671 | + frame.validate(); |
---|
| 1672 | + |
---|
| 1673 | + frame.setVisible(true); |
---|
1489 | 1674 | |
---|
1490 | 1675 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1491 | 1676 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1572 | 1757 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1573 | 1758 | colorSection.add(texture); |
---|
1574 | 1759 | |
---|
1575 | | - cGridBag anisoU = new cGridBag(); |
---|
1576 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1577 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1578 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1579 | | - colorSection.add(anisoU); |
---|
1580 | | - |
---|
1581 | | - cGridBag anisoV = new cGridBag(); |
---|
1582 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1583 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1584 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1585 | | - colorSection.add(anisoV); |
---|
1586 | | - |
---|
1587 | | - cGridBag shadowbias = new cGridBag(); |
---|
1588 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1589 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1590 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1591 | | - colorSection.add(shadowbias); |
---|
1592 | | - |
---|
1593 | 1760 | panel.add(new JSeparator()); |
---|
1594 | 1761 | |
---|
1595 | 1762 | panel.add(colorSection); |
---|
.. | .. |
---|
1639 | 1806 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1640 | 1807 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1641 | 1808 | diffuseSection.add(fakedepth); |
---|
| 1809 | + |
---|
| 1810 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1811 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1812 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1813 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1814 | + diffuseSection.add(shadowbias); |
---|
1642 | 1815 | |
---|
1643 | 1816 | panel.add(new JSeparator()); |
---|
1644 | 1817 | |
---|
.. | .. |
---|
1690 | 1863 | // aConstraints.gridy += 1; |
---|
1691 | 1864 | // aConstraints.gridwidth = 1; |
---|
1692 | 1865 | |
---|
| 1866 | + cGridBag anisoU = new cGridBag(); |
---|
| 1867 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1868 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1869 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1870 | + specularSection.add(anisoU); |
---|
| 1871 | + |
---|
| 1872 | + cGridBag anisoV = new cGridBag(); |
---|
| 1873 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1874 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1875 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1876 | + specularSection.add(anisoV); |
---|
| 1877 | + |
---|
1693 | 1878 | |
---|
1694 | 1879 | panel.add(new JSeparator()); |
---|
1695 | 1880 | |
---|
.. | .. |
---|
1697 | 1882 | |
---|
1698 | 1883 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1699 | 1884 | |
---|
1700 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1885 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1701 | 1886 | |
---|
1702 | 1887 | cGridBag camera = new cGridBag(); |
---|
1703 | 1888 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1704 | 1889 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1705 | 1890 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1706 | | - globalSection.add(camera); |
---|
| 1891 | + colorSection.add(camera); |
---|
1707 | 1892 | |
---|
1708 | 1893 | cGridBag ambient = new cGridBag(); |
---|
1709 | 1894 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1710 | 1895 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1711 | 1896 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1712 | | - globalSection.add(ambient); |
---|
| 1897 | + colorSection.add(ambient); |
---|
1713 | 1898 | |
---|
1714 | 1899 | cGridBag backlit = new cGridBag(); |
---|
1715 | 1900 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1716 | 1901 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1717 | 1902 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1718 | | - globalSection.add(backlit); |
---|
| 1903 | + colorSection.add(backlit); |
---|
1719 | 1904 | |
---|
1720 | 1905 | cGridBag opacity = new cGridBag(); |
---|
1721 | 1906 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1722 | 1907 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1723 | 1908 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1724 | | - globalSection.add(opacity); |
---|
| 1909 | + colorSection.add(opacity); |
---|
1725 | 1910 | |
---|
1726 | | - panel.add(new JSeparator()); |
---|
| 1911 | + //panel.add(new JSeparator()); |
---|
1727 | 1912 | |
---|
1728 | | - panel.add(globalSection); |
---|
| 1913 | + //panel.add(globalSection); |
---|
1729 | 1914 | |
---|
1730 | 1915 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1731 | 1916 | |
---|
.. | .. |
---|
1832 | 2017 | // 3D models |
---|
1833 | 2018 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1834 | 2019 | { |
---|
1835 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1836 | | - LoadFile(filename, lastConverter); |
---|
| 2020 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2021 | + //LoadFile(filename, lastConverter); |
---|
| 2022 | + LoadObjFile(filename); // New 3ds loader |
---|
1837 | 2023 | continue; |
---|
1838 | 2024 | } |
---|
1839 | 2025 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2559 | 2745 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2560 | 2746 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2561 | 2747 | } |
---|
| 2748 | + |
---|
2562 | 2749 | //cJME.count++; |
---|
2563 | 2750 | //cJME.count %= 12; |
---|
2564 | 2751 | if (gc) |
---|
.. | .. |
---|
2742 | 2929 | } |
---|
2743 | 2930 | } |
---|
2744 | 2931 | } |
---|
| 2932 | + |
---|
2745 | 2933 | cFileSystemPane FSPane; |
---|
2746 | 2934 | |
---|
2747 | 2935 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2795 | 2983 | } |
---|
2796 | 2984 | } |
---|
2797 | 2985 | } |
---|
| 2986 | + |
---|
2798 | 2987 | freezematerial = false; |
---|
2799 | 2988 | } |
---|
2800 | 2989 | |
---|
2801 | 2990 | void SetMaterial(Object3D object) |
---|
2802 | 2991 | { |
---|
| 2992 | + latestObject = object; |
---|
| 2993 | + |
---|
2803 | 2994 | cMaterial mat = object.material; |
---|
2804 | 2995 | |
---|
2805 | 2996 | if (mat == null) |
---|
.. | .. |
---|
2911 | 3102 | // } |
---|
2912 | 3103 | |
---|
2913 | 3104 | /**/ |
---|
2914 | | - if (deselect) |
---|
| 3105 | + if (deselect || child == null) |
---|
2915 | 3106 | { |
---|
2916 | 3107 | //group.deselectAll(); |
---|
2917 | 3108 | //freeze = true; |
---|
2918 | 3109 | GetTree().clearSelection(); |
---|
2919 | 3110 | //freeze = false; |
---|
| 3111 | + |
---|
| 3112 | + if (child == null) |
---|
| 3113 | + { |
---|
| 3114 | + return; |
---|
| 3115 | + } |
---|
2920 | 3116 | } |
---|
2921 | 3117 | |
---|
2922 | 3118 | //group.addSelectee(child); |
---|
.. | .. |
---|
2985 | 3181 | cameraView.ToggleDL(); |
---|
2986 | 3182 | cameraView.repaint(); |
---|
2987 | 3183 | return; |
---|
2988 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3184 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2989 | 3185 | { |
---|
2990 | 3186 | cameraView.ToggleTexture(); |
---|
2991 | 3187 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3024 | 3220 | frame.validate(); |
---|
3025 | 3221 | |
---|
3026 | 3222 | return; |
---|
3027 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3223 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3028 | 3224 | { |
---|
3029 | 3225 | cameraView.ToggleSwitch(); |
---|
3030 | 3226 | cameraView.repaint(); |
---|
.. | .. |
---|
3055 | 3251 | { |
---|
3056 | 3252 | copy.live ^= true; |
---|
3057 | 3253 | return; |
---|
3058 | | - } else if (event.getSource() == selectCB) |
---|
| 3254 | + } else if (event.getSource() == selectableCB) |
---|
3059 | 3255 | { |
---|
3060 | 3256 | copy.dontselect ^= true; |
---|
3061 | 3257 | return; |
---|
.. | .. |
---|
3240 | 3436 | { |
---|
3241 | 3437 | Close(); |
---|
3242 | 3438 | //return true; |
---|
3243 | | - } else if (source == loadItem) |
---|
| 3439 | + } else if (source == openItem) |
---|
3244 | 3440 | { |
---|
3245 | | - load(); |
---|
| 3441 | + Open(); |
---|
3246 | 3442 | //return true; |
---|
3247 | 3443 | } else if (source == newItem) |
---|
3248 | 3444 | { |
---|
.. | .. |
---|
3267 | 3463 | { |
---|
3268 | 3464 | generatePOV(); |
---|
3269 | 3465 | //return true; |
---|
| 3466 | + } else if (event.getSource() == archiveItem) |
---|
| 3467 | + { |
---|
| 3468 | + cTools.Archive(frame); |
---|
| 3469 | + return; |
---|
3270 | 3470 | } else if (source == zBufferItem) |
---|
3271 | 3471 | { |
---|
3272 | 3472 | try |
---|
.. | .. |
---|
3318 | 3518 | try |
---|
3319 | 3519 | { |
---|
3320 | 3520 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3321 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3322 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3521 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3522 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3323 | 3523 | |
---|
3324 | 3524 | Object3D parent = o.parent; |
---|
3325 | 3525 | o.parent = null; |
---|
.. | .. |
---|
3330 | 3530 | |
---|
3331 | 3531 | out.flush(); |
---|
3332 | 3532 | |
---|
3333 | | - zstream.close(); |
---|
| 3533 | + baos //zstream |
---|
| 3534 | + .close(); |
---|
3334 | 3535 | out.close(); |
---|
3335 | 3536 | |
---|
3336 | | - return baos.toByteArray(); |
---|
| 3537 | + byte[] bytes = baos.toByteArray(); |
---|
| 3538 | + |
---|
| 3539 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3540 | + return bytes; |
---|
3337 | 3541 | } catch (Exception e) |
---|
3338 | 3542 | { |
---|
3339 | 3543 | System.err.println(e); |
---|
.. | .. |
---|
3343 | 3547 | |
---|
3344 | 3548 | static public Object Uncompress(byte[] bytes) |
---|
3345 | 3549 | { |
---|
3346 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3550 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3347 | 3551 | try |
---|
3348 | 3552 | { |
---|
3349 | 3553 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3350 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3351 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3554 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3555 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3352 | 3556 | Object obj = in.readObject(); |
---|
| 3557 | + |
---|
| 3558 | + bais //istream |
---|
| 3559 | + .close(); |
---|
3353 | 3560 | in.close(); |
---|
3354 | 3561 | |
---|
3355 | 3562 | return obj; |
---|
.. | .. |
---|
3404 | 3611 | return null; |
---|
3405 | 3612 | } |
---|
3406 | 3613 | |
---|
3407 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3408 | 3614 | |
---|
3409 | 3615 | public void Save() |
---|
3410 | 3616 | { |
---|
| 3617 | + //Save(true); |
---|
| 3618 | + Replace(); |
---|
| 3619 | + } |
---|
| 3620 | + |
---|
| 3621 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3622 | + { |
---|
| 3623 | + if (compress.length != name.length) |
---|
| 3624 | + { |
---|
| 3625 | + return false; |
---|
| 3626 | + } |
---|
| 3627 | + |
---|
| 3628 | + for (int i=compress.length; --i>=0;) |
---|
| 3629 | + { |
---|
| 3630 | + if (compress[i] != name[i]) |
---|
| 3631 | + return false; |
---|
| 3632 | + } |
---|
| 3633 | + |
---|
| 3634 | + return true; |
---|
| 3635 | + } |
---|
| 3636 | + |
---|
| 3637 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3638 | + |
---|
| 3639 | + public boolean Save(boolean user) |
---|
| 3640 | + { |
---|
| 3641 | + System.err.println("Save"); |
---|
| 3642 | + |
---|
3411 | 3643 | cRadio tab = GetCurrentTab(); |
---|
3412 | 3644 | |
---|
3413 | | - boolean temp = CameraPane.SWITCH; |
---|
3414 | | - CameraPane.SWITCH = false; |
---|
| 3645 | + byte[] compress = CompressCopy(); |
---|
3415 | 3646 | |
---|
3416 | | - copy.ExtractBigData(hashtable); |
---|
| 3647 | + boolean thesame = false; |
---|
| 3648 | + |
---|
| 3649 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3650 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3651 | + { |
---|
| 3652 | + thesame = true; |
---|
| 3653 | + } |
---|
3417 | 3654 | |
---|
3418 | 3655 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3419 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3420 | | - |
---|
3421 | | - copy.RestoreBigData(hashtable); |
---|
3422 | | - |
---|
3423 | | - CameraPane.SWITCH = temp; |
---|
3424 | | - |
---|
3425 | | - //assert(hashtable.isEmpty()); |
---|
3426 | | - |
---|
3427 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + if (!thesame) |
---|
3428 | 3657 | { |
---|
3429 | | - tab.graphs[i] = null; |
---|
| 3658 | + //tab.user[tab.versionindex] = user; |
---|
| 3659 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3660 | + |
---|
| 3661 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3662 | + |
---|
| 3663 | + // if (increment) |
---|
| 3664 | + // tab.versionindex++; |
---|
3430 | 3665 | } |
---|
3431 | 3666 | |
---|
| 3667 | + //copy.RestoreBigData(versiontable); |
---|
| 3668 | + |
---|
| 3669 | + //assert(hashtable.isEmpty()); |
---|
| 3670 | + |
---|
| 3671 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
| 3672 | + { |
---|
| 3673 | + //tab.user[i] = false; |
---|
| 3674 | + copy.versions[i] = null; |
---|
| 3675 | + } |
---|
| 3676 | + |
---|
| 3677 | + SetUndoStates(); |
---|
| 3678 | + |
---|
3432 | 3679 | // test save |
---|
3433 | 3680 | if (false) |
---|
3434 | 3681 | { |
---|
3435 | 3682 | try |
---|
3436 | 3683 | { |
---|
3437 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3684 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3438 | 3685 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3439 | 3686 | |
---|
3440 | 3687 | p.writeObject(copy); |
---|
.. | .. |
---|
3447 | 3694 | e.printStackTrace(); |
---|
3448 | 3695 | } |
---|
3449 | 3696 | } |
---|
| 3697 | + |
---|
| 3698 | + return !thesame; |
---|
3450 | 3699 | } |
---|
3451 | 3700 | |
---|
3452 | 3701 | void CopyChanged(Object3D obj) |
---|
3453 | 3702 | { |
---|
| 3703 | + SetUndoStates(); |
---|
| 3704 | + |
---|
3454 | 3705 | boolean temp = CameraPane.SWITCH; |
---|
3455 | 3706 | CameraPane.SWITCH = false; |
---|
3456 | 3707 | |
---|
3457 | | - copy.ExtractBigData(hashtable); |
---|
| 3708 | + copy.ExtractBigData(versiontable); |
---|
3458 | 3709 | |
---|
3459 | 3710 | copy.clear(); |
---|
3460 | 3711 | |
---|
.. | .. |
---|
3463 | 3714 | copy.add(obj.get(i)); |
---|
3464 | 3715 | } |
---|
3465 | 3716 | |
---|
3466 | | - copy.RestoreBigData(hashtable); |
---|
| 3717 | + copy.RestoreBigData(versiontable); |
---|
3467 | 3718 | |
---|
3468 | 3719 | CameraPane.SWITCH = temp; |
---|
3469 | 3720 | |
---|
.. | .. |
---|
3490 | 3741 | refreshContents(); |
---|
3491 | 3742 | } |
---|
3492 | 3743 | |
---|
3493 | | - public void Undo() |
---|
| 3744 | + cButton undoButton; |
---|
| 3745 | + cButton restoreButton; |
---|
| 3746 | + cButton replaceButton; |
---|
| 3747 | + cButton redoButton; |
---|
| 3748 | + |
---|
| 3749 | + boolean muteSlider; |
---|
| 3750 | + |
---|
| 3751 | + int VersionCount() |
---|
| 3752 | + { |
---|
| 3753 | + int count = 0; |
---|
| 3754 | + |
---|
| 3755 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3756 | + { |
---|
| 3757 | + if (copy.versions[i] != null) |
---|
| 3758 | + count++; |
---|
| 3759 | + } |
---|
| 3760 | + |
---|
| 3761 | + return count; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
| 3764 | + void SetUndoStates() |
---|
3494 | 3765 | { |
---|
3495 | 3766 | cRadio tab = GetCurrentTab(); |
---|
3496 | 3767 | |
---|
3497 | | - if (tab.undoindex == 0) |
---|
| 3768 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3769 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3770 | + |
---|
| 3771 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3772 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3773 | + |
---|
| 3774 | + muteSlider = true; |
---|
| 3775 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3776 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3777 | + muteSlider = false; |
---|
| 3778 | + } |
---|
| 3779 | + |
---|
| 3780 | + public boolean Undo() |
---|
| 3781 | + { |
---|
| 3782 | + // Option? |
---|
| 3783 | + Replace(); |
---|
| 3784 | + |
---|
| 3785 | + System.err.println("Undo"); |
---|
| 3786 | + |
---|
| 3787 | + cRadio tab = GetCurrentTab(); |
---|
| 3788 | + |
---|
| 3789 | + if (copy.versionindex == 0) |
---|
3498 | 3790 | { |
---|
3499 | 3791 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3500 | | - return; |
---|
| 3792 | + return false; |
---|
3501 | 3793 | } |
---|
3502 | 3794 | |
---|
3503 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3795 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3796 | +// { |
---|
| 3797 | +// if (Save(false)) |
---|
| 3798 | +// tab.versionindex -= 1; |
---|
| 3799 | +// else |
---|
| 3800 | +// { |
---|
| 3801 | +// if (tab.versionindex <= 0) |
---|
| 3802 | +// return false; |
---|
| 3803 | +// else |
---|
| 3804 | +// tab.versionindex -= 1; |
---|
| 3805 | +// } |
---|
| 3806 | +// } |
---|
| 3807 | + |
---|
| 3808 | + copy.versionindex -= 1; |
---|
| 3809 | + |
---|
| 3810 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3811 | + |
---|
| 3812 | + return true; |
---|
| 3813 | + } |
---|
| 3814 | + |
---|
| 3815 | + public boolean Restore() |
---|
| 3816 | + { |
---|
| 3817 | + System.err.println("Restore"); |
---|
| 3818 | + |
---|
| 3819 | + cRadio tab = GetCurrentTab(); |
---|
| 3820 | + |
---|
| 3821 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3504 | 3822 | { |
---|
3505 | | - Save(); |
---|
3506 | | - tab.undoindex -= 1; |
---|
| 3823 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3824 | + return false; |
---|
3507 | 3825 | } |
---|
3508 | 3826 | |
---|
3509 | | - tab.undoindex -= 1; |
---|
| 3827 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3828 | + |
---|
| 3829 | + return true; |
---|
| 3830 | + } |
---|
3510 | 3831 | |
---|
3511 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3832 | + public boolean Replace() |
---|
| 3833 | + { |
---|
| 3834 | + System.err.println("Replace"); |
---|
| 3835 | + |
---|
| 3836 | + cRadio tab = GetCurrentTab(); |
---|
| 3837 | + |
---|
| 3838 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3839 | + { |
---|
| 3840 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3841 | + return false; |
---|
| 3842 | + } |
---|
| 3843 | + |
---|
| 3844 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
| 3845 | + |
---|
| 3846 | + return true; |
---|
3512 | 3847 | } |
---|
3513 | 3848 | |
---|
3514 | 3849 | public void Redo() |
---|
3515 | 3850 | { |
---|
| 3851 | + // Option? |
---|
| 3852 | + Replace(); |
---|
| 3853 | + |
---|
3516 | 3854 | cRadio tab = GetCurrentTab(); |
---|
3517 | 3855 | |
---|
3518 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3856 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3519 | 3857 | { |
---|
3520 | 3858 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3521 | 3859 | return; |
---|
3522 | 3860 | } |
---|
3523 | 3861 | |
---|
3524 | | - tab.undoindex += 1; |
---|
| 3862 | + copy.versionindex += 1; |
---|
3525 | 3863 | |
---|
3526 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3864 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3865 | + |
---|
| 3866 | + //if (!tab.user[tab.versionindex]) |
---|
| 3867 | + // tab.graphs[tab.versionindex] = null; |
---|
3527 | 3868 | } |
---|
3528 | 3869 | |
---|
3529 | 3870 | void ImportGFD() |
---|
.. | .. |
---|
3675 | 4016 | assert false; |
---|
3676 | 4017 | } |
---|
3677 | 4018 | |
---|
3678 | | - void EditSelection() |
---|
| 4019 | + void EditSelection(boolean newWindow) |
---|
3679 | 4020 | { |
---|
3680 | 4021 | } |
---|
3681 | 4022 | |
---|
.. | .. |
---|
3819 | 4160 | //copy.Touch(); |
---|
3820 | 4161 | } |
---|
3821 | 4162 | |
---|
| 4163 | + cNumberSlider versionSlider; |
---|
| 4164 | + |
---|
3822 | 4165 | public void stateChanged(ChangeEvent e) |
---|
3823 | 4166 | { |
---|
3824 | 4167 | // assert(false); |
---|
| 4168 | + if (e.getSource() == versionSlider) |
---|
| 4169 | + { |
---|
| 4170 | + if (muteSlider) |
---|
| 4171 | + return; |
---|
| 4172 | + |
---|
| 4173 | + int version = versionSlider.getInteger(); |
---|
| 4174 | + |
---|
| 4175 | + if (copy.versions[version] != null) |
---|
| 4176 | + { |
---|
| 4177 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4178 | + } |
---|
| 4179 | + |
---|
| 4180 | + return; |
---|
| 4181 | + } |
---|
3825 | 4182 | |
---|
3826 | 4183 | if (freezematerial) |
---|
3827 | 4184 | { |
---|
.. | .. |
---|
4170 | 4527 | |
---|
4171 | 4528 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4172 | 4529 | { |
---|
4173 | | - Save(); |
---|
| 4530 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
| 4531 | + Save(); |
---|
4174 | 4532 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4175 | 4533 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4176 | 4534 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4257 | 4615 | { |
---|
4258 | 4616 | ResetModel(); |
---|
4259 | 4617 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4618 | + |
---|
| 4619 | + if (thing.Size() == 0) |
---|
| 4620 | + { |
---|
| 4621 | + //EditSelection(false); |
---|
| 4622 | + } |
---|
| 4623 | + |
---|
4260 | 4624 | refreshContents(); |
---|
4261 | 4625 | } |
---|
4262 | 4626 | |
---|
.. | .. |
---|
4405 | 4769 | readobj.ResetDisplayList(); |
---|
4406 | 4770 | } catch (Exception e) |
---|
4407 | 4771 | { |
---|
4408 | | - //e.printStackTrace(); |
---|
| 4772 | + if (!e.toString().contains("GZIP")) |
---|
| 4773 | + e.printStackTrace(); |
---|
| 4774 | + |
---|
4409 | 4775 | try |
---|
4410 | 4776 | { |
---|
4411 | 4777 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
.. | .. |
---|
4479 | 4845 | |
---|
4480 | 4846 | if (readobj != null) |
---|
4481 | 4847 | { |
---|
4482 | | - Save(); |
---|
| 4848 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4849 | + // Save(); |
---|
4483 | 4850 | try |
---|
4484 | 4851 | { |
---|
4485 | 4852 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4524 | 4891 | } |
---|
4525 | 4892 | } catch (ClassCastException e) |
---|
4526 | 4893 | { |
---|
| 4894 | + e.printStackTrace(); |
---|
4527 | 4895 | assert (false); |
---|
4528 | 4896 | Composite c = (Composite) copy; |
---|
4529 | 4897 | c.children.clear(); |
---|
.. | .. |
---|
4534 | 4902 | c.addChild(csg); |
---|
4535 | 4903 | } |
---|
4536 | 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 | + |
---|
4537 | 4916 | ResetModel(); |
---|
4538 | 4917 | copy.HardTouch(); // recompile? |
---|
4539 | 4918 | refreshContents(); |
---|
4540 | 4919 | } |
---|
4541 | 4920 | } |
---|
4542 | 4921 | |
---|
4543 | | - void load() // throws ClassNotFoundException |
---|
| 4922 | + void Open() // throws ClassNotFoundException |
---|
4544 | 4923 | { |
---|
4545 | 4924 | if (Grafreed.standAlone) |
---|
4546 | 4925 | { |
---|
.. | .. |
---|
4643 | 5022 | //ps.print(buffer.toString()); |
---|
4644 | 5023 | } catch (IOException e) |
---|
4645 | 5024 | { |
---|
| 5025 | + e.printStackTrace(); |
---|
4646 | 5026 | } |
---|
4647 | 5027 | } |
---|
4648 | 5028 | |
---|
.. | .. |
---|
4657 | 5037 | String filename = browser.getFile(); |
---|
4658 | 5038 | if (filename != null && filename.length() > 0) |
---|
4659 | 5039 | { |
---|
| 5040 | + if (!filename.endsWith(".gfd")) |
---|
| 5041 | + filename += ".gfd"; |
---|
4660 | 5042 | lastname = browser.getDirectory() + filename; |
---|
4661 | 5043 | save(); |
---|
4662 | 5044 | } |
---|
.. | .. |
---|
4823 | 5205 | MenuBar menuBar; |
---|
4824 | 5206 | Menu fileMenu; |
---|
4825 | 5207 | MenuItem newItem; |
---|
4826 | | - MenuItem loadItem; |
---|
| 5208 | + MenuItem openItem; |
---|
4827 | 5209 | MenuItem saveItem; |
---|
4828 | 5210 | MenuItem saveAsItem; |
---|
4829 | 5211 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4846 | 5228 | CheckboxMenuItem toggleSwitchItem; |
---|
4847 | 5229 | CheckboxMenuItem toggleRootItem; |
---|
4848 | 5230 | CheckboxMenuItem animationItem; |
---|
| 5231 | + MenuItem archiveItem; |
---|
4849 | 5232 | CheckboxMenuItem toggleHandleItem; |
---|
4850 | 5233 | CheckboxMenuItem togglePaintItem; |
---|
4851 | 5234 | JSplitPane mainPanel; |
---|
4852 | 5235 | JScrollPane scrollpane; |
---|
| 5236 | + |
---|
4853 | 5237 | JPanel toolbarPanel; |
---|
| 5238 | + |
---|
4854 | 5239 | cGridBag treePanel; |
---|
| 5240 | + |
---|
4855 | 5241 | JPanel radioPanel; |
---|
4856 | 5242 | ButtonGroup buttonGroup; |
---|
4857 | | - cGridBag ctrlPanel; |
---|
| 5243 | + |
---|
| 5244 | + cGridBag toolboxPanel; |
---|
4858 | 5245 | cGridBag materialPanel; |
---|
| 5246 | + cGridBag ctrlPanel; |
---|
| 5247 | + |
---|
4859 | 5248 | JScrollPane infoPanel; |
---|
| 5249 | + |
---|
4860 | 5250 | cGridBag optionsPanel; |
---|
| 5251 | + |
---|
4861 | 5252 | JTabbedPane objectPanel; |
---|
| 5253 | + boolean materialFlushed; |
---|
| 5254 | + Object3D latestObject; |
---|
| 5255 | + |
---|
4862 | 5256 | cGridBag XYZPanel; |
---|
| 5257 | + |
---|
4863 | 5258 | JSplitPane gridPanel; |
---|
4864 | 5259 | JSplitPane bigPanel; |
---|
| 5260 | + |
---|
4865 | 5261 | cGridBag bigThree; |
---|
4866 | 5262 | cGridBag scenePanel; |
---|
4867 | 5263 | cGridBag centralPanel; |
---|
.. | .. |
---|
4976 | 5372 | cNumberSlider fogField; |
---|
4977 | 5373 | JLabel opacityPowerLabel; |
---|
4978 | 5374 | cNumberSlider opacityPowerField; |
---|
4979 | | - JTree jTree; |
---|
| 5375 | + cTree jTree; |
---|
4980 | 5376 | //ObjectUI parent; |
---|
4981 | 5377 | |
---|
4982 | 5378 | cNumberSlider normalpushField; |
---|