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)
....@@ -60,26 +74,40 @@
6074 return new cCheckBox(icon, border);
6175 }
6276
63
- private ImageIcon GetIcon(String name)
77
+ ImageIcon GetIcon(String name)
6478 {
6579 try
6680 {
6781 BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
6882
69
- if (image.getWidth() != 24 && image.getHeight() != 24)
70
- {
71
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
72
- Graphics2D g = resized.createGraphics();
73
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
76
- g.dispose();
77
-
78
- image = resized;
79
- }
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
+// }
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;
....@@ -436,10 +464,10 @@
436464 editPanel.add(editCommandsPanel);
437465 editPanel.add(ctrlPanel);
438466
439
- toolboxPanel = new cGridBag().setVertical(false);
467
+ 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 }
....@@ -1194,6 +1226,8 @@
11941226 hideCB.setToolTipText("Hide object");
11951227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11961228 markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11971231
11981232 setupPanel2 = new cGridBag().setVertical(false);
11991233
....@@ -1520,22 +1554,28 @@
15201554 //tmp.setName("Edit");
15211555 objectPanel.add(materialPanel);
15221556 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
15231559 // JPanel north = new JPanel(new BorderLayout());
15241560 // north.setName("Edit");
15251561 // north.add(ctrlPanel, BorderLayout.NORTH);
15261562 // objectPanel.add(north);
15271563 objectPanel.add(editPanel);
15281564 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15291566
15301567 //if (Globals.ADVANCED)
15311568 objectPanel.add(infoPanel);
15321569 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
15331571
15341572 objectPanel.add(XYZPanel);
15351573 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15361575
15371576 objectPanel.add(toolboxPanel);
15381577 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15391579
15401580 /*
15411581 aConstraints.gridx = 0;
....@@ -1675,7 +1715,6 @@
16751715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16761716 frame.addWindowListener(new WindowAdapter()
16771717 {
1678
-
16791718 public void windowClosing(WindowEvent e)
16801719 {
16811720 Close();
....@@ -1698,12 +1737,85 @@
16981737 ctrlPanel.removeAll();
16991738 }
17001739
1701
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
17021741 {
1703
- /*
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
+ /*
17041816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17051817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1706
- */
1818
+ */
17071819
17081820 cGridBag editBar = new cGridBag().setVertical(false);
17091821
....@@ -1737,27 +1849,50 @@
17371849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17381850
17391851 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);
17401865
17411866 cGridBag color = new cGridBag();
1742
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1743
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1744
- 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
+
17451872 //colorField.preferredWidth = 200;
17461873 colorSection.add(color);
17471874
17481875 cGridBag modulation = new cGridBag();
17491876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17501877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1751
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17521879 colorSection.add(modulation);
17531880
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
+
17541889 cGridBag texture = new cGridBag();
17551890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17561891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17571892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17581893 colorSection.add(texture);
17591894
1760
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17611896
17621897 panel.add(colorSection);
17631898
....@@ -1813,7 +1948,7 @@
18131948 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18141949 diffuseSection.add(shadowbias);
18151950
1816
- panel.add(new JSeparator());
1951
+ panel.add(GetSeparator());
18171952
18181953 panel.add(diffuseSection);
18191954
....@@ -1876,7 +2011,7 @@
18762011 specularSection.add(anisoV);
18772012
18782013
1879
- panel.add(new JSeparator());
2014
+ panel.add(GetSeparator());
18802015
18812016 panel.add(specularSection);
18822017
....@@ -1901,12 +2036,6 @@
19012036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19022037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19032038 colorSection.add(backlit);
1904
-
1905
- cGridBag opacity = new cGridBag();
1906
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1907
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1908
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1909
- colorSection.add(opacity);
19102039
19112040 //panel.add(new JSeparator());
19122041
....@@ -1952,7 +2081,7 @@
19522081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19532082 textureSection.add(opacityPower);
19542083
1955
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
19562085
19572086 panel.add(textureSection);
19582087
....@@ -2939,7 +3068,7 @@
29393068
29403069 freezematerial = true;
29413070 colorField.setFloat(mat.color);
2942
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29433072 metalnessField.setFloat(mat.metalness);
29443073 diffuseField.setFloat(mat.diffuse);
29453074 specularField.setFloat(mat.specular);
....@@ -3250,6 +3379,7 @@
32503379 } else if (event.getSource() == liveCB)
32513380 {
32523381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
32533383 return;
32543384 } else if (event.getSource() == selectableCB)
32553385 {
....@@ -3259,7 +3389,7 @@
32593389 {
32603390 copy.hide ^= true;
32613391 copy.Touch(); // display list issue
3262
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
32633393 return;
32643394 } else if (event.getSource() == link2masterCB)
32653395 {
....@@ -3515,6 +3645,7 @@
35153645
35163646 static public byte[] Compress(Object3D o)
35173647 {
3648
+ // Slower to actually compress.
35183649 try
35193650 {
35203651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3616,6 +3747,7 @@
36163747 {
36173748 //Save(true);
36183749 Replace();
3750
+ SetUndoStates();
36193751 }
36203752
36213753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3636,29 +3768,46 @@
36363768
36373769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36383770
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
+
36393783 public boolean Save(boolean user)
36403784 {
36413785 System.err.println("Save");
3786
+ //Replace();
36423787
36433788 cRadio tab = GetCurrentTab();
36443789
3645
- byte[] compress = CompressCopy();
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36463791
36473792 boolean thesame = false;
36483793
3649
- // Quick heuristic using length. Works only when stream is compressed.
3650
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3651
- {
3652
- thesame = true;
3653
- }
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
36543798
36553799 //EditorFrame.m_MainFrame.requestFocusInWindow();
36563800 if (!thesame)
36573801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
36583807 //tab.user[tab.versionindex] = user;
36593808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36603809
3661
- copy.versions[++copy.versionindex] = compress;
3810
+ copy.versionlist[++copy.versionindex] = compress;
36623811
36633812 // if (increment)
36643813 // tab.versionindex++;
....@@ -3668,11 +3817,11 @@
36683817
36693818 //assert(hashtable.isEmpty());
36703819
3671
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3672
- {
3673
- //tab.user[i] = false;
3674
- copy.versions[i] = null;
3675
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
36763825
36773826 SetUndoStates();
36783827
....@@ -3697,9 +3846,43 @@
36973846
36983847 return !thesame;
36993848 }
3700
-
3701
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
37023853 {
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
+
37033886 SetUndoStates();
37043887
37053888 boolean temp = CameraPane.SWITCH;
....@@ -3709,6 +3892,9 @@
37093892
37103893 copy.clear();
37113894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
37123898 for (int i=0; i<obj.Size(); i++)
37133899 {
37143900 copy.add(obj.get(i));
....@@ -3718,6 +3904,7 @@
37183904
37193905 CameraPane.SWITCH = temp;
37203906
3907
+ RefreshSelection();
37213908 //assert(hashtable.isEmpty());
37223909
37233910 copy.Touch();
....@@ -3738,13 +3925,15 @@
37383925 }
37393926 }
37403927
3741
- refreshContents();
3928
+ refreshContents(true);
37423929 }
37433930
3744
- cButton undoButton;
3931
+ cButton previousVersionButton;
37453932 cButton restoreButton;
37463933 cButton replaceButton;
3747
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
37483937
37493938 boolean muteSlider;
37503939
....@@ -3752,9 +3941,9 @@
37523941 {
37533942 int count = 0;
37543943
3755
- for (int i = copy.versions.length; --i >= 0;)
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
37563945 {
3757
- if (copy.versions[i] != null)
3946
+ if (copy.versionlist[i] != null)
37583947 count++;
37593948 }
37603949
....@@ -3765,11 +3954,14 @@
37653954 {
37663955 cRadio tab = GetCurrentTab();
37673956
3768
- restoreButton.setEnabled(copy.versionindex != -1);
3769
- replaceButton.setEnabled(copy.versionindex != -1);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
37703959
3771
- undoButton.setEnabled(copy.versionindex > 0);
3772
- 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);
37733965
37743966 muteSlider = true;
37753967 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3777,7 +3969,7 @@
37773969 muteSlider = false;
37783970 }
37793971
3780
- public boolean Undo()
3972
+ public boolean PreviousVersion()
37813973 {
37823974 // Option?
37833975 Replace();
....@@ -3807,7 +3999,7 @@
38073999
38084000 copy.versionindex -= 1;
38094001
3810
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged();
38114003
38124004 return true;
38134005 }
....@@ -3818,13 +4010,14 @@
38184010
38194011 cRadio tab = GetCurrentTab();
38204012
3821
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38224014 {
38234015 java.awt.Toolkit.getDefaultToolkit().beep();
38244016 return false;
38254017 }
38264018
3827
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
38284021
38294022 return true;
38304023 }
....@@ -3835,25 +4028,25 @@
38354028
38364029 cRadio tab = GetCurrentTab();
38374030
3838
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38394032 {
38404033 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38414034 return false;
38424035 }
38434036
3844
- copy.versions[copy.versionindex] = CompressCopy();
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
38454038
38464039 return true;
38474040 }
38484041
3849
- public void Redo()
4042
+ public void NextVersion()
38504043 {
38514044 // Option?
38524045 Replace();
38534046
38544047 cRadio tab = GetCurrentTab();
38554048
3856
- if (copy.versions[copy.versionindex + 1] == null)
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
38574050 {
38584051 java.awt.Toolkit.getDefaultToolkit().beep();
38594052 return;
....@@ -3861,7 +4054,7 @@
38614054
38624055 copy.versionindex += 1;
38634056
3864
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4057
+ CopyChanged();
38654058
38664059 //if (!tab.user[tab.versionindex])
38674060 // tab.graphs[tab.versionindex] = null;
....@@ -4075,7 +4268,7 @@
40754268 //copy.material = new cMaterial(copy.GetMaterial());
40764269
40774270 current.color = (float) colorField.getFloat();
4078
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
40794272 current.metalness = (float) metalnessField.getFloat();
40804273 current.diffuse = (float) diffuseField.getFloat();
40814274 current.specular = (float) specularField.getFloat();
....@@ -4108,7 +4301,7 @@
41084301 cMaterial mat = copy.material;
41094302
41104303 colorField.SetToolTipValue((mat.color));
4111
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
41124305 metalnessField.SetToolTipValue((mat.metalness));
41134306 diffuseField.SetToolTipValue((mat.diffuse));
41144307 specularField.SetToolTipValue((mat.specular));
....@@ -4172,9 +4365,10 @@
41724365
41734366 int version = versionSlider.getInteger();
41744367
4175
- if (copy.versions[version] != null)
4368
+ if (copy.versionlist[version] != null)
41764369 {
4177
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
41784372 }
41794373
41804374 return;
....@@ -4214,6 +4408,12 @@
42144408 {
42154409 //System.out.println("stateChanged = " + this);
42164410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
42174417 applySelf();
42184418 //System.out.println("this = " + this);
42194419 //System.out.println("PARENT = " + parent);
....@@ -4513,6 +4713,7 @@
45134713 {
45144714 if (GetTree() != null)
45154715 {
4716
+ GetTree().revalidate();
45164717 GetTree().repaint();
45174718 }
45184719
....@@ -4521,6 +4722,9 @@
45214722 ctrlPanel.validate(); // ? new
45224723 ctrlPanel.repaint();
45234724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
45244728 }
45254729
45264730 static TweenManager tweenManager = new TweenManager();
....@@ -4769,7 +4973,9 @@
47694973 readobj.ResetDisplayList();
47704974 } catch (Exception e)
47714975 {
4772
- e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
47734979 try
47744980 {
47754981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4849,6 +5055,8 @@
48495055 {
48505056 //readobj.deepCopySelf(copy);
48515057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
48525060 for (int i = 0; i < readobj.size(); i++)
48535061 {
48545062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4900,12 +5108,12 @@
49005108 c.addChild(csg);
49015109 }
49025110
4903
- copy.versions = readobj.versions;
5111
+ copy.versionlist = readobj.versionlist;
49045112 copy.versionindex = readobj.versionindex;
49055113
4906
- if (copy.versions == null)
5114
+ if (copy.versionlist == null)
49075115 {
4908
- copy.versions = new byte[100][];
5116
+ copy.versionlist = new Object3D[100];
49095117 copy.versionindex = -1;
49105118 }
49115119
....@@ -4921,7 +5129,7 @@
49215129 {
49225130 if (Grafreed.standAlone)
49235131 {
4924
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49255133 browser.show();
49265134 String filename = browser.getFile();
49275135 if (filename != null && filename.length() > 0)
....@@ -5313,7 +5521,7 @@
53135521 JLabel colorLabel;
53145522 cNumberSlider colorField;
53155523 JLabel modulationLabel;
5316
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
53175525 JLabel metalnessLabel;
53185526 cNumberSlider metalnessField;
53195527 JLabel diffuseLabel;