Normand Briere
2019-08-18 66aca73cce89e4b4d7521862760edf4b0888bc38
ObjEditor.java
....@@ -83,7 +83,10 @@
8383 cButton GetButton(String name, boolean border)
8484 {
8585 ImageIcon icon = GetIcon(name);
86
- return new cButton(icon, border);
86
+ if (icon != null || name.contains("/"))
87
+ return new cButton(icon, border);
88
+ else
89
+ return new cButton(name, border);
8790 }
8891
8992 cLabel GetLabel(String name, boolean border)
....@@ -106,7 +109,7 @@
106109
107110 static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108111
109
- ImageIcon GetIcon(String name)
112
+ static ImageIcon GetIcon(String name)
110113 {
111114 javax.swing.ImageIcon iconCache = icons.get(name);
112115 if (iconCache != null)
....@@ -116,7 +119,7 @@
116119
117120 try
118121 {
119
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
122
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
120123
121124 // if (image.getWidth() > 48 && image.getHeight() > 48)
122125 // {
....@@ -426,6 +429,9 @@
426429
427430 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
428431
432
+ // This is to refresh the UI of the material panel.
433
+ boolean patchMaterial;
434
+
429435 void SetupMenu()
430436 {
431437 frame.setMenuBar(menuBar = new MenuBar());
....@@ -951,18 +957,29 @@
951957 boolean temp = CameraPane.SWITCH;
952958 CameraPane.SWITCH = false;
953959
954
- object.ExtractBigData(versiontable);
960
+ if (Grafreed.grafreed.universe.versiontable == null)
961
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
962
+
963
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
955964 // if (copy == client)
956965
957966 Object3D versions[] = object.versionlist;
967
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
958968 object.versionlist = null;
969
+ object.versiontable = null;
970
+
971
+ Object3D parent = object.parent;
972
+ object.parent = null;
959973
960974 //byte[] compress = Compress(copy);
961975 Object3D compress = (Object3D)Grafreed.clone(object);
962976
963
- object.versionlist = versions;
977
+ object.parent = parent;
964978
965
- object.RestoreBigData(versiontable);
979
+ object.versionlist = versions;
980
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
981
+
982
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
966983
967984 CameraPane.SWITCH = temp;
968985
....@@ -1301,7 +1318,7 @@
13011318
13021319 //if (copy.pinned)
13031320 {
1304
- pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1321
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
13051322 pinButton.setSelected(copy.pinned);
13061323 cGridBag t = new cGridBag();
13071324 t.preferredWidth = 2;
....@@ -1615,6 +1632,45 @@
16151632 //frontView.object = copy;
16161633 //sideView.object = copy;
16171634
1635
+ transformPanel = new cGridBag().setVertical(true);
1636
+
1637
+ cGridBag resetTransformPanel = new cGridBag();
1638
+
1639
+ resetTransformPanel.preferredHeight = 2;
1640
+
1641
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1642
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1643
+ resetTransform.addMouseListener(new MouseAdapter()
1644
+ {
1645
+ public void mouseClicked(MouseEvent e)
1646
+ {
1647
+ ResetTransform();
1648
+ }
1649
+ });
1650
+ resetTransformPanel.add(resetTransform);
1651
+
1652
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1653
+ resetTransform.setToolTipText("Reset Translation only");
1654
+ resetTransform.addMouseListener(new MouseAdapter()
1655
+ {
1656
+ public void mouseClicked(MouseEvent e)
1657
+ {
1658
+ ResetTransform(1);
1659
+ }
1660
+ });
1661
+ resetTransformPanel.add(resetTransform);
1662
+
1663
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1664
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1665
+ resetTransform.addMouseListener(new MouseAdapter()
1666
+ {
1667
+ public void mouseClicked(MouseEvent e)
1668
+ {
1669
+ ResetTransform(2);
1670
+ }
1671
+ });
1672
+ resetTransformPanel.add(resetTransform);
1673
+
16181674 XYZPanel = new cGridBag().setVertical(true);
16191675 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
16201676
....@@ -1624,6 +1680,9 @@
16241680 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
16251681 //XYZPanel.setName("XYZ");
16261682
1683
+ transformPanel.add(resetTransformPanel);
1684
+ transformPanel.add(XYZPanel);
1685
+
16271686 /*
16281687 gridPanel = new JPanel(); //new BorderLayout());
16291688 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1631,12 +1690,12 @@
16311690 gridPanel.add(cameraView);
16321691 gridPanel.add(XYZPanel);
16331692 */
1634
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1635
- gridPanel.setContinuousLayout(true);
1636
- gridPanel.setOneTouchExpandable(true);
1637
- gridPanel.setDividerLocation(1.0);
1638
- gridPanel.setDividerSize(9);
1639
- gridPanel.setResizeWeight(0.85);
1693
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1694
+// gridPanel.setContinuousLayout(true);
1695
+// gridPanel.setOneTouchExpandable(true);
1696
+// gridPanel.setDividerLocation(1.0);
1697
+// gridPanel.setDividerSize(9);
1698
+// gridPanel.setResizeWeight(0.85);
16401699
16411700 // aConstraints.weighty = 0;
16421701 //System.out.println("THIS = " + this);
....@@ -1659,14 +1718,14 @@
16591718
16601719 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
16611720 //tmp.setName("Edit");
1662
- objectPanel.add(materialPanel);
1663
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1664
- objectPanel.setToolTipTextAt(0, "Material");
1665
-
16661721 objectPanel.add(toolboxPanel);
1667
- objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1668
- objectPanel.setToolTipTextAt(1, "Objects & textures");
1722
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1723
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
16691724
1725
+ objectPanel.add(materialPanel);
1726
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1727
+ objectPanel.setToolTipTextAt(1, "Material");
1728
+
16701729 objectPanel.add(skyboxPanel);
16711730 objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
16721731 objectPanel.setToolTipTextAt(2, "Backgrounds");
....@@ -1679,10 +1738,14 @@
16791738 objectPanel.setIconAt(3, GetIcon("icons/write.png"));
16801739 objectPanel.setToolTipTextAt(3, "Edit controls");
16811740
1682
- objectPanel.add(XYZPanel);
1741
+ objectPanel.add(transformPanel);
16831742 objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1684
- objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1743
+ objectPanel.setToolTipTextAt(4, "TRS transform");
16851744
1745
+ patchMaterial = true;
1746
+ cameraView.patchMaterial = this;
1747
+ objectPanel.setSelectedIndex(1);
1748
+
16861749 /*
16871750 aConstraints.gridx = 0;
16881751 aConstraints.gridwidth = 1;
....@@ -1702,7 +1765,7 @@
17021765 scrollpane.addMouseWheelListener(this); // Default not fast enough
17031766
17041767 /*JTabbedPane*/ scenePanel = new cGridBag();
1705
- scenePanel.preferredWidth = 5;
1768
+ scenePanel.preferredWidth = 6;
17061769
17071770 JTabbedPane tabbedPane = new JTabbedPane();
17081771 tabbedPane.add(scrollpane);
....@@ -1713,17 +1776,52 @@
17131776
17141777 AddOptions(optionsPanel); //, aConstraints);
17151778
1716
- tabbedPane.add(optionsPanel);
1717
-
17181779 tabbedPane.add(FSPane = new cFileSystemPane(this));
17191780
1781
+ tabbedPane.add(optionsPanel);
1782
+
17201783 scenePanel.add(tabbedPane);
17211784
1722
- //if (Globals.ADVANCED)
1723
-// tabbedPane.add(infoPanel);
1724
-// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1725
-// tabbedPane.setToolTipTextAt(3, "Information");
1785
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1786
+ creditsPanel.setName("Credits");
17261787
1788
+ cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1789
+ creditsPanel.add(ogaLabel);
1790
+
1791
+ cButton opengameartButton;
1792
+ creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1793
+ opengameartButton.setToolTipText("https://opengameart.org");
1794
+
1795
+ opengameartButton.addMouseListener(new MouseAdapter()
1796
+ {
1797
+ public void mouseClicked(MouseEvent e)
1798
+ {
1799
+ try
1800
+ {
1801
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1802
+ } catch (Exception e1)
1803
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1804
+ {
1805
+ e1.printStackTrace();
1806
+ }
1807
+ }
1808
+ });
1809
+
1810
+ for (int i=10; --i>=0;)
1811
+ {
1812
+ creditsPanel.add(new cGridBag());
1813
+ }
1814
+
1815
+ tabbedPane.add(creditsPanel);
1816
+ tabbedPane.setToolTipTextAt(3, "Credits");
1817
+
1818
+ if (Globals.ADVANCED)
1819
+ {
1820
+ tabbedPane.add(infoPanel);
1821
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1822
+ tabbedPane.setToolTipTextAt(4, "Information");
1823
+ }
1824
+
17271825 /*
17281826 cTree jTree = new cTree(null);
17291827 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1744,13 +1842,13 @@
17441842 jtp.add(tree);
17451843 */
17461844
1747
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1748
- bigPanel.setContinuousLayout(true);
1749
- bigPanel.setOneTouchExpandable(true);
1750
- bigPanel.setDividerLocation(0.8);
1751
- bigPanel.setDividerSize(15);
1752
- bigPanel.setResizeWeight(0.15);
1753
- bigPanel.setName("Scene");
1845
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1846
+// bigPanel.setContinuousLayout(true);
1847
+// bigPanel.setOneTouchExpandable(true);
1848
+// bigPanel.setDividerLocation(0.8);
1849
+// bigPanel.setDividerSize(15);
1850
+// bigPanel.setResizeWeight(0.15);
1851
+// bigPanel.setName("Scene");
17541852
17551853 //bigPanel.setLayout(new BorderLayout());
17561854 //bigPanel.setSize(new Dimension(10,10));
....@@ -1834,7 +1932,7 @@
18341932
18351933 cameraView.requestFocusInWindow();
18361934
1837
- gridPanel.setDividerLocation(1.0);
1935
+// gridPanel.setDividerLocation(1.0);
18381936
18391937 frame.validate();
18401938
....@@ -1869,7 +1967,7 @@
18691967 {
18701968 cGridBag presetpanel = new cGridBag().setVertical(true);
18711969
1872
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1970
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
18731971 skin.setToolTipText("Skin");
18741972 skin.addMouseListener(new MouseAdapter()
18751973 {
....@@ -1880,7 +1978,15 @@
18801978
18811979 // Skin
18821980 colorField.setFloat(material.color);
1883
- saturationField.setFloat(material.modulation);
1981
+ float saturation = material.modulation;
1982
+
1983
+ if (!cameraView.Skinshader)
1984
+ {
1985
+ saturation /= 1.5;
1986
+ }
1987
+
1988
+ saturationField.setFloat(saturation);
1989
+
18841990 subsurfaceField.setFloat(material.subsurface);
18851991 selfshadowField.setFloat(material.diffuseness);
18861992 diffusenessField.setFloat(material.factor);
....@@ -1899,7 +2005,7 @@
18992005 });
19002006 presetpanel.add(skin);
19012007
1902
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2008
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
19032009 lambert.setToolTipText("Diffuse");
19042010 lambert.addMouseListener(new MouseAdapter()
19052011 {
....@@ -1917,7 +2023,7 @@
19172023 });
19182024 presetpanel.add(lambert);
19192025
1920
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2026
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
19212027 diffuse2.setToolTipText("Diffuse2");
19222028 diffuse2.addMouseListener(new MouseAdapter()
19232029 {
....@@ -1935,7 +2041,7 @@
19352041 });
19362042 presetpanel.add(diffuse2);
19372043
1938
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2044
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
19392045 diffusemoon.setToolTipText("Moon");
19402046 diffusemoon.addMouseListener(new MouseAdapter()
19412047 {
....@@ -1953,7 +2059,7 @@
19532059 });
19542060 presetpanel.add(diffusemoon);
19552061
1956
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2062
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
19572063 diffusemoon2.setToolTipText("Moon2");
19582064 diffusemoon2.addMouseListener(new MouseAdapter()
19592065 {
....@@ -1971,7 +2077,7 @@
19712077 });
19722078 presetpanel.add(diffusemoon2);
19732079
1974
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2080
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
19752081 diffusemoon3.setToolTipText("Moon3");
19762082 diffusemoon3.addMouseListener(new MouseAdapter()
19772083 {
....@@ -1989,7 +2095,7 @@
19892095 });
19902096 presetpanel.add(diffusemoon3);
19912097
1992
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2098
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
19932099 diffusesheen.setToolTipText("Sheen");
19942100 diffusesheen.addMouseListener(new MouseAdapter()
19952101 {
....@@ -2006,7 +2112,7 @@
20062112 });
20072113 presetpanel.add(diffusesheen);
20082114
2009
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2115
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
20102116 rough.setToolTipText("Rough metal");
20112117 rough.addMouseListener(new MouseAdapter()
20122118 {
....@@ -2024,7 +2130,7 @@
20242130 });
20252131 presetpanel.add(rough);
20262132
2027
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2133
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
20282134 rough2.setToolTipText("Medium metal");
20292135 rough2.addMouseListener(new MouseAdapter()
20302136 {
....@@ -2042,7 +2148,7 @@
20422148 });
20432149 presetpanel.add(rough2);
20442150
2045
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2151
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
20462152 shini0.setToolTipText("Shiny");
20472153 shini0.addMouseListener(new MouseAdapter()
20482154 {
....@@ -2060,7 +2166,7 @@
20602166 });
20612167 presetpanel.add(shini0);
20622168
2063
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2169
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
20642170 shini1.setToolTipText("Shiny2");
20652171 shini1.addMouseListener(new MouseAdapter()
20662172 {
....@@ -2078,7 +2184,7 @@
20782184 });
20792185 presetpanel.add(shini1);
20802186
2081
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2187
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
20822188 shini2.setToolTipText("Shiny3");
20832189 shini2.addMouseListener(new MouseAdapter()
20842190 {
....@@ -2096,7 +2202,7 @@
20962202 });
20972203 presetpanel.add(shini2);
20982204
2099
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2205
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
21002206 aniso.setToolTipText("AnisoU");
21012207 aniso.addMouseListener(new MouseAdapter()
21022208 {
....@@ -2114,7 +2220,7 @@
21142220 });
21152221 presetpanel.add(aniso);
21162222
2117
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2223
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
21182224 aniso2.setToolTipText("AnisoV");
21192225 aniso2.addMouseListener(new MouseAdapter()
21202226 {
....@@ -2132,7 +2238,7 @@
21322238 });
21332239 presetpanel.add(aniso2);
21342240
2135
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2241
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
21362242 aniso3.setToolTipText("AnisoUV");
21372243 aniso3.addMouseListener(new MouseAdapter()
21382244 {
....@@ -2150,7 +2256,7 @@
21502256 });
21512257 presetpanel.add(aniso3);
21522258
2153
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2259
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
21542260 velvet0.setToolTipText("Velvet");
21552261 velvet0.addMouseListener(new MouseAdapter()
21562262 {
....@@ -2172,7 +2278,7 @@
21722278 });
21732279 presetpanel.add(velvet0);
21742280
2175
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2281
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
21762282 bump0.setToolTipText("Bump texture");
21772283 bump0.addMouseListener(new MouseAdapter()
21782284 {
....@@ -2191,7 +2297,7 @@
21912297 });
21922298 presetpanel.add(bump0);
21932299
2194
- cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2300
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
21952301 borderShader.setToolTipText("Border fade");
21962302 borderShader.addMouseListener(new MouseAdapter()
21972303 {
....@@ -2206,7 +2312,7 @@
22062312 });
22072313 presetpanel.add(borderShader);
22082314
2209
- cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2315
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
22102316 halo.setToolTipText("Halo");
22112317 halo.addMouseListener(new MouseAdapter()
22122318 {
....@@ -2223,7 +2329,7 @@
22232329 });
22242330 presetpanel.add(halo);
22252331
2226
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2332
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
22272333 candle.setToolTipText("Candle");
22282334 candle.addMouseListener(new MouseAdapter()
22292335 {
....@@ -2245,7 +2351,7 @@
22452351 });
22462352 presetpanel.add(candle);
22472353
2248
- cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2354
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
22492355 shadowShader.setToolTipText("Shadow");
22502356 shadowShader.addMouseListener(new MouseAdapter()
22512357 {
....@@ -2280,19 +2386,19 @@
22802386
22812387 cGridBag editBar = new cGridBag().setVertical(false);
22822388
2283
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2389
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
22842390 createMaterialButton.setToolTipText("Create material");
22852391
22862392 /*
22872393 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
22882394 */
22892395
2290
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2396
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
22912397 clearMaterialButton.setToolTipText("Clear material");
22922398
22932399 if (Globals.ADVANCED)
22942400 {
2295
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2401
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
22962402 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
22972403 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
22982404 }
....@@ -3913,7 +4019,7 @@
39134019 //System.out.println("ObjEditor " + event);
39144020 applySelf0(true);
39154021 //parent.applySelf();
3916
- objEditor.refreshContents();
4022
+ // conflicts with requestFocus objEditor.refreshContents();
39174023 } else if (source == resetButton)
39184024 {
39194025 CameraPane.fullreset = true;
....@@ -4093,12 +4199,15 @@
40934199
40944200 void New()
40954201 {
4096
- while (copy.Size() > 1)
4202
+ while (copy.Size() > 0)
40974203 {
4098
- copy.remove(1);
4204
+ copy.remove(0);
40994205 }
41004206
4207
+ copy.selection.clear();
4208
+
41014209 ResetModel();
4210
+ SetupViews();
41024211 objEditor.refreshContents();
41034212 }
41044213
....@@ -4225,8 +4334,6 @@
42254334 return true;
42264335 }
42274336
4228
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4229
-
42304337 void DeleteVersion()
42314338 {
42324339 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4234,7 +4341,11 @@
42344341 copy.versionlist[i] = copy.versionlist[i+1];
42354342 }
42364343
4237
- CopyChanged();
4344
+ if (copy.versionlist[copy.versionindex] == null)
4345
+ copy.versionindex -= 1;
4346
+
4347
+ if (copy.versionindex != -1)
4348
+ CopyChanged();
42384349
42394350 SetVersionStates();
42404351 }
....@@ -4347,7 +4458,7 @@
43474458 boolean temp = CameraPane.SWITCH;
43484459 CameraPane.SWITCH = false;
43494460
4350
- copy.ExtractBigData(versiontable);
4461
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
43514462
43524463 copy.clear();
43534464
....@@ -4359,7 +4470,7 @@
43594470 copy.add(obj.get(i));
43604471 }
43614472
4362
- copy.RestoreBigData(versiontable);
4473
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
43634474
43644475 CameraPane.SWITCH = temp;
43654476
....@@ -4409,6 +4520,8 @@
44094520 return count;
44104521 }
44114522
4523
+ public cGridBag versionSliderPane;
4524
+
44124525 void SetVersionStates()
44134526 {
44144527 //if (true)
....@@ -4416,21 +4529,36 @@
44164529
44174530 //cRadio tab = GetCurrentTab();
44184531
4419
- restoreButton.setEnabled(copy.versionindex != -1);
4420
- replaceButton.setEnabled(copy.versionindex != -1);
4421
-
4422
- previousVersionButton.setEnabled(copy.versionindex > 0);
4423
- nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4424
-
4425
- deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4426
- copy.versionlist[copy.versionindex + 1] != null);
4427
-
4428
- muteSlider = true;
4429
- versionSlider.setMinimum(0);
4430
- versionSlider.setMaximum(VersionCount() - 1);
4431
- versionSlider.setInteger(copy.versionindex);
4432
- versionSlider.setEnabled(copy.versionindex != -1);
4433
- muteSlider = false;
4532
+ if (copy.versionlist == null)
4533
+ {
4534
+ saveVersionButton.setEnabled(false);
4535
+ restoreButton.setEnabled(false);
4536
+ replaceButton.setEnabled(false);
4537
+ previousVersionButton.setEnabled(false);
4538
+ nextVersionButton.setEnabled(false);
4539
+ deleteVersionButton.setEnabled(false);
4540
+ versionSliderPane.setVisible(false);
4541
+ }
4542
+ else
4543
+ {
4544
+ restoreButton.setEnabled(copy.versionindex != -1);
4545
+ replaceButton.setEnabled(copy.versionindex != -1);
4546
+
4547
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4548
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4549
+
4550
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4551
+ //copy.versionlist[copy.versionindex + 1] != null);
4552
+
4553
+ muteSlider = true;
4554
+ versionSlider.setMinimum(0);
4555
+ versionSlider.setMaximum(VersionCount() - 1);
4556
+ versionSlider.setInteger(copy.versionindex);
4557
+ versionSlider.setEnabled(copy.versionindex != -1);
4558
+ muteSlider = false;
4559
+
4560
+ versionSliderPane.setVisible(true);
4561
+ }
44344562 }
44354563
44364564 public boolean PreviousVersion()
....@@ -4488,7 +4616,7 @@
44884616
44894617 public boolean Replace()
44904618 {
4491
- System.err.println("Replace");
4619
+ //System.err.println("Replace");
44924620
44934621 //cRadio tab = GetCurrentTab();
44944622
....@@ -4715,6 +4843,12 @@
47154843 // else
47164844 // applySelf(true);
47174845 // }
4846
+
4847
+ boolean Equal(double a, double b)
4848
+ {
4849
+ return Math.abs(a - b) < 0.001;
4850
+ }
4851
+
47184852 void applySelf0(boolean name)
47194853 {
47204854 if (name)
....@@ -4764,29 +4898,52 @@
47644898 {
47654899 cMaterial mat = copy.material;
47664900
4767
- colorField.SetToolTipValue((mat.color));
4768
- saturationField.SetToolTipValue((mat.modulation));
4769
- metalnessField.SetToolTipValue((mat.metalness));
4770
- diffuseField.SetToolTipValue((mat.diffuse));
4771
- specularField.SetToolTipValue((mat.specular));
4772
- shininessField.SetToolTipValue((mat.shininess));
4773
- shiftField.SetToolTipValue((mat.shift));
4774
- ambientField.SetToolTipValue((mat.ambient));
4775
- lightareaField.SetToolTipValue((mat.lightarea));
4776
- diffusenessField.SetToolTipValue((mat.factor));
4777
- velvetField.SetToolTipValue((mat.velvet));
4778
- sheenField.SetToolTipValue((mat.sheen));
4779
- subsurfaceField.SetToolTipValue((mat.subsurface));
4780
- backlitField.SetToolTipValue((mat.bump));
4781
- anisoField.SetToolTipValue((mat.aniso));
4782
- anisoVField.SetToolTipValue((mat.anisoV));
4783
- cameraField.SetToolTipValue((mat.cameralight));
4784
- selfshadowField.SetToolTipValue((mat.diffuseness));
4785
- shadowField.SetToolTipValue((mat.shadow));
4786
- textureField.SetToolTipValue((mat.texture));
4787
- opacityField.SetToolTipValue((mat.opacity));
4788
- fakedepthField.SetToolTipValue((mat.fakedepth));
4789
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4901
+ if (!Equal(colorField.getFloat(), mat.color))
4902
+ colorField.SetToolTipValue((mat.color));
4903
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4904
+ saturationField.SetToolTipValue((mat.modulation));
4905
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4906
+ metalnessField.SetToolTipValue((mat.metalness));
4907
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4908
+ diffuseField.SetToolTipValue((mat.diffuse));
4909
+ if (!Equal(specularField.getFloat(), mat.specular))
4910
+ specularField.SetToolTipValue((mat.specular));
4911
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4912
+ shininessField.SetToolTipValue((mat.shininess));
4913
+ if (!Equal(shiftField.getFloat(), mat.shift))
4914
+ shiftField.SetToolTipValue((mat.shift));
4915
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4916
+ ambientField.SetToolTipValue((mat.ambient));
4917
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4918
+ lightareaField.SetToolTipValue((mat.lightarea));
4919
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4920
+ diffusenessField.SetToolTipValue((mat.factor));
4921
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4922
+ velvetField.SetToolTipValue((mat.velvet));
4923
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4924
+ sheenField.SetToolTipValue((mat.sheen));
4925
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4926
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4927
+ if (!Equal(backlitField.getFloat(), mat.bump))
4928
+ backlitField.SetToolTipValue((mat.bump));
4929
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4930
+ anisoField.SetToolTipValue((mat.aniso));
4931
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4932
+ anisoVField.SetToolTipValue((mat.anisoV));
4933
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4934
+ cameraField.SetToolTipValue((mat.cameralight));
4935
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4936
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4937
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4938
+ shadowField.SetToolTipValue((mat.shadow));
4939
+ if (!Equal(textureField.getFloat(), mat.texture))
4940
+ textureField.SetToolTipValue((mat.texture));
4941
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4942
+ opacityField.SetToolTipValue((mat.opacity));
4943
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4944
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4945
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4946
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
47904947 }
47914948
47924949 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4821,7 +4978,7 @@
48214978
48224979 public void stateChanged(ChangeEvent e)
48234980 {
4824
- // assert(false);
4981
+ // assert(false);
48254982 if (e.getSource() == versionSlider)
48264983 {
48274984 if (muteSlider)
....@@ -5578,6 +5735,7 @@
55785735
55795736 copy.versionlist = readobj.versionlist;
55805737 copy.versionindex = readobj.versionindex;
5738
+ copy.versiontable = readobj.versiontable;
55815739
55825740 if (copy.versionlist == null)
55835741 {
....@@ -5933,6 +6091,7 @@
59336091 boolean materialFlushed;
59346092 Object3D latestObject;
59356093
6094
+ cGridBag transformPanel;
59366095 cGridBag XYZPanel;
59376096
59386097 JSplitPane gridPanel;