Normand Briere
2019-07-29 c6c3f0948bd31603547ef8ce47a7784a9a4d55c2
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
....@@ -463,10 +469,11 @@
463469 mainPanel.setResizeWeight(0.5);
464470
465471 //mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
-// BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
-// divider.setDividerSize(15);
468
-// divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
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!"));
469475
476
+ mainPanel.setUI(new BasicSplitPaneUI());
470477
471478 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
472479 //mainPanel.setLayout(new GridBagLayout());
....@@ -698,8 +705,8 @@
698705 }
699706 }
700707
701
-static GraphicsDevice device = GraphicsEnvironment
702
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
708
+//static GraphicsDevice device = GraphicsEnvironment
709
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
703710
704711 Rectangle keeprect;
705712 cRadio radio;
....@@ -720,10 +727,19 @@
720727 void Minimize()
721728 {
722729 frame.setState(Frame.ICONIFIED);
730
+ frame.validate();
723731 }
724732
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={}
725736 void Maximize()
726737 {
738
+ if (CameraPane.FULLSCREEN)
739
+ {
740
+ ToggleFullScreen();
741
+ }
742
+
727743 if (maximized)
728744 {
729745 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -731,22 +747,36 @@
731747 else
732748 {
733749 keeprect = frame.getBounds();
734
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
735
- Dimension rect2 = frame.getToolkit().getScreenSize();
736
- 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);
737753 // frame.setState(Frame.MAXIMIZED_BOTH);
754
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
738755 }
739756
740757 maximized ^= true;
758
+
759
+ frame.validate();
741760 }
761
+
762
+ cButton minButton;
763
+ cButton maxButton;
764
+ cButton fullButton;
742765
743766 void ToggleFullScreen()
744767 {
768
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769
+
745770 cameraView.ToggleFullScreen();
746771
747772 if (!CameraPane.FULLSCREEN)
748773 {
749774 device.setFullScreenWindow(null);
775
+ frame.dispose();
776
+ frame.setUndecorated(false);
777
+ frame.validate();
778
+ frame.setVisible(true);
779
+
750780 //frame.setVisible(false);
751781 // frame.removeNotify();
752782 // frame.setUndecorated(false);
....@@ -756,7 +786,7 @@
756786 // X frame.getContentPane().remove(/*"Center",*/bigThree);
757787 // X framePanel.add(bigThree);
758788 // X frame.getContentPane().add(/*"Center",*/framePanel);
759
- framePanel.setDividerLocation(1);
789
+ framePanel.setDividerLocation(46);
760790
761791 //frame.setVisible(true);
762792 radio.layout = keepButton;
....@@ -771,7 +801,12 @@
771801 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
772802 // frame.getToolkit().getScreenSize().height);
773803 //frame.setVisible(false);
804
+
805
+ frame.dispose();
806
+ frame.setUndecorated(true);
774807 device.setFullScreenWindow(frame);
808
+ frame.validate();
809
+ frame.setVisible(true);
775810 // frame.removeNotify();
776811 // frame.setUndecorated(true);
777812 // frame.addNotify();
....@@ -784,7 +819,30 @@
784819 radio.layout.doClick();
785820 //frame.setVisible(true);
786821 }
822
+ frame.validate();
787823 }
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
+ }
788846
789847 private JTextPane createTextPane()
790848 {
....@@ -916,7 +974,7 @@
916974 // NumberSlider vDivsField;
917975 // JCheckBox endcaps;
918976 JCheckBox liveCB;
919
- JCheckBox selectCB;
977
+ JCheckBox selectableCB;
920978 JCheckBox hideCB;
921979 JCheckBox link2masterCB;
922980 JCheckBox markCB;
....@@ -1116,7 +1174,7 @@
11161174 namePanel = new cGridBag();
11171175
11181176 nameField = AddText(namePanel, copy.GetName());
1119
- namePanel.add(nameField);
1177
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11201178 oe.ctrlPanel.add(namePanel);
11211179
11221180 oe.ctrlPanel.Return();
....@@ -1128,26 +1186,30 @@
11281186
11291187 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11301188 liveCB.setToolTipText("Animate object");
1131
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1132
- selectCB.setToolTipText("Make object selectable");
1189
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
+ selectableCB.setToolTipText("Make object selectable");
11331191 // Return();
1192
+
11341193 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11351194 hideCB.setToolTipText("Hide object");
11361195 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11371196 markCB.setToolTipText("As animation target transform");
1197
+
1198
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11381199
11391200 setupPanel2 = new cGridBag().setVertical(false);
11401201
11411202 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11421203 rewindCB.setToolTipText("Rewind animation");
11431204
1144
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1205
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11451206 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11461207
1208
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1209
+ link2masterCB.setToolTipText("Attach to support");
1210
+
11471211 if (Globals.ADVANCED)
11481212 {
1149
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1150
- link2masterCB.setToolTipText("Attach to support");
11511213 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11521214 speedupCB.setToolTipText("Option motion capture");
11531215 }
....@@ -1421,6 +1483,7 @@
14211483 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14221484 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14231485 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1486
+ //XYZPanel.setName("XYZ");
14241487
14251488 /*
14261489 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1458,13 +1521,23 @@
14581521 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14591522 //tmp.setName("Edit");
14601523 objectPanel.add(materialPanel);
1524
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
14611525 // JPanel north = new JPanel(new BorderLayout());
14621526 // north.setName("Edit");
14631527 // north.add(ctrlPanel, BorderLayout.NORTH);
14641528 // objectPanel.add(north);
14651529 objectPanel.add(editPanel);
1466
- 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
+
14671539 objectPanel.add(toolboxPanel);
1540
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
14681541
14691542 /*
14701543 aConstraints.gridx = 0;
....@@ -1485,7 +1558,7 @@
14851558 scrollpane.addMouseWheelListener(this); // Default not fast enough
14861559
14871560 /*JTabbedPane*/ scenePanel = new cGridBag();
1488
- scenePanel.preferredWidth = 6;
1561
+ scenePanel.preferredWidth = 5;
14891562
14901563 JTabbedPane tabbedPane = new JTabbedPane();
14911564 tabbedPane.add(scrollpane);
....@@ -1561,9 +1634,9 @@
15611634 /**/
15621635
15631636 bigThree = new cGridBag();
1564
- bigThree.addComponent(scenePanel);
15651637 bigThree.addComponent(centralPanel);
1566
- bigThree.addComponent(XYZPanel);
1638
+ bigThree.addComponent(scenePanel);
1639
+ //bigThree.addComponent(XYZPanel);
15671640
15681641 // // SIDE EFFECT!!!
15691642 // aConstraints.gridx = 0;
....@@ -1572,9 +1645,9 @@
15721645 // aConstraints.gridheight = 1;
15731646
15741647 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1575
- framePanel.setContinuousLayout(true);
1576
- framePanel.setOneTouchExpandable(true);
1577
- framePanel.setDividerLocation(0.8);
1648
+ framePanel.setContinuousLayout(false);
1649
+ framePanel.setOneTouchExpandable(false);
1650
+ //.setDividerLocation(0.8);
15781651 //framePanel.setDividerSize(15);
15791652 //framePanel.setResizeWeight(0.15);
15801653 framePanel.setName("Frame");
....@@ -1593,12 +1666,13 @@
15931666
15941667 frame.setSize(1280, 860);
15951668
1596
- frame.validate();
1597
- frame.setVisible(true);
1598
-
15991669 cameraView.requestFocusInWindow();
16001670
16011671 gridPanel.setDividerLocation(1.0);
1672
+
1673
+ frame.validate();
1674
+
1675
+ frame.setVisible(true);
16021676
16031677 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16041678 frame.addWindowListener(new WindowAdapter()
....@@ -1685,24 +1759,6 @@
16851759 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16861760 colorSection.add(texture);
16871761
1688
- cGridBag anisoU = new cGridBag();
1689
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1690
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1692
- colorSection.add(anisoU);
1693
-
1694
- cGridBag anisoV = new cGridBag();
1695
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1696
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1697
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1698
- colorSection.add(anisoV);
1699
-
1700
- cGridBag shadowbias = new cGridBag();
1701
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1702
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1703
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1704
- colorSection.add(shadowbias);
1705
-
17061762 panel.add(new JSeparator());
17071763
17081764 panel.add(colorSection);
....@@ -1752,6 +1808,12 @@
17521808 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17531809 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17541810 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);
17551817
17561818 panel.add(new JSeparator());
17571819
....@@ -1803,6 +1865,18 @@
18031865 // aConstraints.gridy += 1;
18041866 // aConstraints.gridwidth = 1;
18051867
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
+
18061880
18071881 panel.add(new JSeparator());
18081882
....@@ -1810,35 +1884,35 @@
18101884
18111885 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18121886
1813
- cGridBag globalSection = new cGridBag().setVertical(true);
1887
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18141888
18151889 cGridBag camera = new cGridBag();
18161890 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18171891 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18181892 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1819
- globalSection.add(camera);
1893
+ colorSection.add(camera);
18201894
18211895 cGridBag ambient = new cGridBag();
18221896 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18231897 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18241898 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1825
- globalSection.add(ambient);
1899
+ colorSection.add(ambient);
18261900
18271901 cGridBag backlit = new cGridBag();
18281902 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18291903 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18301904 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1831
- globalSection.add(backlit);
1905
+ colorSection.add(backlit);
18321906
18331907 cGridBag opacity = new cGridBag();
18341908 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18351909 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18361910 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1837
- globalSection.add(opacity);
1911
+ colorSection.add(opacity);
18381912
1839
- panel.add(new JSeparator());
1913
+ //panel.add(new JSeparator());
18401914
1841
- panel.add(globalSection);
1915
+ //panel.add(globalSection);
18421916
18431917 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18441918
....@@ -1945,8 +2019,9 @@
19452019 // 3D models
19462020 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19472021 {
1948
- lastConverter = new com.jmex.model.converters.MaxToJme();
1949
- LoadFile(filename, lastConverter);
2022
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2023
+ //LoadFile(filename, lastConverter);
2024
+ LoadObjFile(filename); // New 3ds loader
19502025 continue;
19512026 }
19522027 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2672,6 +2747,7 @@
26722747 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26732748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26742749 }
2750
+
26752751 //cJME.count++;
26762752 //cJME.count %= 12;
26772753 if (gc)
....@@ -2855,6 +2931,7 @@
28552931 }
28562932 }
28572933 }
2934
+
28582935 cFileSystemPane FSPane;
28592936
28602937 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2908,6 +2985,7 @@
29082985 }
29092986 }
29102987 }
2988
+
29112989 freezematerial = false;
29122990 }
29132991
....@@ -3175,7 +3253,7 @@
31753253 {
31763254 copy.live ^= true;
31773255 return;
3178
- } else if (event.getSource() == selectCB)
3256
+ } else if (event.getSource() == selectableCB)
31793257 {
31803258 copy.dontselect ^= true;
31813259 return;
....@@ -3360,9 +3438,9 @@
33603438 {
33613439 Close();
33623440 //return true;
3363
- } else if (source == loadItem)
3441
+ } else if (source == openItem)
33643442 {
3365
- load();
3443
+ Open();
33663444 //return true;
33673445 } else if (source == newItem)
33683446 {
....@@ -3387,6 +3465,10 @@
33873465 {
33883466 generatePOV();
33893467 //return true;
3468
+ } else if (event.getSource() == archiveItem)
3469
+ {
3470
+ cTools.Archive(frame);
3471
+ return;
33903472 } else if (source == zBufferItem)
33913473 {
33923474 try
....@@ -3438,8 +3520,8 @@
34383520 try
34393521 {
34403522 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3441
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3442
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3523
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3524
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34433525
34443526 Object3D parent = o.parent;
34453527 o.parent = null;
....@@ -3450,10 +3532,14 @@
34503532
34513533 out.flush();
34523534
3453
- zstream.close();
3535
+ baos //zstream
3536
+ .close();
34543537 out.close();
34553538
3456
- return baos.toByteArray();
3539
+ byte[] bytes = baos.toByteArray();
3540
+
3541
+ System.out.println("save #bytes = " + bytes.length);
3542
+ return bytes;
34573543 } catch (Exception e)
34583544 {
34593545 System.err.println(e);
....@@ -3463,13 +3549,16 @@
34633549
34643550 static public Object Uncompress(byte[] bytes)
34653551 {
3466
- System.out.println("#bytes = " + bytes.length);
3552
+ System.out.println("restore #bytes = " + bytes.length);
34673553 try
34683554 {
34693555 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3470
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3471
- ObjectInputStream in = new ObjectInputStream(istream);
3556
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3557
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34723558 Object obj = in.readObject();
3559
+
3560
+ bais //istream
3561
+ .close();
34733562 in.close();
34743563
34753564 return obj;
....@@ -3524,31 +3613,67 @@
35243613 return null;
35253614 }
35263615
3527
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35283616
35293617 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)
35303642 {
35313643 System.err.println("Save");
35323644
35333645 cRadio tab = GetCurrentTab();
35343646
3535
- boolean temp = CameraPane.SWITCH;
3536
- CameraPane.SWITCH = false;
3647
+ byte[] compress = CompressCopy();
35373648
3538
- 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
+ }
35393656
35403657 //EditorFrame.m_MainFrame.requestFocusInWindow();
3541
- 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
+ }
35423668
3543
- copy.RestoreBigData(hashtable);
3669
+ //copy.RestoreBigData(versiontable);
35443670
3545
- CameraPane.SWITCH = temp;
3546
-
35473671 //assert(hashtable.isEmpty());
35483672
3549
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3673
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35503674 {
3551
- tab.graphs[i] = null;
3675
+ //tab.user[i] = false;
3676
+ copy.versions[i] = null;
35523677 }
35533678
35543679 SetUndoStates();
....@@ -3558,7 +3683,7 @@
35583683 {
35593684 try
35603685 {
3561
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3686
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35623687 ObjectOutputStream p = new ObjectOutputStream(ostream);
35633688
35643689 p.writeObject(copy);
....@@ -3571,6 +3696,8 @@
35713696 e.printStackTrace();
35723697 }
35733698 }
3699
+
3700
+ return !thesame;
35743701 }
35753702
35763703 void CopyChanged(Object3D obj)
....@@ -3580,7 +3707,7 @@
35803707 boolean temp = CameraPane.SWITCH;
35813708 CameraPane.SWITCH = false;
35823709
3583
- copy.ExtractBigData(hashtable);
3710
+ copy.ExtractBigData(versiontable);
35843711
35853712 copy.clear();
35863713
....@@ -3589,7 +3716,7 @@
35893716 copy.add(obj.get(i));
35903717 }
35913718
3592
- copy.RestoreBigData(hashtable);
3719
+ copy.RestoreBigData(versiontable);
35933720
35943721 CameraPane.SWITCH = temp;
35953722
....@@ -3617,52 +3744,129 @@
36173744 }
36183745
36193746 cButton undoButton;
3747
+ cButton restoreButton;
3748
+ cButton replaceButton;
36203749 cButton redoButton;
36213750
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
+
36223766 void SetUndoStates()
36233767 {
36243768 cRadio tab = GetCurrentTab();
36253769
3626
- undoButton.setEnabled(tab.undoindex > 0);
3627
- 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;
36283780 }
36293781
3630
- public void Undo()
3782
+ public boolean Undo()
36313783 {
3784
+ // Option?
3785
+ Replace();
3786
+
36323787 System.err.println("Undo");
36333788
36343789 cRadio tab = GetCurrentTab();
36353790
3636
- if (tab.undoindex == 0)
3791
+ if (copy.versionindex == 0)
36373792 {
36383793 java.awt.Toolkit.getDefaultToolkit().beep();
3639
- return;
3794
+ return false;
36403795 }
36413796
3642
- 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)
36433824 {
3644
- Save();
3645
- tab.undoindex -= 1;
3825
+ java.awt.Toolkit.getDefaultToolkit().beep();
3826
+ return false;
36463827 }
36473828
3648
- tab.undoindex -= 1;
3829
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3830
+
3831
+ return true;
3832
+ }
36493833
3650
- 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;
36513849 }
36523850
36533851 public void Redo()
36543852 {
3853
+ // Option?
3854
+ Replace();
3855
+
36553856 cRadio tab = GetCurrentTab();
36563857
3657
- if (tab.graphs[tab.undoindex + 1] == null)
3858
+ if (copy.versions[copy.versionindex + 1] == null)
36583859 {
36593860 java.awt.Toolkit.getDefaultToolkit().beep();
36603861 return;
36613862 }
36623863
3663
- tab.undoindex += 1;
3864
+ copy.versionindex += 1;
36643865
3665
- 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;
36663870 }
36673871
36683872 void ImportGFD()
....@@ -3958,9 +4162,25 @@
39584162 //copy.Touch();
39594163 }
39604164
4165
+ cNumberSlider versionSlider;
4166
+
39614167 public void stateChanged(ChangeEvent e)
39624168 {
39634169 // 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
+ }
39644184
39654185 if (freezematerial)
39664186 {
....@@ -4309,7 +4529,7 @@
43094529
43104530 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43114531 {
4312
- if (Globals.SAVEONMAKE) // && resetmodel)
4532
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43134533 Save();
43144534 //Tween.set(thing, 0).target(1).start(tweenManager);
43154535 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4551,7 +4771,9 @@
45514771 readobj.ResetDisplayList();
45524772 } catch (Exception e)
45534773 {
4554
- //e.printStackTrace();
4774
+ if (!e.toString().contains("GZIP"))
4775
+ e.printStackTrace();
4776
+
45554777 try
45564778 {
45574779 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4625,8 +4847,8 @@
46254847
46264848 if (readobj != null)
46274849 {
4628
- if (Globals.SAVEONMAKE)
4629
- Save();
4850
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4851
+ // Save();
46304852 try
46314853 {
46324854 //readobj.deepCopySelf(copy);
....@@ -4671,6 +4893,7 @@
46714893 }
46724894 } catch (ClassCastException e)
46734895 {
4896
+ e.printStackTrace();
46744897 assert (false);
46754898 Composite c = (Composite) copy;
46764899 c.children.clear();
....@@ -4681,13 +4904,24 @@
46814904 c.addChild(csg);
46824905 }
46834906
4907
+ copy.versions = readobj.versions;
4908
+ copy.versionindex = readobj.versionindex;
4909
+
4910
+ if (copy.versions == null)
4911
+ {
4912
+ copy.versions = new byte[100][];
4913
+ copy.versionindex = -1;
4914
+ }
4915
+
4916
+ //? SetUndoStates();
4917
+
46844918 ResetModel();
46854919 copy.HardTouch(); // recompile?
46864920 refreshContents();
46874921 }
46884922 }
46894923
4690
- void load() // throws ClassNotFoundException
4924
+ void Open() // throws ClassNotFoundException
46914925 {
46924926 if (Grafreed.standAlone)
46934927 {
....@@ -4790,6 +5024,7 @@
47905024 //ps.print(buffer.toString());
47915025 } catch (IOException e)
47925026 {
5027
+ e.printStackTrace();
47935028 }
47945029 }
47955030
....@@ -4972,7 +5207,7 @@
49725207 MenuBar menuBar;
49735208 Menu fileMenu;
49745209 MenuItem newItem;
4975
- MenuItem loadItem;
5210
+ MenuItem openItem;
49765211 MenuItem saveItem;
49775212 MenuItem saveAsItem;
49785213 MenuItem exportAsItem;
....@@ -4995,6 +5230,7 @@
49955230 CheckboxMenuItem toggleSwitchItem;
49965231 CheckboxMenuItem toggleRootItem;
49975232 CheckboxMenuItem animationItem;
5233
+ MenuItem archiveItem;
49985234 CheckboxMenuItem toggleHandleItem;
49995235 CheckboxMenuItem togglePaintItem;
50005236 JSplitPane mainPanel;