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,7 +496,7 @@
433496
434497 ChangeListener changeListener = new ChangeListener()
435498 {
436
- String name;
499
+ //String name;
437500
438501 public void stateChanged(ChangeEvent changeEvent)
439502 {
....@@ -453,33 +516,34 @@
453516 // EditSelection(false);
454517 // }
455518
456
- if (objectPanel.getSelectedIndex() == 4)
457
- {
458
- name = copy.skyboxname;
459
-
460
- if (name == null)
461
- {
462
- name = "";
463
- }
464
-
465
- copy.skyboxname = "cubemaps/default-skyboxes/rgb";
466
- copy.skyboxext = "jpg";
467
- }
468
- else
469
- {
470
- if (name != null)
471
- {
472
- if (name.equals(""))
473
- {
474
- copy.skyboxname = null;
475
- copy.skyboxext = null;
476
- }
477
- else
478
- {
479
- copy.skyboxname = name;
480
- }
481
- }
482
- }
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;
483547
484548 // refreshContents(false); // To refresh Info tab
485549 cameraView.repaint();
....@@ -908,18 +972,29 @@
908972 boolean temp = CameraPane.SWITCH;
909973 CameraPane.SWITCH = false;
910974
911
- 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);
912979 // if (copy == client)
913980
914981 Object3D versions[] = object.versionlist;
982
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
915983 object.versionlist = null;
984
+ object.versiontable = null;
985
+
986
+ Object3D parent = object.parent;
987
+ object.parent = null;
916988
917989 //byte[] compress = Compress(copy);
918990 Object3D compress = (Object3D)Grafreed.clone(object);
919991
920
- object.versionlist = versions;
992
+ object.parent = parent;
921993
922
- object.RestoreBigData(versiontable);
994
+ object.versionlist = versions;
995
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
996
+
997
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
923998
924999 CameraPane.SWITCH = temp;
9251000
....@@ -1258,7 +1333,7 @@
12581333
12591334 //if (copy.pinned)
12601335 {
1261
- pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1336
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
12621337 pinButton.setSelected(copy.pinned);
12631338 cGridBag t = new cGridBag();
12641339 t.preferredWidth = 2;
....@@ -1281,14 +1356,14 @@
12811356
12821357 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12831358 liveCB.setToolTipText("Animate object");
1359
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1360
+ markCB.setToolTipText("Set target transform");
12841361 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12851362 selectableCB.setToolTipText("Make object selectable");
12861363 // Return();
12871364
12881365 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12891366 hideCB.setToolTipText("Hide object");
1290
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1291
- markCB.setToolTipText("As animation target transform");
12921367
12931368 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12941369
....@@ -1490,22 +1565,9 @@
14901565
14911566 if (cam == null || !(copy.get(0) instanceof cGroup))
14921567 {
1493
- System.out.println("CREATE CAMERAS");
1494
- cams = new cTemplate();
1495
- cams.name = "Cameras";
1496
- copy.insertElementAt(cams, 0);
1497
- //cams.parent = copy;
1498
-
1499
- cam = new Camera(); // LA.newVector(3, 2, 1));
1500
- cams.addChild(cam);
1501
- cam = new Camera(1);
1502
- cams.addChild(cam);
1503
- cam = new Camera(2);
1504
- cams.addChild(cam);
1505
- cam = new Camera(3);
1506
- cams.addChild(cam);
1507
- cam = new Camera(4); // Light
1508
- cams.addChild(cam);
1568
+ if (Globals.DEBUG)
1569
+ System.out.println("CREATE CAMERAS");
1570
+ cams = CreateCameras();
15091571 } else
15101572 {
15111573 cams = (cGroup) copy.get(0);
....@@ -1571,6 +1633,45 @@
15711633 //frontView.object = copy;
15721634 //sideView.object = copy;
15731635
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
+
15741675 XYZPanel = new cGridBag().setVertical(true);
15751676 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15761677
....@@ -1580,6 +1681,9 @@
15801681 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15811682 //XYZPanel.setName("XYZ");
15821683
1684
+ transformPanel.add(resetTransformPanel);
1685
+ transformPanel.add(XYZPanel);
1686
+
15831687 /*
15841688 gridPanel = new JPanel(); //new BorderLayout());
15851689 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1587,12 +1691,12 @@
15871691 gridPanel.add(cameraView);
15881692 gridPanel.add(XYZPanel);
15891693 */
1590
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1591
- gridPanel.setContinuousLayout(true);
1592
- gridPanel.setOneTouchExpandable(true);
1593
- gridPanel.setDividerLocation(1.0);
1594
- gridPanel.setDividerSize(9);
1595
- 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);
15961700
15971701 // aConstraints.weighty = 0;
15981702 //System.out.println("THIS = " + this);
....@@ -1615,30 +1719,34 @@
16151719
16161720 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
16171721 //tmp.setName("Edit");
1618
- objectPanel.add(materialPanel);
1619
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1620
- objectPanel.setToolTipTextAt(0, "Material");
1621
-
1722
+ objectPanel.add(skyboxPanel);
1723
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1724
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1725
+
16221726 objectPanel.add(toolboxPanel);
16231727 objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
16241728 objectPanel.setToolTipTextAt(1, "Objects & textures");
16251729
1626
- objectPanel.add(skyboxPanel);
1627
- objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1628
- objectPanel.setToolTipTextAt(2, "Backgrounds");
1629
-
1730
+ objectPanel.add(materialPanel);
1731
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1732
+ objectPanel.setToolTipTextAt(2, "Material");
1733
+
16301734 // JPanel north = new JPanel(new BorderLayout());
16311735 // north.setName("Edit");
16321736 // north.add(ctrlPanel, BorderLayout.NORTH);
16331737 // objectPanel.add(north);
16341738 objectPanel.add(editPanel);
1635
- objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1739
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
16361740 objectPanel.setToolTipTextAt(3, "Edit controls");
16371741
1638
- objectPanel.add(XYZPanel);
1742
+ objectPanel.add(transformPanel);
16391743 objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1640
- objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1744
+ objectPanel.setToolTipTextAt(4, "TRS transform");
16411745
1746
+ patchMaterial = true;
1747
+ cameraView.patchMaterial = this;
1748
+ objectPanel.setSelectedIndex(2);
1749
+
16421750 /*
16431751 aConstraints.gridx = 0;
16441752 aConstraints.gridwidth = 1;
....@@ -1658,7 +1766,7 @@
16581766 scrollpane.addMouseWheelListener(this); // Default not fast enough
16591767
16601768 /*JTabbedPane*/ scenePanel = new cGridBag();
1661
- scenePanel.preferredWidth = 5;
1769
+ scenePanel.preferredWidth = 6;
16621770
16631771 JTabbedPane tabbedPane = new JTabbedPane();
16641772 tabbedPane.add(scrollpane);
....@@ -1669,17 +1777,52 @@
16691777
16701778 AddOptions(optionsPanel); //, aConstraints);
16711779
1672
- tabbedPane.add(optionsPanel);
1673
-
16741780 tabbedPane.add(FSPane = new cFileSystemPane(this));
16751781
1782
+ tabbedPane.add(optionsPanel);
1783
+
16761784 scenePanel.add(tabbedPane);
16771785
1678
- //if (Globals.ADVANCED)
1679
- tabbedPane.add(infoPanel);
1680
- tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1681
- tabbedPane.setToolTipTextAt(3, "Information");
1786
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1787
+ creditsPanel.setName("Credits");
16821788
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
+
16831826 /*
16841827 cTree jTree = new cTree(null);
16851828 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1700,13 +1843,13 @@
17001843 jtp.add(tree);
17011844 */
17021845
1703
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1704
- bigPanel.setContinuousLayout(true);
1705
- bigPanel.setOneTouchExpandable(true);
1706
- bigPanel.setDividerLocation(0.8);
1707
- bigPanel.setDividerSize(15);
1708
- bigPanel.setResizeWeight(0.15);
1709
- 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");
17101853
17111854 //bigPanel.setLayout(new BorderLayout());
17121855 //bigPanel.setSize(new Dimension(10,10));
....@@ -1776,7 +1919,7 @@
17761919
17771920 frame.getContentPane().setLayout(new BorderLayout());
17781921 /**/
1779
- JTabbedPane worldPane = new JTabbedPane();
1922
+ //JTabbedPane worldPane = new JTabbedPane();
17801923 //worldPane.add(bigPanel);
17811924 //worldPane.add(worldPanel);
17821925 /**/
....@@ -1790,7 +1933,7 @@
17901933
17911934 cameraView.requestFocusInWindow();
17921935
1793
- gridPanel.setDividerLocation(1.0);
1936
+// gridPanel.setDividerLocation(1.0);
17941937
17951938 frame.validate();
17961939
....@@ -1825,7 +1968,7 @@
18251968 {
18261969 cGridBag presetpanel = new cGridBag().setVertical(true);
18271970
1828
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1971
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
18291972 skin.setToolTipText("Skin");
18301973 skin.addMouseListener(new MouseAdapter()
18311974 {
....@@ -1836,7 +1979,15 @@
18361979
18371980 // Skin
18381981 colorField.setFloat(material.color);
1839
- 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
+
18401991 subsurfaceField.setFloat(material.subsurface);
18411992 selfshadowField.setFloat(material.diffuseness);
18421993 diffusenessField.setFloat(material.factor);
....@@ -1855,7 +2006,7 @@
18552006 });
18562007 presetpanel.add(skin);
18572008
1858
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2009
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
18592010 lambert.setToolTipText("Diffuse");
18602011 lambert.addMouseListener(new MouseAdapter()
18612012 {
....@@ -1873,7 +2024,7 @@
18732024 });
18742025 presetpanel.add(lambert);
18752026
1876
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2027
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
18772028 diffuse2.setToolTipText("Diffuse2");
18782029 diffuse2.addMouseListener(new MouseAdapter()
18792030 {
....@@ -1891,7 +2042,7 @@
18912042 });
18922043 presetpanel.add(diffuse2);
18932044
1894
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2045
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
18952046 diffusemoon.setToolTipText("Moon");
18962047 diffusemoon.addMouseListener(new MouseAdapter()
18972048 {
....@@ -1909,7 +2060,7 @@
19092060 });
19102061 presetpanel.add(diffusemoon);
19112062
1912
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2063
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
19132064 diffusemoon2.setToolTipText("Moon2");
19142065 diffusemoon2.addMouseListener(new MouseAdapter()
19152066 {
....@@ -1927,7 +2078,7 @@
19272078 });
19282079 presetpanel.add(diffusemoon2);
19292080
1930
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2081
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
19312082 diffusemoon3.setToolTipText("Moon3");
19322083 diffusemoon3.addMouseListener(new MouseAdapter()
19332084 {
....@@ -1945,7 +2096,7 @@
19452096 });
19462097 presetpanel.add(diffusemoon3);
19472098
1948
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2099
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
19492100 diffusesheen.setToolTipText("Sheen");
19502101 diffusesheen.addMouseListener(new MouseAdapter()
19512102 {
....@@ -1962,7 +2113,7 @@
19622113 });
19632114 presetpanel.add(diffusesheen);
19642115
1965
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2116
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
19662117 rough.setToolTipText("Rough metal");
19672118 rough.addMouseListener(new MouseAdapter()
19682119 {
....@@ -1980,7 +2131,7 @@
19802131 });
19812132 presetpanel.add(rough);
19822133
1983
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2134
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
19842135 rough2.setToolTipText("Medium metal");
19852136 rough2.addMouseListener(new MouseAdapter()
19862137 {
....@@ -1998,7 +2149,7 @@
19982149 });
19992150 presetpanel.add(rough2);
20002151
2001
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2152
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
20022153 shini0.setToolTipText("Shiny");
20032154 shini0.addMouseListener(new MouseAdapter()
20042155 {
....@@ -2016,7 +2167,7 @@
20162167 });
20172168 presetpanel.add(shini0);
20182169
2019
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2170
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
20202171 shini1.setToolTipText("Shiny2");
20212172 shini1.addMouseListener(new MouseAdapter()
20222173 {
....@@ -2034,7 +2185,7 @@
20342185 });
20352186 presetpanel.add(shini1);
20362187
2037
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2188
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
20382189 shini2.setToolTipText("Shiny3");
20392190 shini2.addMouseListener(new MouseAdapter()
20402191 {
....@@ -2052,7 +2203,7 @@
20522203 });
20532204 presetpanel.add(shini2);
20542205
2055
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2206
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
20562207 aniso.setToolTipText("AnisoU");
20572208 aniso.addMouseListener(new MouseAdapter()
20582209 {
....@@ -2070,7 +2221,7 @@
20702221 });
20712222 presetpanel.add(aniso);
20722223
2073
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2224
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
20742225 aniso2.setToolTipText("AnisoV");
20752226 aniso2.addMouseListener(new MouseAdapter()
20762227 {
....@@ -2088,7 +2239,7 @@
20882239 });
20892240 presetpanel.add(aniso2);
20902241
2091
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2242
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
20922243 aniso3.setToolTipText("AnisoUV");
20932244 aniso3.addMouseListener(new MouseAdapter()
20942245 {
....@@ -2106,7 +2257,7 @@
21062257 });
21072258 presetpanel.add(aniso3);
21082259
2109
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2260
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
21102261 velvet0.setToolTipText("Velvet");
21112262 velvet0.addMouseListener(new MouseAdapter()
21122263 {
....@@ -2128,7 +2279,7 @@
21282279 });
21292280 presetpanel.add(velvet0);
21302281
2131
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2282
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
21322283 bump0.setToolTipText("Bump texture");
21332284 bump0.addMouseListener(new MouseAdapter()
21342285 {
....@@ -2147,7 +2298,22 @@
21472298 });
21482299 presetpanel.add(bump0);
21492300
2150
- 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);
21512317 halo.setToolTipText("Halo");
21522318 halo.addMouseListener(new MouseAdapter()
21532319 {
....@@ -2164,7 +2330,7 @@
21642330 });
21652331 presetpanel.add(halo);
21662332
2167
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2333
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
21682334 candle.setToolTipText("Candle");
21692335 candle.addMouseListener(new MouseAdapter()
21702336 {
....@@ -2186,7 +2352,7 @@
21862352 });
21872353 presetpanel.add(candle);
21882354
2189
- cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2355
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
21902356 shadowShader.setToolTipText("Shadow");
21912357 shadowShader.addMouseListener(new MouseAdapter()
21922358 {
....@@ -2221,19 +2387,19 @@
22212387
22222388 cGridBag editBar = new cGridBag().setVertical(false);
22232389
2224
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2390
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
22252391 createMaterialButton.setToolTipText("Create material");
22262392
22272393 /*
22282394 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
22292395 */
22302396
2231
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2397
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
22322398 clearMaterialButton.setToolTipText("Clear material");
22332399
22342400 if (Globals.ADVANCED)
22352401 {
2236
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2402
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
22372403 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
22382404 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
22392405 }
....@@ -2254,9 +2420,20 @@
22542420
22552421 cGridBag huepanel = new cGridBag();
22562422 cGridBag huelabel = new cGridBag();
2257
- skin = GetLabel("icons/hue.png", false);
2258
- skin.fit = true;
2259
- 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);
22602437 huelabel.preferredWidth = 20;
22612438 huepanel.add(new cGridBag()); // Label
22622439 huepanel.add(huelabel); // Field/slider
....@@ -3532,32 +3709,8 @@
35323709
35333710 if (multiplyToggle != null)
35343711 multiplyToggle.setSelected(mat.multiply);
3535
-
3536
- assert (object.projectedVertices != null);
3537
-
3538
- if (object.projectedVertices.length <= 2)
3539
- {
3540
- // Side effect...
3541
- Object3D.cVector2[] keep = object.projectedVertices;
3542
- object.projectedVertices = new Object3D.cVector2[3];
3543
- for (int i = 0; i < 3; i++)
3544
- {
3545
- if (i < keep.length)
3546
- {
3547
- object.projectedVertices[i] = keep[i];
3548
- } else
3549
- {
3550
- object.projectedVertices[i] = new Object3D.cVector2();
3551
- }
3552
- /*
3553
- if(keep.length == 0)
3554
- object.projectedVertices[0] = new Object3D.cVector2();
3555
- else
3556
- object.projectedVertices[0] = keep[0];
3557
- object.projectedVertices[1] = new Object3D.cVector2();
3558
- */
3559
- }
3560
- }
3712
+
3713
+ AllocProjectedVertices(object);
35613714
35623715 SetMaterial(mat, object.projectedVertices);
35633716 }
....@@ -3867,7 +4020,7 @@
38674020 //System.out.println("ObjEditor " + event);
38684021 applySelf0(true);
38694022 //parent.applySelf();
3870
- objEditor.refreshContents();
4023
+ // conflicts with requestFocus objEditor.refreshContents();
38714024 } else if (source == resetButton)
38724025 {
38734026 CameraPane.fullreset = true;
....@@ -4047,11 +4200,18 @@
40474200
40484201 void New()
40494202 {
4050
- while (copy.Size() > 1)
4203
+ while (copy.Size() > 0)
40514204 {
4052
- copy.remove(1);
4205
+ copy.remove(0);
40534206 }
40544207
4208
+ copy.selection.clear();
4209
+
4210
+ if (copy == Grafreed.grafreed.universe)
4211
+ {
4212
+ CreateCameras();
4213
+ cameraView.SetCamera(GetCamera(copy, 0));
4214
+ }
40554215 ResetModel();
40564216 objEditor.refreshContents();
40574217 }
....@@ -4179,8 +4339,6 @@
41794339 return true;
41804340 }
41814341
4182
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4183
-
41844342 void DeleteVersion()
41854343 {
41864344 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4188,7 +4346,11 @@
41884346 copy.versionlist[i] = copy.versionlist[i+1];
41894347 }
41904348
4191
- CopyChanged();
4349
+ if (copy.versionlist[copy.versionindex] == null)
4350
+ copy.versionindex -= 1;
4351
+
4352
+ if (copy.versionindex != -1)
4353
+ CopyChanged();
41924354
41934355 SetVersionStates();
41944356 }
....@@ -4301,7 +4463,7 @@
43014463 boolean temp = CameraPane.SWITCH;
43024464 CameraPane.SWITCH = false;
43034465
4304
- copy.ExtractBigData(versiontable);
4466
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
43054467
43064468 copy.clear();
43074469
....@@ -4313,7 +4475,7 @@
43134475 copy.add(obj.get(i));
43144476 }
43154477
4316
- copy.RestoreBigData(versiontable);
4478
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
43174479
43184480 CameraPane.SWITCH = temp;
43194481
....@@ -4363,6 +4525,8 @@
43634525 return count;
43644526 }
43654527
4528
+ public cGridBag versionSliderPane;
4529
+
43664530 void SetVersionStates()
43674531 {
43684532 //if (true)
....@@ -4370,21 +4534,36 @@
43704534
43714535 //cRadio tab = GetCurrentTab();
43724536
4373
- restoreButton.setEnabled(copy.versionindex != -1);
4374
- replaceButton.setEnabled(copy.versionindex != -1);
4375
-
4376
- previousVersionButton.setEnabled(copy.versionindex > 0);
4377
- nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4378
-
4379
- deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4380
- copy.versionlist[copy.versionindex + 1] != null);
4381
-
4382
- muteSlider = true;
4383
- versionSlider.setMinimum(0);
4384
- versionSlider.setMaximum(VersionCount() - 1);
4385
- versionSlider.setInteger(copy.versionindex);
4386
- versionSlider.setEnabled(copy.versionindex != -1);
4387
- 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
+ }
43884567 }
43894568
43904569 public boolean PreviousVersion()
....@@ -4442,7 +4621,7 @@
44424621
44434622 public boolean Replace()
44444623 {
4445
- System.err.println("Replace");
4624
+ //System.err.println("Replace");
44464625
44474626 //cRadio tab = GetCurrentTab();
44484627
....@@ -4669,6 +4848,12 @@
46694848 // else
46704849 // applySelf(true);
46714850 // }
4851
+
4852
+ boolean Equal(double a, double b)
4853
+ {
4854
+ return Math.abs(a - b) < 0.001;
4855
+ }
4856
+
46724857 void applySelf0(boolean name)
46734858 {
46744859 if (name)
....@@ -4718,29 +4903,52 @@
47184903 {
47194904 cMaterial mat = copy.material;
47204905
4721
- colorField.SetToolTipValue((mat.color));
4722
- saturationField.SetToolTipValue((mat.modulation));
4723
- metalnessField.SetToolTipValue((mat.metalness));
4724
- diffuseField.SetToolTipValue((mat.diffuse));
4725
- specularField.SetToolTipValue((mat.specular));
4726
- shininessField.SetToolTipValue((mat.shininess));
4727
- shiftField.SetToolTipValue((mat.shift));
4728
- ambientField.SetToolTipValue((mat.ambient));
4729
- lightareaField.SetToolTipValue((mat.lightarea));
4730
- diffusenessField.SetToolTipValue((mat.factor));
4731
- velvetField.SetToolTipValue((mat.velvet));
4732
- sheenField.SetToolTipValue((mat.sheen));
4733
- subsurfaceField.SetToolTipValue((mat.subsurface));
4734
- backlitField.SetToolTipValue((mat.bump));
4735
- anisoField.SetToolTipValue((mat.aniso));
4736
- anisoVField.SetToolTipValue((mat.anisoV));
4737
- cameraField.SetToolTipValue((mat.cameralight));
4738
- selfshadowField.SetToolTipValue((mat.diffuseness));
4739
- shadowField.SetToolTipValue((mat.shadow));
4740
- textureField.SetToolTipValue((mat.texture));
4741
- opacityField.SetToolTipValue((mat.opacity));
4742
- fakedepthField.SetToolTipValue((mat.fakedepth));
4743
- 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));
47444952 }
47454953
47464954 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4775,11 +4983,13 @@
47754983
47764984 public void stateChanged(ChangeEvent e)
47774985 {
4778
- // assert(false);
4986
+ // assert(false);
47794987 if (e.getSource() == versionSlider)
47804988 {
47814989 if (muteSlider)
47824990 return;
4991
+
4992
+ Replace();
47834993
47844994 int version = versionSlider.getInteger();
47854995
....@@ -5143,6 +5353,8 @@
51435353
51445354 if (previousVersionButton != null && copy.versionlist != null)
51455355 SetVersionStates();
5356
+
5357
+ cameraView.requestFocusInWindow();
51465358 }
51475359
51485360 static TweenManager tweenManager = new TweenManager();
....@@ -5174,7 +5386,7 @@
51745386 // group = (Composite) group.get(0);
51755387 // }
51765388
5177
- System.out.println("makeSomething of " + thing);
5389
+ //System.out.println("makeSomething of " + thing);
51785390
51795391 /*
51805392 if (deselect && jList != null)
....@@ -5528,6 +5740,7 @@
55285740
55295741 copy.versionlist = readobj.versionlist;
55305742 copy.versionindex = readobj.versionindex;
5743
+ copy.versiontable = readobj.versiontable;
55315744
55325745 if (copy.versionlist == null)
55335746 {
....@@ -5535,7 +5748,7 @@
55355748 copy.versionlist = new Object3D[100];
55365749 copy.versionindex = -1;
55375750
5538
- Save(true);
5751
+ //Save(true);
55395752 }
55405753
55415754 //? SetUndoStates();
....@@ -5883,6 +6096,7 @@
58836096 boolean materialFlushed;
58846097 Object3D latestObject;
58856098
6099
+ cGridBag transformPanel;
58866100 cGridBag XYZPanel;
58876101
58886102 JSplitPane gridPanel;