Normand Briere
2019-08-06 b3ae4e889872ca0b9ca76f1d17b2f0b961226729
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,23 +1554,29 @@
15201554 //tmp.setName("Edit");
15211555 objectPanel.add(materialPanel);
15221556 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
1559
+ objectPanel.add(toolboxPanel);
1560
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Objects & backgrounds");
1562
+
15231563 // JPanel north = new JPanel(new BorderLayout());
15241564 // north.setName("Edit");
15251565 // north.add(ctrlPanel, BorderLayout.NORTH);
15261566 // objectPanel.add(north);
15271567 objectPanel.add(editPanel);
1528
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1568
+ objectPanel.setIconAt(2, GetIcon("icons/write.png"));
1569
+ objectPanel.setToolTipTextAt(2, "Edit controls");
15291570
15301571 //if (Globals.ADVANCED)
15311572 objectPanel.add(infoPanel);
1532
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1573
+ objectPanel.setIconAt(3, GetIcon("icons/info.png"));
1574
+ objectPanel.setToolTipTextAt(3, "Information");
15331575
15341576 objectPanel.add(XYZPanel);
1535
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1577
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1578
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15361579
1537
- objectPanel.add(toolboxPanel);
1538
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1539
-
15401580 /*
15411581 aConstraints.gridx = 0;
15421582 aConstraints.gridwidth = 1;
....@@ -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,384 @@
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
+
1744
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1745
+ skin.setToolTipText("Skin");
1746
+ skin.addMouseListener(new MouseAdapter()
1747
+ {
1748
+ public void mouseClicked(MouseEvent e)
1749
+ {
1750
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1751
+ cMaterial material = object.material;
1752
+
1753
+ // Skin
1754
+ colorField.setFloat(material.color);
1755
+ saturationField.setFloat(material.modulation);
1756
+ subsurfaceField.setFloat(material.subsurface);
1757
+ selfshadowField.setFloat(material.diffuseness);
1758
+ diffusenessField.setFloat(material.factor);
1759
+ shininessField.setFloat(material.shininess);
1760
+ shadowbiasField.setFloat(material.shadowbias);
1761
+ diffuseField.setFloat(material.diffuse);
1762
+ specularField.setFloat(material.specular);
1763
+
1764
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1765
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1766
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1767
+
1768
+ materialtouched = true;
1769
+ applySelf();
1770
+ }
1771
+ });
1772
+ presetpanel.add(skin);
1773
+
1774
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1775
+ lambert.setToolTipText("Diffuse");
1776
+ lambert.addMouseListener(new MouseAdapter()
1777
+ {
1778
+ public void mouseClicked(MouseEvent e)
1779
+ {
1780
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1781
+ cMaterial material = object.material;
1782
+
1783
+ diffusenessField.setFloat(material.factor);
1784
+ selfshadowField.setFloat(material.diffuseness);
1785
+
1786
+ materialtouched = true;
1787
+ applySelf();
1788
+ }
1789
+ });
1790
+ presetpanel.add(lambert);
1791
+
1792
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1793
+ diffuse2.setToolTipText("Diffuse2");
1794
+ diffuse2.addMouseListener(new MouseAdapter()
1795
+ {
1796
+ public void mouseClicked(MouseEvent e)
1797
+ {
1798
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1799
+ cMaterial material = object.material;
1800
+
1801
+ diffusenessField.setFloat(material.factor);
1802
+ selfshadowField.setFloat(material.diffuseness);
1803
+
1804
+ materialtouched = true;
1805
+ applySelf();
1806
+ }
1807
+ });
1808
+ presetpanel.add(diffuse2);
1809
+
1810
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1811
+ diffusemoon.setToolTipText("Moon");
1812
+ diffusemoon.addMouseListener(new MouseAdapter()
1813
+ {
1814
+ public void mouseClicked(MouseEvent e)
1815
+ {
1816
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1817
+ cMaterial material = object.material;
1818
+
1819
+ diffusenessField.setFloat(material.factor);
1820
+ selfshadowField.setFloat(material.diffuseness);
1821
+
1822
+ materialtouched = true;
1823
+ applySelf();
1824
+ }
1825
+ });
1826
+ presetpanel.add(diffusemoon);
1827
+
1828
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1829
+ diffusemoon2.setToolTipText("Moon2");
1830
+ diffusemoon2.addMouseListener(new MouseAdapter()
1831
+ {
1832
+ public void mouseClicked(MouseEvent e)
1833
+ {
1834
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1835
+ cMaterial material = object.material;
1836
+
1837
+ diffusenessField.setFloat(material.factor);
1838
+ selfshadowField.setFloat(material.diffuseness);
1839
+
1840
+ materialtouched = true;
1841
+ applySelf();
1842
+ }
1843
+ });
1844
+ presetpanel.add(diffusemoon2);
1845
+
1846
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1847
+ diffusemoon3.setToolTipText("Moon3");
1848
+ diffusemoon3.addMouseListener(new MouseAdapter()
1849
+ {
1850
+ public void mouseClicked(MouseEvent e)
1851
+ {
1852
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1853
+ cMaterial material = object.material;
1854
+
1855
+ diffusenessField.setFloat(material.factor);
1856
+ selfshadowField.setFloat(material.diffuseness);
1857
+
1858
+ materialtouched = true;
1859
+ applySelf();
1860
+ }
1861
+ });
1862
+ presetpanel.add(diffusemoon3);
1863
+
1864
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1865
+ diffusesheen.setToolTipText("Sheen");
1866
+ diffusesheen.addMouseListener(new MouseAdapter()
1867
+ {
1868
+ public void mouseClicked(MouseEvent e)
1869
+ {
1870
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1871
+ cMaterial material = object.material;
1872
+
1873
+ sheenField.setFloat(material.sheen);
1874
+
1875
+ materialtouched = true;
1876
+ applySelf();
1877
+ }
1878
+ });
1879
+ presetpanel.add(diffusesheen);
1880
+
1881
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1882
+ rough.setToolTipText("Rough metal");
1883
+ rough.addMouseListener(new MouseAdapter()
1884
+ {
1885
+ public void mouseClicked(MouseEvent e)
1886
+ {
1887
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1888
+ cMaterial material = object.material;
1889
+
1890
+ shininessField.setFloat(material.shininess);
1891
+ velvetField.setFloat(material.velvet);
1892
+
1893
+ materialtouched = true;
1894
+ applySelf();
1895
+ }
1896
+ });
1897
+ presetpanel.add(rough);
1898
+
1899
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1900
+ rough2.setToolTipText("Medium metal");
1901
+ rough2.addMouseListener(new MouseAdapter()
1902
+ {
1903
+ public void mouseClicked(MouseEvent e)
1904
+ {
1905
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1906
+ cMaterial material = object.material;
1907
+
1908
+ shininessField.setFloat(material.shininess);
1909
+ lightareaField.setFloat(material.lightarea);
1910
+
1911
+ materialtouched = true;
1912
+ applySelf();
1913
+ }
1914
+ });
1915
+ presetpanel.add(rough2);
1916
+
1917
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1918
+ shini0.setToolTipText("Shiny");
1919
+ shini0.addMouseListener(new MouseAdapter()
1920
+ {
1921
+ public void mouseClicked(MouseEvent e)
1922
+ {
1923
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1924
+ cMaterial material = object.material;
1925
+
1926
+ shininessField.setFloat(material.shininess);
1927
+ lightareaField.setFloat(material.lightarea);
1928
+
1929
+ materialtouched = true;
1930
+ applySelf();
1931
+ }
1932
+ });
1933
+ presetpanel.add(shini0);
1934
+
1935
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1936
+ shini1.setToolTipText("Shiny2");
1937
+ shini1.addMouseListener(new MouseAdapter()
1938
+ {
1939
+ public void mouseClicked(MouseEvent e)
1940
+ {
1941
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1942
+ cMaterial material = object.material;
1943
+
1944
+ shininessField.setFloat(material.shininess);
1945
+ lightareaField.setFloat(material.lightarea);
1946
+
1947
+ materialtouched = true;
1948
+ applySelf();
1949
+ }
1950
+ });
1951
+ presetpanel.add(shini1);
1952
+
1953
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
1954
+ shini2.setToolTipText("Shiny3");
1955
+ shini2.addMouseListener(new MouseAdapter()
1956
+ {
1957
+ public void mouseClicked(MouseEvent e)
1958
+ {
1959
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
1960
+ cMaterial material = object.material;
1961
+
1962
+ shininessField.setFloat(material.shininess);
1963
+ lightareaField.setFloat(material.lightarea);
1964
+
1965
+ materialtouched = true;
1966
+ applySelf();
1967
+ }
1968
+ });
1969
+ presetpanel.add(shini2);
1970
+
1971
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
1972
+ aniso.setToolTipText("AnisoU");
1973
+ aniso.addMouseListener(new MouseAdapter()
1974
+ {
1975
+ public void mouseClicked(MouseEvent e)
1976
+ {
1977
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
1978
+ cMaterial material = object.material;
1979
+
1980
+ anisoField.setFloat(material.aniso);
1981
+ anisoVField.setFloat(material.anisoV);
1982
+
1983
+ materialtouched = true;
1984
+ applySelf();
1985
+ }
1986
+ });
1987
+ presetpanel.add(aniso);
1988
+
1989
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
1990
+ aniso2.setToolTipText("AnisoV");
1991
+ aniso2.addMouseListener(new MouseAdapter()
1992
+ {
1993
+ public void mouseClicked(MouseEvent e)
1994
+ {
1995
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
1996
+ cMaterial material = object.material;
1997
+
1998
+ anisoField.setFloat(material.aniso);
1999
+ anisoVField.setFloat(material.anisoV);
2000
+
2001
+ materialtouched = true;
2002
+ applySelf();
2003
+ }
2004
+ });
2005
+ presetpanel.add(aniso2);
2006
+
2007
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2008
+ aniso3.setToolTipText("AnisoUV");
2009
+ aniso3.addMouseListener(new MouseAdapter()
2010
+ {
2011
+ public void mouseClicked(MouseEvent e)
2012
+ {
2013
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2014
+ cMaterial material = object.material;
2015
+
2016
+ anisoField.setFloat(material.aniso);
2017
+ anisoVField.setFloat(material.anisoV);
2018
+
2019
+ materialtouched = true;
2020
+ applySelf();
2021
+ }
2022
+ });
2023
+ presetpanel.add(aniso3);
2024
+
2025
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2026
+ velvet0.setToolTipText("Velvet");
2027
+ velvet0.addMouseListener(new MouseAdapter()
2028
+ {
2029
+ public void mouseClicked(MouseEvent e)
2030
+ {
2031
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2032
+ cMaterial material = object.material;
2033
+
2034
+ diffusenessField.setFloat(material.factor);
2035
+ selfshadowField.setFloat(material.diffuseness);
2036
+ sheenField.setFloat(material.sheen);
2037
+ shininessField.setFloat(material.shininess);
2038
+ velvetField.setFloat(material.velvet);
2039
+ shiftField.setFloat(material.shift);
2040
+
2041
+ materialtouched = true;
2042
+ applySelf();
2043
+ }
2044
+ });
2045
+ presetpanel.add(velvet0);
2046
+
2047
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2048
+ bump0.setToolTipText("Bump texture");
2049
+ bump0.addMouseListener(new MouseAdapter()
2050
+ {
2051
+ public void mouseClicked(MouseEvent e)
2052
+ {
2053
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2054
+ cMaterial material = object.material;
2055
+
2056
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2057
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2058
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(bump0);
2065
+
2066
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2067
+ halo.setToolTipText("Halo");
2068
+ halo.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2076
+
2077
+ materialtouched = true;
2078
+ applySelf();
2079
+ }
2080
+ });
2081
+ presetpanel.add(halo);
2082
+
2083
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2084
+ candle.setToolTipText("Candle");
2085
+ candle.addMouseListener(new MouseAdapter()
2086
+ {
2087
+ public void mouseClicked(MouseEvent e)
2088
+ {
2089
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2090
+ cMaterial material = object.material;
2091
+
2092
+ subsurfaceField.setFloat(material.subsurface);
2093
+ shadowbiasField.setFloat(material.shadowbias);
2094
+ ambientField.setFloat(material.ambient);
2095
+ specularField.setFloat(material.specular);
2096
+ lightareaField.setFloat(material.lightarea);
2097
+ shininessField.setFloat(material.shininess);
2098
+
2099
+ materialtouched = true;
2100
+ applySelf();
2101
+ }
2102
+ });
2103
+ presetpanel.add(candle);
2104
+
2105
+ cGridBag panel = new cGridBag().setVertical(true);
2106
+
2107
+ presetpanel.preferredWidth = 1;
2108
+
2109
+ materialpanel.add(presetpanel);
2110
+ materialpanel.add(panel);
2111
+
2112
+ panel.preferredWidth = 8;
2113
+
2114
+ /*
17042115 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17052116 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1706
- */
2117
+ */
17072118
17082119 cGridBag editBar = new cGridBag().setVertical(false);
17092120
....@@ -1737,27 +2148,50 @@
17372148 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17382149
17392150 cGridBag colorSection = new cGridBag().setVertical(true);
2151
+
2152
+ cGridBag huepanel = new cGridBag();
2153
+ cGridBag huelabel = new cGridBag();
2154
+ skin = GetLabel("icons/hue.png", false);
2155
+ skin.fit = true;
2156
+ huelabel.add(skin);
2157
+ huelabel.preferredWidth = 20;
2158
+ huepanel.add(new cGridBag()); // Label
2159
+ huepanel.add(huelabel); // Field/slider
2160
+
2161
+ huepanel.preferredHeight = 7;
2162
+
2163
+ colorSection.add(huepanel);
17402164
17412165 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);
2166
+
2167
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2168
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2169
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2170
+
17452171 //colorField.preferredWidth = 200;
17462172 colorSection.add(color);
17472173
17482174 cGridBag modulation = new cGridBag();
17492175 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17502176 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1751
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2177
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17522178 colorSection.add(modulation);
17532179
2180
+ cGridBag opacity = new cGridBag();
2181
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2182
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2183
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2184
+ colorSection.add(opacity);
2185
+
2186
+ colorSection.add(GetSeparator());
2187
+
17542188 cGridBag texture = new cGridBag();
17552189 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17562190 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17572191 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17582192 colorSection.add(texture);
17592193
1760
- panel.add(new JSeparator());
2194
+ panel.add(GetSeparator());
17612195
17622196 panel.add(colorSection);
17632197
....@@ -1813,7 +2247,7 @@
18132247 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18142248 diffuseSection.add(shadowbias);
18152249
1816
- panel.add(new JSeparator());
2250
+ panel.add(GetSeparator());
18172251
18182252 panel.add(diffuseSection);
18192253
....@@ -1876,7 +2310,7 @@
18762310 specularSection.add(anisoV);
18772311
18782312
1879
- panel.add(new JSeparator());
2313
+ panel.add(GetSeparator());
18802314
18812315 panel.add(specularSection);
18822316
....@@ -1901,12 +2335,6 @@
19012335 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19022336 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19032337 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);
19102338
19112339 //panel.add(new JSeparator());
19122340
....@@ -1952,7 +2380,7 @@
19522380 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19532381 textureSection.add(opacityPower);
19542382
1955
- panel.add(new JSeparator());
2383
+ panel.add(GetSeparator());
19562384
19572385 panel.add(textureSection);
19582386
....@@ -2939,7 +3367,7 @@
29393367
29403368 freezematerial = true;
29413369 colorField.setFloat(mat.color);
2942
- modulationField.setFloat(mat.modulation);
3370
+ saturationField.setFloat(mat.modulation);
29433371 metalnessField.setFloat(mat.metalness);
29443372 diffuseField.setFloat(mat.diffuse);
29453373 specularField.setFloat(mat.specular);
....@@ -3250,6 +3678,7 @@
32503678 } else if (event.getSource() == liveCB)
32513679 {
32523680 copy.live ^= true;
3681
+ objEditor.refreshContents(true); // To show item colors
32533682 return;
32543683 } else if (event.getSource() == selectableCB)
32553684 {
....@@ -3259,7 +3688,7 @@
32593688 {
32603689 copy.hide ^= true;
32613690 copy.Touch(); // display list issue
3262
- objEditor.refreshContents();
3691
+ objEditor.refreshContents(true); // To show item colors
32633692 return;
32643693 } else if (event.getSource() == link2masterCB)
32653694 {
....@@ -3515,6 +3944,7 @@
35153944
35163945 static public byte[] Compress(Object3D o)
35173946 {
3947
+ // Slower to actually compress.
35183948 try
35193949 {
35203950 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3616,6 +4046,7 @@
36164046 {
36174047 //Save(true);
36184048 Replace();
4049
+ SetUndoStates();
36194050 }
36204051
36214052 private boolean Equal(byte[] compress, byte[] name)
....@@ -3636,29 +4067,46 @@
36364067
36374068 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36384069
4070
+ void DeleteVersion()
4071
+ {
4072
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4073
+ {
4074
+ copy.versionlist[i] = copy.versionlist[i+1];
4075
+ }
4076
+
4077
+ CopyChanged();
4078
+
4079
+ SetUndoStates();
4080
+ }
4081
+
36394082 public boolean Save(boolean user)
36404083 {
36414084 System.err.println("Save");
4085
+ //Replace();
36424086
36434087 cRadio tab = GetCurrentTab();
36444088
3645
- byte[] compress = CompressCopy();
4089
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36464090
36474091 boolean thesame = false;
36484092
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
- }
4093
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4094
+// {
4095
+// thesame = true;
4096
+// }
36544097
36554098 //EditorFrame.m_MainFrame.requestFocusInWindow();
36564099 if (!thesame)
36574100 {
4101
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4102
+ {
4103
+ copy.versionlist[i] = copy.versionlist[i-1];
4104
+ }
4105
+
36584106 //tab.user[tab.versionindex] = user;
36594107 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36604108
3661
- copy.versions[++copy.versionindex] = compress;
4109
+ copy.versionlist[++copy.versionindex] = compress;
36624110
36634111 // if (increment)
36644112 // tab.versionindex++;
....@@ -3668,11 +4116,11 @@
36684116
36694117 //assert(hashtable.isEmpty());
36704118
3671
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3672
- {
3673
- //tab.user[i] = false;
3674
- copy.versions[i] = null;
3675
- }
4119
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4120
+// {
4121
+// //tab.user[i] = false;
4122
+// copy.versionlist[i] = null;
4123
+// }
36764124
36774125 SetUndoStates();
36784126
....@@ -3697,9 +4145,43 @@
36974145
36984146 return !thesame;
36994147 }
3700
-
3701
- void CopyChanged(Object3D obj)
4148
+
4149
+ boolean flashIt = true;
4150
+
4151
+ void RefreshSelection()
37024152 {
4153
+ Object3D selection = new Object3D();
4154
+
4155
+ for (int i = 0; i < copy.selection.size(); i++)
4156
+ {
4157
+ Object3D elem = copy.selection.elementAt(i);
4158
+
4159
+ Object3D obj = copy.GetObject(elem.GetUUID());
4160
+
4161
+ if (obj == null)
4162
+ {
4163
+ copy.selection.remove(i--);
4164
+ }
4165
+ else
4166
+ {
4167
+ selection.add(obj);
4168
+ copy.selection.setElementAt(obj, i);
4169
+ }
4170
+ }
4171
+
4172
+ flashIt = false;
4173
+ GetTree().clearSelection();
4174
+ for (int i = 0; i < selection.size(); i++)
4175
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4176
+ flashIt = true;
4177
+
4178
+ //refreshContents(false);
4179
+ }
4180
+
4181
+ void CopyChanged()
4182
+ {
4183
+ Object3D obj = copy.versionlist[copy.versionindex];
4184
+
37034185 SetUndoStates();
37044186
37054187 boolean temp = CameraPane.SWITCH;
....@@ -3709,6 +4191,9 @@
37094191
37104192 copy.clear();
37114193
4194
+ copy.skyboxname = obj.skyboxname;
4195
+ copy.skyboxext = obj.skyboxext;
4196
+
37124197 for (int i=0; i<obj.Size(); i++)
37134198 {
37144199 copy.add(obj.get(i));
....@@ -3718,6 +4203,7 @@
37184203
37194204 CameraPane.SWITCH = temp;
37204205
4206
+ RefreshSelection();
37214207 //assert(hashtable.isEmpty());
37224208
37234209 copy.Touch();
....@@ -3738,13 +4224,15 @@
37384224 }
37394225 }
37404226
3741
- refreshContents();
4227
+ refreshContents(true);
37424228 }
37434229
3744
- cButton undoButton;
4230
+ cButton previousVersionButton;
37454231 cButton restoreButton;
37464232 cButton replaceButton;
3747
- cButton redoButton;
4233
+ cButton nextVersionButton;
4234
+ cButton saveVersionButton;
4235
+ cButton deleteVersionButton;
37484236
37494237 boolean muteSlider;
37504238
....@@ -3752,9 +4240,9 @@
37524240 {
37534241 int count = 0;
37544242
3755
- for (int i = copy.versions.length; --i >= 0;)
4243
+ for (int i = copy.versionlist.length; --i >= 0;)
37564244 {
3757
- if (copy.versions[i] != null)
4245
+ if (copy.versionlist[i] != null)
37584246 count++;
37594247 }
37604248
....@@ -3765,11 +4253,14 @@
37654253 {
37664254 cRadio tab = GetCurrentTab();
37674255
3768
- restoreButton.setEnabled(copy.versionindex != -1);
3769
- replaceButton.setEnabled(copy.versionindex != -1);
4256
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
4257
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
37704258
3771
- undoButton.setEnabled(copy.versionindex > 0);
3772
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4259
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4260
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4261
+
4262
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4263
+ copy.versionlist[copy.versionindex + 1] != null);
37734264
37744265 muteSlider = true;
37754266 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3777,7 +4268,7 @@
37774268 muteSlider = false;
37784269 }
37794270
3780
- public boolean Undo()
4271
+ public boolean PreviousVersion()
37814272 {
37824273 // Option?
37834274 Replace();
....@@ -3807,7 +4298,7 @@
38074298
38084299 copy.versionindex -= 1;
38094300
3810
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4301
+ CopyChanged();
38114302
38124303 return true;
38134304 }
....@@ -3818,13 +4309,14 @@
38184309
38194310 cRadio tab = GetCurrentTab();
38204311
3821
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4312
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38224313 {
38234314 java.awt.Toolkit.getDefaultToolkit().beep();
38244315 return false;
38254316 }
38264317
3827
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4318
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4319
+ CopyChanged();
38284320
38294321 return true;
38304322 }
....@@ -3835,25 +4327,25 @@
38354327
38364328 cRadio tab = GetCurrentTab();
38374329
3838
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4330
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38394331 {
38404332 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38414333 return false;
38424334 }
38434335
3844
- copy.versions[copy.versionindex] = CompressCopy();
4336
+ copy.versionlist[copy.versionindex] = CompressCopy();
38454337
38464338 return true;
38474339 }
38484340
3849
- public void Redo()
4341
+ public void NextVersion()
38504342 {
38514343 // Option?
38524344 Replace();
38534345
38544346 cRadio tab = GetCurrentTab();
38554347
3856
- if (copy.versions[copy.versionindex + 1] == null)
4348
+ if (copy.versionlist[copy.versionindex + 1] == null)
38574349 {
38584350 java.awt.Toolkit.getDefaultToolkit().beep();
38594351 return;
....@@ -3861,7 +4353,7 @@
38614353
38624354 copy.versionindex += 1;
38634355
3864
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4356
+ CopyChanged();
38654357
38664358 //if (!tab.user[tab.versionindex])
38674359 // tab.graphs[tab.versionindex] = null;
....@@ -4075,7 +4567,7 @@
40754567 //copy.material = new cMaterial(copy.GetMaterial());
40764568
40774569 current.color = (float) colorField.getFloat();
4078
- current.modulation = (float) modulationField.getFloat();
4570
+ current.modulation = (float) saturationField.getFloat();
40794571 current.metalness = (float) metalnessField.getFloat();
40804572 current.diffuse = (float) diffuseField.getFloat();
40814573 current.specular = (float) specularField.getFloat();
....@@ -4108,7 +4600,7 @@
41084600 cMaterial mat = copy.material;
41094601
41104602 colorField.SetToolTipValue((mat.color));
4111
- modulationField.SetToolTipValue((mat.modulation));
4603
+ saturationField.SetToolTipValue((mat.modulation));
41124604 metalnessField.SetToolTipValue((mat.metalness));
41134605 diffuseField.SetToolTipValue((mat.diffuse));
41144606 specularField.SetToolTipValue((mat.specular));
....@@ -4172,9 +4664,10 @@
41724664
41734665 int version = versionSlider.getInteger();
41744666
4175
- if (copy.versions[version] != null)
4667
+ if (copy.versionlist[version] != null)
41764668 {
4177
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4669
+ copy.versionindex = version;
4670
+ CopyChanged();
41784671 }
41794672
41804673 return;
....@@ -4214,6 +4707,12 @@
42144707 {
42154708 //System.out.println("stateChanged = " + this);
42164709 materialtouched = true;
4710
+
4711
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4712
+ {
4713
+ saturationField.setFloat(1);
4714
+ }
4715
+
42174716 applySelf();
42184717 //System.out.println("this = " + this);
42194718 //System.out.println("PARENT = " + parent);
....@@ -4513,6 +5012,7 @@
45135012 {
45145013 if (GetTree() != null)
45155014 {
5015
+ GetTree().revalidate();
45165016 GetTree().repaint();
45175017 }
45185018
....@@ -4521,6 +5021,9 @@
45215021 ctrlPanel.validate(); // ? new
45225022 ctrlPanel.repaint();
45235023 }
5024
+
5025
+ if (previousVersionButton != null && copy.versionlist != null)
5026
+ SetUndoStates();
45245027 }
45255028
45265029 static TweenManager tweenManager = new TweenManager();
....@@ -4769,7 +5272,9 @@
47695272 readobj.ResetDisplayList();
47705273 } catch (Exception e)
47715274 {
4772
- //e.printStackTrace();
5275
+ if (!e.toString().contains("GZIP"))
5276
+ e.printStackTrace();
5277
+
47735278 try
47745279 {
47755280 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4849,6 +5354,8 @@
48495354 {
48505355 //readobj.deepCopySelf(copy);
48515356 copy.clear(); // june 2014
5357
+ copy.skyboxname = readobj.skyboxname;
5358
+ copy.skyboxext = readobj.skyboxext;
48525359 for (int i = 0; i < readobj.size(); i++)
48535360 {
48545361 Object3D child = readobj.get(i); // reserve(i);
....@@ -4889,6 +5396,7 @@
48895396 }
48905397 } catch (ClassCastException e)
48915398 {
5399
+ e.printStackTrace();
48925400 assert (false);
48935401 Composite c = (Composite) copy;
48945402 c.children.clear();
....@@ -4899,12 +5407,12 @@
48995407 c.addChild(csg);
49005408 }
49015409
4902
- copy.versions = readobj.versions;
5410
+ copy.versionlist = readobj.versionlist;
49035411 copy.versionindex = readobj.versionindex;
49045412
4905
- if (copy.versions == null)
5413
+ if (copy.versionlist == null)
49065414 {
4907
- copy.versions = new byte[100][];
5415
+ copy.versionlist = new Object3D[100];
49085416 copy.versionindex = -1;
49095417 }
49105418
....@@ -4920,7 +5428,7 @@
49205428 {
49215429 if (Grafreed.standAlone)
49225430 {
4923
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5431
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49245432 browser.show();
49255433 String filename = browser.getFile();
49265434 if (filename != null && filename.length() > 0)
....@@ -5019,6 +5527,7 @@
50195527 //ps.print(buffer.toString());
50205528 } catch (IOException e)
50215529 {
5530
+ e.printStackTrace();
50225531 }
50235532 }
50245533
....@@ -5311,7 +5820,7 @@
53115820 JLabel colorLabel;
53125821 cNumberSlider colorField;
53135822 JLabel modulationLabel;
5314
- cNumberSlider modulationField;
5823
+ cNumberSlider saturationField;
53155824 JLabel metalnessLabel;
53165825 cNumberSlider metalnessField;
53175826 JLabel diffuseLabel;