Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -37,6 +41,65 @@
3741 JFrame frame;
3842
3943 static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
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
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
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
+ }
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ try
74
+ {
75
+ ImageIcon icon = GetIcon(name);
76
+ return new cCheckBox(icon, border);
77
+ }
78
+ catch (Exception e)
79
+ {
80
+ return new cCheckBox(name, border);
81
+ }
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;
102
+ }
40103
41104 // SCRIPT
42105
....@@ -147,7 +210,7 @@
147210
148211 objEditor.ctrlPanel.remove(namePanel);
149212
150
- if (!GroupEditor.allparams)
213
+ if (!allparams)
151214 return;
152215
153216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -246,7 +309,7 @@
246309 //localCopy.parent = null;
247310
248311 frame = new JFrame();
249
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
250313 objEditor = this;
251314 this.callee = callee;
252315
....@@ -277,12 +340,17 @@
277340 return frame.action(event, obj);
278341 }
279342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
280348 void SetupMenu()
281349 {
282350 frame.setMenuBar(menuBar = new MenuBar());
283351 menuBar.add(fileMenu = new Menu("File"));
284352 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
286354
287355 //oe.menuBar.add(menu = new Menu("Include"));
288356 Menu menu = new Menu("Import");
....@@ -314,7 +382,7 @@
314382 }
315383
316384 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
318386 saveItem.addActionListener(this);
319387 saveAsItem.addActionListener(this);
320388 exportAsItem.addActionListener(this);
....@@ -323,6 +391,32 @@
323391 closeItem.addActionListener(this);
324392
325393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
326420 toolbarPanel = new JPanel();
327421 toolbarPanel.setName("Toolbar");
328422 treePanel = new cGridBag();
....@@ -337,9 +431,12 @@
337431 editPanel.add(editCommandsPanel);
338432 editPanel.add(ctrlPanel);
339433
340
- materialPanel = new cGridBag().setVertical(true);
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
341436
437
+ materialPanel = new cGridBag().setVertical(true);
342438 materialPanel.setName("Material");
439
+
343440 /*JTextPane*/
344441 infoarea = createTextPane();
345442 doc = infoarea.getStyledDocument();
....@@ -352,7 +449,7 @@
352449 // TEXTAREA infoarea.setLineWrap(true);
353450 // TEXTAREA infoarea.setWrapStyleWord(true);
354451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
355
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
356453 infoPanel.setName("Info");
357454 //infoPanel.setLayout(new BorderLayout());
358455 //infoPanel.add(createTextPane());
....@@ -364,7 +461,14 @@
364461 mainPanel.setDividerSize(9);
365462 mainPanel.setDividerLocation(0.5); //1.0);
366463 mainPanel.setResizeWeight(0.5);
367
-
464
+
465
+//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!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
368472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
369473 //mainPanel.setLayout(new GridBagLayout());
370474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -595,8 +699,8 @@
595699 }
596700 }
597701
598
-static GraphicsDevice device = GraphicsEnvironment
599
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
600704
601705 Rectangle keeprect;
602706 cRadio radio;
....@@ -612,13 +716,24 @@
612716
613717 boolean maximized;
614718
719
+ cButton fullscreenLayout;
720
+
615721 void Minimize()
616722 {
617723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
618725 }
619726
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
620730 void Maximize()
621731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
622737 if (maximized)
623738 {
624739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -626,20 +741,36 @@
626741 else
627742 {
628743 keeprect = frame.getBounds();
629
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
- Dimension rect2 = frame.getToolkit().getScreenSize();
631
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
632747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
633749 }
634750
635751 maximized ^= true;
752
+
753
+ frame.validate();
636754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
637759
638760 void ToggleFullScreen()
639761 {
640
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
641767 {
642768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
643774 //frame.setVisible(false);
644775 // frame.removeNotify();
645776 // frame.setUndecorated(false);
....@@ -649,7 +780,7 @@
649780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
650781 // X framePanel.add(bigThree);
651782 // X frame.getContentPane().add(/*"Center",*/framePanel);
652
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
653784
654785 //frame.setVisible(true);
655786 radio.layout = keepButton;
....@@ -664,7 +795,12 @@
664795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665796 // frame.getToolkit().getScreenSize().height);
666797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
667801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
668804 // frame.removeNotify();
669805 // frame.setUndecorated(true);
670806 // frame.addNotify();
....@@ -673,13 +809,34 @@
673809 // X frame.getContentPane().add(/*"Center",*/bigThree);
674810 framePanel.setDividerLocation(0);
675811
676
- radio.layout = twoButton;
812
+ radio.layout = fullscreenLayout;
677813 radio.layout.doClick();
678814 //frame.setVisible(true);
679815 }
680
-
681
- cameraView.ToggleFullScreen();
816
+ frame.validate();
682817 }
818
+
819
+ private byte[] CompressCopy()
820
+ {
821
+ boolean temp = CameraPane.SWITCH;
822
+ CameraPane.SWITCH = false;
823
+
824
+ copy.ExtractBigData(versiontable);
825
+ // if (copy == client)
826
+
827
+ byte[] versions[] = copy.versions;
828
+ copy.versions = null;
829
+
830
+ byte[] compress = Compress(copy);
831
+
832
+ copy.versions = versions;
833
+
834
+ copy.RestoreBigData(versiontable);
835
+
836
+ CameraPane.SWITCH = temp;
837
+
838
+ return compress;
839
+ }
683840
684841 private JTextPane createTextPane()
685842 {
....@@ -819,7 +976,12 @@
819976 JCheckBox speedupCB;
820977 JCheckBox rewindCB;
821978 JCheckBox flipVCB;
979
+
980
+ cCheckBox toggleTextureCB;
981
+ cCheckBox toggleSwitchCB;
982
+
822983 JComboBox texresMenu;
984
+
823985 JButton resetButton;
824986 JButton stepButton;
825987 JButton stepAllButton;
....@@ -1006,12 +1168,12 @@
10061168 namePanel = new cGridBag();
10071169
10081170 nameField = AddText(namePanel, copy.GetName());
1009
- namePanel.add(nameField);
1171
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10101172 oe.ctrlPanel.add(namePanel);
10111173
10121174 oe.ctrlPanel.Return();
10131175
1014
- if (!GroupEditor.allparams)
1176
+ if (!allparams)
10151177 return;
10161178
10171179 setupPanel = new cGridBag().setVertical(false);
....@@ -1024,20 +1186,21 @@
10241186 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10251187 hideCB.setToolTipText("Hide object");
10261188 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1027
- markCB.setToolTipText("Set the animation target transform");
1189
+ markCB.setToolTipText("As animation target transform");
10281190
10291191 setupPanel2 = new cGridBag().setVertical(false);
10301192
10311193 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10321194 rewindCB.setToolTipText("Rewind animation");
10331195
1034
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1196
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1197
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10361198
1199
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1200
+ link2masterCB.setToolTipText("Attach to support");
1201
+
10371202 if (Globals.ADVANCED)
10381203 {
1039
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1040
- link2masterCB.setToolTipText("Attach to support");
10411204 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10421205 speedupCB.setToolTipText("Option motion capture");
10431206 }
....@@ -1353,7 +1516,11 @@
13531516 // north.add(ctrlPanel, BorderLayout.NORTH);
13541517 // objectPanel.add(north);
13551518 objectPanel.add(editPanel);
1356
- objectPanel.add(infoPanel);
1519
+
1520
+ //if (Globals.ADVANCED)
1521
+ objectPanel.add(infoPanel);
1522
+
1523
+ objectPanel.add(toolboxPanel);
13571524
13581525 /*
13591526 aConstraints.gridx = 0;
....@@ -1362,7 +1529,7 @@
13621529 aConstraints.gridy += 1;
13631530 aConstraints.gridwidth = 1;
13641531 mainPanel.add(objectPanel, aConstraints);
1365
- */
1532
+ */
13661533
13671534 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13681535 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1379,9 +1546,7 @@
13791546 JTabbedPane tabbedPane = new JTabbedPane();
13801547 tabbedPane.add(scrollpane);
13811548
1382
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1383
-
1384
- optionsPanel = new cGridBag().setVertical(true);
1549
+ optionsPanel = new cGridBag().setVertical(false);
13851550
13861551 optionsPanel.setName("Options");
13871552
....@@ -1389,6 +1554,8 @@
13891554
13901555 tabbedPane.add(optionsPanel);
13911556
1557
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1558
+
13921559 scenePanel.add(tabbedPane);
13931560
13941561 /*
....@@ -1461,9 +1628,9 @@
14611628 // aConstraints.gridheight = 1;
14621629
14631630 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1464
- framePanel.setContinuousLayout(true);
1465
- framePanel.setOneTouchExpandable(true);
1466
- framePanel.setDividerLocation(0.8);
1631
+ framePanel.setContinuousLayout(false);
1632
+ framePanel.setOneTouchExpandable(false);
1633
+ //.setDividerLocation(0.8);
14671634 //framePanel.setDividerSize(15);
14681635 //framePanel.setResizeWeight(0.15);
14691636 framePanel.setName("Frame");
....@@ -1481,11 +1648,14 @@
14811648 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14821649
14831650 frame.setSize(1280, 860);
1484
- frame.setVisible(true);
1485
-
1651
+
14861652 cameraView.requestFocusInWindow();
14871653
14881654 gridPanel.setDividerLocation(1.0);
1655
+
1656
+ frame.validate();
1657
+
1658
+ frame.setVisible(true);
14891659
14901660 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14911661 frame.addWindowListener(new WindowAdapter()
....@@ -1572,24 +1742,6 @@
15721742 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15731743 colorSection.add(texture);
15741744
1575
- cGridBag anisoU = new cGridBag();
1576
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1577
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1579
- colorSection.add(anisoU);
1580
-
1581
- cGridBag anisoV = new cGridBag();
1582
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1583
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1585
- colorSection.add(anisoV);
1586
-
1587
- cGridBag shadowbias = new cGridBag();
1588
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1589
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1591
- colorSection.add(shadowbias);
1592
-
15931745 panel.add(new JSeparator());
15941746
15951747 panel.add(colorSection);
....@@ -1639,6 +1791,12 @@
16391791 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16401792 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16411793 diffuseSection.add(fakedepth);
1794
+
1795
+ cGridBag shadowbias = new cGridBag();
1796
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1797
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1798
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1799
+ diffuseSection.add(shadowbias);
16421800
16431801 panel.add(new JSeparator());
16441802
....@@ -1690,6 +1848,18 @@
16901848 // aConstraints.gridy += 1;
16911849 // aConstraints.gridwidth = 1;
16921850
1851
+ cGridBag anisoU = new cGridBag();
1852
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1853
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1854
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1855
+ specularSection.add(anisoU);
1856
+
1857
+ cGridBag anisoV = new cGridBag();
1858
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1859
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1860
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1861
+ specularSection.add(anisoV);
1862
+
16931863
16941864 panel.add(new JSeparator());
16951865
....@@ -1697,35 +1867,35 @@
16971867
16981868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16991869
1700
- cGridBag globalSection = new cGridBag().setVertical(true);
1870
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17011871
17021872 cGridBag camera = new cGridBag();
17031873 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17041874 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17051875 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(camera);
1876
+ colorSection.add(camera);
17071877
17081878 cGridBag ambient = new cGridBag();
17091879 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17101880 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17111881 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1712
- globalSection.add(ambient);
1882
+ colorSection.add(ambient);
17131883
17141884 cGridBag backlit = new cGridBag();
17151885 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17161886 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17171887 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1718
- globalSection.add(backlit);
1888
+ colorSection.add(backlit);
17191889
17201890 cGridBag opacity = new cGridBag();
17211891 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17221892 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17231893 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1724
- globalSection.add(opacity);
1894
+ colorSection.add(opacity);
17251895
1726
- panel.add(new JSeparator());
1896
+ //panel.add(new JSeparator());
17271897
1728
- panel.add(globalSection);
1898
+ //panel.add(globalSection);
17291899
17301900 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17311901
....@@ -1832,8 +2002,9 @@
18322002 // 3D models
18332003 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18342004 {
1835
- lastConverter = new com.jmex.model.converters.MaxToJme();
1836
- LoadFile(filename, lastConverter);
2005
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2006
+ //LoadFile(filename, lastConverter);
2007
+ LoadObjFile(filename); // New 3ds loader
18372008 continue;
18382009 }
18392010 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2559,6 +2730,7 @@
25592730 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25602731 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25612732 }
2733
+
25622734 //cJME.count++;
25632735 //cJME.count %= 12;
25642736 if (gc)
....@@ -2742,6 +2914,7 @@
27422914 }
27432915 }
27442916 }
2917
+
27452918 cFileSystemPane FSPane;
27462919
27472920 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2795,11 +2968,14 @@
27952968 }
27962969 }
27972970 }
2971
+
27982972 freezematerial = false;
27992973 }
28002974
28012975 void SetMaterial(Object3D object)
28022976 {
2977
+ latestObject = object;
2978
+
28032979 cMaterial mat = object.material;
28042980
28052981 if (mat == null)
....@@ -2911,12 +3087,17 @@
29113087 // }
29123088
29133089 /**/
2914
- if (deselect)
3090
+ if (deselect || child == null)
29153091 {
29163092 //group.deselectAll();
29173093 //freeze = true;
29183094 GetTree().clearSelection();
29193095 //freeze = false;
3096
+
3097
+ if (child == null)
3098
+ {
3099
+ return;
3100
+ }
29203101 }
29213102
29223103 //group.addSelectee(child);
....@@ -2985,7 +3166,7 @@
29853166 cameraView.ToggleDL();
29863167 cameraView.repaint();
29873168 return;
2988
- } else if (event.getSource() == toggleTextureItem)
3169
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29893170 {
29903171 cameraView.ToggleTexture();
29913172 // june 2013 copy.HardTouch();
....@@ -3024,7 +3205,7 @@
30243205 frame.validate();
30253206
30263207 return;
3027
- } else if (event.getSource() == toggleSwitchItem)
3208
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30283209 {
30293210 cameraView.ToggleSwitch();
30303211 cameraView.repaint();
....@@ -3240,9 +3421,9 @@
32403421 {
32413422 Close();
32423423 //return true;
3243
- } else if (source == loadItem)
3424
+ } else if (source == openItem)
32443425 {
3245
- load();
3426
+ Open();
32463427 //return true;
32473428 } else if (source == newItem)
32483429 {
....@@ -3267,6 +3448,10 @@
32673448 {
32683449 generatePOV();
32693450 //return true;
3451
+ } else if (event.getSource() == archiveItem)
3452
+ {
3453
+ cTools.Archive(frame);
3454
+ return;
32703455 } else if (source == zBufferItem)
32713456 {
32723457 try
....@@ -3318,8 +3503,8 @@
33183503 try
33193504 {
33203505 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3321
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3322
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3506
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3507
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33233508
33243509 Object3D parent = o.parent;
33253510 o.parent = null;
....@@ -3330,10 +3515,14 @@
33303515
33313516 out.flush();
33323517
3333
- zstream.close();
3518
+ baos //zstream
3519
+ .close();
33343520 out.close();
33353521
3336
- return baos.toByteArray();
3522
+ byte[] bytes = baos.toByteArray();
3523
+
3524
+ System.out.println("save #bytes = " + bytes.length);
3525
+ return bytes;
33373526 } catch (Exception e)
33383527 {
33393528 System.err.println(e);
....@@ -3343,13 +3532,16 @@
33433532
33443533 static public Object Uncompress(byte[] bytes)
33453534 {
3346
- System.out.println("#bytes = " + bytes.length);
3535
+ System.out.println("restore #bytes = " + bytes.length);
33473536 try
33483537 {
33493538 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3350
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3351
- ObjectInputStream in = new ObjectInputStream(istream);
3539
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3540
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33523541 Object obj = in.readObject();
3542
+
3543
+ bais //istream
3544
+ .close();
33533545 in.close();
33543546
33553547 return obj;
....@@ -3404,37 +3596,77 @@
34043596 return null;
34053597 }
34063598
3407
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34083599
34093600 public void Save()
34103601 {
3602
+ //Save(true);
3603
+ Replace();
3604
+ }
3605
+
3606
+ private boolean Equal(byte[] compress, byte[] name)
3607
+ {
3608
+ if (compress.length != name.length)
3609
+ {
3610
+ return false;
3611
+ }
3612
+
3613
+ for (int i=compress.length; --i>=0;)
3614
+ {
3615
+ if (compress[i] != name[i])
3616
+ return false;
3617
+ }
3618
+
3619
+ return true;
3620
+ }
3621
+
3622
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3623
+
3624
+ public boolean Save(boolean user)
3625
+ {
3626
+ System.err.println("Save");
3627
+
34113628 cRadio tab = GetCurrentTab();
34123629
3413
- boolean temp = CameraPane.SWITCH;
3414
- CameraPane.SWITCH = false;
3630
+ byte[] compress = CompressCopy();
34153631
3416
- copy.ExtractBigData(hashtable);
3632
+ boolean thesame = false;
3633
+
3634
+ // Quick heuristic using length. Works only when stream is compressed.
3635
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3636
+ {
3637
+ thesame = true;
3638
+ }
34173639
34183640 //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
- tab.graphs[tab.undoindex++] = Compress(copy);
3420
-
3421
- copy.RestoreBigData(hashtable);
3422
-
3423
- CameraPane.SWITCH = temp;
3424
-
3425
- //assert(hashtable.isEmpty());
3426
-
3427
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3641
+ if (!thesame)
34283642 {
3429
- tab.graphs[i] = null;
3643
+ //tab.user[tab.versionindex] = user;
3644
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3645
+
3646
+ copy.versions[++copy.versionindex] = compress;
3647
+
3648
+ // if (increment)
3649
+ // tab.versionindex++;
34303650 }
34313651
3652
+ //copy.RestoreBigData(versiontable);
3653
+
3654
+ //assert(hashtable.isEmpty());
3655
+
3656
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3657
+ {
3658
+ //tab.user[i] = false;
3659
+ copy.versions[i] = null;
3660
+ }
3661
+
3662
+ SetUndoStates();
3663
+
34323664 // test save
34333665 if (false)
34343666 {
34353667 try
34363668 {
3437
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3669
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34383670 ObjectOutputStream p = new ObjectOutputStream(ostream);
34393671
34403672 p.writeObject(copy);
....@@ -3447,14 +3679,18 @@
34473679 e.printStackTrace();
34483680 }
34493681 }
3682
+
3683
+ return !thesame;
34503684 }
34513685
34523686 void CopyChanged(Object3D obj)
34533687 {
3688
+ SetUndoStates();
3689
+
34543690 boolean temp = CameraPane.SWITCH;
34553691 CameraPane.SWITCH = false;
34563692
3457
- copy.ExtractBigData(hashtable);
3693
+ copy.ExtractBigData(versiontable);
34583694
34593695 copy.clear();
34603696
....@@ -3463,7 +3699,7 @@
34633699 copy.add(obj.get(i));
34643700 }
34653701
3466
- copy.RestoreBigData(hashtable);
3702
+ copy.RestoreBigData(versiontable);
34673703
34683704 CameraPane.SWITCH = temp;
34693705
....@@ -3490,40 +3726,103 @@
34903726 refreshContents();
34913727 }
34923728
3493
- public void Undo()
3729
+ cButton undoButton;
3730
+ cButton restoreButton;
3731
+ cButton replaceButton;
3732
+ cButton redoButton;
3733
+
3734
+ void SetUndoStates()
34943735 {
34953736 cRadio tab = GetCurrentTab();
34963737
3497
- if (tab.undoindex == 0)
3738
+ restoreButton.setEnabled(copy.versionindex != -1);
3739
+ replaceButton.setEnabled(copy.versionindex != -1);
3740
+ undoButton.setEnabled(copy.versionindex > 0);
3741
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3742
+ }
3743
+
3744
+ public boolean Undo()
3745
+ {
3746
+ System.err.println("Undo");
3747
+
3748
+ cRadio tab = GetCurrentTab();
3749
+
3750
+ if (copy.versionindex == 0)
34983751 {
34993752 java.awt.Toolkit.getDefaultToolkit().beep();
3500
- return;
3753
+ return false;
35013754 }
35023755
3503
- if (tab.graphs[tab.undoindex] == null)
3756
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3757
+// {
3758
+// if (Save(false))
3759
+// tab.versionindex -= 1;
3760
+// else
3761
+// {
3762
+// if (tab.versionindex <= 0)
3763
+// return false;
3764
+// else
3765
+// tab.versionindex -= 1;
3766
+// }
3767
+// }
3768
+
3769
+ copy.versionindex -= 1;
3770
+
3771
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3772
+
3773
+ return true;
3774
+ }
3775
+
3776
+ public boolean Restore()
3777
+ {
3778
+ System.err.println("Restore");
3779
+
3780
+ cRadio tab = GetCurrentTab();
3781
+
3782
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
35043783 {
3505
- Save();
3506
- tab.undoindex -= 1;
3784
+ java.awt.Toolkit.getDefaultToolkit().beep();
3785
+ return false;
35073786 }
35083787
3509
- tab.undoindex -= 1;
3788
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3789
+
3790
+ return true;
3791
+ }
35103792
3511
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3793
+ public boolean Replace()
3794
+ {
3795
+ System.err.println("Replace");
3796
+
3797
+ cRadio tab = GetCurrentTab();
3798
+
3799
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3800
+ {
3801
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3802
+ return false;
3803
+ }
3804
+
3805
+ copy.versions[copy.versionindex] = CompressCopy();
3806
+
3807
+ return true;
35123808 }
35133809
35143810 public void Redo()
35153811 {
35163812 cRadio tab = GetCurrentTab();
35173813
3518
- if (tab.graphs[tab.undoindex + 1] == null)
3814
+ if (copy.versions[copy.versionindex + 1] == null)
35193815 {
35203816 java.awt.Toolkit.getDefaultToolkit().beep();
35213817 return;
35223818 }
35233819
3524
- tab.undoindex += 1;
3820
+ copy.versionindex += 1;
35253821
3526
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3822
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3823
+
3824
+ //if (!tab.user[tab.versionindex])
3825
+ // tab.graphs[tab.versionindex] = null;
35273826 }
35283827
35293828 void ImportGFD()
....@@ -3675,7 +3974,7 @@
36753974 assert false;
36763975 }
36773976
3678
- void EditSelection()
3977
+ void EditSelection(boolean newWindow)
36793978 {
36803979 }
36813980
....@@ -3819,9 +4118,22 @@
38194118 //copy.Touch();
38204119 }
38214120
4121
+ cNumberSlider versionField;
4122
+
38224123 public void stateChanged(ChangeEvent e)
38234124 {
38244125 // assert(false);
4126
+ if (e.getSource() == versionField)
4127
+ {
4128
+ int version = versionField.getInteger();
4129
+
4130
+ if (copy.versions[version] != null)
4131
+ {
4132
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4133
+ }
4134
+
4135
+ return;
4136
+ }
38254137
38264138 if (freezematerial)
38274139 {
....@@ -4170,7 +4482,8 @@
41704482
41714483 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724484 {
4173
- Save();
4485
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4486
+ Save();
41744487 //Tween.set(thing, 0).target(1).start(tweenManager);
41754488 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764489 // if (thing instanceof GenericJointDemo)
....@@ -4257,6 +4570,12 @@
42574570 {
42584571 ResetModel();
42594572 Select(thing.GetTreePath(), true, false); // unselect... false);
4573
+
4574
+ if (thing.Size() == 0)
4575
+ {
4576
+ //EditSelection(false);
4577
+ }
4578
+
42604579 refreshContents();
42614580 }
42624581
....@@ -4479,7 +4798,8 @@
44794798
44804799 if (readobj != null)
44814800 {
4482
- Save();
4801
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4802
+ // Save();
44834803 try
44844804 {
44854805 //readobj.deepCopySelf(copy);
....@@ -4534,13 +4854,18 @@
45344854 c.addChild(csg);
45354855 }
45364856
4857
+ copy.versions = readobj.versions;
4858
+ copy.versionindex = readobj.versionindex;
4859
+
4860
+ SetUndoStates();
4861
+
45374862 ResetModel();
45384863 copy.HardTouch(); // recompile?
45394864 refreshContents();
45404865 }
45414866 }
45424867
4543
- void load() // throws ClassNotFoundException
4868
+ void Open() // throws ClassNotFoundException
45444869 {
45454870 if (Grafreed.standAlone)
45464871 {
....@@ -4657,6 +4982,8 @@
46574982 String filename = browser.getFile();
46584983 if (filename != null && filename.length() > 0)
46594984 {
4985
+ if (!filename.endsWith(".gfd"))
4986
+ filename += ".gfd";
46604987 lastname = browser.getDirectory() + filename;
46614988 save();
46624989 }
....@@ -4823,7 +5150,7 @@
48235150 MenuBar menuBar;
48245151 Menu fileMenu;
48255152 MenuItem newItem;
4826
- MenuItem loadItem;
5153
+ MenuItem openItem;
48275154 MenuItem saveItem;
48285155 MenuItem saveAsItem;
48295156 MenuItem exportAsItem;
....@@ -4846,22 +5173,36 @@
48465173 CheckboxMenuItem toggleSwitchItem;
48475174 CheckboxMenuItem toggleRootItem;
48485175 CheckboxMenuItem animationItem;
5176
+ MenuItem archiveItem;
48495177 CheckboxMenuItem toggleHandleItem;
48505178 CheckboxMenuItem togglePaintItem;
48515179 JSplitPane mainPanel;
48525180 JScrollPane scrollpane;
5181
+
48535182 JPanel toolbarPanel;
5183
+
48545184 cGridBag treePanel;
5185
+
48555186 JPanel radioPanel;
48565187 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
5188
+
5189
+ cGridBag toolboxPanel;
48585190 cGridBag materialPanel;
5191
+ cGridBag ctrlPanel;
5192
+
48595193 JScrollPane infoPanel;
5194
+
48605195 cGridBag optionsPanel;
5196
+
48615197 JTabbedPane objectPanel;
5198
+ boolean materialFlushed;
5199
+ Object3D latestObject;
5200
+
48625201 cGridBag XYZPanel;
5202
+
48635203 JSplitPane gridPanel;
48645204 JSplitPane bigPanel;
5205
+
48655206 cGridBag bigThree;
48665207 cGridBag scenePanel;
48675208 cGridBag centralPanel;
....@@ -4976,7 +5317,7 @@
49765317 cNumberSlider fogField;
49775318 JLabel opacityPowerLabel;
49785319 cNumberSlider opacityPowerField;
4979
- JTree jTree;
5320
+ cTree jTree;
49805321 //ObjectUI parent;
49815322
49825323 cNumberSlider normalpushField;