Normand Briere
2019-08-18 480ad70047e54b2b92f974e6c2ac5a6c0bdc5a5c
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,6 +42,50 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
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
+ }
4489
4590 public cGridBag GetSeparator()
4691 {
....@@ -53,7 +98,10 @@
5398 cButton GetButton(String name, boolean border)
5499 {
55100 ImageIcon icon = GetIcon(name);
56
- 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);
57105 }
58106
59107 cLabel GetLabel(String name, boolean border)
....@@ -74,11 +122,19 @@
74122 return new cCheckBox(icon, border);
75123 }
76124
77
- 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)
78128 {
129
+ javax.swing.ImageIcon iconCache = icons.get(name);
130
+ if (iconCache != null)
131
+ {
132
+ return iconCache;
133
+ }
134
+
79135 try
80136 {
81
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
137
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
82138
83139 // if (image.getWidth() > 48 && image.getHeight() > 48)
84140 // {
....@@ -93,10 +149,14 @@
93149 // }
94150
95151 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
152
+
153
+ icons.put(name, icon);
154
+
96155 return icon;
97156 }
98157 catch (Exception e)
99158 {
159
+ //icons.put(name, null);
100160 return null;
101161 }
102162 }
....@@ -296,11 +356,13 @@
296356 client = inClient;
297357 copy = client;
298358
299
- if (copy.versionlist == null)
300
- {
301
- copy.versionlist = new Object3D[100];
302
- copy.versionindex = -1;
303
- }
359
+// if (copy.versionlist == null)
360
+// {
361
+// copy.versionlist = new Object3D[100];
362
+// copy.versionindex = -1;
363
+//
364
+// callee.Save(true);
365
+// }
304366
305367 // "this" is not called: SetupUI2(objEditor);
306368 }
....@@ -319,6 +381,8 @@
319381 {
320382 copy.versionlist = new Object3D[100];
321383 copy.versionindex = -1;
384
+
385
+// Save(true);
322386 }
323387
324388 SetupUI2(callee.GetEditor());
....@@ -342,7 +406,8 @@
342406 //parent = p;
343407
344408 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
345
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
409
+ if (Globals.DEBUG)
410
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
346411 //gd.setFullScreenWindow(this);
347412 //setResizable(false);
348413 //if (!isDisplayable())
....@@ -353,11 +418,13 @@
353418 copy = localCopy;
354419 copy.editWindow = this;
355420
356
- if (copy.versionlist == null)
357
- {
358
-// copy.versions = new byte[100][];
421
+// if (copy.versionlist == null)
422
+// {
423
+// copy.versionlist = new Object3D[100];
359424 // copy.versionindex = -1;
360
- }
425
+//
426
+// Save(true);
427
+// }
361428
362429 SetupMenu();
363430
....@@ -377,6 +444,9 @@
377444
378445 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379446
447
+ // This is to refresh the UI of the material panel.
448
+ boolean patchMaterial;
449
+
380450 void SetupMenu()
381451 {
382452 frame.setMenuBar(menuBar = new MenuBar());
....@@ -426,6 +496,8 @@
426496
427497 ChangeListener changeListener = new ChangeListener()
428498 {
499
+ //String name;
500
+
429501 public void stateChanged(ChangeEvent changeEvent)
430502 {
431503 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -444,7 +516,37 @@
444516 // EditSelection(false);
445517 // }
446518
447
- refreshContents(false); // To refresh Info tab
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
+
548
+// refreshContents(false); // To refresh Info tab
549
+ cameraView.repaint();
448550 }
449551 };
450552 objectPanel.addChangeListener(changeListener);
....@@ -466,6 +568,8 @@
466568
467569 toolboxPanel = new cGridBag().setVertical(true);
468570 //toolboxPanel.setName("Toolbox");
571
+
572
+ skyboxPanel = new cGridBag().setVertical(true);
469573
470574 materialPanel = new cGridBag().setVertical(false);
471575 //materialPanel.setName("Material");
....@@ -751,6 +855,7 @@
751855 boolean maximized;
752856
753857 cButton fullscreenLayout;
858
+ cButton expandedLayout;
754859
755860 void Minimize()
756861 {
....@@ -790,10 +895,12 @@
790895 cButton minButton;
791896 cButton maxButton;
792897 cButton fullButton;
898
+ cButton collapseButton;
899
+ cButton maximize3DButton;
793900
794901 void ToggleFullScreen()
795902 {
796
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
903
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797904
798905 cameraView.ToggleFullScreen();
799906
....@@ -814,13 +921,13 @@
814921 // X frame.getContentPane().remove(/*"Center",*/bigThree);
815922 // X framePanel.add(bigThree);
816923 // X frame.getContentPane().add(/*"Center",*/framePanel);
817
- framePanel.setDividerLocation(46);
924
+// framePanel.setDividerLocation(46); // icons are 24x24
818925
819926 //frame.setVisible(true);
820
- radio.layout = keepButton;
927
+// radio.layout = keepButton;
821928 //theFrame = null;
822929 keepButton = null;
823
- radio.layout.doClick();
930
+// radio.layout.doClick();
824931
825932 } else
826933 {
....@@ -841,10 +948,10 @@
841948 // X frame.getContentPane().remove(/*"Center",*/framePanel);
842949 // X framePanel.remove(bigThree);
843950 // X frame.getContentPane().add(/*"Center",*/bigThree);
844
- framePanel.setDividerLocation(0);
951
+// framePanel.setDividerLocation(0);
845952
846
- radio.layout = fullscreenLayout;
847
- radio.layout.doClick();
953
+// radio.layout = fullscreenLayout;
954
+// radio.layout.doClick();
848955 //frame.setVisible(true);
849956 }
850957 frame.validate();
....@@ -852,23 +959,42 @@
852959 cameraView.requestFocusInWindow();
853960 }
854961
855
- private Object3D CompressCopy()
962
+ void CollapseToolbar()
963
+ {
964
+ framePanel.setDividerLocation(0);
965
+ //frame.validate();
966
+
967
+ cameraView.requestFocusInWindow();
968
+ }
969
+
970
+ private Object3D Duplicate(Object3D object)
856971 {
857972 boolean temp = CameraPane.SWITCH;
858973 CameraPane.SWITCH = false;
859974
860
- copy.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);
861979 // if (copy == client)
862980
863
- Object3D versions[] = copy.versionlist;
864
- copy.versionlist = null;
981
+ Object3D versions[] = object.versionlist;
982
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
983
+ object.versionlist = null;
984
+ object.versiontable = null;
985
+
986
+ Object3D parent = object.parent;
987
+ object.parent = null;
865988
866989 //byte[] compress = Compress(copy);
867
- Object3D compress = (Object3D)Grafreed.clone(copy);
990
+ Object3D compress = (Object3D)Grafreed.clone(object);
868991
869
- copy.versionlist = versions;
992
+ object.parent = parent;
870993
871
- copy.RestoreBigData(versiontable);
994
+ object.versionlist = versions;
995
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
996
+
997
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
872998
873999 CameraPane.SWITCH = temp;
8741000
....@@ -1205,6 +1331,18 @@
12051331
12061332 namePanel = new cGridBag();
12071333
1334
+ //if (copy.pinned)
1335
+ {
1336
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1337
+ pinButton.setSelected(copy.pinned);
1338
+ cGridBag t = new cGridBag();
1339
+ t.preferredWidth = 2;
1340
+ t.add(pinButton);
1341
+ namePanel.add(t);
1342
+
1343
+ pinButton.addItemListener(this);
1344
+ }
1345
+
12081346 nameField = AddText(namePanel, copy.GetName());
12091347 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
12101348 oe.ctrlPanel.add(namePanel);
....@@ -1218,14 +1356,14 @@
12181356
12191357 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12201358 liveCB.setToolTipText("Animate object");
1359
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1360
+ markCB.setToolTipText("Set target transform");
12211361 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12221362 selectableCB.setToolTipText("Make object selectable");
12231363 // Return();
12241364
12251365 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12261366 hideCB.setToolTipText("Hide object");
1227
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1228
- markCB.setToolTipText("As animation target transform");
12291367
12301368 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12311369
....@@ -1427,22 +1565,9 @@
14271565
14281566 if (cam == null || !(copy.get(0) instanceof cGroup))
14291567 {
1430
- System.out.println("CREATE CAMERAS");
1431
- cams = new cTemplate();
1432
- cams.name = "Cameras";
1433
- copy.insertElementAt(cams, 0);
1434
- //cams.parent = copy;
1435
-
1436
- cam = new Camera(); // LA.newVector(3, 2, 1));
1437
- cams.addChild(cam);
1438
- cam = new Camera(1);
1439
- cams.addChild(cam);
1440
- cam = new Camera(2);
1441
- cams.addChild(cam);
1442
- cam = new Camera(3);
1443
- cams.addChild(cam);
1444
- cam = new Camera(4); // Light
1445
- cams.addChild(cam);
1568
+ if (Globals.DEBUG)
1569
+ System.out.println("CREATE CAMERAS");
1570
+ cams = CreateCameras();
14461571 } else
14471572 {
14481573 cams = (cGroup) copy.get(0);
....@@ -1508,6 +1633,45 @@
15081633 //frontView.object = copy;
15091634 //sideView.object = copy;
15101635
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
+
15111675 XYZPanel = new cGridBag().setVertical(true);
15121676 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15131677
....@@ -1517,6 +1681,9 @@
15171681 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15181682 //XYZPanel.setName("XYZ");
15191683
1684
+ transformPanel.add(resetTransformPanel);
1685
+ transformPanel.add(XYZPanel);
1686
+
15201687 /*
15211688 gridPanel = new JPanel(); //new BorderLayout());
15221689 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1524,12 +1691,12 @@
15241691 gridPanel.add(cameraView);
15251692 gridPanel.add(XYZPanel);
15261693 */
1527
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1528
- gridPanel.setContinuousLayout(true);
1529
- gridPanel.setOneTouchExpandable(true);
1530
- gridPanel.setDividerLocation(1.0);
1531
- gridPanel.setDividerSize(9);
1532
- 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);
15331700
15341701 // aConstraints.weighty = 0;
15351702 //System.out.println("THIS = " + this);
....@@ -1552,31 +1719,34 @@
15521719
15531720 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15541721 //tmp.setName("Edit");
1722
+ objectPanel.add(skyboxPanel);
1723
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1724
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1725
+
1726
+ objectPanel.add(toolboxPanel);
1727
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1728
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1729
+
15551730 objectPanel.add(materialPanel);
1556
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
- objectPanel.setToolTipTextAt(0, "Material");
1731
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1732
+ objectPanel.setToolTipTextAt(2, "Material");
15581733
15591734 // JPanel north = new JPanel(new BorderLayout());
15601735 // north.setName("Edit");
15611736 // north.add(ctrlPanel, BorderLayout.NORTH);
15621737 // objectPanel.add(north);
15631738 objectPanel.add(editPanel);
1564
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
- objectPanel.setToolTipTextAt(1, "Edit controls");
1739
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1740
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15661741
1567
- //if (Globals.ADVANCED)
1568
- objectPanel.add(infoPanel);
1569
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
- objectPanel.setToolTipTextAt(2, "Information");
1742
+ objectPanel.add(transformPanel);
1743
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1744
+ objectPanel.setToolTipTextAt(4, "TRS transform");
15711745
1572
- objectPanel.add(XYZPanel);
1573
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
- objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1575
-
1576
- objectPanel.add(toolboxPanel);
1577
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
- objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
1579
-
1746
+ patchMaterial = true;
1747
+ cameraView.patchMaterial = this;
1748
+ objectPanel.setSelectedIndex(2);
1749
+
15801750 /*
15811751 aConstraints.gridx = 0;
15821752 aConstraints.gridwidth = 1;
....@@ -1596,7 +1766,7 @@
15961766 scrollpane.addMouseWheelListener(this); // Default not fast enough
15971767
15981768 /*JTabbedPane*/ scenePanel = new cGridBag();
1599
- scenePanel.preferredWidth = 5;
1769
+ scenePanel.preferredWidth = 6;
16001770
16011771 JTabbedPane tabbedPane = new JTabbedPane();
16021772 tabbedPane.add(scrollpane);
....@@ -1607,11 +1777,51 @@
16071777
16081778 AddOptions(optionsPanel); //, aConstraints);
16091779
1610
- tabbedPane.add(optionsPanel);
1611
-
16121780 tabbedPane.add(FSPane = new cFileSystemPane(this));
16131781
1782
+ tabbedPane.add(optionsPanel);
1783
+
16141784 scenePanel.add(tabbedPane);
1785
+
1786
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1787
+ creditsPanel.setName("Credits");
1788
+
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
+ }
16151825
16161826 /*
16171827 cTree jTree = new cTree(null);
....@@ -1633,13 +1843,13 @@
16331843 jtp.add(tree);
16341844 */
16351845
1636
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1637
- bigPanel.setContinuousLayout(true);
1638
- bigPanel.setOneTouchExpandable(true);
1639
- bigPanel.setDividerLocation(0.8);
1640
- bigPanel.setDividerSize(15);
1641
- bigPanel.setResizeWeight(0.15);
1642
- 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");
16431853
16441854 //bigPanel.setLayout(new BorderLayout());
16451855 //bigPanel.setSize(new Dimension(10,10));
....@@ -1683,6 +1893,23 @@
16831893 // aConstraints.gridheight = 1;
16841894
16851895 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1896
+
1897
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1898
+ new java.beans.PropertyChangeListener()
1899
+ {
1900
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1901
+ {
1902
+ if ((Integer)pce.getOldValue() == 1)
1903
+ {
1904
+ if (radio.layout != expandedLayout)
1905
+ {
1906
+ radio.layout = expandedLayout;
1907
+ radio.layout.doClick();
1908
+ }
1909
+ }
1910
+ }
1911
+ });
1912
+
16861913 framePanel.setContinuousLayout(false);
16871914 framePanel.setOneTouchExpandable(false);
16881915 //.setDividerLocation(0.8);
....@@ -1692,7 +1919,7 @@
16921919
16931920 frame.getContentPane().setLayout(new BorderLayout());
16941921 /**/
1695
- JTabbedPane worldPane = new JTabbedPane();
1922
+ //JTabbedPane worldPane = new JTabbedPane();
16961923 //worldPane.add(bigPanel);
16971924 //worldPane.add(worldPanel);
16981925 /**/
....@@ -1706,7 +1933,7 @@
17061933
17071934 cameraView.requestFocusInWindow();
17081935
1709
- gridPanel.setDividerLocation(1.0);
1936
+// gridPanel.setDividerLocation(1.0);
17101937
17111938 frame.validate();
17121939
....@@ -1741,7 +1968,7 @@
17411968 {
17421969 cGridBag presetpanel = new cGridBag().setVertical(true);
17431970
1744
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1971
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
17451972 skin.setToolTipText("Skin");
17461973 skin.addMouseListener(new MouseAdapter()
17471974 {
....@@ -1752,7 +1979,15 @@
17521979
17531980 // Skin
17541981 colorField.setFloat(material.color);
1755
- 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
+
17561991 subsurfaceField.setFloat(material.subsurface);
17571992 selfshadowField.setFloat(material.diffuseness);
17581993 diffusenessField.setFloat(material.factor);
....@@ -1771,7 +2006,7 @@
17712006 });
17722007 presetpanel.add(skin);
17732008
1774
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2009
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
17752010 lambert.setToolTipText("Diffuse");
17762011 lambert.addMouseListener(new MouseAdapter()
17772012 {
....@@ -1789,7 +2024,7 @@
17892024 });
17902025 presetpanel.add(lambert);
17912026
1792
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2027
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
17932028 diffuse2.setToolTipText("Diffuse2");
17942029 diffuse2.addMouseListener(new MouseAdapter()
17952030 {
....@@ -1807,7 +2042,7 @@
18072042 });
18082043 presetpanel.add(diffuse2);
18092044
1810
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2045
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
18112046 diffusemoon.setToolTipText("Moon");
18122047 diffusemoon.addMouseListener(new MouseAdapter()
18132048 {
....@@ -1825,7 +2060,7 @@
18252060 });
18262061 presetpanel.add(diffusemoon);
18272062
1828
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2063
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
18292064 diffusemoon2.setToolTipText("Moon2");
18302065 diffusemoon2.addMouseListener(new MouseAdapter()
18312066 {
....@@ -1843,7 +2078,7 @@
18432078 });
18442079 presetpanel.add(diffusemoon2);
18452080
1846
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2081
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
18472082 diffusemoon3.setToolTipText("Moon3");
18482083 diffusemoon3.addMouseListener(new MouseAdapter()
18492084 {
....@@ -1861,7 +2096,7 @@
18612096 });
18622097 presetpanel.add(diffusemoon3);
18632098
1864
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2099
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
18652100 diffusesheen.setToolTipText("Sheen");
18662101 diffusesheen.addMouseListener(new MouseAdapter()
18672102 {
....@@ -1878,7 +2113,7 @@
18782113 });
18792114 presetpanel.add(diffusesheen);
18802115
1881
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2116
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
18822117 rough.setToolTipText("Rough metal");
18832118 rough.addMouseListener(new MouseAdapter()
18842119 {
....@@ -1896,7 +2131,7 @@
18962131 });
18972132 presetpanel.add(rough);
18982133
1899
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2134
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
19002135 rough2.setToolTipText("Medium metal");
19012136 rough2.addMouseListener(new MouseAdapter()
19022137 {
....@@ -1914,7 +2149,7 @@
19142149 });
19152150 presetpanel.add(rough2);
19162151
1917
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2152
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
19182153 shini0.setToolTipText("Shiny");
19192154 shini0.addMouseListener(new MouseAdapter()
19202155 {
....@@ -1932,7 +2167,7 @@
19322167 });
19332168 presetpanel.add(shini0);
19342169
1935
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2170
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
19362171 shini1.setToolTipText("Shiny2");
19372172 shini1.addMouseListener(new MouseAdapter()
19382173 {
....@@ -1950,7 +2185,7 @@
19502185 });
19512186 presetpanel.add(shini1);
19522187
1953
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2188
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
19542189 shini2.setToolTipText("Shiny3");
19552190 shini2.addMouseListener(new MouseAdapter()
19562191 {
....@@ -1968,7 +2203,7 @@
19682203 });
19692204 presetpanel.add(shini2);
19702205
1971
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2206
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
19722207 aniso.setToolTipText("AnisoU");
19732208 aniso.addMouseListener(new MouseAdapter()
19742209 {
....@@ -1986,7 +2221,7 @@
19862221 });
19872222 presetpanel.add(aniso);
19882223
1989
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2224
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
19902225 aniso2.setToolTipText("AnisoV");
19912226 aniso2.addMouseListener(new MouseAdapter()
19922227 {
....@@ -2004,7 +2239,7 @@
20042239 });
20052240 presetpanel.add(aniso2);
20062241
2007
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2242
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
20082243 aniso3.setToolTipText("AnisoUV");
20092244 aniso3.addMouseListener(new MouseAdapter()
20102245 {
....@@ -2022,7 +2257,7 @@
20222257 });
20232258 presetpanel.add(aniso3);
20242259
2025
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2260
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
20262261 velvet0.setToolTipText("Velvet");
20272262 velvet0.addMouseListener(new MouseAdapter()
20282263 {
....@@ -2044,7 +2279,7 @@
20442279 });
20452280 presetpanel.add(velvet0);
20462281
2047
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2282
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
20482283 bump0.setToolTipText("Bump texture");
20492284 bump0.addMouseListener(new MouseAdapter()
20502285 {
....@@ -2063,7 +2298,22 @@
20632298 });
20642299 presetpanel.add(bump0);
20652300
2066
- 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);
20672317 halo.setToolTipText("Halo");
20682318 halo.addMouseListener(new MouseAdapter()
20692319 {
....@@ -2080,7 +2330,7 @@
20802330 });
20812331 presetpanel.add(halo);
20822332
2083
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2333
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
20842334 candle.setToolTipText("Candle");
20852335 candle.addMouseListener(new MouseAdapter()
20862336 {
....@@ -2102,6 +2352,25 @@
21022352 });
21032353 presetpanel.add(candle);
21042354
2355
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2356
+ shadowShader.setToolTipText("Shadow");
2357
+ shadowShader.addMouseListener(new MouseAdapter()
2358
+ {
2359
+ public void mouseClicked(MouseEvent e)
2360
+ {
2361
+ diffuseField.setFloat(0.001);
2362
+ ambientField.setFloat(0.001);
2363
+ cameraField.setFloat(0.001);
2364
+ specularField.setFloat(0.001);
2365
+ fakedepthField.setFloat(0.001);
2366
+ opacityField.setFloat(0.6);
2367
+
2368
+ materialtouched = true;
2369
+ applySelf();
2370
+ }
2371
+ });
2372
+ presetpanel.add(shadowShader);
2373
+
21052374 cGridBag panel = new cGridBag().setVertical(true);
21062375
21072376 presetpanel.preferredWidth = 1;
....@@ -2118,19 +2387,19 @@
21182387
21192388 cGridBag editBar = new cGridBag().setVertical(false);
21202389
2121
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2390
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
21222391 createMaterialButton.setToolTipText("Create material");
21232392
21242393 /*
21252394 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
21262395 */
21272396
2128
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2397
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
21292398 clearMaterialButton.setToolTipText("Clear material");
21302399
21312400 if (Globals.ADVANCED)
21322401 {
2133
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2402
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
21342403 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
21352404 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
21362405 }
....@@ -2151,9 +2420,20 @@
21512420
21522421 cGridBag huepanel = new cGridBag();
21532422 cGridBag huelabel = new cGridBag();
2154
- skin = GetLabel("icons/hue.png", false);
2155
- skin.fit = true;
2156
- 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);
21572437 huelabel.preferredWidth = 20;
21582438 huepanel.add(new cGridBag()); // Label
21592439 huepanel.add(huelabel); // Field/slider
....@@ -3429,32 +3709,8 @@
34293709
34303710 if (multiplyToggle != null)
34313711 multiplyToggle.setSelected(mat.multiply);
3432
-
3433
- assert (object.projectedVertices != null);
3434
-
3435
- if (object.projectedVertices.length <= 2)
3436
- {
3437
- // Side effect...
3438
- Object3D.cVector2[] keep = object.projectedVertices;
3439
- object.projectedVertices = new Object3D.cVector2[3];
3440
- for (int i = 0; i < 3; i++)
3441
- {
3442
- if (i < keep.length)
3443
- {
3444
- object.projectedVertices[i] = keep[i];
3445
- } else
3446
- {
3447
- object.projectedVertices[i] = new Object3D.cVector2();
3448
- }
3449
- /*
3450
- if(keep.length == 0)
3451
- object.projectedVertices[0] = new Object3D.cVector2();
3452
- else
3453
- object.projectedVertices[0] = keep[0];
3454
- object.projectedVertices[1] = new Object3D.cVector2();
3455
- */
3456
- }
3457
- }
3712
+
3713
+ AllocProjectedVertices(object);
34583714
34593715 SetMaterial(mat, object.projectedVertices);
34603716 }
....@@ -3574,6 +3830,17 @@
35743830 public void itemStateChanged(ItemEvent event)
35753831 {
35763832 // System.out.println("Propagate = " + propagate);
3833
+ if (event.getSource() == pinButton)
3834
+ {
3835
+ copy.pinned ^= true;
3836
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3837
+ {
3838
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3839
+ copy.CloseUI();
3840
+ //copy.editWindow.refreshContents();
3841
+ }
3842
+ }
3843
+ else
35773844 if (event.getSource() == propagateToggle)
35783845 {
35793846 propagate ^= true;
....@@ -3753,7 +4020,7 @@
37534020 //System.out.println("ObjEditor " + event);
37544021 applySelf0(true);
37554022 //parent.applySelf();
3756
- objEditor.refreshContents();
4023
+ // conflicts with requestFocus objEditor.refreshContents();
37574024 } else if (source == resetButton)
37584025 {
37594026 CameraPane.fullreset = true;
....@@ -3933,11 +4200,18 @@
39334200
39344201 void New()
39354202 {
3936
- while (copy.Size() > 1)
4203
+ while (copy.Size() > 0)
39374204 {
3938
- copy.remove(1);
4205
+ copy.remove(0);
39394206 }
39404207
4208
+ copy.selection.clear();
4209
+
4210
+ if (copy == Grafreed.grafreed.universe)
4211
+ {
4212
+ CreateCameras();
4213
+ cameraView.SetCamera(GetCamera(copy, 0));
4214
+ }
39414215 ResetModel();
39424216 objEditor.refreshContents();
39434217 }
....@@ -4046,7 +4320,7 @@
40464320 {
40474321 //Save(true);
40484322 Replace();
4049
- SetUndoStates();
4323
+ SetVersionStates();
40504324 }
40514325
40524326 private boolean Equal(byte[] compress, byte[] name)
....@@ -4065,8 +4339,6 @@
40654339 return true;
40664340 }
40674341
4068
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4069
-
40704342 void DeleteVersion()
40714343 {
40724344 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4074,19 +4346,23 @@
40744346 copy.versionlist[i] = copy.versionlist[i+1];
40754347 }
40764348
4077
- CopyChanged();
4349
+ if (copy.versionlist[copy.versionindex] == null)
4350
+ copy.versionindex -= 1;
40784351
4079
- SetUndoStates();
4352
+ if (copy.versionindex != -1)
4353
+ CopyChanged();
4354
+
4355
+ SetVersionStates();
40804356 }
40814357
40824358 public boolean Save(boolean user)
40834359 {
40844360 System.err.println("Save");
4085
- //Replace();
4361
+ Replace();
40864362
4087
- cRadio tab = GetCurrentTab();
4363
+ //cRadio tab = GetCurrentTab();
40884364
4089
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
4365
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
40904366
40914367 boolean thesame = false;
40924368
....@@ -4122,7 +4398,7 @@
41224398 // copy.versionlist[i] = null;
41234399 // }
41244400
4125
- SetUndoStates();
4401
+ SetVersionStates();
41264402
41274403 // test save
41284404 if (false)
....@@ -4180,14 +4456,14 @@
41804456
41814457 void CopyChanged()
41824458 {
4183
- Object3D obj = copy.versionlist[copy.versionindex];
4459
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
41844460
4185
- SetUndoStates();
4461
+ SetVersionStates();
41864462
41874463 boolean temp = CameraPane.SWITCH;
41884464 CameraPane.SWITCH = false;
41894465
4190
- copy.ExtractBigData(versiontable);
4466
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
41914467
41924468 copy.clear();
41934469
....@@ -4199,7 +4475,7 @@
41994475 copy.add(obj.get(i));
42004476 }
42014477
4202
- copy.RestoreBigData(versiontable);
4478
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
42034479
42044480 CameraPane.SWITCH = temp;
42054481
....@@ -4249,23 +4525,45 @@
42494525 return count;
42504526 }
42514527
4252
- void SetUndoStates()
4528
+ public cGridBag versionSliderPane;
4529
+
4530
+ void SetVersionStates()
42534531 {
4254
- cRadio tab = GetCurrentTab();
4532
+ //if (true)
4533
+ // return;
4534
+
4535
+ //cRadio tab = GetCurrentTab();
42554536
4256
- restoreButton.setEnabled(true); // copy.versionindex != -1);
4257
- replaceButton.setEnabled(true); // copy.versionindex != -1);
4258
-
4259
- previousVersionButton.setEnabled(copy.versionindex > 0);
4260
- nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4261
-
4262
- deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4263
- copy.versionlist[copy.versionindex + 1] != null);
4264
-
4265
- muteSlider = true;
4266
- versionSlider.setMaximum(VersionCount() - 1);
4267
- versionSlider.setInteger(copy.versionindex);
4268
- 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
+ }
42694567 }
42704568
42714569 public boolean PreviousVersion()
....@@ -4275,7 +4573,7 @@
42754573
42764574 System.err.println("Undo");
42774575
4278
- cRadio tab = GetCurrentTab();
4576
+ //cRadio tab = GetCurrentTab();
42794577
42804578 if (copy.versionindex == 0)
42814579 {
....@@ -4307,7 +4605,7 @@
43074605 {
43084606 System.err.println("Restore");
43094607
4310
- cRadio tab = GetCurrentTab();
4608
+ //cRadio tab = GetCurrentTab();
43114609
43124610 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43134611 {
....@@ -4323,9 +4621,9 @@
43234621
43244622 public boolean Replace()
43254623 {
4326
- System.err.println("Replace");
4624
+ //System.err.println("Replace");
43274625
4328
- cRadio tab = GetCurrentTab();
4626
+ //cRadio tab = GetCurrentTab();
43294627
43304628 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43314629 {
....@@ -4333,7 +4631,7 @@
43334631 return false;
43344632 }
43354633
4336
- copy.versionlist[copy.versionindex] = CompressCopy();
4634
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
43374635
43384636 return true;
43394637 }
....@@ -4343,7 +4641,7 @@
43434641 // Option?
43444642 Replace();
43454643
4346
- cRadio tab = GetCurrentTab();
4644
+ //cRadio tab = GetCurrentTab();
43474645
43484646 if (copy.versionlist[copy.versionindex + 1] == null)
43494647 {
....@@ -4550,6 +4848,12 @@
45504848 // else
45514849 // applySelf(true);
45524850 // }
4851
+
4852
+ boolean Equal(double a, double b)
4853
+ {
4854
+ return Math.abs(a - b) < 0.001;
4855
+ }
4856
+
45534857 void applySelf0(boolean name)
45544858 {
45554859 if (name)
....@@ -4599,29 +4903,52 @@
45994903 {
46004904 cMaterial mat = copy.material;
46014905
4602
- colorField.SetToolTipValue((mat.color));
4603
- saturationField.SetToolTipValue((mat.modulation));
4604
- metalnessField.SetToolTipValue((mat.metalness));
4605
- diffuseField.SetToolTipValue((mat.diffuse));
4606
- specularField.SetToolTipValue((mat.specular));
4607
- shininessField.SetToolTipValue((mat.shininess));
4608
- shiftField.SetToolTipValue((mat.shift));
4609
- ambientField.SetToolTipValue((mat.ambient));
4610
- lightareaField.SetToolTipValue((mat.lightarea));
4611
- diffusenessField.SetToolTipValue((mat.factor));
4612
- velvetField.SetToolTipValue((mat.velvet));
4613
- sheenField.SetToolTipValue((mat.sheen));
4614
- subsurfaceField.SetToolTipValue((mat.subsurface));
4615
- backlitField.SetToolTipValue((mat.bump));
4616
- anisoField.SetToolTipValue((mat.aniso));
4617
- anisoVField.SetToolTipValue((mat.anisoV));
4618
- cameraField.SetToolTipValue((mat.cameralight));
4619
- selfshadowField.SetToolTipValue((mat.diffuseness));
4620
- shadowField.SetToolTipValue((mat.shadow));
4621
- textureField.SetToolTipValue((mat.texture));
4622
- opacityField.SetToolTipValue((mat.opacity));
4623
- fakedepthField.SetToolTipValue((mat.fakedepth));
4624
- 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));
46254952 }
46264953
46274954 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4656,15 +4983,17 @@
46564983
46574984 public void stateChanged(ChangeEvent e)
46584985 {
4659
- // assert(false);
4986
+ // assert(false);
46604987 if (e.getSource() == versionSlider)
46614988 {
46624989 if (muteSlider)
46634990 return;
46644991
4992
+ Replace();
4993
+
46654994 int version = versionSlider.getInteger();
46664995
4667
- if (copy.versionlist[version] != null)
4996
+ if (version != -1 && copy.versionlist[version] != null)
46684997 {
46694998 copy.versionindex = version;
46704999 CopyChanged();
....@@ -4708,7 +5037,7 @@
47085037 //System.out.println("stateChanged = " + this);
47095038 materialtouched = true;
47105039
4711
- if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
5040
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
47125041 {
47135042 saturationField.setFloat(1);
47145043 }
....@@ -5023,7 +5352,9 @@
50235352 }
50245353
50255354 if (previousVersionButton != null && copy.versionlist != null)
5026
- SetUndoStates();
5355
+ SetVersionStates();
5356
+
5357
+ cameraView.requestFocusInWindow();
50275358 }
50285359
50295360 static TweenManager tweenManager = new TweenManager();
....@@ -5055,7 +5386,7 @@
50555386 // group = (Composite) group.get(0);
50565387 // }
50575388
5058
- System.out.println("makeSomething of " + thing);
5389
+ //System.out.println("makeSomething of " + thing);
50595390
50605391 /*
50615392 if (deselect && jList != null)
....@@ -5409,11 +5740,15 @@
54095740
54105741 copy.versionlist = readobj.versionlist;
54115742 copy.versionindex = readobj.versionindex;
5743
+ copy.versiontable = readobj.versiontable;
54125744
54135745 if (copy.versionlist == null)
54145746 {
5747
+ // Backward compatibility
54155748 copy.versionlist = new Object3D[100];
54165749 copy.versionindex = -1;
5750
+
5751
+ //Save(true);
54175752 }
54185753
54195754 //? SetUndoStates();
....@@ -5505,6 +5840,8 @@
55055840
55065841 void save()
55075842 {
5843
+ Replace();
5844
+
55085845 if (lastname == null)
55095846 {
55105847 return;
....@@ -5747,6 +6084,7 @@
57476084 ButtonGroup buttonGroup;
57486085
57496086 cGridBag toolboxPanel;
6087
+ cGridBag skyboxPanel;
57506088 cGridBag materialPanel;
57516089 cGridBag ctrlPanel;
57526090
....@@ -5758,6 +6096,7 @@
57586096 boolean materialFlushed;
57596097 Object3D latestObject;
57606098
6099
+ cGridBag transformPanel;
57616100 cGridBag XYZPanel;
57626101
57636102 JSplitPane gridPanel;
....@@ -5851,6 +6190,7 @@
58516190 cNumberSlider anisoField;
58526191 JLabel anisoVLabel;
58536192 cNumberSlider anisoVField;
6193
+
58546194 JLabel cameraLabel;
58556195 cNumberSlider cameraField;
58566196 JLabel selfshadowLabel;
....@@ -5865,6 +6205,7 @@
58656205 cNumberSlider fakedepthField;
58666206 JLabel shadowbiasLabel;
58676207 cNumberSlider shadowbiasField;
6208
+
58686209 JLabel bumpLabel;
58696210 cNumberSlider bumpField;
58706211 JLabel noiseLabel;