Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -35,6 +39,67 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
47
+ try
48
+ {
49
+ ImageIcon icon = GetIcon(name);
50
+ return new cButton(icon, border);
51
+ }
52
+ catch (Exception e)
53
+ {
54
+ return new cButton(name, border);
55
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
60
+ try
61
+ {
62
+ ImageIcon icon = GetIcon(name);
63
+ return new cToggleButton(icon, border);
64
+ }
65
+ catch (Exception e)
66
+ {
67
+ return new cToggleButton(name, border);
68
+ }
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ try
74
+ {
75
+ ImageIcon icon = GetIcon(name);
76
+ return new cCheckBox(icon, border);
77
+ }
78
+ catch (Exception e)
79
+ {
80
+ return new cCheckBox(name, border);
81
+ }
82
+ }
83
+
84
+ private ImageIcon GetIcon(String name) throws IOException
85
+ {
86
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
+
88
+ if (image.getWidth() != 24 && image.getHeight() != 24)
89
+ {
90
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
+ Graphics2D g = resized.createGraphics();
92
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
+ g.dispose();
96
+
97
+ image = resized;
98
+ }
99
+
100
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
+ return icon;
102
+ }
38103
39104 // SCRIPT
40105
....@@ -145,7 +210,7 @@
145210
146211 objEditor.ctrlPanel.remove(namePanel);
147212
148
- if (!GroupEditor.allparams)
213
+ if (!allparams)
149214 return;
150215
151216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +233,8 @@
168233 // objEditor.ctrlPanel.remove(remarkButton);
169234
170235 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
236
+ objEditor.ctrlPanel.remove(setupPanel2);
237
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172238 objEditor.ctrlPanel.remove(pushPanel);
173239 //objEditor.ctrlPanel.remove(fillPanel);
174240
....@@ -243,6 +309,7 @@
243309 //localCopy.parent = null;
244310
245311 frame = new JFrame();
312
+ frame.setUndecorated(true);
246313 objEditor = this;
247314 this.callee = callee;
248315
....@@ -273,12 +340,17 @@
273340 return frame.action(event, obj);
274341 }
275342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
276348 void SetupMenu()
277349 {
278350 frame.setMenuBar(menuBar = new MenuBar());
279351 menuBar.add(fileMenu = new Menu("File"));
280352 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
353
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282354
283355 //oe.menuBar.add(menu = new Menu("Include"));
284356 Menu menu = new Menu("Import");
....@@ -319,14 +391,52 @@
319391 closeItem.addActionListener(this);
320392
321393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
322420 toolbarPanel = new JPanel();
323421 toolbarPanel.setName("Toolbar");
324422 treePanel = new cGridBag();
325423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
326428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
429
+
430
+ editCommandsPanel = new cGridBag();
431
+ editPanel.add(editCommandsPanel);
432
+ editPanel.add(ctrlPanel);
433
+
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
436
+
328437 materialPanel = new cGridBag().setVertical(true);
329438 materialPanel.setName("Material");
439
+
330440 /*JTextPane*/
331441 infoarea = createTextPane();
332442 doc = infoarea.getStyledDocument();
....@@ -339,7 +449,7 @@
339449 // TEXTAREA infoarea.setLineWrap(true);
340450 // TEXTAREA infoarea.setWrapStyleWord(true);
341451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
342
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
343453 infoPanel.setName("Info");
344454 //infoPanel.setLayout(new BorderLayout());
345455 //infoPanel.add(createTextPane());
....@@ -351,7 +461,14 @@
351461 mainPanel.setDividerSize(9);
352462 mainPanel.setDividerLocation(0.5); //1.0);
353463 mainPanel.setResizeWeight(0.5);
354
-
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
355472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356473 //mainPanel.setLayout(new GridBagLayout());
357474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -419,10 +536,10 @@
419536 e.printStackTrace();
420537 }
421538
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();
539
+// String selection = infoarea.getText();
540
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
541
+// java.awt.datatransfer.Clipboard clipboard =
542
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426543 //clipboard.setContents(data, data);
427544 }
428545
....@@ -582,20 +699,111 @@
582699 }
583700 }
584701
702
+static GraphicsDevice device = GraphicsEnvironment
703
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
704
+
705
+ Rectangle keeprect;
706
+ cRadio radio;
707
+
708
+cButton keepButton;
709
+ cButton twoButton; // Full 3D
710
+ cButton sixButton;
711
+ cButton threeButton;
712
+ cButton sevenButton;
713
+ cButton fourButton; // full panel
714
+ cButton oneButton; // full XYZ
715
+ //cButton currentLayout;
716
+
717
+ boolean maximized;
718
+
719
+ cButton fullscreenLayout;
720
+
721
+ void Minimize()
722
+ {
723
+ frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
725
+ }
726
+
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
730
+ void Maximize()
731
+ {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
737
+ if (maximized)
738
+ {
739
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
740
+ }
741
+ else
742
+ {
743
+ keeprect = frame.getBounds();
744
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+ Dimension rect2 = frame.getToolkit().getScreenSize();
746
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
747
+// frame.setState(Frame.MAXIMIZED_BOTH);
748
+ }
749
+
750
+ maximized ^= true;
751
+
752
+ frame.validate();
753
+ }
754
+
755
+ cButton minButton;
756
+ cButton maxButton;
757
+ cButton fullButton;
758
+
585759 void ToggleFullScreen()
586760 {
587
- if (CameraPane.FULLSCREEN)
761
+ cameraView.ToggleFullScreen();
762
+
763
+ if (!CameraPane.FULLSCREEN)
588764 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
765
+ device.setFullScreenWindow(null);
766
+ frame.validate();
767
+
768
+ //frame.setVisible(false);
769
+// frame.removeNotify();
770
+// frame.setUndecorated(false);
771
+// frame.addNotify();
772
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
773
+
774
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
775
+// X framePanel.add(bigThree);
776
+// X frame.getContentPane().add(/*"Center",*/framePanel);
777
+ framePanel.setDividerLocation(1);
778
+
779
+ //frame.setVisible(true);
780
+ radio.layout = keepButton;
781
+ //theFrame = null;
782
+ keepButton = null;
783
+ radio.layout.doClick();
784
+
592785 } else
593786 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
787
+ keepButton = radio.layout;
788
+ //keeprect = frame.getBounds();
789
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
790
+// frame.getToolkit().getScreenSize().height);
791
+ //frame.setVisible(false);
792
+ device.setFullScreenWindow(frame);
793
+ frame.validate();
794
+// frame.removeNotify();
795
+// frame.setUndecorated(true);
796
+// frame.addNotify();
797
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
798
+// X framePanel.remove(bigThree);
799
+// X frame.getContentPane().add(/*"Center",*/bigThree);
800
+ framePanel.setDividerLocation(0);
801
+
802
+ radio.layout = fullscreenLayout;
803
+ radio.layout.doClick();
804
+ //frame.setVisible(true);
597805 }
598
- cameraView.ToggleFullScreen();
806
+ frame.validate();
599807 }
600808
601809 private JTextPane createTextPane()
....@@ -736,7 +944,12 @@
736944 JCheckBox speedupCB;
737945 JCheckBox rewindCB;
738946 JCheckBox flipVCB;
947
+
948
+ cCheckBox toggleTextureCB;
949
+ cCheckBox toggleSwitchCB;
950
+
739951 JComboBox texresMenu;
952
+
740953 JButton resetButton;
741954 JButton stepButton;
742955 JButton stepAllButton;
....@@ -745,9 +958,13 @@
745958 JButton fasterButton;
746959 JButton remarkButton;
747960
961
+ cGridBag editPanel;
962
+ cGridBag editCommandsPanel;
963
+
748964 cGridBag namePanel;
749965 cGridBag setupPanel;
750
- cGridBag commandsPanel;
966
+ cGridBag setupPanel2;
967
+ cGridBag objectCommandsPanel;
751968 cGridBag pushPanel;
752969 cGridBag fillPanel;
753970
....@@ -919,12 +1136,12 @@
9191136 namePanel = new cGridBag();
9201137
9211138 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1139
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231140 oe.ctrlPanel.add(namePanel);
9241141
9251142 oe.ctrlPanel.Return();
9261143
927
- if (!GroupEditor.allparams)
1144
+ if (!allparams)
9281145 return;
9291146
9301147 setupPanel = new cGridBag().setVertical(false);
....@@ -937,42 +1154,46 @@
9371154 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381155 hideCB.setToolTipText("Hide object");
9391156 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
1157
+ markCB.setToolTipText("As animation target transform");
9411158
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1159
+ setupPanel2 = new cGridBag().setVertical(false);
1160
+
1161
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431162 rewindCB.setToolTipText("Rewind animation");
9441163
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1164
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1165
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471166
9481167 if (Globals.ADVANCED)
9491168 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1169
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
9511170 link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1171
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531172 speedupCB.setToolTipText("Option motion capture");
9541173 }
9551174
9561175 oe.ctrlPanel.add(setupPanel);
9571176 oe.ctrlPanel.Return();
1177
+ oe.ctrlPanel.add(setupPanel2);
1178
+ oe.ctrlPanel.Return();
9581179
959
- commandsPanel = new cGridBag().setVertical(false);
1180
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601181
961
- resetButton = AddButton(commandsPanel, "Reset");
1182
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621183 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1184
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641185 stepButton.setToolTipText("Step one frame");
9651186 // resetAllButton = AddButton(oe, "Reset All");
9661187 // stepAllButton = AddButton(oe, "Step All");
9671188 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1189
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691190 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1191
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711192 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1193
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731194 remarkButton.setToolTipText("Set the current transform as the target");
9741195
975
- oe.ctrlPanel.add(commandsPanel);
1196
+ oe.ctrlPanel.add(objectCommandsPanel);
9761197 oe.ctrlPanel.Return();
9771198
9781199 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1399,11 @@
11781399 //worldPanel.setName("World");
11791400 centralPanel = new cGridBag();
11801401 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1402
+
1403
+ if (Globals.ADVANCED)
1404
+ {
1405
+ timelinePanel = new JPanel(new BorderLayout());
1406
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831407
11841408 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851409 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1412,10 @@
11881412 // cameraPanel.setDividerSize(9);
11891413 cameraPanel.setResizeWeight(1.0);
11901414
1415
+ }
1416
+
11911417 centralPanel.add(cameraView);
1418
+ centralPanel.setFocusable(true);
11921419 //frame.setJMenuBar(timelineMenubar);
11931420 //centralPanel.add(timelinePanel);
11941421
....@@ -1255,8 +1482,9 @@
12551482 // north.setName("Edit");
12561483 // north.add(ctrlPanel, BorderLayout.NORTH);
12571484 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1485
+ objectPanel.add(editPanel);
12591486 objectPanel.add(infoPanel);
1487
+ objectPanel.add(toolboxPanel);
12601488
12611489 /*
12621490 aConstraints.gridx = 0;
....@@ -1265,7 +1493,7 @@
12651493 aConstraints.gridy += 1;
12661494 aConstraints.gridwidth = 1;
12671495 mainPanel.add(objectPanel, aConstraints);
1268
- */
1496
+ */
12691497
12701498 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711499 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1282,9 +1510,7 @@
12821510 JTabbedPane tabbedPane = new JTabbedPane();
12831511 tabbedPane.add(scrollpane);
12841512
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1513
+ optionsPanel = new cGridBag().setVertical(false);
12881514
12891515 optionsPanel.setName("Options");
12901516
....@@ -1292,6 +1518,8 @@
12921518
12931519 tabbedPane.add(optionsPanel);
12941520
1521
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1522
+
12951523 scenePanel.add(tabbedPane);
12961524
12971525 /*
....@@ -1384,8 +1612,12 @@
13841612 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851613
13861614 frame.setSize(1280, 860);
1615
+
1616
+ frame.validate();
13871617 frame.setVisible(true);
13881618
1619
+ cameraView.requestFocusInWindow();
1620
+
13891621 gridPanel.setDividerLocation(1.0);
13901622
13911623 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1473,24 +1705,6 @@
14731705 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14741706 colorSection.add(texture);
14751707
1476
- cGridBag anisoU = new cGridBag();
1477
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1478
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1479
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1480
- colorSection.add(anisoU);
1481
-
1482
- cGridBag anisoV = new cGridBag();
1483
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1484
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoV);
1487
-
1488
- cGridBag shadowbias = new cGridBag();
1489
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1490
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1492
- colorSection.add(shadowbias);
1493
-
14941708 panel.add(new JSeparator());
14951709
14961710 panel.add(colorSection);
....@@ -1540,6 +1754,12 @@
15401754 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15411755 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421756 diffuseSection.add(fakedepth);
1757
+
1758
+ cGridBag shadowbias = new cGridBag();
1759
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1760
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1761
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1762
+ diffuseSection.add(shadowbias);
15431763
15441764 panel.add(new JSeparator());
15451765
....@@ -1591,6 +1811,18 @@
15911811 // aConstraints.gridy += 1;
15921812 // aConstraints.gridwidth = 1;
15931813
1814
+ cGridBag anisoU = new cGridBag();
1815
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1816
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1817
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
+ specularSection.add(anisoU);
1819
+
1820
+ cGridBag anisoV = new cGridBag();
1821
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1822
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1823
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1824
+ specularSection.add(anisoV);
1825
+
15941826
15951827 panel.add(new JSeparator());
15961828
....@@ -1598,35 +1830,35 @@
15981830
15991831 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16001832
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
1833
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16021834
16031835 cGridBag camera = new cGridBag();
16041836 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16051837 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16061838 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
1839
+ colorSection.add(camera);
16081840
16091841 cGridBag ambient = new cGridBag();
16101842 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16111843 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121844 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
1845
+ colorSection.add(ambient);
16141846
16151847 cGridBag backlit = new cGridBag();
16161848 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16171849 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181850 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
1851
+ colorSection.add(backlit);
16201852
16211853 cGridBag opacity = new cGridBag();
16221854 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16231855 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241856 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1625
- globalSection.add(opacity);
1857
+ colorSection.add(opacity);
16261858
1627
- panel.add(new JSeparator());
1859
+ //panel.add(new JSeparator());
16281860
1629
- panel.add(globalSection);
1861
+ //panel.add(globalSection);
16301862
16311863 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16321864
....@@ -2072,19 +2304,19 @@
20722304
20732305 void LoadObjFile(String fullname)
20742306 {
2075
- /*
2307
+ System.out.println("Loading " + fullname);
2308
+ /**/
20762309 //lastFilename = fullname;
20772310 if(loadObjThread == null)
20782311 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2312
+ loadObjThread = new LoadOBJThread();
2313
+ loadObjThread.start();
20812314 }
20822315
20832316 loadObjThread.add(fullname);
2084
- */
2317
+ /**/
20852318
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2319
+ //makeSomething(new FileObject(fullname, true), true);
20882320 }
20892321
20902322 void LoadGFDFile(String fullname)
....@@ -2701,6 +2933,8 @@
27012933
27022934 void SetMaterial(Object3D object)
27032935 {
2936
+ latestObject = object;
2937
+
27042938 cMaterial mat = object.material;
27052939
27062940 if (mat == null)
....@@ -2812,12 +3046,17 @@
28123046 // }
28133047
28143048 /**/
2815
- if (deselect)
3049
+ if (deselect || child == null)
28163050 {
28173051 //group.deselectAll();
28183052 //freeze = true;
28193053 GetTree().clearSelection();
28203054 //freeze = false;
3055
+
3056
+ if (child == null)
3057
+ {
3058
+ return;
3059
+ }
28213060 }
28223061
28233062 //group.addSelectee(child);
....@@ -2886,7 +3125,7 @@
28863125 cameraView.ToggleDL();
28873126 cameraView.repaint();
28883127 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3128
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903129 {
28913130 cameraView.ToggleTexture();
28923131 // june 2013 copy.HardTouch();
....@@ -2925,9 +3164,9 @@
29253164 frame.validate();
29263165
29273166 return;
2928
- } else if (event.getSource() == toggleSwitchItem)
3167
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293168 {
2930
- cameraView.ToggleRandom();
3169
+ cameraView.ToggleSwitch();
29313170 cameraView.repaint();
29323171 return;
29333172 } else if (event.getSource() == toggleHandleItem)
....@@ -3214,6 +3453,53 @@
32143453 objEditor.refreshContents();
32153454 }
32163455
3456
+ static public byte[] Compress(Object3D o)
3457
+ {
3458
+ try
3459
+ {
3460
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3461
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3462
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3463
+
3464
+ Object3D parent = o.parent;
3465
+ o.parent = null;
3466
+
3467
+ out.writeObject(o);
3468
+
3469
+ o.parent = parent;
3470
+
3471
+ out.flush();
3472
+
3473
+ zstream.close();
3474
+ out.close();
3475
+
3476
+ return baos.toByteArray();
3477
+ } catch (Exception e)
3478
+ {
3479
+ System.err.println(e);
3480
+ return null;
3481
+ }
3482
+ }
3483
+
3484
+ static public Object Uncompress(byte[] bytes)
3485
+ {
3486
+ System.out.println("#bytes = " + bytes.length);
3487
+ try
3488
+ {
3489
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3490
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3491
+ ObjectInputStream in = new ObjectInputStream(istream);
3492
+ Object obj = in.readObject();
3493
+ in.close();
3494
+
3495
+ return obj;
3496
+ } catch (Exception e)
3497
+ {
3498
+ System.err.println(e);
3499
+ return null;
3500
+ }
3501
+ }
3502
+
32173503 static public Object clone(Object o)
32183504 {
32193505 try
....@@ -3222,12 +3508,19 @@
32223508 ObjectOutputStream out = new ObjectOutputStream(baos);
32233509
32243510 out.writeObject(o);
3511
+
3512
+ out.flush();
3513
+ out.close();
3514
+
3515
+ byte[] bytes = baos.toByteArray();
3516
+
3517
+ System.out.println("clone = " + bytes.length);
32253518
3226
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3519
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
32273520 ObjectInputStream in = new ObjectInputStream(bais);
32283521 Object obj = in.readObject();
32293522 in.close();
3230
- out.close();
3523
+
32313524 return obj;
32323525 } catch (Exception e)
32333526 {
....@@ -3242,7 +3535,7 @@
32423535 for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
32433536 {
32443537 ab = (cRadio)e.nextElement();
3245
- if(ab.GetObject() == client)
3538
+ if(ab.GetObject() == copy)
32463539 {
32473540 return ab;
32483541 }
....@@ -3251,18 +3544,37 @@
32513544 return null;
32523545 }
32533546
3547
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3548
+
32543549 public void Save()
32553550 {
3551
+ System.err.println("Save");
3552
+
32563553 cRadio tab = GetCurrentTab();
32573554
3555
+ boolean temp = CameraPane.SWITCH;
3556
+ CameraPane.SWITCH = false;
3557
+
3558
+ copy.ExtractBigData(hashtable);
3559
+
3560
+ byte[] compress = Compress(copy);
3561
+
32583562 //EditorFrame.m_MainFrame.requestFocusInWindow();
3259
- tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3563
+ tab.graphs[tab.undoindex++] = compress;
32603564
3565
+ copy.RestoreBigData(hashtable);
3566
+
3567
+ CameraPane.SWITCH = temp;
3568
+
3569
+ //assert(hashtable.isEmpty());
3570
+
32613571 for (int i = tab.undoindex; i < tab.graphs.length; i++)
32623572 {
32633573 tab.graphs[i] = null;
32643574 }
32653575
3576
+ SetUndoStates();
3577
+
32663578 // test save
32673579 if (false)
32683580 {
....@@ -3285,12 +3597,25 @@
32853597
32863598 void CopyChanged(Object3D obj)
32873599 {
3600
+ SetUndoStates();
3601
+
3602
+ boolean temp = CameraPane.SWITCH;
3603
+ CameraPane.SWITCH = false;
3604
+
3605
+ copy.ExtractBigData(hashtable);
3606
+
32883607 copy.clear();
32893608
32903609 for (int i=0; i<obj.Size(); i++)
32913610 {
32923611 copy.add(obj.get(i));
32933612 }
3613
+
3614
+ copy.RestoreBigData(hashtable);
3615
+
3616
+ CameraPane.SWITCH = temp;
3617
+
3618
+ //assert(hashtable.isEmpty());
32943619
32953620 copy.Touch();
32963621
....@@ -3313,8 +3638,21 @@
33133638 refreshContents();
33143639 }
33153640
3641
+ cButton undoButton;
3642
+ cButton redoButton;
3643
+
3644
+ void SetUndoStates()
3645
+ {
3646
+ cRadio tab = GetCurrentTab();
3647
+
3648
+ undoButton.setEnabled(tab.undoindex > 0);
3649
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3650
+ }
3651
+
33163652 public void Undo()
33173653 {
3654
+ System.err.println("Undo");
3655
+
33183656 cRadio tab = GetCurrentTab();
33193657
33203658 if (tab.undoindex == 0)
....@@ -3331,7 +3669,7 @@
33313669
33323670 tab.undoindex -= 1;
33333671
3334
- CopyChanged(tab.graphs[tab.undoindex]);
3672
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33353673 }
33363674
33373675 public void Redo()
....@@ -3346,7 +3684,7 @@
33463684
33473685 tab.undoindex += 1;
33483686
3349
- CopyChanged(tab.graphs[tab.undoindex]);
3687
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33503688 }
33513689
33523690 void ImportGFD()
....@@ -3498,7 +3836,7 @@
34983836 assert false;
34993837 }
35003838
3501
- void EditSelection()
3839
+ void EditSelection(boolean newWindow)
35023840 {
35033841 }
35043842
....@@ -3993,7 +4331,8 @@
39934331
39944332 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
39954333 {
3996
- Save();
4334
+ if (Globals.SAVEONMAKE) // && resetmodel)
4335
+ Save();
39974336 //Tween.set(thing, 0).target(1).start(tweenManager);
39984337 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
39994338 // if (thing instanceof GenericJointDemo)
....@@ -4080,6 +4419,12 @@
40804419 {
40814420 ResetModel();
40824421 Select(thing.GetTreePath(), true, false); // unselect... false);
4422
+
4423
+ if (thing.Size() == 0)
4424
+ {
4425
+ //EditSelection(false);
4426
+ }
4427
+
40834428 refreshContents();
40844429 }
40854430
....@@ -4217,6 +4562,7 @@
42174562
42184563 try
42194564 {
4565
+ // Try compressed version first.
42204566 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
42214567 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
42224568 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4286,6 +4632,12 @@
42864632
42874633 void LoadIt(Object obj)
42884634 {
4635
+ if (obj == null)
4636
+ {
4637
+ // Invalid file
4638
+ return;
4639
+ }
4640
+
42894641 System.out.println("Loaded " + obj);
42904642 //new Exception().printStackTrace();
42914643 Object3D readobj = (Object3D) obj;
....@@ -4295,6 +4647,8 @@
42954647
42964648 if (readobj != null)
42974649 {
4650
+ if (Globals.SAVEONMAKE)
4651
+ Save();
42984652 try
42994653 {
43004654 //readobj.deepCopySelf(copy);
....@@ -4472,6 +4826,8 @@
44724826 String filename = browser.getFile();
44734827 if (filename != null && filename.length() > 0)
44744828 {
4829
+ if (!filename.endsWith(".gfd"))
4830
+ filename += ".gfd";
44754831 lastname = browser.getDirectory() + filename;
44764832 save();
44774833 }
....@@ -4665,18 +5021,31 @@
46655021 CheckboxMenuItem togglePaintItem;
46665022 JSplitPane mainPanel;
46675023 JScrollPane scrollpane;
5024
+
46685025 JPanel toolbarPanel;
5026
+
46695027 cGridBag treePanel;
5028
+
46705029 JPanel radioPanel;
46715030 ButtonGroup buttonGroup;
4672
- cGridBag ctrlPanel;
5031
+
5032
+ cGridBag toolboxPanel;
46735033 cGridBag materialPanel;
5034
+ cGridBag ctrlPanel;
5035
+
46745036 JScrollPane infoPanel;
5037
+
46755038 cGridBag optionsPanel;
5039
+
46765040 JTabbedPane objectPanel;
5041
+ boolean materialFlushed;
5042
+ Object3D latestObject;
5043
+
46775044 cGridBag XYZPanel;
5045
+
46785046 JSplitPane gridPanel;
46795047 JSplitPane bigPanel;
5048
+
46805049 cGridBag bigThree;
46815050 cGridBag scenePanel;
46825051 cGridBag centralPanel;
....@@ -4791,7 +5160,7 @@
47915160 cNumberSlider fogField;
47925161 JLabel opacityPowerLabel;
47935162 cNumberSlider opacityPowerField;
4794
- JTree jTree;
5163
+ cTree jTree;
47955164 //ObjectUI parent;
47965165
47975166 cNumberSlider normalpushField;