Normand Briere
2019-07-07 46dbce888e7c3eff8969f1ddbe22e144410b67f4
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(false);
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("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
282354
283355 //oe.menuBar.add(menu = new Menu("Include"));
284356 Menu menu = new Menu("Import");
....@@ -310,7 +382,7 @@
310382 }
311383
312384 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
314386 saveItem.addActionListener(this);
315387 saveAsItem.addActionListener(this);
316388 exportAsItem.addActionListener(this);
....@@ -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(1, 1));
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));
....@@ -582,20 +699,121 @@
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
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
749
+ }
750
+
751
+ maximized ^= true;
752
+
753
+ frame.validate();
754
+ }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
759
+
585760 void ToggleFullScreen()
586761 {
587
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
588767 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
768
+ device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
774
+ //frame.setVisible(false);
775
+// frame.removeNotify();
776
+// frame.setUndecorated(false);
777
+// frame.addNotify();
778
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
779
+
780
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
781
+// X framePanel.add(bigThree);
782
+// X frame.getContentPane().add(/*"Center",*/framePanel);
783
+ framePanel.setDividerLocation(46);
784
+
785
+ //frame.setVisible(true);
786
+ radio.layout = keepButton;
787
+ //theFrame = null;
788
+ keepButton = null;
789
+ radio.layout.doClick();
790
+
592791 } else
593792 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
793
+ keepButton = radio.layout;
794
+ //keeprect = frame.getBounds();
795
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
796
+// frame.getToolkit().getScreenSize().height);
797
+ //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
801
+ device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
804
+// frame.removeNotify();
805
+// frame.setUndecorated(true);
806
+// frame.addNotify();
807
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
808
+// X framePanel.remove(bigThree);
809
+// X frame.getContentPane().add(/*"Center",*/bigThree);
810
+ framePanel.setDividerLocation(0);
811
+
812
+ radio.layout = fullscreenLayout;
813
+ radio.layout.doClick();
814
+ //frame.setVisible(true);
597815 }
598
- cameraView.ToggleFullScreen();
816
+ frame.validate();
599817 }
600818
601819 private JTextPane createTextPane()
....@@ -736,7 +954,12 @@
736954 JCheckBox speedupCB;
737955 JCheckBox rewindCB;
738956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
739961 JComboBox texresMenu;
962
+
740963 JButton resetButton;
741964 JButton stepButton;
742965 JButton stepAllButton;
....@@ -745,9 +968,13 @@
745968 JButton fasterButton;
746969 JButton remarkButton;
747970
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
748974 cGridBag namePanel;
749975 cGridBag setupPanel;
750
- cGridBag commandsPanel;
976
+ cGridBag setupPanel2;
977
+ cGridBag objectCommandsPanel;
751978 cGridBag pushPanel;
752979 cGridBag fillPanel;
753980
....@@ -919,12 +1146,12 @@
9191146 namePanel = new cGridBag();
9201147
9211148 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231150 oe.ctrlPanel.add(namePanel);
9241151
9251152 oe.ctrlPanel.Return();
9261153
927
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
9281155 return;
9291156
9301157 setupPanel = new cGridBag().setVertical(false);
....@@ -937,42 +1164,46 @@
9371164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381165 hideCB.setToolTipText("Hide object");
9391166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
9411168
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1169
+ setupPanel2 = new cGridBag().setVertical(false);
1170
+
1171
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431172 rewindCB.setToolTipText("Rewind animation");
9441173
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471176
9481177 if (Globals.ADVANCED)
9491178 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1179
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
9511180 link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1181
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531182 speedupCB.setToolTipText("Option motion capture");
9541183 }
9551184
9561185 oe.ctrlPanel.add(setupPanel);
9571186 oe.ctrlPanel.Return();
1187
+ oe.ctrlPanel.add(setupPanel2);
1188
+ oe.ctrlPanel.Return();
9581189
959
- commandsPanel = new cGridBag().setVertical(false);
1190
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601191
961
- resetButton = AddButton(commandsPanel, "Reset");
1192
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621193 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1194
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641195 stepButton.setToolTipText("Step one frame");
9651196 // resetAllButton = AddButton(oe, "Reset All");
9661197 // stepAllButton = AddButton(oe, "Step All");
9671198 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1199
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691200 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1201
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711202 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1203
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731204 remarkButton.setToolTipText("Set the current transform as the target");
9741205
975
- oe.ctrlPanel.add(commandsPanel);
1206
+ oe.ctrlPanel.add(objectCommandsPanel);
9761207 oe.ctrlPanel.Return();
9771208
9781209 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1409,11 @@
11781409 //worldPanel.setName("World");
11791410 centralPanel = new cGridBag();
11801411 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1412
+
1413
+ if (Globals.ADVANCED)
1414
+ {
1415
+ timelinePanel = new JPanel(new BorderLayout());
1416
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831417
11841418 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851419 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1422,10 @@
11881422 // cameraPanel.setDividerSize(9);
11891423 cameraPanel.setResizeWeight(1.0);
11901424
1425
+ }
1426
+
11911427 centralPanel.add(cameraView);
1428
+ centralPanel.setFocusable(true);
11921429 //frame.setJMenuBar(timelineMenubar);
11931430 //centralPanel.add(timelinePanel);
11941431
....@@ -1255,8 +1492,12 @@
12551492 // north.setName("Edit");
12561493 // north.add(ctrlPanel, BorderLayout.NORTH);
12571494 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1495
+ objectPanel.add(editPanel);
1496
+
1497
+ //if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
1500
+ objectPanel.add(toolboxPanel);
12601501
12611502 /*
12621503 aConstraints.gridx = 0;
....@@ -1265,7 +1506,7 @@
12651506 aConstraints.gridy += 1;
12661507 aConstraints.gridwidth = 1;
12671508 mainPanel.add(objectPanel, aConstraints);
1268
- */
1509
+ */
12691510
12701511 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711512 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1282,9 +1523,7 @@
12821523 JTabbedPane tabbedPane = new JTabbedPane();
12831524 tabbedPane.add(scrollpane);
12841525
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1526
+ optionsPanel = new cGridBag().setVertical(false);
12881527
12891528 optionsPanel.setName("Options");
12901529
....@@ -1292,6 +1531,8 @@
12921531
12931532 tabbedPane.add(optionsPanel);
12941533
1534
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1535
+
12951536 scenePanel.add(tabbedPane);
12961537
12971538 /*
....@@ -1364,9 +1605,9 @@
13641605 // aConstraints.gridheight = 1;
13651606
13661607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
13701611 //framePanel.setDividerSize(15);
13711612 //framePanel.setResizeWeight(0.15);
13721613 framePanel.setName("Frame");
....@@ -1384,9 +1625,14 @@
13841625 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851626
13861627 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1388
-
1628
+
1629
+ cameraView.requestFocusInWindow();
1630
+
13891631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
13901636
13911637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13921638 frame.addWindowListener(new WindowAdapter()
....@@ -1473,24 +1719,6 @@
14731719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14741720 colorSection.add(texture);
14751721
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
-
14941722 panel.add(new JSeparator());
14951723
14961724 panel.add(colorSection);
....@@ -1540,6 +1768,12 @@
15401768 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15411769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421770 diffuseSection.add(fakedepth);
1771
+
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
15431777
15441778 panel.add(new JSeparator());
15451779
....@@ -1591,6 +1825,18 @@
15911825 // aConstraints.gridy += 1;
15921826 // aConstraints.gridwidth = 1;
15931827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
1833
+
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
15941840
15951841 panel.add(new JSeparator());
15961842
....@@ -1598,35 +1844,35 @@
15981844
15991845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16001846
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16021848
16031849 cGridBag camera = new cGridBag();
16041850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16051851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16061852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
1853
+ colorSection.add(camera);
16081854
16091855 cGridBag ambient = new cGridBag();
16101856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16111857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
16141860
16151861 cGridBag backlit = new cGridBag();
16161862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16171863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
16201866
16211867 cGridBag opacity = new cGridBag();
16221868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16231869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1625
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
16261872
1627
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
16281874
1629
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
16301876
16311877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16321878
....@@ -1733,8 +1979,9 @@
17331979 // 3D models
17341980 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17351981 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
1982
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1983
+ //LoadFile(filename, lastConverter);
1984
+ LoadObjFile(filename); // New 3ds loader
17381985 continue;
17391986 }
17401987 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2460,6 +2707,7 @@
24602707 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24612708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24622709 }
2710
+
24632711 //cJME.count++;
24642712 //cJME.count %= 12;
24652713 if (gc)
....@@ -2643,6 +2891,7 @@
26432891 }
26442892 }
26452893 }
2894
+
26462895 cFileSystemPane FSPane;
26472896
26482897 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2696,11 +2945,14 @@
26962945 }
26972946 }
26982947 }
2948
+
26992949 freezematerial = false;
27002950 }
27012951
27022952 void SetMaterial(Object3D object)
27032953 {
2954
+ latestObject = object;
2955
+
27042956 cMaterial mat = object.material;
27052957
27062958 if (mat == null)
....@@ -2812,12 +3064,17 @@
28123064 // }
28133065
28143066 /**/
2815
- if (deselect)
3067
+ if (deselect || child == null)
28163068 {
28173069 //group.deselectAll();
28183070 //freeze = true;
28193071 GetTree().clearSelection();
28203072 //freeze = false;
3073
+
3074
+ if (child == null)
3075
+ {
3076
+ return;
3077
+ }
28213078 }
28223079
28233080 //group.addSelectee(child);
....@@ -2886,7 +3143,7 @@
28863143 cameraView.ToggleDL();
28873144 cameraView.repaint();
28883145 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3146
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903147 {
28913148 cameraView.ToggleTexture();
28923149 // june 2013 copy.HardTouch();
....@@ -2925,7 +3182,7 @@
29253182 frame.validate();
29263183
29273184 return;
2928
- } else if (event.getSource() == toggleSwitchItem)
3185
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293186 {
29303187 cameraView.ToggleSwitch();
29313188 cameraView.repaint();
....@@ -3141,9 +3398,9 @@
31413398 {
31423399 Close();
31433400 //return true;
3144
- } else if (source == loadItem)
3401
+ } else if (source == openItem)
31453402 {
3146
- load();
3403
+ Open();
31473404 //return true;
31483405 } else if (source == newItem)
31493406 {
....@@ -3168,6 +3425,10 @@
31683425 {
31693426 generatePOV();
31703427 //return true;
3428
+ } else if (event.getSource() == archiveItem)
3429
+ {
3430
+ cTools.Archive(frame);
3431
+ return;
31713432 } else if (source == zBufferItem)
31723433 {
31733434 try
....@@ -3309,6 +3570,30 @@
33093570
33103571 public void Save()
33113572 {
3573
+ // Default reduces the probability of heuristics errors.
3574
+ Save(true);
3575
+ }
3576
+
3577
+ private boolean Equal(byte[] compress, byte[] name)
3578
+ {
3579
+ if (compress.length != name.length)
3580
+ {
3581
+ return false;
3582
+ }
3583
+
3584
+ for (int i=compress.length; --i>=0;)
3585
+ {
3586
+ if (compress[i] != name[i])
3587
+ return false;
3588
+ }
3589
+
3590
+ return true;
3591
+ }
3592
+
3593
+ public boolean Save(boolean user)
3594
+ {
3595
+ System.err.println("Save");
3596
+
33123597 cRadio tab = GetCurrentTab();
33133598
33143599 boolean temp = CameraPane.SWITCH;
....@@ -3316,20 +3601,37 @@
33163601
33173602 copy.ExtractBigData(hashtable);
33183603
3319
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3320
- tab.graphs[tab.undoindex++] = Compress(copy);
3321
-
3322
- copy.RestoreBigData(hashtable);
3604
+ byte[] compress = Compress(copy);
33233605
33243606 CameraPane.SWITCH = temp;
33253607
3608
+ boolean thesame = false;
3609
+
3610
+ // Quick heuristic using length. Works only when stream is compressed.
3611
+ if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3612
+ {
3613
+ thesame = true;
3614
+ }
3615
+
3616
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3617
+ if (!thesame)
3618
+ {
3619
+ tab.user[tab.undoindex] = user;
3620
+ tab.graphs[tab.undoindex++] = compress;
3621
+ }
3622
+
3623
+ copy.RestoreBigData(hashtable);
3624
+
33263625 //assert(hashtable.isEmpty());
33273626
33283627 for (int i = tab.undoindex; i < tab.graphs.length; i++)
33293628 {
3629
+ tab.user[i] = false;
33303630 tab.graphs[i] = null;
33313631 }
33323632
3633
+ SetUndoStates();
3634
+
33333635 // test save
33343636 if (false)
33353637 {
....@@ -3348,10 +3650,14 @@
33483650 e.printStackTrace();
33493651 }
33503652 }
3653
+
3654
+ return !thesame;
33513655 }
33523656
33533657 void CopyChanged(Object3D obj)
33543658 {
3659
+ SetUndoStates();
3660
+
33553661 boolean temp = CameraPane.SWITCH;
33563662 CameraPane.SWITCH = false;
33573663
....@@ -3391,25 +3697,47 @@
33913697 refreshContents();
33923698 }
33933699
3394
- public void Undo()
3700
+ cButton undoButton;
3701
+ cButton redoButton;
3702
+
3703
+ void SetUndoStates()
33953704 {
3705
+ cRadio tab = GetCurrentTab();
3706
+
3707
+ undoButton.setEnabled(tab.undoindex > 0);
3708
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3709
+ }
3710
+
3711
+ public boolean Undo()
3712
+ {
3713
+ System.err.println("Undo");
3714
+
33963715 cRadio tab = GetCurrentTab();
33973716
33983717 if (tab.undoindex == 0)
33993718 {
34003719 java.awt.Toolkit.getDefaultToolkit().beep();
3401
- return;
3720
+ return false;
34023721 }
34033722
3404
- if (tab.graphs[tab.undoindex] == null)
3723
+ if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex])
34053724 {
3406
- Save();
3407
- tab.undoindex -= 1;
3725
+ if (Save(false))
3726
+ tab.undoindex -= 1;
3727
+ else
3728
+ {
3729
+ if (tab.undoindex <= 0)
3730
+ return false;
3731
+ else
3732
+ tab.undoindex -= 1;
3733
+ }
34083734 }
34093735
34103736 tab.undoindex -= 1;
34113737
34123738 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3739
+
3740
+ return true;
34133741 }
34143742
34153743 public void Redo()
....@@ -3425,6 +3753,9 @@
34253753 tab.undoindex += 1;
34263754
34273755 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3756
+
3757
+ if (!tab.user[tab.undoindex])
3758
+ tab.graphs[tab.undoindex] = null;
34283759 }
34293760
34303761 void ImportGFD()
....@@ -3576,7 +3907,7 @@
35763907 assert false;
35773908 }
35783909
3579
- void EditSelection()
3910
+ void EditSelection(boolean newWindow)
35803911 {
35813912 }
35823913
....@@ -4071,7 +4402,8 @@
40714402
40724403 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40734404 {
4074
- Save();
4405
+ if (Globals.SAVEONMAKE) // && resetmodel)
4406
+ Save();
40754407 //Tween.set(thing, 0).target(1).start(tweenManager);
40764408 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40774409 // if (thing instanceof GenericJointDemo)
....@@ -4158,6 +4490,12 @@
41584490 {
41594491 ResetModel();
41604492 Select(thing.GetTreePath(), true, false); // unselect... false);
4493
+
4494
+ if (thing.Size() == 0)
4495
+ {
4496
+ //EditSelection(false);
4497
+ }
4498
+
41614499 refreshContents();
41624500 }
41634501
....@@ -4380,6 +4718,7 @@
43804718
43814719 if (readobj != null)
43824720 {
4721
+ if (Globals.SAVEONMAKE)
43834722 Save();
43844723 try
43854724 {
....@@ -4441,7 +4780,7 @@
44414780 }
44424781 }
44434782
4444
- void load() // throws ClassNotFoundException
4783
+ void Open() // throws ClassNotFoundException
44454784 {
44464785 if (Grafreed.standAlone)
44474786 {
....@@ -4558,6 +4897,8 @@
45584897 String filename = browser.getFile();
45594898 if (filename != null && filename.length() > 0)
45604899 {
4900
+ if (!filename.endsWith(".gfd"))
4901
+ filename += ".gfd";
45614902 lastname = browser.getDirectory() + filename;
45624903 save();
45634904 }
....@@ -4724,7 +5065,7 @@
47245065 MenuBar menuBar;
47255066 Menu fileMenu;
47265067 MenuItem newItem;
4727
- MenuItem loadItem;
5068
+ MenuItem openItem;
47285069 MenuItem saveItem;
47295070 MenuItem saveAsItem;
47305071 MenuItem exportAsItem;
....@@ -4747,22 +5088,36 @@
47475088 CheckboxMenuItem toggleSwitchItem;
47485089 CheckboxMenuItem toggleRootItem;
47495090 CheckboxMenuItem animationItem;
5091
+ MenuItem archiveItem;
47505092 CheckboxMenuItem toggleHandleItem;
47515093 CheckboxMenuItem togglePaintItem;
47525094 JSplitPane mainPanel;
47535095 JScrollPane scrollpane;
5096
+
47545097 JPanel toolbarPanel;
5098
+
47555099 cGridBag treePanel;
5100
+
47565101 JPanel radioPanel;
47575102 ButtonGroup buttonGroup;
4758
- cGridBag ctrlPanel;
5103
+
5104
+ cGridBag toolboxPanel;
47595105 cGridBag materialPanel;
5106
+ cGridBag ctrlPanel;
5107
+
47605108 JScrollPane infoPanel;
5109
+
47615110 cGridBag optionsPanel;
5111
+
47625112 JTabbedPane objectPanel;
5113
+ boolean materialFlushed;
5114
+ Object3D latestObject;
5115
+
47635116 cGridBag XYZPanel;
5117
+
47645118 JSplitPane gridPanel;
47655119 JSplitPane bigPanel;
5120
+
47665121 cGridBag bigThree;
47675122 cGridBag scenePanel;
47685123 cGridBag centralPanel;
....@@ -4877,7 +5232,7 @@
48775232 cNumberSlider fogField;
48785233 JLabel opacityPowerLabel;
48795234 cNumberSlider opacityPowerField;
4880
- JTree jTree;
5235
+ cTree jTree;
48815236 //ObjectUI parent;
48825237
48835238 cNumberSlider normalpushField;