Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
ObjEditor.java
....@@ -44,61 +44,47 @@
4444
4545 cButton GetButton(String name, boolean border)
4646 {
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
- }
47
+ ImageIcon icon = GetIcon(name);
48
+ return new cButton(icon, border);
5649 }
5750
5851 cToggleButton GetToggleButton(String name, boolean border)
5952 {
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
- }
53
+ ImageIcon icon = GetIcon(name);
54
+ return new cToggleButton(icon, border);
6955 }
7056
7157 cCheckBox GetCheckBox(String name, boolean border)
7258 {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+
63
+ ImageIcon GetIcon(String name)
64
+ {
7365 try
7466 {
75
- ImageIcon icon = GetIcon(name);
76
- 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;
7783 }
7884 catch (Exception e)
7985 {
80
- return new cCheckBox(name, border);
86
+ return null;
8187 }
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;
10288 }
10389
10490 // SCRIPT
....@@ -282,6 +268,12 @@
282268 client = inClient;
283269 copy = client;
284270
271
+ if (copy.versions == null)
272
+ {
273
+ copy.versions = new byte[100][];
274
+ copy.versionindex = -1;
275
+ }
276
+
285277 // "this" is not called: SetupUI2(objEditor);
286278 }
287279
....@@ -295,6 +287,12 @@
295287 client = inClient;
296288 copy = client;
297289
290
+ if (copy.versions == null)
291
+ {
292
+ copy.versions = new byte[100][];
293
+ copy.versionindex = -1;
294
+ }
295
+
298296 SetupUI2(callee.GetEditor());
299297 }
300298
....@@ -309,7 +307,7 @@
309307 //localCopy.parent = null;
310308
311309 frame = new JFrame();
312
- frame.setUndecorated(true);
310
+ frame.setUndecorated(false);
313311 objEditor = this;
314312 this.callee = callee;
315313
....@@ -327,6 +325,12 @@
327325 copy = localCopy;
328326 copy.editWindow = this;
329327
328
+ if (copy.versions == null)
329
+ {
330
+// copy.versions = new byte[100][];
331
+// copy.versionindex = -1;
332
+ }
333
+
330334 SetupMenu();
331335
332336 //SetupName(objEditor); // new
....@@ -350,7 +354,7 @@
350354 frame.setMenuBar(menuBar = new MenuBar());
351355 menuBar.add(fileMenu = new Menu("File"));
352356 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
357
+ fileMenu.add(openItem = new MenuItem("Open..."));
354358
355359 //oe.menuBar.add(menu = new Menu("Include"));
356360 Menu menu = new Menu("Import");
....@@ -382,7 +386,7 @@
382386 }
383387
384388 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
389
+ openItem.addActionListener(this);
386390 saveItem.addActionListener(this);
387391 saveAsItem.addActionListener(this);
388392 exportAsItem.addActionListener(this);
....@@ -419,11 +423,12 @@
419423
420424 toolbarPanel = new JPanel();
421425 toolbarPanel.setName("Toolbar");
426
+
422427 treePanel = new cGridBag();
423428 treePanel.setName("Tree");
424429
425430 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
431
+ //editPanel.setName("Edit");
427432
428433 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429434
....@@ -431,11 +436,11 @@
431436 editPanel.add(editCommandsPanel);
432437 editPanel.add(ctrlPanel);
433438
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
439
+ toolboxPanel = new cGridBag().setVertical(true);
440
+ //toolboxPanel.setName("Toolbox");
436441
437442 materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
443
+ //materialPanel.setName("Material");
439444
440445 /*JTextPane*/
441446 infoarea = createTextPane();
....@@ -443,14 +448,15 @@
443448
444449 infoarea.setEditable(true);
445450 SetText();
451
+
446452 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447453 // infoarea.setOpaque(false);
448454 // //infoarea.setForeground(textcolor);
449455 // TEXTAREA infoarea.setLineWrap(true);
450456 // TEXTAREA infoarea.setWrapStyleWord(true);
451457 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- infoPanel.setPreferredSize(new Dimension(50, 200));
453
- infoPanel.setName("Info");
458
+ infoPanel.setPreferredSize(new Dimension(1, 1));
459
+ //infoPanel.setName("Info");
454460 //infoPanel.setLayout(new BorderLayout());
455461 //infoPanel.add(createTextPane());
456462
....@@ -699,8 +705,8 @@
699705 }
700706 }
701707
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
708
+//static GraphicsDevice device = GraphicsEnvironment
709
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704710
705711 Rectangle keeprect;
706712 cRadio radio;
....@@ -721,10 +727,19 @@
721727 void Minimize()
722728 {
723729 frame.setState(Frame.ICONIFIED);
730
+ frame.validate();
724731 }
725732
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={}
726736 void Maximize()
727737 {
738
+ if (CameraPane.FULLSCREEN)
739
+ {
740
+ ToggleFullScreen();
741
+ }
742
+
728743 if (maximized)
729744 {
730745 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +747,36 @@
732747 else
733748 {
734749 keeprect = frame.getBounds();
735
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
736
- Dimension rect2 = frame.getToolkit().getScreenSize();
737
- 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);
738753 // frame.setState(Frame.MAXIMIZED_BOTH);
754
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739755 }
740756
741757 maximized ^= true;
758
+
759
+ frame.validate();
742760 }
761
+
762
+ cButton minButton;
763
+ cButton maxButton;
764
+ cButton fullButton;
743765
744766 void ToggleFullScreen()
745767 {
768
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769
+
746770 cameraView.ToggleFullScreen();
747771
748772 if (!CameraPane.FULLSCREEN)
749773 {
750774 device.setFullScreenWindow(null);
775
+ frame.dispose();
776
+ frame.setUndecorated(false);
777
+ frame.validate();
778
+ frame.setVisible(true);
779
+
751780 //frame.setVisible(false);
752781 // frame.removeNotify();
753782 // frame.setUndecorated(false);
....@@ -757,7 +786,7 @@
757786 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758787 // X framePanel.add(bigThree);
759788 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
789
+ framePanel.setDividerLocation(46);
761790
762791 //frame.setVisible(true);
763792 radio.layout = keepButton;
....@@ -772,7 +801,12 @@
772801 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773802 // frame.getToolkit().getScreenSize().height);
774803 //frame.setVisible(false);
804
+
805
+ frame.dispose();
806
+ frame.setUndecorated(true);
775807 device.setFullScreenWindow(frame);
808
+ frame.validate();
809
+ frame.setVisible(true);
776810 // frame.removeNotify();
777811 // frame.setUndecorated(true);
778812 // frame.addNotify();
....@@ -785,7 +819,30 @@
785819 radio.layout.doClick();
786820 //frame.setVisible(true);
787821 }
822
+ frame.validate();
788823 }
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
+ }
789846
790847 private JTextPane createTextPane()
791848 {
....@@ -917,7 +974,7 @@
917974 // NumberSlider vDivsField;
918975 // JCheckBox endcaps;
919976 JCheckBox liveCB;
920
- JCheckBox selectCB;
977
+ JCheckBox selectableCB;
921978 JCheckBox hideCB;
922979 JCheckBox link2masterCB;
923980 JCheckBox markCB;
....@@ -1117,7 +1174,7 @@
11171174 namePanel = new cGridBag();
11181175
11191176 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1177
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211178 oe.ctrlPanel.add(namePanel);
11221179
11231180 oe.ctrlPanel.Return();
....@@ -1129,26 +1186,30 @@
11291186
11301187 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11311188 liveCB.setToolTipText("Animate object");
1132
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1133
- selectCB.setToolTipText("Make object selectable");
1189
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
+ selectableCB.setToolTipText("Make object selectable");
11341191 // Return();
1192
+
11351193 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11361194 hideCB.setToolTipText("Hide object");
11371195 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11381196 markCB.setToolTipText("As animation target transform");
1197
+
1198
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11391199
11401200 setupPanel2 = new cGridBag().setVertical(false);
11411201
11421202 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431203 rewindCB.setToolTipText("Rewind animation");
11441204
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1205
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461206 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471207
1208
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1209
+ link2masterCB.setToolTipText("Attach to support");
1210
+
11481211 if (Globals.ADVANCED)
11491212 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521213 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531214 speedupCB.setToolTipText("Option motion capture");
11541215 }
....@@ -1422,6 +1483,7 @@
14221483 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14231484 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14241485 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1486
+ //XYZPanel.setName("XYZ");
14251487
14261488 /*
14271489 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1459,13 +1521,23 @@
14591521 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14601522 //tmp.setName("Edit");
14611523 objectPanel.add(materialPanel);
1524
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
14621525 // JPanel north = new JPanel(new BorderLayout());
14631526 // north.setName("Edit");
14641527 // north.add(ctrlPanel, BorderLayout.NORTH);
14651528 // objectPanel.add(north);
14661529 objectPanel.add(editPanel);
1467
- 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
+
14681539 objectPanel.add(toolboxPanel);
1540
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
14691541
14701542 /*
14711543 aConstraints.gridx = 0;
....@@ -1486,7 +1558,7 @@
14861558 scrollpane.addMouseWheelListener(this); // Default not fast enough
14871559
14881560 /*JTabbedPane*/ scenePanel = new cGridBag();
1489
- scenePanel.preferredWidth = 6;
1561
+ scenePanel.preferredWidth = 5;
14901562
14911563 JTabbedPane tabbedPane = new JTabbedPane();
14921564 tabbedPane.add(scrollpane);
....@@ -1562,9 +1634,9 @@
15621634 /**/
15631635
15641636 bigThree = new cGridBag();
1565
- bigThree.addComponent(scenePanel);
15661637 bigThree.addComponent(centralPanel);
1567
- bigThree.addComponent(XYZPanel);
1638
+ bigThree.addComponent(scenePanel);
1639
+ //bigThree.addComponent(XYZPanel);
15681640
15691641 // // SIDE EFFECT!!!
15701642 // aConstraints.gridx = 0;
....@@ -1573,9 +1645,9 @@
15731645 // aConstraints.gridheight = 1;
15741646
15751647 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1648
+ framePanel.setContinuousLayout(false);
1649
+ framePanel.setOneTouchExpandable(false);
1650
+ //.setDividerLocation(0.8);
15791651 //framePanel.setDividerSize(15);
15801652 //framePanel.setResizeWeight(0.15);
15811653 framePanel.setName("Frame");
....@@ -1594,12 +1666,13 @@
15941666
15951667 frame.setSize(1280, 860);
15961668
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001669 cameraView.requestFocusInWindow();
16011670
16021671 gridPanel.setDividerLocation(1.0);
1672
+
1673
+ frame.validate();
1674
+
1675
+ frame.setVisible(true);
16031676
16041677 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051678 frame.addWindowListener(new WindowAdapter()
....@@ -1686,24 +1759,6 @@
16861759 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871760 colorSection.add(texture);
16881761
1689
- cGridBag anisoU = new cGridBag();
1690
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1691
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1693
- colorSection.add(anisoU);
1694
-
1695
- cGridBag anisoV = new cGridBag();
1696
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1697
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1698
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1699
- colorSection.add(anisoV);
1700
-
1701
- cGridBag shadowbias = new cGridBag();
1702
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1703
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1704
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1705
- colorSection.add(shadowbias);
1706
-
17071762 panel.add(new JSeparator());
17081763
17091764 panel.add(colorSection);
....@@ -1753,6 +1808,12 @@
17531808 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17541809 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551810 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);
17561817
17571818 panel.add(new JSeparator());
17581819
....@@ -1804,6 +1865,18 @@
18041865 // aConstraints.gridy += 1;
18051866 // aConstraints.gridwidth = 1;
18061867
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
+
18071880
18081881 panel.add(new JSeparator());
18091882
....@@ -1811,35 +1884,35 @@
18111884
18121885 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131886
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1887
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151888
18161889 cGridBag camera = new cGridBag();
18171890 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181891 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191892 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1893
+ colorSection.add(camera);
18211894
18221895 cGridBag ambient = new cGridBag();
18231896 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241897 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251898 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1899
+ colorSection.add(ambient);
18271900
18281901 cGridBag backlit = new cGridBag();
18291902 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301903 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311904 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1905
+ colorSection.add(backlit);
18331906
18341907 cGridBag opacity = new cGridBag();
18351908 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18361909 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18371910 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1911
+ colorSection.add(opacity);
18391912
1840
- panel.add(new JSeparator());
1913
+ //panel.add(new JSeparator());
18411914
1842
- panel.add(globalSection);
1915
+ //panel.add(globalSection);
18431916
18441917 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451918
....@@ -1946,8 +2019,9 @@
19462019 // 3D models
19472020 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482021 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2022
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2023
+ //LoadFile(filename, lastConverter);
2024
+ LoadObjFile(filename); // New 3ds loader
19512025 continue;
19522026 }
19532027 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2747,7 @@
26732747 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752749 }
2750
+
26762751 //cJME.count++;
26772752 //cJME.count %= 12;
26782753 if (gc)
....@@ -2856,6 +2931,7 @@
28562931 }
28572932 }
28582933 }
2934
+
28592935 cFileSystemPane FSPane;
28602936
28612937 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +2985,7 @@
29092985 }
29102986 }
29112987 }
2988
+
29122989 freezematerial = false;
29132990 }
29142991
....@@ -3176,7 +3253,7 @@
31763253 {
31773254 copy.live ^= true;
31783255 return;
3179
- } else if (event.getSource() == selectCB)
3256
+ } else if (event.getSource() == selectableCB)
31803257 {
31813258 copy.dontselect ^= true;
31823259 return;
....@@ -3361,9 +3438,9 @@
33613438 {
33623439 Close();
33633440 //return true;
3364
- } else if (source == loadItem)
3441
+ } else if (source == openItem)
33653442 {
3366
- load();
3443
+ Open();
33673444 //return true;
33683445 } else if (source == newItem)
33693446 {
....@@ -3388,6 +3465,10 @@
33883465 {
33893466 generatePOV();
33903467 //return true;
3468
+ } else if (event.getSource() == archiveItem)
3469
+ {
3470
+ cTools.Archive(frame);
3471
+ return;
33913472 } else if (source == zBufferItem)
33923473 {
33933474 try
....@@ -3439,8 +3520,8 @@
34393520 try
34403521 {
34413522 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3523
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3524
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443525
34453526 Object3D parent = o.parent;
34463527 o.parent = null;
....@@ -3451,10 +3532,14 @@
34513532
34523533 out.flush();
34533534
3454
- zstream.close();
3535
+ baos //zstream
3536
+ .close();
34553537 out.close();
34563538
3457
- return baos.toByteArray();
3539
+ byte[] bytes = baos.toByteArray();
3540
+
3541
+ System.out.println("save #bytes = " + bytes.length);
3542
+ return bytes;
34583543 } catch (Exception e)
34593544 {
34603545 System.err.println(e);
....@@ -3464,13 +3549,16 @@
34643549
34653550 static public Object Uncompress(byte[] bytes)
34663551 {
3467
- System.out.println("#bytes = " + bytes.length);
3552
+ System.out.println("restore #bytes = " + bytes.length);
34683553 try
34693554 {
34703555 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3556
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3557
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733558 Object obj = in.readObject();
3559
+
3560
+ bais //istream
3561
+ .close();
34743562 in.close();
34753563
34763564 return obj;
....@@ -3525,31 +3613,67 @@
35253613 return null;
35263614 }
35273615
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35293616
35303617 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)
35313642 {
35323643 System.err.println("Save");
35333644
35343645 cRadio tab = GetCurrentTab();
35353646
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
3647
+ byte[] compress = CompressCopy();
35383648
3539
- 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
+ }
35403656
35413657 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- 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
+ }
35433668
3544
- copy.RestoreBigData(hashtable);
3669
+ //copy.RestoreBigData(versiontable);
35453670
3546
- CameraPane.SWITCH = temp;
3547
-
35483671 //assert(hashtable.isEmpty());
35493672
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3673
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35513674 {
3552
- tab.graphs[i] = null;
3675
+ //tab.user[i] = false;
3676
+ copy.versions[i] = null;
35533677 }
35543678
35553679 SetUndoStates();
....@@ -3559,7 +3683,7 @@
35593683 {
35603684 try
35613685 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3686
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35633687 ObjectOutputStream p = new ObjectOutputStream(ostream);
35643688
35653689 p.writeObject(copy);
....@@ -3572,6 +3696,8 @@
35723696 e.printStackTrace();
35733697 }
35743698 }
3699
+
3700
+ return !thesame;
35753701 }
35763702
35773703 void CopyChanged(Object3D obj)
....@@ -3581,7 +3707,7 @@
35813707 boolean temp = CameraPane.SWITCH;
35823708 CameraPane.SWITCH = false;
35833709
3584
- copy.ExtractBigData(hashtable);
3710
+ copy.ExtractBigData(versiontable);
35853711
35863712 copy.clear();
35873713
....@@ -3590,7 +3716,7 @@
35903716 copy.add(obj.get(i));
35913717 }
35923718
3593
- copy.RestoreBigData(hashtable);
3719
+ copy.RestoreBigData(versiontable);
35943720
35953721 CameraPane.SWITCH = temp;
35963722
....@@ -3618,52 +3744,129 @@
36183744 }
36193745
36203746 cButton undoButton;
3747
+ cButton restoreButton;
3748
+ cButton replaceButton;
36213749 cButton redoButton;
36223750
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
+
36233766 void SetUndoStates()
36243767 {
36253768 cRadio tab = GetCurrentTab();
36263769
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- 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;
36293780 }
36303781
3631
- public void Undo()
3782
+ public boolean Undo()
36323783 {
3784
+ // Option?
3785
+ Replace();
3786
+
36333787 System.err.println("Undo");
36343788
36353789 cRadio tab = GetCurrentTab();
36363790
3637
- if (tab.undoindex == 0)
3791
+ if (copy.versionindex == 0)
36383792 {
36393793 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3794
+ return false;
36413795 }
36423796
3643
- 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)
36443824 {
3645
- Save();
3646
- tab.undoindex -= 1;
3825
+ java.awt.Toolkit.getDefaultToolkit().beep();
3826
+ return false;
36473827 }
36483828
3649
- tab.undoindex -= 1;
3829
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3830
+
3831
+ return true;
3832
+ }
36503833
3651
- 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;
36523849 }
36533850
36543851 public void Redo()
36553852 {
3853
+ // Option?
3854
+ Replace();
3855
+
36563856 cRadio tab = GetCurrentTab();
36573857
3658
- if (tab.graphs[tab.undoindex + 1] == null)
3858
+ if (copy.versions[copy.versionindex + 1] == null)
36593859 {
36603860 java.awt.Toolkit.getDefaultToolkit().beep();
36613861 return;
36623862 }
36633863
3664
- tab.undoindex += 1;
3864
+ copy.versionindex += 1;
36653865
3666
- 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;
36673870 }
36683871
36693872 void ImportGFD()
....@@ -3959,9 +4162,25 @@
39594162 //copy.Touch();
39604163 }
39614164
4165
+ cNumberSlider versionSlider;
4166
+
39624167 public void stateChanged(ChangeEvent e)
39634168 {
39644169 // 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
+ }
39654184
39664185 if (freezematerial)
39674186 {
....@@ -4310,7 +4529,7 @@
43104529
43114530 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43124531 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
4532
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43144533 Save();
43154534 //Tween.set(thing, 0).target(1).start(tweenManager);
43164535 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4552,7 +4771,9 @@
45524771 readobj.ResetDisplayList();
45534772 } catch (Exception e)
45544773 {
4555
- //e.printStackTrace();
4774
+ if (!e.toString().contains("GZIP"))
4775
+ e.printStackTrace();
4776
+
45564777 try
45574778 {
45584779 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4626,12 +4847,14 @@
46264847
46274848 if (readobj != null)
46284849 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
4850
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4851
+ // Save();
46314852 try
46324853 {
46334854 //readobj.deepCopySelf(copy);
46344855 copy.clear(); // june 2014
4856
+ copy.skyboxname = readobj.skyboxname;
4857
+ copy.skyboxext = readobj.skyboxext;
46354858 for (int i = 0; i < readobj.size(); i++)
46364859 {
46374860 Object3D child = readobj.get(i); // reserve(i);
....@@ -4672,6 +4895,7 @@
46724895 }
46734896 } catch (ClassCastException e)
46744897 {
4898
+ e.printStackTrace();
46754899 assert (false);
46764900 Composite c = (Composite) copy;
46774901 c.children.clear();
....@@ -4682,13 +4906,24 @@
46824906 c.addChild(csg);
46834907 }
46844908
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
+
46854920 ResetModel();
46864921 copy.HardTouch(); // recompile?
46874922 refreshContents();
46884923 }
46894924 }
46904925
4691
- void load() // throws ClassNotFoundException
4926
+ void Open() // throws ClassNotFoundException
46924927 {
46934928 if (Grafreed.standAlone)
46944929 {
....@@ -4791,6 +5026,7 @@
47915026 //ps.print(buffer.toString());
47925027 } catch (IOException e)
47935028 {
5029
+ e.printStackTrace();
47945030 }
47955031 }
47965032
....@@ -4973,7 +5209,7 @@
49735209 MenuBar menuBar;
49745210 Menu fileMenu;
49755211 MenuItem newItem;
4976
- MenuItem loadItem;
5212
+ MenuItem openItem;
49775213 MenuItem saveItem;
49785214 MenuItem saveAsItem;
49795215 MenuItem exportAsItem;
....@@ -4996,6 +5232,7 @@
49965232 CheckboxMenuItem toggleSwitchItem;
49975233 CheckboxMenuItem toggleRootItem;
49985234 CheckboxMenuItem animationItem;
5235
+ MenuItem archiveItem;
49995236 CheckboxMenuItem toggleHandleItem;
50005237 CheckboxMenuItem togglePaintItem;
50015238 JSplitPane mainPanel;