Normand Briere
2019-08-13 c67de8aca04d988179191ccb52461af00125920e
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -296,11 +297,13 @@
296297 client = inClient;
297298 copy = client;
298299
299
- if (copy.versions == null)
300
- {
301
- copy.versions = new byte[100][];
302
- copy.versionindex = -1;
303
- }
300
+// if (copy.versionlist == null)
301
+// {
302
+// copy.versionlist = new Object3D[100];
303
+// copy.versionindex = -1;
304
+//
305
+// callee.Save(true);
306
+// }
304307
305308 // "this" is not called: SetupUI2(objEditor);
306309 }
....@@ -315,10 +318,12 @@
315318 client = inClient;
316319 copy = client;
317320
318
- if (copy.versions == null)
321
+ if (copy.versionlist == null)
319322 {
320
- copy.versions = new byte[100][];
323
+ copy.versionlist = new Object3D[100];
321324 copy.versionindex = -1;
325
+
326
+// Save(true);
322327 }
323328
324329 SetupUI2(callee.GetEditor());
....@@ -353,11 +358,13 @@
353358 copy = localCopy;
354359 copy.editWindow = this;
355360
356
- if (copy.versions == null)
357
- {
358
-// copy.versions = new byte[100][];
361
+// if (copy.versionlist == null)
362
+// {
363
+// copy.versionlist = new Object3D[100];
359364 // copy.versionindex = -1;
360
- }
365
+//
366
+// Save(true);
367
+// }
361368
362369 SetupMenu();
363370
....@@ -426,6 +433,8 @@
426433
427434 ChangeListener changeListener = new ChangeListener()
428435 {
436
+ String name;
437
+
429438 public void stateChanged(ChangeEvent changeEvent)
430439 {
431440 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -444,7 +453,36 @@
444453 // EditSelection(false);
445454 // }
446455
447
- refreshContents(false); // To refresh Info tab
456
+ if (objectPanel.getSelectedIndex() == 4)
457
+ {
458
+ name = copy.skyboxname;
459
+
460
+ if (name == null)
461
+ {
462
+ name = "";
463
+ }
464
+
465
+ copy.skyboxname = "cubemaps/default-skyboxes/rgb";
466
+ copy.skyboxext = "jpg";
467
+ }
468
+ else
469
+ {
470
+ if (name != null)
471
+ {
472
+ if (name.equals(""))
473
+ {
474
+ copy.skyboxname = null;
475
+ copy.skyboxext = null;
476
+ }
477
+ else
478
+ {
479
+ copy.skyboxname = name;
480
+ }
481
+ }
482
+ }
483
+
484
+// refreshContents(false); // To refresh Info tab
485
+ cameraView.repaint();
448486 }
449487 };
450488 objectPanel.addChangeListener(changeListener);
....@@ -467,7 +505,9 @@
467505 toolboxPanel = new cGridBag().setVertical(true);
468506 //toolboxPanel.setName("Toolbox");
469507
470
- materialPanel = new cGridBag().setVertical(true);
508
+ skyboxPanel = new cGridBag().setVertical(true);
509
+
510
+ materialPanel = new cGridBag().setVertical(false);
471511 //materialPanel.setName("Material");
472512
473513 /*JTextPane*/
....@@ -751,6 +791,7 @@
751791 boolean maximized;
752792
753793 cButton fullscreenLayout;
794
+ cButton expandedLayout;
754795
755796 void Minimize()
756797 {
....@@ -790,10 +831,12 @@
790831 cButton minButton;
791832 cButton maxButton;
792833 cButton fullButton;
834
+ cButton collapseButton;
835
+ cButton maximize3DButton;
793836
794837 void ToggleFullScreen()
795838 {
796
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
839
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797840
798841 cameraView.ToggleFullScreen();
799842
....@@ -814,13 +857,13 @@
814857 // X frame.getContentPane().remove(/*"Center",*/bigThree);
815858 // X framePanel.add(bigThree);
816859 // X frame.getContentPane().add(/*"Center",*/framePanel);
817
- framePanel.setDividerLocation(46);
860
+// framePanel.setDividerLocation(46); // icons are 24x24
818861
819862 //frame.setVisible(true);
820
- radio.layout = keepButton;
863
+// radio.layout = keepButton;
821864 //theFrame = null;
822865 keepButton = null;
823
- radio.layout.doClick();
866
+// radio.layout.doClick();
824867
825868 } else
826869 {
....@@ -841,31 +884,42 @@
841884 // X frame.getContentPane().remove(/*"Center",*/framePanel);
842885 // X framePanel.remove(bigThree);
843886 // X frame.getContentPane().add(/*"Center",*/bigThree);
844
- framePanel.setDividerLocation(0);
887
+// framePanel.setDividerLocation(0);
845888
846
- radio.layout = fullscreenLayout;
847
- radio.layout.doClick();
889
+// radio.layout = fullscreenLayout;
890
+// radio.layout.doClick();
848891 //frame.setVisible(true);
849892 }
850893 frame.validate();
894
+
895
+ cameraView.requestFocusInWindow();
851896 }
852897
853
- private byte[] CompressCopy()
898
+ void CollapseToolbar()
899
+ {
900
+ framePanel.setDividerLocation(0);
901
+ //frame.validate();
902
+
903
+ cameraView.requestFocusInWindow();
904
+ }
905
+
906
+ private Object3D Duplicate(Object3D object)
854907 {
855908 boolean temp = CameraPane.SWITCH;
856909 CameraPane.SWITCH = false;
857910
858
- copy.ExtractBigData(versiontable);
911
+ object.ExtractBigData(versiontable);
859912 // if (copy == client)
860913
861
- byte[] versions[] = copy.versions;
862
- copy.versions = null;
914
+ Object3D versions[] = object.versionlist;
915
+ object.versionlist = null;
863916
864
- byte[] compress = Compress(copy);
917
+ //byte[] compress = Compress(copy);
918
+ Object3D compress = (Object3D)Grafreed.clone(object);
865919
866
- copy.versions = versions;
920
+ object.versionlist = versions;
867921
868
- copy.RestoreBigData(versiontable);
922
+ object.RestoreBigData(versiontable);
869923
870924 CameraPane.SWITCH = temp;
871925
....@@ -993,6 +1047,7 @@
9931047 {
9941048 SetupMaterial(materialPanel);
9951049 }
1050
+
9961051 //SetupName();
9971052 //SetupViews();
9981053 }
....@@ -1201,6 +1256,18 @@
12011256
12021257 namePanel = new cGridBag();
12031258
1259
+ //if (copy.pinned)
1260
+ {
1261
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1262
+ pinButton.setSelected(copy.pinned);
1263
+ cGridBag t = new cGridBag();
1264
+ t.preferredWidth = 2;
1265
+ t.add(pinButton);
1266
+ namePanel.add(t);
1267
+
1268
+ pinButton.addItemListener(this);
1269
+ }
1270
+
12041271 nameField = AddText(namePanel, copy.GetName());
12051272 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
12061273 oe.ctrlPanel.add(namePanel);
....@@ -1550,29 +1617,28 @@
15501617 //tmp.setName("Edit");
15511618 objectPanel.add(materialPanel);
15521619 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
- objectPanel.setToolTipTextAt(0, "Material panel");
1620
+ objectPanel.setToolTipTextAt(0, "Material");
15541621
1622
+ objectPanel.add(toolboxPanel);
1623
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1624
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1625
+
1626
+ objectPanel.add(skyboxPanel);
1627
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1628
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1629
+
15551630 // JPanel north = new JPanel(new BorderLayout());
15561631 // north.setName("Edit");
15571632 // north.add(ctrlPanel, BorderLayout.NORTH);
15581633 // objectPanel.add(north);
15591634 objectPanel.add(editPanel);
1560
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
- objectPanel.setToolTipTextAt(1, "Edit panel");
1562
-
1563
- //if (Globals.ADVANCED)
1564
- objectPanel.add(infoPanel);
1565
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
- objectPanel.setToolTipTextAt(2, "Info panel");
1635
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1636
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15671637
15681638 objectPanel.add(XYZPanel);
1569
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
- objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1639
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1640
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15711641
1572
- objectPanel.add(toolboxPanel);
1573
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
- objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
1575
-
15761642 /*
15771643 aConstraints.gridx = 0;
15781644 aConstraints.gridwidth = 1;
....@@ -1609,6 +1675,11 @@
16091675
16101676 scenePanel.add(tabbedPane);
16111677
1678
+ //if (Globals.ADVANCED)
1679
+ tabbedPane.add(infoPanel);
1680
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1681
+ tabbedPane.setToolTipTextAt(3, "Information");
1682
+
16121683 /*
16131684 cTree jTree = new cTree(null);
16141685 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1679,6 +1750,23 @@
16791750 // aConstraints.gridheight = 1;
16801751
16811752 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1753
+
1754
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1755
+ new java.beans.PropertyChangeListener()
1756
+ {
1757
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1758
+ {
1759
+ if ((Integer)pce.getOldValue() == 1)
1760
+ {
1761
+ if (radio.layout != expandedLayout)
1762
+ {
1763
+ radio.layout = expandedLayout;
1764
+ radio.layout.doClick();
1765
+ }
1766
+ }
1767
+ }
1768
+ });
1769
+
16821770 framePanel.setContinuousLayout(false);
16831771 framePanel.setOneTouchExpandable(false);
16841772 //.setDividerLocation(0.8);
....@@ -1733,12 +1821,403 @@
17331821 ctrlPanel.removeAll();
17341822 }
17351823
1736
- void SetupMaterial(cGridBag panel)
1824
+ void SetupMaterial(cGridBag materialpanel)
17371825 {
1738
- /*
1826
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1827
+
1828
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1829
+ skin.setToolTipText("Skin");
1830
+ skin.addMouseListener(new MouseAdapter()
1831
+ {
1832
+ public void mouseClicked(MouseEvent e)
1833
+ {
1834
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1835
+ cMaterial material = object.material;
1836
+
1837
+ // Skin
1838
+ colorField.setFloat(material.color);
1839
+ saturationField.setFloat(material.modulation);
1840
+ subsurfaceField.setFloat(material.subsurface);
1841
+ selfshadowField.setFloat(material.diffuseness);
1842
+ diffusenessField.setFloat(material.factor);
1843
+ shininessField.setFloat(material.shininess);
1844
+ shadowbiasField.setFloat(material.shadowbias);
1845
+ diffuseField.setFloat(material.diffuse);
1846
+ specularField.setFloat(material.specular);
1847
+
1848
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1849
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1850
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1851
+
1852
+ materialtouched = true;
1853
+ applySelf();
1854
+ }
1855
+ });
1856
+ presetpanel.add(skin);
1857
+
1858
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1859
+ lambert.setToolTipText("Diffuse");
1860
+ lambert.addMouseListener(new MouseAdapter()
1861
+ {
1862
+ public void mouseClicked(MouseEvent e)
1863
+ {
1864
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1865
+ cMaterial material = object.material;
1866
+
1867
+ diffusenessField.setFloat(material.factor);
1868
+ selfshadowField.setFloat(material.diffuseness);
1869
+
1870
+ materialtouched = true;
1871
+ applySelf();
1872
+ }
1873
+ });
1874
+ presetpanel.add(lambert);
1875
+
1876
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1877
+ diffuse2.setToolTipText("Diffuse2");
1878
+ diffuse2.addMouseListener(new MouseAdapter()
1879
+ {
1880
+ public void mouseClicked(MouseEvent e)
1881
+ {
1882
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1883
+ cMaterial material = object.material;
1884
+
1885
+ diffusenessField.setFloat(material.factor);
1886
+ selfshadowField.setFloat(material.diffuseness);
1887
+
1888
+ materialtouched = true;
1889
+ applySelf();
1890
+ }
1891
+ });
1892
+ presetpanel.add(diffuse2);
1893
+
1894
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1895
+ diffusemoon.setToolTipText("Moon");
1896
+ diffusemoon.addMouseListener(new MouseAdapter()
1897
+ {
1898
+ public void mouseClicked(MouseEvent e)
1899
+ {
1900
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1901
+ cMaterial material = object.material;
1902
+
1903
+ diffusenessField.setFloat(material.factor);
1904
+ selfshadowField.setFloat(material.diffuseness);
1905
+
1906
+ materialtouched = true;
1907
+ applySelf();
1908
+ }
1909
+ });
1910
+ presetpanel.add(diffusemoon);
1911
+
1912
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1913
+ diffusemoon2.setToolTipText("Moon2");
1914
+ diffusemoon2.addMouseListener(new MouseAdapter()
1915
+ {
1916
+ public void mouseClicked(MouseEvent e)
1917
+ {
1918
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1919
+ cMaterial material = object.material;
1920
+
1921
+ diffusenessField.setFloat(material.factor);
1922
+ selfshadowField.setFloat(material.diffuseness);
1923
+
1924
+ materialtouched = true;
1925
+ applySelf();
1926
+ }
1927
+ });
1928
+ presetpanel.add(diffusemoon2);
1929
+
1930
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1931
+ diffusemoon3.setToolTipText("Moon3");
1932
+ diffusemoon3.addMouseListener(new MouseAdapter()
1933
+ {
1934
+ public void mouseClicked(MouseEvent e)
1935
+ {
1936
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1937
+ cMaterial material = object.material;
1938
+
1939
+ diffusenessField.setFloat(material.factor);
1940
+ selfshadowField.setFloat(material.diffuseness);
1941
+
1942
+ materialtouched = true;
1943
+ applySelf();
1944
+ }
1945
+ });
1946
+ presetpanel.add(diffusemoon3);
1947
+
1948
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1949
+ diffusesheen.setToolTipText("Sheen");
1950
+ diffusesheen.addMouseListener(new MouseAdapter()
1951
+ {
1952
+ public void mouseClicked(MouseEvent e)
1953
+ {
1954
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1955
+ cMaterial material = object.material;
1956
+
1957
+ sheenField.setFloat(material.sheen);
1958
+
1959
+ materialtouched = true;
1960
+ applySelf();
1961
+ }
1962
+ });
1963
+ presetpanel.add(diffusesheen);
1964
+
1965
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1966
+ rough.setToolTipText("Rough metal");
1967
+ rough.addMouseListener(new MouseAdapter()
1968
+ {
1969
+ public void mouseClicked(MouseEvent e)
1970
+ {
1971
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1972
+ cMaterial material = object.material;
1973
+
1974
+ shininessField.setFloat(material.shininess);
1975
+ velvetField.setFloat(material.velvet);
1976
+
1977
+ materialtouched = true;
1978
+ applySelf();
1979
+ }
1980
+ });
1981
+ presetpanel.add(rough);
1982
+
1983
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1984
+ rough2.setToolTipText("Medium metal");
1985
+ rough2.addMouseListener(new MouseAdapter()
1986
+ {
1987
+ public void mouseClicked(MouseEvent e)
1988
+ {
1989
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1990
+ cMaterial material = object.material;
1991
+
1992
+ shininessField.setFloat(material.shininess);
1993
+ lightareaField.setFloat(material.lightarea);
1994
+
1995
+ materialtouched = true;
1996
+ applySelf();
1997
+ }
1998
+ });
1999
+ presetpanel.add(rough2);
2000
+
2001
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2002
+ shini0.setToolTipText("Shiny");
2003
+ shini0.addMouseListener(new MouseAdapter()
2004
+ {
2005
+ public void mouseClicked(MouseEvent e)
2006
+ {
2007
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2008
+ cMaterial material = object.material;
2009
+
2010
+ shininessField.setFloat(material.shininess);
2011
+ lightareaField.setFloat(material.lightarea);
2012
+
2013
+ materialtouched = true;
2014
+ applySelf();
2015
+ }
2016
+ });
2017
+ presetpanel.add(shini0);
2018
+
2019
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2020
+ shini1.setToolTipText("Shiny2");
2021
+ shini1.addMouseListener(new MouseAdapter()
2022
+ {
2023
+ public void mouseClicked(MouseEvent e)
2024
+ {
2025
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2026
+ cMaterial material = object.material;
2027
+
2028
+ shininessField.setFloat(material.shininess);
2029
+ lightareaField.setFloat(material.lightarea);
2030
+
2031
+ materialtouched = true;
2032
+ applySelf();
2033
+ }
2034
+ });
2035
+ presetpanel.add(shini1);
2036
+
2037
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2038
+ shini2.setToolTipText("Shiny3");
2039
+ shini2.addMouseListener(new MouseAdapter()
2040
+ {
2041
+ public void mouseClicked(MouseEvent e)
2042
+ {
2043
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2044
+ cMaterial material = object.material;
2045
+
2046
+ shininessField.setFloat(material.shininess);
2047
+ lightareaField.setFloat(material.lightarea);
2048
+
2049
+ materialtouched = true;
2050
+ applySelf();
2051
+ }
2052
+ });
2053
+ presetpanel.add(shini2);
2054
+
2055
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2056
+ aniso.setToolTipText("AnisoU");
2057
+ aniso.addMouseListener(new MouseAdapter()
2058
+ {
2059
+ public void mouseClicked(MouseEvent e)
2060
+ {
2061
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2062
+ cMaterial material = object.material;
2063
+
2064
+ anisoField.setFloat(material.aniso);
2065
+ anisoVField.setFloat(material.anisoV);
2066
+
2067
+ materialtouched = true;
2068
+ applySelf();
2069
+ }
2070
+ });
2071
+ presetpanel.add(aniso);
2072
+
2073
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2074
+ aniso2.setToolTipText("AnisoV");
2075
+ aniso2.addMouseListener(new MouseAdapter()
2076
+ {
2077
+ public void mouseClicked(MouseEvent e)
2078
+ {
2079
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2080
+ cMaterial material = object.material;
2081
+
2082
+ anisoField.setFloat(material.aniso);
2083
+ anisoVField.setFloat(material.anisoV);
2084
+
2085
+ materialtouched = true;
2086
+ applySelf();
2087
+ }
2088
+ });
2089
+ presetpanel.add(aniso2);
2090
+
2091
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2092
+ aniso3.setToolTipText("AnisoUV");
2093
+ aniso3.addMouseListener(new MouseAdapter()
2094
+ {
2095
+ public void mouseClicked(MouseEvent e)
2096
+ {
2097
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2098
+ cMaterial material = object.material;
2099
+
2100
+ anisoField.setFloat(material.aniso);
2101
+ anisoVField.setFloat(material.anisoV);
2102
+
2103
+ materialtouched = true;
2104
+ applySelf();
2105
+ }
2106
+ });
2107
+ presetpanel.add(aniso3);
2108
+
2109
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2110
+ velvet0.setToolTipText("Velvet");
2111
+ velvet0.addMouseListener(new MouseAdapter()
2112
+ {
2113
+ public void mouseClicked(MouseEvent e)
2114
+ {
2115
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2116
+ cMaterial material = object.material;
2117
+
2118
+ diffusenessField.setFloat(material.factor);
2119
+ selfshadowField.setFloat(material.diffuseness);
2120
+ sheenField.setFloat(material.sheen);
2121
+ shininessField.setFloat(material.shininess);
2122
+ velvetField.setFloat(material.velvet);
2123
+ shiftField.setFloat(material.shift);
2124
+
2125
+ materialtouched = true;
2126
+ applySelf();
2127
+ }
2128
+ });
2129
+ presetpanel.add(velvet0);
2130
+
2131
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2132
+ bump0.setToolTipText("Bump texture");
2133
+ bump0.addMouseListener(new MouseAdapter()
2134
+ {
2135
+ public void mouseClicked(MouseEvent e)
2136
+ {
2137
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2138
+ cMaterial material = object.material;
2139
+
2140
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2141
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2142
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2143
+
2144
+ materialtouched = true;
2145
+ applySelf();
2146
+ }
2147
+ });
2148
+ presetpanel.add(bump0);
2149
+
2150
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2151
+ halo.setToolTipText("Halo");
2152
+ halo.addMouseListener(new MouseAdapter()
2153
+ {
2154
+ public void mouseClicked(MouseEvent e)
2155
+ {
2156
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2157
+ cMaterial material = object.material;
2158
+
2159
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2160
+
2161
+ materialtouched = true;
2162
+ applySelf();
2163
+ }
2164
+ });
2165
+ presetpanel.add(halo);
2166
+
2167
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2168
+ candle.setToolTipText("Candle");
2169
+ candle.addMouseListener(new MouseAdapter()
2170
+ {
2171
+ public void mouseClicked(MouseEvent e)
2172
+ {
2173
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2174
+ cMaterial material = object.material;
2175
+
2176
+ subsurfaceField.setFloat(material.subsurface);
2177
+ shadowbiasField.setFloat(material.shadowbias);
2178
+ ambientField.setFloat(material.ambient);
2179
+ specularField.setFloat(material.specular);
2180
+ lightareaField.setFloat(material.lightarea);
2181
+ shininessField.setFloat(material.shininess);
2182
+
2183
+ materialtouched = true;
2184
+ applySelf();
2185
+ }
2186
+ });
2187
+ presetpanel.add(candle);
2188
+
2189
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2190
+ shadowShader.setToolTipText("Shadow");
2191
+ shadowShader.addMouseListener(new MouseAdapter()
2192
+ {
2193
+ public void mouseClicked(MouseEvent e)
2194
+ {
2195
+ diffuseField.setFloat(0.001);
2196
+ ambientField.setFloat(0.001);
2197
+ cameraField.setFloat(0.001);
2198
+ specularField.setFloat(0.001);
2199
+ fakedepthField.setFloat(0.001);
2200
+ opacityField.setFloat(0.6);
2201
+
2202
+ materialtouched = true;
2203
+ applySelf();
2204
+ }
2205
+ });
2206
+ presetpanel.add(shadowShader);
2207
+
2208
+ cGridBag panel = new cGridBag().setVertical(true);
2209
+
2210
+ presetpanel.preferredWidth = 1;
2211
+
2212
+ materialpanel.add(presetpanel);
2213
+ materialpanel.add(panel);
2214
+
2215
+ panel.preferredWidth = 8;
2216
+
2217
+ /*
17392218 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17402219 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1741
- */
2220
+ */
17422221
17432222 cGridBag editBar = new cGridBag().setVertical(false);
17442223
....@@ -1775,7 +2254,9 @@
17752254
17762255 cGridBag huepanel = new cGridBag();
17772256 cGridBag huelabel = new cGridBag();
1778
- huelabel.add(GetLabel("icons/hue.png", false));
2257
+ skin = GetLabel("icons/hue.png", false);
2258
+ skin.fit = true;
2259
+ huelabel.add(skin);
17792260 huelabel.preferredWidth = 20;
17802261 huepanel.add(new cGridBag()); // Label
17812262 huepanel.add(huelabel); // Field/slider
....@@ -1796,7 +2277,7 @@
17962277 cGridBag modulation = new cGridBag();
17972278 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17982279 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1799
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2280
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
18002281 colorSection.add(modulation);
18012282
18022283 cGridBag opacity = new cGridBag();
....@@ -2989,7 +3470,7 @@
29893470
29903471 freezematerial = true;
29913472 colorField.setFloat(mat.color);
2992
- modulationField.setFloat(mat.modulation);
3473
+ saturationField.setFloat(mat.modulation);
29933474 metalnessField.setFloat(mat.metalness);
29943475 diffuseField.setFloat(mat.diffuse);
29953476 specularField.setFloat(mat.specular);
....@@ -3196,6 +3677,17 @@
31963677 public void itemStateChanged(ItemEvent event)
31973678 {
31983679 // System.out.println("Propagate = " + propagate);
3680
+ if (event.getSource() == pinButton)
3681
+ {
3682
+ copy.pinned ^= true;
3683
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3684
+ {
3685
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3686
+ copy.CloseUI();
3687
+ //copy.editWindow.refreshContents();
3688
+ }
3689
+ }
3690
+ else
31993691 if (event.getSource() == propagateToggle)
32003692 {
32013693 propagate ^= true;
....@@ -3300,6 +3792,7 @@
33003792 } else if (event.getSource() == liveCB)
33013793 {
33023794 copy.live ^= true;
3795
+ objEditor.refreshContents(true); // To show item colors
33033796 return;
33043797 } else if (event.getSource() == selectableCB)
33053798 {
....@@ -3309,7 +3802,7 @@
33093802 {
33103803 copy.hide ^= true;
33113804 copy.Touch(); // display list issue
3312
- objEditor.refreshContents();
3805
+ objEditor.refreshContents(true); // To show item colors
33133806 return;
33143807 } else if (event.getSource() == link2masterCB)
33153808 {
....@@ -3565,6 +4058,7 @@
35654058
35664059 static public byte[] Compress(Object3D o)
35674060 {
4061
+ // Slower to actually compress.
35684062 try
35694063 {
35704064 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3666,6 +4160,7 @@
36664160 {
36674161 //Save(true);
36684162 Replace();
4163
+ SetVersionStates();
36694164 }
36704165
36714166 private boolean Equal(byte[] compress, byte[] name)
....@@ -3686,29 +4181,46 @@
36864181
36874182 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36884183
4184
+ void DeleteVersion()
4185
+ {
4186
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4187
+ {
4188
+ copy.versionlist[i] = copy.versionlist[i+1];
4189
+ }
4190
+
4191
+ CopyChanged();
4192
+
4193
+ SetVersionStates();
4194
+ }
4195
+
36894196 public boolean Save(boolean user)
36904197 {
36914198 System.err.println("Save");
4199
+ Replace();
36924200
3693
- cRadio tab = GetCurrentTab();
4201
+ //cRadio tab = GetCurrentTab();
36944202
3695
- byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
4203
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36964204
36974205 boolean thesame = false;
36984206
3699
- // Quick heuristic using length. Works only when stream is compressed.
3700
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3701
- {
3702
- thesame = true;
3703
- }
4207
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4208
+// {
4209
+// thesame = true;
4210
+// }
37044211
37054212 //EditorFrame.m_MainFrame.requestFocusInWindow();
37064213 if (!thesame)
37074214 {
4215
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4216
+ {
4217
+ copy.versionlist[i] = copy.versionlist[i-1];
4218
+ }
4219
+
37084220 //tab.user[tab.versionindex] = user;
37094221 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37104222
3711
- copy.versions[++copy.versionindex] = compress;
4223
+ copy.versionlist[++copy.versionindex] = compress;
37124224
37134225 // if (increment)
37144226 // tab.versionindex++;
....@@ -3718,13 +4230,13 @@
37184230
37194231 //assert(hashtable.isEmpty());
37204232
3721
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3722
- {
3723
- //tab.user[i] = false;
3724
- copy.versions[i] = null;
3725
- }
4233
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4234
+// {
4235
+// //tab.user[i] = false;
4236
+// copy.versionlist[i] = null;
4237
+// }
37264238
3727
- SetUndoStates();
4239
+ SetVersionStates();
37284240
37294241 // test save
37304242 if (false)
....@@ -3747,10 +4259,44 @@
37474259
37484260 return !thesame;
37494261 }
3750
-
3751
- void CopyChanged(Object3D obj)
4262
+
4263
+ boolean flashIt = true;
4264
+
4265
+ void RefreshSelection()
37524266 {
3753
- SetUndoStates();
4267
+ Object3D selection = new Object3D();
4268
+
4269
+ for (int i = 0; i < copy.selection.size(); i++)
4270
+ {
4271
+ Object3D elem = copy.selection.elementAt(i);
4272
+
4273
+ Object3D obj = copy.GetObject(elem.GetUUID());
4274
+
4275
+ if (obj == null)
4276
+ {
4277
+ copy.selection.remove(i--);
4278
+ }
4279
+ else
4280
+ {
4281
+ selection.add(obj);
4282
+ copy.selection.setElementAt(obj, i);
4283
+ }
4284
+ }
4285
+
4286
+ flashIt = false;
4287
+ GetTree().clearSelection();
4288
+ for (int i = 0; i < selection.size(); i++)
4289
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4290
+ flashIt = true;
4291
+
4292
+ //refreshContents(false);
4293
+ }
4294
+
4295
+ void CopyChanged()
4296
+ {
4297
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4298
+
4299
+ SetVersionStates();
37544300
37554301 boolean temp = CameraPane.SWITCH;
37564302 CameraPane.SWITCH = false;
....@@ -3771,6 +4317,7 @@
37714317
37724318 CameraPane.SWITCH = temp;
37734319
4320
+ RefreshSelection();
37744321 //assert(hashtable.isEmpty());
37754322
37764323 copy.Touch();
....@@ -3791,13 +4338,15 @@
37914338 }
37924339 }
37934340
3794
- refreshContents();
4341
+ refreshContents(true);
37954342 }
37964343
3797
- cButton undoButton;
4344
+ cButton previousVersionButton;
37984345 cButton restoreButton;
37994346 cButton replaceButton;
3800
- cButton redoButton;
4347
+ cButton nextVersionButton;
4348
+ cButton saveVersionButton;
4349
+ cButton deleteVersionButton;
38014350
38024351 boolean muteSlider;
38034352
....@@ -3805,39 +4354,47 @@
38054354 {
38064355 int count = 0;
38074356
3808
- for (int i = copy.versions.length; --i >= 0;)
4357
+ for (int i = copy.versionlist.length; --i >= 0;)
38094358 {
3810
- if (copy.versions[i] != null)
4359
+ if (copy.versionlist[i] != null)
38114360 count++;
38124361 }
38134362
38144363 return count;
38154364 }
38164365
3817
- void SetUndoStates()
4366
+ void SetVersionStates()
38184367 {
3819
- cRadio tab = GetCurrentTab();
4368
+ //if (true)
4369
+ // return;
4370
+
4371
+ //cRadio tab = GetCurrentTab();
38204372
38214373 restoreButton.setEnabled(copy.versionindex != -1);
38224374 replaceButton.setEnabled(copy.versionindex != -1);
38234375
3824
- undoButton.setEnabled(copy.versionindex > 0);
3825
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4376
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4377
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4378
+
4379
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4380
+ copy.versionlist[copy.versionindex + 1] != null);
38264381
38274382 muteSlider = true;
4383
+ versionSlider.setMinimum(0);
38284384 versionSlider.setMaximum(VersionCount() - 1);
38294385 versionSlider.setInteger(copy.versionindex);
4386
+ versionSlider.setEnabled(copy.versionindex != -1);
38304387 muteSlider = false;
38314388 }
38324389
3833
- public boolean Undo()
4390
+ public boolean PreviousVersion()
38344391 {
38354392 // Option?
38364393 Replace();
38374394
38384395 System.err.println("Undo");
38394396
3840
- cRadio tab = GetCurrentTab();
4397
+ //cRadio tab = GetCurrentTab();
38414398
38424399 if (copy.versionindex == 0)
38434400 {
....@@ -3860,7 +4417,7 @@
38604417
38614418 copy.versionindex -= 1;
38624419
3863
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4420
+ CopyChanged();
38644421
38654422 return true;
38664423 }
....@@ -3869,15 +4426,16 @@
38694426 {
38704427 System.err.println("Restore");
38714428
3872
- cRadio tab = GetCurrentTab();
4429
+ //cRadio tab = GetCurrentTab();
38734430
3874
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4431
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38754432 {
38764433 java.awt.Toolkit.getDefaultToolkit().beep();
38774434 return false;
38784435 }
38794436
3880
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4437
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4438
+ CopyChanged();
38814439
38824440 return true;
38834441 }
....@@ -3886,27 +4444,27 @@
38864444 {
38874445 System.err.println("Replace");
38884446
3889
- cRadio tab = GetCurrentTab();
4447
+ //cRadio tab = GetCurrentTab();
38904448
3891
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4449
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38924450 {
38934451 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38944452 return false;
38954453 }
38964454
3897
- copy.versions[copy.versionindex] = CompressCopy();
4455
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38984456
38994457 return true;
39004458 }
39014459
3902
- public void Redo()
4460
+ public void NextVersion()
39034461 {
39044462 // Option?
39054463 Replace();
39064464
3907
- cRadio tab = GetCurrentTab();
4465
+ //cRadio tab = GetCurrentTab();
39084466
3909
- if (copy.versions[copy.versionindex + 1] == null)
4467
+ if (copy.versionlist[copy.versionindex + 1] == null)
39104468 {
39114469 java.awt.Toolkit.getDefaultToolkit().beep();
39124470 return;
....@@ -3914,7 +4472,7 @@
39144472
39154473 copy.versionindex += 1;
39164474
3917
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4475
+ CopyChanged();
39184476
39194477 //if (!tab.user[tab.versionindex])
39204478 // tab.graphs[tab.versionindex] = null;
....@@ -4128,7 +4686,7 @@
41284686 //copy.material = new cMaterial(copy.GetMaterial());
41294687
41304688 current.color = (float) colorField.getFloat();
4131
- current.modulation = (float) modulationField.getFloat();
4689
+ current.modulation = (float) saturationField.getFloat();
41324690 current.metalness = (float) metalnessField.getFloat();
41334691 current.diffuse = (float) diffuseField.getFloat();
41344692 current.specular = (float) specularField.getFloat();
....@@ -4161,7 +4719,7 @@
41614719 cMaterial mat = copy.material;
41624720
41634721 colorField.SetToolTipValue((mat.color));
4164
- modulationField.SetToolTipValue((mat.modulation));
4722
+ saturationField.SetToolTipValue((mat.modulation));
41654723 metalnessField.SetToolTipValue((mat.metalness));
41664724 diffuseField.SetToolTipValue((mat.diffuse));
41674725 specularField.SetToolTipValue((mat.specular));
....@@ -4225,9 +4783,10 @@
42254783
42264784 int version = versionSlider.getInteger();
42274785
4228
- if (copy.versions[version] != null)
4786
+ if (version != -1 && copy.versionlist[version] != null)
42294787 {
4230
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4788
+ copy.versionindex = version;
4789
+ CopyChanged();
42314790 }
42324791
42334792 return;
....@@ -4267,6 +4826,12 @@
42674826 {
42684827 //System.out.println("stateChanged = " + this);
42694828 materialtouched = true;
4829
+
4830
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4831
+ {
4832
+ saturationField.setFloat(1);
4833
+ }
4834
+
42704835 applySelf();
42714836 //System.out.println("this = " + this);
42724837 //System.out.println("PARENT = " + parent);
....@@ -4566,6 +5131,7 @@
45665131 {
45675132 if (GetTree() != null)
45685133 {
5134
+ GetTree().revalidate();
45695135 GetTree().repaint();
45705136 }
45715137
....@@ -4574,6 +5140,9 @@
45745140 ctrlPanel.validate(); // ? new
45755141 ctrlPanel.repaint();
45765142 }
5143
+
5144
+ if (previousVersionButton != null && copy.versionlist != null)
5145
+ SetVersionStates();
45775146 }
45785147
45795148 static TweenManager tweenManager = new TweenManager();
....@@ -4957,13 +5526,16 @@
49575526 c.addChild(csg);
49585527 }
49595528
4960
- copy.versions = readobj.versions;
5529
+ copy.versionlist = readobj.versionlist;
49615530 copy.versionindex = readobj.versionindex;
49625531
4963
- if (copy.versions == null)
5532
+ if (copy.versionlist == null)
49645533 {
4965
- copy.versions = new byte[100][];
5534
+ // Backward compatibility
5535
+ copy.versionlist = new Object3D[100];
49665536 copy.versionindex = -1;
5537
+
5538
+ Save(true);
49675539 }
49685540
49695541 //? SetUndoStates();
....@@ -4978,7 +5550,7 @@
49785550 {
49795551 if (Grafreed.standAlone)
49805552 {
4981
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5553
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49825554 browser.show();
49835555 String filename = browser.getFile();
49845556 if (filename != null && filename.length() > 0)
....@@ -5055,6 +5627,8 @@
50555627
50565628 void save()
50575629 {
5630
+ Replace();
5631
+
50585632 if (lastname == null)
50595633 {
50605634 return;
....@@ -5297,6 +5871,7 @@
52975871 ButtonGroup buttonGroup;
52985872
52995873 cGridBag toolboxPanel;
5874
+ cGridBag skyboxPanel;
53005875 cGridBag materialPanel;
53015876 cGridBag ctrlPanel;
53025877
....@@ -5370,7 +5945,7 @@
53705945 JLabel colorLabel;
53715946 cNumberSlider colorField;
53725947 JLabel modulationLabel;
5373
- cNumberSlider modulationField;
5948
+ cNumberSlider saturationField;
53745949 JLabel metalnessLabel;
53755950 cNumberSlider metalnessField;
53765951 JLabel diffuseLabel;
....@@ -5401,6 +5976,7 @@
54015976 cNumberSlider anisoField;
54025977 JLabel anisoVLabel;
54035978 cNumberSlider anisoVField;
5979
+
54045980 JLabel cameraLabel;
54055981 cNumberSlider cameraField;
54065982 JLabel selfshadowLabel;
....@@ -5415,6 +5991,7 @@
54155991 cNumberSlider fakedepthField;
54165992 JLabel shadowbiasLabel;
54175993 cNumberSlider shadowbiasField;
5994
+
54185995 JLabel bumpLabel;
54195996 cNumberSlider bumpField;
54205997 JLabel noiseLabel;