Normand Briere
2019-08-18 480ad70047e54b2b92f974e6c2ac5a6c0bdc5a5c
ObjEditor.java
....@@ -43,6 +43,50 @@
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
+
75
+ public Composite CreateCameras()
76
+ {
77
+ Composite cams = new cTemplate();
78
+ cams.name = "Cameras";
79
+ copy.insertElementAt(cams, 0);
80
+
81
+ cams.addChild(new Camera());
82
+ cams.addChild(new Camera(1));
83
+ cams.addChild(new Camera(2));
84
+ cams.addChild(new Camera(3));
85
+ cams.addChild(new Camera(4));
86
+
87
+ return cams;
88
+ }
89
+
4690 public cGridBag GetSeparator()
4791 {
4892 cGridBag separator = new cGridBag();
....@@ -54,7 +98,10 @@
5498 cButton GetButton(String name, boolean border)
5599 {
56100 ImageIcon icon = GetIcon(name);
57
- return new cButton(icon, border);
101
+ if (icon != null || name.contains("/"))
102
+ return new cButton(icon, border);
103
+ else
104
+ return new cButton(name, border);
58105 }
59106
60107 cLabel GetLabel(String name, boolean border)
....@@ -75,11 +122,19 @@
75122 return new cCheckBox(icon, border);
76123 }
77124
78
- ImageIcon GetIcon(String name)
125
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
126
+
127
+ static ImageIcon GetIcon(String name)
79128 {
129
+ javax.swing.ImageIcon iconCache = icons.get(name);
130
+ if (iconCache != null)
131
+ {
132
+ return iconCache;
133
+ }
134
+
80135 try
81136 {
82
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
137
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
83138
84139 // if (image.getWidth() > 48 && image.getHeight() > 48)
85140 // {
....@@ -94,10 +149,14 @@
94149 // }
95150
96151 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
152
+
153
+ icons.put(name, icon);
154
+
97155 return icon;
98156 }
99157 catch (Exception e)
100158 {
159
+ //icons.put(name, null);
101160 return null;
102161 }
103162 }
....@@ -347,7 +406,8 @@
347406 //parent = p;
348407
349408 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
350
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
409
+ if (Globals.DEBUG)
410
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
351411 //gd.setFullScreenWindow(this);
352412 //setResizable(false);
353413 //if (!isDisplayable())
....@@ -384,6 +444,9 @@
384444
385445 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
386446
447
+ // This is to refresh the UI of the material panel.
448
+ boolean patchMaterial;
449
+
387450 void SetupMenu()
388451 {
389452 frame.setMenuBar(menuBar = new MenuBar());
....@@ -433,6 +496,8 @@
433496
434497 ChangeListener changeListener = new ChangeListener()
435498 {
499
+ //String name;
500
+
436501 public void stateChanged(ChangeEvent changeEvent)
437502 {
438503 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -451,7 +516,37 @@
451516 // EditSelection(false);
452517 // }
453518
519
+// if (objectPanel.getSelectedIndex() == 4)
520
+// {
521
+// name = copy.skyboxname;
522
+//
523
+// if (name == null)
524
+// {
525
+// name = "";
526
+// }
527
+//
528
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
529
+// copy.skyboxext = "jpg";
530
+// }
531
+// else
532
+// {
533
+// if (name != null)
534
+// {
535
+// if (name.equals(""))
536
+// {
537
+// copy.skyboxname = null;
538
+// copy.skyboxext = null;
539
+// }
540
+// else
541
+// {
542
+// copy.skyboxname = name;
543
+// }
544
+// }
545
+// }
546
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
547
+
454548 // refreshContents(false); // To refresh Info tab
549
+ cameraView.repaint();
455550 }
456551 };
457552 objectPanel.addChangeListener(changeListener);
....@@ -877,18 +972,29 @@
877972 boolean temp = CameraPane.SWITCH;
878973 CameraPane.SWITCH = false;
879974
880
- object.ExtractBigData(versiontable);
975
+ if (Grafreed.grafreed.universe.versiontable == null)
976
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
977
+
978
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
881979 // if (copy == client)
882980
883981 Object3D versions[] = object.versionlist;
982
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
884983 object.versionlist = null;
984
+ object.versiontable = null;
985
+
986
+ Object3D parent = object.parent;
987
+ object.parent = null;
885988
886989 //byte[] compress = Compress(copy);
887990 Object3D compress = (Object3D)Grafreed.clone(object);
888991
889
- object.versionlist = versions;
992
+ object.parent = parent;
890993
891
- object.RestoreBigData(versiontable);
994
+ object.versionlist = versions;
995
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
996
+
997
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
892998
893999 CameraPane.SWITCH = temp;
8941000
....@@ -1227,7 +1333,7 @@
12271333
12281334 //if (copy.pinned)
12291335 {
1230
- pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1336
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
12311337 pinButton.setSelected(copy.pinned);
12321338 cGridBag t = new cGridBag();
12331339 t.preferredWidth = 2;
....@@ -1250,14 +1356,14 @@
12501356
12511357 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12521358 liveCB.setToolTipText("Animate object");
1359
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1360
+ markCB.setToolTipText("Set target transform");
12531361 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12541362 selectableCB.setToolTipText("Make object selectable");
12551363 // Return();
12561364
12571365 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12581366 hideCB.setToolTipText("Hide object");
1259
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1260
- markCB.setToolTipText("As animation target transform");
12611367
12621368 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12631369
....@@ -1459,22 +1565,9 @@
14591565
14601566 if (cam == null || !(copy.get(0) instanceof cGroup))
14611567 {
1462
- System.out.println("CREATE CAMERAS");
1463
- cams = new cTemplate();
1464
- cams.name = "Cameras";
1465
- copy.insertElementAt(cams, 0);
1466
- //cams.parent = copy;
1467
-
1468
- cam = new Camera(); // LA.newVector(3, 2, 1));
1469
- cams.addChild(cam);
1470
- cam = new Camera(1);
1471
- cams.addChild(cam);
1472
- cam = new Camera(2);
1473
- cams.addChild(cam);
1474
- cam = new Camera(3);
1475
- cams.addChild(cam);
1476
- cam = new Camera(4); // Light
1477
- cams.addChild(cam);
1568
+ if (Globals.DEBUG)
1569
+ System.out.println("CREATE CAMERAS");
1570
+ cams = CreateCameras();
14781571 } else
14791572 {
14801573 cams = (cGroup) copy.get(0);
....@@ -1540,6 +1633,45 @@
15401633 //frontView.object = copy;
15411634 //sideView.object = copy;
15421635
1636
+ transformPanel = new cGridBag().setVertical(true);
1637
+
1638
+ cGridBag resetTransformPanel = new cGridBag();
1639
+
1640
+ resetTransformPanel.preferredHeight = 2;
1641
+
1642
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1643
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1644
+ resetTransform.addMouseListener(new MouseAdapter()
1645
+ {
1646
+ public void mouseClicked(MouseEvent e)
1647
+ {
1648
+ ResetTransform();
1649
+ }
1650
+ });
1651
+ resetTransformPanel.add(resetTransform);
1652
+
1653
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1654
+ resetTransform.setToolTipText("Reset Translation only");
1655
+ resetTransform.addMouseListener(new MouseAdapter()
1656
+ {
1657
+ public void mouseClicked(MouseEvent e)
1658
+ {
1659
+ ResetTransform(1);
1660
+ }
1661
+ });
1662
+ resetTransformPanel.add(resetTransform);
1663
+
1664
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1665
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1666
+ resetTransform.addMouseListener(new MouseAdapter()
1667
+ {
1668
+ public void mouseClicked(MouseEvent e)
1669
+ {
1670
+ ResetTransform(2);
1671
+ }
1672
+ });
1673
+ resetTransformPanel.add(resetTransform);
1674
+
15431675 XYZPanel = new cGridBag().setVertical(true);
15441676 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15451677
....@@ -1549,6 +1681,9 @@
15491681 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15501682 //XYZPanel.setName("XYZ");
15511683
1684
+ transformPanel.add(resetTransformPanel);
1685
+ transformPanel.add(XYZPanel);
1686
+
15521687 /*
15531688 gridPanel = new JPanel(); //new BorderLayout());
15541689 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1556,12 +1691,12 @@
15561691 gridPanel.add(cameraView);
15571692 gridPanel.add(XYZPanel);
15581693 */
1559
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1560
- gridPanel.setContinuousLayout(true);
1561
- gridPanel.setOneTouchExpandable(true);
1562
- gridPanel.setDividerLocation(1.0);
1563
- gridPanel.setDividerSize(9);
1564
- gridPanel.setResizeWeight(0.85);
1694
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1695
+// gridPanel.setContinuousLayout(true);
1696
+// gridPanel.setOneTouchExpandable(true);
1697
+// gridPanel.setDividerLocation(1.0);
1698
+// gridPanel.setDividerSize(9);
1699
+// gridPanel.setResizeWeight(0.85);
15651700
15661701 // aConstraints.weighty = 0;
15671702 //System.out.println("THIS = " + this);
....@@ -1584,30 +1719,34 @@
15841719
15851720 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15861721 //tmp.setName("Edit");
1587
- objectPanel.add(materialPanel);
1588
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1589
- objectPanel.setToolTipTextAt(0, "Material");
1590
-
1722
+ objectPanel.add(skyboxPanel);
1723
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1724
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1725
+
15911726 objectPanel.add(toolboxPanel);
15921727 objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
15931728 objectPanel.setToolTipTextAt(1, "Objects & textures");
15941729
1595
- objectPanel.add(skyboxPanel);
1596
- objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1597
- objectPanel.setToolTipTextAt(2, "Backgrounds");
1598
-
1730
+ objectPanel.add(materialPanel);
1731
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1732
+ objectPanel.setToolTipTextAt(2, "Material");
1733
+
15991734 // JPanel north = new JPanel(new BorderLayout());
16001735 // north.setName("Edit");
16011736 // north.add(ctrlPanel, BorderLayout.NORTH);
16021737 // objectPanel.add(north);
16031738 objectPanel.add(editPanel);
1604
- objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1739
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
16051740 objectPanel.setToolTipTextAt(3, "Edit controls");
16061741
1607
- objectPanel.add(XYZPanel);
1742
+ objectPanel.add(transformPanel);
16081743 objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1609
- objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1744
+ objectPanel.setToolTipTextAt(4, "TRS transform");
16101745
1746
+ patchMaterial = true;
1747
+ cameraView.patchMaterial = this;
1748
+ objectPanel.setSelectedIndex(2);
1749
+
16111750 /*
16121751 aConstraints.gridx = 0;
16131752 aConstraints.gridwidth = 1;
....@@ -1627,7 +1766,7 @@
16271766 scrollpane.addMouseWheelListener(this); // Default not fast enough
16281767
16291768 /*JTabbedPane*/ scenePanel = new cGridBag();
1630
- scenePanel.preferredWidth = 5;
1769
+ scenePanel.preferredWidth = 6;
16311770
16321771 JTabbedPane tabbedPane = new JTabbedPane();
16331772 tabbedPane.add(scrollpane);
....@@ -1638,17 +1777,52 @@
16381777
16391778 AddOptions(optionsPanel); //, aConstraints);
16401779
1641
- tabbedPane.add(optionsPanel);
1642
-
16431780 tabbedPane.add(FSPane = new cFileSystemPane(this));
16441781
1782
+ tabbedPane.add(optionsPanel);
1783
+
16451784 scenePanel.add(tabbedPane);
16461785
1647
- //if (Globals.ADVANCED)
1648
- tabbedPane.add(infoPanel);
1649
- tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1650
- tabbedPane.setToolTipTextAt(3, "Information");
1786
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1787
+ creditsPanel.setName("Credits");
16511788
1789
+ cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1790
+ creditsPanel.add(ogaLabel);
1791
+
1792
+ cButton opengameartButton;
1793
+ creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1794
+ opengameartButton.setToolTipText("https://opengameart.org");
1795
+
1796
+ opengameartButton.addMouseListener(new MouseAdapter()
1797
+ {
1798
+ public void mouseClicked(MouseEvent e)
1799
+ {
1800
+ try
1801
+ {
1802
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1803
+ } catch (Exception e1)
1804
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1805
+ {
1806
+ e1.printStackTrace();
1807
+ }
1808
+ }
1809
+ });
1810
+
1811
+ for (int i=10; --i>=0;)
1812
+ {
1813
+ creditsPanel.add(new cGridBag());
1814
+ }
1815
+
1816
+ tabbedPane.add(creditsPanel);
1817
+ tabbedPane.setToolTipTextAt(3, "Credits");
1818
+
1819
+ if (Globals.ADVANCED)
1820
+ {
1821
+ tabbedPane.add(infoPanel);
1822
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1823
+ tabbedPane.setToolTipTextAt(4, "Information");
1824
+ }
1825
+
16521826 /*
16531827 cTree jTree = new cTree(null);
16541828 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1669,13 +1843,13 @@
16691843 jtp.add(tree);
16701844 */
16711845
1672
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1673
- bigPanel.setContinuousLayout(true);
1674
- bigPanel.setOneTouchExpandable(true);
1675
- bigPanel.setDividerLocation(0.8);
1676
- bigPanel.setDividerSize(15);
1677
- bigPanel.setResizeWeight(0.15);
1678
- bigPanel.setName("Scene");
1846
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1847
+// bigPanel.setContinuousLayout(true);
1848
+// bigPanel.setOneTouchExpandable(true);
1849
+// bigPanel.setDividerLocation(0.8);
1850
+// bigPanel.setDividerSize(15);
1851
+// bigPanel.setResizeWeight(0.15);
1852
+// bigPanel.setName("Scene");
16791853
16801854 //bigPanel.setLayout(new BorderLayout());
16811855 //bigPanel.setSize(new Dimension(10,10));
....@@ -1745,7 +1919,7 @@
17451919
17461920 frame.getContentPane().setLayout(new BorderLayout());
17471921 /**/
1748
- JTabbedPane worldPane = new JTabbedPane();
1922
+ //JTabbedPane worldPane = new JTabbedPane();
17491923 //worldPane.add(bigPanel);
17501924 //worldPane.add(worldPanel);
17511925 /**/
....@@ -1759,7 +1933,7 @@
17591933
17601934 cameraView.requestFocusInWindow();
17611935
1762
- gridPanel.setDividerLocation(1.0);
1936
+// gridPanel.setDividerLocation(1.0);
17631937
17641938 frame.validate();
17651939
....@@ -1794,7 +1968,7 @@
17941968 {
17951969 cGridBag presetpanel = new cGridBag().setVertical(true);
17961970
1797
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1971
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
17981972 skin.setToolTipText("Skin");
17991973 skin.addMouseListener(new MouseAdapter()
18001974 {
....@@ -1805,7 +1979,15 @@
18051979
18061980 // Skin
18071981 colorField.setFloat(material.color);
1808
- saturationField.setFloat(material.modulation);
1982
+ float saturation = material.modulation;
1983
+
1984
+ if (!cameraView.Skinshader)
1985
+ {
1986
+ saturation /= 1.5;
1987
+ }
1988
+
1989
+ saturationField.setFloat(saturation);
1990
+
18091991 subsurfaceField.setFloat(material.subsurface);
18101992 selfshadowField.setFloat(material.diffuseness);
18111993 diffusenessField.setFloat(material.factor);
....@@ -1824,7 +2006,7 @@
18242006 });
18252007 presetpanel.add(skin);
18262008
1827
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2009
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
18282010 lambert.setToolTipText("Diffuse");
18292011 lambert.addMouseListener(new MouseAdapter()
18302012 {
....@@ -1842,7 +2024,7 @@
18422024 });
18432025 presetpanel.add(lambert);
18442026
1845
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2027
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
18462028 diffuse2.setToolTipText("Diffuse2");
18472029 diffuse2.addMouseListener(new MouseAdapter()
18482030 {
....@@ -1860,7 +2042,7 @@
18602042 });
18612043 presetpanel.add(diffuse2);
18622044
1863
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2045
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
18642046 diffusemoon.setToolTipText("Moon");
18652047 diffusemoon.addMouseListener(new MouseAdapter()
18662048 {
....@@ -1878,7 +2060,7 @@
18782060 });
18792061 presetpanel.add(diffusemoon);
18802062
1881
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2063
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
18822064 diffusemoon2.setToolTipText("Moon2");
18832065 diffusemoon2.addMouseListener(new MouseAdapter()
18842066 {
....@@ -1896,7 +2078,7 @@
18962078 });
18972079 presetpanel.add(diffusemoon2);
18982080
1899
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2081
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
19002082 diffusemoon3.setToolTipText("Moon3");
19012083 diffusemoon3.addMouseListener(new MouseAdapter()
19022084 {
....@@ -1914,7 +2096,7 @@
19142096 });
19152097 presetpanel.add(diffusemoon3);
19162098
1917
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2099
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
19182100 diffusesheen.setToolTipText("Sheen");
19192101 diffusesheen.addMouseListener(new MouseAdapter()
19202102 {
....@@ -1931,7 +2113,7 @@
19312113 });
19322114 presetpanel.add(diffusesheen);
19332115
1934
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2116
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
19352117 rough.setToolTipText("Rough metal");
19362118 rough.addMouseListener(new MouseAdapter()
19372119 {
....@@ -1949,7 +2131,7 @@
19492131 });
19502132 presetpanel.add(rough);
19512133
1952
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2134
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
19532135 rough2.setToolTipText("Medium metal");
19542136 rough2.addMouseListener(new MouseAdapter()
19552137 {
....@@ -1967,7 +2149,7 @@
19672149 });
19682150 presetpanel.add(rough2);
19692151
1970
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2152
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
19712153 shini0.setToolTipText("Shiny");
19722154 shini0.addMouseListener(new MouseAdapter()
19732155 {
....@@ -1985,7 +2167,7 @@
19852167 });
19862168 presetpanel.add(shini0);
19872169
1988
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2170
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
19892171 shini1.setToolTipText("Shiny2");
19902172 shini1.addMouseListener(new MouseAdapter()
19912173 {
....@@ -2003,7 +2185,7 @@
20032185 });
20042186 presetpanel.add(shini1);
20052187
2006
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2188
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
20072189 shini2.setToolTipText("Shiny3");
20082190 shini2.addMouseListener(new MouseAdapter()
20092191 {
....@@ -2021,7 +2203,7 @@
20212203 });
20222204 presetpanel.add(shini2);
20232205
2024
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2206
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
20252207 aniso.setToolTipText("AnisoU");
20262208 aniso.addMouseListener(new MouseAdapter()
20272209 {
....@@ -2039,7 +2221,7 @@
20392221 });
20402222 presetpanel.add(aniso);
20412223
2042
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2224
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
20432225 aniso2.setToolTipText("AnisoV");
20442226 aniso2.addMouseListener(new MouseAdapter()
20452227 {
....@@ -2057,7 +2239,7 @@
20572239 });
20582240 presetpanel.add(aniso2);
20592241
2060
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2242
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
20612243 aniso3.setToolTipText("AnisoUV");
20622244 aniso3.addMouseListener(new MouseAdapter()
20632245 {
....@@ -2075,7 +2257,7 @@
20752257 });
20762258 presetpanel.add(aniso3);
20772259
2078
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2260
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
20792261 velvet0.setToolTipText("Velvet");
20802262 velvet0.addMouseListener(new MouseAdapter()
20812263 {
....@@ -2097,7 +2279,7 @@
20972279 });
20982280 presetpanel.add(velvet0);
20992281
2100
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2282
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
21012283 bump0.setToolTipText("Bump texture");
21022284 bump0.addMouseListener(new MouseAdapter()
21032285 {
....@@ -2116,7 +2298,22 @@
21162298 });
21172299 presetpanel.add(bump0);
21182300
2119
- cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2301
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2302
+ borderShader.setToolTipText("Border fade");
2303
+ borderShader.addMouseListener(new MouseAdapter()
2304
+ {
2305
+ public void mouseClicked(MouseEvent e)
2306
+ {
2307
+ borderfadeField.setFloat(0.5);
2308
+ opacityField.setFloat(0.75);
2309
+
2310
+ materialtouched = true;
2311
+ applySelf();
2312
+ }
2313
+ });
2314
+ presetpanel.add(borderShader);
2315
+
2316
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
21202317 halo.setToolTipText("Halo");
21212318 halo.addMouseListener(new MouseAdapter()
21222319 {
....@@ -2133,7 +2330,7 @@
21332330 });
21342331 presetpanel.add(halo);
21352332
2136
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2333
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
21372334 candle.setToolTipText("Candle");
21382335 candle.addMouseListener(new MouseAdapter()
21392336 {
....@@ -2155,7 +2352,7 @@
21552352 });
21562353 presetpanel.add(candle);
21572354
2158
- cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2355
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
21592356 shadowShader.setToolTipText("Shadow");
21602357 shadowShader.addMouseListener(new MouseAdapter()
21612358 {
....@@ -2190,19 +2387,19 @@
21902387
21912388 cGridBag editBar = new cGridBag().setVertical(false);
21922389
2193
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2390
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
21942391 createMaterialButton.setToolTipText("Create material");
21952392
21962393 /*
21972394 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
21982395 */
21992396
2200
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2397
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
22012398 clearMaterialButton.setToolTipText("Clear material");
22022399
22032400 if (Globals.ADVANCED)
22042401 {
2205
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2402
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
22062403 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
22072404 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
22082405 }
....@@ -2223,9 +2420,20 @@
22232420
22242421 cGridBag huepanel = new cGridBag();
22252422 cGridBag huelabel = new cGridBag();
2226
- skin = GetLabel("icons/hue.png", false);
2227
- skin.fit = true;
2228
- huelabel.add(skin);
2423
+ cLabel hue = GetLabel("icons/hue.png", false);
2424
+ hue.fit = true;
2425
+
2426
+ hue.addMouseListener(new MouseAdapter()
2427
+ {
2428
+ public void mousePressed(MouseEvent e)
2429
+ {
2430
+ int x = e.getX();
2431
+
2432
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2433
+ }
2434
+ });
2435
+
2436
+ huelabel.add(hue);
22292437 huelabel.preferredWidth = 20;
22302438 huepanel.add(new cGridBag()); // Label
22312439 huepanel.add(huelabel); // Field/slider
....@@ -3501,32 +3709,8 @@
35013709
35023710 if (multiplyToggle != null)
35033711 multiplyToggle.setSelected(mat.multiply);
3504
-
3505
- assert (object.projectedVertices != null);
3506
-
3507
- if (object.projectedVertices.length <= 2)
3508
- {
3509
- // Side effect...
3510
- Object3D.cVector2[] keep = object.projectedVertices;
3511
- object.projectedVertices = new Object3D.cVector2[3];
3512
- for (int i = 0; i < 3; i++)
3513
- {
3514
- if (i < keep.length)
3515
- {
3516
- object.projectedVertices[i] = keep[i];
3517
- } else
3518
- {
3519
- object.projectedVertices[i] = new Object3D.cVector2();
3520
- }
3521
- /*
3522
- if(keep.length == 0)
3523
- object.projectedVertices[0] = new Object3D.cVector2();
3524
- else
3525
- object.projectedVertices[0] = keep[0];
3526
- object.projectedVertices[1] = new Object3D.cVector2();
3527
- */
3528
- }
3529
- }
3712
+
3713
+ AllocProjectedVertices(object);
35303714
35313715 SetMaterial(mat, object.projectedVertices);
35323716 }
....@@ -3836,7 +4020,7 @@
38364020 //System.out.println("ObjEditor " + event);
38374021 applySelf0(true);
38384022 //parent.applySelf();
3839
- objEditor.refreshContents();
4023
+ // conflicts with requestFocus objEditor.refreshContents();
38404024 } else if (source == resetButton)
38414025 {
38424026 CameraPane.fullreset = true;
....@@ -4016,11 +4200,18 @@
40164200
40174201 void New()
40184202 {
4019
- while (copy.Size() > 1)
4203
+ while (copy.Size() > 0)
40204204 {
4021
- copy.remove(1);
4205
+ copy.remove(0);
40224206 }
40234207
4208
+ copy.selection.clear();
4209
+
4210
+ if (copy == Grafreed.grafreed.universe)
4211
+ {
4212
+ CreateCameras();
4213
+ cameraView.SetCamera(GetCamera(copy, 0));
4214
+ }
40244215 ResetModel();
40254216 objEditor.refreshContents();
40264217 }
....@@ -4129,7 +4320,7 @@
41294320 {
41304321 //Save(true);
41314322 Replace();
4132
- SetUndoStates();
4323
+ SetVersionStates();
41334324 }
41344325
41354326 private boolean Equal(byte[] compress, byte[] name)
....@@ -4148,8 +4339,6 @@
41484339 return true;
41494340 }
41504341
4151
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4152
-
41534342 void DeleteVersion()
41544343 {
41554344 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4157,9 +4346,13 @@
41574346 copy.versionlist[i] = copy.versionlist[i+1];
41584347 }
41594348
4160
- CopyChanged();
4349
+ if (copy.versionlist[copy.versionindex] == null)
4350
+ copy.versionindex -= 1;
41614351
4162
- SetUndoStates();
4352
+ if (copy.versionindex != -1)
4353
+ CopyChanged();
4354
+
4355
+ SetVersionStates();
41634356 }
41644357
41654358 public boolean Save(boolean user)
....@@ -4205,7 +4398,7 @@
42054398 // copy.versionlist[i] = null;
42064399 // }
42074400
4208
- SetUndoStates();
4401
+ SetVersionStates();
42094402
42104403 // test save
42114404 if (false)
....@@ -4265,12 +4458,12 @@
42654458 {
42664459 Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
42674460
4268
- SetUndoStates();
4461
+ SetVersionStates();
42694462
42704463 boolean temp = CameraPane.SWITCH;
42714464 CameraPane.SWITCH = false;
42724465
4273
- copy.ExtractBigData(versiontable);
4466
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
42744467
42754468 copy.clear();
42764469
....@@ -4282,7 +4475,7 @@
42824475 copy.add(obj.get(i));
42834476 }
42844477
4285
- copy.RestoreBigData(versiontable);
4478
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
42864479
42874480 CameraPane.SWITCH = temp;
42884481
....@@ -4332,28 +4525,45 @@
43324525 return count;
43334526 }
43344527
4335
- void SetUndoStates()
4528
+ public cGridBag versionSliderPane;
4529
+
4530
+ void SetVersionStates()
43364531 {
43374532 //if (true)
43384533 // return;
43394534
43404535 //cRadio tab = GetCurrentTab();
43414536
4342
- restoreButton.setEnabled(copy.versionindex != -1);
4343
- replaceButton.setEnabled(copy.versionindex != -1);
4344
-
4345
- previousVersionButton.setEnabled(copy.versionindex > 0);
4346
- nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4347
-
4348
- deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4349
- copy.versionlist[copy.versionindex + 1] != null);
4350
-
4351
- muteSlider = true;
4352
- versionSlider.setMinimum(0);
4353
- versionSlider.setMaximum(VersionCount() - 1);
4354
- versionSlider.setInteger(copy.versionindex);
4355
- versionSlider.setEnabled(copy.versionindex != -1);
4356
- muteSlider = false;
4537
+ if (copy.versionlist == null)
4538
+ {
4539
+ saveVersionButton.setEnabled(false);
4540
+ restoreButton.setEnabled(false);
4541
+ replaceButton.setEnabled(false);
4542
+ previousVersionButton.setEnabled(false);
4543
+ nextVersionButton.setEnabled(false);
4544
+ deleteVersionButton.setEnabled(false);
4545
+ versionSliderPane.setVisible(false);
4546
+ }
4547
+ else
4548
+ {
4549
+ restoreButton.setEnabled(copy.versionindex != -1);
4550
+ replaceButton.setEnabled(copy.versionindex != -1);
4551
+
4552
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4553
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4554
+
4555
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4556
+ //copy.versionlist[copy.versionindex + 1] != null);
4557
+
4558
+ muteSlider = true;
4559
+ versionSlider.setMinimum(0);
4560
+ versionSlider.setMaximum(VersionCount() - 1);
4561
+ versionSlider.setInteger(copy.versionindex);
4562
+ versionSlider.setEnabled(copy.versionindex != -1);
4563
+ muteSlider = false;
4564
+
4565
+ versionSliderPane.setVisible(true);
4566
+ }
43574567 }
43584568
43594569 public boolean PreviousVersion()
....@@ -4411,7 +4621,7 @@
44114621
44124622 public boolean Replace()
44134623 {
4414
- System.err.println("Replace");
4624
+ //System.err.println("Replace");
44154625
44164626 //cRadio tab = GetCurrentTab();
44174627
....@@ -4638,6 +4848,12 @@
46384848 // else
46394849 // applySelf(true);
46404850 // }
4851
+
4852
+ boolean Equal(double a, double b)
4853
+ {
4854
+ return Math.abs(a - b) < 0.001;
4855
+ }
4856
+
46414857 void applySelf0(boolean name)
46424858 {
46434859 if (name)
....@@ -4687,29 +4903,52 @@
46874903 {
46884904 cMaterial mat = copy.material;
46894905
4690
- colorField.SetToolTipValue((mat.color));
4691
- saturationField.SetToolTipValue((mat.modulation));
4692
- metalnessField.SetToolTipValue((mat.metalness));
4693
- diffuseField.SetToolTipValue((mat.diffuse));
4694
- specularField.SetToolTipValue((mat.specular));
4695
- shininessField.SetToolTipValue((mat.shininess));
4696
- shiftField.SetToolTipValue((mat.shift));
4697
- ambientField.SetToolTipValue((mat.ambient));
4698
- lightareaField.SetToolTipValue((mat.lightarea));
4699
- diffusenessField.SetToolTipValue((mat.factor));
4700
- velvetField.SetToolTipValue((mat.velvet));
4701
- sheenField.SetToolTipValue((mat.sheen));
4702
- subsurfaceField.SetToolTipValue((mat.subsurface));
4703
- backlitField.SetToolTipValue((mat.bump));
4704
- anisoField.SetToolTipValue((mat.aniso));
4705
- anisoVField.SetToolTipValue((mat.anisoV));
4706
- cameraField.SetToolTipValue((mat.cameralight));
4707
- selfshadowField.SetToolTipValue((mat.diffuseness));
4708
- shadowField.SetToolTipValue((mat.shadow));
4709
- textureField.SetToolTipValue((mat.texture));
4710
- opacityField.SetToolTipValue((mat.opacity));
4711
- fakedepthField.SetToolTipValue((mat.fakedepth));
4712
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4906
+ if (!Equal(colorField.getFloat(), mat.color))
4907
+ colorField.SetToolTipValue((mat.color));
4908
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4909
+ saturationField.SetToolTipValue((mat.modulation));
4910
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4911
+ metalnessField.SetToolTipValue((mat.metalness));
4912
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4913
+ diffuseField.SetToolTipValue((mat.diffuse));
4914
+ if (!Equal(specularField.getFloat(), mat.specular))
4915
+ specularField.SetToolTipValue((mat.specular));
4916
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4917
+ shininessField.SetToolTipValue((mat.shininess));
4918
+ if (!Equal(shiftField.getFloat(), mat.shift))
4919
+ shiftField.SetToolTipValue((mat.shift));
4920
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4921
+ ambientField.SetToolTipValue((mat.ambient));
4922
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4923
+ lightareaField.SetToolTipValue((mat.lightarea));
4924
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4925
+ diffusenessField.SetToolTipValue((mat.factor));
4926
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4927
+ velvetField.SetToolTipValue((mat.velvet));
4928
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4929
+ sheenField.SetToolTipValue((mat.sheen));
4930
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4931
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4932
+ if (!Equal(backlitField.getFloat(), mat.bump))
4933
+ backlitField.SetToolTipValue((mat.bump));
4934
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4935
+ anisoField.SetToolTipValue((mat.aniso));
4936
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4937
+ anisoVField.SetToolTipValue((mat.anisoV));
4938
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4939
+ cameraField.SetToolTipValue((mat.cameralight));
4940
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4941
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4942
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4943
+ shadowField.SetToolTipValue((mat.shadow));
4944
+ if (!Equal(textureField.getFloat(), mat.texture))
4945
+ textureField.SetToolTipValue((mat.texture));
4946
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4947
+ opacityField.SetToolTipValue((mat.opacity));
4948
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4949
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4950
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4951
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
47134952 }
47144953
47154954 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4744,11 +4983,13 @@
47444983
47454984 public void stateChanged(ChangeEvent e)
47464985 {
4747
- // assert(false);
4986
+ // assert(false);
47484987 if (e.getSource() == versionSlider)
47494988 {
47504989 if (muteSlider)
47514990 return;
4991
+
4992
+ Replace();
47524993
47534994 int version = versionSlider.getInteger();
47544995
....@@ -5111,7 +5352,9 @@
51115352 }
51125353
51135354 if (previousVersionButton != null && copy.versionlist != null)
5114
- SetUndoStates();
5355
+ SetVersionStates();
5356
+
5357
+ cameraView.requestFocusInWindow();
51155358 }
51165359
51175360 static TweenManager tweenManager = new TweenManager();
....@@ -5143,7 +5386,7 @@
51435386 // group = (Composite) group.get(0);
51445387 // }
51455388
5146
- System.out.println("makeSomething of " + thing);
5389
+ //System.out.println("makeSomething of " + thing);
51475390
51485391 /*
51495392 if (deselect && jList != null)
....@@ -5497,6 +5740,7 @@
54975740
54985741 copy.versionlist = readobj.versionlist;
54995742 copy.versionindex = readobj.versionindex;
5743
+ copy.versiontable = readobj.versiontable;
55005744
55015745 if (copy.versionlist == null)
55025746 {
....@@ -5504,7 +5748,7 @@
55045748 copy.versionlist = new Object3D[100];
55055749 copy.versionindex = -1;
55065750
5507
- Save(true);
5751
+ //Save(true);
55085752 }
55095753
55105754 //? SetUndoStates();
....@@ -5596,6 +5840,8 @@
55965840
55975841 void save()
55985842 {
5843
+ Replace();
5844
+
55995845 if (lastname == null)
56005846 {
56015847 return;
....@@ -5850,6 +6096,7 @@
58506096 boolean materialFlushed;
58516097 Object3D latestObject;
58526098
6099
+ cGridBag transformPanel;
58536100 cGridBag XYZPanel;
58546101
58556102 JSplitPane gridPanel;