.. | .. |
---|
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 | 726 | if (CameraPane.FULLSCREEN) |
---|
588 | 727 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 728 | + device.setFullScreenWindow(null); |
---|
| 729 | + //frame.setVisible(false); |
---|
| 730 | +// frame.removeNotify(); |
---|
| 731 | +// frame.setUndecorated(false); |
---|
| 732 | +// frame.addNotify(); |
---|
| 733 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 734 | + |
---|
| 735 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 736 | +// X framePanel.add(bigThree); |
---|
| 737 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 738 | + framePanel.setDividerLocation(1); |
---|
| 739 | + |
---|
| 740 | + //frame.setVisible(true); |
---|
| 741 | + radio.layout = keepButton; |
---|
| 742 | + //theFrame = null; |
---|
| 743 | + keepButton = null; |
---|
| 744 | + radio.layout.doClick(); |
---|
| 745 | + |
---|
592 | 746 | } else |
---|
593 | 747 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 748 | + keepButton = radio.layout; |
---|
| 749 | + //keeprect = frame.getBounds(); |
---|
| 750 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 751 | +// frame.getToolkit().getScreenSize().height); |
---|
| 752 | + //frame.setVisible(false); |
---|
| 753 | + device.setFullScreenWindow(frame); |
---|
| 754 | +// frame.removeNotify(); |
---|
| 755 | +// frame.setUndecorated(true); |
---|
| 756 | +// frame.addNotify(); |
---|
| 757 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 758 | +// X framePanel.remove(bigThree); |
---|
| 759 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 760 | + framePanel.setDividerLocation(0); |
---|
| 761 | + |
---|
| 762 | + radio.layout = fullscreenLayout; |
---|
| 763 | + radio.layout.doClick(); |
---|
| 764 | + //frame.setVisible(true); |
---|
597 | 765 | } |
---|
| 766 | + |
---|
598 | 767 | cameraView.ToggleFullScreen(); |
---|
599 | 768 | } |
---|
600 | 769 | |
---|
.. | .. |
---|
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) |
---|
.. | .. |
---|
3207 | 3404 | { |
---|
3208 | 3405 | copy.remove(1); |
---|
3209 | 3406 | } |
---|
| 3407 | + |
---|
3210 | 3408 | ResetModel(); |
---|
3211 | 3409 | objEditor.refreshContents(); |
---|
3212 | 3410 | } |
---|
3213 | 3411 | |
---|
| 3412 | + static public byte[] Compress(Object3D o) |
---|
| 3413 | + { |
---|
| 3414 | + try |
---|
| 3415 | + { |
---|
| 3416 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3417 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3418 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3419 | + |
---|
| 3420 | + Object3D parent = o.parent; |
---|
| 3421 | + o.parent = null; |
---|
| 3422 | + |
---|
| 3423 | + out.writeObject(o); |
---|
| 3424 | + |
---|
| 3425 | + o.parent = parent; |
---|
| 3426 | + |
---|
| 3427 | + out.flush(); |
---|
| 3428 | + |
---|
| 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); |
---|
| 3448 | + Object obj = in.readObject(); |
---|
| 3449 | + in.close(); |
---|
| 3450 | + |
---|
| 3451 | + return obj; |
---|
| 3452 | + } catch (Exception e) |
---|
| 3453 | + { |
---|
| 3454 | + System.err.println(e); |
---|
| 3455 | + return null; |
---|
| 3456 | + } |
---|
| 3457 | + } |
---|
| 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 | + |
---|
| 3505 | + public void Save() |
---|
| 3506 | + { |
---|
| 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); |
---|
| 3515 | + |
---|
| 3516 | + //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
| 3517 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
| 3518 | + |
---|
| 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++) |
---|
| 3526 | + { |
---|
| 3527 | + tab.graphs[i] = null; |
---|
| 3528 | + } |
---|
| 3529 | + |
---|
| 3530 | + // test save |
---|
| 3531 | + if (false) |
---|
| 3532 | + { |
---|
| 3533 | + try |
---|
| 3534 | + { |
---|
| 3535 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3536 | + ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
| 3537 | + |
---|
| 3538 | + p.writeObject(copy); |
---|
| 3539 | + |
---|
| 3540 | + p.flush(); |
---|
| 3541 | + |
---|
| 3542 | + ostream.close(); |
---|
| 3543 | + } catch (Exception e) |
---|
| 3544 | + { |
---|
| 3545 | + e.printStackTrace(); |
---|
| 3546 | + } |
---|
| 3547 | + } |
---|
| 3548 | + } |
---|
| 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 | + |
---|
| 3591 | + public void Undo() |
---|
| 3592 | + { |
---|
| 3593 | + System.err.println("Undo"); |
---|
| 3594 | + |
---|
| 3595 | + cRadio tab = GetCurrentTab(); |
---|
| 3596 | + |
---|
| 3597 | + if (tab.undoindex == 0) |
---|
| 3598 | + { |
---|
| 3599 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3600 | + return; |
---|
| 3601 | + } |
---|
| 3602 | + |
---|
| 3603 | + if (tab.graphs[tab.undoindex] == null) |
---|
| 3604 | + { |
---|
| 3605 | + Save(); |
---|
| 3606 | + tab.undoindex -= 1; |
---|
| 3607 | + } |
---|
| 3608 | + |
---|
| 3609 | + tab.undoindex -= 1; |
---|
| 3610 | + |
---|
| 3611 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3612 | + } |
---|
| 3613 | + |
---|
| 3614 | + public void Redo() |
---|
| 3615 | + { |
---|
| 3616 | + cRadio tab = GetCurrentTab(); |
---|
| 3617 | + |
---|
| 3618 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3619 | + { |
---|
| 3620 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3621 | + return; |
---|
| 3622 | + } |
---|
| 3623 | + |
---|
| 3624 | + tab.undoindex += 1; |
---|
| 3625 | + |
---|
| 3626 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3627 | + } |
---|
| 3628 | + |
---|
3214 | 3629 | void ImportGFD() |
---|
3215 | 3630 | { |
---|
3216 | 3631 | FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); |
---|
.. | .. |
---|
3360 | 3775 | assert false; |
---|
3361 | 3776 | } |
---|
3362 | 3777 | |
---|
3363 | | - void EditSelection() |
---|
| 3778 | + void EditSelection(boolean newWindow) |
---|
3364 | 3779 | { |
---|
3365 | 3780 | } |
---|
3366 | 3781 | |
---|
.. | .. |
---|
3855 | 4270 | |
---|
3856 | 4271 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3857 | 4272 | { |
---|
| 4273 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4274 | + Save(); |
---|
3858 | 4275 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3859 | 4276 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3860 | 4277 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
3941 | 4358 | { |
---|
3942 | 4359 | ResetModel(); |
---|
3943 | 4360 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4361 | + |
---|
| 4362 | + if (thing.Size() == 0) |
---|
| 4363 | + { |
---|
| 4364 | + //EditSelection(false); |
---|
| 4365 | + } |
---|
| 4366 | + |
---|
3944 | 4367 | refreshContents(); |
---|
3945 | 4368 | } |
---|
3946 | 4369 | |
---|
.. | .. |
---|
4078 | 4501 | |
---|
4079 | 4502 | try |
---|
4080 | 4503 | { |
---|
| 4504 | + // Try compressed version first. |
---|
4081 | 4505 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4082 | 4506 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4083 | 4507 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4147 | 4571 | |
---|
4148 | 4572 | void LoadIt(Object obj) |
---|
4149 | 4573 | { |
---|
| 4574 | + if (obj == null) |
---|
| 4575 | + { |
---|
| 4576 | + // Invalid file |
---|
| 4577 | + return; |
---|
| 4578 | + } |
---|
| 4579 | + |
---|
4150 | 4580 | System.out.println("Loaded " + obj); |
---|
4151 | 4581 | //new Exception().printStackTrace(); |
---|
4152 | 4582 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4156 | 4586 | |
---|
4157 | 4587 | if (readobj != null) |
---|
4158 | 4588 | { |
---|
| 4589 | + if (Globals.SAVEONMAKE) |
---|
| 4590 | + Save(); |
---|
4159 | 4591 | try |
---|
4160 | 4592 | { |
---|
4161 | 4593 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4526 | 4958 | CheckboxMenuItem togglePaintItem; |
---|
4527 | 4959 | JSplitPane mainPanel; |
---|
4528 | 4960 | JScrollPane scrollpane; |
---|
| 4961 | + |
---|
4529 | 4962 | JPanel toolbarPanel; |
---|
| 4963 | + |
---|
4530 | 4964 | cGridBag treePanel; |
---|
| 4965 | + |
---|
4531 | 4966 | JPanel radioPanel; |
---|
4532 | 4967 | ButtonGroup buttonGroup; |
---|
4533 | | - cGridBag ctrlPanel; |
---|
| 4968 | + |
---|
| 4969 | + cGridBag toolboxPanel; |
---|
4534 | 4970 | cGridBag materialPanel; |
---|
| 4971 | + cGridBag ctrlPanel; |
---|
| 4972 | + |
---|
4535 | 4973 | JScrollPane infoPanel; |
---|
| 4974 | + |
---|
4536 | 4975 | cGridBag optionsPanel; |
---|
| 4976 | + |
---|
4537 | 4977 | JTabbedPane objectPanel; |
---|
| 4978 | + boolean materialFlushed; |
---|
| 4979 | + Object3D latestObject; |
---|
| 4980 | + |
---|
4538 | 4981 | cGridBag XYZPanel; |
---|
| 4982 | + |
---|
4539 | 4983 | JSplitPane gridPanel; |
---|
4540 | 4984 | JSplitPane bigPanel; |
---|
| 4985 | + |
---|
4541 | 4986 | cGridBag bigThree; |
---|
4542 | 4987 | cGridBag scenePanel; |
---|
4543 | 4988 | cGridBag centralPanel; |
---|
.. | .. |
---|
4652 | 5097 | cNumberSlider fogField; |
---|
4653 | 5098 | JLabel opacityPowerLabel; |
---|
4654 | 5099 | cNumberSlider opacityPowerField; |
---|
4655 | | - JTree jTree; |
---|
| 5100 | + cTree jTree; |
---|
4656 | 5101 | //ObjectUI parent; |
---|
4657 | 5102 | |
---|
4658 | 5103 | cNumberSlider normalpushField; |
---|