Normand Briere
2019-08-07 59de607850161a26863f92961d53caae7a2dabc8
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,11 +42,25 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
4453
4554 cButton GetButton(String name, boolean border)
4655 {
4756 ImageIcon icon = GetIcon(name);
4857 return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
4964 }
5065
5166 cToggleButton GetToggleButton(String name, boolean border)
....@@ -80,6 +95,20 @@
8095
8196 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
8297 return icon;
98
+ }
99
+ catch (Exception e)
100
+ {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ BufferedImage GetImage(String name)
106
+ {
107
+ try
108
+ {
109
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
110
+
111
+ return image;
83112 }
84113 catch (Exception e)
85114 {
....@@ -268,9 +297,9 @@
268297 client = inClient;
269298 copy = client;
270299
271
- if (copy.versions == null)
300
+ if (copy.versionlist == null)
272301 {
273
- copy.versions = new byte[100][];
302
+ copy.versionlist = new Object3D[100];
274303 copy.versionindex = -1;
275304 }
276305
....@@ -287,9 +316,9 @@
287316 client = inClient;
288317 copy = client;
289318
290
- if (copy.versions == null)
319
+ if (copy.versionlist == null)
291320 {
292
- copy.versions = new byte[100][];
321
+ copy.versionlist = new Object3D[100];
293322 copy.versionindex = -1;
294323 }
295324
....@@ -325,7 +354,7 @@
325354 copy = localCopy;
326355 copy.editWindow = this;
327356
328
- if (copy.versions == null)
357
+ if (copy.versionlist == null)
329358 {
330359 // copy.versions = new byte[100][];
331360 // copy.versionindex = -1;
....@@ -439,7 +468,9 @@
439468 toolboxPanel = new cGridBag().setVertical(true);
440469 //toolboxPanel.setName("Toolbox");
441470
442
- materialPanel = new cGridBag().setVertical(true);
471
+ skyboxPanel = new cGridBag().setVertical(true);
472
+
473
+ materialPanel = new cGridBag().setVertical(false);
443474 //materialPanel.setName("Material");
444475
445476 /*JTextPane*/
....@@ -820,9 +851,11 @@
820851 //frame.setVisible(true);
821852 }
822853 frame.validate();
854
+
855
+ cameraView.requestFocusInWindow();
823856 }
824857
825
- private byte[] CompressCopy()
858
+ private Object3D CompressCopy()
826859 {
827860 boolean temp = CameraPane.SWITCH;
828861 CameraPane.SWITCH = false;
....@@ -830,12 +863,13 @@
830863 copy.ExtractBigData(versiontable);
831864 // if (copy == client)
832865
833
- byte[] versions[] = copy.versions;
834
- copy.versions = null;
866
+ Object3D versions[] = copy.versionlist;
867
+ copy.versionlist = null;
835868
836
- byte[] compress = Compress(copy);
869
+ //byte[] compress = Compress(copy);
870
+ Object3D compress = (Object3D)Grafreed.clone(copy);
837871
838
- copy.versions = versions;
872
+ copy.versionlist = versions;
839873
840874 copy.RestoreBigData(versiontable);
841875
....@@ -965,6 +999,7 @@
965999 {
9661000 SetupMaterial(materialPanel);
9671001 }
1002
+
9681003 //SetupName();
9691004 //SetupViews();
9701005 }
....@@ -1173,6 +1208,18 @@
11731208
11741209 namePanel = new cGridBag();
11751210
1211
+ //if (copy.pinned)
1212
+ {
1213
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1214
+ pinButton.setSelected(copy.pinned);
1215
+ cGridBag t = new cGridBag();
1216
+ t.preferredWidth = 2;
1217
+ t.add(pinButton);
1218
+ namePanel.add(t);
1219
+
1220
+ pinButton.addItemListener(this);
1221
+ }
1222
+
11761223 nameField = AddText(namePanel, copy.GetName());
11771224 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11781225 oe.ctrlPanel.add(namePanel);
....@@ -1522,23 +1569,28 @@
15221569 //tmp.setName("Edit");
15231570 objectPanel.add(materialPanel);
15241571 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1572
+ objectPanel.setToolTipTextAt(0, "Material");
1573
+
1574
+ objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1577
+
1578
+ objectPanel.add(skyboxPanel);
1579
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1580
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1581
+
15251582 // JPanel north = new JPanel(new BorderLayout());
15261583 // north.setName("Edit");
15271584 // north.add(ctrlPanel, BorderLayout.NORTH);
15281585 // objectPanel.add(north);
15291586 objectPanel.add(editPanel);
1530
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1531
-
1532
- //if (Globals.ADVANCED)
1533
- objectPanel.add(infoPanel);
1534
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1587
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1588
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15351589
15361590 objectPanel.add(XYZPanel);
1537
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1591
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1592
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15381593
1539
- objectPanel.add(toolboxPanel);
1540
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1541
-
15421594 /*
15431595 aConstraints.gridx = 0;
15441596 aConstraints.gridwidth = 1;
....@@ -1575,6 +1627,11 @@
15751627
15761628 scenePanel.add(tabbedPane);
15771629
1630
+ //if (Globals.ADVANCED)
1631
+ tabbedPane.add(infoPanel);
1632
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1633
+ tabbedPane.setToolTipTextAt(3, "Information");
1634
+
15781635 /*
15791636 cTree jTree = new cTree(null);
15801637 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1634,8 +1691,8 @@
16341691 /**/
16351692
16361693 bigThree = new cGridBag();
1637
- bigThree.addComponent(centralPanel);
16381694 bigThree.addComponent(scenePanel);
1695
+ bigThree.addComponent(centralPanel);
16391696 //bigThree.addComponent(XYZPanel);
16401697
16411698 // // SIDE EFFECT!!!
....@@ -1677,7 +1734,6 @@
16771734 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16781735 frame.addWindowListener(new WindowAdapter()
16791736 {
1680
-
16811737 public void windowClosing(WindowEvent e)
16821738 {
16831739 Close();
....@@ -1700,12 +1756,384 @@
17001756 ctrlPanel.removeAll();
17011757 }
17021758
1703
- void SetupMaterial(cGridBag panel)
1759
+ void SetupMaterial(cGridBag materialpanel)
17041760 {
1705
- /*
1761
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1762
+
1763
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1764
+ skin.setToolTipText("Skin");
1765
+ skin.addMouseListener(new MouseAdapter()
1766
+ {
1767
+ public void mouseClicked(MouseEvent e)
1768
+ {
1769
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1770
+ cMaterial material = object.material;
1771
+
1772
+ // Skin
1773
+ colorField.setFloat(material.color);
1774
+ saturationField.setFloat(material.modulation);
1775
+ subsurfaceField.setFloat(material.subsurface);
1776
+ selfshadowField.setFloat(material.diffuseness);
1777
+ diffusenessField.setFloat(material.factor);
1778
+ shininessField.setFloat(material.shininess);
1779
+ shadowbiasField.setFloat(material.shadowbias);
1780
+ diffuseField.setFloat(material.diffuse);
1781
+ specularField.setFloat(material.specular);
1782
+
1783
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1784
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1785
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1786
+
1787
+ materialtouched = true;
1788
+ applySelf();
1789
+ }
1790
+ });
1791
+ presetpanel.add(skin);
1792
+
1793
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1794
+ lambert.setToolTipText("Diffuse");
1795
+ lambert.addMouseListener(new MouseAdapter()
1796
+ {
1797
+ public void mouseClicked(MouseEvent e)
1798
+ {
1799
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1800
+ cMaterial material = object.material;
1801
+
1802
+ diffusenessField.setFloat(material.factor);
1803
+ selfshadowField.setFloat(material.diffuseness);
1804
+
1805
+ materialtouched = true;
1806
+ applySelf();
1807
+ }
1808
+ });
1809
+ presetpanel.add(lambert);
1810
+
1811
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1812
+ diffuse2.setToolTipText("Diffuse2");
1813
+ diffuse2.addMouseListener(new MouseAdapter()
1814
+ {
1815
+ public void mouseClicked(MouseEvent e)
1816
+ {
1817
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1818
+ cMaterial material = object.material;
1819
+
1820
+ diffusenessField.setFloat(material.factor);
1821
+ selfshadowField.setFloat(material.diffuseness);
1822
+
1823
+ materialtouched = true;
1824
+ applySelf();
1825
+ }
1826
+ });
1827
+ presetpanel.add(diffuse2);
1828
+
1829
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1830
+ diffusemoon.setToolTipText("Moon");
1831
+ diffusemoon.addMouseListener(new MouseAdapter()
1832
+ {
1833
+ public void mouseClicked(MouseEvent e)
1834
+ {
1835
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1836
+ cMaterial material = object.material;
1837
+
1838
+ diffusenessField.setFloat(material.factor);
1839
+ selfshadowField.setFloat(material.diffuseness);
1840
+
1841
+ materialtouched = true;
1842
+ applySelf();
1843
+ }
1844
+ });
1845
+ presetpanel.add(diffusemoon);
1846
+
1847
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1848
+ diffusemoon2.setToolTipText("Moon2");
1849
+ diffusemoon2.addMouseListener(new MouseAdapter()
1850
+ {
1851
+ public void mouseClicked(MouseEvent e)
1852
+ {
1853
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1854
+ cMaterial material = object.material;
1855
+
1856
+ diffusenessField.setFloat(material.factor);
1857
+ selfshadowField.setFloat(material.diffuseness);
1858
+
1859
+ materialtouched = true;
1860
+ applySelf();
1861
+ }
1862
+ });
1863
+ presetpanel.add(diffusemoon2);
1864
+
1865
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1866
+ diffusemoon3.setToolTipText("Moon3");
1867
+ diffusemoon3.addMouseListener(new MouseAdapter()
1868
+ {
1869
+ public void mouseClicked(MouseEvent e)
1870
+ {
1871
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1872
+ cMaterial material = object.material;
1873
+
1874
+ diffusenessField.setFloat(material.factor);
1875
+ selfshadowField.setFloat(material.diffuseness);
1876
+
1877
+ materialtouched = true;
1878
+ applySelf();
1879
+ }
1880
+ });
1881
+ presetpanel.add(diffusemoon3);
1882
+
1883
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1884
+ diffusesheen.setToolTipText("Sheen");
1885
+ diffusesheen.addMouseListener(new MouseAdapter()
1886
+ {
1887
+ public void mouseClicked(MouseEvent e)
1888
+ {
1889
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1890
+ cMaterial material = object.material;
1891
+
1892
+ sheenField.setFloat(material.sheen);
1893
+
1894
+ materialtouched = true;
1895
+ applySelf();
1896
+ }
1897
+ });
1898
+ presetpanel.add(diffusesheen);
1899
+
1900
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1901
+ rough.setToolTipText("Rough metal");
1902
+ rough.addMouseListener(new MouseAdapter()
1903
+ {
1904
+ public void mouseClicked(MouseEvent e)
1905
+ {
1906
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1907
+ cMaterial material = object.material;
1908
+
1909
+ shininessField.setFloat(material.shininess);
1910
+ velvetField.setFloat(material.velvet);
1911
+
1912
+ materialtouched = true;
1913
+ applySelf();
1914
+ }
1915
+ });
1916
+ presetpanel.add(rough);
1917
+
1918
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1919
+ rough2.setToolTipText("Medium metal");
1920
+ rough2.addMouseListener(new MouseAdapter()
1921
+ {
1922
+ public void mouseClicked(MouseEvent e)
1923
+ {
1924
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1925
+ cMaterial material = object.material;
1926
+
1927
+ shininessField.setFloat(material.shininess);
1928
+ lightareaField.setFloat(material.lightarea);
1929
+
1930
+ materialtouched = true;
1931
+ applySelf();
1932
+ }
1933
+ });
1934
+ presetpanel.add(rough2);
1935
+
1936
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1937
+ shini0.setToolTipText("Shiny");
1938
+ shini0.addMouseListener(new MouseAdapter()
1939
+ {
1940
+ public void mouseClicked(MouseEvent e)
1941
+ {
1942
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1943
+ cMaterial material = object.material;
1944
+
1945
+ shininessField.setFloat(material.shininess);
1946
+ lightareaField.setFloat(material.lightarea);
1947
+
1948
+ materialtouched = true;
1949
+ applySelf();
1950
+ }
1951
+ });
1952
+ presetpanel.add(shini0);
1953
+
1954
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1955
+ shini1.setToolTipText("Shiny2");
1956
+ shini1.addMouseListener(new MouseAdapter()
1957
+ {
1958
+ public void mouseClicked(MouseEvent e)
1959
+ {
1960
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1961
+ cMaterial material = object.material;
1962
+
1963
+ shininessField.setFloat(material.shininess);
1964
+ lightareaField.setFloat(material.lightarea);
1965
+
1966
+ materialtouched = true;
1967
+ applySelf();
1968
+ }
1969
+ });
1970
+ presetpanel.add(shini1);
1971
+
1972
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
1973
+ shini2.setToolTipText("Shiny3");
1974
+ shini2.addMouseListener(new MouseAdapter()
1975
+ {
1976
+ public void mouseClicked(MouseEvent e)
1977
+ {
1978
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
1979
+ cMaterial material = object.material;
1980
+
1981
+ shininessField.setFloat(material.shininess);
1982
+ lightareaField.setFloat(material.lightarea);
1983
+
1984
+ materialtouched = true;
1985
+ applySelf();
1986
+ }
1987
+ });
1988
+ presetpanel.add(shini2);
1989
+
1990
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
1991
+ aniso.setToolTipText("AnisoU");
1992
+ aniso.addMouseListener(new MouseAdapter()
1993
+ {
1994
+ public void mouseClicked(MouseEvent e)
1995
+ {
1996
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
1997
+ cMaterial material = object.material;
1998
+
1999
+ anisoField.setFloat(material.aniso);
2000
+ anisoVField.setFloat(material.anisoV);
2001
+
2002
+ materialtouched = true;
2003
+ applySelf();
2004
+ }
2005
+ });
2006
+ presetpanel.add(aniso);
2007
+
2008
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2009
+ aniso2.setToolTipText("AnisoV");
2010
+ aniso2.addMouseListener(new MouseAdapter()
2011
+ {
2012
+ public void mouseClicked(MouseEvent e)
2013
+ {
2014
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2015
+ cMaterial material = object.material;
2016
+
2017
+ anisoField.setFloat(material.aniso);
2018
+ anisoVField.setFloat(material.anisoV);
2019
+
2020
+ materialtouched = true;
2021
+ applySelf();
2022
+ }
2023
+ });
2024
+ presetpanel.add(aniso2);
2025
+
2026
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2027
+ aniso3.setToolTipText("AnisoUV");
2028
+ aniso3.addMouseListener(new MouseAdapter()
2029
+ {
2030
+ public void mouseClicked(MouseEvent e)
2031
+ {
2032
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2033
+ cMaterial material = object.material;
2034
+
2035
+ anisoField.setFloat(material.aniso);
2036
+ anisoVField.setFloat(material.anisoV);
2037
+
2038
+ materialtouched = true;
2039
+ applySelf();
2040
+ }
2041
+ });
2042
+ presetpanel.add(aniso3);
2043
+
2044
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2045
+ velvet0.setToolTipText("Velvet");
2046
+ velvet0.addMouseListener(new MouseAdapter()
2047
+ {
2048
+ public void mouseClicked(MouseEvent e)
2049
+ {
2050
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2051
+ cMaterial material = object.material;
2052
+
2053
+ diffusenessField.setFloat(material.factor);
2054
+ selfshadowField.setFloat(material.diffuseness);
2055
+ sheenField.setFloat(material.sheen);
2056
+ shininessField.setFloat(material.shininess);
2057
+ velvetField.setFloat(material.velvet);
2058
+ shiftField.setFloat(material.shift);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(velvet0);
2065
+
2066
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2067
+ bump0.setToolTipText("Bump texture");
2068
+ bump0.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2076
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2077
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2078
+
2079
+ materialtouched = true;
2080
+ applySelf();
2081
+ }
2082
+ });
2083
+ presetpanel.add(bump0);
2084
+
2085
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2086
+ halo.setToolTipText("Halo");
2087
+ halo.addMouseListener(new MouseAdapter()
2088
+ {
2089
+ public void mouseClicked(MouseEvent e)
2090
+ {
2091
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2092
+ cMaterial material = object.material;
2093
+
2094
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2095
+
2096
+ materialtouched = true;
2097
+ applySelf();
2098
+ }
2099
+ });
2100
+ presetpanel.add(halo);
2101
+
2102
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2103
+ candle.setToolTipText("Candle");
2104
+ candle.addMouseListener(new MouseAdapter()
2105
+ {
2106
+ public void mouseClicked(MouseEvent e)
2107
+ {
2108
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2109
+ cMaterial material = object.material;
2110
+
2111
+ subsurfaceField.setFloat(material.subsurface);
2112
+ shadowbiasField.setFloat(material.shadowbias);
2113
+ ambientField.setFloat(material.ambient);
2114
+ specularField.setFloat(material.specular);
2115
+ lightareaField.setFloat(material.lightarea);
2116
+ shininessField.setFloat(material.shininess);
2117
+
2118
+ materialtouched = true;
2119
+ applySelf();
2120
+ }
2121
+ });
2122
+ presetpanel.add(candle);
2123
+
2124
+ cGridBag panel = new cGridBag().setVertical(true);
2125
+
2126
+ presetpanel.preferredWidth = 1;
2127
+
2128
+ materialpanel.add(presetpanel);
2129
+ materialpanel.add(panel);
2130
+
2131
+ panel.preferredWidth = 8;
2132
+
2133
+ /*
17062134 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17072135 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1708
- */
2136
+ */
17092137
17102138 cGridBag editBar = new cGridBag().setVertical(false);
17112139
....@@ -1739,27 +2167,50 @@
17392167 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17402168
17412169 cGridBag colorSection = new cGridBag().setVertical(true);
2170
+
2171
+ cGridBag huepanel = new cGridBag();
2172
+ cGridBag huelabel = new cGridBag();
2173
+ skin = GetLabel("icons/hue.png", false);
2174
+ skin.fit = true;
2175
+ huelabel.add(skin);
2176
+ huelabel.preferredWidth = 20;
2177
+ huepanel.add(new cGridBag()); // Label
2178
+ huepanel.add(huelabel); // Field/slider
2179
+
2180
+ huepanel.preferredHeight = 7;
2181
+
2182
+ colorSection.add(huepanel);
17422183
17432184 cGridBag color = new cGridBag();
1744
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1745
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1746
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2185
+
2186
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2187
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2188
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2189
+
17472190 //colorField.preferredWidth = 200;
17482191 colorSection.add(color);
17492192
17502193 cGridBag modulation = new cGridBag();
17512194 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17522195 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1753
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2196
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17542197 colorSection.add(modulation);
17552198
2199
+ cGridBag opacity = new cGridBag();
2200
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2201
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2202
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2203
+ colorSection.add(opacity);
2204
+
2205
+ colorSection.add(GetSeparator());
2206
+
17562207 cGridBag texture = new cGridBag();
17572208 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17582209 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17592210 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17602211 colorSection.add(texture);
17612212
1762
- panel.add(new JSeparator());
2213
+ panel.add(GetSeparator());
17632214
17642215 panel.add(colorSection);
17652216
....@@ -1815,7 +2266,7 @@
18152266 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18162267 diffuseSection.add(shadowbias);
18172268
1818
- panel.add(new JSeparator());
2269
+ panel.add(GetSeparator());
18192270
18202271 panel.add(diffuseSection);
18212272
....@@ -1878,7 +2329,7 @@
18782329 specularSection.add(anisoV);
18792330
18802331
1881
- panel.add(new JSeparator());
2332
+ panel.add(GetSeparator());
18822333
18832334 panel.add(specularSection);
18842335
....@@ -1903,12 +2354,6 @@
19032354 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19042355 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19052356 colorSection.add(backlit);
1906
-
1907
- cGridBag opacity = new cGridBag();
1908
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1909
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1910
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1911
- colorSection.add(opacity);
19122357
19132358 //panel.add(new JSeparator());
19142359
....@@ -1954,7 +2399,7 @@
19542399 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19552400 textureSection.add(opacityPower);
19562401
1957
- panel.add(new JSeparator());
2402
+ panel.add(GetSeparator());
19582403
19592404 panel.add(textureSection);
19602405
....@@ -2941,7 +3386,7 @@
29413386
29423387 freezematerial = true;
29433388 colorField.setFloat(mat.color);
2944
- modulationField.setFloat(mat.modulation);
3389
+ saturationField.setFloat(mat.modulation);
29453390 metalnessField.setFloat(mat.metalness);
29463391 diffuseField.setFloat(mat.diffuse);
29473392 specularField.setFloat(mat.specular);
....@@ -3148,6 +3593,17 @@
31483593 public void itemStateChanged(ItemEvent event)
31493594 {
31503595 // System.out.println("Propagate = " + propagate);
3596
+ if (event.getSource() == pinButton)
3597
+ {
3598
+ copy.pinned ^= true;
3599
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3600
+ {
3601
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3602
+ copy.CloseUI();
3603
+ //copy.editWindow.refreshContents();
3604
+ }
3605
+ }
3606
+ else
31513607 if (event.getSource() == propagateToggle)
31523608 {
31533609 propagate ^= true;
....@@ -3252,6 +3708,7 @@
32523708 } else if (event.getSource() == liveCB)
32533709 {
32543710 copy.live ^= true;
3711
+ objEditor.refreshContents(true); // To show item colors
32553712 return;
32563713 } else if (event.getSource() == selectableCB)
32573714 {
....@@ -3261,7 +3718,7 @@
32613718 {
32623719 copy.hide ^= true;
32633720 copy.Touch(); // display list issue
3264
- objEditor.refreshContents();
3721
+ objEditor.refreshContents(true); // To show item colors
32653722 return;
32663723 } else if (event.getSource() == link2masterCB)
32673724 {
....@@ -3517,6 +3974,7 @@
35173974
35183975 static public byte[] Compress(Object3D o)
35193976 {
3977
+ // Slower to actually compress.
35203978 try
35213979 {
35223980 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3618,6 +4076,7 @@
36184076 {
36194077 //Save(true);
36204078 Replace();
4079
+ SetUndoStates();
36214080 }
36224081
36234082 private boolean Equal(byte[] compress, byte[] name)
....@@ -3638,29 +4097,46 @@
36384097
36394098 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36404099
4100
+ void DeleteVersion()
4101
+ {
4102
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4103
+ {
4104
+ copy.versionlist[i] = copy.versionlist[i+1];
4105
+ }
4106
+
4107
+ CopyChanged();
4108
+
4109
+ SetUndoStates();
4110
+ }
4111
+
36414112 public boolean Save(boolean user)
36424113 {
36434114 System.err.println("Save");
4115
+ //Replace();
36444116
36454117 cRadio tab = GetCurrentTab();
36464118
3647
- byte[] compress = CompressCopy();
4119
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36484120
36494121 boolean thesame = false;
36504122
3651
- // Quick heuristic using length. Works only when stream is compressed.
3652
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3653
- {
3654
- thesame = true;
3655
- }
4123
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4124
+// {
4125
+// thesame = true;
4126
+// }
36564127
36574128 //EditorFrame.m_MainFrame.requestFocusInWindow();
36584129 if (!thesame)
36594130 {
4131
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4132
+ {
4133
+ copy.versionlist[i] = copy.versionlist[i-1];
4134
+ }
4135
+
36604136 //tab.user[tab.versionindex] = user;
36614137 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36624138
3663
- copy.versions[++copy.versionindex] = compress;
4139
+ copy.versionlist[++copy.versionindex] = compress;
36644140
36654141 // if (increment)
36664142 // tab.versionindex++;
....@@ -3670,11 +4146,11 @@
36704146
36714147 //assert(hashtable.isEmpty());
36724148
3673
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3674
- {
3675
- //tab.user[i] = false;
3676
- copy.versions[i] = null;
3677
- }
4149
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4150
+// {
4151
+// //tab.user[i] = false;
4152
+// copy.versionlist[i] = null;
4153
+// }
36784154
36794155 SetUndoStates();
36804156
....@@ -3699,9 +4175,43 @@
36994175
37004176 return !thesame;
37014177 }
3702
-
3703
- void CopyChanged(Object3D obj)
4178
+
4179
+ boolean flashIt = true;
4180
+
4181
+ void RefreshSelection()
37044182 {
4183
+ Object3D selection = new Object3D();
4184
+
4185
+ for (int i = 0; i < copy.selection.size(); i++)
4186
+ {
4187
+ Object3D elem = copy.selection.elementAt(i);
4188
+
4189
+ Object3D obj = copy.GetObject(elem.GetUUID());
4190
+
4191
+ if (obj == null)
4192
+ {
4193
+ copy.selection.remove(i--);
4194
+ }
4195
+ else
4196
+ {
4197
+ selection.add(obj);
4198
+ copy.selection.setElementAt(obj, i);
4199
+ }
4200
+ }
4201
+
4202
+ flashIt = false;
4203
+ GetTree().clearSelection();
4204
+ for (int i = 0; i < selection.size(); i++)
4205
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4206
+ flashIt = true;
4207
+
4208
+ //refreshContents(false);
4209
+ }
4210
+
4211
+ void CopyChanged()
4212
+ {
4213
+ Object3D obj = copy.versionlist[copy.versionindex];
4214
+
37054215 SetUndoStates();
37064216
37074217 boolean temp = CameraPane.SWITCH;
....@@ -3711,6 +4221,9 @@
37114221
37124222 copy.clear();
37134223
4224
+ copy.skyboxname = obj.skyboxname;
4225
+ copy.skyboxext = obj.skyboxext;
4226
+
37144227 for (int i=0; i<obj.Size(); i++)
37154228 {
37164229 copy.add(obj.get(i));
....@@ -3720,6 +4233,7 @@
37204233
37214234 CameraPane.SWITCH = temp;
37224235
4236
+ RefreshSelection();
37234237 //assert(hashtable.isEmpty());
37244238
37254239 copy.Touch();
....@@ -3740,13 +4254,15 @@
37404254 }
37414255 }
37424256
3743
- refreshContents();
4257
+ refreshContents(true);
37444258 }
37454259
3746
- cButton undoButton;
4260
+ cButton previousVersionButton;
37474261 cButton restoreButton;
37484262 cButton replaceButton;
3749
- cButton redoButton;
4263
+ cButton nextVersionButton;
4264
+ cButton saveVersionButton;
4265
+ cButton deleteVersionButton;
37504266
37514267 boolean muteSlider;
37524268
....@@ -3754,9 +4270,9 @@
37544270 {
37554271 int count = 0;
37564272
3757
- for (int i = copy.versions.length; --i >= 0;)
4273
+ for (int i = copy.versionlist.length; --i >= 0;)
37584274 {
3759
- if (copy.versions[i] != null)
4275
+ if (copy.versionlist[i] != null)
37604276 count++;
37614277 }
37624278
....@@ -3767,11 +4283,14 @@
37674283 {
37684284 cRadio tab = GetCurrentTab();
37694285
3770
- restoreButton.setEnabled(copy.versionindex != -1);
3771
- replaceButton.setEnabled(copy.versionindex != -1);
4286
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
4287
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
37724288
3773
- undoButton.setEnabled(copy.versionindex > 0);
3774
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4289
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4290
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4291
+
4292
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4293
+ copy.versionlist[copy.versionindex + 1] != null);
37754294
37764295 muteSlider = true;
37774296 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3779,7 +4298,7 @@
37794298 muteSlider = false;
37804299 }
37814300
3782
- public boolean Undo()
4301
+ public boolean PreviousVersion()
37834302 {
37844303 // Option?
37854304 Replace();
....@@ -3809,7 +4328,7 @@
38094328
38104329 copy.versionindex -= 1;
38114330
3812
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4331
+ CopyChanged();
38134332
38144333 return true;
38154334 }
....@@ -3820,13 +4339,14 @@
38204339
38214340 cRadio tab = GetCurrentTab();
38224341
3823
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4342
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38244343 {
38254344 java.awt.Toolkit.getDefaultToolkit().beep();
38264345 return false;
38274346 }
38284347
3829
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4348
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4349
+ CopyChanged();
38304350
38314351 return true;
38324352 }
....@@ -3837,25 +4357,25 @@
38374357
38384358 cRadio tab = GetCurrentTab();
38394359
3840
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4360
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38414361 {
38424362 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38434363 return false;
38444364 }
38454365
3846
- copy.versions[copy.versionindex] = CompressCopy();
4366
+ copy.versionlist[copy.versionindex] = CompressCopy();
38474367
38484368 return true;
38494369 }
38504370
3851
- public void Redo()
4371
+ public void NextVersion()
38524372 {
38534373 // Option?
38544374 Replace();
38554375
38564376 cRadio tab = GetCurrentTab();
38574377
3858
- if (copy.versions[copy.versionindex + 1] == null)
4378
+ if (copy.versionlist[copy.versionindex + 1] == null)
38594379 {
38604380 java.awt.Toolkit.getDefaultToolkit().beep();
38614381 return;
....@@ -3863,7 +4383,7 @@
38634383
38644384 copy.versionindex += 1;
38654385
3866
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4386
+ CopyChanged();
38674387
38684388 //if (!tab.user[tab.versionindex])
38694389 // tab.graphs[tab.versionindex] = null;
....@@ -4077,7 +4597,7 @@
40774597 //copy.material = new cMaterial(copy.GetMaterial());
40784598
40794599 current.color = (float) colorField.getFloat();
4080
- current.modulation = (float) modulationField.getFloat();
4600
+ current.modulation = (float) saturationField.getFloat();
40814601 current.metalness = (float) metalnessField.getFloat();
40824602 current.diffuse = (float) diffuseField.getFloat();
40834603 current.specular = (float) specularField.getFloat();
....@@ -4110,7 +4630,7 @@
41104630 cMaterial mat = copy.material;
41114631
41124632 colorField.SetToolTipValue((mat.color));
4113
- modulationField.SetToolTipValue((mat.modulation));
4633
+ saturationField.SetToolTipValue((mat.modulation));
41144634 metalnessField.SetToolTipValue((mat.metalness));
41154635 diffuseField.SetToolTipValue((mat.diffuse));
41164636 specularField.SetToolTipValue((mat.specular));
....@@ -4174,9 +4694,10 @@
41744694
41754695 int version = versionSlider.getInteger();
41764696
4177
- if (copy.versions[version] != null)
4697
+ if (copy.versionlist[version] != null)
41784698 {
4179
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4699
+ copy.versionindex = version;
4700
+ CopyChanged();
41804701 }
41814702
41824703 return;
....@@ -4216,6 +4737,12 @@
42164737 {
42174738 //System.out.println("stateChanged = " + this);
42184739 materialtouched = true;
4740
+
4741
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4742
+ {
4743
+ saturationField.setFloat(1);
4744
+ }
4745
+
42194746 applySelf();
42204747 //System.out.println("this = " + this);
42214748 //System.out.println("PARENT = " + parent);
....@@ -4515,6 +5042,7 @@
45155042 {
45165043 if (GetTree() != null)
45175044 {
5045
+ GetTree().revalidate();
45185046 GetTree().repaint();
45195047 }
45205048
....@@ -4523,6 +5051,9 @@
45235051 ctrlPanel.validate(); // ? new
45245052 ctrlPanel.repaint();
45255053 }
5054
+
5055
+ if (previousVersionButton != null && copy.versionlist != null)
5056
+ SetUndoStates();
45265057 }
45275058
45285059 static TweenManager tweenManager = new TweenManager();
....@@ -4906,12 +5437,12 @@
49065437 c.addChild(csg);
49075438 }
49085439
4909
- copy.versions = readobj.versions;
5440
+ copy.versionlist = readobj.versionlist;
49105441 copy.versionindex = readobj.versionindex;
49115442
4912
- if (copy.versions == null)
5443
+ if (copy.versionlist == null)
49135444 {
4914
- copy.versions = new byte[100][];
5445
+ copy.versionlist = new Object3D[100];
49155446 copy.versionindex = -1;
49165447 }
49175448
....@@ -4927,7 +5458,7 @@
49275458 {
49285459 if (Grafreed.standAlone)
49295460 {
4930
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5461
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49315462 browser.show();
49325463 String filename = browser.getFile();
49335464 if (filename != null && filename.length() > 0)
....@@ -5246,6 +5777,7 @@
52465777 ButtonGroup buttonGroup;
52475778
52485779 cGridBag toolboxPanel;
5780
+ cGridBag skyboxPanel;
52495781 cGridBag materialPanel;
52505782 cGridBag ctrlPanel;
52515783
....@@ -5319,7 +5851,7 @@
53195851 JLabel colorLabel;
53205852 cNumberSlider colorField;
53215853 JLabel modulationLabel;
5322
- cNumberSlider modulationField;
5854
+ cNumberSlider saturationField;
53235855 JLabel metalnessLabel;
53245856 cNumberSlider metalnessField;
53255857 JLabel diffuseLabel;