Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
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.
....@@ -41,61 +44,47 @@
4144
4245 cButton GetButton(String name, boolean border)
4346 {
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
- }
47
+ ImageIcon icon = GetIcon(name);
48
+ return new cButton(icon, border);
5349 }
5450
5551 cToggleButton GetToggleButton(String name, boolean border)
5652 {
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
- }
53
+ ImageIcon icon = GetIcon(name);
54
+ return new cToggleButton(icon, border);
6655 }
6756
6857 cCheckBox GetCheckBox(String name, boolean border)
6958 {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+
63
+ ImageIcon GetIcon(String name)
64
+ {
7065 try
7166 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
67
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
68
+
69
+// if (image.getWidth() > 48 && image.getHeight() > 48)
70
+// {
71
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
72
+// Graphics2D g = resized.createGraphics();
73
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
76
+// g.dispose();
77
+//
78
+// image = resized;
79
+// }
80
+
81
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
82
+ return icon;
7483 }
7584 catch (Exception e)
7685 {
77
- return new cCheckBox(name, border);
86
+ return null;
7887 }
79
- }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
82
- {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
86
- {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
95
- }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
9988 }
10089
10190 // SCRIPT
....@@ -279,6 +268,12 @@
279268 client = inClient;
280269 copy = client;
281270
271
+ if (copy.versions == null)
272
+ {
273
+ copy.versions = new byte[100][];
274
+ copy.versionindex = -1;
275
+ }
276
+
282277 // "this" is not called: SetupUI2(objEditor);
283278 }
284279
....@@ -292,6 +287,12 @@
292287 client = inClient;
293288 copy = client;
294289
290
+ if (copy.versions == null)
291
+ {
292
+ copy.versions = new byte[100][];
293
+ copy.versionindex = -1;
294
+ }
295
+
295296 SetupUI2(callee.GetEditor());
296297 }
297298
....@@ -306,7 +307,7 @@
306307 //localCopy.parent = null;
307308
308309 frame = new JFrame();
309
- frame.setUndecorated(true);
310
+ frame.setUndecorated(false);
310311 objEditor = this;
311312 this.callee = callee;
312313
....@@ -324,6 +325,12 @@
324325 copy = localCopy;
325326 copy.editWindow = this;
326327
328
+ if (copy.versions == null)
329
+ {
330
+// copy.versions = new byte[100][];
331
+// copy.versionindex = -1;
332
+ }
333
+
327334 SetupMenu();
328335
329336 //SetupName(objEditor); // new
....@@ -347,7 +354,7 @@
347354 frame.setMenuBar(menuBar = new MenuBar());
348355 menuBar.add(fileMenu = new Menu("File"));
349356 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
357
+ fileMenu.add(openItem = new MenuItem("Open..."));
351358
352359 //oe.menuBar.add(menu = new Menu("Include"));
353360 Menu menu = new Menu("Import");
....@@ -379,7 +386,7 @@
379386 }
380387
381388 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
389
+ openItem.addActionListener(this);
383390 saveItem.addActionListener(this);
384391 saveAsItem.addActionListener(this);
385392 exportAsItem.addActionListener(this);
....@@ -416,11 +423,12 @@
416423
417424 toolbarPanel = new JPanel();
418425 toolbarPanel.setName("Toolbar");
426
+
419427 treePanel = new cGridBag();
420428 treePanel.setName("Tree");
421429
422430 editPanel = new cGridBag().setVertical(true);
423
- editPanel.setName("Edit");
431
+ //editPanel.setName("Edit");
424432
425433 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
426434
....@@ -428,11 +436,11 @@
428436 editPanel.add(editCommandsPanel);
429437 editPanel.add(ctrlPanel);
430438
431
- toolboxPanel = new cGridBag().setVertical(false);
432
- toolboxPanel.setName("Toolbox");
439
+ toolboxPanel = new cGridBag().setVertical(true);
440
+ //toolboxPanel.setName("Toolbox");
433441
434442 materialPanel = new cGridBag().setVertical(true);
435
- materialPanel.setName("Material");
443
+ //materialPanel.setName("Material");
436444
437445 /*JTextPane*/
438446 infoarea = createTextPane();
....@@ -440,14 +448,15 @@
440448
441449 infoarea.setEditable(true);
442450 SetText();
451
+
443452 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
444453 // infoarea.setOpaque(false);
445454 // //infoarea.setForeground(textcolor);
446455 // TEXTAREA infoarea.setLineWrap(true);
447456 // TEXTAREA infoarea.setWrapStyleWord(true);
448457 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");
458
+ infoPanel.setPreferredSize(new Dimension(1, 1));
459
+ //infoPanel.setName("Info");
451460 //infoPanel.setLayout(new BorderLayout());
452461 //infoPanel.add(createTextPane());
453462
....@@ -458,7 +467,14 @@
458467 mainPanel.setDividerSize(9);
459468 mainPanel.setDividerLocation(0.5); //1.0);
460469 mainPanel.setResizeWeight(0.5);
461
-
470
+
471
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
472
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
473
+ divider.setDividerSize(15);
474
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
475
+
476
+ mainPanel.setUI(new BasicSplitPaneUI());
477
+
462478 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463479 //mainPanel.setLayout(new GridBagLayout());
464480 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +705,8 @@
689705 }
690706 }
691707
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
708
+//static GraphicsDevice device = GraphicsEnvironment
709
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694710
695711 Rectangle keeprect;
696712 cRadio radio;
....@@ -711,10 +727,19 @@
711727 void Minimize()
712728 {
713729 frame.setState(Frame.ICONIFIED);
730
+ frame.validate();
714731 }
715732
733
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
734
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
735
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
716736 void Maximize()
717737 {
738
+ if (CameraPane.FULLSCREEN)
739
+ {
740
+ ToggleFullScreen();
741
+ }
742
+
718743 if (maximized)
719744 {
720745 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +747,36 @@
722747 else
723748 {
724749 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);
750
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
751
+// Dimension rect2 = frame.getToolkit().getScreenSize();
752
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
728753 // frame.setState(Frame.MAXIMIZED_BOTH);
754
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729755 }
730756
731757 maximized ^= true;
758
+
759
+ frame.validate();
732760 }
761
+
762
+ cButton minButton;
763
+ cButton maxButton;
764
+ cButton fullButton;
733765
734766 void ToggleFullScreen()
735767 {
768
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769
+
736770 cameraView.ToggleFullScreen();
737771
738772 if (!CameraPane.FULLSCREEN)
739773 {
740774 device.setFullScreenWindow(null);
775
+ frame.dispose();
776
+ frame.setUndecorated(false);
777
+ frame.validate();
778
+ frame.setVisible(true);
779
+
741780 //frame.setVisible(false);
742781 // frame.removeNotify();
743782 // frame.setUndecorated(false);
....@@ -747,7 +786,7 @@
747786 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748787 // X framePanel.add(bigThree);
749788 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
789
+ framePanel.setDividerLocation(46);
751790
752791 //frame.setVisible(true);
753792 radio.layout = keepButton;
....@@ -762,7 +801,12 @@
762801 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763802 // frame.getToolkit().getScreenSize().height);
764803 //frame.setVisible(false);
804
+
805
+ frame.dispose();
806
+ frame.setUndecorated(true);
765807 device.setFullScreenWindow(frame);
808
+ frame.validate();
809
+ frame.setVisible(true);
766810 // frame.removeNotify();
767811 // frame.setUndecorated(true);
768812 // frame.addNotify();
....@@ -775,7 +819,30 @@
775819 radio.layout.doClick();
776820 //frame.setVisible(true);
777821 }
822
+ frame.validate();
778823 }
824
+
825
+ private byte[] CompressCopy()
826
+ {
827
+ boolean temp = CameraPane.SWITCH;
828
+ CameraPane.SWITCH = false;
829
+
830
+ copy.ExtractBigData(versiontable);
831
+ // if (copy == client)
832
+
833
+ byte[] versions[] = copy.versions;
834
+ copy.versions = null;
835
+
836
+ byte[] compress = Compress(copy);
837
+
838
+ copy.versions = versions;
839
+
840
+ copy.RestoreBigData(versiontable);
841
+
842
+ CameraPane.SWITCH = temp;
843
+
844
+ return compress;
845
+ }
779846
780847 private JTextPane createTextPane()
781848 {
....@@ -907,7 +974,7 @@
907974 // NumberSlider vDivsField;
908975 // JCheckBox endcaps;
909976 JCheckBox liveCB;
910
- JCheckBox selectCB;
977
+ JCheckBox selectableCB;
911978 JCheckBox hideCB;
912979 JCheckBox link2masterCB;
913980 JCheckBox markCB;
....@@ -1107,7 +1174,7 @@
11071174 namePanel = new cGridBag();
11081175
11091176 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1177
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111178 oe.ctrlPanel.add(namePanel);
11121179
11131180 oe.ctrlPanel.Return();
....@@ -1119,26 +1186,30 @@
11191186
11201187 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11211188 liveCB.setToolTipText("Animate object");
1122
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1123
- selectCB.setToolTipText("Make object selectable");
1189
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
+ selectableCB.setToolTipText("Make object selectable");
11241191 // Return();
1192
+
11251193 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261194 hideCB.setToolTipText("Hide object");
11271195 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1196
+ markCB.setToolTipText("As animation target transform");
1197
+
1198
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11291199
11301200 setupPanel2 = new cGridBag().setVertical(false);
11311201
11321202 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331203 rewindCB.setToolTipText("Rewind animation");
11341204
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1205
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1206
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371207
1208
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1209
+ link2masterCB.setToolTipText("Attach to support");
1210
+
11381211 if (Globals.ADVANCED)
11391212 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421213 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431214 speedupCB.setToolTipText("Option motion capture");
11441215 }
....@@ -1412,6 +1483,7 @@
14121483 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14131484 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14141485 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1486
+ //XYZPanel.setName("XYZ");
14151487
14161488 /*
14171489 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1449,13 +1521,23 @@
14491521 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14501522 //tmp.setName("Edit");
14511523 objectPanel.add(materialPanel);
1524
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
14521525 // JPanel north = new JPanel(new BorderLayout());
14531526 // north.setName("Edit");
14541527 // north.add(ctrlPanel, BorderLayout.NORTH);
14551528 // objectPanel.add(north);
14561529 objectPanel.add(editPanel);
1457
- objectPanel.add(infoPanel);
1530
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1531
+
1532
+ //if (Globals.ADVANCED)
1533
+ objectPanel.add(infoPanel);
1534
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1535
+
1536
+ objectPanel.add(XYZPanel);
1537
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1538
+
14581539 objectPanel.add(toolboxPanel);
1540
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
14591541
14601542 /*
14611543 aConstraints.gridx = 0;
....@@ -1476,7 +1558,7 @@
14761558 scrollpane.addMouseWheelListener(this); // Default not fast enough
14771559
14781560 /*JTabbedPane*/ scenePanel = new cGridBag();
1479
- scenePanel.preferredWidth = 6;
1561
+ scenePanel.preferredWidth = 5;
14801562
14811563 JTabbedPane tabbedPane = new JTabbedPane();
14821564 tabbedPane.add(scrollpane);
....@@ -1552,9 +1634,9 @@
15521634 /**/
15531635
15541636 bigThree = new cGridBag();
1555
- bigThree.addComponent(scenePanel);
15561637 bigThree.addComponent(centralPanel);
1557
- bigThree.addComponent(XYZPanel);
1638
+ bigThree.addComponent(scenePanel);
1639
+ //bigThree.addComponent(XYZPanel);
15581640
15591641 // // SIDE EFFECT!!!
15601642 // aConstraints.gridx = 0;
....@@ -1563,9 +1645,9 @@
15631645 // aConstraints.gridheight = 1;
15641646
15651647 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1648
+ framePanel.setContinuousLayout(false);
1649
+ framePanel.setOneTouchExpandable(false);
1650
+ //.setDividerLocation(0.8);
15691651 //framePanel.setDividerSize(15);
15701652 //framePanel.setResizeWeight(0.15);
15711653 framePanel.setName("Frame");
....@@ -1584,12 +1666,13 @@
15841666
15851667 frame.setSize(1280, 860);
15861668
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901669 cameraView.requestFocusInWindow();
15911670
15921671 gridPanel.setDividerLocation(1.0);
1672
+
1673
+ frame.validate();
1674
+
1675
+ frame.setVisible(true);
15931676
15941677 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15951678 frame.addWindowListener(new WindowAdapter()
....@@ -1676,24 +1759,6 @@
16761759 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16771760 colorSection.add(texture);
16781761
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
-
16971762 panel.add(new JSeparator());
16981763
16991764 panel.add(colorSection);
....@@ -1743,6 +1808,12 @@
17431808 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17441809 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17451810 diffuseSection.add(fakedepth);
1811
+
1812
+ cGridBag shadowbias = new cGridBag();
1813
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1814
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1815
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
+ diffuseSection.add(shadowbias);
17461817
17471818 panel.add(new JSeparator());
17481819
....@@ -1794,6 +1865,18 @@
17941865 // aConstraints.gridy += 1;
17951866 // aConstraints.gridwidth = 1;
17961867
1868
+ cGridBag anisoU = new cGridBag();
1869
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1870
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1871
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1872
+ specularSection.add(anisoU);
1873
+
1874
+ cGridBag anisoV = new cGridBag();
1875
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1876
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1877
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ specularSection.add(anisoV);
1879
+
17971880
17981881 panel.add(new JSeparator());
17991882
....@@ -1801,35 +1884,35 @@
18011884
18021885 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18031886
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
1887
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18051888
18061889 cGridBag camera = new cGridBag();
18071890 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18081891 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18091892 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
1893
+ colorSection.add(camera);
18111894
18121895 cGridBag ambient = new cGridBag();
18131896 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18141897 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18151898 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
1899
+ colorSection.add(ambient);
18171900
18181901 cGridBag backlit = new cGridBag();
18191902 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18201903 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18211904 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
1905
+ colorSection.add(backlit);
18231906
18241907 cGridBag opacity = new cGridBag();
18251908 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18261909 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18271910 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1911
+ colorSection.add(opacity);
18291912
1830
- panel.add(new JSeparator());
1913
+ //panel.add(new JSeparator());
18311914
1832
- panel.add(globalSection);
1915
+ //panel.add(globalSection);
18331916
18341917 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18351918
....@@ -1936,8 +2019,9 @@
19362019 // 3D models
19372020 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382021 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2022
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2023
+ //LoadFile(filename, lastConverter);
2024
+ LoadObjFile(filename); // New 3ds loader
19412025 continue;
19422026 }
19432027 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +2747,7 @@
26632747 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26642748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26652749 }
2750
+
26662751 //cJME.count++;
26672752 //cJME.count %= 12;
26682753 if (gc)
....@@ -2846,6 +2931,7 @@
28462931 }
28472932 }
28482933 }
2934
+
28492935 cFileSystemPane FSPane;
28502936
28512937 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2899,6 +2985,7 @@
28992985 }
29002986 }
29012987 }
2988
+
29022989 freezematerial = false;
29032990 }
29042991
....@@ -3017,12 +3104,17 @@
30173104 // }
30183105
30193106 /**/
3020
- if (deselect)
3107
+ if (deselect || child == null)
30213108 {
30223109 //group.deselectAll();
30233110 //freeze = true;
30243111 GetTree().clearSelection();
30253112 //freeze = false;
3113
+
3114
+ if (child == null)
3115
+ {
3116
+ return;
3117
+ }
30263118 }
30273119
30283120 //group.addSelectee(child);
....@@ -3161,7 +3253,7 @@
31613253 {
31623254 copy.live ^= true;
31633255 return;
3164
- } else if (event.getSource() == selectCB)
3256
+ } else if (event.getSource() == selectableCB)
31653257 {
31663258 copy.dontselect ^= true;
31673259 return;
....@@ -3346,9 +3438,9 @@
33463438 {
33473439 Close();
33483440 //return true;
3349
- } else if (source == loadItem)
3441
+ } else if (source == openItem)
33503442 {
3351
- load();
3443
+ Open();
33523444 //return true;
33533445 } else if (source == newItem)
33543446 {
....@@ -3373,6 +3465,10 @@
33733465 {
33743466 generatePOV();
33753467 //return true;
3468
+ } else if (event.getSource() == archiveItem)
3469
+ {
3470
+ cTools.Archive(frame);
3471
+ return;
33763472 } else if (source == zBufferItem)
33773473 {
33783474 try
....@@ -3424,8 +3520,8 @@
34243520 try
34253521 {
34263522 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3523
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3524
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34293525
34303526 Object3D parent = o.parent;
34313527 o.parent = null;
....@@ -3436,10 +3532,14 @@
34363532
34373533 out.flush();
34383534
3439
- zstream.close();
3535
+ baos //zstream
3536
+ .close();
34403537 out.close();
34413538
3442
- return baos.toByteArray();
3539
+ byte[] bytes = baos.toByteArray();
3540
+
3541
+ System.out.println("save #bytes = " + bytes.length);
3542
+ return bytes;
34433543 } catch (Exception e)
34443544 {
34453545 System.err.println(e);
....@@ -3449,13 +3549,16 @@
34493549
34503550 static public Object Uncompress(byte[] bytes)
34513551 {
3452
- System.out.println("#bytes = " + bytes.length);
3552
+ System.out.println("restore #bytes = " + bytes.length);
34533553 try
34543554 {
34553555 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
3556
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3557
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34583558 Object obj = in.readObject();
3559
+
3560
+ bais //istream
3561
+ .close();
34593562 in.close();
34603563
34613564 return obj;
....@@ -3510,31 +3613,67 @@
35103613 return null;
35113614 }
35123615
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35143616
35153617 public void Save()
3618
+ {
3619
+ //Save(true);
3620
+ Replace();
3621
+ }
3622
+
3623
+ private boolean Equal(byte[] compress, byte[] name)
3624
+ {
3625
+ if (compress.length != name.length)
3626
+ {
3627
+ return false;
3628
+ }
3629
+
3630
+ for (int i=compress.length; --i>=0;)
3631
+ {
3632
+ if (compress[i] != name[i])
3633
+ return false;
3634
+ }
3635
+
3636
+ return true;
3637
+ }
3638
+
3639
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3640
+
3641
+ public boolean Save(boolean user)
35163642 {
35173643 System.err.println("Save");
35183644
35193645 cRadio tab = GetCurrentTab();
35203646
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
3647
+ byte[] compress = CompressCopy();
35233648
3524
- copy.ExtractBigData(hashtable);
3649
+ boolean thesame = false;
3650
+
3651
+ // Quick heuristic using length. Works only when stream is compressed.
3652
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3653
+ {
3654
+ thesame = true;
3655
+ }
35253656
35263657 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- tab.graphs[tab.undoindex++] = Compress(copy);
3658
+ if (!thesame)
3659
+ {
3660
+ //tab.user[tab.versionindex] = user;
3661
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3662
+
3663
+ copy.versions[++copy.versionindex] = compress;
3664
+
3665
+ // if (increment)
3666
+ // tab.versionindex++;
3667
+ }
35283668
3529
- copy.RestoreBigData(hashtable);
3669
+ //copy.RestoreBigData(versiontable);
35303670
3531
- CameraPane.SWITCH = temp;
3532
-
35333671 //assert(hashtable.isEmpty());
35343672
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3673
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35363674 {
3537
- tab.graphs[i] = null;
3675
+ //tab.user[i] = false;
3676
+ copy.versions[i] = null;
35383677 }
35393678
35403679 SetUndoStates();
....@@ -3544,7 +3683,7 @@
35443683 {
35453684 try
35463685 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3686
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35483687 ObjectOutputStream p = new ObjectOutputStream(ostream);
35493688
35503689 p.writeObject(copy);
....@@ -3557,6 +3696,8 @@
35573696 e.printStackTrace();
35583697 }
35593698 }
3699
+
3700
+ return !thesame;
35603701 }
35613702
35623703 void CopyChanged(Object3D obj)
....@@ -3566,7 +3707,7 @@
35663707 boolean temp = CameraPane.SWITCH;
35673708 CameraPane.SWITCH = false;
35683709
3569
- copy.ExtractBigData(hashtable);
3710
+ copy.ExtractBigData(versiontable);
35703711
35713712 copy.clear();
35723713
....@@ -3575,7 +3716,7 @@
35753716 copy.add(obj.get(i));
35763717 }
35773718
3578
- copy.RestoreBigData(hashtable);
3719
+ copy.RestoreBigData(versiontable);
35793720
35803721 CameraPane.SWITCH = temp;
35813722
....@@ -3603,52 +3744,129 @@
36033744 }
36043745
36053746 cButton undoButton;
3747
+ cButton restoreButton;
3748
+ cButton replaceButton;
36063749 cButton redoButton;
36073750
3751
+ boolean muteSlider;
3752
+
3753
+ int VersionCount()
3754
+ {
3755
+ int count = 0;
3756
+
3757
+ for (int i = copy.versions.length; --i >= 0;)
3758
+ {
3759
+ if (copy.versions[i] != null)
3760
+ count++;
3761
+ }
3762
+
3763
+ return count;
3764
+ }
3765
+
36083766 void SetUndoStates()
36093767 {
36103768 cRadio tab = GetCurrentTab();
36113769
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3770
+ restoreButton.setEnabled(copy.versionindex != -1);
3771
+ replaceButton.setEnabled(copy.versionindex != -1);
3772
+
3773
+ undoButton.setEnabled(copy.versionindex > 0);
3774
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3775
+
3776
+ muteSlider = true;
3777
+ versionSlider.setMaximum(VersionCount() - 1);
3778
+ versionSlider.setInteger(copy.versionindex);
3779
+ muteSlider = false;
36143780 }
36153781
3616
- public void Undo()
3782
+ public boolean Undo()
36173783 {
3784
+ // Option?
3785
+ Replace();
3786
+
36183787 System.err.println("Undo");
36193788
36203789 cRadio tab = GetCurrentTab();
36213790
3622
- if (tab.undoindex == 0)
3791
+ if (copy.versionindex == 0)
36233792 {
36243793 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
3794
+ return false;
36263795 }
36273796
3628
- if (tab.graphs[tab.undoindex] == null)
3797
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3798
+// {
3799
+// if (Save(false))
3800
+// tab.versionindex -= 1;
3801
+// else
3802
+// {
3803
+// if (tab.versionindex <= 0)
3804
+// return false;
3805
+// else
3806
+// tab.versionindex -= 1;
3807
+// }
3808
+// }
3809
+
3810
+ copy.versionindex -= 1;
3811
+
3812
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3813
+
3814
+ return true;
3815
+ }
3816
+
3817
+ public boolean Restore()
3818
+ {
3819
+ System.err.println("Restore");
3820
+
3821
+ cRadio tab = GetCurrentTab();
3822
+
3823
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36293824 {
3630
- Save();
3631
- tab.undoindex -= 1;
3825
+ java.awt.Toolkit.getDefaultToolkit().beep();
3826
+ return false;
36323827 }
36333828
3634
- tab.undoindex -= 1;
3829
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3830
+
3831
+ return true;
3832
+ }
36353833
3636
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3834
+ public boolean Replace()
3835
+ {
3836
+ System.err.println("Replace");
3837
+
3838
+ cRadio tab = GetCurrentTab();
3839
+
3840
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3841
+ {
3842
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3843
+ return false;
3844
+ }
3845
+
3846
+ copy.versions[copy.versionindex] = CompressCopy();
3847
+
3848
+ return true;
36373849 }
36383850
36393851 public void Redo()
36403852 {
3853
+ // Option?
3854
+ Replace();
3855
+
36413856 cRadio tab = GetCurrentTab();
36423857
3643
- if (tab.graphs[tab.undoindex + 1] == null)
3858
+ if (copy.versions[copy.versionindex + 1] == null)
36443859 {
36453860 java.awt.Toolkit.getDefaultToolkit().beep();
36463861 return;
36473862 }
36483863
3649
- tab.undoindex += 1;
3864
+ copy.versionindex += 1;
36503865
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3866
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3867
+
3868
+ //if (!tab.user[tab.versionindex])
3869
+ // tab.graphs[tab.versionindex] = null;
36523870 }
36533871
36543872 void ImportGFD()
....@@ -3944,9 +4162,25 @@
39444162 //copy.Touch();
39454163 }
39464164
4165
+ cNumberSlider versionSlider;
4166
+
39474167 public void stateChanged(ChangeEvent e)
39484168 {
39494169 // assert(false);
4170
+ if (e.getSource() == versionSlider)
4171
+ {
4172
+ if (muteSlider)
4173
+ return;
4174
+
4175
+ int version = versionSlider.getInteger();
4176
+
4177
+ if (copy.versions[version] != null)
4178
+ {
4179
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4180
+ }
4181
+
4182
+ return;
4183
+ }
39504184
39514185 if (freezematerial)
39524186 {
....@@ -4295,7 +4529,7 @@
42954529
42964530 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42974531 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
4532
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42994533 Save();
43004534 //Tween.set(thing, 0).target(1).start(tweenManager);
43014535 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4537,7 +4771,9 @@
45374771 readobj.ResetDisplayList();
45384772 } catch (Exception e)
45394773 {
4540
- //e.printStackTrace();
4774
+ if (!e.toString().contains("GZIP"))
4775
+ e.printStackTrace();
4776
+
45414777 try
45424778 {
45434779 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4611,12 +4847,14 @@
46114847
46124848 if (readobj != null)
46134849 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
4850
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4851
+ // Save();
46164852 try
46174853 {
46184854 //readobj.deepCopySelf(copy);
46194855 copy.clear(); // june 2014
4856
+ copy.skyboxname = readobj.skyboxname;
4857
+ copy.skyboxext = readobj.skyboxext;
46204858 for (int i = 0; i < readobj.size(); i++)
46214859 {
46224860 Object3D child = readobj.get(i); // reserve(i);
....@@ -4657,6 +4895,7 @@
46574895 }
46584896 } catch (ClassCastException e)
46594897 {
4898
+ e.printStackTrace();
46604899 assert (false);
46614900 Composite c = (Composite) copy;
46624901 c.children.clear();
....@@ -4667,13 +4906,24 @@
46674906 c.addChild(csg);
46684907 }
46694908
4909
+ copy.versions = readobj.versions;
4910
+ copy.versionindex = readobj.versionindex;
4911
+
4912
+ if (copy.versions == null)
4913
+ {
4914
+ copy.versions = new byte[100][];
4915
+ copy.versionindex = -1;
4916
+ }
4917
+
4918
+ //? SetUndoStates();
4919
+
46704920 ResetModel();
46714921 copy.HardTouch(); // recompile?
46724922 refreshContents();
46734923 }
46744924 }
46754925
4676
- void load() // throws ClassNotFoundException
4926
+ void Open() // throws ClassNotFoundException
46774927 {
46784928 if (Grafreed.standAlone)
46794929 {
....@@ -4776,6 +5026,7 @@
47765026 //ps.print(buffer.toString());
47775027 } catch (IOException e)
47785028 {
5029
+ e.printStackTrace();
47795030 }
47805031 }
47815032
....@@ -4958,7 +5209,7 @@
49585209 MenuBar menuBar;
49595210 Menu fileMenu;
49605211 MenuItem newItem;
4961
- MenuItem loadItem;
5212
+ MenuItem openItem;
49625213 MenuItem saveItem;
49635214 MenuItem saveAsItem;
49645215 MenuItem exportAsItem;
....@@ -4981,6 +5232,7 @@
49815232 CheckboxMenuItem toggleSwitchItem;
49825233 CheckboxMenuItem toggleRootItem;
49835234 CheckboxMenuItem animationItem;
5235
+ MenuItem archiveItem;
49845236 CheckboxMenuItem toggleHandleItem;
49855237 CheckboxMenuItem togglePaintItem;
49865238 JSplitPane mainPanel;