Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -41,61 +44,47 @@
4144
4245 cButton GetButton(String name, boolean border)
4346 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
47
- return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
51
- return new cButton(name, border);
52
- }
47
+ ImageIcon icon = GetIcon(name);
48
+ return new cButton(icon, border);
5349 }
5450
5551 cToggleButton GetToggleButton(String name, boolean border)
5652 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
53
+ ImageIcon icon = GetIcon(name);
54
+ return new cToggleButton(icon, border);
6655 }
6756
6857 cCheckBox GetCheckBox(String name, boolean border)
6958 {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+
63
+ private ImageIcon GetIcon(String name)
64
+ {
7065 try
7166 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
67
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
68
+
69
+ if (image.getWidth() != 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;
7483 }
7584 catch (Exception e)
7685 {
77
- return new cCheckBox(name, border);
86
+ return null;
7887 }
79
- }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
82
- {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
86
- {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
95
- }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
9988 }
10089
10190 // SCRIPT
....@@ -207,7 +196,7 @@
207196
208197 objEditor.ctrlPanel.remove(namePanel);
209198
210
- if (!GroupEditor.allparams)
199
+ if (!allparams)
211200 return;
212201
213202 // objEditor.ctrlPanel.remove(liveCB);
....@@ -279,6 +268,12 @@
279268 client = inClient;
280269 copy = client;
281270
271
+ if (copy.versions == null)
272
+ {
273
+ copy.versions = new byte[100][];
274
+ copy.versionindex = -1;
275
+ }
276
+
282277 // "this" is not called: SetupUI2(objEditor);
283278 }
284279
....@@ -292,6 +287,12 @@
292287 client = inClient;
293288 copy = client;
294289
290
+ if (copy.versions == null)
291
+ {
292
+ copy.versions = new byte[100][];
293
+ copy.versionindex = -1;
294
+ }
295
+
295296 SetupUI2(callee.GetEditor());
296297 }
297298
....@@ -306,7 +307,7 @@
306307 //localCopy.parent = null;
307308
308309 frame = new JFrame();
309
- frame.setUndecorated(true);
310
+ frame.setUndecorated(false);
310311 objEditor = this;
311312 this.callee = callee;
312313
....@@ -324,6 +325,12 @@
324325 copy = localCopy;
325326 copy.editWindow = this;
326327
328
+ if (copy.versions == null)
329
+ {
330
+ copy.versions = new byte[100][];
331
+ copy.versionindex = -1;
332
+ }
333
+
327334 SetupMenu();
328335
329336 //SetupName(objEditor); // new
....@@ -337,12 +344,17 @@
337344 return frame.action(event, obj);
338345 }
339346
347
+ // Cannot work without static
348
+ static boolean allparams = true;
349
+
350
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
351
+
340352 void SetupMenu()
341353 {
342354 frame.setMenuBar(menuBar = new MenuBar());
343355 menuBar.add(fileMenu = new Menu("File"));
344356 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
357
+ fileMenu.add(openItem = new MenuItem("Open..."));
346358
347359 //oe.menuBar.add(menu = new Menu("Include"));
348360 Menu menu = new Menu("Import");
....@@ -374,7 +386,7 @@
374386 }
375387
376388 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
389
+ openItem.addActionListener(this);
378390 saveItem.addActionListener(this);
379391 saveAsItem.addActionListener(this);
380392 exportAsItem.addActionListener(this);
....@@ -398,6 +410,11 @@
398410 //
399411 // materialFlushed = true;
400412 // }
413
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
414
+// {
415
+// if (listUI.size() == 0)
416
+// EditSelection(false);
417
+// }
401418
402419 refreshContents(false); // To refresh Info tab
403420 }
....@@ -406,11 +423,12 @@
406423
407424 toolbarPanel = new JPanel();
408425 toolbarPanel.setName("Toolbar");
426
+
409427 treePanel = new cGridBag();
410428 treePanel.setName("Tree");
411429
412430 editPanel = new cGridBag().setVertical(true);
413
- editPanel.setName("Edit");
431
+ //editPanel.setName("Edit");
414432
415433 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
416434
....@@ -419,10 +437,10 @@
419437 editPanel.add(ctrlPanel);
420438
421439 toolboxPanel = new cGridBag().setVertical(false);
422
- toolboxPanel.setName("Toolbox");
440
+ //toolboxPanel.setName("Toolbox");
423441
424442 materialPanel = new cGridBag().setVertical(true);
425
- materialPanel.setName("Material");
443
+ //materialPanel.setName("Material");
426444
427445 /*JTextPane*/
428446 infoarea = createTextPane();
....@@ -430,14 +448,15 @@
430448
431449 infoarea.setEditable(true);
432450 SetText();
451
+
433452 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
434453 // infoarea.setOpaque(false);
435454 // //infoarea.setForeground(textcolor);
436455 // TEXTAREA infoarea.setLineWrap(true);
437456 // TEXTAREA infoarea.setWrapStyleWord(true);
438457 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
439
- infoPanel.setPreferredSize(new Dimension(50, 200));
440
- infoPanel.setName("Info");
458
+ infoPanel.setPreferredSize(new Dimension(1, 1));
459
+ //infoPanel.setName("Info");
441460 //infoPanel.setLayout(new BorderLayout());
442461 //infoPanel.add(createTextPane());
443462
....@@ -448,7 +467,14 @@
448467 mainPanel.setDividerSize(9);
449468 mainPanel.setDividerLocation(0.5); //1.0);
450469 mainPanel.setResizeWeight(0.5);
451
-
470
+
471
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
472
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
473
+ divider.setDividerSize(15);
474
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
475
+
476
+ mainPanel.setUI(new BasicSplitPaneUI());
477
+
452478 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
453479 //mainPanel.setLayout(new GridBagLayout());
454480 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -679,8 +705,8 @@
679705 }
680706 }
681707
682
-static GraphicsDevice device = GraphicsEnvironment
683
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
708
+//static GraphicsDevice device = GraphicsEnvironment
709
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
684710
685711 Rectangle keeprect;
686712 cRadio radio;
....@@ -701,10 +727,19 @@
701727 void Minimize()
702728 {
703729 frame.setState(Frame.ICONIFIED);
730
+ frame.validate();
704731 }
705732
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={}
706736 void Maximize()
707737 {
738
+ if (CameraPane.FULLSCREEN)
739
+ {
740
+ ToggleFullScreen();
741
+ }
742
+
708743 if (maximized)
709744 {
710745 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -712,22 +747,36 @@
712747 else
713748 {
714749 keeprect = frame.getBounds();
715
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
- Dimension rect2 = frame.getToolkit().getScreenSize();
717
- 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);
718753 // frame.setState(Frame.MAXIMIZED_BOTH);
754
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
719755 }
720756
721757 maximized ^= true;
758
+
759
+ frame.validate();
722760 }
761
+
762
+ cButton minButton;
763
+ cButton maxButton;
764
+ cButton fullButton;
723765
724766 void ToggleFullScreen()
725767 {
768
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769
+
726770 cameraView.ToggleFullScreen();
727771
728772 if (!CameraPane.FULLSCREEN)
729773 {
730774 device.setFullScreenWindow(null);
775
+ frame.dispose();
776
+ frame.setUndecorated(false);
777
+ frame.validate();
778
+ frame.setVisible(true);
779
+
731780 //frame.setVisible(false);
732781 // frame.removeNotify();
733782 // frame.setUndecorated(false);
....@@ -737,7 +786,7 @@
737786 // X frame.getContentPane().remove(/*"Center",*/bigThree);
738787 // X framePanel.add(bigThree);
739788 // X frame.getContentPane().add(/*"Center",*/framePanel);
740
- framePanel.setDividerLocation(1);
789
+ framePanel.setDividerLocation(46);
741790
742791 //frame.setVisible(true);
743792 radio.layout = keepButton;
....@@ -752,7 +801,12 @@
752801 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
753802 // frame.getToolkit().getScreenSize().height);
754803 //frame.setVisible(false);
804
+
805
+ frame.dispose();
806
+ frame.setUndecorated(true);
755807 device.setFullScreenWindow(frame);
808
+ frame.validate();
809
+ frame.setVisible(true);
756810 // frame.removeNotify();
757811 // frame.setUndecorated(true);
758812 // frame.addNotify();
....@@ -765,7 +819,30 @@
765819 radio.layout.doClick();
766820 //frame.setVisible(true);
767821 }
822
+ frame.validate();
768823 }
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
+ }
769846
770847 private JTextPane createTextPane()
771848 {
....@@ -1097,12 +1174,12 @@
10971174 namePanel = new cGridBag();
10981175
10991176 nameField = AddText(namePanel, copy.GetName());
1100
- namePanel.add(nameField);
1177
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11011178 oe.ctrlPanel.add(namePanel);
11021179
11031180 oe.ctrlPanel.Return();
11041181
1105
- if (!GroupEditor.allparams)
1182
+ if (!allparams)
11061183 return;
11071184
11081185 setupPanel = new cGridBag().setVertical(false);
....@@ -1115,20 +1192,21 @@
11151192 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11161193 hideCB.setToolTipText("Hide object");
11171194 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
- markCB.setToolTipText("Set the animation target transform");
1195
+ markCB.setToolTipText("As animation target transform");
11191196
11201197 setupPanel2 = new cGridBag().setVertical(false);
11211198
11221199 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11231200 rewindCB.setToolTipText("Rewind animation");
11241201
1125
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1202
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1203
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11271204
1205
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1206
+ link2masterCB.setToolTipText("Attach to support");
1207
+
11281208 if (Globals.ADVANCED)
11291209 {
1130
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1131
- link2masterCB.setToolTipText("Attach to support");
11321210 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11331211 speedupCB.setToolTipText("Option motion capture");
11341212 }
....@@ -1402,6 +1480,7 @@
14021480 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14031481 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14041482 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1483
+ //XYZPanel.setName("XYZ");
14051484
14061485 /*
14071486 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1439,13 +1518,23 @@
14391518 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14401519 //tmp.setName("Edit");
14411520 objectPanel.add(materialPanel);
1442
- objectPanel.add(toolboxPanel);
1521
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
14431522 // JPanel north = new JPanel(new BorderLayout());
14441523 // north.setName("Edit");
14451524 // north.add(ctrlPanel, BorderLayout.NORTH);
14461525 // objectPanel.add(north);
14471526 objectPanel.add(editPanel);
1448
- objectPanel.add(infoPanel);
1527
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1528
+
1529
+ //if (Globals.ADVANCED)
1530
+ objectPanel.add(infoPanel);
1531
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1532
+
1533
+ objectPanel.add(XYZPanel);
1534
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1535
+
1536
+ objectPanel.add(toolboxPanel);
1537
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
14491538
14501539 /*
14511540 aConstraints.gridx = 0;
....@@ -1454,7 +1543,7 @@
14541543 aConstraints.gridy += 1;
14551544 aConstraints.gridwidth = 1;
14561545 mainPanel.add(objectPanel, aConstraints);
1457
- */
1546
+ */
14581547
14591548 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14601549 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1466,7 +1555,7 @@
14661555 scrollpane.addMouseWheelListener(this); // Default not fast enough
14671556
14681557 /*JTabbedPane*/ scenePanel = new cGridBag();
1469
- scenePanel.preferredWidth = 6;
1558
+ scenePanel.preferredWidth = 5;
14701559
14711560 JTabbedPane tabbedPane = new JTabbedPane();
14721561 tabbedPane.add(scrollpane);
....@@ -1544,7 +1633,7 @@
15441633 bigThree = new cGridBag();
15451634 bigThree.addComponent(scenePanel);
15461635 bigThree.addComponent(centralPanel);
1547
- bigThree.addComponent(XYZPanel);
1636
+ //bigThree.addComponent(XYZPanel);
15481637
15491638 // // SIDE EFFECT!!!
15501639 // aConstraints.gridx = 0;
....@@ -1553,9 +1642,9 @@
15531642 // aConstraints.gridheight = 1;
15541643
15551644 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1556
- framePanel.setContinuousLayout(true);
1557
- framePanel.setOneTouchExpandable(true);
1558
- framePanel.setDividerLocation(0.8);
1645
+ framePanel.setContinuousLayout(false);
1646
+ framePanel.setOneTouchExpandable(false);
1647
+ //.setDividerLocation(0.8);
15591648 //framePanel.setDividerSize(15);
15601649 //framePanel.setResizeWeight(0.15);
15611650 framePanel.setName("Frame");
....@@ -1574,12 +1663,13 @@
15741663
15751664 frame.setSize(1280, 860);
15761665
1577
- frame.validate();
1578
- frame.setVisible(true);
1579
-
15801666 cameraView.requestFocusInWindow();
15811667
15821668 gridPanel.setDividerLocation(1.0);
1669
+
1670
+ frame.validate();
1671
+
1672
+ frame.setVisible(true);
15831673
15841674 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15851675 frame.addWindowListener(new WindowAdapter()
....@@ -1666,24 +1756,6 @@
16661756 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16671757 colorSection.add(texture);
16681758
1669
- cGridBag anisoU = new cGridBag();
1670
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1671
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1673
- colorSection.add(anisoU);
1674
-
1675
- cGridBag anisoV = new cGridBag();
1676
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1677
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1678
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1679
- colorSection.add(anisoV);
1680
-
1681
- cGridBag shadowbias = new cGridBag();
1682
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1683
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1684
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1685
- colorSection.add(shadowbias);
1686
-
16871759 panel.add(new JSeparator());
16881760
16891761 panel.add(colorSection);
....@@ -1733,6 +1805,12 @@
17331805 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17341806 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17351807 diffuseSection.add(fakedepth);
1808
+
1809
+ cGridBag shadowbias = new cGridBag();
1810
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1811
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1812
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1813
+ diffuseSection.add(shadowbias);
17361814
17371815 panel.add(new JSeparator());
17381816
....@@ -1784,6 +1862,18 @@
17841862 // aConstraints.gridy += 1;
17851863 // aConstraints.gridwidth = 1;
17861864
1865
+ cGridBag anisoU = new cGridBag();
1866
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1867
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1868
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1869
+ specularSection.add(anisoU);
1870
+
1871
+ cGridBag anisoV = new cGridBag();
1872
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1873
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1874
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1875
+ specularSection.add(anisoV);
1876
+
17871877
17881878 panel.add(new JSeparator());
17891879
....@@ -1791,35 +1881,35 @@
17911881
17921882 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17931883
1794
- cGridBag globalSection = new cGridBag().setVertical(true);
1884
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17951885
17961886 cGridBag camera = new cGridBag();
17971887 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17981888 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17991889 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1800
- globalSection.add(camera);
1890
+ colorSection.add(camera);
18011891
18021892 cGridBag ambient = new cGridBag();
18031893 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18041894 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18051895 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1806
- globalSection.add(ambient);
1896
+ colorSection.add(ambient);
18071897
18081898 cGridBag backlit = new cGridBag();
18091899 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18101900 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18111901 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1812
- globalSection.add(backlit);
1902
+ colorSection.add(backlit);
18131903
18141904 cGridBag opacity = new cGridBag();
18151905 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18161906 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18171907 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
- globalSection.add(opacity);
1908
+ colorSection.add(opacity);
18191909
1820
- panel.add(new JSeparator());
1910
+ //panel.add(new JSeparator());
18211911
1822
- panel.add(globalSection);
1912
+ //panel.add(globalSection);
18231913
18241914 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18251915
....@@ -1926,8 +2016,9 @@
19262016 // 3D models
19272017 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19282018 {
1929
- lastConverter = new com.jmex.model.converters.MaxToJme();
1930
- LoadFile(filename, lastConverter);
2019
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2020
+ //LoadFile(filename, lastConverter);
2021
+ LoadObjFile(filename); // New 3ds loader
19312022 continue;
19322023 }
19332024 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2653,6 +2744,7 @@
26532744 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26542745 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26552746 }
2747
+
26562748 //cJME.count++;
26572749 //cJME.count %= 12;
26582750 if (gc)
....@@ -2836,6 +2928,7 @@
28362928 }
28372929 }
28382930 }
2931
+
28392932 cFileSystemPane FSPane;
28402933
28412934 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2889,6 +2982,7 @@
28892982 }
28902983 }
28912984 }
2985
+
28922986 freezematerial = false;
28932987 }
28942988
....@@ -3007,12 +3101,17 @@
30073101 // }
30083102
30093103 /**/
3010
- if (deselect)
3104
+ if (deselect || child == null)
30113105 {
30123106 //group.deselectAll();
30133107 //freeze = true;
30143108 GetTree().clearSelection();
30153109 //freeze = false;
3110
+
3111
+ if (child == null)
3112
+ {
3113
+ return;
3114
+ }
30163115 }
30173116
30183117 //group.addSelectee(child);
....@@ -3336,9 +3435,9 @@
33363435 {
33373436 Close();
33383437 //return true;
3339
- } else if (source == loadItem)
3438
+ } else if (source == openItem)
33403439 {
3341
- load();
3440
+ Open();
33423441 //return true;
33433442 } else if (source == newItem)
33443443 {
....@@ -3363,6 +3462,10 @@
33633462 {
33643463 generatePOV();
33653464 //return true;
3465
+ } else if (event.getSource() == archiveItem)
3466
+ {
3467
+ cTools.Archive(frame);
3468
+ return;
33663469 } else if (source == zBufferItem)
33673470 {
33683471 try
....@@ -3414,8 +3517,8 @@
34143517 try
34153518 {
34163519 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3417
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3418
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3520
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3521
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34193522
34203523 Object3D parent = o.parent;
34213524 o.parent = null;
....@@ -3426,10 +3529,14 @@
34263529
34273530 out.flush();
34283531
3429
- zstream.close();
3532
+ baos //zstream
3533
+ .close();
34303534 out.close();
34313535
3432
- return baos.toByteArray();
3536
+ byte[] bytes = baos.toByteArray();
3537
+
3538
+ System.out.println("save #bytes = " + bytes.length);
3539
+ return bytes;
34333540 } catch (Exception e)
34343541 {
34353542 System.err.println(e);
....@@ -3439,13 +3546,16 @@
34393546
34403547 static public Object Uncompress(byte[] bytes)
34413548 {
3442
- System.out.println("#bytes = " + bytes.length);
3549
+ System.out.println("restore #bytes = " + bytes.length);
34433550 try
34443551 {
34453552 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3446
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3447
- ObjectInputStream in = new ObjectInputStream(istream);
3553
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3554
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34483555 Object obj = in.readObject();
3556
+
3557
+ bais //istream
3558
+ .close();
34493559 in.close();
34503560
34513561 return obj;
....@@ -3500,39 +3610,77 @@
35003610 return null;
35013611 }
35023612
3503
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35043613
35053614 public void Save()
3615
+ {
3616
+ //Save(true);
3617
+ Replace();
3618
+ }
3619
+
3620
+ private boolean Equal(byte[] compress, byte[] name)
3621
+ {
3622
+ if (compress.length != name.length)
3623
+ {
3624
+ return false;
3625
+ }
3626
+
3627
+ for (int i=compress.length; --i>=0;)
3628
+ {
3629
+ if (compress[i] != name[i])
3630
+ return false;
3631
+ }
3632
+
3633
+ return true;
3634
+ }
3635
+
3636
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3637
+
3638
+ public boolean Save(boolean user)
35063639 {
35073640 System.err.println("Save");
35083641
35093642 cRadio tab = GetCurrentTab();
35103643
3511
- boolean temp = CameraPane.SWITCH;
3512
- CameraPane.SWITCH = false;
3644
+ byte[] compress = CompressCopy();
35133645
3514
- copy.ExtractBigData(hashtable);
3646
+ boolean thesame = false;
3647
+
3648
+ // Quick heuristic using length. Works only when stream is compressed.
3649
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3650
+ {
3651
+ thesame = true;
3652
+ }
35153653
35163654 //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
- tab.graphs[tab.undoindex++] = Compress(copy);
3518
-
3519
- copy.RestoreBigData(hashtable);
3520
-
3521
- CameraPane.SWITCH = temp;
3522
-
3523
- //assert(hashtable.isEmpty());
3524
-
3525
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3655
+ if (!thesame)
35263656 {
3527
- tab.graphs[i] = null;
3657
+ //tab.user[tab.versionindex] = user;
3658
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3659
+
3660
+ copy.versions[++copy.versionindex] = compress;
3661
+
3662
+ // if (increment)
3663
+ // tab.versionindex++;
35283664 }
35293665
3666
+ //copy.RestoreBigData(versiontable);
3667
+
3668
+ //assert(hashtable.isEmpty());
3669
+
3670
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3671
+ {
3672
+ //tab.user[i] = false;
3673
+ copy.versions[i] = null;
3674
+ }
3675
+
3676
+ SetUndoStates();
3677
+
35303678 // test save
35313679 if (false)
35323680 {
35333681 try
35343682 {
3535
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3683
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35363684 ObjectOutputStream p = new ObjectOutputStream(ostream);
35373685
35383686 p.writeObject(copy);
....@@ -3545,14 +3693,18 @@
35453693 e.printStackTrace();
35463694 }
35473695 }
3696
+
3697
+ return !thesame;
35483698 }
35493699
35503700 void CopyChanged(Object3D obj)
35513701 {
3702
+ SetUndoStates();
3703
+
35523704 boolean temp = CameraPane.SWITCH;
35533705 CameraPane.SWITCH = false;
35543706
3555
- copy.ExtractBigData(hashtable);
3707
+ copy.ExtractBigData(versiontable);
35563708
35573709 copy.clear();
35583710
....@@ -3561,7 +3713,7 @@
35613713 copy.add(obj.get(i));
35623714 }
35633715
3564
- copy.RestoreBigData(hashtable);
3716
+ copy.RestoreBigData(versiontable);
35653717
35663718 CameraPane.SWITCH = temp;
35673719
....@@ -3588,42 +3740,130 @@
35883740 refreshContents();
35893741 }
35903742
3591
- public void Undo()
3743
+ cButton undoButton;
3744
+ cButton restoreButton;
3745
+ cButton replaceButton;
3746
+ cButton redoButton;
3747
+
3748
+ boolean muteSlider;
3749
+
3750
+ int VersionCount()
35923751 {
3752
+ int count = 0;
3753
+
3754
+ for (int i = copy.versions.length; --i >= 0;)
3755
+ {
3756
+ if (copy.versions[i] != null)
3757
+ count++;
3758
+ }
3759
+
3760
+ return count;
3761
+ }
3762
+
3763
+ void SetUndoStates()
3764
+ {
3765
+ cRadio tab = GetCurrentTab();
3766
+
3767
+ restoreButton.setEnabled(copy.versionindex != -1);
3768
+ replaceButton.setEnabled(copy.versionindex != -1);
3769
+
3770
+ undoButton.setEnabled(copy.versionindex > 0);
3771
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3772
+
3773
+ muteSlider = true;
3774
+ versionSlider.setMaximum(VersionCount() - 1);
3775
+ versionSlider.setInteger(copy.versionindex);
3776
+ muteSlider = false;
3777
+ }
3778
+
3779
+ public boolean Undo()
3780
+ {
3781
+ // Option?
3782
+ Replace();
3783
+
35933784 System.err.println("Undo");
35943785
35953786 cRadio tab = GetCurrentTab();
35963787
3597
- if (tab.undoindex == 0)
3788
+ if (copy.versionindex == 0)
35983789 {
35993790 java.awt.Toolkit.getDefaultToolkit().beep();
3600
- return;
3791
+ return false;
36013792 }
36023793
3603
- if (tab.graphs[tab.undoindex] == null)
3794
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3795
+// {
3796
+// if (Save(false))
3797
+// tab.versionindex -= 1;
3798
+// else
3799
+// {
3800
+// if (tab.versionindex <= 0)
3801
+// return false;
3802
+// else
3803
+// tab.versionindex -= 1;
3804
+// }
3805
+// }
3806
+
3807
+ copy.versionindex -= 1;
3808
+
3809
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3810
+
3811
+ return true;
3812
+ }
3813
+
3814
+ public boolean Restore()
3815
+ {
3816
+ System.err.println("Restore");
3817
+
3818
+ cRadio tab = GetCurrentTab();
3819
+
3820
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36043821 {
3605
- Save();
3606
- tab.undoindex -= 1;
3822
+ java.awt.Toolkit.getDefaultToolkit().beep();
3823
+ return false;
36073824 }
36083825
3609
- tab.undoindex -= 1;
3826
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3827
+
3828
+ return true;
3829
+ }
36103830
3611
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3831
+ public boolean Replace()
3832
+ {
3833
+ System.err.println("Replace");
3834
+
3835
+ cRadio tab = GetCurrentTab();
3836
+
3837
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3838
+ {
3839
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3840
+ return false;
3841
+ }
3842
+
3843
+ copy.versions[copy.versionindex] = CompressCopy();
3844
+
3845
+ return true;
36123846 }
36133847
36143848 public void Redo()
36153849 {
3850
+ // Option?
3851
+ Replace();
3852
+
36163853 cRadio tab = GetCurrentTab();
36173854
3618
- if (tab.graphs[tab.undoindex + 1] == null)
3855
+ if (copy.versions[copy.versionindex + 1] == null)
36193856 {
36203857 java.awt.Toolkit.getDefaultToolkit().beep();
36213858 return;
36223859 }
36233860
3624
- tab.undoindex += 1;
3861
+ copy.versionindex += 1;
36253862
3626
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3863
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+
3865
+ //if (!tab.user[tab.versionindex])
3866
+ // tab.graphs[tab.versionindex] = null;
36273867 }
36283868
36293869 void ImportGFD()
....@@ -3919,9 +4159,25 @@
39194159 //copy.Touch();
39204160 }
39214161
4162
+ cNumberSlider versionSlider;
4163
+
39224164 public void stateChanged(ChangeEvent e)
39234165 {
39244166 // assert(false);
4167
+ if (e.getSource() == versionSlider)
4168
+ {
4169
+ if (muteSlider)
4170
+ return;
4171
+
4172
+ int version = versionSlider.getInteger();
4173
+
4174
+ if (copy.versions[version] != null)
4175
+ {
4176
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4177
+ }
4178
+
4179
+ return;
4180
+ }
39254181
39264182 if (freezematerial)
39274183 {
....@@ -4270,7 +4526,7 @@
42704526
42714527 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42724528 {
4273
- if (Globals.SAVEONMAKE) // && resetmodel)
4529
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42744530 Save();
42754531 //Tween.set(thing, 0).target(1).start(tweenManager);
42764532 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4586,8 +4842,8 @@
45864842
45874843 if (readobj != null)
45884844 {
4589
- if (Globals.SAVEONMAKE)
4590
- Save();
4845
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4846
+ // Save();
45914847 try
45924848 {
45934849 //readobj.deepCopySelf(copy);
....@@ -4642,13 +4898,24 @@
46424898 c.addChild(csg);
46434899 }
46444900
4901
+ copy.versions = readobj.versions;
4902
+ copy.versionindex = readobj.versionindex;
4903
+
4904
+ if (copy.versions == null)
4905
+ {
4906
+ copy.versions = new byte[100][];
4907
+ copy.versionindex = -1;
4908
+ }
4909
+
4910
+ //? SetUndoStates();
4911
+
46454912 ResetModel();
46464913 copy.HardTouch(); // recompile?
46474914 refreshContents();
46484915 }
46494916 }
46504917
4651
- void load() // throws ClassNotFoundException
4918
+ void Open() // throws ClassNotFoundException
46524919 {
46534920 if (Grafreed.standAlone)
46544921 {
....@@ -4765,6 +5032,8 @@
47655032 String filename = browser.getFile();
47665033 if (filename != null && filename.length() > 0)
47675034 {
5035
+ if (!filename.endsWith(".gfd"))
5036
+ filename += ".gfd";
47685037 lastname = browser.getDirectory() + filename;
47695038 save();
47705039 }
....@@ -4931,7 +5200,7 @@
49315200 MenuBar menuBar;
49325201 Menu fileMenu;
49335202 MenuItem newItem;
4934
- MenuItem loadItem;
5203
+ MenuItem openItem;
49355204 MenuItem saveItem;
49365205 MenuItem saveAsItem;
49375206 MenuItem exportAsItem;
....@@ -4954,6 +5223,7 @@
49545223 CheckboxMenuItem toggleSwitchItem;
49555224 CheckboxMenuItem toggleRootItem;
49565225 CheckboxMenuItem animationItem;
5226
+ MenuItem archiveItem;
49575227 CheckboxMenuItem toggleHandleItem;
49585228 CheckboxMenuItem togglePaintItem;
49595229 JSplitPane mainPanel;