Normand Briere
2019-08-18 66aca73cce89e4b4d7521862760edf4b0888bc38
ObjEditor.java
....@@ -43,6 +43,35 @@
4343
4444 static ObjEditor theFrame;
4545
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
4675 public cGridBag GetSeparator()
4776 {
4877 cGridBag separator = new cGridBag();
....@@ -54,7 +83,10 @@
5483 cButton GetButton(String name, boolean border)
5584 {
5685 ImageIcon icon = GetIcon(name);
57
- 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);
5890 }
5991
6092 cLabel GetLabel(String name, boolean border)
....@@ -77,7 +109,7 @@
77109
78110 static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
79111
80
- ImageIcon GetIcon(String name)
112
+ static ImageIcon GetIcon(String name)
81113 {
82114 javax.swing.ImageIcon iconCache = icons.get(name);
83115 if (iconCache != null)
....@@ -87,7 +119,7 @@
87119
88120 try
89121 {
90
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
122
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
91123
92124 // if (image.getWidth() > 48 && image.getHeight() > 48)
93125 // {
....@@ -359,7 +391,8 @@
359391 //parent = p;
360392
361393 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
362
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
394
+ if (Globals.DEBUG)
395
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
363396 //gd.setFullScreenWindow(this);
364397 //setResizable(false);
365398 //if (!isDisplayable())
....@@ -396,6 +429,9 @@
396429
397430 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
398431
432
+ // This is to refresh the UI of the material panel.
433
+ boolean patchMaterial;
434
+
399435 void SetupMenu()
400436 {
401437 frame.setMenuBar(menuBar = new MenuBar());
....@@ -921,18 +957,29 @@
921957 boolean temp = CameraPane.SWITCH;
922958 CameraPane.SWITCH = false;
923959
924
- 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);
925964 // if (copy == client)
926965
927966 Object3D versions[] = object.versionlist;
967
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
928968 object.versionlist = null;
969
+ object.versiontable = null;
970
+
971
+ Object3D parent = object.parent;
972
+ object.parent = null;
929973
930974 //byte[] compress = Compress(copy);
931975 Object3D compress = (Object3D)Grafreed.clone(object);
932976
933
- object.versionlist = versions;
977
+ object.parent = parent;
934978
935
- object.RestoreBigData(versiontable);
979
+ object.versionlist = versions;
980
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
981
+
982
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
936983
937984 CameraPane.SWITCH = temp;
938985
....@@ -1271,7 +1318,7 @@
12711318
12721319 //if (copy.pinned)
12731320 {
1274
- pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1321
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
12751322 pinButton.setSelected(copy.pinned);
12761323 cGridBag t = new cGridBag();
12771324 t.preferredWidth = 2;
....@@ -1294,14 +1341,14 @@
12941341
12951342 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12961343 liveCB.setToolTipText("Animate object");
1344
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1345
+ markCB.setToolTipText("Set target transform");
12971346 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12981347 selectableCB.setToolTipText("Make object selectable");
12991348 // Return();
13001349
13011350 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
13021351 hideCB.setToolTipText("Hide object");
1303
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1304
- markCB.setToolTipText("As animation target transform");
13051352
13061353 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
13071354
....@@ -1503,6 +1550,7 @@
15031550
15041551 if (cam == null || !(copy.get(0) instanceof cGroup))
15051552 {
1553
+ if (Globals.DEBUG)
15061554 System.out.println("CREATE CAMERAS");
15071555 cams = new cTemplate();
15081556 cams.name = "Cameras";
....@@ -1584,6 +1632,45 @@
15841632 //frontView.object = copy;
15851633 //sideView.object = copy;
15861634
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
+
15871674 XYZPanel = new cGridBag().setVertical(true);
15881675 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15891676
....@@ -1593,6 +1680,9 @@
15931680 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15941681 //XYZPanel.setName("XYZ");
15951682
1683
+ transformPanel.add(resetTransformPanel);
1684
+ transformPanel.add(XYZPanel);
1685
+
15961686 /*
15971687 gridPanel = new JPanel(); //new BorderLayout());
15981688 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1600,12 +1690,12 @@
16001690 gridPanel.add(cameraView);
16011691 gridPanel.add(XYZPanel);
16021692 */
1603
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1604
- gridPanel.setContinuousLayout(true);
1605
- gridPanel.setOneTouchExpandable(true);
1606
- gridPanel.setDividerLocation(1.0);
1607
- gridPanel.setDividerSize(9);
1608
- 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);
16091699
16101700 // aConstraints.weighty = 0;
16111701 //System.out.println("THIS = " + this);
....@@ -1628,14 +1718,14 @@
16281718
16291719 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
16301720 //tmp.setName("Edit");
1631
- objectPanel.add(materialPanel);
1632
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1633
- objectPanel.setToolTipTextAt(0, "Material");
1634
-
16351721 objectPanel.add(toolboxPanel);
1636
- objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1637
- objectPanel.setToolTipTextAt(1, "Objects & textures");
1722
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1723
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
16381724
1725
+ objectPanel.add(materialPanel);
1726
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1727
+ objectPanel.setToolTipTextAt(1, "Material");
1728
+
16391729 objectPanel.add(skyboxPanel);
16401730 objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
16411731 objectPanel.setToolTipTextAt(2, "Backgrounds");
....@@ -1648,10 +1738,14 @@
16481738 objectPanel.setIconAt(3, GetIcon("icons/write.png"));
16491739 objectPanel.setToolTipTextAt(3, "Edit controls");
16501740
1651
- objectPanel.add(XYZPanel);
1741
+ objectPanel.add(transformPanel);
16521742 objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1653
- objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1743
+ objectPanel.setToolTipTextAt(4, "TRS transform");
16541744
1745
+ patchMaterial = true;
1746
+ cameraView.patchMaterial = this;
1747
+ objectPanel.setSelectedIndex(1);
1748
+
16551749 /*
16561750 aConstraints.gridx = 0;
16571751 aConstraints.gridwidth = 1;
....@@ -1671,7 +1765,7 @@
16711765 scrollpane.addMouseWheelListener(this); // Default not fast enough
16721766
16731767 /*JTabbedPane*/ scenePanel = new cGridBag();
1674
- scenePanel.preferredWidth = 5;
1768
+ scenePanel.preferredWidth = 6;
16751769
16761770 JTabbedPane tabbedPane = new JTabbedPane();
16771771 tabbedPane.add(scrollpane);
....@@ -1682,17 +1776,52 @@
16821776
16831777 AddOptions(optionsPanel); //, aConstraints);
16841778
1685
- tabbedPane.add(optionsPanel);
1686
-
16871779 tabbedPane.add(FSPane = new cFileSystemPane(this));
16881780
1781
+ tabbedPane.add(optionsPanel);
1782
+
16891783 scenePanel.add(tabbedPane);
16901784
1691
- //if (Globals.ADVANCED)
1692
-// tabbedPane.add(infoPanel);
1693
-// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1694
-// tabbedPane.setToolTipTextAt(3, "Information");
1785
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1786
+ creditsPanel.setName("Credits");
16951787
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
+
16961825 /*
16971826 cTree jTree = new cTree(null);
16981827 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1713,13 +1842,13 @@
17131842 jtp.add(tree);
17141843 */
17151844
1716
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1717
- bigPanel.setContinuousLayout(true);
1718
- bigPanel.setOneTouchExpandable(true);
1719
- bigPanel.setDividerLocation(0.8);
1720
- bigPanel.setDividerSize(15);
1721
- bigPanel.setResizeWeight(0.15);
1722
- 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");
17231852
17241853 //bigPanel.setLayout(new BorderLayout());
17251854 //bigPanel.setSize(new Dimension(10,10));
....@@ -1789,7 +1918,7 @@
17891918
17901919 frame.getContentPane().setLayout(new BorderLayout());
17911920 /**/
1792
- JTabbedPane worldPane = new JTabbedPane();
1921
+ //JTabbedPane worldPane = new JTabbedPane();
17931922 //worldPane.add(bigPanel);
17941923 //worldPane.add(worldPanel);
17951924 /**/
....@@ -1803,7 +1932,7 @@
18031932
18041933 cameraView.requestFocusInWindow();
18051934
1806
- gridPanel.setDividerLocation(1.0);
1935
+// gridPanel.setDividerLocation(1.0);
18071936
18081937 frame.validate();
18091938
....@@ -1838,7 +1967,7 @@
18381967 {
18391968 cGridBag presetpanel = new cGridBag().setVertical(true);
18401969
1841
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1970
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
18421971 skin.setToolTipText("Skin");
18431972 skin.addMouseListener(new MouseAdapter()
18441973 {
....@@ -1849,7 +1978,15 @@
18491978
18501979 // Skin
18511980 colorField.setFloat(material.color);
1852
- 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
+
18531990 subsurfaceField.setFloat(material.subsurface);
18541991 selfshadowField.setFloat(material.diffuseness);
18551992 diffusenessField.setFloat(material.factor);
....@@ -1868,7 +2005,7 @@
18682005 });
18692006 presetpanel.add(skin);
18702007
1871
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2008
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
18722009 lambert.setToolTipText("Diffuse");
18732010 lambert.addMouseListener(new MouseAdapter()
18742011 {
....@@ -1886,7 +2023,7 @@
18862023 });
18872024 presetpanel.add(lambert);
18882025
1889
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2026
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
18902027 diffuse2.setToolTipText("Diffuse2");
18912028 diffuse2.addMouseListener(new MouseAdapter()
18922029 {
....@@ -1904,7 +2041,7 @@
19042041 });
19052042 presetpanel.add(diffuse2);
19062043
1907
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2044
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
19082045 diffusemoon.setToolTipText("Moon");
19092046 diffusemoon.addMouseListener(new MouseAdapter()
19102047 {
....@@ -1922,7 +2059,7 @@
19222059 });
19232060 presetpanel.add(diffusemoon);
19242061
1925
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2062
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
19262063 diffusemoon2.setToolTipText("Moon2");
19272064 diffusemoon2.addMouseListener(new MouseAdapter()
19282065 {
....@@ -1940,7 +2077,7 @@
19402077 });
19412078 presetpanel.add(diffusemoon2);
19422079
1943
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2080
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
19442081 diffusemoon3.setToolTipText("Moon3");
19452082 diffusemoon3.addMouseListener(new MouseAdapter()
19462083 {
....@@ -1958,7 +2095,7 @@
19582095 });
19592096 presetpanel.add(diffusemoon3);
19602097
1961
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2098
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
19622099 diffusesheen.setToolTipText("Sheen");
19632100 diffusesheen.addMouseListener(new MouseAdapter()
19642101 {
....@@ -1975,7 +2112,7 @@
19752112 });
19762113 presetpanel.add(diffusesheen);
19772114
1978
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2115
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
19792116 rough.setToolTipText("Rough metal");
19802117 rough.addMouseListener(new MouseAdapter()
19812118 {
....@@ -1993,7 +2130,7 @@
19932130 });
19942131 presetpanel.add(rough);
19952132
1996
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2133
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
19972134 rough2.setToolTipText("Medium metal");
19982135 rough2.addMouseListener(new MouseAdapter()
19992136 {
....@@ -2011,7 +2148,7 @@
20112148 });
20122149 presetpanel.add(rough2);
20132150
2014
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2151
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
20152152 shini0.setToolTipText("Shiny");
20162153 shini0.addMouseListener(new MouseAdapter()
20172154 {
....@@ -2029,7 +2166,7 @@
20292166 });
20302167 presetpanel.add(shini0);
20312168
2032
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2169
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
20332170 shini1.setToolTipText("Shiny2");
20342171 shini1.addMouseListener(new MouseAdapter()
20352172 {
....@@ -2047,7 +2184,7 @@
20472184 });
20482185 presetpanel.add(shini1);
20492186
2050
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2187
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
20512188 shini2.setToolTipText("Shiny3");
20522189 shini2.addMouseListener(new MouseAdapter()
20532190 {
....@@ -2065,7 +2202,7 @@
20652202 });
20662203 presetpanel.add(shini2);
20672204
2068
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2205
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
20692206 aniso.setToolTipText("AnisoU");
20702207 aniso.addMouseListener(new MouseAdapter()
20712208 {
....@@ -2083,7 +2220,7 @@
20832220 });
20842221 presetpanel.add(aniso);
20852222
2086
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2223
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
20872224 aniso2.setToolTipText("AnisoV");
20882225 aniso2.addMouseListener(new MouseAdapter()
20892226 {
....@@ -2101,7 +2238,7 @@
21012238 });
21022239 presetpanel.add(aniso2);
21032240
2104
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2241
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
21052242 aniso3.setToolTipText("AnisoUV");
21062243 aniso3.addMouseListener(new MouseAdapter()
21072244 {
....@@ -2119,7 +2256,7 @@
21192256 });
21202257 presetpanel.add(aniso3);
21212258
2122
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2259
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
21232260 velvet0.setToolTipText("Velvet");
21242261 velvet0.addMouseListener(new MouseAdapter()
21252262 {
....@@ -2141,7 +2278,7 @@
21412278 });
21422279 presetpanel.add(velvet0);
21432280
2144
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2281
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
21452282 bump0.setToolTipText("Bump texture");
21462283 bump0.addMouseListener(new MouseAdapter()
21472284 {
....@@ -2160,7 +2297,22 @@
21602297 });
21612298 presetpanel.add(bump0);
21622299
2163
- cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2300
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2301
+ borderShader.setToolTipText("Border fade");
2302
+ borderShader.addMouseListener(new MouseAdapter()
2303
+ {
2304
+ public void mouseClicked(MouseEvent e)
2305
+ {
2306
+ borderfadeField.setFloat(0.5);
2307
+ opacityField.setFloat(0.75);
2308
+
2309
+ materialtouched = true;
2310
+ applySelf();
2311
+ }
2312
+ });
2313
+ presetpanel.add(borderShader);
2314
+
2315
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
21642316 halo.setToolTipText("Halo");
21652317 halo.addMouseListener(new MouseAdapter()
21662318 {
....@@ -2177,7 +2329,7 @@
21772329 });
21782330 presetpanel.add(halo);
21792331
2180
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2332
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
21812333 candle.setToolTipText("Candle");
21822334 candle.addMouseListener(new MouseAdapter()
21832335 {
....@@ -2199,7 +2351,7 @@
21992351 });
22002352 presetpanel.add(candle);
22012353
2202
- cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2354
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
22032355 shadowShader.setToolTipText("Shadow");
22042356 shadowShader.addMouseListener(new MouseAdapter()
22052357 {
....@@ -2234,19 +2386,19 @@
22342386
22352387 cGridBag editBar = new cGridBag().setVertical(false);
22362388
2237
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2389
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
22382390 createMaterialButton.setToolTipText("Create material");
22392391
22402392 /*
22412393 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
22422394 */
22432395
2244
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2396
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
22452397 clearMaterialButton.setToolTipText("Clear material");
22462398
22472399 if (Globals.ADVANCED)
22482400 {
2249
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2401
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
22502402 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
22512403 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
22522404 }
....@@ -2267,9 +2419,20 @@
22672419
22682420 cGridBag huepanel = new cGridBag();
22692421 cGridBag huelabel = new cGridBag();
2270
- skin = GetLabel("icons/hue.png", false);
2271
- skin.fit = true;
2272
- huelabel.add(skin);
2422
+ cLabel hue = GetLabel("icons/hue.png", false);
2423
+ hue.fit = true;
2424
+
2425
+ hue.addMouseListener(new MouseAdapter()
2426
+ {
2427
+ public void mousePressed(MouseEvent e)
2428
+ {
2429
+ int x = e.getX();
2430
+
2431
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2432
+ }
2433
+ });
2434
+
2435
+ huelabel.add(hue);
22732436 huelabel.preferredWidth = 20;
22742437 huepanel.add(new cGridBag()); // Label
22752438 huepanel.add(huelabel); // Field/slider
....@@ -3545,32 +3708,8 @@
35453708
35463709 if (multiplyToggle != null)
35473710 multiplyToggle.setSelected(mat.multiply);
3548
-
3549
- assert (object.projectedVertices != null);
3550
-
3551
- if (object.projectedVertices.length <= 2)
3552
- {
3553
- // Side effect...
3554
- Object3D.cVector2[] keep = object.projectedVertices;
3555
- object.projectedVertices = new Object3D.cVector2[3];
3556
- for (int i = 0; i < 3; i++)
3557
- {
3558
- if (i < keep.length)
3559
- {
3560
- object.projectedVertices[i] = keep[i];
3561
- } else
3562
- {
3563
- object.projectedVertices[i] = new Object3D.cVector2();
3564
- }
3565
- /*
3566
- if(keep.length == 0)
3567
- object.projectedVertices[0] = new Object3D.cVector2();
3568
- else
3569
- object.projectedVertices[0] = keep[0];
3570
- object.projectedVertices[1] = new Object3D.cVector2();
3571
- */
3572
- }
3573
- }
3711
+
3712
+ AllocProjectedVertices(object);
35743713
35753714 SetMaterial(mat, object.projectedVertices);
35763715 }
....@@ -3880,7 +4019,7 @@
38804019 //System.out.println("ObjEditor " + event);
38814020 applySelf0(true);
38824021 //parent.applySelf();
3883
- objEditor.refreshContents();
4022
+ // conflicts with requestFocus objEditor.refreshContents();
38844023 } else if (source == resetButton)
38854024 {
38864025 CameraPane.fullreset = true;
....@@ -4060,12 +4199,15 @@
40604199
40614200 void New()
40624201 {
4063
- while (copy.Size() > 1)
4202
+ while (copy.Size() > 0)
40644203 {
4065
- copy.remove(1);
4204
+ copy.remove(0);
40664205 }
40674206
4207
+ copy.selection.clear();
4208
+
40684209 ResetModel();
4210
+ SetupViews();
40694211 objEditor.refreshContents();
40704212 }
40714213
....@@ -4192,8 +4334,6 @@
41924334 return true;
41934335 }
41944336
4195
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4196
-
41974337 void DeleteVersion()
41984338 {
41994339 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4201,7 +4341,11 @@
42014341 copy.versionlist[i] = copy.versionlist[i+1];
42024342 }
42034343
4204
- CopyChanged();
4344
+ if (copy.versionlist[copy.versionindex] == null)
4345
+ copy.versionindex -= 1;
4346
+
4347
+ if (copy.versionindex != -1)
4348
+ CopyChanged();
42054349
42064350 SetVersionStates();
42074351 }
....@@ -4314,7 +4458,7 @@
43144458 boolean temp = CameraPane.SWITCH;
43154459 CameraPane.SWITCH = false;
43164460
4317
- copy.ExtractBigData(versiontable);
4461
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
43184462
43194463 copy.clear();
43204464
....@@ -4326,7 +4470,7 @@
43264470 copy.add(obj.get(i));
43274471 }
43284472
4329
- copy.RestoreBigData(versiontable);
4473
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
43304474
43314475 CameraPane.SWITCH = temp;
43324476
....@@ -4376,6 +4520,8 @@
43764520 return count;
43774521 }
43784522
4523
+ public cGridBag versionSliderPane;
4524
+
43794525 void SetVersionStates()
43804526 {
43814527 //if (true)
....@@ -4383,21 +4529,36 @@
43834529
43844530 //cRadio tab = GetCurrentTab();
43854531
4386
- restoreButton.setEnabled(copy.versionindex != -1);
4387
- replaceButton.setEnabled(copy.versionindex != -1);
4388
-
4389
- previousVersionButton.setEnabled(copy.versionindex > 0);
4390
- nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4391
-
4392
- deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4393
- copy.versionlist[copy.versionindex + 1] != null);
4394
-
4395
- muteSlider = true;
4396
- versionSlider.setMinimum(0);
4397
- versionSlider.setMaximum(VersionCount() - 1);
4398
- versionSlider.setInteger(copy.versionindex);
4399
- versionSlider.setEnabled(copy.versionindex != -1);
4400
- 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
+ }
44014562 }
44024563
44034564 public boolean PreviousVersion()
....@@ -4455,7 +4616,7 @@
44554616
44564617 public boolean Replace()
44574618 {
4458
- System.err.println("Replace");
4619
+ //System.err.println("Replace");
44594620
44604621 //cRadio tab = GetCurrentTab();
44614622
....@@ -4682,6 +4843,12 @@
46824843 // else
46834844 // applySelf(true);
46844845 // }
4846
+
4847
+ boolean Equal(double a, double b)
4848
+ {
4849
+ return Math.abs(a - b) < 0.001;
4850
+ }
4851
+
46854852 void applySelf0(boolean name)
46864853 {
46874854 if (name)
....@@ -4731,29 +4898,52 @@
47314898 {
47324899 cMaterial mat = copy.material;
47334900
4734
- colorField.SetToolTipValue((mat.color));
4735
- saturationField.SetToolTipValue((mat.modulation));
4736
- metalnessField.SetToolTipValue((mat.metalness));
4737
- diffuseField.SetToolTipValue((mat.diffuse));
4738
- specularField.SetToolTipValue((mat.specular));
4739
- shininessField.SetToolTipValue((mat.shininess));
4740
- shiftField.SetToolTipValue((mat.shift));
4741
- ambientField.SetToolTipValue((mat.ambient));
4742
- lightareaField.SetToolTipValue((mat.lightarea));
4743
- diffusenessField.SetToolTipValue((mat.factor));
4744
- velvetField.SetToolTipValue((mat.velvet));
4745
- sheenField.SetToolTipValue((mat.sheen));
4746
- subsurfaceField.SetToolTipValue((mat.subsurface));
4747
- backlitField.SetToolTipValue((mat.bump));
4748
- anisoField.SetToolTipValue((mat.aniso));
4749
- anisoVField.SetToolTipValue((mat.anisoV));
4750
- cameraField.SetToolTipValue((mat.cameralight));
4751
- selfshadowField.SetToolTipValue((mat.diffuseness));
4752
- shadowField.SetToolTipValue((mat.shadow));
4753
- textureField.SetToolTipValue((mat.texture));
4754
- opacityField.SetToolTipValue((mat.opacity));
4755
- fakedepthField.SetToolTipValue((mat.fakedepth));
4756
- 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));
47574947 }
47584948
47594949 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4788,7 +4978,7 @@
47884978
47894979 public void stateChanged(ChangeEvent e)
47904980 {
4791
- // assert(false);
4981
+ // assert(false);
47924982 if (e.getSource() == versionSlider)
47934983 {
47944984 if (muteSlider)
....@@ -5158,6 +5348,8 @@
51585348
51595349 if (previousVersionButton != null && copy.versionlist != null)
51605350 SetVersionStates();
5351
+
5352
+ cameraView.requestFocusInWindow();
51615353 }
51625354
51635355 static TweenManager tweenManager = new TweenManager();
....@@ -5189,7 +5381,7 @@
51895381 // group = (Composite) group.get(0);
51905382 // }
51915383
5192
- System.out.println("makeSomething of " + thing);
5384
+ //System.out.println("makeSomething of " + thing);
51935385
51945386 /*
51955387 if (deselect && jList != null)
....@@ -5543,6 +5735,7 @@
55435735
55445736 copy.versionlist = readobj.versionlist;
55455737 copy.versionindex = readobj.versionindex;
5738
+ copy.versiontable = readobj.versiontable;
55465739
55475740 if (copy.versionlist == null)
55485741 {
....@@ -5550,7 +5743,7 @@
55505743 copy.versionlist = new Object3D[100];
55515744 copy.versionindex = -1;
55525745
5553
- Save(true);
5746
+ //Save(true);
55545747 }
55555748
55565749 //? SetUndoStates();
....@@ -5898,6 +6091,7 @@
58986091 boolean materialFlushed;
58996092 Object3D latestObject;
59006093
6094
+ cGridBag transformPanel;
59016095 cGridBag XYZPanel;
59026096
59036097 JSplitPane gridPanel;