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,10 +353,10 @@
325353 copy = localCopy;
326354 copy.editWindow = this;
327355
328
- if (copy.versions == null)
356
+ if (copy.versionlist == null)
329357 {
330
- copy.versions = new byte[100][];
331
- copy.versionindex = -1;
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
332360 }
333361
334362 SetupMenu();
....@@ -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 }
....@@ -974,7 +1006,7 @@
9741006 // NumberSlider vDivsField;
9751007 // JCheckBox endcaps;
9761008 JCheckBox liveCB;
977
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9781010 JCheckBox hideCB;
9791011 JCheckBox link2masterCB;
9801012 JCheckBox markCB;
....@@ -1186,13 +1218,16 @@
11861218
11871219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11881220 liveCB.setToolTipText("Animate object");
1189
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
11911223 // Return();
1224
+
11921225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11931226 hideCB.setToolTipText("Hide object");
11941227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11951228 markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11961231
11971232 setupPanel2 = new cGridBag().setVertical(false);
11981233
....@@ -1519,22 +1554,28 @@
15191554 //tmp.setName("Edit");
15201555 objectPanel.add(materialPanel);
15211556 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
15221559 // JPanel north = new JPanel(new BorderLayout());
15231560 // north.setName("Edit");
15241561 // north.add(ctrlPanel, BorderLayout.NORTH);
15251562 // objectPanel.add(north);
15261563 objectPanel.add(editPanel);
15271564 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15281566
15291567 //if (Globals.ADVANCED)
15301568 objectPanel.add(infoPanel);
15311569 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
15321571
15331572 objectPanel.add(XYZPanel);
15341573 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15351575
15361576 objectPanel.add(toolboxPanel);
15371577 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15381579
15391580 /*
15401581 aConstraints.gridx = 0;
....@@ -1674,7 +1715,6 @@
16741715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16751716 frame.addWindowListener(new WindowAdapter()
16761717 {
1677
-
16781718 public void windowClosing(WindowEvent e)
16791719 {
16801720 Close();
....@@ -1697,12 +1737,85 @@
16971737 ctrlPanel.removeAll();
16981738 }
16991739
1700
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
17011741 {
1702
- /*
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
+ /*
17031816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17041817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1705
- */
1818
+ */
17061819
17071820 cGridBag editBar = new cGridBag().setVertical(false);
17081821
....@@ -1736,27 +1849,50 @@
17361849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17371850
17381851 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);
17391865
17401866 cGridBag color = new cGridBag();
1741
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1742
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1743
- 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
+
17441872 //colorField.preferredWidth = 200;
17451873 colorSection.add(color);
17461874
17471875 cGridBag modulation = new cGridBag();
17481876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17491877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1750
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17511879 colorSection.add(modulation);
17521880
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
+
17531889 cGridBag texture = new cGridBag();
17541890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17551891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17561892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17571893 colorSection.add(texture);
17581894
1759
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17601896
17611897 panel.add(colorSection);
17621898
....@@ -1812,7 +1948,7 @@
18121948 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18131949 diffuseSection.add(shadowbias);
18141950
1815
- panel.add(new JSeparator());
1951
+ panel.add(GetSeparator());
18161952
18171953 panel.add(diffuseSection);
18181954
....@@ -1875,7 +2011,7 @@
18752011 specularSection.add(anisoV);
18762012
18772013
1878
- panel.add(new JSeparator());
2014
+ panel.add(GetSeparator());
18792015
18802016 panel.add(specularSection);
18812017
....@@ -1900,12 +2036,6 @@
19002036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19012037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19022038 colorSection.add(backlit);
1903
-
1904
- cGridBag opacity = new cGridBag();
1905
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1906
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1907
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1908
- colorSection.add(opacity);
19092039
19102040 //panel.add(new JSeparator());
19112041
....@@ -1951,7 +2081,7 @@
19512081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19522082 textureSection.add(opacityPower);
19532083
1954
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
19552085
19562086 panel.add(textureSection);
19572087
....@@ -2938,7 +3068,7 @@
29383068
29393069 freezematerial = true;
29403070 colorField.setFloat(mat.color);
2941
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29423072 metalnessField.setFloat(mat.metalness);
29433073 diffuseField.setFloat(mat.diffuse);
29443074 specularField.setFloat(mat.specular);
....@@ -3249,8 +3379,9 @@
32493379 } else if (event.getSource() == liveCB)
32503380 {
32513381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
32523383 return;
3253
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
32543385 {
32553386 copy.dontselect ^= true;
32563387 return;
....@@ -3258,7 +3389,7 @@
32583389 {
32593390 copy.hide ^= true;
32603391 copy.Touch(); // display list issue
3261
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
32623393 return;
32633394 } else if (event.getSource() == link2masterCB)
32643395 {
....@@ -3514,6 +3645,7 @@
35143645
35153646 static public byte[] Compress(Object3D o)
35163647 {
3648
+ // Slower to actually compress.
35173649 try
35183650 {
35193651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3615,6 +3747,7 @@
36153747 {
36163748 //Save(true);
36173749 Replace();
3750
+ SetUndoStates();
36183751 }
36193752
36203753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3635,29 +3768,46 @@
36353768
36363769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36373770
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
+
36383783 public boolean Save(boolean user)
36393784 {
36403785 System.err.println("Save");
3786
+ //Replace();
36413787
36423788 cRadio tab = GetCurrentTab();
36433789
3644
- byte[] compress = CompressCopy();
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36453791
36463792 boolean thesame = false;
36473793
3648
- // Quick heuristic using length. Works only when stream is compressed.
3649
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3650
- {
3651
- thesame = true;
3652
- }
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
36533798
36543799 //EditorFrame.m_MainFrame.requestFocusInWindow();
36553800 if (!thesame)
36563801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
36573807 //tab.user[tab.versionindex] = user;
36583808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36593809
3660
- copy.versions[++copy.versionindex] = compress;
3810
+ copy.versionlist[++copy.versionindex] = compress;
36613811
36623812 // if (increment)
36633813 // tab.versionindex++;
....@@ -3667,11 +3817,11 @@
36673817
36683818 //assert(hashtable.isEmpty());
36693819
3670
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3671
- {
3672
- //tab.user[i] = false;
3673
- copy.versions[i] = null;
3674
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
36753825
36763826 SetUndoStates();
36773827
....@@ -3696,9 +3846,43 @@
36963846
36973847 return !thesame;
36983848 }
3699
-
3700
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
37013853 {
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
+
37023886 SetUndoStates();
37033887
37043888 boolean temp = CameraPane.SWITCH;
....@@ -3708,6 +3892,9 @@
37083892
37093893 copy.clear();
37103894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
37113898 for (int i=0; i<obj.Size(); i++)
37123899 {
37133900 copy.add(obj.get(i));
....@@ -3717,6 +3904,7 @@
37173904
37183905 CameraPane.SWITCH = temp;
37193906
3907
+ RefreshSelection();
37203908 //assert(hashtable.isEmpty());
37213909
37223910 copy.Touch();
....@@ -3737,13 +3925,15 @@
37373925 }
37383926 }
37393927
3740
- refreshContents();
3928
+ refreshContents(true);
37413929 }
37423930
3743
- cButton undoButton;
3931
+ cButton previousVersionButton;
37443932 cButton restoreButton;
37453933 cButton replaceButton;
3746
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
37473937
37483938 boolean muteSlider;
37493939
....@@ -3751,9 +3941,9 @@
37513941 {
37523942 int count = 0;
37533943
3754
- for (int i = copy.versions.length; --i >= 0;)
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
37553945 {
3756
- if (copy.versions[i] != null)
3946
+ if (copy.versionlist[i] != null)
37573947 count++;
37583948 }
37593949
....@@ -3764,11 +3954,14 @@
37643954 {
37653955 cRadio tab = GetCurrentTab();
37663956
3767
- restoreButton.setEnabled(copy.versionindex != -1);
3768
- replaceButton.setEnabled(copy.versionindex != -1);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
37693959
3770
- undoButton.setEnabled(copy.versionindex > 0);
3771
- 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);
37723965
37733966 muteSlider = true;
37743967 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3776,7 +3969,7 @@
37763969 muteSlider = false;
37773970 }
37783971
3779
- public boolean Undo()
3972
+ public boolean PreviousVersion()
37803973 {
37813974 // Option?
37823975 Replace();
....@@ -3806,7 +3999,7 @@
38063999
38074000 copy.versionindex -= 1;
38084001
3809
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged();
38104003
38114004 return true;
38124005 }
....@@ -3817,13 +4010,14 @@
38174010
38184011 cRadio tab = GetCurrentTab();
38194012
3820
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38214014 {
38224015 java.awt.Toolkit.getDefaultToolkit().beep();
38234016 return false;
38244017 }
38254018
3826
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
38274021
38284022 return true;
38294023 }
....@@ -3834,25 +4028,25 @@
38344028
38354029 cRadio tab = GetCurrentTab();
38364030
3837
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38384032 {
38394033 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38404034 return false;
38414035 }
38424036
3843
- copy.versions[copy.versionindex] = CompressCopy();
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
38444038
38454039 return true;
38464040 }
38474041
3848
- public void Redo()
4042
+ public void NextVersion()
38494043 {
38504044 // Option?
38514045 Replace();
38524046
38534047 cRadio tab = GetCurrentTab();
38544048
3855
- if (copy.versions[copy.versionindex + 1] == null)
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
38564050 {
38574051 java.awt.Toolkit.getDefaultToolkit().beep();
38584052 return;
....@@ -3860,7 +4054,7 @@
38604054
38614055 copy.versionindex += 1;
38624056
3863
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4057
+ CopyChanged();
38644058
38654059 //if (!tab.user[tab.versionindex])
38664060 // tab.graphs[tab.versionindex] = null;
....@@ -4074,7 +4268,7 @@
40744268 //copy.material = new cMaterial(copy.GetMaterial());
40754269
40764270 current.color = (float) colorField.getFloat();
4077
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
40784272 current.metalness = (float) metalnessField.getFloat();
40794273 current.diffuse = (float) diffuseField.getFloat();
40804274 current.specular = (float) specularField.getFloat();
....@@ -4107,7 +4301,7 @@
41074301 cMaterial mat = copy.material;
41084302
41094303 colorField.SetToolTipValue((mat.color));
4110
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
41114305 metalnessField.SetToolTipValue((mat.metalness));
41124306 diffuseField.SetToolTipValue((mat.diffuse));
41134307 specularField.SetToolTipValue((mat.specular));
....@@ -4171,9 +4365,10 @@
41714365
41724366 int version = versionSlider.getInteger();
41734367
4174
- if (copy.versions[version] != null)
4368
+ if (copy.versionlist[version] != null)
41754369 {
4176
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
41774372 }
41784373
41794374 return;
....@@ -4213,6 +4408,12 @@
42134408 {
42144409 //System.out.println("stateChanged = " + this);
42154410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
42164417 applySelf();
42174418 //System.out.println("this = " + this);
42184419 //System.out.println("PARENT = " + parent);
....@@ -4512,6 +4713,7 @@
45124713 {
45134714 if (GetTree() != null)
45144715 {
4716
+ GetTree().revalidate();
45154717 GetTree().repaint();
45164718 }
45174719
....@@ -4520,6 +4722,9 @@
45204722 ctrlPanel.validate(); // ? new
45214723 ctrlPanel.repaint();
45224724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
45234728 }
45244729
45254730 static TweenManager tweenManager = new TweenManager();
....@@ -4768,7 +4973,9 @@
47684973 readobj.ResetDisplayList();
47694974 } catch (Exception e)
47704975 {
4771
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
47724979 try
47734980 {
47744981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4848,6 +5055,8 @@
48485055 {
48495056 //readobj.deepCopySelf(copy);
48505057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
48515060 for (int i = 0; i < readobj.size(); i++)
48525061 {
48535062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4888,6 +5097,7 @@
48885097 }
48895098 } catch (ClassCastException e)
48905099 {
5100
+ e.printStackTrace();
48915101 assert (false);
48925102 Composite c = (Composite) copy;
48935103 c.children.clear();
....@@ -4898,12 +5108,12 @@
48985108 c.addChild(csg);
48995109 }
49005110
4901
- copy.versions = readobj.versions;
5111
+ copy.versionlist = readobj.versionlist;
49025112 copy.versionindex = readobj.versionindex;
49035113
4904
- if (copy.versions == null)
5114
+ if (copy.versionlist == null)
49055115 {
4906
- copy.versions = new byte[100][];
5116
+ copy.versionlist = new Object3D[100];
49075117 copy.versionindex = -1;
49085118 }
49095119
....@@ -4919,7 +5129,7 @@
49195129 {
49205130 if (Grafreed.standAlone)
49215131 {
4922
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49235133 browser.show();
49245134 String filename = browser.getFile();
49255135 if (filename != null && filename.length() > 0)
....@@ -5018,6 +5228,7 @@
50185228 //ps.print(buffer.toString());
50195229 } catch (IOException e)
50205230 {
5231
+ e.printStackTrace();
50215232 }
50225233 }
50235234
....@@ -5310,7 +5521,7 @@
53105521 JLabel colorLabel;
53115522 cNumberSlider colorField;
53125523 JLabel modulationLabel;
5313
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
53145525 JLabel metalnessLabel;
53155526 cNumberSlider metalnessField;
53165527 JLabel diffuseLabel;