.. | .. |
---|
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.*; |
---|
.. | .. |
---|
35 | 36 | |
---|
36 | 37 | GroupEditor callee; |
---|
37 | 38 | JFrame frame; |
---|
| 39 | + |
---|
| 40 | + static ObjEditor theFrame; |
---|
| 41 | + |
---|
| 42 | + cButton GetButton(String name, boolean border) |
---|
| 43 | + { |
---|
| 44 | + try |
---|
| 45 | + { |
---|
| 46 | + ImageIcon icon = GetIcon(name); |
---|
| 47 | + return new cButton(icon, border); |
---|
| 48 | + } |
---|
| 49 | + catch (Exception e) |
---|
| 50 | + { |
---|
| 51 | + return new cButton(name, border); |
---|
| 52 | + } |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 56 | + { |
---|
| 57 | + try |
---|
| 58 | + { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cToggleButton(icon, border); |
---|
| 61 | + } |
---|
| 62 | + catch (Exception e) |
---|
| 63 | + { |
---|
| 64 | + return new cToggleButton(name, border); |
---|
| 65 | + } |
---|
| 66 | + } |
---|
| 67 | + |
---|
| 68 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 69 | + { |
---|
| 70 | + try |
---|
| 71 | + { |
---|
| 72 | + ImageIcon icon = GetIcon(name); |
---|
| 73 | + return new cCheckBox(icon, border); |
---|
| 74 | + } |
---|
| 75 | + catch (Exception e) |
---|
| 76 | + { |
---|
| 77 | + return new cCheckBox(name, border); |
---|
| 78 | + } |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 82 | + { |
---|
| 83 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 84 | + |
---|
| 85 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 86 | + { |
---|
| 87 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 88 | + Graphics2D g = resized.createGraphics(); |
---|
| 89 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 90 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 91 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 92 | + g.dispose(); |
---|
| 93 | + |
---|
| 94 | + image = resized; |
---|
| 95 | + } |
---|
| 96 | + |
---|
| 97 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 98 | + return icon; |
---|
| 99 | + } |
---|
38 | 100 | |
---|
39 | 101 | // SCRIPT |
---|
40 | 102 | |
---|
.. | .. |
---|
168 | 230 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 231 | |
---|
170 | 232 | objEditor.ctrlPanel.remove(setupPanel); |
---|
171 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 233 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
| 234 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
172 | 235 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 236 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
174 | 237 | |
---|
.. | .. |
---|
243 | 306 | //localCopy.parent = null; |
---|
244 | 307 | |
---|
245 | 308 | frame = new JFrame(); |
---|
| 309 | + frame.setUndecorated(true); |
---|
246 | 310 | objEditor = this; |
---|
247 | 311 | this.callee = callee; |
---|
248 | 312 | |
---|
.. | .. |
---|
278 | 342 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 343 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 344 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 345 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 346 | |
---|
283 | 347 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 348 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
319 | 383 | closeItem.addActionListener(this); |
---|
320 | 384 | |
---|
321 | 385 | objectPanel = new JTabbedPane(); |
---|
| 386 | + |
---|
| 387 | + ChangeListener changeListener = new ChangeListener() |
---|
| 388 | + { |
---|
| 389 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 390 | + { |
---|
| 391 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 392 | +// { |
---|
| 393 | +// if (latestObject != null) |
---|
| 394 | +// { |
---|
| 395 | +// refreshContents(true); |
---|
| 396 | +// SetMaterial(latestObject); |
---|
| 397 | +// } |
---|
| 398 | +// |
---|
| 399 | +// materialFlushed = true; |
---|
| 400 | +// } |
---|
| 401 | + |
---|
| 402 | + refreshContents(false); // To refresh Info tab |
---|
| 403 | + } |
---|
| 404 | + }; |
---|
| 405 | + objectPanel.addChangeListener(changeListener); |
---|
| 406 | + |
---|
322 | 407 | toolbarPanel = new JPanel(); |
---|
323 | 408 | toolbarPanel.setName("Toolbar"); |
---|
324 | 409 | treePanel = new cGridBag(); |
---|
325 | 410 | treePanel.setName("Tree"); |
---|
| 411 | + |
---|
| 412 | + editPanel = new cGridBag().setVertical(true); |
---|
| 413 | + editPanel.setName("Edit"); |
---|
| 414 | + |
---|
326 | 415 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
327 | | - ctrlPanel.setName("Edit"); |
---|
| 416 | + |
---|
| 417 | + editCommandsPanel = new cGridBag(); |
---|
| 418 | + editPanel.add(editCommandsPanel); |
---|
| 419 | + editPanel.add(ctrlPanel); |
---|
| 420 | + |
---|
| 421 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 422 | + toolboxPanel.setName("Toolbox"); |
---|
| 423 | + |
---|
328 | 424 | materialPanel = new cGridBag().setVertical(true); |
---|
329 | 425 | materialPanel.setName("Material"); |
---|
| 426 | + |
---|
330 | 427 | /*JTextPane*/ |
---|
331 | 428 | infoarea = createTextPane(); |
---|
332 | 429 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
419 | 516 | e.printStackTrace(); |
---|
420 | 517 | } |
---|
421 | 518 | |
---|
422 | | - String selection = infoarea.getText(); |
---|
423 | | - java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
424 | | - java.awt.datatransfer.Clipboard clipboard = |
---|
425 | | - Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 519 | +// String selection = infoarea.getText(); |
---|
| 520 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 521 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 522 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 523 | //clipboard.setContents(data, data); |
---|
427 | 524 | } |
---|
428 | 525 | |
---|
.. | .. |
---|
582 | 679 | } |
---|
583 | 680 | } |
---|
584 | 681 | |
---|
| 682 | +static GraphicsDevice device = GraphicsEnvironment |
---|
| 683 | + .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 684 | + |
---|
| 685 | + Rectangle keeprect; |
---|
| 686 | + cRadio radio; |
---|
| 687 | + |
---|
| 688 | +cButton keepButton; |
---|
| 689 | + cButton twoButton; // Full 3D |
---|
| 690 | + cButton sixButton; |
---|
| 691 | + cButton threeButton; |
---|
| 692 | + cButton sevenButton; |
---|
| 693 | + cButton fourButton; // full panel |
---|
| 694 | + cButton oneButton; // full XYZ |
---|
| 695 | + //cButton currentLayout; |
---|
| 696 | + |
---|
| 697 | + boolean maximized; |
---|
| 698 | + |
---|
| 699 | + cButton fullscreenLayout; |
---|
| 700 | + |
---|
| 701 | + void Minimize() |
---|
| 702 | + { |
---|
| 703 | + frame.setState(Frame.ICONIFIED); |
---|
| 704 | + } |
---|
| 705 | + |
---|
| 706 | + void Maximize() |
---|
| 707 | + { |
---|
| 708 | + if (maximized) |
---|
| 709 | + { |
---|
| 710 | + frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 711 | + } |
---|
| 712 | + else |
---|
| 713 | + { |
---|
| 714 | + keeprect = frame.getBounds(); |
---|
| 715 | + Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 716 | + Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 717 | + frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 718 | +// frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 719 | + } |
---|
| 720 | + |
---|
| 721 | + maximized ^= true; |
---|
| 722 | + } |
---|
| 723 | + |
---|
585 | 724 | void ToggleFullScreen() |
---|
586 | 725 | { |
---|
587 | | - if (CameraPane.FULLSCREEN) |
---|
| 726 | + cameraView.ToggleFullScreen(); |
---|
| 727 | + |
---|
| 728 | + if (!CameraPane.FULLSCREEN) |
---|
588 | 729 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 730 | + device.setFullScreenWindow(null); |
---|
| 731 | + //frame.setVisible(false); |
---|
| 732 | +// frame.removeNotify(); |
---|
| 733 | +// frame.setUndecorated(false); |
---|
| 734 | +// frame.addNotify(); |
---|
| 735 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 736 | + |
---|
| 737 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 738 | +// X framePanel.add(bigThree); |
---|
| 739 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 740 | + framePanel.setDividerLocation(1); |
---|
| 741 | + |
---|
| 742 | + //frame.setVisible(true); |
---|
| 743 | + radio.layout = keepButton; |
---|
| 744 | + //theFrame = null; |
---|
| 745 | + keepButton = null; |
---|
| 746 | + radio.layout.doClick(); |
---|
| 747 | + |
---|
592 | 748 | } else |
---|
593 | 749 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 750 | + keepButton = radio.layout; |
---|
| 751 | + //keeprect = frame.getBounds(); |
---|
| 752 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 753 | +// frame.getToolkit().getScreenSize().height); |
---|
| 754 | + //frame.setVisible(false); |
---|
| 755 | + device.setFullScreenWindow(frame); |
---|
| 756 | +// frame.removeNotify(); |
---|
| 757 | +// frame.setUndecorated(true); |
---|
| 758 | +// frame.addNotify(); |
---|
| 759 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 760 | +// X framePanel.remove(bigThree); |
---|
| 761 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 762 | + framePanel.setDividerLocation(0); |
---|
| 763 | + |
---|
| 764 | + radio.layout = fullscreenLayout; |
---|
| 765 | + radio.layout.doClick(); |
---|
| 766 | + //frame.setVisible(true); |
---|
597 | 767 | } |
---|
598 | | - cameraView.ToggleFullScreen(); |
---|
599 | 768 | } |
---|
600 | 769 | |
---|
601 | 770 | private JTextPane createTextPane() |
---|
.. | .. |
---|
736 | 905 | JCheckBox speedupCB; |
---|
737 | 906 | JCheckBox rewindCB; |
---|
738 | 907 | JCheckBox flipVCB; |
---|
| 908 | + |
---|
| 909 | + cCheckBox toggleTextureCB; |
---|
| 910 | + cCheckBox toggleSwitchCB; |
---|
| 911 | + |
---|
739 | 912 | JComboBox texresMenu; |
---|
| 913 | + |
---|
740 | 914 | JButton resetButton; |
---|
741 | 915 | JButton stepButton; |
---|
742 | 916 | JButton stepAllButton; |
---|
.. | .. |
---|
745 | 919 | JButton fasterButton; |
---|
746 | 920 | JButton remarkButton; |
---|
747 | 921 | |
---|
| 922 | + cGridBag editPanel; |
---|
| 923 | + cGridBag editCommandsPanel; |
---|
| 924 | + |
---|
748 | 925 | cGridBag namePanel; |
---|
749 | 926 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 927 | + cGridBag setupPanel2; |
---|
| 928 | + cGridBag objectCommandsPanel; |
---|
751 | 929 | cGridBag pushPanel; |
---|
752 | 930 | cGridBag fillPanel; |
---|
753 | 931 | |
---|
.. | .. |
---|
939 | 1117 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | 1118 | markCB.setToolTipText("Set the animation target transform"); |
---|
941 | 1119 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1120 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1121 | + |
---|
| 1122 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1123 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1124 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1125 | + randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1126 | + randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
947 | 1127 | |
---|
948 | 1128 | if (Globals.ADVANCED) |
---|
949 | 1129 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
| 1130 | + link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
951 | 1131 | link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1132 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1133 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1134 | } |
---|
955 | 1135 | |
---|
956 | 1136 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1137 | oe.ctrlPanel.Return(); |
---|
| 1138 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1139 | + oe.ctrlPanel.Return(); |
---|
958 | 1140 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1141 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1142 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1143 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1144 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1145 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1146 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1147 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1148 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1149 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1150 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1151 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1152 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1153 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1154 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1155 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1156 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1157 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1158 | oe.ctrlPanel.Return(); |
---|
977 | 1159 | |
---|
978 | 1160 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1360 | //worldPanel.setName("World"); |
---|
1179 | 1361 | centralPanel = new cGridBag(); |
---|
1180 | 1362 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1363 | + |
---|
| 1364 | + if (Globals.ADVANCED) |
---|
| 1365 | + { |
---|
| 1366 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1367 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1368 | |
---|
1184 | 1369 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1370 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1373 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1374 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1375 | |
---|
| 1376 | + } |
---|
| 1377 | + |
---|
1191 | 1378 | centralPanel.add(cameraView); |
---|
| 1379 | + centralPanel.setFocusable(true); |
---|
1192 | 1380 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1381 | //centralPanel.add(timelinePanel); |
---|
1194 | 1382 | |
---|
.. | .. |
---|
1251 | 1439 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1252 | 1440 | //tmp.setName("Edit"); |
---|
1253 | 1441 | objectPanel.add(materialPanel); |
---|
| 1442 | + objectPanel.add(toolboxPanel); |
---|
1254 | 1443 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1255 | 1444 | // north.setName("Edit"); |
---|
1256 | 1445 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1446 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
| 1447 | + objectPanel.add(editPanel); |
---|
1259 | 1448 | objectPanel.add(infoPanel); |
---|
1260 | 1449 | |
---|
1261 | 1450 | /* |
---|
.. | .. |
---|
1282 | 1471 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1283 | 1472 | tabbedPane.add(scrollpane); |
---|
1284 | 1473 | |
---|
1285 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1286 | | - |
---|
1287 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1474 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1288 | 1475 | |
---|
1289 | 1476 | optionsPanel.setName("Options"); |
---|
1290 | 1477 | |
---|
.. | .. |
---|
1292 | 1479 | |
---|
1293 | 1480 | tabbedPane.add(optionsPanel); |
---|
1294 | 1481 | |
---|
| 1482 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1483 | + |
---|
1295 | 1484 | scenePanel.add(tabbedPane); |
---|
1296 | 1485 | |
---|
1297 | 1486 | /* |
---|
.. | .. |
---|
1384 | 1573 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1385 | 1574 | |
---|
1386 | 1575 | frame.setSize(1280, 860); |
---|
| 1576 | + |
---|
| 1577 | + frame.validate(); |
---|
1387 | 1578 | frame.setVisible(true); |
---|
1388 | 1579 | |
---|
| 1580 | + cameraView.requestFocusInWindow(); |
---|
| 1581 | + |
---|
1389 | 1582 | gridPanel.setDividerLocation(1.0); |
---|
1390 | 1583 | |
---|
1391 | 1584 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
.. | .. |
---|
1935 | 2128 | e2.printStackTrace(); |
---|
1936 | 2129 | } |
---|
1937 | 2130 | } |
---|
| 2131 | + |
---|
1938 | 2132 | LoadJMEThread loadThread; |
---|
1939 | 2133 | |
---|
1940 | 2134 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 2186 | //LoadFile0(filename, converter); |
---|
1993 | 2187 | } |
---|
1994 | 2188 | } |
---|
| 2189 | + |
---|
1995 | 2190 | LoadOBJThread loadObjThread; |
---|
1996 | 2191 | |
---|
1997 | 2192 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
2070 | 2265 | |
---|
2071 | 2266 | void LoadObjFile(String fullname) |
---|
2072 | 2267 | { |
---|
2073 | | - /* |
---|
| 2268 | + System.out.println("Loading " + fullname); |
---|
| 2269 | + /**/ |
---|
2074 | 2270 | //lastFilename = fullname; |
---|
2075 | 2271 | if(loadObjThread == null) |
---|
2076 | 2272 | { |
---|
2077 | | - loadObjThread = new LoadOBJThread(); |
---|
2078 | | - loadObjThread.start(); |
---|
| 2273 | + loadObjThread = new LoadOBJThread(); |
---|
| 2274 | + loadObjThread.start(); |
---|
2079 | 2275 | } |
---|
2080 | 2276 | |
---|
2081 | 2277 | loadObjThread.add(fullname); |
---|
2082 | | - */ |
---|
| 2278 | + /**/ |
---|
2083 | 2279 | |
---|
2084 | | - System.out.println("Loading " + fullname); |
---|
2085 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2280 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2086 | 2281 | } |
---|
2087 | 2282 | |
---|
2088 | 2283 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2699 | 2894 | |
---|
2700 | 2895 | void SetMaterial(Object3D object) |
---|
2701 | 2896 | { |
---|
| 2897 | + latestObject = object; |
---|
| 2898 | + |
---|
2702 | 2899 | cMaterial mat = object.material; |
---|
2703 | 2900 | |
---|
2704 | 2901 | if (mat == null) |
---|
.. | .. |
---|
2884 | 3081 | cameraView.ToggleDL(); |
---|
2885 | 3082 | cameraView.repaint(); |
---|
2886 | 3083 | return; |
---|
2887 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3084 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2888 | 3085 | { |
---|
2889 | 3086 | cameraView.ToggleTexture(); |
---|
2890 | 3087 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
2923 | 3120 | frame.validate(); |
---|
2924 | 3121 | |
---|
2925 | 3122 | return; |
---|
2926 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3123 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
2927 | 3124 | { |
---|
2928 | | - cameraView.ToggleRandom(); |
---|
| 3125 | + cameraView.ToggleSwitch(); |
---|
2929 | 3126 | cameraView.repaint(); |
---|
2930 | 3127 | return; |
---|
2931 | 3128 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3212 | 3409 | objEditor.refreshContents(); |
---|
3213 | 3410 | } |
---|
3214 | 3411 | |
---|
3215 | | - Object3D graphs[] = new Object3D[10000]; |
---|
3216 | | - int undoindex = 0; |
---|
3217 | | - |
---|
3218 | | - static public Object clone(Object o) |
---|
| 3412 | + static public byte[] Compress(Object3D o) |
---|
3219 | 3413 | { |
---|
3220 | 3414 | try |
---|
3221 | 3415 | { |
---|
3222 | 3416 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3417 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3418 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
3224 | 3419 | |
---|
| 3420 | + Object3D parent = o.parent; |
---|
| 3421 | + o.parent = null; |
---|
| 3422 | + |
---|
3225 | 3423 | out.writeObject(o); |
---|
| 3424 | + |
---|
| 3425 | + o.parent = parent; |
---|
| 3426 | + |
---|
| 3427 | + out.flush(); |
---|
3226 | 3428 | |
---|
3227 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
3228 | | - ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3429 | + zstream.close(); |
---|
| 3430 | + out.close(); |
---|
| 3431 | + |
---|
| 3432 | + return baos.toByteArray(); |
---|
| 3433 | + } catch (Exception e) |
---|
| 3434 | + { |
---|
| 3435 | + System.err.println(e); |
---|
| 3436 | + return null; |
---|
| 3437 | + } |
---|
| 3438 | + } |
---|
| 3439 | + |
---|
| 3440 | + static public Object Uncompress(byte[] bytes) |
---|
| 3441 | + { |
---|
| 3442 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3443 | + try |
---|
| 3444 | + { |
---|
| 3445 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3446 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3447 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
3229 | 3448 | Object obj = in.readObject(); |
---|
3230 | 3449 | in.close(); |
---|
3231 | | - out.close(); |
---|
| 3450 | + |
---|
3232 | 3451 | return obj; |
---|
3233 | 3452 | } catch (Exception e) |
---|
3234 | 3453 | { |
---|
.. | .. |
---|
3237 | 3456 | } |
---|
3238 | 3457 | } |
---|
3239 | 3458 | |
---|
| 3459 | + static public Object clone(Object o) |
---|
| 3460 | + { |
---|
| 3461 | + try |
---|
| 3462 | + { |
---|
| 3463 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3464 | + ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3465 | + |
---|
| 3466 | + out.writeObject(o); |
---|
| 3467 | + |
---|
| 3468 | + out.flush(); |
---|
| 3469 | + out.close(); |
---|
| 3470 | + |
---|
| 3471 | + byte[] bytes = baos.toByteArray(); |
---|
| 3472 | + |
---|
| 3473 | + System.out.println("clone = " + bytes.length); |
---|
| 3474 | + |
---|
| 3475 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3476 | + ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3477 | + Object obj = in.readObject(); |
---|
| 3478 | + in.close(); |
---|
| 3479 | + |
---|
| 3480 | + return obj; |
---|
| 3481 | + } catch (Exception e) |
---|
| 3482 | + { |
---|
| 3483 | + System.err.println(e); |
---|
| 3484 | + return null; |
---|
| 3485 | + } |
---|
| 3486 | + } |
---|
| 3487 | + |
---|
| 3488 | + cRadio GetCurrentTab() |
---|
| 3489 | + { |
---|
| 3490 | + cRadio ab; |
---|
| 3491 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3492 | + { |
---|
| 3493 | + ab = (cRadio)e.nextElement(); |
---|
| 3494 | + if(ab.GetObject() == copy) |
---|
| 3495 | + { |
---|
| 3496 | + return ab; |
---|
| 3497 | + } |
---|
| 3498 | + } |
---|
| 3499 | + |
---|
| 3500 | + return null; |
---|
| 3501 | + } |
---|
| 3502 | + |
---|
| 3503 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3504 | + |
---|
3240 | 3505 | public void Save() |
---|
3241 | 3506 | { |
---|
3242 | | - if (true) return; |
---|
| 3507 | + System.err.println("Save"); |
---|
| 3508 | + |
---|
| 3509 | + cRadio tab = GetCurrentTab(); |
---|
| 3510 | + |
---|
| 3511 | + boolean temp = CameraPane.SWITCH; |
---|
| 3512 | + CameraPane.SWITCH = false; |
---|
| 3513 | + |
---|
| 3514 | + copy.ExtractBigData(hashtable); |
---|
3243 | 3515 | |
---|
3244 | 3516 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3245 | | - graphs[undoindex++] = (Object3D)clone(copy); |
---|
| 3517 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3246 | 3518 | |
---|
3247 | | - for (int i = undoindex; i < graphs.length; i++) |
---|
| 3519 | + copy.RestoreBigData(hashtable); |
---|
| 3520 | + |
---|
| 3521 | + CameraPane.SWITCH = temp; |
---|
| 3522 | + |
---|
| 3523 | + //assert(hashtable.isEmpty()); |
---|
| 3524 | + |
---|
| 3525 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3248 | 3526 | { |
---|
3249 | | - graphs[i] = null; |
---|
| 3527 | + tab.graphs[i] = null; |
---|
3250 | 3528 | } |
---|
3251 | 3529 | |
---|
3252 | 3530 | // test save |
---|
.. | .. |
---|
3254 | 3532 | { |
---|
3255 | 3533 | try |
---|
3256 | 3534 | { |
---|
3257 | | - FileOutputStream ostream = new FileOutputStream("save" + undoindex); |
---|
| 3535 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
3258 | 3536 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3259 | 3537 | |
---|
3260 | 3538 | p.writeObject(copy); |
---|
.. | .. |
---|
3269 | 3547 | } |
---|
3270 | 3548 | } |
---|
3271 | 3549 | |
---|
| 3550 | + void CopyChanged(Object3D obj) |
---|
| 3551 | + { |
---|
| 3552 | + boolean temp = CameraPane.SWITCH; |
---|
| 3553 | + CameraPane.SWITCH = false; |
---|
| 3554 | + |
---|
| 3555 | + copy.ExtractBigData(hashtable); |
---|
| 3556 | + |
---|
| 3557 | + copy.clear(); |
---|
| 3558 | + |
---|
| 3559 | + for (int i=0; i<obj.Size(); i++) |
---|
| 3560 | + { |
---|
| 3561 | + copy.add(obj.get(i)); |
---|
| 3562 | + } |
---|
| 3563 | + |
---|
| 3564 | + copy.RestoreBigData(hashtable); |
---|
| 3565 | + |
---|
| 3566 | + CameraPane.SWITCH = temp; |
---|
| 3567 | + |
---|
| 3568 | + //assert(hashtable.isEmpty()); |
---|
| 3569 | + |
---|
| 3570 | + copy.Touch(); |
---|
| 3571 | + |
---|
| 3572 | + ResetModel(); |
---|
| 3573 | + copy.HardTouch(); // recompile? |
---|
| 3574 | + |
---|
| 3575 | + cRadio ab; |
---|
| 3576 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3577 | + { |
---|
| 3578 | + ab = (cRadio)e.nextElement(); |
---|
| 3579 | + Object3D test = copy.GetObject(ab.object.GetUUID()); |
---|
| 3580 | + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); |
---|
| 3581 | + if (test != null) |
---|
| 3582 | + { |
---|
| 3583 | + test.editWindow = ab.object.editWindow; |
---|
| 3584 | + ab.object = test; |
---|
| 3585 | + } |
---|
| 3586 | + } |
---|
| 3587 | + |
---|
| 3588 | + refreshContents(); |
---|
| 3589 | + } |
---|
| 3590 | + |
---|
3272 | 3591 | public void Undo() |
---|
3273 | 3592 | { |
---|
3274 | | - if (undoindex == 0) |
---|
| 3593 | + System.err.println("Undo"); |
---|
| 3594 | + |
---|
| 3595 | + cRadio tab = GetCurrentTab(); |
---|
| 3596 | + |
---|
| 3597 | + if (tab.undoindex == 0) |
---|
3275 | 3598 | { |
---|
3276 | 3599 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3277 | 3600 | return; |
---|
3278 | 3601 | } |
---|
3279 | 3602 | |
---|
3280 | | - if (graphs[undoindex] == null) |
---|
| 3603 | + if (tab.graphs[tab.undoindex] == null) |
---|
3281 | 3604 | { |
---|
3282 | 3605 | Save(); |
---|
3283 | | - undoindex -= 1; |
---|
| 3606 | + tab.undoindex -= 1; |
---|
3284 | 3607 | } |
---|
3285 | 3608 | |
---|
3286 | | - undoindex -= 1; |
---|
| 3609 | + tab.undoindex -= 1; |
---|
3287 | 3610 | |
---|
3288 | | - copy = graphs[undoindex]; |
---|
3289 | | - |
---|
3290 | | - cameraView.object = copy; |
---|
3291 | | - copy.Touch(); |
---|
3292 | | - |
---|
3293 | | - ResetModel(); |
---|
3294 | | - refreshContents(); |
---|
| 3611 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3295 | 3612 | } |
---|
3296 | 3613 | |
---|
3297 | 3614 | public void Redo() |
---|
3298 | 3615 | { |
---|
3299 | | - if (graphs[undoindex + 1] == null) |
---|
| 3616 | + cRadio tab = GetCurrentTab(); |
---|
| 3617 | + |
---|
| 3618 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
3300 | 3619 | { |
---|
3301 | 3620 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3302 | 3621 | return; |
---|
3303 | 3622 | } |
---|
3304 | 3623 | |
---|
3305 | | - undoindex += 1; |
---|
| 3624 | + tab.undoindex += 1; |
---|
3306 | 3625 | |
---|
3307 | | - copy = graphs[undoindex]; |
---|
3308 | | - |
---|
3309 | | - cameraView.object = copy; |
---|
3310 | | - copy.Touch(); |
---|
3311 | | - |
---|
3312 | | - ResetModel(); |
---|
3313 | | - refreshContents(); |
---|
| 3626 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3314 | 3627 | } |
---|
3315 | 3628 | |
---|
3316 | 3629 | void ImportGFD() |
---|
.. | .. |
---|
3462 | 3775 | assert false; |
---|
3463 | 3776 | } |
---|
3464 | 3777 | |
---|
3465 | | - void EditSelection() |
---|
| 3778 | + void EditSelection(boolean newWindow) |
---|
3466 | 3779 | { |
---|
3467 | 3780 | } |
---|
3468 | 3781 | |
---|
.. | .. |
---|
3957 | 4270 | |
---|
3958 | 4271 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3959 | 4272 | { |
---|
3960 | | - Save(); |
---|
| 4273 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4274 | + Save(); |
---|
3961 | 4275 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3962 | 4276 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3963 | 4277 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4044 | 4358 | { |
---|
4045 | 4359 | ResetModel(); |
---|
4046 | 4360 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4361 | + |
---|
| 4362 | + if (thing.Size() == 0) |
---|
| 4363 | + { |
---|
| 4364 | + //EditSelection(false); |
---|
| 4365 | + } |
---|
| 4366 | + |
---|
4047 | 4367 | refreshContents(); |
---|
4048 | 4368 | } |
---|
4049 | 4369 | |
---|
.. | .. |
---|
4181 | 4501 | |
---|
4182 | 4502 | try |
---|
4183 | 4503 | { |
---|
| 4504 | + // Try compressed version first. |
---|
4184 | 4505 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4185 | 4506 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4186 | 4507 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4250 | 4571 | |
---|
4251 | 4572 | void LoadIt(Object obj) |
---|
4252 | 4573 | { |
---|
| 4574 | + if (obj == null) |
---|
| 4575 | + { |
---|
| 4576 | + // Invalid file |
---|
| 4577 | + return; |
---|
| 4578 | + } |
---|
| 4579 | + |
---|
4253 | 4580 | System.out.println("Loaded " + obj); |
---|
4254 | 4581 | //new Exception().printStackTrace(); |
---|
4255 | 4582 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4259 | 4586 | |
---|
4260 | 4587 | if (readobj != null) |
---|
4261 | 4588 | { |
---|
| 4589 | + if (Globals.SAVEONMAKE) |
---|
| 4590 | + Save(); |
---|
4262 | 4591 | try |
---|
4263 | 4592 | { |
---|
4264 | 4593 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4629 | 4958 | CheckboxMenuItem togglePaintItem; |
---|
4630 | 4959 | JSplitPane mainPanel; |
---|
4631 | 4960 | JScrollPane scrollpane; |
---|
| 4961 | + |
---|
4632 | 4962 | JPanel toolbarPanel; |
---|
| 4963 | + |
---|
4633 | 4964 | cGridBag treePanel; |
---|
| 4965 | + |
---|
4634 | 4966 | JPanel radioPanel; |
---|
4635 | 4967 | ButtonGroup buttonGroup; |
---|
4636 | | - cGridBag ctrlPanel; |
---|
| 4968 | + |
---|
| 4969 | + cGridBag toolboxPanel; |
---|
4637 | 4970 | cGridBag materialPanel; |
---|
| 4971 | + cGridBag ctrlPanel; |
---|
| 4972 | + |
---|
4638 | 4973 | JScrollPane infoPanel; |
---|
| 4974 | + |
---|
4639 | 4975 | cGridBag optionsPanel; |
---|
| 4976 | + |
---|
4640 | 4977 | JTabbedPane objectPanel; |
---|
| 4978 | + boolean materialFlushed; |
---|
| 4979 | + Object3D latestObject; |
---|
| 4980 | + |
---|
4641 | 4981 | cGridBag XYZPanel; |
---|
| 4982 | + |
---|
4642 | 4983 | JSplitPane gridPanel; |
---|
4643 | 4984 | JSplitPane bigPanel; |
---|
| 4985 | + |
---|
4644 | 4986 | cGridBag bigThree; |
---|
4645 | 4987 | cGridBag scenePanel; |
---|
4646 | 4988 | cGridBag centralPanel; |
---|
.. | .. |
---|
4755 | 5097 | cNumberSlider fogField; |
---|
4756 | 5098 | JLabel opacityPowerLabel; |
---|
4757 | 5099 | cNumberSlider opacityPowerField; |
---|
4758 | | - JTree jTree; |
---|
| 5100 | + cTree jTree; |
---|
4759 | 5101 | //ObjectUI parent; |
---|
4760 | 5102 | |
---|
4761 | 5103 | cNumberSlider normalpushField; |
---|