Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
ObjEditor.java
....@@ -41,64 +41,78 @@
4141 JFrame frame;
4242
4343 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4452
4553 cButton GetButton(String name, boolean border)
4654 {
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
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5663 }
5764
5865 cToggleButton GetToggleButton(String name, boolean border)
5966 {
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
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6969 }
7070
7171 cCheckBox GetCheckBox(String name, boolean border)
7272 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7379 try
7480 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7797 }
7898 catch (Exception e)
7999 {
80
- return new cCheckBox(name, border);
100
+ return null;
81101 }
82102 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
85105 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
89107 {
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;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
98111 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
102116 }
103117
104118 // SCRIPT
....@@ -282,6 +296,12 @@
282296 client = inClient;
283297 copy = client;
284298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
285305 // "this" is not called: SetupUI2(objEditor);
286306 }
287307
....@@ -295,6 +315,12 @@
295315 client = inClient;
296316 copy = client;
297317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
298324 SetupUI2(callee.GetEditor());
299325 }
300326
....@@ -327,6 +353,12 @@
327353 copy = localCopy;
328354 copy.editWindow = this;
329355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
330362 SetupMenu();
331363
332364 //SetupName(objEditor); // new
....@@ -419,11 +451,12 @@
419451
420452 toolbarPanel = new JPanel();
421453 toolbarPanel.setName("Toolbar");
454
+
422455 treePanel = new cGridBag();
423456 treePanel.setName("Tree");
424457
425458 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
427460
428461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429462
....@@ -431,11 +464,11 @@
431464 editPanel.add(editCommandsPanel);
432465 editPanel.add(ctrlPanel);
433466
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
436469
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
439472
440473 /*JTextPane*/
441474 infoarea = createTextPane();
....@@ -443,6 +476,7 @@
443476
444477 infoarea.setEditable(true);
445478 SetText();
479
+
446480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447481 // infoarea.setOpaque(false);
448482 // //infoarea.setForeground(textcolor);
....@@ -450,7 +484,7 @@
450484 // TEXTAREA infoarea.setWrapStyleWord(true);
451485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452486 infoPanel.setPreferredSize(new Dimension(1, 1));
453
- infoPanel.setName("Info");
487
+ //infoPanel.setName("Info");
454488 //infoPanel.setLayout(new BorderLayout());
455489 //infoPanel.add(createTextPane());
456490
....@@ -816,6 +850,29 @@
816850 frame.validate();
817851 }
818852
853
+ private Object3D CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ Object3D versions[] = copy.versionlist;
862
+ copy.versionlist = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versionlist = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
875
+
819876 private JTextPane createTextPane()
820877 {
821878 // TEXTAREA String[] initString =
....@@ -937,6 +994,7 @@
937994 {
938995 SetupMaterial(materialPanel);
939996 }
997
+
940998 //SetupName();
941999 //SetupViews();
9421000 }
....@@ -946,7 +1004,7 @@
9461004 // NumberSlider vDivsField;
9471005 // JCheckBox endcaps;
9481006 JCheckBox liveCB;
949
- JCheckBox selectCB;
1007
+ JCheckBox selectableCB;
9501008 JCheckBox hideCB;
9511009 JCheckBox link2masterCB;
9521010 JCheckBox markCB;
....@@ -1158,13 +1216,16 @@
11581216
11591217 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11601218 liveCB.setToolTipText("Animate object");
1161
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
- selectCB.setToolTipText("Make object selectable");
1219
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1220
+ selectableCB.setToolTipText("Make object selectable");
11631221 // Return();
1222
+
11641223 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11651224 hideCB.setToolTipText("Hide object");
11661225 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11671226 markCB.setToolTipText("As animation target transform");
1227
+
1228
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11681229
11691230 setupPanel2 = new cGridBag().setVertical(false);
11701231
....@@ -1452,6 +1513,7 @@
14521513 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14531514 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14541515 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1516
+ //XYZPanel.setName("XYZ");
14551517
14561518 /*
14571519 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1489,16 +1551,29 @@
14891551 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14901552 //tmp.setName("Edit");
14911553 objectPanel.add(materialPanel);
1554
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
+ objectPanel.setToolTipTextAt(0, "Material");
1556
+
14921557 // JPanel north = new JPanel(new BorderLayout());
14931558 // north.setName("Edit");
14941559 // north.add(ctrlPanel, BorderLayout.NORTH);
14951560 // objectPanel.add(north);
14961561 objectPanel.add(editPanel);
1562
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
14971564
14981565 //if (Globals.ADVANCED)
14991566 objectPanel.add(infoPanel);
1567
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
+ objectPanel.setToolTipTextAt(2, "Information");
1569
+
1570
+ objectPanel.add(XYZPanel);
1571
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15001573
15011574 objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15021577
15031578 /*
15041579 aConstraints.gridx = 0;
....@@ -1519,7 +1594,7 @@
15191594 scrollpane.addMouseWheelListener(this); // Default not fast enough
15201595
15211596 /*JTabbedPane*/ scenePanel = new cGridBag();
1522
- scenePanel.preferredWidth = 6;
1597
+ scenePanel.preferredWidth = 5;
15231598
15241599 JTabbedPane tabbedPane = new JTabbedPane();
15251600 tabbedPane.add(scrollpane);
....@@ -1597,7 +1672,7 @@
15971672 bigThree = new cGridBag();
15981673 bigThree.addComponent(scenePanel);
15991674 bigThree.addComponent(centralPanel);
1600
- bigThree.addComponent(XYZPanel);
1675
+ //bigThree.addComponent(XYZPanel);
16011676
16021677 // // SIDE EFFECT!!!
16031678 // aConstraints.gridx = 0;
....@@ -1638,7 +1713,6 @@
16381713 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16391714 frame.addWindowListener(new WindowAdapter()
16401715 {
1641
-
16421716 public void windowClosing(WindowEvent e)
16431717 {
16441718 Close();
....@@ -1661,12 +1735,56 @@
16611735 ctrlPanel.removeAll();
16621736 }
16631737
1664
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
16651739 {
1666
- /*
1740
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1741
+ cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
+ label.addMouseListener(new MouseAdapter()
1743
+ {
1744
+ public void mouseClicked(MouseEvent e)
1745
+ {
1746
+ colorField.setFloat(0);
1747
+ saturationField.setFloat(1);
1748
+ materialtouched = true;
1749
+ applySelf();
1750
+ }
1751
+ });
1752
+ presetpanel.add(label);
1753
+
1754
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
1774
+
1775
+ cGridBag panel = new cGridBag().setVertical(true);
1776
+
1777
+ presetpanel.preferredWidth = 1;
1778
+
1779
+ materialpanel.add(panel);
1780
+ materialpanel.add(presetpanel);
1781
+
1782
+ panel.preferredWidth = 8;
1783
+
1784
+ /*
16671785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16681786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1669
- */
1787
+ */
16701788
16711789 cGridBag editBar = new cGridBag().setVertical(false);
16721790
....@@ -1700,27 +1818,50 @@
17001818 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17011819
17021820 cGridBag colorSection = new cGridBag().setVertical(true);
1821
+
1822
+ cGridBag huepanel = new cGridBag();
1823
+ cGridBag huelabel = new cGridBag();
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
1827
+ huelabel.preferredWidth = 20;
1828
+ huepanel.add(new cGridBag()); // Label
1829
+ huepanel.add(huelabel); // Field/slider
1830
+
1831
+ huepanel.preferredHeight = 7;
1832
+
1833
+ colorSection.add(huepanel);
17031834
17041835 cGridBag color = new cGridBag();
1705
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1706
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1707
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1836
+
1837
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1838
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1839
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1840
+
17081841 //colorField.preferredWidth = 200;
17091842 colorSection.add(color);
17101843
17111844 cGridBag modulation = new cGridBag();
17121845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17131846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1714
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17151848 colorSection.add(modulation);
17161849
1850
+ cGridBag opacity = new cGridBag();
1851
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1852
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1853
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1854
+ colorSection.add(opacity);
1855
+
1856
+ colorSection.add(GetSeparator());
1857
+
17171858 cGridBag texture = new cGridBag();
17181859 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17191860 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17201861 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17211862 colorSection.add(texture);
17221863
1723
- panel.add(new JSeparator());
1864
+ panel.add(GetSeparator());
17241865
17251866 panel.add(colorSection);
17261867
....@@ -1776,7 +1917,7 @@
17761917 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17771918 diffuseSection.add(shadowbias);
17781919
1779
- panel.add(new JSeparator());
1920
+ panel.add(GetSeparator());
17801921
17811922 panel.add(diffuseSection);
17821923
....@@ -1839,7 +1980,7 @@
18391980 specularSection.add(anisoV);
18401981
18411982
1842
- panel.add(new JSeparator());
1983
+ panel.add(GetSeparator());
18431984
18441985 panel.add(specularSection);
18451986
....@@ -1864,12 +2005,6 @@
18642005 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18652006 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18662007 colorSection.add(backlit);
1867
-
1868
- cGridBag opacity = new cGridBag();
1869
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1870
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1871
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1872
- colorSection.add(opacity);
18732008
18742009 //panel.add(new JSeparator());
18752010
....@@ -1915,7 +2050,7 @@
19152050 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19162051 textureSection.add(opacityPower);
19172052
1918
- panel.add(new JSeparator());
2053
+ panel.add(GetSeparator());
19192054
19202055 panel.add(textureSection);
19212056
....@@ -2902,7 +3037,7 @@
29023037
29033038 freezematerial = true;
29043039 colorField.setFloat(mat.color);
2905
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
29063041 metalnessField.setFloat(mat.metalness);
29073042 diffuseField.setFloat(mat.diffuse);
29083043 specularField.setFloat(mat.specular);
....@@ -3213,8 +3348,9 @@
32133348 } else if (event.getSource() == liveCB)
32143349 {
32153350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
32163352 return;
3217
- } else if (event.getSource() == selectCB)
3353
+ } else if (event.getSource() == selectableCB)
32183354 {
32193355 copy.dontselect ^= true;
32203356 return;
....@@ -3222,7 +3358,7 @@
32223358 {
32233359 copy.hide ^= true;
32243360 copy.Touch(); // display list issue
3225
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
32263362 return;
32273363 } else if (event.getSource() == link2masterCB)
32283364 {
....@@ -3478,6 +3614,7 @@
34783614
34793615 static public byte[] Compress(Object3D o)
34803616 {
3617
+ // Slower to actually compress.
34813618 try
34823619 {
34833620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3574,11 +3711,12 @@
35743711 return null;
35753712 }
35763713
3577
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35783714
35793715 public void Save()
35803716 {
3581
- Save(true);
3717
+ //Save(true);
3718
+ Replace();
3719
+ SetUndoStates();
35823720 }
35833721
35843722 private boolean Equal(byte[] compress, byte[] name)
....@@ -3597,49 +3735,44 @@
35973735 return true;
35983736 }
35993737
3738
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3739
+
36003740 public boolean Save(boolean user)
36013741 {
36023742 System.err.println("Save");
3743
+ Replace();
36033744
36043745 cRadio tab = GetCurrentTab();
36053746
3606
- boolean temp = CameraPane.SWITCH;
3607
- CameraPane.SWITCH = false;
3608
-
3609
- copy.ExtractBigData(hashtable);
3610
-
3611
- byte[] compress = Compress(copy);
3612
-
3613
- CameraPane.SWITCH = temp;
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
36143748
36153749 boolean thesame = false;
36163750
3617
- // Quick heuristic using length. Works only when stream is compressed.
3618
- if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3619
- {
3620
- thesame = true;
3621
- }
3751
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3752
+// {
3753
+// thesame = true;
3754
+// }
36223755
36233756 //EditorFrame.m_MainFrame.requestFocusInWindow();
36243757 if (!thesame)
36253758 {
3626
- //tab.user[tab.undoindex] = user;
3627
- boolean increment = tab.graphs[tab.undoindex] == null;
3759
+ //tab.user[tab.versionindex] = user;
3760
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36283761
3629
- tab.graphs[tab.undoindex] = compress;
3762
+ copy.versionlist[++copy.versionindex] = compress;
36303763
3631
- if (increment)
3632
- tab.undoindex++;
3764
+ // if (increment)
3765
+ // tab.versionindex++;
36333766 }
36343767
3635
- copy.RestoreBigData(hashtable);
3768
+ //copy.RestoreBigData(versiontable);
36363769
36373770 //assert(hashtable.isEmpty());
36383771
3639
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
36403773 {
36413774 //tab.user[i] = false;
3642
- // tab.graphs[i] = null;
3775
+ copy.versionlist[i] = null;
36433776 }
36443777
36453778 SetUndoStates();
....@@ -3649,7 +3782,7 @@
36493782 {
36503783 try
36513784 {
3652
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3785
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
36533786 ObjectOutputStream p = new ObjectOutputStream(ostream);
36543787
36553788 p.writeObject(copy);
....@@ -3665,6 +3798,38 @@
36653798
36663799 return !thesame;
36673800 }
3801
+
3802
+ boolean flashIt = true;
3803
+
3804
+ void RefreshSelection()
3805
+ {
3806
+ Object3D selection = new Object3D();
3807
+
3808
+ for (int i = 0; i < copy.selection.size(); i++)
3809
+ {
3810
+ Object3D elem = copy.selection.elementAt(i);
3811
+
3812
+ Object3D obj = copy.GetObject(elem.GetUUID());
3813
+
3814
+ if (obj == null)
3815
+ {
3816
+ copy.selection.remove(i--);
3817
+ }
3818
+ else
3819
+ {
3820
+ selection.add(obj);
3821
+ copy.selection.setElementAt(obj, i);
3822
+ }
3823
+ }
3824
+
3825
+ flashIt = false;
3826
+ GetTree().clearSelection();
3827
+ for (int i = 0; i < selection.size(); i++)
3828
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3829
+ flashIt = true;
3830
+
3831
+ refreshContents(false);
3832
+ }
36683833
36693834 void CopyChanged(Object3D obj)
36703835 {
....@@ -3673,19 +3838,23 @@
36733838 boolean temp = CameraPane.SWITCH;
36743839 CameraPane.SWITCH = false;
36753840
3676
- copy.ExtractBigData(hashtable);
3841
+ copy.ExtractBigData(versiontable);
36773842
36783843 copy.clear();
36793844
3845
+ copy.skyboxname = obj.skyboxname;
3846
+ copy.skyboxext = obj.skyboxext;
3847
+
36803848 for (int i=0; i<obj.Size(); i++)
36813849 {
36823850 copy.add(obj.get(i));
36833851 }
36843852
3685
- copy.RestoreBigData(hashtable);
3853
+ copy.RestoreBigData(versiontable);
36863854
36873855 CameraPane.SWITCH = temp;
36883856
3857
+ RefreshSelection();
36893858 //assert(hashtable.isEmpty());
36903859
36913860 copy.Touch();
....@@ -3710,64 +3879,130 @@
37103879 }
37113880
37123881 cButton undoButton;
3882
+ cButton restoreButton;
3883
+ cButton replaceButton;
37133884 cButton redoButton;
37143885
3886
+ boolean muteSlider;
3887
+
3888
+ int VersionCount()
3889
+ {
3890
+ int count = 0;
3891
+
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
3893
+ {
3894
+ if (copy.versionlist[i] != null)
3895
+ count++;
3896
+ }
3897
+
3898
+ return count;
3899
+ }
3900
+
37153901 void SetUndoStates()
37163902 {
37173903 cRadio tab = GetCurrentTab();
37183904
3719
- undoButton.setEnabled(tab.undoindex > 0);
3720
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3905
+ restoreButton.setEnabled(copy.versionindex != -1);
3906
+ replaceButton.setEnabled(copy.versionindex != -1);
3907
+
3908
+ undoButton.setEnabled(copy.versionindex > 0);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3910
+
3911
+ muteSlider = true;
3912
+ versionSlider.setMaximum(VersionCount() - 1);
3913
+ versionSlider.setInteger(copy.versionindex);
3914
+ muteSlider = false;
37213915 }
37223916
37233917 public boolean Undo()
37243918 {
3919
+ // Option?
3920
+ Replace();
3921
+
37253922 System.err.println("Undo");
37263923
37273924 cRadio tab = GetCurrentTab();
37283925
3729
- if (tab.undoindex == 0)
3926
+ if (copy.versionindex == 0)
37303927 {
37313928 java.awt.Toolkit.getDefaultToolkit().beep();
37323929 return false;
37333930 }
37343931
3735
- if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
3932
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3933
+// {
3934
+// if (Save(false))
3935
+// tab.versionindex -= 1;
3936
+// else
3937
+// {
3938
+// if (tab.versionindex <= 0)
3939
+// return false;
3940
+// else
3941
+// tab.versionindex -= 1;
3942
+// }
3943
+// }
3944
+
3945
+ copy.versionindex -= 1;
3946
+
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
3948
+
3949
+ return true;
3950
+ }
3951
+
3952
+ public boolean Restore()
3953
+ {
3954
+ System.err.println("Restore");
3955
+
3956
+ cRadio tab = GetCurrentTab();
3957
+
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
37363959 {
3737
- if (Save(false))
3738
- tab.undoindex -= 1;
3739
- else
3740
- {
3741
- if (tab.undoindex <= 0)
3742
- return false;
3743
- else
3744
- tab.undoindex -= 1;
3745
- }
3960
+ java.awt.Toolkit.getDefaultToolkit().beep();
3961
+ return false;
37463962 }
37473963
3748
- tab.undoindex -= 1;
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
3966
+
3967
+ return true;
3968
+ }
37493969
3750
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3970
+ public boolean Replace()
3971
+ {
3972
+ System.err.println("Replace");
3973
+
3974
+ cRadio tab = GetCurrentTab();
3975
+
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
3977
+ {
3978
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3979
+ return false;
3980
+ }
3981
+
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
37513983
37523984 return true;
37533985 }
37543986
37553987 public void Redo()
37563988 {
3989
+ // Option?
3990
+ Replace();
3991
+
37573992 cRadio tab = GetCurrentTab();
37583993
3759
- if (tab.graphs[tab.undoindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
37603995 {
37613996 java.awt.Toolkit.getDefaultToolkit().beep();
37623997 return;
37633998 }
37643999
3765
- tab.undoindex += 1;
4000
+ copy.versionindex += 1;
37664001
3767
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
37684003
3769
- //if (!tab.user[tab.undoindex])
3770
- // tab.graphs[tab.undoindex] = null;
4004
+ //if (!tab.user[tab.versionindex])
4005
+ // tab.graphs[tab.versionindex] = null;
37714006 }
37724007
37734008 void ImportGFD()
....@@ -3978,7 +4213,7 @@
39784213 //copy.material = new cMaterial(copy.GetMaterial());
39794214
39804215 current.color = (float) colorField.getFloat();
3981
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
39824217 current.metalness = (float) metalnessField.getFloat();
39834218 current.diffuse = (float) diffuseField.getFloat();
39844219 current.specular = (float) specularField.getFloat();
....@@ -4011,7 +4246,7 @@
40114246 cMaterial mat = copy.material;
40124247
40134248 colorField.SetToolTipValue((mat.color));
4014
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
40154250 metalnessField.SetToolTipValue((mat.metalness));
40164251 diffuseField.SetToolTipValue((mat.diffuse));
40174252 specularField.SetToolTipValue((mat.specular));
....@@ -4063,9 +4298,25 @@
40634298 //copy.Touch();
40644299 }
40654300
4301
+ cNumberSlider versionSlider;
4302
+
40664303 public void stateChanged(ChangeEvent e)
40674304 {
40684305 // assert(false);
4306
+ if (e.getSource() == versionSlider)
4307
+ {
4308
+ if (muteSlider)
4309
+ return;
4310
+
4311
+ int version = versionSlider.getInteger();
4312
+
4313
+ if (copy.versionlist[version] != null)
4314
+ {
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
4316
+ }
4317
+
4318
+ return;
4319
+ }
40694320
40704321 if (freezematerial)
40714322 {
....@@ -4101,6 +4352,12 @@
41014352 {
41024353 //System.out.println("stateChanged = " + this);
41034354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
41044361 applySelf();
41054362 //System.out.println("this = " + this);
41064363 //System.out.println("PARENT = " + parent);
....@@ -4400,6 +4657,7 @@
44004657 {
44014658 if (GetTree() != null)
44024659 {
4660
+ GetTree().revalidate();
44034661 GetTree().repaint();
44044662 }
44054663
....@@ -4414,7 +4672,7 @@
44144672
44154673 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
44164674 {
4417
- if (Globals.SAVEONMAKE) // && resetmodel)
4675
+ if (Globals.REPLACEONMAKE) // && resetmodel)
44184676 Save();
44194677 //Tween.set(thing, 0).target(1).start(tweenManager);
44204678 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4656,7 +4914,9 @@
46564914 readobj.ResetDisplayList();
46574915 } catch (Exception e)
46584916 {
4659
- //e.printStackTrace();
4917
+ if (!e.toString().contains("GZIP"))
4918
+ e.printStackTrace();
4919
+
46604920 try
46614921 {
46624922 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4736,6 +4996,8 @@
47364996 {
47374997 //readobj.deepCopySelf(copy);
47384998 copy.clear(); // june 2014
4999
+ copy.skyboxname = readobj.skyboxname;
5000
+ copy.skyboxext = readobj.skyboxext;
47395001 for (int i = 0; i < readobj.size(); i++)
47405002 {
47415003 Object3D child = readobj.get(i); // reserve(i);
....@@ -4776,6 +5038,7 @@
47765038 }
47775039 } catch (ClassCastException e)
47785040 {
5041
+ e.printStackTrace();
47795042 assert (false);
47805043 Composite c = (Composite) copy;
47815044 c.children.clear();
....@@ -4786,6 +5049,17 @@
47865049 c.addChild(csg);
47875050 }
47885051
5052
+ copy.versionlist = readobj.versionlist;
5053
+ copy.versionindex = readobj.versionindex;
5054
+
5055
+ if (copy.versionlist == null)
5056
+ {
5057
+ copy.versionlist = new Object3D[100];
5058
+ copy.versionindex = -1;
5059
+ }
5060
+
5061
+ //? SetUndoStates();
5062
+
47895063 ResetModel();
47905064 copy.HardTouch(); // recompile?
47915065 refreshContents();
....@@ -4895,6 +5169,7 @@
48955169 //ps.print(buffer.toString());
48965170 } catch (IOException e)
48975171 {
5172
+ e.printStackTrace();
48985173 }
48995174 }
49005175
....@@ -5187,7 +5462,7 @@
51875462 JLabel colorLabel;
51885463 cNumberSlider colorField;
51895464 JLabel modulationLabel;
5190
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
51915466 JLabel metalnessLabel;
51925467 cNumberSlider metalnessField;
51935468 JLabel diffuseLabel;