.. | .. |
---|
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); |
---|
.. | .. |
---|
171 | 220 | |
---|
172 | 221 | objEditor.ctrlPanel.remove(setupPanel); |
---|
173 | 222 | objEditor.ctrlPanel.remove(setupPanel2); |
---|
174 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 223 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
175 | 224 | objEditor.ctrlPanel.remove(pushPanel); |
---|
176 | 225 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
177 | 226 | |
---|
.. | .. |
---|
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"); |
---|
| 429 | + |
---|
| 430 | + editPanel = new cGridBag().setVertical(true); |
---|
| 431 | + //editPanel.setName("Edit"); |
---|
| 432 | + |
---|
330 | 433 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
331 | | - ctrlPanel.setName("Edit"); |
---|
| 434 | + |
---|
| 435 | + editCommandsPanel = new cGridBag(); |
---|
| 436 | + editPanel.add(editCommandsPanel); |
---|
| 437 | + editPanel.add(ctrlPanel); |
---|
| 438 | + |
---|
| 439 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 440 | + //toolboxPanel.setName("Toolbox"); |
---|
| 441 | + |
---|
332 | 442 | materialPanel = new cGridBag().setVertical(true); |
---|
333 | | - materialPanel.setName("Material"); |
---|
| 443 | + //materialPanel.setName("Material"); |
---|
| 444 | + |
---|
334 | 445 | /*JTextPane*/ |
---|
335 | 446 | infoarea = createTextPane(); |
---|
336 | 447 | doc = infoarea.getStyledDocument(); |
---|
337 | 448 | |
---|
338 | 449 | infoarea.setEditable(true); |
---|
339 | 450 | SetText(); |
---|
| 451 | + |
---|
340 | 452 | // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); |
---|
341 | 453 | // infoarea.setOpaque(false); |
---|
342 | 454 | // //infoarea.setForeground(textcolor); |
---|
343 | 455 | // TEXTAREA infoarea.setLineWrap(true); |
---|
344 | 456 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
345 | 457 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
346 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
347 | | - infoPanel.setName("Info"); |
---|
| 458 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
| 459 | + //infoPanel.setName("Info"); |
---|
348 | 460 | //infoPanel.setLayout(new BorderLayout()); |
---|
349 | 461 | //infoPanel.add(createTextPane()); |
---|
350 | 462 | |
---|
.. | .. |
---|
355 | 467 | mainPanel.setDividerSize(9); |
---|
356 | 468 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
357 | 469 | mainPanel.setResizeWeight(0.5); |
---|
358 | | - |
---|
| 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 | + |
---|
359 | 478 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
360 | 479 | //mainPanel.setLayout(new GridBagLayout()); |
---|
361 | 480 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
586 | 705 | } |
---|
587 | 706 | } |
---|
588 | 707 | |
---|
589 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
590 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 708 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 709 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
591 | 710 | |
---|
592 | 711 | Rectangle keeprect; |
---|
593 | 712 | cRadio radio; |
---|
.. | .. |
---|
603 | 722 | |
---|
604 | 723 | boolean maximized; |
---|
605 | 724 | |
---|
| 725 | + cButton fullscreenLayout; |
---|
| 726 | + |
---|
606 | 727 | void Minimize() |
---|
607 | 728 | { |
---|
608 | 729 | frame.setState(Frame.ICONIFIED); |
---|
| 730 | + frame.validate(); |
---|
609 | 731 | } |
---|
610 | 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={} |
---|
611 | 736 | void Maximize() |
---|
612 | 737 | { |
---|
| 738 | + if (CameraPane.FULLSCREEN) |
---|
| 739 | + { |
---|
| 740 | + ToggleFullScreen(); |
---|
| 741 | + } |
---|
| 742 | + |
---|
613 | 743 | if (maximized) |
---|
614 | 744 | { |
---|
615 | 745 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
617 | 747 | else |
---|
618 | 748 | { |
---|
619 | 749 | keeprect = frame.getBounds(); |
---|
620 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
621 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
622 | | - 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); |
---|
623 | 753 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 754 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
624 | 755 | } |
---|
625 | 756 | |
---|
626 | 757 | maximized ^= true; |
---|
| 758 | + |
---|
| 759 | + frame.validate(); |
---|
627 | 760 | } |
---|
| 761 | + |
---|
| 762 | + cButton minButton; |
---|
| 763 | + cButton maxButton; |
---|
| 764 | + cButton fullButton; |
---|
628 | 765 | |
---|
629 | 766 | void ToggleFullScreen() |
---|
630 | 767 | { |
---|
631 | | - if (CameraPane.FULLSCREEN) |
---|
| 768 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 769 | + |
---|
| 770 | + cameraView.ToggleFullScreen(); |
---|
| 771 | + |
---|
| 772 | + if (!CameraPane.FULLSCREEN) |
---|
632 | 773 | { |
---|
633 | 774 | device.setFullScreenWindow(null); |
---|
| 775 | + frame.dispose(); |
---|
| 776 | + frame.setUndecorated(false); |
---|
| 777 | + frame.validate(); |
---|
| 778 | + frame.setVisible(true); |
---|
| 779 | + |
---|
634 | 780 | //frame.setVisible(false); |
---|
635 | 781 | // frame.removeNotify(); |
---|
636 | 782 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
640 | 786 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
641 | 787 | // X framePanel.add(bigThree); |
---|
642 | 788 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
643 | | - framePanel.setDividerLocation(1); |
---|
| 789 | + framePanel.setDividerLocation(46); |
---|
644 | 790 | |
---|
645 | 791 | //frame.setVisible(true); |
---|
646 | 792 | radio.layout = keepButton; |
---|
.. | .. |
---|
655 | 801 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
656 | 802 | // frame.getToolkit().getScreenSize().height); |
---|
657 | 803 | //frame.setVisible(false); |
---|
| 804 | + |
---|
| 805 | + frame.dispose(); |
---|
| 806 | + frame.setUndecorated(true); |
---|
658 | 807 | device.setFullScreenWindow(frame); |
---|
| 808 | + frame.validate(); |
---|
| 809 | + frame.setVisible(true); |
---|
659 | 810 | // frame.removeNotify(); |
---|
660 | 811 | // frame.setUndecorated(true); |
---|
661 | 812 | // frame.addNotify(); |
---|
.. | .. |
---|
664 | 815 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
665 | 816 | framePanel.setDividerLocation(0); |
---|
666 | 817 | |
---|
667 | | - radio.layout = twoButton; |
---|
| 818 | + radio.layout = fullscreenLayout; |
---|
668 | 819 | radio.layout.doClick(); |
---|
669 | 820 | //frame.setVisible(true); |
---|
670 | 821 | } |
---|
671 | | - |
---|
672 | | - cameraView.ToggleFullScreen(); |
---|
| 822 | + frame.validate(); |
---|
673 | 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 | + } |
---|
674 | 846 | |
---|
675 | 847 | private JTextPane createTextPane() |
---|
676 | 848 | { |
---|
.. | .. |
---|
802 | 974 | // NumberSlider vDivsField; |
---|
803 | 975 | // JCheckBox endcaps; |
---|
804 | 976 | JCheckBox liveCB; |
---|
805 | | - JCheckBox selectCB; |
---|
| 977 | + JCheckBox selectableCB; |
---|
806 | 978 | JCheckBox hideCB; |
---|
807 | 979 | JCheckBox link2masterCB; |
---|
808 | 980 | JCheckBox markCB; |
---|
.. | .. |
---|
810 | 982 | JCheckBox speedupCB; |
---|
811 | 983 | JCheckBox rewindCB; |
---|
812 | 984 | JCheckBox flipVCB; |
---|
| 985 | + |
---|
| 986 | + cCheckBox toggleTextureCB; |
---|
| 987 | + cCheckBox toggleSwitchCB; |
---|
| 988 | + |
---|
813 | 989 | JComboBox texresMenu; |
---|
| 990 | + |
---|
814 | 991 | JButton resetButton; |
---|
815 | 992 | JButton stepButton; |
---|
816 | 993 | JButton stepAllButton; |
---|
.. | .. |
---|
819 | 996 | JButton fasterButton; |
---|
820 | 997 | JButton remarkButton; |
---|
821 | 998 | |
---|
| 999 | + cGridBag editPanel; |
---|
| 1000 | + cGridBag editCommandsPanel; |
---|
| 1001 | + |
---|
822 | 1002 | cGridBag namePanel; |
---|
823 | 1003 | cGridBag setupPanel; |
---|
824 | 1004 | cGridBag setupPanel2; |
---|
825 | | - cGridBag commandsPanel; |
---|
| 1005 | + cGridBag objectCommandsPanel; |
---|
826 | 1006 | cGridBag pushPanel; |
---|
827 | 1007 | cGridBag fillPanel; |
---|
828 | 1008 | |
---|
.. | .. |
---|
994 | 1174 | namePanel = new cGridBag(); |
---|
995 | 1175 | |
---|
996 | 1176 | nameField = AddText(namePanel, copy.GetName()); |
---|
997 | | - namePanel.add(nameField); |
---|
| 1177 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
998 | 1178 | oe.ctrlPanel.add(namePanel); |
---|
999 | 1179 | |
---|
1000 | 1180 | oe.ctrlPanel.Return(); |
---|
1001 | 1181 | |
---|
1002 | | - if (!GroupEditor.allparams) |
---|
| 1182 | + if (!allparams) |
---|
1003 | 1183 | return; |
---|
1004 | 1184 | |
---|
1005 | 1185 | setupPanel = new cGridBag().setVertical(false); |
---|
1006 | 1186 | |
---|
1007 | 1187 | liveCB = AddCheckBox(setupPanel, "Live", copy.live); |
---|
1008 | 1188 | liveCB.setToolTipText("Animate object"); |
---|
1009 | | - selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
1010 | | - selectCB.setToolTipText("Make object selectable"); |
---|
| 1189 | + selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
| 1190 | + selectableCB.setToolTipText("Make object selectable"); |
---|
1011 | 1191 | // Return(); |
---|
| 1192 | + |
---|
1012 | 1193 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1013 | 1194 | hideCB.setToolTipText("Hide object"); |
---|
1014 | 1195 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1015 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1196 | + markCB.setToolTipText("As animation target transform"); |
---|
1016 | 1197 | |
---|
1017 | 1198 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1018 | 1199 | |
---|
1019 | 1200 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1020 | 1201 | rewindCB.setToolTipText("Rewind animation"); |
---|
1021 | 1202 | |
---|
1022 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
1023 | | - 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)"); |
---|
1024 | 1205 | |
---|
| 1206 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1207 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1208 | + |
---|
1025 | 1209 | if (Globals.ADVANCED) |
---|
1026 | 1210 | { |
---|
1027 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1028 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1029 | 1211 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1030 | 1212 | speedupCB.setToolTipText("Option motion capture"); |
---|
1031 | 1213 | } |
---|
.. | .. |
---|
1035 | 1217 | oe.ctrlPanel.add(setupPanel2); |
---|
1036 | 1218 | oe.ctrlPanel.Return(); |
---|
1037 | 1219 | |
---|
1038 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1220 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
1039 | 1221 | |
---|
1040 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1222 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
1041 | 1223 | resetButton.setToolTipText("Jump to frame zero"); |
---|
1042 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1224 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
1043 | 1225 | stepButton.setToolTipText("Step one frame"); |
---|
1044 | 1226 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
1045 | 1227 | // stepAllButton = AddButton(oe, "Step All"); |
---|
1046 | 1228 | // Return(); |
---|
1047 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1229 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
1048 | 1230 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
1049 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1231 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
1050 | 1232 | fasterButton.setToolTipText("Increase animation speed"); |
---|
1051 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1233 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
1052 | 1234 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
1053 | 1235 | |
---|
1054 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1236 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
1055 | 1237 | oe.ctrlPanel.Return(); |
---|
1056 | 1238 | |
---|
1057 | 1239 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1299 | 1481 | XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); |
---|
1300 | 1482 | XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); |
---|
1301 | 1483 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
| 1484 | + //XYZPanel.setName("XYZ"); |
---|
1302 | 1485 | |
---|
1303 | 1486 | /* |
---|
1304 | 1487 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
.. | .. |
---|
1336 | 1519 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1337 | 1520 | //tmp.setName("Edit"); |
---|
1338 | 1521 | objectPanel.add(materialPanel); |
---|
| 1522 | + objectPanel.setIconAt(0, GetIcon("icons/material.png")); |
---|
1339 | 1523 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1340 | 1524 | // north.setName("Edit"); |
---|
1341 | 1525 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1342 | 1526 | // objectPanel.add(north); |
---|
1343 | | - objectPanel.add(ctrlPanel); |
---|
1344 | | - objectPanel.add(infoPanel); |
---|
| 1527 | + objectPanel.add(editPanel); |
---|
| 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")); |
---|
1345 | 1539 | |
---|
1346 | 1540 | /* |
---|
1347 | 1541 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1350 | 1544 | aConstraints.gridy += 1; |
---|
1351 | 1545 | aConstraints.gridwidth = 1; |
---|
1352 | 1546 | mainPanel.add(objectPanel, aConstraints); |
---|
1353 | | - */ |
---|
| 1547 | + */ |
---|
1354 | 1548 | |
---|
1355 | 1549 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1356 | 1550 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1362 | 1556 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1363 | 1557 | |
---|
1364 | 1558 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1365 | | - scenePanel.preferredWidth = 6; |
---|
| 1559 | + scenePanel.preferredWidth = 5; |
---|
1366 | 1560 | |
---|
1367 | 1561 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1368 | 1562 | tabbedPane.add(scrollpane); |
---|
1369 | 1563 | |
---|
1370 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1371 | | - |
---|
1372 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1564 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1373 | 1565 | |
---|
1374 | 1566 | optionsPanel.setName("Options"); |
---|
1375 | 1567 | |
---|
.. | .. |
---|
1377 | 1569 | |
---|
1378 | 1570 | tabbedPane.add(optionsPanel); |
---|
1379 | 1571 | |
---|
| 1572 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1573 | + |
---|
1380 | 1574 | scenePanel.add(tabbedPane); |
---|
1381 | 1575 | |
---|
1382 | 1576 | /* |
---|
.. | .. |
---|
1440 | 1634 | bigThree = new cGridBag(); |
---|
1441 | 1635 | bigThree.addComponent(scenePanel); |
---|
1442 | 1636 | bigThree.addComponent(centralPanel); |
---|
1443 | | - bigThree.addComponent(XYZPanel); |
---|
| 1637 | + //bigThree.addComponent(XYZPanel); |
---|
1444 | 1638 | |
---|
1445 | 1639 | // // SIDE EFFECT!!! |
---|
1446 | 1640 | // aConstraints.gridx = 0; |
---|
.. | .. |
---|
1449 | 1643 | // aConstraints.gridheight = 1; |
---|
1450 | 1644 | |
---|
1451 | 1645 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1452 | | - framePanel.setContinuousLayout(true); |
---|
1453 | | - framePanel.setOneTouchExpandable(true); |
---|
1454 | | - framePanel.setDividerLocation(0.8); |
---|
| 1646 | + framePanel.setContinuousLayout(false); |
---|
| 1647 | + framePanel.setOneTouchExpandable(false); |
---|
| 1648 | + //.setDividerLocation(0.8); |
---|
1455 | 1649 | //framePanel.setDividerSize(15); |
---|
1456 | 1650 | //framePanel.setResizeWeight(0.15); |
---|
1457 | 1651 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1469 | 1663 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1470 | 1664 | |
---|
1471 | 1665 | frame.setSize(1280, 860); |
---|
1472 | | - frame.setVisible(true); |
---|
1473 | | - |
---|
| 1666 | + |
---|
1474 | 1667 | cameraView.requestFocusInWindow(); |
---|
1475 | 1668 | |
---|
1476 | 1669 | gridPanel.setDividerLocation(1.0); |
---|
| 1670 | + |
---|
| 1671 | + frame.validate(); |
---|
| 1672 | + |
---|
| 1673 | + frame.setVisible(true); |
---|
1477 | 1674 | |
---|
1478 | 1675 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1479 | 1676 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1560 | 1757 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1561 | 1758 | colorSection.add(texture); |
---|
1562 | 1759 | |
---|
1563 | | - cGridBag anisoU = new cGridBag(); |
---|
1564 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1565 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1566 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1567 | | - colorSection.add(anisoU); |
---|
1568 | | - |
---|
1569 | | - cGridBag anisoV = new cGridBag(); |
---|
1570 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1571 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1572 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1573 | | - colorSection.add(anisoV); |
---|
1574 | | - |
---|
1575 | | - cGridBag shadowbias = new cGridBag(); |
---|
1576 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1577 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1578 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1579 | | - colorSection.add(shadowbias); |
---|
1580 | | - |
---|
1581 | 1760 | panel.add(new JSeparator()); |
---|
1582 | 1761 | |
---|
1583 | 1762 | panel.add(colorSection); |
---|
.. | .. |
---|
1627 | 1806 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1628 | 1807 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1629 | 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); |
---|
1630 | 1815 | |
---|
1631 | 1816 | panel.add(new JSeparator()); |
---|
1632 | 1817 | |
---|
.. | .. |
---|
1678 | 1863 | // aConstraints.gridy += 1; |
---|
1679 | 1864 | // aConstraints.gridwidth = 1; |
---|
1680 | 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 | + |
---|
1681 | 1878 | |
---|
1682 | 1879 | panel.add(new JSeparator()); |
---|
1683 | 1880 | |
---|
.. | .. |
---|
1685 | 1882 | |
---|
1686 | 1883 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1687 | 1884 | |
---|
1688 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1885 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1689 | 1886 | |
---|
1690 | 1887 | cGridBag camera = new cGridBag(); |
---|
1691 | 1888 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1692 | 1889 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1693 | 1890 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1694 | | - globalSection.add(camera); |
---|
| 1891 | + colorSection.add(camera); |
---|
1695 | 1892 | |
---|
1696 | 1893 | cGridBag ambient = new cGridBag(); |
---|
1697 | 1894 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1698 | 1895 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1699 | 1896 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1700 | | - globalSection.add(ambient); |
---|
| 1897 | + colorSection.add(ambient); |
---|
1701 | 1898 | |
---|
1702 | 1899 | cGridBag backlit = new cGridBag(); |
---|
1703 | 1900 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1704 | 1901 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1705 | 1902 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1706 | | - globalSection.add(backlit); |
---|
| 1903 | + colorSection.add(backlit); |
---|
1707 | 1904 | |
---|
1708 | 1905 | cGridBag opacity = new cGridBag(); |
---|
1709 | 1906 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1710 | 1907 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1711 | 1908 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1712 | | - globalSection.add(opacity); |
---|
| 1909 | + colorSection.add(opacity); |
---|
1713 | 1910 | |
---|
1714 | | - panel.add(new JSeparator()); |
---|
| 1911 | + //panel.add(new JSeparator()); |
---|
1715 | 1912 | |
---|
1716 | | - panel.add(globalSection); |
---|
| 1913 | + //panel.add(globalSection); |
---|
1717 | 1914 | |
---|
1718 | 1915 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1719 | 1916 | |
---|
.. | .. |
---|
1820 | 2017 | // 3D models |
---|
1821 | 2018 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1822 | 2019 | { |
---|
1823 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1824 | | - LoadFile(filename, lastConverter); |
---|
| 2020 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2021 | + //LoadFile(filename, lastConverter); |
---|
| 2022 | + LoadObjFile(filename); // New 3ds loader |
---|
1825 | 2023 | continue; |
---|
1826 | 2024 | } |
---|
1827 | 2025 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2547 | 2745 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2548 | 2746 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2549 | 2747 | } |
---|
| 2748 | + |
---|
2550 | 2749 | //cJME.count++; |
---|
2551 | 2750 | //cJME.count %= 12; |
---|
2552 | 2751 | if (gc) |
---|
.. | .. |
---|
2730 | 2929 | } |
---|
2731 | 2930 | } |
---|
2732 | 2931 | } |
---|
| 2932 | + |
---|
2733 | 2933 | cFileSystemPane FSPane; |
---|
2734 | 2934 | |
---|
2735 | 2935 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2783 | 2983 | } |
---|
2784 | 2984 | } |
---|
2785 | 2985 | } |
---|
| 2986 | + |
---|
2786 | 2987 | freezematerial = false; |
---|
2787 | 2988 | } |
---|
2788 | 2989 | |
---|
2789 | 2990 | void SetMaterial(Object3D object) |
---|
2790 | 2991 | { |
---|
| 2992 | + latestObject = object; |
---|
| 2993 | + |
---|
2791 | 2994 | cMaterial mat = object.material; |
---|
2792 | 2995 | |
---|
2793 | 2996 | if (mat == null) |
---|
.. | .. |
---|
2899 | 3102 | // } |
---|
2900 | 3103 | |
---|
2901 | 3104 | /**/ |
---|
2902 | | - if (deselect) |
---|
| 3105 | + if (deselect || child == null) |
---|
2903 | 3106 | { |
---|
2904 | 3107 | //group.deselectAll(); |
---|
2905 | 3108 | //freeze = true; |
---|
2906 | 3109 | GetTree().clearSelection(); |
---|
2907 | 3110 | //freeze = false; |
---|
| 3111 | + |
---|
| 3112 | + if (child == null) |
---|
| 3113 | + { |
---|
| 3114 | + return; |
---|
| 3115 | + } |
---|
2908 | 3116 | } |
---|
2909 | 3117 | |
---|
2910 | 3118 | //group.addSelectee(child); |
---|
.. | .. |
---|
2973 | 3181 | cameraView.ToggleDL(); |
---|
2974 | 3182 | cameraView.repaint(); |
---|
2975 | 3183 | return; |
---|
2976 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3184 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2977 | 3185 | { |
---|
2978 | 3186 | cameraView.ToggleTexture(); |
---|
2979 | 3187 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3012 | 3220 | frame.validate(); |
---|
3013 | 3221 | |
---|
3014 | 3222 | return; |
---|
3015 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3223 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3016 | 3224 | { |
---|
3017 | 3225 | cameraView.ToggleSwitch(); |
---|
3018 | 3226 | cameraView.repaint(); |
---|
.. | .. |
---|
3043 | 3251 | { |
---|
3044 | 3252 | copy.live ^= true; |
---|
3045 | 3253 | return; |
---|
3046 | | - } else if (event.getSource() == selectCB) |
---|
| 3254 | + } else if (event.getSource() == selectableCB) |
---|
3047 | 3255 | { |
---|
3048 | 3256 | copy.dontselect ^= true; |
---|
3049 | 3257 | return; |
---|
.. | .. |
---|
3228 | 3436 | { |
---|
3229 | 3437 | Close(); |
---|
3230 | 3438 | //return true; |
---|
3231 | | - } else if (source == loadItem) |
---|
| 3439 | + } else if (source == openItem) |
---|
3232 | 3440 | { |
---|
3233 | | - load(); |
---|
| 3441 | + Open(); |
---|
3234 | 3442 | //return true; |
---|
3235 | 3443 | } else if (source == newItem) |
---|
3236 | 3444 | { |
---|
.. | .. |
---|
3255 | 3463 | { |
---|
3256 | 3464 | generatePOV(); |
---|
3257 | 3465 | //return true; |
---|
| 3466 | + } else if (event.getSource() == archiveItem) |
---|
| 3467 | + { |
---|
| 3468 | + cTools.Archive(frame); |
---|
| 3469 | + return; |
---|
3258 | 3470 | } else if (source == zBufferItem) |
---|
3259 | 3471 | { |
---|
3260 | 3472 | try |
---|
.. | .. |
---|
3306 | 3518 | try |
---|
3307 | 3519 | { |
---|
3308 | 3520 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3309 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3310 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3521 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3522 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3311 | 3523 | |
---|
3312 | 3524 | Object3D parent = o.parent; |
---|
3313 | 3525 | o.parent = null; |
---|
.. | .. |
---|
3318 | 3530 | |
---|
3319 | 3531 | out.flush(); |
---|
3320 | 3532 | |
---|
3321 | | - zstream.close(); |
---|
| 3533 | + baos //zstream |
---|
| 3534 | + .close(); |
---|
3322 | 3535 | out.close(); |
---|
3323 | 3536 | |
---|
3324 | | - return baos.toByteArray(); |
---|
| 3537 | + byte[] bytes = baos.toByteArray(); |
---|
| 3538 | + |
---|
| 3539 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3540 | + return bytes; |
---|
3325 | 3541 | } catch (Exception e) |
---|
3326 | 3542 | { |
---|
3327 | 3543 | System.err.println(e); |
---|
.. | .. |
---|
3331 | 3547 | |
---|
3332 | 3548 | static public Object Uncompress(byte[] bytes) |
---|
3333 | 3549 | { |
---|
3334 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3550 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3335 | 3551 | try |
---|
3336 | 3552 | { |
---|
3337 | 3553 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3338 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3339 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3554 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3555 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3340 | 3556 | Object obj = in.readObject(); |
---|
| 3557 | + |
---|
| 3558 | + bais //istream |
---|
| 3559 | + .close(); |
---|
3341 | 3560 | in.close(); |
---|
3342 | 3561 | |
---|
3343 | 3562 | return obj; |
---|
.. | .. |
---|
3392 | 3611 | return null; |
---|
3393 | 3612 | } |
---|
3394 | 3613 | |
---|
3395 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3396 | 3614 | |
---|
3397 | 3615 | public void Save() |
---|
3398 | 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 | + |
---|
3399 | 3643 | cRadio tab = GetCurrentTab(); |
---|
3400 | 3644 | |
---|
3401 | | - boolean temp = CameraPane.SWITCH; |
---|
3402 | | - CameraPane.SWITCH = false; |
---|
| 3645 | + byte[] compress = CompressCopy(); |
---|
3403 | 3646 | |
---|
3404 | | - 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 | + } |
---|
3405 | 3654 | |
---|
3406 | 3655 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3407 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3408 | | - |
---|
3409 | | - copy.RestoreBigData(hashtable); |
---|
3410 | | - |
---|
3411 | | - CameraPane.SWITCH = temp; |
---|
3412 | | - |
---|
3413 | | - //assert(hashtable.isEmpty()); |
---|
3414 | | - |
---|
3415 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + if (!thesame) |
---|
3416 | 3657 | { |
---|
3417 | | - 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++; |
---|
3418 | 3665 | } |
---|
3419 | 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 | + |
---|
3420 | 3679 | // test save |
---|
3421 | 3680 | if (false) |
---|
3422 | 3681 | { |
---|
3423 | 3682 | try |
---|
3424 | 3683 | { |
---|
3425 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3684 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3426 | 3685 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3427 | 3686 | |
---|
3428 | 3687 | p.writeObject(copy); |
---|
.. | .. |
---|
3435 | 3694 | e.printStackTrace(); |
---|
3436 | 3695 | } |
---|
3437 | 3696 | } |
---|
| 3697 | + |
---|
| 3698 | + return !thesame; |
---|
3438 | 3699 | } |
---|
3439 | 3700 | |
---|
3440 | 3701 | void CopyChanged(Object3D obj) |
---|
3441 | 3702 | { |
---|
| 3703 | + SetUndoStates(); |
---|
| 3704 | + |
---|
3442 | 3705 | boolean temp = CameraPane.SWITCH; |
---|
3443 | 3706 | CameraPane.SWITCH = false; |
---|
3444 | 3707 | |
---|
3445 | | - copy.ExtractBigData(hashtable); |
---|
| 3708 | + copy.ExtractBigData(versiontable); |
---|
3446 | 3709 | |
---|
3447 | 3710 | copy.clear(); |
---|
3448 | 3711 | |
---|
.. | .. |
---|
3451 | 3714 | copy.add(obj.get(i)); |
---|
3452 | 3715 | } |
---|
3453 | 3716 | |
---|
3454 | | - copy.RestoreBigData(hashtable); |
---|
| 3717 | + copy.RestoreBigData(versiontable); |
---|
3455 | 3718 | |
---|
3456 | 3719 | CameraPane.SWITCH = temp; |
---|
3457 | 3720 | |
---|
.. | .. |
---|
3478 | 3741 | refreshContents(); |
---|
3479 | 3742 | } |
---|
3480 | 3743 | |
---|
3481 | | - 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() |
---|
3482 | 3765 | { |
---|
3483 | 3766 | cRadio tab = GetCurrentTab(); |
---|
3484 | 3767 | |
---|
3485 | | - 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) |
---|
3486 | 3790 | { |
---|
3487 | 3791 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3488 | | - return; |
---|
| 3792 | + return false; |
---|
3489 | 3793 | } |
---|
3490 | 3794 | |
---|
3491 | | - 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) |
---|
3492 | 3822 | { |
---|
3493 | | - Save(); |
---|
3494 | | - tab.undoindex -= 1; |
---|
| 3823 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3824 | + return false; |
---|
3495 | 3825 | } |
---|
3496 | 3826 | |
---|
3497 | | - tab.undoindex -= 1; |
---|
| 3827 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3828 | + |
---|
| 3829 | + return true; |
---|
| 3830 | + } |
---|
3498 | 3831 | |
---|
3499 | | - 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; |
---|
3500 | 3847 | } |
---|
3501 | 3848 | |
---|
3502 | 3849 | public void Redo() |
---|
3503 | 3850 | { |
---|
| 3851 | + // Option? |
---|
| 3852 | + Replace(); |
---|
| 3853 | + |
---|
3504 | 3854 | cRadio tab = GetCurrentTab(); |
---|
3505 | 3855 | |
---|
3506 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3856 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3507 | 3857 | { |
---|
3508 | 3858 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3509 | 3859 | return; |
---|
3510 | 3860 | } |
---|
3511 | 3861 | |
---|
3512 | | - tab.undoindex += 1; |
---|
| 3862 | + copy.versionindex += 1; |
---|
3513 | 3863 | |
---|
3514 | | - 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; |
---|
3515 | 3868 | } |
---|
3516 | 3869 | |
---|
3517 | 3870 | void ImportGFD() |
---|
.. | .. |
---|
3663 | 4016 | assert false; |
---|
3664 | 4017 | } |
---|
3665 | 4018 | |
---|
3666 | | - void EditSelection() |
---|
| 4019 | + void EditSelection(boolean newWindow) |
---|
3667 | 4020 | { |
---|
3668 | 4021 | } |
---|
3669 | 4022 | |
---|
.. | .. |
---|
3807 | 4160 | //copy.Touch(); |
---|
3808 | 4161 | } |
---|
3809 | 4162 | |
---|
| 4163 | + cNumberSlider versionSlider; |
---|
| 4164 | + |
---|
3810 | 4165 | public void stateChanged(ChangeEvent e) |
---|
3811 | 4166 | { |
---|
3812 | 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 | + } |
---|
3813 | 4182 | |
---|
3814 | 4183 | if (freezematerial) |
---|
3815 | 4184 | { |
---|
.. | .. |
---|
4158 | 4527 | |
---|
4159 | 4528 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4160 | 4529 | { |
---|
4161 | | - Save(); |
---|
| 4530 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
| 4531 | + Save(); |
---|
4162 | 4532 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4163 | 4533 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4164 | 4534 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4245 | 4615 | { |
---|
4246 | 4616 | ResetModel(); |
---|
4247 | 4617 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4618 | + |
---|
| 4619 | + if (thing.Size() == 0) |
---|
| 4620 | + { |
---|
| 4621 | + //EditSelection(false); |
---|
| 4622 | + } |
---|
| 4623 | + |
---|
4248 | 4624 | refreshContents(); |
---|
4249 | 4625 | } |
---|
4250 | 4626 | |
---|
.. | .. |
---|
4393 | 4769 | readobj.ResetDisplayList(); |
---|
4394 | 4770 | } catch (Exception e) |
---|
4395 | 4771 | { |
---|
4396 | | - //e.printStackTrace(); |
---|
| 4772 | + e.printStackTrace(); |
---|
4397 | 4773 | try |
---|
4398 | 4774 | { |
---|
4399 | 4775 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
.. | .. |
---|
4467 | 4843 | |
---|
4468 | 4844 | if (readobj != null) |
---|
4469 | 4845 | { |
---|
4470 | | - Save(); |
---|
| 4846 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4847 | + // Save(); |
---|
4471 | 4848 | try |
---|
4472 | 4849 | { |
---|
4473 | 4850 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4522 | 4899 | c.addChild(csg); |
---|
4523 | 4900 | } |
---|
4524 | 4901 | |
---|
| 4902 | + copy.versions = readobj.versions; |
---|
| 4903 | + copy.versionindex = readobj.versionindex; |
---|
| 4904 | + |
---|
| 4905 | + if (copy.versions == null) |
---|
| 4906 | + { |
---|
| 4907 | + copy.versions = new byte[100][]; |
---|
| 4908 | + copy.versionindex = -1; |
---|
| 4909 | + } |
---|
| 4910 | + |
---|
| 4911 | + //? SetUndoStates(); |
---|
| 4912 | + |
---|
4525 | 4913 | ResetModel(); |
---|
4526 | 4914 | copy.HardTouch(); // recompile? |
---|
4527 | 4915 | refreshContents(); |
---|
4528 | 4916 | } |
---|
4529 | 4917 | } |
---|
4530 | 4918 | |
---|
4531 | | - void load() // throws ClassNotFoundException |
---|
| 4919 | + void Open() // throws ClassNotFoundException |
---|
4532 | 4920 | { |
---|
4533 | 4921 | if (Grafreed.standAlone) |
---|
4534 | 4922 | { |
---|
.. | .. |
---|
4645 | 5033 | String filename = browser.getFile(); |
---|
4646 | 5034 | if (filename != null && filename.length() > 0) |
---|
4647 | 5035 | { |
---|
| 5036 | + if (!filename.endsWith(".gfd")) |
---|
| 5037 | + filename += ".gfd"; |
---|
4648 | 5038 | lastname = browser.getDirectory() + filename; |
---|
4649 | 5039 | save(); |
---|
4650 | 5040 | } |
---|
.. | .. |
---|
4811 | 5201 | MenuBar menuBar; |
---|
4812 | 5202 | Menu fileMenu; |
---|
4813 | 5203 | MenuItem newItem; |
---|
4814 | | - MenuItem loadItem; |
---|
| 5204 | + MenuItem openItem; |
---|
4815 | 5205 | MenuItem saveItem; |
---|
4816 | 5206 | MenuItem saveAsItem; |
---|
4817 | 5207 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4834 | 5224 | CheckboxMenuItem toggleSwitchItem; |
---|
4835 | 5225 | CheckboxMenuItem toggleRootItem; |
---|
4836 | 5226 | CheckboxMenuItem animationItem; |
---|
| 5227 | + MenuItem archiveItem; |
---|
4837 | 5228 | CheckboxMenuItem toggleHandleItem; |
---|
4838 | 5229 | CheckboxMenuItem togglePaintItem; |
---|
4839 | 5230 | JSplitPane mainPanel; |
---|
4840 | 5231 | JScrollPane scrollpane; |
---|
| 5232 | + |
---|
4841 | 5233 | JPanel toolbarPanel; |
---|
| 5234 | + |
---|
4842 | 5235 | cGridBag treePanel; |
---|
| 5236 | + |
---|
4843 | 5237 | JPanel radioPanel; |
---|
4844 | 5238 | ButtonGroup buttonGroup; |
---|
4845 | | - cGridBag ctrlPanel; |
---|
| 5239 | + |
---|
| 5240 | + cGridBag toolboxPanel; |
---|
4846 | 5241 | cGridBag materialPanel; |
---|
| 5242 | + cGridBag ctrlPanel; |
---|
| 5243 | + |
---|
4847 | 5244 | JScrollPane infoPanel; |
---|
| 5245 | + |
---|
4848 | 5246 | cGridBag optionsPanel; |
---|
| 5247 | + |
---|
4849 | 5248 | JTabbedPane objectPanel; |
---|
| 5249 | + boolean materialFlushed; |
---|
| 5250 | + Object3D latestObject; |
---|
| 5251 | + |
---|
4850 | 5252 | cGridBag XYZPanel; |
---|
| 5253 | + |
---|
4851 | 5254 | JSplitPane gridPanel; |
---|
4852 | 5255 | JSplitPane bigPanel; |
---|
| 5256 | + |
---|
4853 | 5257 | cGridBag bigThree; |
---|
4854 | 5258 | cGridBag scenePanel; |
---|
4855 | 5259 | cGridBag centralPanel; |
---|
.. | .. |
---|
4964 | 5368 | cNumberSlider fogField; |
---|
4965 | 5369 | JLabel opacityPowerLabel; |
---|
4966 | 5370 | cNumberSlider opacityPowerField; |
---|
4967 | | - JTree jTree; |
---|
| 5371 | + cTree jTree; |
---|
4968 | 5372 | //ObjectUI parent; |
---|
4969 | 5373 | |
---|
4970 | 5374 | cNumberSlider normalpushField; |
---|