Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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.
....@@ -49,6 +52,19 @@
4952 catch (Exception e)
5053 {
5154 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);
5268 }
5369 }
5470
....@@ -194,7 +210,7 @@
194210
195211 objEditor.ctrlPanel.remove(namePanel);
196212
197
- if (!GroupEditor.allparams)
213
+ if (!allparams)
198214 return;
199215
200216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -266,6 +282,12 @@
266282 client = inClient;
267283 copy = client;
268284
285
+ if (copy.versions == null)
286
+ {
287
+ copy.versions = new byte[100][];
288
+ copy.versionindex = -1;
289
+ }
290
+
269291 // "this" is not called: SetupUI2(objEditor);
270292 }
271293
....@@ -279,6 +301,12 @@
279301 client = inClient;
280302 copy = client;
281303
304
+ if (copy.versions == null)
305
+ {
306
+ copy.versions = new byte[100][];
307
+ copy.versionindex = -1;
308
+ }
309
+
282310 SetupUI2(callee.GetEditor());
283311 }
284312
....@@ -293,7 +321,7 @@
293321 //localCopy.parent = null;
294322
295323 frame = new JFrame();
296
- frame.setUndecorated(true);
324
+ frame.setUndecorated(false);
297325 objEditor = this;
298326 this.callee = callee;
299327
....@@ -311,6 +339,12 @@
311339 copy = localCopy;
312340 copy.editWindow = this;
313341
342
+ if (copy.versions == null)
343
+ {
344
+ copy.versions = new byte[100][];
345
+ copy.versionindex = -1;
346
+ }
347
+
314348 SetupMenu();
315349
316350 //SetupName(objEditor); // new
....@@ -324,12 +358,17 @@
324358 return frame.action(event, obj);
325359 }
326360
361
+ // Cannot work without static
362
+ static boolean allparams = true;
363
+
364
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
365
+
327366 void SetupMenu()
328367 {
329368 frame.setMenuBar(menuBar = new MenuBar());
330369 menuBar.add(fileMenu = new Menu("File"));
331370 fileMenu.add(newItem = new MenuItem("New"));
332
- fileMenu.add(loadItem = new MenuItem("Open..."));
371
+ fileMenu.add(openItem = new MenuItem("Open..."));
333372
334373 //oe.menuBar.add(menu = new Menu("Include"));
335374 Menu menu = new Menu("Import");
....@@ -361,7 +400,7 @@
361400 }
362401
363402 newItem.addActionListener(this);
364
- loadItem.addActionListener(this);
403
+ openItem.addActionListener(this);
365404 saveItem.addActionListener(this);
366405 saveAsItem.addActionListener(this);
367406 exportAsItem.addActionListener(this);
....@@ -370,6 +409,32 @@
370409 closeItem.addActionListener(this);
371410
372411 objectPanel = new JTabbedPane();
412
+
413
+ ChangeListener changeListener = new ChangeListener()
414
+ {
415
+ public void stateChanged(ChangeEvent changeEvent)
416
+ {
417
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
418
+// {
419
+// if (latestObject != null)
420
+// {
421
+// refreshContents(true);
422
+// SetMaterial(latestObject);
423
+// }
424
+//
425
+// materialFlushed = true;
426
+// }
427
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
428
+// {
429
+// if (listUI.size() == 0)
430
+// EditSelection(false);
431
+// }
432
+
433
+ refreshContents(false); // To refresh Info tab
434
+ }
435
+ };
436
+ objectPanel.addChangeListener(changeListener);
437
+
373438 toolbarPanel = new JPanel();
374439 toolbarPanel.setName("Toolbar");
375440 treePanel = new cGridBag();
....@@ -384,9 +449,12 @@
384449 editPanel.add(editCommandsPanel);
385450 editPanel.add(ctrlPanel);
386451
387
- materialPanel = new cGridBag().setVertical(true);
452
+ toolboxPanel = new cGridBag().setVertical(false);
453
+ toolboxPanel.setName("Toolbox");
388454
455
+ materialPanel = new cGridBag().setVertical(true);
389456 materialPanel.setName("Material");
457
+
390458 /*JTextPane*/
391459 infoarea = createTextPane();
392460 doc = infoarea.getStyledDocument();
....@@ -399,7 +467,7 @@
399467 // TEXTAREA infoarea.setLineWrap(true);
400468 // TEXTAREA infoarea.setWrapStyleWord(true);
401469 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
402
- infoPanel.setPreferredSize(new Dimension(50, 200));
470
+ infoPanel.setPreferredSize(new Dimension(1, 1));
403471 infoPanel.setName("Info");
404472 //infoPanel.setLayout(new BorderLayout());
405473 //infoPanel.add(createTextPane());
....@@ -411,7 +479,14 @@
411479 mainPanel.setDividerSize(9);
412480 mainPanel.setDividerLocation(0.5); //1.0);
413481 mainPanel.setResizeWeight(0.5);
414
-
482
+
483
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
484
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
485
+ divider.setDividerSize(15);
486
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
487
+
488
+ mainPanel.setUI(new BasicSplitPaneUI());
489
+
415490 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
416491 //mainPanel.setLayout(new GridBagLayout());
417492 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -642,8 +717,8 @@
642717 }
643718 }
644719
645
-static GraphicsDevice device = GraphicsEnvironment
646
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
720
+//static GraphicsDevice device = GraphicsEnvironment
721
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
647722
648723 Rectangle keeprect;
649724 cRadio radio;
....@@ -659,13 +734,24 @@
659734
660735 boolean maximized;
661736
737
+ cButton fullscreenLayout;
738
+
662739 void Minimize()
663740 {
664741 frame.setState(Frame.ICONIFIED);
742
+ frame.validate();
665743 }
666744
745
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
746
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
747
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
667748 void Maximize()
668749 {
750
+ if (CameraPane.FULLSCREEN)
751
+ {
752
+ ToggleFullScreen();
753
+ }
754
+
669755 if (maximized)
670756 {
671757 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -673,20 +759,36 @@
673759 else
674760 {
675761 keeprect = frame.getBounds();
676
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
677
- Dimension rect2 = frame.getToolkit().getScreenSize();
678
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
762
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
763
+// Dimension rect2 = frame.getToolkit().getScreenSize();
764
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
679765 // frame.setState(Frame.MAXIMIZED_BOTH);
766
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
680767 }
681768
682769 maximized ^= true;
770
+
771
+ frame.validate();
683772 }
773
+
774
+ cButton minButton;
775
+ cButton maxButton;
776
+ cButton fullButton;
684777
685778 void ToggleFullScreen()
686779 {
687
- if (CameraPane.FULLSCREEN)
780
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781
+
782
+ cameraView.ToggleFullScreen();
783
+
784
+ if (!CameraPane.FULLSCREEN)
688785 {
689786 device.setFullScreenWindow(null);
787
+ frame.dispose();
788
+ frame.setUndecorated(false);
789
+ frame.validate();
790
+ frame.setVisible(true);
791
+
690792 //frame.setVisible(false);
691793 // frame.removeNotify();
692794 // frame.setUndecorated(false);
....@@ -696,7 +798,7 @@
696798 // X frame.getContentPane().remove(/*"Center",*/bigThree);
697799 // X framePanel.add(bigThree);
698800 // X frame.getContentPane().add(/*"Center",*/framePanel);
699
- framePanel.setDividerLocation(1);
801
+ framePanel.setDividerLocation(46);
700802
701803 //frame.setVisible(true);
702804 radio.layout = keepButton;
....@@ -711,7 +813,12 @@
711813 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
712814 // frame.getToolkit().getScreenSize().height);
713815 //frame.setVisible(false);
816
+
817
+ frame.dispose();
818
+ frame.setUndecorated(true);
714819 device.setFullScreenWindow(frame);
820
+ frame.validate();
821
+ frame.setVisible(true);
715822 // frame.removeNotify();
716823 // frame.setUndecorated(true);
717824 // frame.addNotify();
....@@ -720,13 +827,34 @@
720827 // X frame.getContentPane().add(/*"Center",*/bigThree);
721828 framePanel.setDividerLocation(0);
722829
723
- radio.layout = twoButton;
830
+ radio.layout = fullscreenLayout;
724831 radio.layout.doClick();
725832 //frame.setVisible(true);
726833 }
727
-
728
- cameraView.ToggleFullScreen();
834
+ frame.validate();
729835 }
836
+
837
+ private byte[] CompressCopy()
838
+ {
839
+ boolean temp = CameraPane.SWITCH;
840
+ CameraPane.SWITCH = false;
841
+
842
+ copy.ExtractBigData(versiontable);
843
+ // if (copy == client)
844
+
845
+ byte[] versions[] = copy.versions;
846
+ copy.versions = null;
847
+
848
+ byte[] compress = Compress(copy);
849
+
850
+ copy.versions = versions;
851
+
852
+ copy.RestoreBigData(versiontable);
853
+
854
+ CameraPane.SWITCH = temp;
855
+
856
+ return compress;
857
+ }
730858
731859 private JTextPane createTextPane()
732860 {
....@@ -866,7 +994,12 @@
866994 JCheckBox speedupCB;
867995 JCheckBox rewindCB;
868996 JCheckBox flipVCB;
997
+
998
+ cCheckBox toggleTextureCB;
999
+ cCheckBox toggleSwitchCB;
1000
+
8691001 JComboBox texresMenu;
1002
+
8701003 JButton resetButton;
8711004 JButton stepButton;
8721005 JButton stepAllButton;
....@@ -1053,12 +1186,12 @@
10531186 namePanel = new cGridBag();
10541187
10551188 nameField = AddText(namePanel, copy.GetName());
1056
- namePanel.add(nameField);
1189
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10571190 oe.ctrlPanel.add(namePanel);
10581191
10591192 oe.ctrlPanel.Return();
10601193
1061
- if (!GroupEditor.allparams)
1194
+ if (!allparams)
10621195 return;
10631196
10641197 setupPanel = new cGridBag().setVertical(false);
....@@ -1071,20 +1204,21 @@
10711204 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10721205 hideCB.setToolTipText("Hide object");
10731206 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
- markCB.setToolTipText("Set the animation target transform");
1207
+ markCB.setToolTipText("As animation target transform");
10751208
10761209 setupPanel2 = new cGridBag().setVertical(false);
10771210
10781211 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10791212 rewindCB.setToolTipText("Rewind animation");
10801213
1081
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1214
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1215
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10831216
1217
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1218
+ link2masterCB.setToolTipText("Attach to support");
1219
+
10841220 if (Globals.ADVANCED)
10851221 {
1086
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1087
- link2masterCB.setToolTipText("Attach to support");
10881222 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10891223 speedupCB.setToolTipText("Option motion capture");
10901224 }
....@@ -1400,7 +1534,11 @@
14001534 // north.add(ctrlPanel, BorderLayout.NORTH);
14011535 // objectPanel.add(north);
14021536 objectPanel.add(editPanel);
1403
- objectPanel.add(infoPanel);
1537
+
1538
+ //if (Globals.ADVANCED)
1539
+ objectPanel.add(infoPanel);
1540
+
1541
+ objectPanel.add(toolboxPanel);
14041542
14051543 /*
14061544 aConstraints.gridx = 0;
....@@ -1409,7 +1547,7 @@
14091547 aConstraints.gridy += 1;
14101548 aConstraints.gridwidth = 1;
14111549 mainPanel.add(objectPanel, aConstraints);
1412
- */
1550
+ */
14131551
14141552 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14151553 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1426,9 +1564,7 @@
14261564 JTabbedPane tabbedPane = new JTabbedPane();
14271565 tabbedPane.add(scrollpane);
14281566
1429
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1430
-
1431
- optionsPanel = new cGridBag().setVertical(true);
1567
+ optionsPanel = new cGridBag().setVertical(false);
14321568
14331569 optionsPanel.setName("Options");
14341570
....@@ -1436,6 +1572,8 @@
14361572
14371573 tabbedPane.add(optionsPanel);
14381574
1575
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1576
+
14391577 scenePanel.add(tabbedPane);
14401578
14411579 /*
....@@ -1508,9 +1646,9 @@
15081646 // aConstraints.gridheight = 1;
15091647
15101648 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1511
- framePanel.setContinuousLayout(true);
1512
- framePanel.setOneTouchExpandable(true);
1513
- framePanel.setDividerLocation(0.8);
1649
+ framePanel.setContinuousLayout(false);
1650
+ framePanel.setOneTouchExpandable(false);
1651
+ //.setDividerLocation(0.8);
15141652 //framePanel.setDividerSize(15);
15151653 //framePanel.setResizeWeight(0.15);
15161654 framePanel.setName("Frame");
....@@ -1528,11 +1666,14 @@
15281666 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15291667
15301668 frame.setSize(1280, 860);
1531
- frame.setVisible(true);
1532
-
1669
+
15331670 cameraView.requestFocusInWindow();
15341671
15351672 gridPanel.setDividerLocation(1.0);
1673
+
1674
+ frame.validate();
1675
+
1676
+ frame.setVisible(true);
15361677
15371678 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15381679 frame.addWindowListener(new WindowAdapter()
....@@ -1619,24 +1760,6 @@
16191760 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16201761 colorSection.add(texture);
16211762
1622
- cGridBag anisoU = new cGridBag();
1623
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1624
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1626
- colorSection.add(anisoU);
1627
-
1628
- cGridBag anisoV = new cGridBag();
1629
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1630
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1631
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1632
- colorSection.add(anisoV);
1633
-
1634
- cGridBag shadowbias = new cGridBag();
1635
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1636
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1637
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1638
- colorSection.add(shadowbias);
1639
-
16401763 panel.add(new JSeparator());
16411764
16421765 panel.add(colorSection);
....@@ -1686,6 +1809,12 @@
16861809 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16871810 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16881811 diffuseSection.add(fakedepth);
1812
+
1813
+ cGridBag shadowbias = new cGridBag();
1814
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1815
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1816
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1817
+ diffuseSection.add(shadowbias);
16891818
16901819 panel.add(new JSeparator());
16911820
....@@ -1737,6 +1866,18 @@
17371866 // aConstraints.gridy += 1;
17381867 // aConstraints.gridwidth = 1;
17391868
1869
+ cGridBag anisoU = new cGridBag();
1870
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1871
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1872
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1873
+ specularSection.add(anisoU);
1874
+
1875
+ cGridBag anisoV = new cGridBag();
1876
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1877
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1878
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1879
+ specularSection.add(anisoV);
1880
+
17401881
17411882 panel.add(new JSeparator());
17421883
....@@ -1744,35 +1885,35 @@
17441885
17451886 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17461887
1747
- cGridBag globalSection = new cGridBag().setVertical(true);
1888
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17481889
17491890 cGridBag camera = new cGridBag();
17501891 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17511892 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17521893 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1753
- globalSection.add(camera);
1894
+ colorSection.add(camera);
17541895
17551896 cGridBag ambient = new cGridBag();
17561897 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17571898 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17581899 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
- globalSection.add(ambient);
1900
+ colorSection.add(ambient);
17601901
17611902 cGridBag backlit = new cGridBag();
17621903 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17631904 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17641905 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
- globalSection.add(backlit);
1906
+ colorSection.add(backlit);
17661907
17671908 cGridBag opacity = new cGridBag();
17681909 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17691910 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17701911 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1771
- globalSection.add(opacity);
1912
+ colorSection.add(opacity);
17721913
1773
- panel.add(new JSeparator());
1914
+ //panel.add(new JSeparator());
17741915
1775
- panel.add(globalSection);
1916
+ //panel.add(globalSection);
17761917
17771918 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17781919
....@@ -1879,8 +2020,9 @@
18792020 // 3D models
18802021 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18812022 {
1882
- lastConverter = new com.jmex.model.converters.MaxToJme();
1883
- LoadFile(filename, lastConverter);
2023
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2024
+ //LoadFile(filename, lastConverter);
2025
+ LoadObjFile(filename); // New 3ds loader
18842026 continue;
18852027 }
18862028 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2606,6 +2748,7 @@
26062748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26072749 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26082750 }
2751
+
26092752 //cJME.count++;
26102753 //cJME.count %= 12;
26112754 if (gc)
....@@ -2789,6 +2932,7 @@
27892932 }
27902933 }
27912934 }
2935
+
27922936 cFileSystemPane FSPane;
27932937
27942938 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2842,11 +2986,14 @@
28422986 }
28432987 }
28442988 }
2989
+
28452990 freezematerial = false;
28462991 }
28472992
28482993 void SetMaterial(Object3D object)
28492994 {
2995
+ latestObject = object;
2996
+
28502997 cMaterial mat = object.material;
28512998
28522999 if (mat == null)
....@@ -2958,12 +3105,17 @@
29583105 // }
29593106
29603107 /**/
2961
- if (deselect)
3108
+ if (deselect || child == null)
29623109 {
29633110 //group.deselectAll();
29643111 //freeze = true;
29653112 GetTree().clearSelection();
29663113 //freeze = false;
3114
+
3115
+ if (child == null)
3116
+ {
3117
+ return;
3118
+ }
29673119 }
29683120
29693121 //group.addSelectee(child);
....@@ -3032,7 +3184,7 @@
30323184 cameraView.ToggleDL();
30333185 cameraView.repaint();
30343186 return;
3035
- } else if (event.getSource() == toggleTextureItem)
3187
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30363188 {
30373189 cameraView.ToggleTexture();
30383190 // june 2013 copy.HardTouch();
....@@ -3071,7 +3223,7 @@
30713223 frame.validate();
30723224
30733225 return;
3074
- } else if (event.getSource() == toggleSwitchItem)
3226
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30753227 {
30763228 cameraView.ToggleSwitch();
30773229 cameraView.repaint();
....@@ -3287,9 +3439,9 @@
32873439 {
32883440 Close();
32893441 //return true;
3290
- } else if (source == loadItem)
3442
+ } else if (source == openItem)
32913443 {
3292
- load();
3444
+ Open();
32933445 //return true;
32943446 } else if (source == newItem)
32953447 {
....@@ -3314,6 +3466,10 @@
33143466 {
33153467 generatePOV();
33163468 //return true;
3469
+ } else if (event.getSource() == archiveItem)
3470
+ {
3471
+ cTools.Archive(frame);
3472
+ return;
33173473 } else if (source == zBufferItem)
33183474 {
33193475 try
....@@ -3365,8 +3521,8 @@
33653521 try
33663522 {
33673523 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3368
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3369
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3524
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3525
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33703526
33713527 Object3D parent = o.parent;
33723528 o.parent = null;
....@@ -3377,10 +3533,14 @@
33773533
33783534 out.flush();
33793535
3380
- zstream.close();
3536
+ baos //zstream
3537
+ .close();
33813538 out.close();
33823539
3383
- return baos.toByteArray();
3540
+ byte[] bytes = baos.toByteArray();
3541
+
3542
+ System.out.println("save #bytes = " + bytes.length);
3543
+ return bytes;
33843544 } catch (Exception e)
33853545 {
33863546 System.err.println(e);
....@@ -3390,13 +3550,16 @@
33903550
33913551 static public Object Uncompress(byte[] bytes)
33923552 {
3393
- System.out.println("#bytes = " + bytes.length);
3553
+ System.out.println("restore #bytes = " + bytes.length);
33943554 try
33953555 {
33963556 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3397
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3398
- ObjectInputStream in = new ObjectInputStream(istream);
3557
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3558
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33993559 Object obj = in.readObject();
3560
+
3561
+ bais //istream
3562
+ .close();
34003563 in.close();
34013564
34023565 return obj;
....@@ -3451,39 +3614,77 @@
34513614 return null;
34523615 }
34533616
3454
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34553617
34563618 public void Save()
3619
+ {
3620
+ //Save(true);
3621
+ Replace();
3622
+ }
3623
+
3624
+ private boolean Equal(byte[] compress, byte[] name)
3625
+ {
3626
+ if (compress.length != name.length)
3627
+ {
3628
+ return false;
3629
+ }
3630
+
3631
+ for (int i=compress.length; --i>=0;)
3632
+ {
3633
+ if (compress[i] != name[i])
3634
+ return false;
3635
+ }
3636
+
3637
+ return true;
3638
+ }
3639
+
3640
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3641
+
3642
+ public boolean Save(boolean user)
34573643 {
34583644 System.err.println("Save");
34593645
34603646 cRadio tab = GetCurrentTab();
34613647
3462
- boolean temp = CameraPane.SWITCH;
3463
- CameraPane.SWITCH = false;
3648
+ byte[] compress = CompressCopy();
34643649
3465
- copy.ExtractBigData(hashtable);
3650
+ boolean thesame = false;
3651
+
3652
+ // Quick heuristic using length. Works only when stream is compressed.
3653
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3654
+ {
3655
+ thesame = true;
3656
+ }
34663657
34673658 //EditorFrame.m_MainFrame.requestFocusInWindow();
3468
- tab.graphs[tab.undoindex++] = Compress(copy);
3469
-
3470
- copy.RestoreBigData(hashtable);
3471
-
3472
- CameraPane.SWITCH = temp;
3473
-
3474
- //assert(hashtable.isEmpty());
3475
-
3476
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3659
+ if (!thesame)
34773660 {
3478
- tab.graphs[i] = null;
3661
+ //tab.user[tab.versionindex] = user;
3662
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3663
+
3664
+ copy.versions[++copy.versionindex] = compress;
3665
+
3666
+ // if (increment)
3667
+ // tab.versionindex++;
34793668 }
34803669
3670
+ //copy.RestoreBigData(versiontable);
3671
+
3672
+ //assert(hashtable.isEmpty());
3673
+
3674
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3675
+ {
3676
+ //tab.user[i] = false;
3677
+ copy.versions[i] = null;
3678
+ }
3679
+
3680
+ SetUndoStates();
3681
+
34813682 // test save
34823683 if (false)
34833684 {
34843685 try
34853686 {
3486
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3687
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34873688 ObjectOutputStream p = new ObjectOutputStream(ostream);
34883689
34893690 p.writeObject(copy);
....@@ -3496,14 +3697,18 @@
34963697 e.printStackTrace();
34973698 }
34983699 }
3700
+
3701
+ return !thesame;
34993702 }
35003703
35013704 void CopyChanged(Object3D obj)
35023705 {
3706
+ SetUndoStates();
3707
+
35033708 boolean temp = CameraPane.SWITCH;
35043709 CameraPane.SWITCH = false;
35053710
3506
- copy.ExtractBigData(hashtable);
3711
+ copy.ExtractBigData(versiontable);
35073712
35083713 copy.clear();
35093714
....@@ -3512,7 +3717,7 @@
35123717 copy.add(obj.get(i));
35133718 }
35143719
3515
- copy.RestoreBigData(hashtable);
3720
+ copy.RestoreBigData(versiontable);
35163721
35173722 CameraPane.SWITCH = temp;
35183723
....@@ -3539,42 +3744,130 @@
35393744 refreshContents();
35403745 }
35413746
3542
- public void Undo()
3747
+ cButton undoButton;
3748
+ cButton restoreButton;
3749
+ cButton replaceButton;
3750
+ cButton redoButton;
3751
+
3752
+ boolean muteSlider;
3753
+
3754
+ int VersionCount()
35433755 {
3756
+ int count = 0;
3757
+
3758
+ for (int i = copy.versions.length; --i >= 0;)
3759
+ {
3760
+ if (copy.versions[i] != null)
3761
+ count++;
3762
+ }
3763
+
3764
+ return count;
3765
+ }
3766
+
3767
+ void SetUndoStates()
3768
+ {
3769
+ cRadio tab = GetCurrentTab();
3770
+
3771
+ restoreButton.setEnabled(copy.versionindex != -1);
3772
+ replaceButton.setEnabled(copy.versionindex != -1);
3773
+
3774
+ undoButton.setEnabled(copy.versionindex > 0);
3775
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3776
+
3777
+ muteSlider = true;
3778
+ versionSlider.setMaximum(VersionCount() - 1);
3779
+ versionSlider.setInteger(copy.versionindex);
3780
+ muteSlider = false;
3781
+ }
3782
+
3783
+ public boolean Undo()
3784
+ {
3785
+ // Option?
3786
+ Replace();
3787
+
35443788 System.err.println("Undo");
35453789
35463790 cRadio tab = GetCurrentTab();
35473791
3548
- if (tab.undoindex == 0)
3792
+ if (copy.versionindex == 0)
35493793 {
35503794 java.awt.Toolkit.getDefaultToolkit().beep();
3551
- return;
3795
+ return false;
35523796 }
35533797
3554
- if (tab.graphs[tab.undoindex] == null)
3798
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3799
+// {
3800
+// if (Save(false))
3801
+// tab.versionindex -= 1;
3802
+// else
3803
+// {
3804
+// if (tab.versionindex <= 0)
3805
+// return false;
3806
+// else
3807
+// tab.versionindex -= 1;
3808
+// }
3809
+// }
3810
+
3811
+ copy.versionindex -= 1;
3812
+
3813
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3814
+
3815
+ return true;
3816
+ }
3817
+
3818
+ public boolean Restore()
3819
+ {
3820
+ System.err.println("Restore");
3821
+
3822
+ cRadio tab = GetCurrentTab();
3823
+
3824
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
35553825 {
3556
- Save();
3557
- tab.undoindex -= 1;
3826
+ java.awt.Toolkit.getDefaultToolkit().beep();
3827
+ return false;
35583828 }
35593829
3560
- tab.undoindex -= 1;
3830
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3831
+
3832
+ return true;
3833
+ }
35613834
3562
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3835
+ public boolean Replace()
3836
+ {
3837
+ System.err.println("Replace");
3838
+
3839
+ cRadio tab = GetCurrentTab();
3840
+
3841
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3842
+ {
3843
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3844
+ return false;
3845
+ }
3846
+
3847
+ copy.versions[copy.versionindex] = CompressCopy();
3848
+
3849
+ return true;
35633850 }
35643851
35653852 public void Redo()
35663853 {
3854
+ // Option?
3855
+ Replace();
3856
+
35673857 cRadio tab = GetCurrentTab();
35683858
3569
- if (tab.graphs[tab.undoindex + 1] == null)
3859
+ if (copy.versions[copy.versionindex + 1] == null)
35703860 {
35713861 java.awt.Toolkit.getDefaultToolkit().beep();
35723862 return;
35733863 }
35743864
3575
- tab.undoindex += 1;
3865
+ copy.versionindex += 1;
35763866
3577
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3867
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3868
+
3869
+ //if (!tab.user[tab.versionindex])
3870
+ // tab.graphs[tab.versionindex] = null;
35783871 }
35793872
35803873 void ImportGFD()
....@@ -3726,7 +4019,7 @@
37264019 assert false;
37274020 }
37284021
3729
- void EditSelection()
4022
+ void EditSelection(boolean newWindow)
37304023 {
37314024 }
37324025
....@@ -3870,9 +4163,25 @@
38704163 //copy.Touch();
38714164 }
38724165
4166
+ cNumberSlider versionSlider;
4167
+
38734168 public void stateChanged(ChangeEvent e)
38744169 {
38754170 // assert(false);
4171
+ if (e.getSource() == versionSlider)
4172
+ {
4173
+ if (muteSlider)
4174
+ return;
4175
+
4176
+ int version = versionSlider.getInteger();
4177
+
4178
+ if (copy.versions[version] != null)
4179
+ {
4180
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4181
+ }
4182
+
4183
+ return;
4184
+ }
38764185
38774186 if (freezematerial)
38784187 {
....@@ -4221,7 +4530,7 @@
42214530
42224531 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42234532 {
4224
- if (Globals.SAVEONMAKE)
4533
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42254534 Save();
42264535 //Tween.set(thing, 0).target(1).start(tweenManager);
42274536 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4309,6 +4618,12 @@
43094618 {
43104619 ResetModel();
43114620 Select(thing.GetTreePath(), true, false); // unselect... false);
4621
+
4622
+ if (thing.Size() == 0)
4623
+ {
4624
+ //EditSelection(false);
4625
+ }
4626
+
43124627 refreshContents();
43134628 }
43144629
....@@ -4531,8 +4846,8 @@
45314846
45324847 if (readobj != null)
45334848 {
4534
- if (Globals.SAVEONMAKE)
4535
- Save();
4849
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4850
+ // Save();
45364851 try
45374852 {
45384853 //readobj.deepCopySelf(copy);
....@@ -4587,13 +4902,24 @@
45874902 c.addChild(csg);
45884903 }
45894904
4905
+ copy.versions = readobj.versions;
4906
+ copy.versionindex = readobj.versionindex;
4907
+
4908
+ if (copy.versions == null)
4909
+ {
4910
+ copy.versions = new byte[100][];
4911
+ copy.versionindex = -1;
4912
+ }
4913
+
4914
+ //? SetUndoStates();
4915
+
45904916 ResetModel();
45914917 copy.HardTouch(); // recompile?
45924918 refreshContents();
45934919 }
45944920 }
45954921
4596
- void load() // throws ClassNotFoundException
4922
+ void Open() // throws ClassNotFoundException
45974923 {
45984924 if (Grafreed.standAlone)
45994925 {
....@@ -4710,6 +5036,8 @@
47105036 String filename = browser.getFile();
47115037 if (filename != null && filename.length() > 0)
47125038 {
5039
+ if (!filename.endsWith(".gfd"))
5040
+ filename += ".gfd";
47135041 lastname = browser.getDirectory() + filename;
47145042 save();
47155043 }
....@@ -4876,7 +5204,7 @@
48765204 MenuBar menuBar;
48775205 Menu fileMenu;
48785206 MenuItem newItem;
4879
- MenuItem loadItem;
5207
+ MenuItem openItem;
48805208 MenuItem saveItem;
48815209 MenuItem saveAsItem;
48825210 MenuItem exportAsItem;
....@@ -4899,22 +5227,36 @@
48995227 CheckboxMenuItem toggleSwitchItem;
49005228 CheckboxMenuItem toggleRootItem;
49015229 CheckboxMenuItem animationItem;
5230
+ MenuItem archiveItem;
49025231 CheckboxMenuItem toggleHandleItem;
49035232 CheckboxMenuItem togglePaintItem;
49045233 JSplitPane mainPanel;
49055234 JScrollPane scrollpane;
5235
+
49065236 JPanel toolbarPanel;
5237
+
49075238 cGridBag treePanel;
5239
+
49085240 JPanel radioPanel;
49095241 ButtonGroup buttonGroup;
4910
- cGridBag ctrlPanel;
5242
+
5243
+ cGridBag toolboxPanel;
49115244 cGridBag materialPanel;
5245
+ cGridBag ctrlPanel;
5246
+
49125247 JScrollPane infoPanel;
5248
+
49135249 cGridBag optionsPanel;
5250
+
49145251 JTabbedPane objectPanel;
5252
+ boolean materialFlushed;
5253
+ Object3D latestObject;
5254
+
49155255 cGridBag XYZPanel;
5256
+
49165257 JSplitPane gridPanel;
49175258 JSplitPane bigPanel;
5259
+
49185260 cGridBag bigThree;
49195261 cGridBag scenePanel;
49205262 cGridBag centralPanel;
....@@ -5029,7 +5371,7 @@
50295371 cNumberSlider fogField;
50305372 JLabel opacityPowerLabel;
50315373 cNumberSlider opacityPowerField;
5032
- JTree jTree;
5374
+ cTree jTree;
50335375 //ObjectUI parent;
50345376
50355377 cNumberSlider normalpushField;