Normand Briere
2019-08-18 66aca73cce89e4b4d7521862760edf4b0888bc38
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,35 @@
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
+ }
4474
4575 public cGridBag GetSeparator()
4676 {
....@@ -53,7 +83,10 @@
5383 cButton GetButton(String name, boolean border)
5484 {
5585 ImageIcon icon = GetIcon(name);
56
- return new cButton(icon, border);
86
+ if (icon != null || name.contains("/"))
87
+ return new cButton(icon, border);
88
+ else
89
+ return new cButton(name, border);
5790 }
5891
5992 cLabel GetLabel(String name, boolean border)
....@@ -74,11 +107,19 @@
74107 return new cCheckBox(icon, border);
75108 }
76109
77
- ImageIcon GetIcon(String name)
110
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
111
+
112
+ static ImageIcon GetIcon(String name)
78113 {
114
+ javax.swing.ImageIcon iconCache = icons.get(name);
115
+ if (iconCache != null)
116
+ {
117
+ return iconCache;
118
+ }
119
+
79120 try
80121 {
81
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
122
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
82123
83124 // if (image.getWidth() > 48 && image.getHeight() > 48)
84125 // {
....@@ -93,10 +134,14 @@
93134 // }
94135
95136 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
137
+
138
+ icons.put(name, icon);
139
+
96140 return icon;
97141 }
98142 catch (Exception e)
99143 {
144
+ //icons.put(name, null);
100145 return null;
101146 }
102147 }
....@@ -296,11 +341,13 @@
296341 client = inClient;
297342 copy = client;
298343
299
- if (copy.versionlist == null)
300
- {
301
- copy.versionlist = new Object3D[100];
302
- copy.versionindex = -1;
303
- }
344
+// if (copy.versionlist == null)
345
+// {
346
+// copy.versionlist = new Object3D[100];
347
+// copy.versionindex = -1;
348
+//
349
+// callee.Save(true);
350
+// }
304351
305352 // "this" is not called: SetupUI2(objEditor);
306353 }
....@@ -319,6 +366,8 @@
319366 {
320367 copy.versionlist = new Object3D[100];
321368 copy.versionindex = -1;
369
+
370
+// Save(true);
322371 }
323372
324373 SetupUI2(callee.GetEditor());
....@@ -342,7 +391,8 @@
342391 //parent = p;
343392
344393 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
345
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
394
+ if (Globals.DEBUG)
395
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
346396 //gd.setFullScreenWindow(this);
347397 //setResizable(false);
348398 //if (!isDisplayable())
....@@ -353,11 +403,13 @@
353403 copy = localCopy;
354404 copy.editWindow = this;
355405
356
- if (copy.versionlist == null)
357
- {
358
-// copy.versions = new byte[100][];
406
+// if (copy.versionlist == null)
407
+// {
408
+// copy.versionlist = new Object3D[100];
359409 // copy.versionindex = -1;
360
- }
410
+//
411
+// Save(true);
412
+// }
361413
362414 SetupMenu();
363415
....@@ -377,6 +429,9 @@
377429
378430 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379431
432
+ // This is to refresh the UI of the material panel.
433
+ boolean patchMaterial;
434
+
380435 void SetupMenu()
381436 {
382437 frame.setMenuBar(menuBar = new MenuBar());
....@@ -426,6 +481,8 @@
426481
427482 ChangeListener changeListener = new ChangeListener()
428483 {
484
+ //String name;
485
+
429486 public void stateChanged(ChangeEvent changeEvent)
430487 {
431488 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -444,7 +501,37 @@
444501 // EditSelection(false);
445502 // }
446503
447
- refreshContents(false); // To refresh Info tab
504
+// if (objectPanel.getSelectedIndex() == 4)
505
+// {
506
+// name = copy.skyboxname;
507
+//
508
+// if (name == null)
509
+// {
510
+// name = "";
511
+// }
512
+//
513
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
514
+// copy.skyboxext = "jpg";
515
+// }
516
+// else
517
+// {
518
+// if (name != null)
519
+// {
520
+// if (name.equals(""))
521
+// {
522
+// copy.skyboxname = null;
523
+// copy.skyboxext = null;
524
+// }
525
+// else
526
+// {
527
+// copy.skyboxname = name;
528
+// }
529
+// }
530
+// }
531
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
532
+
533
+// refreshContents(false); // To refresh Info tab
534
+ cameraView.repaint();
448535 }
449536 };
450537 objectPanel.addChangeListener(changeListener);
....@@ -466,6 +553,8 @@
466553
467554 toolboxPanel = new cGridBag().setVertical(true);
468555 //toolboxPanel.setName("Toolbox");
556
+
557
+ skyboxPanel = new cGridBag().setVertical(true);
469558
470559 materialPanel = new cGridBag().setVertical(false);
471560 //materialPanel.setName("Material");
....@@ -751,6 +840,7 @@
751840 boolean maximized;
752841
753842 cButton fullscreenLayout;
843
+ cButton expandedLayout;
754844
755845 void Minimize()
756846 {
....@@ -790,10 +880,12 @@
790880 cButton minButton;
791881 cButton maxButton;
792882 cButton fullButton;
883
+ cButton collapseButton;
884
+ cButton maximize3DButton;
793885
794886 void ToggleFullScreen()
795887 {
796
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
888
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797889
798890 cameraView.ToggleFullScreen();
799891
....@@ -814,13 +906,13 @@
814906 // X frame.getContentPane().remove(/*"Center",*/bigThree);
815907 // X framePanel.add(bigThree);
816908 // X frame.getContentPane().add(/*"Center",*/framePanel);
817
- framePanel.setDividerLocation(46);
909
+// framePanel.setDividerLocation(46); // icons are 24x24
818910
819911 //frame.setVisible(true);
820
- radio.layout = keepButton;
912
+// radio.layout = keepButton;
821913 //theFrame = null;
822914 keepButton = null;
823
- radio.layout.doClick();
915
+// radio.layout.doClick();
824916
825917 } else
826918 {
....@@ -841,32 +933,53 @@
841933 // X frame.getContentPane().remove(/*"Center",*/framePanel);
842934 // X framePanel.remove(bigThree);
843935 // X frame.getContentPane().add(/*"Center",*/bigThree);
844
- framePanel.setDividerLocation(0);
936
+// framePanel.setDividerLocation(0);
845937
846
- radio.layout = fullscreenLayout;
847
- radio.layout.doClick();
938
+// radio.layout = fullscreenLayout;
939
+// radio.layout.doClick();
848940 //frame.setVisible(true);
849941 }
850942 frame.validate();
943
+
944
+ cameraView.requestFocusInWindow();
851945 }
852946
853
- private Object3D CompressCopy()
947
+ void CollapseToolbar()
948
+ {
949
+ framePanel.setDividerLocation(0);
950
+ //frame.validate();
951
+
952
+ cameraView.requestFocusInWindow();
953
+ }
954
+
955
+ private Object3D Duplicate(Object3D object)
854956 {
855957 boolean temp = CameraPane.SWITCH;
856958 CameraPane.SWITCH = false;
857959
858
- copy.ExtractBigData(versiontable);
960
+ if (Grafreed.grafreed.universe.versiontable == null)
961
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
962
+
963
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
859964 // if (copy == client)
860965
861
- Object3D versions[] = copy.versionlist;
862
- copy.versionlist = null;
966
+ Object3D versions[] = object.versionlist;
967
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
968
+ object.versionlist = null;
969
+ object.versiontable = null;
970
+
971
+ Object3D parent = object.parent;
972
+ object.parent = null;
863973
864974 //byte[] compress = Compress(copy);
865
- Object3D compress = (Object3D)Grafreed.clone(copy);
975
+ Object3D compress = (Object3D)Grafreed.clone(object);
866976
867
- copy.versionlist = versions;
977
+ object.parent = parent;
868978
869
- copy.RestoreBigData(versiontable);
979
+ object.versionlist = versions;
980
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
981
+
982
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
870983
871984 CameraPane.SWITCH = temp;
872985
....@@ -1203,6 +1316,18 @@
12031316
12041317 namePanel = new cGridBag();
12051318
1319
+ //if (copy.pinned)
1320
+ {
1321
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1322
+ pinButton.setSelected(copy.pinned);
1323
+ cGridBag t = new cGridBag();
1324
+ t.preferredWidth = 2;
1325
+ t.add(pinButton);
1326
+ namePanel.add(t);
1327
+
1328
+ pinButton.addItemListener(this);
1329
+ }
1330
+
12061331 nameField = AddText(namePanel, copy.GetName());
12071332 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
12081333 oe.ctrlPanel.add(namePanel);
....@@ -1216,14 +1341,14 @@
12161341
12171342 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12181343 liveCB.setToolTipText("Animate object");
1344
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1345
+ markCB.setToolTipText("Set target transform");
12191346 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12201347 selectableCB.setToolTipText("Make object selectable");
12211348 // Return();
12221349
12231350 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12241351 hideCB.setToolTipText("Hide object");
1225
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1226
- markCB.setToolTipText("As animation target transform");
12271352
12281353 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12291354
....@@ -1425,6 +1550,7 @@
14251550
14261551 if (cam == null || !(copy.get(0) instanceof cGroup))
14271552 {
1553
+ if (Globals.DEBUG)
14281554 System.out.println("CREATE CAMERAS");
14291555 cams = new cTemplate();
14301556 cams.name = "Cameras";
....@@ -1506,6 +1632,45 @@
15061632 //frontView.object = copy;
15071633 //sideView.object = copy;
15081634
1635
+ transformPanel = new cGridBag().setVertical(true);
1636
+
1637
+ cGridBag resetTransformPanel = new cGridBag();
1638
+
1639
+ resetTransformPanel.preferredHeight = 2;
1640
+
1641
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1642
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1643
+ resetTransform.addMouseListener(new MouseAdapter()
1644
+ {
1645
+ public void mouseClicked(MouseEvent e)
1646
+ {
1647
+ ResetTransform();
1648
+ }
1649
+ });
1650
+ resetTransformPanel.add(resetTransform);
1651
+
1652
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1653
+ resetTransform.setToolTipText("Reset Translation only");
1654
+ resetTransform.addMouseListener(new MouseAdapter()
1655
+ {
1656
+ public void mouseClicked(MouseEvent e)
1657
+ {
1658
+ ResetTransform(1);
1659
+ }
1660
+ });
1661
+ resetTransformPanel.add(resetTransform);
1662
+
1663
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1664
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1665
+ resetTransform.addMouseListener(new MouseAdapter()
1666
+ {
1667
+ public void mouseClicked(MouseEvent e)
1668
+ {
1669
+ ResetTransform(2);
1670
+ }
1671
+ });
1672
+ resetTransformPanel.add(resetTransform);
1673
+
15091674 XYZPanel = new cGridBag().setVertical(true);
15101675 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15111676
....@@ -1515,6 +1680,9 @@
15151680 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15161681 //XYZPanel.setName("XYZ");
15171682
1683
+ transformPanel.add(resetTransformPanel);
1684
+ transformPanel.add(XYZPanel);
1685
+
15181686 /*
15191687 gridPanel = new JPanel(); //new BorderLayout());
15201688 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1522,12 +1690,12 @@
15221690 gridPanel.add(cameraView);
15231691 gridPanel.add(XYZPanel);
15241692 */
1525
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1526
- gridPanel.setContinuousLayout(true);
1527
- gridPanel.setOneTouchExpandable(true);
1528
- gridPanel.setDividerLocation(1.0);
1529
- gridPanel.setDividerSize(9);
1530
- gridPanel.setResizeWeight(0.85);
1693
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1694
+// gridPanel.setContinuousLayout(true);
1695
+// gridPanel.setOneTouchExpandable(true);
1696
+// gridPanel.setDividerLocation(1.0);
1697
+// gridPanel.setDividerSize(9);
1698
+// gridPanel.setResizeWeight(0.85);
15311699
15321700 // aConstraints.weighty = 0;
15331701 //System.out.println("THIS = " + this);
....@@ -1550,31 +1718,34 @@
15501718
15511719 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15521720 //tmp.setName("Edit");
1721
+ objectPanel.add(toolboxPanel);
1722
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1723
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1724
+
15531725 objectPanel.add(materialPanel);
1554
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
- objectPanel.setToolTipTextAt(0, "Material");
1726
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1727
+ objectPanel.setToolTipTextAt(1, "Material");
15561728
1729
+ objectPanel.add(skyboxPanel);
1730
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1731
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1732
+
15571733 // JPanel north = new JPanel(new BorderLayout());
15581734 // north.setName("Edit");
15591735 // north.add(ctrlPanel, BorderLayout.NORTH);
15601736 // objectPanel.add(north);
15611737 objectPanel.add(editPanel);
1562
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
- objectPanel.setToolTipTextAt(1, "Edit controls");
1738
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1739
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15641740
1565
- //if (Globals.ADVANCED)
1566
- objectPanel.add(infoPanel);
1567
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
- objectPanel.setToolTipTextAt(2, "Information");
1741
+ objectPanel.add(transformPanel);
1742
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1743
+ objectPanel.setToolTipTextAt(4, "TRS transform");
15691744
1570
- objectPanel.add(XYZPanel);
1571
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1572
- objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1573
-
1574
- objectPanel.add(toolboxPanel);
1575
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1576
- objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
1577
-
1745
+ patchMaterial = true;
1746
+ cameraView.patchMaterial = this;
1747
+ objectPanel.setSelectedIndex(1);
1748
+
15781749 /*
15791750 aConstraints.gridx = 0;
15801751 aConstraints.gridwidth = 1;
....@@ -1594,7 +1765,7 @@
15941765 scrollpane.addMouseWheelListener(this); // Default not fast enough
15951766
15961767 /*JTabbedPane*/ scenePanel = new cGridBag();
1597
- scenePanel.preferredWidth = 5;
1768
+ scenePanel.preferredWidth = 6;
15981769
15991770 JTabbedPane tabbedPane = new JTabbedPane();
16001771 tabbedPane.add(scrollpane);
....@@ -1605,11 +1776,51 @@
16051776
16061777 AddOptions(optionsPanel); //, aConstraints);
16071778
1608
- tabbedPane.add(optionsPanel);
1609
-
16101779 tabbedPane.add(FSPane = new cFileSystemPane(this));
16111780
1781
+ tabbedPane.add(optionsPanel);
1782
+
16121783 scenePanel.add(tabbedPane);
1784
+
1785
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1786
+ creditsPanel.setName("Credits");
1787
+
1788
+ cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1789
+ creditsPanel.add(ogaLabel);
1790
+
1791
+ cButton opengameartButton;
1792
+ creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1793
+ opengameartButton.setToolTipText("https://opengameart.org");
1794
+
1795
+ opengameartButton.addMouseListener(new MouseAdapter()
1796
+ {
1797
+ public void mouseClicked(MouseEvent e)
1798
+ {
1799
+ try
1800
+ {
1801
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1802
+ } catch (Exception e1)
1803
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1804
+ {
1805
+ e1.printStackTrace();
1806
+ }
1807
+ }
1808
+ });
1809
+
1810
+ for (int i=10; --i>=0;)
1811
+ {
1812
+ creditsPanel.add(new cGridBag());
1813
+ }
1814
+
1815
+ tabbedPane.add(creditsPanel);
1816
+ tabbedPane.setToolTipTextAt(3, "Credits");
1817
+
1818
+ if (Globals.ADVANCED)
1819
+ {
1820
+ tabbedPane.add(infoPanel);
1821
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1822
+ tabbedPane.setToolTipTextAt(4, "Information");
1823
+ }
16131824
16141825 /*
16151826 cTree jTree = new cTree(null);
....@@ -1631,13 +1842,13 @@
16311842 jtp.add(tree);
16321843 */
16331844
1634
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1635
- bigPanel.setContinuousLayout(true);
1636
- bigPanel.setOneTouchExpandable(true);
1637
- bigPanel.setDividerLocation(0.8);
1638
- bigPanel.setDividerSize(15);
1639
- bigPanel.setResizeWeight(0.15);
1640
- bigPanel.setName("Scene");
1845
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1846
+// bigPanel.setContinuousLayout(true);
1847
+// bigPanel.setOneTouchExpandable(true);
1848
+// bigPanel.setDividerLocation(0.8);
1849
+// bigPanel.setDividerSize(15);
1850
+// bigPanel.setResizeWeight(0.15);
1851
+// bigPanel.setName("Scene");
16411852
16421853 //bigPanel.setLayout(new BorderLayout());
16431854 //bigPanel.setSize(new Dimension(10,10));
....@@ -1681,6 +1892,23 @@
16811892 // aConstraints.gridheight = 1;
16821893
16831894 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1895
+
1896
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1897
+ new java.beans.PropertyChangeListener()
1898
+ {
1899
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1900
+ {
1901
+ if ((Integer)pce.getOldValue() == 1)
1902
+ {
1903
+ if (radio.layout != expandedLayout)
1904
+ {
1905
+ radio.layout = expandedLayout;
1906
+ radio.layout.doClick();
1907
+ }
1908
+ }
1909
+ }
1910
+ });
1911
+
16841912 framePanel.setContinuousLayout(false);
16851913 framePanel.setOneTouchExpandable(false);
16861914 //.setDividerLocation(0.8);
....@@ -1690,7 +1918,7 @@
16901918
16911919 frame.getContentPane().setLayout(new BorderLayout());
16921920 /**/
1693
- JTabbedPane worldPane = new JTabbedPane();
1921
+ //JTabbedPane worldPane = new JTabbedPane();
16941922 //worldPane.add(bigPanel);
16951923 //worldPane.add(worldPanel);
16961924 /**/
....@@ -1704,7 +1932,7 @@
17041932
17051933 cameraView.requestFocusInWindow();
17061934
1707
- gridPanel.setDividerLocation(1.0);
1935
+// gridPanel.setDividerLocation(1.0);
17081936
17091937 frame.validate();
17101938
....@@ -1738,46 +1966,416 @@
17381966 void SetupMaterial(cGridBag materialpanel)
17391967 {
17401968 cGridBag presetpanel = new cGridBag().setVertical(true);
1741
- cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
- label.addMouseListener(new MouseAdapter()
1969
+
1970
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
1971
+ skin.setToolTipText("Skin");
1972
+ skin.addMouseListener(new MouseAdapter()
17431973 {
17441974 public void mouseClicked(MouseEvent e)
17451975 {
1746
- colorField.setFloat(0);
1747
- saturationField.setFloat(1);
1976
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1977
+ cMaterial material = object.material;
1978
+
1979
+ // Skin
1980
+ colorField.setFloat(material.color);
1981
+ float saturation = material.modulation;
1982
+
1983
+ if (!cameraView.Skinshader)
1984
+ {
1985
+ saturation /= 1.5;
1986
+ }
1987
+
1988
+ saturationField.setFloat(saturation);
1989
+
1990
+ subsurfaceField.setFloat(material.subsurface);
1991
+ selfshadowField.setFloat(material.diffuseness);
1992
+ diffusenessField.setFloat(material.factor);
1993
+ shininessField.setFloat(material.shininess);
1994
+ shadowbiasField.setFloat(material.shadowbias);
1995
+ diffuseField.setFloat(material.diffuse);
1996
+ specularField.setFloat(material.specular);
1997
+
1998
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1999
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2000
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2001
+
17482002 materialtouched = true;
17492003 applySelf();
17502004 }
17512005 });
1752
- presetpanel.add(label);
2006
+ presetpanel.add(skin);
17532007
1754
- presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
- presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
- presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
- presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
- presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
- presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
- presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
- presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
- presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
- presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
- presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
- presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
- presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
- presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
- presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
- presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
- presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
- presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
- presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
- presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
2008
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2009
+ lambert.setToolTipText("Diffuse");
2010
+ lambert.addMouseListener(new MouseAdapter()
2011
+ {
2012
+ public void mouseClicked(MouseEvent e)
2013
+ {
2014
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2015
+ cMaterial material = object.material;
2016
+
2017
+ diffusenessField.setFloat(material.factor);
2018
+ selfshadowField.setFloat(material.diffuseness);
2019
+
2020
+ materialtouched = true;
2021
+ applySelf();
2022
+ }
2023
+ });
2024
+ presetpanel.add(lambert);
2025
+
2026
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2027
+ diffuse2.setToolTipText("Diffuse2");
2028
+ diffuse2.addMouseListener(new MouseAdapter()
2029
+ {
2030
+ public void mouseClicked(MouseEvent e)
2031
+ {
2032
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2033
+ cMaterial material = object.material;
2034
+
2035
+ diffusenessField.setFloat(material.factor);
2036
+ selfshadowField.setFloat(material.diffuseness);
2037
+
2038
+ materialtouched = true;
2039
+ applySelf();
2040
+ }
2041
+ });
2042
+ presetpanel.add(diffuse2);
2043
+
2044
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2045
+ diffusemoon.setToolTipText("Moon");
2046
+ diffusemoon.addMouseListener(new MouseAdapter()
2047
+ {
2048
+ public void mouseClicked(MouseEvent e)
2049
+ {
2050
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2051
+ cMaterial material = object.material;
2052
+
2053
+ diffusenessField.setFloat(material.factor);
2054
+ selfshadowField.setFloat(material.diffuseness);
2055
+
2056
+ materialtouched = true;
2057
+ applySelf();
2058
+ }
2059
+ });
2060
+ presetpanel.add(diffusemoon);
2061
+
2062
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2063
+ diffusemoon2.setToolTipText("Moon2");
2064
+ diffusemoon2.addMouseListener(new MouseAdapter()
2065
+ {
2066
+ public void mouseClicked(MouseEvent e)
2067
+ {
2068
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2069
+ cMaterial material = object.material;
2070
+
2071
+ diffusenessField.setFloat(material.factor);
2072
+ selfshadowField.setFloat(material.diffuseness);
2073
+
2074
+ materialtouched = true;
2075
+ applySelf();
2076
+ }
2077
+ });
2078
+ presetpanel.add(diffusemoon2);
2079
+
2080
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2081
+ diffusemoon3.setToolTipText("Moon3");
2082
+ diffusemoon3.addMouseListener(new MouseAdapter()
2083
+ {
2084
+ public void mouseClicked(MouseEvent e)
2085
+ {
2086
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2087
+ cMaterial material = object.material;
2088
+
2089
+ diffusenessField.setFloat(material.factor);
2090
+ selfshadowField.setFloat(material.diffuseness);
2091
+
2092
+ materialtouched = true;
2093
+ applySelf();
2094
+ }
2095
+ });
2096
+ presetpanel.add(diffusemoon3);
2097
+
2098
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2099
+ diffusesheen.setToolTipText("Sheen");
2100
+ diffusesheen.addMouseListener(new MouseAdapter()
2101
+ {
2102
+ public void mouseClicked(MouseEvent e)
2103
+ {
2104
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2105
+ cMaterial material = object.material;
2106
+
2107
+ sheenField.setFloat(material.sheen);
2108
+
2109
+ materialtouched = true;
2110
+ applySelf();
2111
+ }
2112
+ });
2113
+ presetpanel.add(diffusesheen);
2114
+
2115
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2116
+ rough.setToolTipText("Rough metal");
2117
+ rough.addMouseListener(new MouseAdapter()
2118
+ {
2119
+ public void mouseClicked(MouseEvent e)
2120
+ {
2121
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2122
+ cMaterial material = object.material;
2123
+
2124
+ shininessField.setFloat(material.shininess);
2125
+ velvetField.setFloat(material.velvet);
2126
+
2127
+ materialtouched = true;
2128
+ applySelf();
2129
+ }
2130
+ });
2131
+ presetpanel.add(rough);
2132
+
2133
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2134
+ rough2.setToolTipText("Medium metal");
2135
+ rough2.addMouseListener(new MouseAdapter()
2136
+ {
2137
+ public void mouseClicked(MouseEvent e)
2138
+ {
2139
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2140
+ cMaterial material = object.material;
2141
+
2142
+ shininessField.setFloat(material.shininess);
2143
+ lightareaField.setFloat(material.lightarea);
2144
+
2145
+ materialtouched = true;
2146
+ applySelf();
2147
+ }
2148
+ });
2149
+ presetpanel.add(rough2);
2150
+
2151
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2152
+ shini0.setToolTipText("Shiny");
2153
+ shini0.addMouseListener(new MouseAdapter()
2154
+ {
2155
+ public void mouseClicked(MouseEvent e)
2156
+ {
2157
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2158
+ cMaterial material = object.material;
2159
+
2160
+ shininessField.setFloat(material.shininess);
2161
+ lightareaField.setFloat(material.lightarea);
2162
+
2163
+ materialtouched = true;
2164
+ applySelf();
2165
+ }
2166
+ });
2167
+ presetpanel.add(shini0);
2168
+
2169
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2170
+ shini1.setToolTipText("Shiny2");
2171
+ shini1.addMouseListener(new MouseAdapter()
2172
+ {
2173
+ public void mouseClicked(MouseEvent e)
2174
+ {
2175
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2176
+ cMaterial material = object.material;
2177
+
2178
+ shininessField.setFloat(material.shininess);
2179
+ lightareaField.setFloat(material.lightarea);
2180
+
2181
+ materialtouched = true;
2182
+ applySelf();
2183
+ }
2184
+ });
2185
+ presetpanel.add(shini1);
2186
+
2187
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2188
+ shini2.setToolTipText("Shiny3");
2189
+ shini2.addMouseListener(new MouseAdapter()
2190
+ {
2191
+ public void mouseClicked(MouseEvent e)
2192
+ {
2193
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2194
+ cMaterial material = object.material;
2195
+
2196
+ shininessField.setFloat(material.shininess);
2197
+ lightareaField.setFloat(material.lightarea);
2198
+
2199
+ materialtouched = true;
2200
+ applySelf();
2201
+ }
2202
+ });
2203
+ presetpanel.add(shini2);
2204
+
2205
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2206
+ aniso.setToolTipText("AnisoU");
2207
+ aniso.addMouseListener(new MouseAdapter()
2208
+ {
2209
+ public void mouseClicked(MouseEvent e)
2210
+ {
2211
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2212
+ cMaterial material = object.material;
2213
+
2214
+ anisoField.setFloat(material.aniso);
2215
+ anisoVField.setFloat(material.anisoV);
2216
+
2217
+ materialtouched = true;
2218
+ applySelf();
2219
+ }
2220
+ });
2221
+ presetpanel.add(aniso);
2222
+
2223
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2224
+ aniso2.setToolTipText("AnisoV");
2225
+ aniso2.addMouseListener(new MouseAdapter()
2226
+ {
2227
+ public void mouseClicked(MouseEvent e)
2228
+ {
2229
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2230
+ cMaterial material = object.material;
2231
+
2232
+ anisoField.setFloat(material.aniso);
2233
+ anisoVField.setFloat(material.anisoV);
2234
+
2235
+ materialtouched = true;
2236
+ applySelf();
2237
+ }
2238
+ });
2239
+ presetpanel.add(aniso2);
2240
+
2241
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2242
+ aniso3.setToolTipText("AnisoUV");
2243
+ aniso3.addMouseListener(new MouseAdapter()
2244
+ {
2245
+ public void mouseClicked(MouseEvent e)
2246
+ {
2247
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2248
+ cMaterial material = object.material;
2249
+
2250
+ anisoField.setFloat(material.aniso);
2251
+ anisoVField.setFloat(material.anisoV);
2252
+
2253
+ materialtouched = true;
2254
+ applySelf();
2255
+ }
2256
+ });
2257
+ presetpanel.add(aniso3);
2258
+
2259
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2260
+ velvet0.setToolTipText("Velvet");
2261
+ velvet0.addMouseListener(new MouseAdapter()
2262
+ {
2263
+ public void mouseClicked(MouseEvent e)
2264
+ {
2265
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2266
+ cMaterial material = object.material;
2267
+
2268
+ diffusenessField.setFloat(material.factor);
2269
+ selfshadowField.setFloat(material.diffuseness);
2270
+ sheenField.setFloat(material.sheen);
2271
+ shininessField.setFloat(material.shininess);
2272
+ velvetField.setFloat(material.velvet);
2273
+ shiftField.setFloat(material.shift);
2274
+
2275
+ materialtouched = true;
2276
+ applySelf();
2277
+ }
2278
+ });
2279
+ presetpanel.add(velvet0);
2280
+
2281
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2282
+ bump0.setToolTipText("Bump texture");
2283
+ bump0.addMouseListener(new MouseAdapter()
2284
+ {
2285
+ public void mouseClicked(MouseEvent e)
2286
+ {
2287
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2288
+ cMaterial material = object.material;
2289
+
2290
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2291
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2292
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2293
+
2294
+ materialtouched = true;
2295
+ applySelf();
2296
+ }
2297
+ });
2298
+ presetpanel.add(bump0);
2299
+
2300
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2301
+ borderShader.setToolTipText("Border fade");
2302
+ borderShader.addMouseListener(new MouseAdapter()
2303
+ {
2304
+ public void mouseClicked(MouseEvent e)
2305
+ {
2306
+ borderfadeField.setFloat(0.5);
2307
+ opacityField.setFloat(0.75);
2308
+
2309
+ materialtouched = true;
2310
+ applySelf();
2311
+ }
2312
+ });
2313
+ presetpanel.add(borderShader);
2314
+
2315
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2316
+ halo.setToolTipText("Halo");
2317
+ halo.addMouseListener(new MouseAdapter()
2318
+ {
2319
+ public void mouseClicked(MouseEvent e)
2320
+ {
2321
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2322
+ cMaterial material = object.material;
2323
+
2324
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2325
+
2326
+ materialtouched = true;
2327
+ applySelf();
2328
+ }
2329
+ });
2330
+ presetpanel.add(halo);
2331
+
2332
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2333
+ candle.setToolTipText("Candle");
2334
+ candle.addMouseListener(new MouseAdapter()
2335
+ {
2336
+ public void mouseClicked(MouseEvent e)
2337
+ {
2338
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2339
+ cMaterial material = object.material;
2340
+
2341
+ subsurfaceField.setFloat(material.subsurface);
2342
+ shadowbiasField.setFloat(material.shadowbias);
2343
+ ambientField.setFloat(material.ambient);
2344
+ specularField.setFloat(material.specular);
2345
+ lightareaField.setFloat(material.lightarea);
2346
+ shininessField.setFloat(material.shininess);
2347
+
2348
+ materialtouched = true;
2349
+ applySelf();
2350
+ }
2351
+ });
2352
+ presetpanel.add(candle);
2353
+
2354
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2355
+ shadowShader.setToolTipText("Shadow");
2356
+ shadowShader.addMouseListener(new MouseAdapter()
2357
+ {
2358
+ public void mouseClicked(MouseEvent e)
2359
+ {
2360
+ diffuseField.setFloat(0.001);
2361
+ ambientField.setFloat(0.001);
2362
+ cameraField.setFloat(0.001);
2363
+ specularField.setFloat(0.001);
2364
+ fakedepthField.setFloat(0.001);
2365
+ opacityField.setFloat(0.6);
2366
+
2367
+ materialtouched = true;
2368
+ applySelf();
2369
+ }
2370
+ });
2371
+ presetpanel.add(shadowShader);
17742372
17752373 cGridBag panel = new cGridBag().setVertical(true);
17762374
17772375 presetpanel.preferredWidth = 1;
17782376
1779
- materialpanel.add(panel);
17802377 materialpanel.add(presetpanel);
2378
+ materialpanel.add(panel);
17812379
17822380 panel.preferredWidth = 8;
17832381
....@@ -1788,19 +2386,19 @@
17882386
17892387 cGridBag editBar = new cGridBag().setVertical(false);
17902388
1791
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2389
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
17922390 createMaterialButton.setToolTipText("Create material");
17932391
17942392 /*
17952393 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
17962394 */
17972395
1798
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2396
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
17992397 clearMaterialButton.setToolTipText("Clear material");
18002398
18012399 if (Globals.ADVANCED)
18022400 {
1803
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2401
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
18042402 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
18052403 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
18062404 }
....@@ -1821,9 +2419,20 @@
18212419
18222420 cGridBag huepanel = new cGridBag();
18232421 cGridBag huelabel = new cGridBag();
1824
- label = GetLabel("icons/hue.png", false);
1825
- label.fit = true;
1826
- huelabel.add(label);
2422
+ cLabel hue = GetLabel("icons/hue.png", false);
2423
+ hue.fit = true;
2424
+
2425
+ hue.addMouseListener(new MouseAdapter()
2426
+ {
2427
+ public void mousePressed(MouseEvent e)
2428
+ {
2429
+ int x = e.getX();
2430
+
2431
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2432
+ }
2433
+ });
2434
+
2435
+ huelabel.add(hue);
18272436 huelabel.preferredWidth = 20;
18282437 huepanel.add(new cGridBag()); // Label
18292438 huepanel.add(huelabel); // Field/slider
....@@ -3099,32 +3708,8 @@
30993708
31003709 if (multiplyToggle != null)
31013710 multiplyToggle.setSelected(mat.multiply);
3102
-
3103
- assert (object.projectedVertices != null);
3104
-
3105
- if (object.projectedVertices.length <= 2)
3106
- {
3107
- // Side effect...
3108
- Object3D.cVector2[] keep = object.projectedVertices;
3109
- object.projectedVertices = new Object3D.cVector2[3];
3110
- for (int i = 0; i < 3; i++)
3111
- {
3112
- if (i < keep.length)
3113
- {
3114
- object.projectedVertices[i] = keep[i];
3115
- } else
3116
- {
3117
- object.projectedVertices[i] = new Object3D.cVector2();
3118
- }
3119
- /*
3120
- if(keep.length == 0)
3121
- object.projectedVertices[0] = new Object3D.cVector2();
3122
- else
3123
- object.projectedVertices[0] = keep[0];
3124
- object.projectedVertices[1] = new Object3D.cVector2();
3125
- */
3126
- }
3127
- }
3711
+
3712
+ AllocProjectedVertices(object);
31283713
31293714 SetMaterial(mat, object.projectedVertices);
31303715 }
....@@ -3244,6 +3829,17 @@
32443829 public void itemStateChanged(ItemEvent event)
32453830 {
32463831 // System.out.println("Propagate = " + propagate);
3832
+ if (event.getSource() == pinButton)
3833
+ {
3834
+ copy.pinned ^= true;
3835
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3836
+ {
3837
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3838
+ copy.CloseUI();
3839
+ //copy.editWindow.refreshContents();
3840
+ }
3841
+ }
3842
+ else
32473843 if (event.getSource() == propagateToggle)
32483844 {
32493845 propagate ^= true;
....@@ -3423,7 +4019,7 @@
34234019 //System.out.println("ObjEditor " + event);
34244020 applySelf0(true);
34254021 //parent.applySelf();
3426
- objEditor.refreshContents();
4022
+ // conflicts with requestFocus objEditor.refreshContents();
34274023 } else if (source == resetButton)
34284024 {
34294025 CameraPane.fullreset = true;
....@@ -3603,12 +4199,15 @@
36034199
36044200 void New()
36054201 {
3606
- while (copy.Size() > 1)
4202
+ while (copy.Size() > 0)
36074203 {
3608
- copy.remove(1);
4204
+ copy.remove(0);
36094205 }
36104206
4207
+ copy.selection.clear();
4208
+
36114209 ResetModel();
4210
+ SetupViews();
36124211 objEditor.refreshContents();
36134212 }
36144213
....@@ -3716,7 +4315,7 @@
37164315 {
37174316 //Save(true);
37184317 Replace();
3719
- SetUndoStates();
4318
+ SetVersionStates();
37204319 }
37214320
37224321 private boolean Equal(byte[] compress, byte[] name)
....@@ -3735,16 +4334,30 @@
37354334 return true;
37364335 }
37374336
3738
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4337
+ void DeleteVersion()
4338
+ {
4339
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4340
+ {
4341
+ copy.versionlist[i] = copy.versionlist[i+1];
4342
+ }
4343
+
4344
+ if (copy.versionlist[copy.versionindex] == null)
4345
+ copy.versionindex -= 1;
4346
+
4347
+ if (copy.versionindex != -1)
4348
+ CopyChanged();
4349
+
4350
+ SetVersionStates();
4351
+ }
37394352
37404353 public boolean Save(boolean user)
37414354 {
37424355 System.err.println("Save");
37434356 Replace();
37444357
3745
- cRadio tab = GetCurrentTab();
4358
+ //cRadio tab = GetCurrentTab();
37464359
3747
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
4360
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
37484361
37494362 boolean thesame = false;
37504363
....@@ -3756,6 +4369,11 @@
37564369 //EditorFrame.m_MainFrame.requestFocusInWindow();
37574370 if (!thesame)
37584371 {
4372
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4373
+ {
4374
+ copy.versionlist[i] = copy.versionlist[i-1];
4375
+ }
4376
+
37594377 //tab.user[tab.versionindex] = user;
37604378 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37614379
....@@ -3769,13 +4387,13 @@
37694387
37704388 //assert(hashtable.isEmpty());
37714389
3772
- for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3773
- {
3774
- //tab.user[i] = false;
3775
- copy.versionlist[i] = null;
3776
- }
4390
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4391
+// {
4392
+// //tab.user[i] = false;
4393
+// copy.versionlist[i] = null;
4394
+// }
37774395
3778
- SetUndoStates();
4396
+ SetVersionStates();
37794397
37804398 // test save
37814399 if (false)
....@@ -3828,17 +4446,19 @@
38284446 GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
38294447 flashIt = true;
38304448
3831
- refreshContents(false);
4449
+ //refreshContents(false);
38324450 }
38334451
3834
- void CopyChanged(Object3D obj)
4452
+ void CopyChanged()
38354453 {
3836
- SetUndoStates();
4454
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4455
+
4456
+ SetVersionStates();
38374457
38384458 boolean temp = CameraPane.SWITCH;
38394459 CameraPane.SWITCH = false;
38404460
3841
- copy.ExtractBigData(versiontable);
4461
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
38424462
38434463 copy.clear();
38444464
....@@ -3850,7 +4470,7 @@
38504470 copy.add(obj.get(i));
38514471 }
38524472
3853
- copy.RestoreBigData(versiontable);
4473
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
38544474
38554475 CameraPane.SWITCH = temp;
38564476
....@@ -3875,13 +4495,15 @@
38754495 }
38764496 }
38774497
3878
- refreshContents();
4498
+ refreshContents(true);
38794499 }
38804500
3881
- cButton undoButton;
4501
+ cButton previousVersionButton;
38824502 cButton restoreButton;
38834503 cButton replaceButton;
3884
- cButton redoButton;
4504
+ cButton nextVersionButton;
4505
+ cButton saveVersionButton;
4506
+ cButton deleteVersionButton;
38854507
38864508 boolean muteSlider;
38874509
....@@ -3898,30 +4520,55 @@
38984520 return count;
38994521 }
39004522
3901
- void SetUndoStates()
4523
+ public cGridBag versionSliderPane;
4524
+
4525
+ void SetVersionStates()
39024526 {
3903
- cRadio tab = GetCurrentTab();
4527
+ //if (true)
4528
+ // return;
4529
+
4530
+ //cRadio tab = GetCurrentTab();
39044531
3905
- restoreButton.setEnabled(copy.versionindex != -1);
3906
- replaceButton.setEnabled(copy.versionindex != -1);
3907
-
3908
- undoButton.setEnabled(copy.versionindex > 0);
3909
- redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3910
-
3911
- muteSlider = true;
3912
- versionSlider.setMaximum(VersionCount() - 1);
3913
- versionSlider.setInteger(copy.versionindex);
3914
- muteSlider = false;
4532
+ if (copy.versionlist == null)
4533
+ {
4534
+ saveVersionButton.setEnabled(false);
4535
+ restoreButton.setEnabled(false);
4536
+ replaceButton.setEnabled(false);
4537
+ previousVersionButton.setEnabled(false);
4538
+ nextVersionButton.setEnabled(false);
4539
+ deleteVersionButton.setEnabled(false);
4540
+ versionSliderPane.setVisible(false);
4541
+ }
4542
+ else
4543
+ {
4544
+ restoreButton.setEnabled(copy.versionindex != -1);
4545
+ replaceButton.setEnabled(copy.versionindex != -1);
4546
+
4547
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4548
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4549
+
4550
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4551
+ //copy.versionlist[copy.versionindex + 1] != null);
4552
+
4553
+ muteSlider = true;
4554
+ versionSlider.setMinimum(0);
4555
+ versionSlider.setMaximum(VersionCount() - 1);
4556
+ versionSlider.setInteger(copy.versionindex);
4557
+ versionSlider.setEnabled(copy.versionindex != -1);
4558
+ muteSlider = false;
4559
+
4560
+ versionSliderPane.setVisible(true);
4561
+ }
39154562 }
39164563
3917
- public boolean Undo()
4564
+ public boolean PreviousVersion()
39184565 {
39194566 // Option?
39204567 Replace();
39214568
39224569 System.err.println("Undo");
39234570
3924
- cRadio tab = GetCurrentTab();
4571
+ //cRadio tab = GetCurrentTab();
39254572
39264573 if (copy.versionindex == 0)
39274574 {
....@@ -3944,7 +4591,7 @@
39444591
39454592 copy.versionindex -= 1;
39464593
3947
- CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
4594
+ CopyChanged();
39484595
39494596 return true;
39504597 }
....@@ -3953,7 +4600,7 @@
39534600 {
39544601 System.err.println("Restore");
39554602
3956
- cRadio tab = GetCurrentTab();
4603
+ //cRadio tab = GetCurrentTab();
39574604
39584605 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
39594606 {
....@@ -3962,16 +4609,16 @@
39624609 }
39634610
39644611 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
- CopyChanged(copy.versionlist[copy.versionindex]);
4612
+ CopyChanged();
39664613
39674614 return true;
39684615 }
39694616
39704617 public boolean Replace()
39714618 {
3972
- System.err.println("Replace");
4619
+ //System.err.println("Replace");
39734620
3974
- cRadio tab = GetCurrentTab();
4621
+ //cRadio tab = GetCurrentTab();
39754622
39764623 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
39774624 {
....@@ -3979,17 +4626,17 @@
39794626 return false;
39804627 }
39814628
3982
- copy.versionlist[copy.versionindex] = CompressCopy();
4629
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
39834630
39844631 return true;
39854632 }
39864633
3987
- public void Redo()
4634
+ public void NextVersion()
39884635 {
39894636 // Option?
39904637 Replace();
39914638
3992
- cRadio tab = GetCurrentTab();
4639
+ //cRadio tab = GetCurrentTab();
39934640
39944641 if (copy.versionlist[copy.versionindex + 1] == null)
39954642 {
....@@ -3999,7 +4646,7 @@
39994646
40004647 copy.versionindex += 1;
40014648
4002
- CopyChanged(copy.versionlist[copy.versionindex]);
4649
+ CopyChanged();
40034650
40044651 //if (!tab.user[tab.versionindex])
40054652 // tab.graphs[tab.versionindex] = null;
....@@ -4196,6 +4843,12 @@
41964843 // else
41974844 // applySelf(true);
41984845 // }
4846
+
4847
+ boolean Equal(double a, double b)
4848
+ {
4849
+ return Math.abs(a - b) < 0.001;
4850
+ }
4851
+
41994852 void applySelf0(boolean name)
42004853 {
42014854 if (name)
....@@ -4245,29 +4898,52 @@
42454898 {
42464899 cMaterial mat = copy.material;
42474900
4248
- colorField.SetToolTipValue((mat.color));
4249
- saturationField.SetToolTipValue((mat.modulation));
4250
- metalnessField.SetToolTipValue((mat.metalness));
4251
- diffuseField.SetToolTipValue((mat.diffuse));
4252
- specularField.SetToolTipValue((mat.specular));
4253
- shininessField.SetToolTipValue((mat.shininess));
4254
- shiftField.SetToolTipValue((mat.shift));
4255
- ambientField.SetToolTipValue((mat.ambient));
4256
- lightareaField.SetToolTipValue((mat.lightarea));
4257
- diffusenessField.SetToolTipValue((mat.factor));
4258
- velvetField.SetToolTipValue((mat.velvet));
4259
- sheenField.SetToolTipValue((mat.sheen));
4260
- subsurfaceField.SetToolTipValue((mat.subsurface));
4261
- backlitField.SetToolTipValue((mat.bump));
4262
- anisoField.SetToolTipValue((mat.aniso));
4263
- anisoVField.SetToolTipValue((mat.anisoV));
4264
- cameraField.SetToolTipValue((mat.cameralight));
4265
- selfshadowField.SetToolTipValue((mat.diffuseness));
4266
- shadowField.SetToolTipValue((mat.shadow));
4267
- textureField.SetToolTipValue((mat.texture));
4268
- opacityField.SetToolTipValue((mat.opacity));
4269
- fakedepthField.SetToolTipValue((mat.fakedepth));
4270
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4901
+ if (!Equal(colorField.getFloat(), mat.color))
4902
+ colorField.SetToolTipValue((mat.color));
4903
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4904
+ saturationField.SetToolTipValue((mat.modulation));
4905
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4906
+ metalnessField.SetToolTipValue((mat.metalness));
4907
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4908
+ diffuseField.SetToolTipValue((mat.diffuse));
4909
+ if (!Equal(specularField.getFloat(), mat.specular))
4910
+ specularField.SetToolTipValue((mat.specular));
4911
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4912
+ shininessField.SetToolTipValue((mat.shininess));
4913
+ if (!Equal(shiftField.getFloat(), mat.shift))
4914
+ shiftField.SetToolTipValue((mat.shift));
4915
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4916
+ ambientField.SetToolTipValue((mat.ambient));
4917
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4918
+ lightareaField.SetToolTipValue((mat.lightarea));
4919
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4920
+ diffusenessField.SetToolTipValue((mat.factor));
4921
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4922
+ velvetField.SetToolTipValue((mat.velvet));
4923
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4924
+ sheenField.SetToolTipValue((mat.sheen));
4925
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4926
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4927
+ if (!Equal(backlitField.getFloat(), mat.bump))
4928
+ backlitField.SetToolTipValue((mat.bump));
4929
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4930
+ anisoField.SetToolTipValue((mat.aniso));
4931
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4932
+ anisoVField.SetToolTipValue((mat.anisoV));
4933
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4934
+ cameraField.SetToolTipValue((mat.cameralight));
4935
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4936
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4937
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4938
+ shadowField.SetToolTipValue((mat.shadow));
4939
+ if (!Equal(textureField.getFloat(), mat.texture))
4940
+ textureField.SetToolTipValue((mat.texture));
4941
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4942
+ opacityField.SetToolTipValue((mat.opacity));
4943
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4944
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4945
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4946
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
42714947 }
42724948
42734949 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4302,17 +4978,20 @@
43024978
43034979 public void stateChanged(ChangeEvent e)
43044980 {
4305
- // assert(false);
4981
+ // assert(false);
43064982 if (e.getSource() == versionSlider)
43074983 {
43084984 if (muteSlider)
43094985 return;
43104986
4987
+ Replace();
4988
+
43114989 int version = versionSlider.getInteger();
43124990
4313
- if (copy.versionlist[version] != null)
4991
+ if (version != -1 && copy.versionlist[version] != null)
43144992 {
4315
- CopyChanged(copy.versionlist[copy.versionindex = version]);
4993
+ copy.versionindex = version;
4994
+ CopyChanged();
43164995 }
43174996
43184997 return;
....@@ -4353,7 +5032,7 @@
43535032 //System.out.println("stateChanged = " + this);
43545033 materialtouched = true;
43555034
4356
- if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
5035
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
43575036 {
43585037 saturationField.setFloat(1);
43595038 }
....@@ -4666,6 +5345,11 @@
46665345 ctrlPanel.validate(); // ? new
46675346 ctrlPanel.repaint();
46685347 }
5348
+
5349
+ if (previousVersionButton != null && copy.versionlist != null)
5350
+ SetVersionStates();
5351
+
5352
+ cameraView.requestFocusInWindow();
46695353 }
46705354
46715355 static TweenManager tweenManager = new TweenManager();
....@@ -4697,7 +5381,7 @@
46975381 // group = (Composite) group.get(0);
46985382 // }
46995383
4700
- System.out.println("makeSomething of " + thing);
5384
+ //System.out.println("makeSomething of " + thing);
47015385
47025386 /*
47035387 if (deselect && jList != null)
....@@ -5051,11 +5735,15 @@
50515735
50525736 copy.versionlist = readobj.versionlist;
50535737 copy.versionindex = readobj.versionindex;
5738
+ copy.versiontable = readobj.versiontable;
50545739
50555740 if (copy.versionlist == null)
50565741 {
5742
+ // Backward compatibility
50575743 copy.versionlist = new Object3D[100];
50585744 copy.versionindex = -1;
5745
+
5746
+ //Save(true);
50595747 }
50605748
50615749 //? SetUndoStates();
....@@ -5070,7 +5758,7 @@
50705758 {
50715759 if (Grafreed.standAlone)
50725760 {
5073
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5761
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
50745762 browser.show();
50755763 String filename = browser.getFile();
50765764 if (filename != null && filename.length() > 0)
....@@ -5147,6 +5835,8 @@
51475835
51485836 void save()
51495837 {
5838
+ Replace();
5839
+
51505840 if (lastname == null)
51515841 {
51525842 return;
....@@ -5389,6 +6079,7 @@
53896079 ButtonGroup buttonGroup;
53906080
53916081 cGridBag toolboxPanel;
6082
+ cGridBag skyboxPanel;
53926083 cGridBag materialPanel;
53936084 cGridBag ctrlPanel;
53946085
....@@ -5400,6 +6091,7 @@
54006091 boolean materialFlushed;
54016092 Object3D latestObject;
54026093
6094
+ cGridBag transformPanel;
54036095 cGridBag XYZPanel;
54046096
54056097 JSplitPane gridPanel;
....@@ -5493,6 +6185,7 @@
54936185 cNumberSlider anisoField;
54946186 JLabel anisoVLabel;
54956187 cNumberSlider anisoVField;
6188
+
54966189 JLabel cameraLabel;
54976190 cNumberSlider cameraField;
54986191 JLabel selfshadowLabel;
....@@ -5507,6 +6200,7 @@
55076200 cNumberSlider fakedepthField;
55086201 JLabel shadowbiasLabel;
55096202 cNumberSlider shadowbiasField;
6203
+
55106204 JLabel bumpLabel;
55116205 cNumberSlider bumpField;
55126206 JLabel noiseLabel;