Normand Briere
2019-07-21 76522bc3ee92bd50dbd946d7f865666be4ad7bac
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
+ private 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() != 24 && image.getHeight() != 24)
70
+ {
71
+ BufferedImage resized = new BufferedImage(24, 24, 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, 24, 24, 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
....@@ -432,10 +437,10 @@
432437 editPanel.add(ctrlPanel);
433438
434439 toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
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,9 +1186,10 @@
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);
....@@ -1142,13 +1200,14 @@
11421200 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431201 rewindCB.setToolTipText("Rewind animation");
11441202
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1203
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461204 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471205
1206
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1207
+ link2masterCB.setToolTipText("Attach to support");
1208
+
11481209 if (Globals.ADVANCED)
11491210 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521211 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531212 speedupCB.setToolTipText("Option motion capture");
11541213 }
....@@ -1422,6 +1481,7 @@
14221481 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14231482 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14241483 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1484
+ //XYZPanel.setName("XYZ");
14251485
14261486 /*
14271487 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1459,13 +1519,23 @@
14591519 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14601520 //tmp.setName("Edit");
14611521 objectPanel.add(materialPanel);
1522
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
14621523 // JPanel north = new JPanel(new BorderLayout());
14631524 // north.setName("Edit");
14641525 // north.add(ctrlPanel, BorderLayout.NORTH);
14651526 // objectPanel.add(north);
14661527 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1528
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1529
+
1530
+ //if (Globals.ADVANCED)
1531
+ objectPanel.add(infoPanel);
1532
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1533
+
1534
+ objectPanel.add(XYZPanel);
1535
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1536
+
14681537 objectPanel.add(toolboxPanel);
1538
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
14691539
14701540 /*
14711541 aConstraints.gridx = 0;
....@@ -1486,7 +1556,7 @@
14861556 scrollpane.addMouseWheelListener(this); // Default not fast enough
14871557
14881558 /*JTabbedPane*/ scenePanel = new cGridBag();
1489
- scenePanel.preferredWidth = 6;
1559
+ scenePanel.preferredWidth = 5;
14901560
14911561 JTabbedPane tabbedPane = new JTabbedPane();
14921562 tabbedPane.add(scrollpane);
....@@ -1564,7 +1634,7 @@
15641634 bigThree = new cGridBag();
15651635 bigThree.addComponent(scenePanel);
15661636 bigThree.addComponent(centralPanel);
1567
- bigThree.addComponent(XYZPanel);
1637
+ //bigThree.addComponent(XYZPanel);
15681638
15691639 // // SIDE EFFECT!!!
15701640 // aConstraints.gridx = 0;
....@@ -1573,9 +1643,9 @@
15731643 // aConstraints.gridheight = 1;
15741644
15751645 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1646
+ framePanel.setContinuousLayout(false);
1647
+ framePanel.setOneTouchExpandable(false);
1648
+ //.setDividerLocation(0.8);
15791649 //framePanel.setDividerSize(15);
15801650 //framePanel.setResizeWeight(0.15);
15811651 framePanel.setName("Frame");
....@@ -1594,12 +1664,13 @@
15941664
15951665 frame.setSize(1280, 860);
15961666
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001667 cameraView.requestFocusInWindow();
16011668
16021669 gridPanel.setDividerLocation(1.0);
1670
+
1671
+ frame.validate();
1672
+
1673
+ frame.setVisible(true);
16031674
16041675 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051676 frame.addWindowListener(new WindowAdapter()
....@@ -1686,24 +1757,6 @@
16861757 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871758 colorSection.add(texture);
16881759
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
-
17071760 panel.add(new JSeparator());
17081761
17091762 panel.add(colorSection);
....@@ -1753,6 +1806,12 @@
17531806 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17541807 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551808 diffuseSection.add(fakedepth);
1809
+
1810
+ cGridBag shadowbias = new cGridBag();
1811
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1812
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1813
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1814
+ diffuseSection.add(shadowbias);
17561815
17571816 panel.add(new JSeparator());
17581817
....@@ -1804,6 +1863,18 @@
18041863 // aConstraints.gridy += 1;
18051864 // aConstraints.gridwidth = 1;
18061865
1866
+ cGridBag anisoU = new cGridBag();
1867
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1868
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1869
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1870
+ specularSection.add(anisoU);
1871
+
1872
+ cGridBag anisoV = new cGridBag();
1873
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1874
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1875
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1876
+ specularSection.add(anisoV);
1877
+
18071878
18081879 panel.add(new JSeparator());
18091880
....@@ -1811,35 +1882,35 @@
18111882
18121883 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131884
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1885
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151886
18161887 cGridBag camera = new cGridBag();
18171888 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181889 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191890 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1891
+ colorSection.add(camera);
18211892
18221893 cGridBag ambient = new cGridBag();
18231894 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241895 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251896 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1897
+ colorSection.add(ambient);
18271898
18281899 cGridBag backlit = new cGridBag();
18291900 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301901 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311902 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1903
+ colorSection.add(backlit);
18331904
18341905 cGridBag opacity = new cGridBag();
18351906 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18361907 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18371908 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1909
+ colorSection.add(opacity);
18391910
1840
- panel.add(new JSeparator());
1911
+ //panel.add(new JSeparator());
18411912
1842
- panel.add(globalSection);
1913
+ //panel.add(globalSection);
18431914
18441915 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451916
....@@ -1946,8 +2017,9 @@
19462017 // 3D models
19472018 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482019 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2020
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2021
+ //LoadFile(filename, lastConverter);
2022
+ LoadObjFile(filename); // New 3ds loader
19512023 continue;
19522024 }
19532025 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2745,7 @@
26732745 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742746 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752747 }
2748
+
26762749 //cJME.count++;
26772750 //cJME.count %= 12;
26782751 if (gc)
....@@ -2856,6 +2929,7 @@
28562929 }
28572930 }
28582931 }
2932
+
28592933 cFileSystemPane FSPane;
28602934
28612935 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +2983,7 @@
29092983 }
29102984 }
29112985 }
2986
+
29122987 freezematerial = false;
29132988 }
29142989
....@@ -3176,7 +3251,7 @@
31763251 {
31773252 copy.live ^= true;
31783253 return;
3179
- } else if (event.getSource() == selectCB)
3254
+ } else if (event.getSource() == selectableCB)
31803255 {
31813256 copy.dontselect ^= true;
31823257 return;
....@@ -3361,9 +3436,9 @@
33613436 {
33623437 Close();
33633438 //return true;
3364
- } else if (source == loadItem)
3439
+ } else if (source == openItem)
33653440 {
3366
- load();
3441
+ Open();
33673442 //return true;
33683443 } else if (source == newItem)
33693444 {
....@@ -3388,6 +3463,10 @@
33883463 {
33893464 generatePOV();
33903465 //return true;
3466
+ } else if (event.getSource() == archiveItem)
3467
+ {
3468
+ cTools.Archive(frame);
3469
+ return;
33913470 } else if (source == zBufferItem)
33923471 {
33933472 try
....@@ -3439,8 +3518,8 @@
34393518 try
34403519 {
34413520 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3521
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3522
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443523
34453524 Object3D parent = o.parent;
34463525 o.parent = null;
....@@ -3451,10 +3530,14 @@
34513530
34523531 out.flush();
34533532
3454
- zstream.close();
3533
+ baos //zstream
3534
+ .close();
34553535 out.close();
34563536
3457
- return baos.toByteArray();
3537
+ byte[] bytes = baos.toByteArray();
3538
+
3539
+ System.out.println("save #bytes = " + bytes.length);
3540
+ return bytes;
34583541 } catch (Exception e)
34593542 {
34603543 System.err.println(e);
....@@ -3464,13 +3547,16 @@
34643547
34653548 static public Object Uncompress(byte[] bytes)
34663549 {
3467
- System.out.println("#bytes = " + bytes.length);
3550
+ System.out.println("restore #bytes = " + bytes.length);
34683551 try
34693552 {
34703553 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3554
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3555
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733556 Object obj = in.readObject();
3557
+
3558
+ bais //istream
3559
+ .close();
34743560 in.close();
34753561
34763562 return obj;
....@@ -3525,31 +3611,67 @@
35253611 return null;
35263612 }
35273613
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35293614
35303615 public void Save()
3616
+ {
3617
+ //Save(true);
3618
+ Replace();
3619
+ }
3620
+
3621
+ private boolean Equal(byte[] compress, byte[] name)
3622
+ {
3623
+ if (compress.length != name.length)
3624
+ {
3625
+ return false;
3626
+ }
3627
+
3628
+ for (int i=compress.length; --i>=0;)
3629
+ {
3630
+ if (compress[i] != name[i])
3631
+ return false;
3632
+ }
3633
+
3634
+ return true;
3635
+ }
3636
+
3637
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3638
+
3639
+ public boolean Save(boolean user)
35313640 {
35323641 System.err.println("Save");
35333642
35343643 cRadio tab = GetCurrentTab();
35353644
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
3645
+ byte[] compress = CompressCopy();
35383646
3539
- copy.ExtractBigData(hashtable);
3647
+ boolean thesame = false;
3648
+
3649
+ // Quick heuristic using length. Works only when stream is compressed.
3650
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3651
+ {
3652
+ thesame = true;
3653
+ }
35403654
35413655 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3656
+ if (!thesame)
3657
+ {
3658
+ //tab.user[tab.versionindex] = user;
3659
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3660
+
3661
+ copy.versions[++copy.versionindex] = compress;
3662
+
3663
+ // if (increment)
3664
+ // tab.versionindex++;
3665
+ }
35433666
3544
- copy.RestoreBigData(hashtable);
3667
+ //copy.RestoreBigData(versiontable);
35453668
3546
- CameraPane.SWITCH = temp;
3547
-
35483669 //assert(hashtable.isEmpty());
35493670
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3671
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35513672 {
3552
- tab.graphs[i] = null;
3673
+ //tab.user[i] = false;
3674
+ copy.versions[i] = null;
35533675 }
35543676
35553677 SetUndoStates();
....@@ -3559,7 +3681,7 @@
35593681 {
35603682 try
35613683 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3684
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35633685 ObjectOutputStream p = new ObjectOutputStream(ostream);
35643686
35653687 p.writeObject(copy);
....@@ -3572,6 +3694,8 @@
35723694 e.printStackTrace();
35733695 }
35743696 }
3697
+
3698
+ return !thesame;
35753699 }
35763700
35773701 void CopyChanged(Object3D obj)
....@@ -3581,7 +3705,7 @@
35813705 boolean temp = CameraPane.SWITCH;
35823706 CameraPane.SWITCH = false;
35833707
3584
- copy.ExtractBigData(hashtable);
3708
+ copy.ExtractBigData(versiontable);
35853709
35863710 copy.clear();
35873711
....@@ -3590,7 +3714,7 @@
35903714 copy.add(obj.get(i));
35913715 }
35923716
3593
- copy.RestoreBigData(hashtable);
3717
+ copy.RestoreBigData(versiontable);
35943718
35953719 CameraPane.SWITCH = temp;
35963720
....@@ -3618,52 +3742,129 @@
36183742 }
36193743
36203744 cButton undoButton;
3745
+ cButton restoreButton;
3746
+ cButton replaceButton;
36213747 cButton redoButton;
36223748
3749
+ boolean muteSlider;
3750
+
3751
+ int VersionCount()
3752
+ {
3753
+ int count = 0;
3754
+
3755
+ for (int i = copy.versions.length; --i >= 0;)
3756
+ {
3757
+ if (copy.versions[i] != null)
3758
+ count++;
3759
+ }
3760
+
3761
+ return count;
3762
+ }
3763
+
36233764 void SetUndoStates()
36243765 {
36253766 cRadio tab = GetCurrentTab();
36263767
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3768
+ restoreButton.setEnabled(copy.versionindex != -1);
3769
+ replaceButton.setEnabled(copy.versionindex != -1);
3770
+
3771
+ undoButton.setEnabled(copy.versionindex > 0);
3772
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3773
+
3774
+ muteSlider = true;
3775
+ versionSlider.setMaximum(VersionCount() - 1);
3776
+ versionSlider.setInteger(copy.versionindex);
3777
+ muteSlider = false;
36293778 }
36303779
3631
- public void Undo()
3780
+ public boolean Undo()
36323781 {
3782
+ // Option?
3783
+ Replace();
3784
+
36333785 System.err.println("Undo");
36343786
36353787 cRadio tab = GetCurrentTab();
36363788
3637
- if (tab.undoindex == 0)
3789
+ if (copy.versionindex == 0)
36383790 {
36393791 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3792
+ return false;
36413793 }
36423794
3643
- if (tab.graphs[tab.undoindex] == null)
3795
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3796
+// {
3797
+// if (Save(false))
3798
+// tab.versionindex -= 1;
3799
+// else
3800
+// {
3801
+// if (tab.versionindex <= 0)
3802
+// return false;
3803
+// else
3804
+// tab.versionindex -= 1;
3805
+// }
3806
+// }
3807
+
3808
+ copy.versionindex -= 1;
3809
+
3810
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3811
+
3812
+ return true;
3813
+ }
3814
+
3815
+ public boolean Restore()
3816
+ {
3817
+ System.err.println("Restore");
3818
+
3819
+ cRadio tab = GetCurrentTab();
3820
+
3821
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36443822 {
3645
- Save();
3646
- tab.undoindex -= 1;
3823
+ java.awt.Toolkit.getDefaultToolkit().beep();
3824
+ return false;
36473825 }
36483826
3649
- tab.undoindex -= 1;
3827
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3828
+
3829
+ return true;
3830
+ }
36503831
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3832
+ public boolean Replace()
3833
+ {
3834
+ System.err.println("Replace");
3835
+
3836
+ cRadio tab = GetCurrentTab();
3837
+
3838
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3839
+ {
3840
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3841
+ return false;
3842
+ }
3843
+
3844
+ copy.versions[copy.versionindex] = CompressCopy();
3845
+
3846
+ return true;
36523847 }
36533848
36543849 public void Redo()
36553850 {
3851
+ // Option?
3852
+ Replace();
3853
+
36563854 cRadio tab = GetCurrentTab();
36573855
3658
- if (tab.graphs[tab.undoindex + 1] == null)
3856
+ if (copy.versions[copy.versionindex + 1] == null)
36593857 {
36603858 java.awt.Toolkit.getDefaultToolkit().beep();
36613859 return;
36623860 }
36633861
3664
- tab.undoindex += 1;
3862
+ copy.versionindex += 1;
36653863
3666
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3864
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3865
+
3866
+ //if (!tab.user[tab.versionindex])
3867
+ // tab.graphs[tab.versionindex] = null;
36673868 }
36683869
36693870 void ImportGFD()
....@@ -3959,9 +4160,25 @@
39594160 //copy.Touch();
39604161 }
39614162
4163
+ cNumberSlider versionSlider;
4164
+
39624165 public void stateChanged(ChangeEvent e)
39634166 {
39644167 // assert(false);
4168
+ if (e.getSource() == versionSlider)
4169
+ {
4170
+ if (muteSlider)
4171
+ return;
4172
+
4173
+ int version = versionSlider.getInteger();
4174
+
4175
+ if (copy.versions[version] != null)
4176
+ {
4177
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4178
+ }
4179
+
4180
+ return;
4181
+ }
39654182
39664183 if (freezematerial)
39674184 {
....@@ -4310,7 +4527,7 @@
43104527
43114528 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43124529 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
4530
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43144531 Save();
43154532 //Tween.set(thing, 0).target(1).start(tweenManager);
43164533 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4552,7 +4769,7 @@
45524769 readobj.ResetDisplayList();
45534770 } catch (Exception e)
45544771 {
4555
- //e.printStackTrace();
4772
+ e.printStackTrace();
45564773 try
45574774 {
45584775 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4626,8 +4843,8 @@
46264843
46274844 if (readobj != null)
46284845 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
4846
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4847
+ // Save();
46314848 try
46324849 {
46334850 //readobj.deepCopySelf(copy);
....@@ -4682,13 +4899,24 @@
46824899 c.addChild(csg);
46834900 }
46844901
4902
+ copy.versions = readobj.versions;
4903
+ copy.versionindex = readobj.versionindex;
4904
+
4905
+ if (copy.versions == null)
4906
+ {
4907
+ copy.versions = new byte[100][];
4908
+ copy.versionindex = -1;
4909
+ }
4910
+
4911
+ //? SetUndoStates();
4912
+
46854913 ResetModel();
46864914 copy.HardTouch(); // recompile?
46874915 refreshContents();
46884916 }
46894917 }
46904918
4691
- void load() // throws ClassNotFoundException
4919
+ void Open() // throws ClassNotFoundException
46924920 {
46934921 if (Grafreed.standAlone)
46944922 {
....@@ -4973,7 +5201,7 @@
49735201 MenuBar menuBar;
49745202 Menu fileMenu;
49755203 MenuItem newItem;
4976
- MenuItem loadItem;
5204
+ MenuItem openItem;
49775205 MenuItem saveItem;
49785206 MenuItem saveAsItem;
49795207 MenuItem exportAsItem;
....@@ -4996,6 +5224,7 @@
49965224 CheckboxMenuItem toggleSwitchItem;
49975225 CheckboxMenuItem toggleRootItem;
49985226 CheckboxMenuItem animationItem;
5227
+ MenuItem archiveItem;
49995228 CheckboxMenuItem toggleHandleItem;
50005229 CheckboxMenuItem togglePaintItem;
50015230 JSplitPane mainPanel;