Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
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);
....@@ -169,7 +234,7 @@
169234
170235 objEditor.ctrlPanel.remove(setupPanel);
171236 objEditor.ctrlPanel.remove(setupPanel2);
172
- objEditor.ctrlPanel.remove(commandsPanel);
237
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
173238 objEditor.ctrlPanel.remove(pushPanel);
174239 //objEditor.ctrlPanel.remove(fillPanel);
175240
....@@ -244,6 +309,7 @@
244309 //localCopy.parent = null;
245310
246311 frame = new JFrame();
312
+ frame.setUndecorated(false);
247313 objEditor = this;
248314 this.callee = callee;
249315
....@@ -274,12 +340,17 @@
274340 return frame.action(event, obj);
275341 }
276342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
277348 void SetupMenu()
278349 {
279350 frame.setMenuBar(menuBar = new MenuBar());
280351 menuBar.add(fileMenu = new Menu("File"));
281352 fileMenu.add(newItem = new MenuItem("New"));
282
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
283354
284355 //oe.menuBar.add(menu = new Menu("Include"));
285356 Menu menu = new Menu("Import");
....@@ -311,7 +382,7 @@
311382 }
312383
313384 newItem.addActionListener(this);
314
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
315386 saveItem.addActionListener(this);
316387 saveAsItem.addActionListener(this);
317388 exportAsItem.addActionListener(this);
....@@ -320,14 +391,52 @@
320391 closeItem.addActionListener(this);
321392
322393 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
+
323420 toolbarPanel = new JPanel();
324421 toolbarPanel.setName("Toolbar");
325422 treePanel = new cGridBag();
326423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
327428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
328
- 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
+
329437 materialPanel = new cGridBag().setVertical(true);
330438 materialPanel.setName("Material");
439
+
331440 /*JTextPane*/
332441 infoarea = createTextPane();
333442 doc = infoarea.getStyledDocument();
....@@ -340,7 +449,7 @@
340449 // TEXTAREA infoarea.setLineWrap(true);
341450 // TEXTAREA infoarea.setWrapStyleWord(true);
342451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
343
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
344453 infoPanel.setName("Info");
345454 //infoPanel.setLayout(new BorderLayout());
346455 //infoPanel.add(createTextPane());
....@@ -352,7 +461,14 @@
352461 mainPanel.setDividerSize(9);
353462 mainPanel.setDividerLocation(0.5); //1.0);
354463 mainPanel.setResizeWeight(0.5);
355
-
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
+
356472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
357473 //mainPanel.setLayout(new GridBagLayout());
358474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -583,20 +699,121 @@
583699 }
584700 }
585701
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
+
586760 void ToggleFullScreen()
587761 {
588
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
589767 {
590
- frame.getContentPane().remove(/*"Center",*/bigThree);
591
- framePanel.add(bigThree);
592
- 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
+
593791 } else
594792 {
595
- frame.getContentPane().remove(/*"Center",*/framePanel);
596
- framePanel.remove(bigThree);
597
- 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);
598815 }
599
- cameraView.ToggleFullScreen();
816
+ frame.validate();
600817 }
601818
602819 private JTextPane createTextPane()
....@@ -737,7 +954,12 @@
737954 JCheckBox speedupCB;
738955 JCheckBox rewindCB;
739956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
740961 JComboBox texresMenu;
962
+
741963 JButton resetButton;
742964 JButton stepButton;
743965 JButton stepAllButton;
....@@ -746,10 +968,13 @@
746968 JButton fasterButton;
747969 JButton remarkButton;
748970
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
749974 cGridBag namePanel;
750975 cGridBag setupPanel;
751976 cGridBag setupPanel2;
752
- cGridBag commandsPanel;
977
+ cGridBag objectCommandsPanel;
753978 cGridBag pushPanel;
754979 cGridBag fillPanel;
755980
....@@ -921,12 +1146,12 @@
9211146 namePanel = new cGridBag();
9221147
9231148 nameField = AddText(namePanel, copy.GetName());
924
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9251150 oe.ctrlPanel.add(namePanel);
9261151
9271152 oe.ctrlPanel.Return();
9281153
929
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
9301155 return;
9311156
9321157 setupPanel = new cGridBag().setVertical(false);
....@@ -939,20 +1164,21 @@
9391164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9401165 hideCB.setToolTipText("Hide object");
9411166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
942
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
9431168
9441169 setupPanel2 = new cGridBag().setVertical(false);
9451170
9461171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9471172 rewindCB.setToolTipText("Rewind animation");
9481173
949
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
950
- randomCB.setToolTipText("Rewind or Go back and forth randomly");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9511176
1177
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1178
+ link2masterCB.setToolTipText("Attach to support");
1179
+
9521180 if (Globals.ADVANCED)
9531181 {
954
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
955
- link2masterCB.setToolTipText("Attach to support");
9561182 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9571183 speedupCB.setToolTipText("Option motion capture");
9581184 }
....@@ -962,23 +1188,23 @@
9621188 oe.ctrlPanel.add(setupPanel2);
9631189 oe.ctrlPanel.Return();
9641190
965
- commandsPanel = new cGridBag().setVertical(false);
1191
+ objectCommandsPanel = new cGridBag().setVertical(false);
9661192
967
- resetButton = AddButton(commandsPanel, "Reset");
1193
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9681194 resetButton.setToolTipText("Jump to frame zero");
969
- stepButton = AddButton(commandsPanel, "Step");
1195
+ stepButton = AddButton(objectCommandsPanel, "Step");
9701196 stepButton.setToolTipText("Step one frame");
9711197 // resetAllButton = AddButton(oe, "Reset All");
9721198 // stepAllButton = AddButton(oe, "Step All");
9731199 // Return();
974
- slowerButton = AddButton(commandsPanel, "Slow");
1200
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9751201 slowerButton.setToolTipText("Decrease animation speed");
976
- fasterButton = AddButton(commandsPanel, "Fast");
1202
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9771203 fasterButton.setToolTipText("Increase animation speed");
978
- remarkButton = AddButton(commandsPanel, "Remark");
1204
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9791205 remarkButton.setToolTipText("Set the current transform as the target");
9801206
981
- oe.ctrlPanel.add(commandsPanel);
1207
+ oe.ctrlPanel.add(objectCommandsPanel);
9821208 oe.ctrlPanel.Return();
9831209
9841210 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1184,8 +1410,11 @@
11841410 //worldPanel.setName("World");
11851411 centralPanel = new cGridBag();
11861412 centralPanel.preferredWidth = 20;
1187
- timelinePanel = new JPanel(new BorderLayout());
1188
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1413
+
1414
+ if (Globals.ADVANCED)
1415
+ {
1416
+ timelinePanel = new JPanel(new BorderLayout());
1417
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11891418
11901419 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11911420 cameraPanel.setContinuousLayout(true);
....@@ -1194,7 +1423,10 @@
11941423 // cameraPanel.setDividerSize(9);
11951424 cameraPanel.setResizeWeight(1.0);
11961425
1426
+ }
1427
+
11971428 centralPanel.add(cameraView);
1429
+ centralPanel.setFocusable(true);
11981430 //frame.setJMenuBar(timelineMenubar);
11991431 //centralPanel.add(timelinePanel);
12001432
....@@ -1261,8 +1493,12 @@
12611493 // north.setName("Edit");
12621494 // north.add(ctrlPanel, BorderLayout.NORTH);
12631495 // objectPanel.add(north);
1264
- objectPanel.add(ctrlPanel);
1265
- objectPanel.add(infoPanel);
1496
+ objectPanel.add(editPanel);
1497
+
1498
+ //if (Globals.ADVANCED)
1499
+ objectPanel.add(infoPanel);
1500
+
1501
+ objectPanel.add(toolboxPanel);
12661502
12671503 /*
12681504 aConstraints.gridx = 0;
....@@ -1271,7 +1507,7 @@
12711507 aConstraints.gridy += 1;
12721508 aConstraints.gridwidth = 1;
12731509 mainPanel.add(objectPanel, aConstraints);
1274
- */
1510
+ */
12751511
12761512 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12771513 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1288,9 +1524,7 @@
12881524 JTabbedPane tabbedPane = new JTabbedPane();
12891525 tabbedPane.add(scrollpane);
12901526
1291
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1292
-
1293
- optionsPanel = new cGridBag().setVertical(true);
1527
+ optionsPanel = new cGridBag().setVertical(false);
12941528
12951529 optionsPanel.setName("Options");
12961530
....@@ -1298,6 +1532,8 @@
12981532
12991533 tabbedPane.add(optionsPanel);
13001534
1535
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1536
+
13011537 scenePanel.add(tabbedPane);
13021538
13031539 /*
....@@ -1370,9 +1606,9 @@
13701606 // aConstraints.gridheight = 1;
13711607
13721608 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1373
- framePanel.setContinuousLayout(true);
1374
- framePanel.setOneTouchExpandable(true);
1375
- framePanel.setDividerLocation(0.8);
1609
+ framePanel.setContinuousLayout(false);
1610
+ framePanel.setOneTouchExpandable(false);
1611
+ //.setDividerLocation(0.8);
13761612 //framePanel.setDividerSize(15);
13771613 //framePanel.setResizeWeight(0.15);
13781614 framePanel.setName("Frame");
....@@ -1390,9 +1626,14 @@
13901626 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13911627
13921628 frame.setSize(1280, 860);
1393
- frame.setVisible(true);
1394
-
1629
+
1630
+ cameraView.requestFocusInWindow();
1631
+
13951632 gridPanel.setDividerLocation(1.0);
1633
+
1634
+ frame.validate();
1635
+
1636
+ frame.setVisible(true);
13961637
13971638 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13981639 frame.addWindowListener(new WindowAdapter()
....@@ -1479,24 +1720,6 @@
14791720 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14801721 colorSection.add(texture);
14811722
1482
- cGridBag anisoU = new cGridBag();
1483
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1484
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoU);
1487
-
1488
- cGridBag anisoV = new cGridBag();
1489
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1490
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1492
- colorSection.add(anisoV);
1493
-
1494
- cGridBag shadowbias = new cGridBag();
1495
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1496
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1497
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1498
- colorSection.add(shadowbias);
1499
-
15001723 panel.add(new JSeparator());
15011724
15021725 panel.add(colorSection);
....@@ -1546,6 +1769,12 @@
15461769 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15471770 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15481771 diffuseSection.add(fakedepth);
1772
+
1773
+ cGridBag shadowbias = new cGridBag();
1774
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1775
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1776
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1777
+ diffuseSection.add(shadowbias);
15491778
15501779 panel.add(new JSeparator());
15511780
....@@ -1597,6 +1826,18 @@
15971826 // aConstraints.gridy += 1;
15981827 // aConstraints.gridwidth = 1;
15991828
1829
+ cGridBag anisoU = new cGridBag();
1830
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1831
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1832
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1833
+ specularSection.add(anisoU);
1834
+
1835
+ cGridBag anisoV = new cGridBag();
1836
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1837
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1838
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1839
+ specularSection.add(anisoV);
1840
+
16001841
16011842 panel.add(new JSeparator());
16021843
....@@ -1604,35 +1845,35 @@
16041845
16051846 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16061847
1607
- cGridBag globalSection = new cGridBag().setVertical(true);
1848
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16081849
16091850 cGridBag camera = new cGridBag();
16101851 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16111852 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121853 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(camera);
1854
+ colorSection.add(camera);
16141855
16151856 cGridBag ambient = new cGridBag();
16161857 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16171858 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181859 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(ambient);
1860
+ colorSection.add(ambient);
16201861
16211862 cGridBag backlit = new cGridBag();
16221863 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16231864 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241865 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(backlit);
1866
+ colorSection.add(backlit);
16261867
16271868 cGridBag opacity = new cGridBag();
16281869 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16291870 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16301871 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1631
- globalSection.add(opacity);
1872
+ colorSection.add(opacity);
16321873
1633
- panel.add(new JSeparator());
1874
+ //panel.add(new JSeparator());
16341875
1635
- panel.add(globalSection);
1876
+ //panel.add(globalSection);
16361877
16371878 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16381879
....@@ -1739,8 +1980,9 @@
17391980 // 3D models
17401981 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17411982 {
1742
- lastConverter = new com.jmex.model.converters.MaxToJme();
1743
- LoadFile(filename, lastConverter);
1983
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1984
+ //LoadFile(filename, lastConverter);
1985
+ LoadObjFile(filename); // New 3ds loader
17441986 continue;
17451987 }
17461988 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2466,6 +2708,7 @@
24662708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24672709 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24682710 }
2711
+
24692712 //cJME.count++;
24702713 //cJME.count %= 12;
24712714 if (gc)
....@@ -2649,6 +2892,7 @@
26492892 }
26502893 }
26512894 }
2895
+
26522896 cFileSystemPane FSPane;
26532897
26542898 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2702,11 +2946,14 @@
27022946 }
27032947 }
27042948 }
2949
+
27052950 freezematerial = false;
27062951 }
27072952
27082953 void SetMaterial(Object3D object)
27092954 {
2955
+ latestObject = object;
2956
+
27102957 cMaterial mat = object.material;
27112958
27122959 if (mat == null)
....@@ -2818,12 +3065,17 @@
28183065 // }
28193066
28203067 /**/
2821
- if (deselect)
3068
+ if (deselect || child == null)
28223069 {
28233070 //group.deselectAll();
28243071 //freeze = true;
28253072 GetTree().clearSelection();
28263073 //freeze = false;
3074
+
3075
+ if (child == null)
3076
+ {
3077
+ return;
3078
+ }
28273079 }
28283080
28293081 //group.addSelectee(child);
....@@ -2892,7 +3144,7 @@
28923144 cameraView.ToggleDL();
28933145 cameraView.repaint();
28943146 return;
2895
- } else if (event.getSource() == toggleTextureItem)
3147
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28963148 {
28973149 cameraView.ToggleTexture();
28983150 // june 2013 copy.HardTouch();
....@@ -2931,7 +3183,7 @@
29313183 frame.validate();
29323184
29333185 return;
2934
- } else if (event.getSource() == toggleSwitchItem)
3186
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29353187 {
29363188 cameraView.ToggleSwitch();
29373189 cameraView.repaint();
....@@ -3147,9 +3399,9 @@
31473399 {
31483400 Close();
31493401 //return true;
3150
- } else if (source == loadItem)
3402
+ } else if (source == openItem)
31513403 {
3152
- load();
3404
+ Open();
31533405 //return true;
31543406 } else if (source == newItem)
31553407 {
....@@ -3174,6 +3426,10 @@
31743426 {
31753427 generatePOV();
31763428 //return true;
3429
+ } else if (event.getSource() == archiveItem)
3430
+ {
3431
+ cTools.Archive(frame);
3432
+ return;
31773433 } else if (source == zBufferItem)
31783434 {
31793435 try
....@@ -3225,8 +3481,8 @@
32253481 try
32263482 {
32273483 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3228
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3229
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3484
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3485
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32303486
32313487 Object3D parent = o.parent;
32323488 o.parent = null;
....@@ -3237,10 +3493,14 @@
32373493
32383494 out.flush();
32393495
3240
- zstream.close();
3496
+ baos //zstream
3497
+ .close();
32413498 out.close();
32423499
3243
- return baos.toByteArray();
3500
+ byte[] bytes = baos.toByteArray();
3501
+
3502
+ System.out.println("save #bytes = " + bytes.length);
3503
+ return bytes;
32443504 } catch (Exception e)
32453505 {
32463506 System.err.println(e);
....@@ -3250,13 +3510,16 @@
32503510
32513511 static public Object Uncompress(byte[] bytes)
32523512 {
3253
- System.out.println("#bytes = " + bytes.length);
3513
+ System.out.println("restore #bytes = " + bytes.length);
32543514 try
32553515 {
32563516 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3257
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3258
- ObjectInputStream in = new ObjectInputStream(istream);
3517
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3518
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32593519 Object obj = in.readObject();
3520
+
3521
+ bais //istream
3522
+ .close();
32603523 in.close();
32613524
32623525 return obj;
....@@ -3315,6 +3578,29 @@
33153578
33163579 public void Save()
33173580 {
3581
+ Save(true);
3582
+ }
3583
+
3584
+ private boolean Equal(byte[] compress, byte[] name)
3585
+ {
3586
+ if (compress.length != name.length)
3587
+ {
3588
+ return false;
3589
+ }
3590
+
3591
+ for (int i=compress.length; --i>=0;)
3592
+ {
3593
+ if (compress[i] != name[i])
3594
+ return false;
3595
+ }
3596
+
3597
+ return true;
3598
+ }
3599
+
3600
+ public boolean Save(boolean user)
3601
+ {
3602
+ System.err.println("Save");
3603
+
33183604 cRadio tab = GetCurrentTab();
33193605
33203606 boolean temp = CameraPane.SWITCH;
....@@ -3322,20 +3608,42 @@
33223608
33233609 copy.ExtractBigData(hashtable);
33243610
3325
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3326
- tab.graphs[tab.undoindex++] = Compress(copy);
3327
-
3328
- copy.RestoreBigData(hashtable);
3611
+ byte[] compress = Compress(copy);
33293612
33303613 CameraPane.SWITCH = temp;
33313614
3615
+ boolean thesame = false;
3616
+
3617
+ // Quick heuristic using length. Works only when stream is compressed.
3618
+ if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3619
+ {
3620
+ thesame = true;
3621
+ }
3622
+
3623
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3624
+ if (!thesame)
3625
+ {
3626
+ //tab.user[tab.undoindex] = user;
3627
+ boolean increment = tab.graphs[tab.undoindex] == null;
3628
+
3629
+ tab.graphs[tab.undoindex] = compress;
3630
+
3631
+ if (increment)
3632
+ tab.undoindex++;
3633
+ }
3634
+
3635
+ copy.RestoreBigData(hashtable);
3636
+
33323637 //assert(hashtable.isEmpty());
33333638
33343639 for (int i = tab.undoindex; i < tab.graphs.length; i++)
33353640 {
3336
- tab.graphs[i] = null;
3641
+ //tab.user[i] = false;
3642
+ // tab.graphs[i] = null;
33373643 }
33383644
3645
+ SetUndoStates();
3646
+
33393647 // test save
33403648 if (false)
33413649 {
....@@ -3354,10 +3662,14 @@
33543662 e.printStackTrace();
33553663 }
33563664 }
3665
+
3666
+ return !thesame;
33573667 }
33583668
33593669 void CopyChanged(Object3D obj)
33603670 {
3671
+ SetUndoStates();
3672
+
33613673 boolean temp = CameraPane.SWITCH;
33623674 CameraPane.SWITCH = false;
33633675
....@@ -3397,25 +3709,47 @@
33973709 refreshContents();
33983710 }
33993711
3400
- public void Undo()
3712
+ cButton undoButton;
3713
+ cButton redoButton;
3714
+
3715
+ void SetUndoStates()
34013716 {
3717
+ cRadio tab = GetCurrentTab();
3718
+
3719
+ undoButton.setEnabled(tab.undoindex > 0);
3720
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3721
+ }
3722
+
3723
+ public boolean Undo()
3724
+ {
3725
+ System.err.println("Undo");
3726
+
34023727 cRadio tab = GetCurrentTab();
34033728
34043729 if (tab.undoindex == 0)
34053730 {
34063731 java.awt.Toolkit.getDefaultToolkit().beep();
3407
- return;
3732
+ return false;
34083733 }
34093734
3410
- if (tab.graphs[tab.undoindex] == null)
3735
+ if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
34113736 {
3412
- Save();
3413
- tab.undoindex -= 1;
3737
+ if (Save(false))
3738
+ tab.undoindex -= 1;
3739
+ else
3740
+ {
3741
+ if (tab.undoindex <= 0)
3742
+ return false;
3743
+ else
3744
+ tab.undoindex -= 1;
3745
+ }
34143746 }
34153747
34163748 tab.undoindex -= 1;
34173749
34183750 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3751
+
3752
+ return true;
34193753 }
34203754
34213755 public void Redo()
....@@ -3431,6 +3765,9 @@
34313765 tab.undoindex += 1;
34323766
34333767 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3768
+
3769
+ //if (!tab.user[tab.undoindex])
3770
+ // tab.graphs[tab.undoindex] = null;
34343771 }
34353772
34363773 void ImportGFD()
....@@ -3582,7 +3919,7 @@
35823919 assert false;
35833920 }
35843921
3585
- void EditSelection()
3922
+ void EditSelection(boolean newWindow)
35863923 {
35873924 }
35883925
....@@ -4077,7 +4414,8 @@
40774414
40784415 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40794416 {
4080
- Save();
4417
+ if (Globals.SAVEONMAKE) // && resetmodel)
4418
+ Save();
40814419 //Tween.set(thing, 0).target(1).start(tweenManager);
40824420 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40834421 // if (thing instanceof GenericJointDemo)
....@@ -4164,6 +4502,12 @@
41644502 {
41654503 ResetModel();
41664504 Select(thing.GetTreePath(), true, false); // unselect... false);
4505
+
4506
+ if (thing.Size() == 0)
4507
+ {
4508
+ //EditSelection(false);
4509
+ }
4510
+
41674511 refreshContents();
41684512 }
41694513
....@@ -4386,7 +4730,8 @@
43864730
43874731 if (readobj != null)
43884732 {
4389
- Save();
4733
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4734
+ // Save();
43904735 try
43914736 {
43924737 //readobj.deepCopySelf(copy);
....@@ -4447,7 +4792,7 @@
44474792 }
44484793 }
44494794
4450
- void load() // throws ClassNotFoundException
4795
+ void Open() // throws ClassNotFoundException
44514796 {
44524797 if (Grafreed.standAlone)
44534798 {
....@@ -4564,6 +4909,8 @@
45644909 String filename = browser.getFile();
45654910 if (filename != null && filename.length() > 0)
45664911 {
4912
+ if (!filename.endsWith(".gfd"))
4913
+ filename += ".gfd";
45674914 lastname = browser.getDirectory() + filename;
45684915 save();
45694916 }
....@@ -4730,7 +5077,7 @@
47305077 MenuBar menuBar;
47315078 Menu fileMenu;
47325079 MenuItem newItem;
4733
- MenuItem loadItem;
5080
+ MenuItem openItem;
47345081 MenuItem saveItem;
47355082 MenuItem saveAsItem;
47365083 MenuItem exportAsItem;
....@@ -4753,22 +5100,36 @@
47535100 CheckboxMenuItem toggleSwitchItem;
47545101 CheckboxMenuItem toggleRootItem;
47555102 CheckboxMenuItem animationItem;
5103
+ MenuItem archiveItem;
47565104 CheckboxMenuItem toggleHandleItem;
47575105 CheckboxMenuItem togglePaintItem;
47585106 JSplitPane mainPanel;
47595107 JScrollPane scrollpane;
5108
+
47605109 JPanel toolbarPanel;
5110
+
47615111 cGridBag treePanel;
5112
+
47625113 JPanel radioPanel;
47635114 ButtonGroup buttonGroup;
4764
- cGridBag ctrlPanel;
5115
+
5116
+ cGridBag toolboxPanel;
47655117 cGridBag materialPanel;
5118
+ cGridBag ctrlPanel;
5119
+
47665120 JScrollPane infoPanel;
5121
+
47675122 cGridBag optionsPanel;
5123
+
47685124 JTabbedPane objectPanel;
5125
+ boolean materialFlushed;
5126
+ Object3D latestObject;
5127
+
47695128 cGridBag XYZPanel;
5129
+
47705130 JSplitPane gridPanel;
47715131 JSplitPane bigPanel;
5132
+
47725133 cGridBag bigThree;
47735134 cGridBag scenePanel;
47745135 cGridBag centralPanel;
....@@ -4883,7 +5244,7 @@
48835244 cNumberSlider fogField;
48845245 JLabel opacityPowerLabel;
48855246 cNumberSlider opacityPowerField;
4886
- JTree jTree;
5247
+ cTree jTree;
48875248 //ObjectUI parent;
48885249
48895250 cNumberSlider normalpushField;