Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
ObjEditor.java
....@@ -41,11 +41,25 @@
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 {
4755 ImageIcon icon = GetIcon(name);
4856 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);
4963 }
5064
5165 cToggleButton GetToggleButton(String name, boolean border)
....@@ -80,6 +94,20 @@
8094
8195 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
8296 return icon;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
83111 }
84112 catch (Exception e)
85113 {
....@@ -268,9 +296,9 @@
268296 client = inClient;
269297 copy = client;
270298
271
- if (copy.versions == null)
299
+ if (copy.versionlist == null)
272300 {
273
- copy.versions = new byte[100][];
301
+ copy.versionlist = new Object3D[100];
274302 copy.versionindex = -1;
275303 }
276304
....@@ -287,9 +315,9 @@
287315 client = inClient;
288316 copy = client;
289317
290
- if (copy.versions == null)
318
+ if (copy.versionlist == null)
291319 {
292
- copy.versions = new byte[100][];
320
+ copy.versionlist = new Object3D[100];
293321 copy.versionindex = -1;
294322 }
295323
....@@ -325,7 +353,7 @@
325353 copy = localCopy;
326354 copy.editWindow = this;
327355
328
- if (copy.versions == null)
356
+ if (copy.versionlist == null)
329357 {
330358 // copy.versions = new byte[100][];
331359 // copy.versionindex = -1;
....@@ -439,7 +467,7 @@
439467 toolboxPanel = new cGridBag().setVertical(true);
440468 //toolboxPanel.setName("Toolbox");
441469
442
- materialPanel = new cGridBag().setVertical(true);
470
+ materialPanel = new cGridBag().setVertical(false);
443471 //materialPanel.setName("Material");
444472
445473 /*JTextPane*/
....@@ -820,9 +848,11 @@
820848 //frame.setVisible(true);
821849 }
822850 frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
823853 }
824854
825
- private byte[] CompressCopy()
855
+ private Object3D CompressCopy()
826856 {
827857 boolean temp = CameraPane.SWITCH;
828858 CameraPane.SWITCH = false;
....@@ -830,12 +860,13 @@
830860 copy.ExtractBigData(versiontable);
831861 // if (copy == client)
832862
833
- byte[] versions[] = copy.versions;
834
- copy.versions = null;
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
835865
836
- byte[] compress = Compress(copy);
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
837868
838
- copy.versions = versions;
869
+ copy.versionlist = versions;
839870
840871 copy.RestoreBigData(versiontable);
841872
....@@ -965,6 +996,7 @@
965996 {
966997 SetupMaterial(materialPanel);
967998 }
999
+
9681000 //SetupName();
9691001 //SetupViews();
9701002 }
....@@ -1522,22 +1554,28 @@
15221554 //tmp.setName("Edit");
15231555 objectPanel.add(materialPanel);
15241556 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
15251559 // JPanel north = new JPanel(new BorderLayout());
15261560 // north.setName("Edit");
15271561 // north.add(ctrlPanel, BorderLayout.NORTH);
15281562 // objectPanel.add(north);
15291563 objectPanel.add(editPanel);
15301564 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15311566
15321567 //if (Globals.ADVANCED)
15331568 objectPanel.add(infoPanel);
15341569 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
15351571
15361572 objectPanel.add(XYZPanel);
15371573 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15381575
15391576 objectPanel.add(toolboxPanel);
15401577 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15411579
15421580 /*
15431581 aConstraints.gridx = 0;
....@@ -1634,8 +1672,8 @@
16341672 /**/
16351673
16361674 bigThree = new cGridBag();
1637
- bigThree.addComponent(centralPanel);
16381675 bigThree.addComponent(scenePanel);
1676
+ bigThree.addComponent(centralPanel);
16391677 //bigThree.addComponent(XYZPanel);
16401678
16411679 // // SIDE EFFECT!!!
....@@ -1677,7 +1715,6 @@
16771715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16781716 frame.addWindowListener(new WindowAdapter()
16791717 {
1680
-
16811718 public void windowClosing(WindowEvent e)
16821719 {
16831720 Close();
....@@ -1700,12 +1737,85 @@
17001737 ctrlPanel.removeAll();
17011738 }
17021739
1703
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
17041741 {
1705
- /*
1742
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
1745
+ {
1746
+ public void mouseClicked(MouseEvent e)
1747
+ {
1748
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1749
+ cMaterial material = object.material;
1750
+
1751
+ // Skin
1752
+ colorField.setFloat(material.color);
1753
+ saturationField.setFloat(material.modulation);
1754
+ subsurfaceField.setFloat(material.subsurface);
1755
+ selfshadowField.setFloat(material.diffuseness);
1756
+ diffusenessField.setFloat(material.factor);
1757
+ shininessField.setFloat(material.shininess);
1758
+ shadowbiasField.setFloat(material.shadowbias);
1759
+ diffuseField.setFloat(material.diffuse);
1760
+ specularField.setFloat(material.specular);
1761
+
1762
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1763
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1764
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1765
+
1766
+ materialtouched = true;
1767
+ applySelf();
1768
+ }
1769
+ });
1770
+ presetpanel.add(skin);
1771
+
1772
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1773
+ rough2.addMouseListener(new MouseAdapter()
1774
+ {
1775
+ public void mouseClicked(MouseEvent e)
1776
+ {
1777
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1778
+ cMaterial material = object.material;
1779
+
1780
+ shininessField.setFloat(material.shininess);
1781
+ velvetField.setFloat(material.velvet);
1782
+
1783
+ materialtouched = true;
1784
+ applySelf();
1785
+ }
1786
+ });
1787
+ presetpanel.add(rough2);
1788
+
1789
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1790
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1791
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1792
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1793
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1794
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1795
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1796
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1797
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1798
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1799
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1800
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1801
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1802
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1803
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1804
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1805
+
1806
+ cGridBag panel = new cGridBag().setVertical(true);
1807
+
1808
+ presetpanel.preferredWidth = 1;
1809
+
1810
+ materialpanel.add(panel);
1811
+ materialpanel.add(presetpanel);
1812
+
1813
+ panel.preferredWidth = 8;
1814
+
1815
+ /*
17061816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17071817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1708
- */
1818
+ */
17091819
17101820 cGridBag editBar = new cGridBag().setVertical(false);
17111821
....@@ -1739,27 +1849,50 @@
17391849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17401850
17411851 cGridBag colorSection = new cGridBag().setVertical(true);
1852
+
1853
+ cGridBag huepanel = new cGridBag();
1854
+ cGridBag huelabel = new cGridBag();
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
1858
+ huelabel.preferredWidth = 20;
1859
+ huepanel.add(new cGridBag()); // Label
1860
+ huepanel.add(huelabel); // Field/slider
1861
+
1862
+ huepanel.preferredHeight = 7;
1863
+
1864
+ colorSection.add(huepanel);
17421865
17431866 cGridBag color = new cGridBag();
1744
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1745
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1746
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1867
+
1868
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1869
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1871
+
17471872 //colorField.preferredWidth = 200;
17481873 colorSection.add(color);
17491874
17501875 cGridBag modulation = new cGridBag();
17511876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17521877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1753
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17541879 colorSection.add(modulation);
17551880
1881
+ cGridBag opacity = new cGridBag();
1882
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1883
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1884
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1885
+ colorSection.add(opacity);
1886
+
1887
+ colorSection.add(GetSeparator());
1888
+
17561889 cGridBag texture = new cGridBag();
17571890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17581891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17591892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17601893 colorSection.add(texture);
17611894
1762
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17631896
17641897 panel.add(colorSection);
17651898
....@@ -1815,7 +1948,7 @@
18151948 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18161949 diffuseSection.add(shadowbias);
18171950
1818
- panel.add(new JSeparator());
1951
+ panel.add(GetSeparator());
18191952
18201953 panel.add(diffuseSection);
18211954
....@@ -1878,7 +2011,7 @@
18782011 specularSection.add(anisoV);
18792012
18802013
1881
- panel.add(new JSeparator());
2014
+ panel.add(GetSeparator());
18822015
18832016 panel.add(specularSection);
18842017
....@@ -1903,12 +2036,6 @@
19032036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19042037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19052038 colorSection.add(backlit);
1906
-
1907
- cGridBag opacity = new cGridBag();
1908
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1909
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1910
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1911
- colorSection.add(opacity);
19122039
19132040 //panel.add(new JSeparator());
19142041
....@@ -1954,7 +2081,7 @@
19542081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19552082 textureSection.add(opacityPower);
19562083
1957
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
19582085
19592086 panel.add(textureSection);
19602087
....@@ -2941,7 +3068,7 @@
29413068
29423069 freezematerial = true;
29433070 colorField.setFloat(mat.color);
2944
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29453072 metalnessField.setFloat(mat.metalness);
29463073 diffuseField.setFloat(mat.diffuse);
29473074 specularField.setFloat(mat.specular);
....@@ -3252,6 +3379,7 @@
32523379 } else if (event.getSource() == liveCB)
32533380 {
32543381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
32553383 return;
32563384 } else if (event.getSource() == selectableCB)
32573385 {
....@@ -3261,7 +3389,7 @@
32613389 {
32623390 copy.hide ^= true;
32633391 copy.Touch(); // display list issue
3264
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
32653393 return;
32663394 } else if (event.getSource() == link2masterCB)
32673395 {
....@@ -3517,6 +3645,7 @@
35173645
35183646 static public byte[] Compress(Object3D o)
35193647 {
3648
+ // Slower to actually compress.
35203649 try
35213650 {
35223651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3618,6 +3747,7 @@
36183747 {
36193748 //Save(true);
36203749 Replace();
3750
+ SetUndoStates();
36213751 }
36223752
36233753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3638,29 +3768,46 @@
36383768
36393769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36403770
3771
+ void DeleteVersion()
3772
+ {
3773
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
3774
+ {
3775
+ copy.versionlist[i] = copy.versionlist[i+1];
3776
+ }
3777
+
3778
+ CopyChanged();
3779
+
3780
+ SetUndoStates();
3781
+ }
3782
+
36413783 public boolean Save(boolean user)
36423784 {
36433785 System.err.println("Save");
3786
+ //Replace();
36443787
36453788 cRadio tab = GetCurrentTab();
36463789
3647
- byte[] compress = CompressCopy();
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36483791
36493792 boolean thesame = false;
36503793
3651
- // Quick heuristic using length. Works only when stream is compressed.
3652
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3653
- {
3654
- thesame = true;
3655
- }
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
36563798
36573799 //EditorFrame.m_MainFrame.requestFocusInWindow();
36583800 if (!thesame)
36593801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
36603807 //tab.user[tab.versionindex] = user;
36613808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36623809
3663
- copy.versions[++copy.versionindex] = compress;
3810
+ copy.versionlist[++copy.versionindex] = compress;
36643811
36653812 // if (increment)
36663813 // tab.versionindex++;
....@@ -3670,11 +3817,11 @@
36703817
36713818 //assert(hashtable.isEmpty());
36723819
3673
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3674
- {
3675
- //tab.user[i] = false;
3676
- copy.versions[i] = null;
3677
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
36783825
36793826 SetUndoStates();
36803827
....@@ -3699,9 +3846,43 @@
36993846
37003847 return !thesame;
37013848 }
3702
-
3703
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
37043853 {
3854
+ Object3D selection = new Object3D();
3855
+
3856
+ for (int i = 0; i < copy.selection.size(); i++)
3857
+ {
3858
+ Object3D elem = copy.selection.elementAt(i);
3859
+
3860
+ Object3D obj = copy.GetObject(elem.GetUUID());
3861
+
3862
+ if (obj == null)
3863
+ {
3864
+ copy.selection.remove(i--);
3865
+ }
3866
+ else
3867
+ {
3868
+ selection.add(obj);
3869
+ copy.selection.setElementAt(obj, i);
3870
+ }
3871
+ }
3872
+
3873
+ flashIt = false;
3874
+ GetTree().clearSelection();
3875
+ for (int i = 0; i < selection.size(); i++)
3876
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3877
+ flashIt = true;
3878
+
3879
+ //refreshContents(false);
3880
+ }
3881
+
3882
+ void CopyChanged()
3883
+ {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
37053886 SetUndoStates();
37063887
37073888 boolean temp = CameraPane.SWITCH;
....@@ -3711,6 +3892,9 @@
37113892
37123893 copy.clear();
37133894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
37143898 for (int i=0; i<obj.Size(); i++)
37153899 {
37163900 copy.add(obj.get(i));
....@@ -3720,6 +3904,7 @@
37203904
37213905 CameraPane.SWITCH = temp;
37223906
3907
+ RefreshSelection();
37233908 //assert(hashtable.isEmpty());
37243909
37253910 copy.Touch();
....@@ -3740,13 +3925,15 @@
37403925 }
37413926 }
37423927
3743
- refreshContents();
3928
+ refreshContents(true);
37443929 }
37453930
3746
- cButton undoButton;
3931
+ cButton previousVersionButton;
37473932 cButton restoreButton;
37483933 cButton replaceButton;
3749
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
37503937
37513938 boolean muteSlider;
37523939
....@@ -3754,9 +3941,9 @@
37543941 {
37553942 int count = 0;
37563943
3757
- for (int i = copy.versions.length; --i >= 0;)
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
37583945 {
3759
- if (copy.versions[i] != null)
3946
+ if (copy.versionlist[i] != null)
37603947 count++;
37613948 }
37623949
....@@ -3767,11 +3954,14 @@
37673954 {
37683955 cRadio tab = GetCurrentTab();
37693956
3770
- restoreButton.setEnabled(copy.versionindex != -1);
3771
- replaceButton.setEnabled(copy.versionindex != -1);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
37723959
3773
- undoButton.setEnabled(copy.versionindex > 0);
3774
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3960
+ previousVersionButton.setEnabled(copy.versionindex > 0);
3961
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3962
+
3963
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
3964
+ copy.versionlist[copy.versionindex + 1] != null);
37753965
37763966 muteSlider = true;
37773967 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3779,7 +3969,7 @@
37793969 muteSlider = false;
37803970 }
37813971
3782
- public boolean Undo()
3972
+ public boolean PreviousVersion()
37833973 {
37843974 // Option?
37853975 Replace();
....@@ -3809,7 +3999,7 @@
38093999
38104000 copy.versionindex -= 1;
38114001
3812
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged();
38134003
38144004 return true;
38154005 }
....@@ -3820,13 +4010,14 @@
38204010
38214011 cRadio tab = GetCurrentTab();
38224012
3823
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38244014 {
38254015 java.awt.Toolkit.getDefaultToolkit().beep();
38264016 return false;
38274017 }
38284018
3829
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
38304021
38314022 return true;
38324023 }
....@@ -3837,25 +4028,25 @@
38374028
38384029 cRadio tab = GetCurrentTab();
38394030
3840
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38414032 {
38424033 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38434034 return false;
38444035 }
38454036
3846
- copy.versions[copy.versionindex] = CompressCopy();
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
38474038
38484039 return true;
38494040 }
38504041
3851
- public void Redo()
4042
+ public void NextVersion()
38524043 {
38534044 // Option?
38544045 Replace();
38554046
38564047 cRadio tab = GetCurrentTab();
38574048
3858
- if (copy.versions[copy.versionindex + 1] == null)
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
38594050 {
38604051 java.awt.Toolkit.getDefaultToolkit().beep();
38614052 return;
....@@ -3863,7 +4054,7 @@
38634054
38644055 copy.versionindex += 1;
38654056
3866
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4057
+ CopyChanged();
38674058
38684059 //if (!tab.user[tab.versionindex])
38694060 // tab.graphs[tab.versionindex] = null;
....@@ -4077,7 +4268,7 @@
40774268 //copy.material = new cMaterial(copy.GetMaterial());
40784269
40794270 current.color = (float) colorField.getFloat();
4080
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
40814272 current.metalness = (float) metalnessField.getFloat();
40824273 current.diffuse = (float) diffuseField.getFloat();
40834274 current.specular = (float) specularField.getFloat();
....@@ -4110,7 +4301,7 @@
41104301 cMaterial mat = copy.material;
41114302
41124303 colorField.SetToolTipValue((mat.color));
4113
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
41144305 metalnessField.SetToolTipValue((mat.metalness));
41154306 diffuseField.SetToolTipValue((mat.diffuse));
41164307 specularField.SetToolTipValue((mat.specular));
....@@ -4174,9 +4365,10 @@
41744365
41754366 int version = versionSlider.getInteger();
41764367
4177
- if (copy.versions[version] != null)
4368
+ if (copy.versionlist[version] != null)
41784369 {
4179
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
41804372 }
41814373
41824374 return;
....@@ -4216,6 +4408,12 @@
42164408 {
42174409 //System.out.println("stateChanged = " + this);
42184410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
42194417 applySelf();
42204418 //System.out.println("this = " + this);
42214419 //System.out.println("PARENT = " + parent);
....@@ -4515,6 +4713,7 @@
45154713 {
45164714 if (GetTree() != null)
45174715 {
4716
+ GetTree().revalidate();
45184717 GetTree().repaint();
45194718 }
45204719
....@@ -4523,6 +4722,9 @@
45234722 ctrlPanel.validate(); // ? new
45244723 ctrlPanel.repaint();
45254724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
45264728 }
45274729
45284730 static TweenManager tweenManager = new TweenManager();
....@@ -4906,12 +5108,12 @@
49065108 c.addChild(csg);
49075109 }
49085110
4909
- copy.versions = readobj.versions;
5111
+ copy.versionlist = readobj.versionlist;
49105112 copy.versionindex = readobj.versionindex;
49115113
4912
- if (copy.versions == null)
5114
+ if (copy.versionlist == null)
49135115 {
4914
- copy.versions = new byte[100][];
5116
+ copy.versionlist = new Object3D[100];
49155117 copy.versionindex = -1;
49165118 }
49175119
....@@ -4927,7 +5129,7 @@
49275129 {
49285130 if (Grafreed.standAlone)
49295131 {
4930
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49315133 browser.show();
49325134 String filename = browser.getFile();
49335135 if (filename != null && filename.length() > 0)
....@@ -5319,7 +5521,7 @@
53195521 JLabel colorLabel;
53205522 cNumberSlider colorField;
53215523 JLabel modulationLabel;
5322
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
53235525 JLabel metalnessLabel;
53245526 cNumberSlider metalnessField;
53255527 JLabel diffuseLabel;