Normand Briere
2019-08-01 c99d954f5e2bffa601c599142371cfeb45630f40
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -38,64 +41,78 @@
3841 JFrame frame;
3942
4043 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4152
4253 cButton GetButton(String name, boolean border)
4354 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
47
- return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
51
- return new cButton(name, border);
52
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5363 }
5464
5565 cToggleButton GetToggleButton(String name, boolean border)
5666 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6669 }
6770
6871 cCheckBox GetCheckBox(String name, boolean border)
6972 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7079 try
7180 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7497 }
7598 catch (Exception e)
7699 {
77
- return new cCheckBox(name, border);
100
+ return null;
78101 }
79102 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
82105 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
86107 {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
95111 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
99116 }
100117
101118 // SCRIPT
....@@ -279,6 +296,12 @@
279296 client = inClient;
280297 copy = client;
281298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new byte[100][];
302
+ copy.versionindex = -1;
303
+ }
304
+
282305 // "this" is not called: SetupUI2(objEditor);
283306 }
284307
....@@ -292,6 +315,12 @@
292315 client = inClient;
293316 copy = client;
294317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new byte[100][];
321
+ copy.versionindex = -1;
322
+ }
323
+
295324 SetupUI2(callee.GetEditor());
296325 }
297326
....@@ -306,7 +335,7 @@
306335 //localCopy.parent = null;
307336
308337 frame = new JFrame();
309
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
310339 objEditor = this;
311340 this.callee = callee;
312341
....@@ -324,6 +353,12 @@
324353 copy = localCopy;
325354 copy.editWindow = this;
326355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
327362 SetupMenu();
328363
329364 //SetupName(objEditor); // new
....@@ -347,7 +382,7 @@
347382 frame.setMenuBar(menuBar = new MenuBar());
348383 menuBar.add(fileMenu = new Menu("File"));
349384 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
351386
352387 //oe.menuBar.add(menu = new Menu("Include"));
353388 Menu menu = new Menu("Import");
....@@ -379,7 +414,7 @@
379414 }
380415
381416 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
383418 saveItem.addActionListener(this);
384419 saveAsItem.addActionListener(this);
385420 exportAsItem.addActionListener(this);
....@@ -416,11 +451,12 @@
416451
417452 toolbarPanel = new JPanel();
418453 toolbarPanel.setName("Toolbar");
454
+
419455 treePanel = new cGridBag();
420456 treePanel.setName("Tree");
421457
422458 editPanel = new cGridBag().setVertical(true);
423
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
424460
425461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
426462
....@@ -428,11 +464,11 @@
428464 editPanel.add(editCommandsPanel);
429465 editPanel.add(ctrlPanel);
430466
431
- toolboxPanel = new cGridBag().setVertical(false);
432
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
433469
434470 materialPanel = new cGridBag().setVertical(true);
435
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
436472
437473 /*JTextPane*/
438474 infoarea = createTextPane();
....@@ -440,14 +476,15 @@
440476
441477 infoarea.setEditable(true);
442478 SetText();
479
+
443480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
444481 // infoarea.setOpaque(false);
445482 // //infoarea.setForeground(textcolor);
446483 // TEXTAREA infoarea.setLineWrap(true);
447484 // TEXTAREA infoarea.setWrapStyleWord(true);
448485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
449
- infoPanel.setPreferredSize(new Dimension(50, 200));
450
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
451488 //infoPanel.setLayout(new BorderLayout());
452489 //infoPanel.add(createTextPane());
453490
....@@ -458,7 +495,14 @@
458495 mainPanel.setDividerSize(9);
459496 mainPanel.setDividerLocation(0.5); //1.0);
460497 mainPanel.setResizeWeight(0.5);
461
-
498
+
499
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
500
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
501
+ divider.setDividerSize(15);
502
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
503
+
504
+ mainPanel.setUI(new BasicSplitPaneUI());
505
+
462506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463507 //mainPanel.setLayout(new GridBagLayout());
464508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +733,8 @@
689733 }
690734 }
691735
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694738
695739 Rectangle keeprect;
696740 cRadio radio;
....@@ -711,10 +755,19 @@
711755 void Minimize()
712756 {
713757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
714759 }
715760
761
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
762
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
763
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
716764 void Maximize()
717765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
718771 if (maximized)
719772 {
720773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +775,36 @@
722775 else
723776 {
724777 keeprect = frame.getBounds();
725
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
- Dimension rect2 = frame.getToolkit().getScreenSize();
727
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
728781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729783 }
730784
731785 maximized ^= true;
786
+
787
+ frame.validate();
732788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
733793
734794 void ToggleFullScreen()
735795 {
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
736798 cameraView.ToggleFullScreen();
737799
738800 if (!CameraPane.FULLSCREEN)
739801 {
740802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
741808 //frame.setVisible(false);
742809 // frame.removeNotify();
743810 // frame.setUndecorated(false);
....@@ -747,7 +814,7 @@
747814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748815 // X framePanel.add(bigThree);
749816 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
751818
752819 //frame.setVisible(true);
753820 radio.layout = keepButton;
....@@ -762,7 +829,12 @@
762829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763830 // frame.getToolkit().getScreenSize().height);
764831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
765835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
766838 // frame.removeNotify();
767839 // frame.setUndecorated(true);
768840 // frame.addNotify();
....@@ -775,7 +847,30 @@
775847 radio.layout.doClick();
776848 //frame.setVisible(true);
777849 }
850
+ frame.validate();
778851 }
852
+
853
+ private byte[] CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ byte[] versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ byte[] compress = Compress(copy);
865
+
866
+ copy.versions = versions;
867
+
868
+ copy.RestoreBigData(versiontable);
869
+
870
+ CameraPane.SWITCH = temp;
871
+
872
+ return compress;
873
+ }
779874
780875 private JTextPane createTextPane()
781876 {
....@@ -907,7 +1002,7 @@
9071002 // NumberSlider vDivsField;
9081003 // JCheckBox endcaps;
9091004 JCheckBox liveCB;
910
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
9111006 JCheckBox hideCB;
9121007 JCheckBox link2masterCB;
9131008 JCheckBox markCB;
....@@ -1107,7 +1202,7 @@
11071202 namePanel = new cGridBag();
11081203
11091204 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1205
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111206 oe.ctrlPanel.add(namePanel);
11121207
11131208 oe.ctrlPanel.Return();
....@@ -1119,26 +1214,30 @@
11191214
11201215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11211216 liveCB.setToolTipText("Animate object");
1122
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1123
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
11241219 // Return();
1220
+
11251221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261222 hideCB.setToolTipText("Hide object");
11271223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1224
+ markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11291227
11301228 setupPanel2 = new cGridBag().setVertical(false);
11311229
11321230 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331231 rewindCB.setToolTipText("Rewind animation");
11341232
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1233
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1234
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371235
1236
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1237
+ link2masterCB.setToolTipText("Attach to support");
1238
+
11381239 if (Globals.ADVANCED)
11391240 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421241 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431242 speedupCB.setToolTipText("Option motion capture");
11441243 }
....@@ -1412,6 +1511,7 @@
14121511 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14131512 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14141513 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1514
+ //XYZPanel.setName("XYZ");
14151515
14161516 /*
14171517 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1449,13 +1549,29 @@
14491549 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14501550 //tmp.setName("Edit");
14511551 objectPanel.add(materialPanel);
1552
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
14521555 // JPanel north = new JPanel(new BorderLayout());
14531556 // north.setName("Edit");
14541557 // north.add(ctrlPanel, BorderLayout.NORTH);
14551558 // objectPanel.add(north);
14561559 objectPanel.add(editPanel);
1457
- objectPanel.add(infoPanel);
1560
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1562
+
1563
+ //if (Globals.ADVANCED)
1564
+ objectPanel.add(infoPanel);
1565
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
1567
+
1568
+ objectPanel.add(XYZPanel);
1569
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1571
+
14581572 objectPanel.add(toolboxPanel);
1573
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
14591575
14601576 /*
14611577 aConstraints.gridx = 0;
....@@ -1476,7 +1592,7 @@
14761592 scrollpane.addMouseWheelListener(this); // Default not fast enough
14771593
14781594 /*JTabbedPane*/ scenePanel = new cGridBag();
1479
- scenePanel.preferredWidth = 6;
1595
+ scenePanel.preferredWidth = 5;
14801596
14811597 JTabbedPane tabbedPane = new JTabbedPane();
14821598 tabbedPane.add(scrollpane);
....@@ -1554,7 +1670,7 @@
15541670 bigThree = new cGridBag();
15551671 bigThree.addComponent(scenePanel);
15561672 bigThree.addComponent(centralPanel);
1557
- bigThree.addComponent(XYZPanel);
1673
+ //bigThree.addComponent(XYZPanel);
15581674
15591675 // // SIDE EFFECT!!!
15601676 // aConstraints.gridx = 0;
....@@ -1563,9 +1679,9 @@
15631679 // aConstraints.gridheight = 1;
15641680
15651681 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1682
+ framePanel.setContinuousLayout(false);
1683
+ framePanel.setOneTouchExpandable(false);
1684
+ //.setDividerLocation(0.8);
15691685 //framePanel.setDividerSize(15);
15701686 //framePanel.setResizeWeight(0.15);
15711687 framePanel.setName("Frame");
....@@ -1584,17 +1700,17 @@
15841700
15851701 frame.setSize(1280, 860);
15861702
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901703 cameraView.requestFocusInWindow();
15911704
15921705 gridPanel.setDividerLocation(1.0);
1706
+
1707
+ frame.validate();
1708
+
1709
+ frame.setVisible(true);
15931710
15941711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15951712 frame.addWindowListener(new WindowAdapter()
15961713 {
1597
-
15981714 public void windowClosing(WindowEvent e)
15991715 {
16001716 Close();
....@@ -1656,45 +1772,48 @@
16561772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16571773
16581774 cGridBag colorSection = new cGridBag().setVertical(true);
1775
+
1776
+ cGridBag huepanel = new cGridBag();
1777
+ cGridBag huelabel = new cGridBag();
1778
+ huelabel.add(GetLabel("icons/hue.png", false));
1779
+ huelabel.preferredWidth = 20;
1780
+ huepanel.add(new cGridBag()); // Label
1781
+ huepanel.add(huelabel); // Field/slider
1782
+
1783
+ huepanel.preferredHeight = 7;
1784
+
1785
+ colorSection.add(huepanel);
16591786
16601787 cGridBag color = new cGridBag();
1661
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1662
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1788
+
1789
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1790
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1791
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1792
+
16641793 //colorField.preferredWidth = 200;
16651794 colorSection.add(color);
16661795
16671796 cGridBag modulation = new cGridBag();
16681797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16691798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1670
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16711800 colorSection.add(modulation);
16721801
1802
+ cGridBag opacity = new cGridBag();
1803
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1804
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1805
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1806
+ colorSection.add(opacity);
1807
+
1808
+ colorSection.add(GetSeparator());
1809
+
16731810 cGridBag texture = new cGridBag();
16741811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16751812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16761813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16771814 colorSection.add(texture);
16781815
1679
- cGridBag anisoU = new cGridBag();
1680
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
- colorSection.add(anisoU);
1684
-
1685
- cGridBag anisoV = new cGridBag();
1686
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
- colorSection.add(anisoV);
1690
-
1691
- cGridBag shadowbias = new cGridBag();
1692
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
- colorSection.add(shadowbias);
1696
-
1697
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
16981817
16991818 panel.add(colorSection);
17001819
....@@ -1744,7 +1863,13 @@
17441863 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17451864 diffuseSection.add(fakedepth);
17461865
1747
- panel.add(new JSeparator());
1866
+ cGridBag shadowbias = new cGridBag();
1867
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1868
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1869
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1870
+ diffuseSection.add(shadowbias);
1871
+
1872
+ panel.add(GetSeparator());
17481873
17491874 panel.add(diffuseSection);
17501875
....@@ -1794,42 +1919,48 @@
17941919 // aConstraints.gridy += 1;
17951920 // aConstraints.gridwidth = 1;
17961921
1922
+ cGridBag anisoU = new cGridBag();
1923
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1924
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1925
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1926
+ specularSection.add(anisoU);
17971927
1798
- panel.add(new JSeparator());
1928
+ cGridBag anisoV = new cGridBag();
1929
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1930
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1931
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1932
+ specularSection.add(anisoV);
1933
+
1934
+
1935
+ panel.add(GetSeparator());
17991936
18001937 panel.add(specularSection);
18011938
18021939 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18031940
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
1941
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18051942
18061943 cGridBag camera = new cGridBag();
18071944 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18081945 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18091946 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
1947
+ colorSection.add(camera);
18111948
18121949 cGridBag ambient = new cGridBag();
18131950 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18141951 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18151952 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
1953
+ colorSection.add(ambient);
18171954
18181955 cGridBag backlit = new cGridBag();
18191956 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18201957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18211958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
1959
+ colorSection.add(backlit);
18231960
1824
- cGridBag opacity = new cGridBag();
1825
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1826
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1827
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1829
-
1830
- panel.add(new JSeparator());
1961
+ //panel.add(new JSeparator());
18311962
1832
- panel.add(globalSection);
1963
+ //panel.add(globalSection);
18331964
18341965 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18351966
....@@ -1871,7 +2002,7 @@
18712002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18722003 textureSection.add(opacityPower);
18732004
1874
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
18752006
18762007 panel.add(textureSection);
18772008
....@@ -1936,8 +2067,9 @@
19362067 // 3D models
19372068 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382069 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2070
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2071
+ //LoadFile(filename, lastConverter);
2072
+ LoadObjFile(filename); // New 3ds loader
19412073 continue;
19422074 }
19432075 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +2795,7 @@
26632795 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26642796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26652797 }
2798
+
26662799 //cJME.count++;
26672800 //cJME.count %= 12;
26682801 if (gc)
....@@ -2846,6 +2979,7 @@
28462979 }
28472980 }
28482981 }
2982
+
28492983 cFileSystemPane FSPane;
28502984
28512985 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2899,6 +3033,7 @@
28993033 }
29003034 }
29013035 }
3036
+
29023037 freezematerial = false;
29033038 }
29043039
....@@ -3017,12 +3152,17 @@
30173152 // }
30183153
30193154 /**/
3020
- if (deselect)
3155
+ if (deselect || child == null)
30213156 {
30223157 //group.deselectAll();
30233158 //freeze = true;
30243159 GetTree().clearSelection();
30253160 //freeze = false;
3161
+
3162
+ if (child == null)
3163
+ {
3164
+ return;
3165
+ }
30263166 }
30273167
30283168 //group.addSelectee(child);
....@@ -3161,7 +3301,7 @@
31613301 {
31623302 copy.live ^= true;
31633303 return;
3164
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
31653305 {
31663306 copy.dontselect ^= true;
31673307 return;
....@@ -3346,9 +3486,9 @@
33463486 {
33473487 Close();
33483488 //return true;
3349
- } else if (source == loadItem)
3489
+ } else if (source == openItem)
33503490 {
3351
- load();
3491
+ Open();
33523492 //return true;
33533493 } else if (source == newItem)
33543494 {
....@@ -3373,6 +3513,10 @@
33733513 {
33743514 generatePOV();
33753515 //return true;
3516
+ } else if (event.getSource() == archiveItem)
3517
+ {
3518
+ cTools.Archive(frame);
3519
+ return;
33763520 } else if (source == zBufferItem)
33773521 {
33783522 try
....@@ -3424,8 +3568,8 @@
34243568 try
34253569 {
34263570 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3571
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3572
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34293573
34303574 Object3D parent = o.parent;
34313575 o.parent = null;
....@@ -3436,10 +3580,14 @@
34363580
34373581 out.flush();
34383582
3439
- zstream.close();
3583
+ baos //zstream
3584
+ .close();
34403585 out.close();
34413586
3442
- return baos.toByteArray();
3587
+ byte[] bytes = baos.toByteArray();
3588
+
3589
+ System.out.println("save #bytes = " + bytes.length);
3590
+ return bytes;
34433591 } catch (Exception e)
34443592 {
34453593 System.err.println(e);
....@@ -3449,13 +3597,16 @@
34493597
34503598 static public Object Uncompress(byte[] bytes)
34513599 {
3452
- System.out.println("#bytes = " + bytes.length);
3600
+ System.out.println("restore #bytes = " + bytes.length);
34533601 try
34543602 {
34553603 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
3604
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3605
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34583606 Object obj = in.readObject();
3607
+
3608
+ bais //istream
3609
+ .close();
34593610 in.close();
34603611
34613612 return obj;
....@@ -3510,31 +3661,67 @@
35103661 return null;
35113662 }
35123663
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35143664
35153665 public void Save()
3666
+ {
3667
+ //Save(true);
3668
+ Replace();
3669
+ }
3670
+
3671
+ private boolean Equal(byte[] compress, byte[] name)
3672
+ {
3673
+ if (compress.length != name.length)
3674
+ {
3675
+ return false;
3676
+ }
3677
+
3678
+ for (int i=compress.length; --i>=0;)
3679
+ {
3680
+ if (compress[i] != name[i])
3681
+ return false;
3682
+ }
3683
+
3684
+ return true;
3685
+ }
3686
+
3687
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3688
+
3689
+ public boolean Save(boolean user)
35163690 {
35173691 System.err.println("Save");
35183692
35193693 cRadio tab = GetCurrentTab();
35203694
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
35233696
3524
- copy.ExtractBigData(hashtable);
3697
+ boolean thesame = false;
3698
+
3699
+ // Quick heuristic using length. Works only when stream is compressed.
3700
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3701
+ {
3702
+ thesame = true;
3703
+ }
35253704
35263705 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- tab.graphs[tab.undoindex++] = Compress(copy);
3706
+ if (!thesame)
3707
+ {
3708
+ //tab.user[tab.versionindex] = user;
3709
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3710
+
3711
+ copy.versions[++copy.versionindex] = compress;
3712
+
3713
+ // if (increment)
3714
+ // tab.versionindex++;
3715
+ }
35283716
3529
- copy.RestoreBigData(hashtable);
3717
+ //copy.RestoreBigData(versiontable);
35303718
3531
- CameraPane.SWITCH = temp;
3532
-
35333719 //assert(hashtable.isEmpty());
35343720
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3721
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35363722 {
3537
- tab.graphs[i] = null;
3723
+ //tab.user[i] = false;
3724
+ copy.versions[i] = null;
35383725 }
35393726
35403727 SetUndoStates();
....@@ -3544,7 +3731,7 @@
35443731 {
35453732 try
35463733 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3734
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35483735 ObjectOutputStream p = new ObjectOutputStream(ostream);
35493736
35503737 p.writeObject(copy);
....@@ -3557,6 +3744,8 @@
35573744 e.printStackTrace();
35583745 }
35593746 }
3747
+
3748
+ return !thesame;
35603749 }
35613750
35623751 void CopyChanged(Object3D obj)
....@@ -3566,16 +3755,19 @@
35663755 boolean temp = CameraPane.SWITCH;
35673756 CameraPane.SWITCH = false;
35683757
3569
- copy.ExtractBigData(hashtable);
3758
+ copy.ExtractBigData(versiontable);
35703759
35713760 copy.clear();
35723761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
35733765 for (int i=0; i<obj.Size(); i++)
35743766 {
35753767 copy.add(obj.get(i));
35763768 }
35773769
3578
- copy.RestoreBigData(hashtable);
3770
+ copy.RestoreBigData(versiontable);
35793771
35803772 CameraPane.SWITCH = temp;
35813773
....@@ -3603,52 +3795,129 @@
36033795 }
36043796
36053797 cButton undoButton;
3798
+ cButton restoreButton;
3799
+ cButton replaceButton;
36063800 cButton redoButton;
36073801
3802
+ boolean muteSlider;
3803
+
3804
+ int VersionCount()
3805
+ {
3806
+ int count = 0;
3807
+
3808
+ for (int i = copy.versions.length; --i >= 0;)
3809
+ {
3810
+ if (copy.versions[i] != null)
3811
+ count++;
3812
+ }
3813
+
3814
+ return count;
3815
+ }
3816
+
36083817 void SetUndoStates()
36093818 {
36103819 cRadio tab = GetCurrentTab();
36113820
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3821
+ restoreButton.setEnabled(copy.versionindex != -1);
3822
+ replaceButton.setEnabled(copy.versionindex != -1);
3823
+
3824
+ undoButton.setEnabled(copy.versionindex > 0);
3825
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3826
+
3827
+ muteSlider = true;
3828
+ versionSlider.setMaximum(VersionCount() - 1);
3829
+ versionSlider.setInteger(copy.versionindex);
3830
+ muteSlider = false;
36143831 }
36153832
3616
- public void Undo()
3833
+ public boolean Undo()
36173834 {
3835
+ // Option?
3836
+ Replace();
3837
+
36183838 System.err.println("Undo");
36193839
36203840 cRadio tab = GetCurrentTab();
36213841
3622
- if (tab.undoindex == 0)
3842
+ if (copy.versionindex == 0)
36233843 {
36243844 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
3845
+ return false;
36263846 }
36273847
3628
- if (tab.graphs[tab.undoindex] == null)
3848
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3849
+// {
3850
+// if (Save(false))
3851
+// tab.versionindex -= 1;
3852
+// else
3853
+// {
3854
+// if (tab.versionindex <= 0)
3855
+// return false;
3856
+// else
3857
+// tab.versionindex -= 1;
3858
+// }
3859
+// }
3860
+
3861
+ copy.versionindex -= 1;
3862
+
3863
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+
3865
+ return true;
3866
+ }
3867
+
3868
+ public boolean Restore()
3869
+ {
3870
+ System.err.println("Restore");
3871
+
3872
+ cRadio tab = GetCurrentTab();
3873
+
3874
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36293875 {
3630
- Save();
3631
- tab.undoindex -= 1;
3876
+ java.awt.Toolkit.getDefaultToolkit().beep();
3877
+ return false;
36323878 }
36333879
3634
- tab.undoindex -= 1;
3880
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+
3882
+ return true;
3883
+ }
36353884
3636
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3885
+ public boolean Replace()
3886
+ {
3887
+ System.err.println("Replace");
3888
+
3889
+ cRadio tab = GetCurrentTab();
3890
+
3891
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3892
+ {
3893
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3894
+ return false;
3895
+ }
3896
+
3897
+ copy.versions[copy.versionindex] = CompressCopy();
3898
+
3899
+ return true;
36373900 }
36383901
36393902 public void Redo()
36403903 {
3904
+ // Option?
3905
+ Replace();
3906
+
36413907 cRadio tab = GetCurrentTab();
36423908
3643
- if (tab.graphs[tab.undoindex + 1] == null)
3909
+ if (copy.versions[copy.versionindex + 1] == null)
36443910 {
36453911 java.awt.Toolkit.getDefaultToolkit().beep();
36463912 return;
36473913 }
36483914
3649
- tab.undoindex += 1;
3915
+ copy.versionindex += 1;
36503916
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3917
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3918
+
3919
+ //if (!tab.user[tab.versionindex])
3920
+ // tab.graphs[tab.versionindex] = null;
36523921 }
36533922
36543923 void ImportGFD()
....@@ -3944,9 +4213,25 @@
39444213 //copy.Touch();
39454214 }
39464215
4216
+ cNumberSlider versionSlider;
4217
+
39474218 public void stateChanged(ChangeEvent e)
39484219 {
39494220 // assert(false);
4221
+ if (e.getSource() == versionSlider)
4222
+ {
4223
+ if (muteSlider)
4224
+ return;
4225
+
4226
+ int version = versionSlider.getInteger();
4227
+
4228
+ if (copy.versions[version] != null)
4229
+ {
4230
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4231
+ }
4232
+
4233
+ return;
4234
+ }
39504235
39514236 if (freezematerial)
39524237 {
....@@ -4295,7 +4580,7 @@
42954580
42964581 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42974582 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
4583
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42994584 Save();
43004585 //Tween.set(thing, 0).target(1).start(tweenManager);
43014586 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4537,7 +4822,9 @@
45374822 readobj.ResetDisplayList();
45384823 } catch (Exception e)
45394824 {
4540
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
45414828 try
45424829 {
45434830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4611,12 +4898,14 @@
46114898
46124899 if (readobj != null)
46134900 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
4901
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4902
+ // Save();
46164903 try
46174904 {
46184905 //readobj.deepCopySelf(copy);
46194906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
46204909 for (int i = 0; i < readobj.size(); i++)
46214910 {
46224911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4657,6 +4946,7 @@
46574946 }
46584947 } catch (ClassCastException e)
46594948 {
4949
+ e.printStackTrace();
46604950 assert (false);
46614951 Composite c = (Composite) copy;
46624952 c.children.clear();
....@@ -4667,13 +4957,24 @@
46674957 c.addChild(csg);
46684958 }
46694959
4960
+ copy.versions = readobj.versions;
4961
+ copy.versionindex = readobj.versionindex;
4962
+
4963
+ if (copy.versions == null)
4964
+ {
4965
+ copy.versions = new byte[100][];
4966
+ copy.versionindex = -1;
4967
+ }
4968
+
4969
+ //? SetUndoStates();
4970
+
46704971 ResetModel();
46714972 copy.HardTouch(); // recompile?
46724973 refreshContents();
46734974 }
46744975 }
46754976
4676
- void load() // throws ClassNotFoundException
4977
+ void Open() // throws ClassNotFoundException
46774978 {
46784979 if (Grafreed.standAlone)
46794980 {
....@@ -4776,6 +5077,7 @@
47765077 //ps.print(buffer.toString());
47775078 } catch (IOException e)
47785079 {
5080
+ e.printStackTrace();
47795081 }
47805082 }
47815083
....@@ -4958,7 +5260,7 @@
49585260 MenuBar menuBar;
49595261 Menu fileMenu;
49605262 MenuItem newItem;
4961
- MenuItem loadItem;
5263
+ MenuItem openItem;
49625264 MenuItem saveItem;
49635265 MenuItem saveAsItem;
49645266 MenuItem exportAsItem;
....@@ -4981,6 +5283,7 @@
49815283 CheckboxMenuItem toggleSwitchItem;
49825284 CheckboxMenuItem toggleRootItem;
49835285 CheckboxMenuItem animationItem;
5286
+ MenuItem archiveItem;
49845287 CheckboxMenuItem toggleHandleItem;
49855288 CheckboxMenuItem togglePaintItem;
49865289 JSplitPane mainPanel;