Normand Briere
2019-08-20 7dc9a8879ed29a7693d617afcb48014504ddc4a9
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());
....@@ -390,8 +460,11 @@
390460 importOBJItem.addActionListener(this);
391461 import3DSItem = menu.add(new MenuItem("3DS file..."));
392462 import3DSItem.addActionListener(this);
463
+ if (Globals.ADVANCED)
464
+ {
393465 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
394466 importVRMLX3DItem.addActionListener(this);
467
+ }
395468 menu.add("-");
396469 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
397470 importGFDItem.addActionListener(this);
....@@ -426,6 +499,8 @@
426499
427500 ChangeListener changeListener = new ChangeListener()
428501 {
502
+ //String name;
503
+
429504 public void stateChanged(ChangeEvent changeEvent)
430505 {
431506 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -444,7 +519,37 @@
444519 // EditSelection(false);
445520 // }
446521
447
- refreshContents(false); // To refresh Info tab
522
+// if (objectPanel.getSelectedIndex() == 4)
523
+// {
524
+// name = copy.skyboxname;
525
+//
526
+// if (name == null)
527
+// {
528
+// name = "";
529
+// }
530
+//
531
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
532
+// copy.skyboxext = "jpg";
533
+// }
534
+// else
535
+// {
536
+// if (name != null)
537
+// {
538
+// if (name.equals(""))
539
+// {
540
+// copy.skyboxname = null;
541
+// copy.skyboxext = null;
542
+// }
543
+// else
544
+// {
545
+// copy.skyboxname = name;
546
+// }
547
+// }
548
+// }
549
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
550
+
551
+// refreshContents(false); // To refresh Info tab
552
+ cameraView.repaint();
448553 }
449554 };
450555 objectPanel.addChangeListener(changeListener);
....@@ -466,6 +571,8 @@
466571
467572 toolboxPanel = new cGridBag().setVertical(true);
468573 //toolboxPanel.setName("Toolbox");
574
+
575
+ skyboxPanel = new cGridBag().setVertical(true);
469576
470577 materialPanel = new cGridBag().setVertical(false);
471578 //materialPanel.setName("Material");
....@@ -751,6 +858,7 @@
751858 boolean maximized;
752859
753860 cButton fullscreenLayout;
861
+ cButton expandedLayout;
754862
755863 void Minimize()
756864 {
....@@ -790,10 +898,12 @@
790898 cButton minButton;
791899 cButton maxButton;
792900 cButton fullButton;
901
+ cButton collapseButton;
902
+ cButton maximize3DButton;
793903
794904 void ToggleFullScreen()
795905 {
796
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
906
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797907
798908 cameraView.ToggleFullScreen();
799909
....@@ -814,13 +924,13 @@
814924 // X frame.getContentPane().remove(/*"Center",*/bigThree);
815925 // X framePanel.add(bigThree);
816926 // X frame.getContentPane().add(/*"Center",*/framePanel);
817
- framePanel.setDividerLocation(46);
927
+// framePanel.setDividerLocation(46); // icons are 24x24
818928
819929 //frame.setVisible(true);
820
- radio.layout = keepButton;
930
+// radio.layout = keepButton;
821931 //theFrame = null;
822932 keepButton = null;
823
- radio.layout.doClick();
933
+// radio.layout.doClick();
824934
825935 } else
826936 {
....@@ -841,10 +951,10 @@
841951 // X frame.getContentPane().remove(/*"Center",*/framePanel);
842952 // X framePanel.remove(bigThree);
843953 // X frame.getContentPane().add(/*"Center",*/bigThree);
844
- framePanel.setDividerLocation(0);
954
+// framePanel.setDividerLocation(0);
845955
846
- radio.layout = fullscreenLayout;
847
- radio.layout.doClick();
956
+// radio.layout = fullscreenLayout;
957
+// radio.layout.doClick();
848958 //frame.setVisible(true);
849959 }
850960 frame.validate();
....@@ -852,23 +962,42 @@
852962 cameraView.requestFocusInWindow();
853963 }
854964
855
- private Object3D CompressCopy()
965
+ void CollapseToolbar()
966
+ {
967
+ framePanel.setDividerLocation(0);
968
+ //frame.validate();
969
+
970
+ cameraView.requestFocusInWindow();
971
+ }
972
+
973
+ private Object3D Duplicate(Object3D object)
856974 {
857975 boolean temp = CameraPane.SWITCH;
858976 CameraPane.SWITCH = false;
859977
860
- copy.ExtractBigData(versiontable);
978
+ if (Grafreed.grafreed.universe.versiontable == null)
979
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
980
+
981
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
861982 // if (copy == client)
862983
863
- Object3D versions[] = copy.versionlist;
864
- copy.versionlist = null;
984
+ Object3D versions[] = object.versionlist;
985
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
986
+ object.versionlist = null;
987
+ object.versiontable = null;
988
+
989
+ Object3D parent = object.parent;
990
+ object.parent = null;
865991
866992 //byte[] compress = Compress(copy);
867
- Object3D compress = (Object3D)Grafreed.clone(copy);
993
+ Object3D compress = (Object3D)Grafreed.clone(object);
868994
869
- copy.versionlist = versions;
995
+ object.parent = parent;
870996
871
- copy.RestoreBigData(versiontable);
997
+ object.versionlist = versions;
998
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
999
+
1000
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
8721001
8731002 CameraPane.SWITCH = temp;
8741003
....@@ -1205,6 +1334,18 @@
12051334
12061335 namePanel = new cGridBag();
12071336
1337
+ //if (copy.pinned)
1338
+ {
1339
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1340
+ pinButton.setSelected(copy.pinned);
1341
+ cGridBag t = new cGridBag();
1342
+ t.preferredWidth = 2;
1343
+ t.add(pinButton);
1344
+ namePanel.add(t);
1345
+
1346
+ pinButton.addItemListener(this);
1347
+ }
1348
+
12081349 nameField = AddText(namePanel, copy.GetName());
12091350 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
12101351 oe.ctrlPanel.add(namePanel);
....@@ -1218,14 +1359,14 @@
12181359
12191360 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12201361 liveCB.setToolTipText("Animate object");
1362
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1363
+ markCB.setToolTipText("Set target transform");
12211364 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12221365 selectableCB.setToolTipText("Make object selectable");
12231366 // Return();
12241367
12251368 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12261369 hideCB.setToolTipText("Hide object");
1227
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1228
- markCB.setToolTipText("As animation target transform");
12291370
12301371 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12311372
....@@ -1427,22 +1568,9 @@
14271568
14281569 if (cam == null || !(copy.get(0) instanceof cGroup))
14291570 {
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);
1571
+ if (Globals.DEBUG)
1572
+ System.out.println("CREATE CAMERAS");
1573
+ cams = CreateCameras();
14461574 } else
14471575 {
14481576 cams = (cGroup) copy.get(0);
....@@ -1508,6 +1636,45 @@
15081636 //frontView.object = copy;
15091637 //sideView.object = copy;
15101638
1639
+ transformPanel = new cGridBag().setVertical(true);
1640
+
1641
+ cGridBag resetTransformPanel = new cGridBag();
1642
+
1643
+ resetTransformPanel.preferredHeight = 2;
1644
+
1645
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1646
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1647
+ resetTransform.addMouseListener(new MouseAdapter()
1648
+ {
1649
+ public void mouseClicked(MouseEvent e)
1650
+ {
1651
+ ResetTransform();
1652
+ }
1653
+ });
1654
+ resetTransformPanel.add(resetTransform);
1655
+
1656
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1657
+ resetTransform.setToolTipText("Reset Translation only");
1658
+ resetTransform.addMouseListener(new MouseAdapter()
1659
+ {
1660
+ public void mouseClicked(MouseEvent e)
1661
+ {
1662
+ ResetTransform(1);
1663
+ }
1664
+ });
1665
+ resetTransformPanel.add(resetTransform);
1666
+
1667
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1668
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1669
+ resetTransform.addMouseListener(new MouseAdapter()
1670
+ {
1671
+ public void mouseClicked(MouseEvent e)
1672
+ {
1673
+ ResetTransform(2);
1674
+ }
1675
+ });
1676
+ resetTransformPanel.add(resetTransform);
1677
+
15111678 XYZPanel = new cGridBag().setVertical(true);
15121679 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15131680
....@@ -1517,6 +1684,9 @@
15171684 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15181685 //XYZPanel.setName("XYZ");
15191686
1687
+ transformPanel.add(resetTransformPanel);
1688
+ transformPanel.add(XYZPanel);
1689
+
15201690 /*
15211691 gridPanel = new JPanel(); //new BorderLayout());
15221692 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1524,12 +1694,12 @@
15241694 gridPanel.add(cameraView);
15251695 gridPanel.add(XYZPanel);
15261696 */
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);
1697
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1698
+// gridPanel.setContinuousLayout(true);
1699
+// gridPanel.setOneTouchExpandable(true);
1700
+// gridPanel.setDividerLocation(1.0);
1701
+// gridPanel.setDividerSize(9);
1702
+// gridPanel.setResizeWeight(0.85);
15331703
15341704 // aConstraints.weighty = 0;
15351705 //System.out.println("THIS = " + this);
....@@ -1552,31 +1722,34 @@
15521722
15531723 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15541724 //tmp.setName("Edit");
1555
- objectPanel.add(materialPanel);
1556
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
- objectPanel.setToolTipTextAt(0, "Material");
1558
-
1725
+ objectPanel.add(skyboxPanel);
1726
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1727
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1728
+
15591729 objectPanel.add(toolboxPanel);
15601730 objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1561
- objectPanel.setToolTipTextAt(1, "Objects & backgrounds");
1731
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
15621732
1733
+ objectPanel.add(materialPanel);
1734
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1735
+ objectPanel.setToolTipTextAt(2, "Material");
1736
+
15631737 // JPanel north = new JPanel(new BorderLayout());
15641738 // north.setName("Edit");
15651739 // north.add(ctrlPanel, BorderLayout.NORTH);
15661740 // objectPanel.add(north);
15671741 objectPanel.add(editPanel);
1568
- objectPanel.setIconAt(2, GetIcon("icons/write.png"));
1569
- objectPanel.setToolTipTextAt(2, "Edit controls");
1742
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1743
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15701744
1571
- //if (Globals.ADVANCED)
1572
- objectPanel.add(infoPanel);
1573
- objectPanel.setIconAt(3, GetIcon("icons/info.png"));
1574
- objectPanel.setToolTipTextAt(3, "Information");
1575
-
1576
- objectPanel.add(XYZPanel);
1745
+ objectPanel.add(transformPanel);
15771746 objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1578
- objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1747
+ objectPanel.setToolTipTextAt(4, "TRS transform");
15791748
1749
+ patchMaterial = true;
1750
+ cameraView.patchMaterial = this;
1751
+ objectPanel.setSelectedIndex(2);
1752
+
15801753 /*
15811754 aConstraints.gridx = 0;
15821755 aConstraints.gridwidth = 1;
....@@ -1596,7 +1769,7 @@
15961769 scrollpane.addMouseWheelListener(this); // Default not fast enough
15971770
15981771 /*JTabbedPane*/ scenePanel = new cGridBag();
1599
- scenePanel.preferredWidth = 5;
1772
+ scenePanel.preferredWidth = 6;
16001773
16011774 JTabbedPane tabbedPane = new JTabbedPane();
16021775 tabbedPane.add(scrollpane);
....@@ -1607,11 +1780,108 @@
16071780
16081781 AddOptions(optionsPanel); //, aConstraints);
16091782
1610
- tabbedPane.add(optionsPanel);
1611
-
16121783 tabbedPane.add(FSPane = new cFileSystemPane(this));
16131784
1785
+ tabbedPane.add(optionsPanel);
1786
+
16141787 scenePanel.add(tabbedPane);
1788
+
1789
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1790
+ creditsPanel.setName("Credits");
1791
+
1792
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1793
+ creditsPanel.add(ogaLabel);
1794
+
1795
+ cButton creditButton;
1796
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1797
+ creditButton.setToolTipText("https://opengameart.org");
1798
+
1799
+ creditButton.addMouseListener(new MouseAdapter()
1800
+ {
1801
+ public void mouseClicked(MouseEvent e)
1802
+ {
1803
+ try
1804
+ {
1805
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1806
+ } catch (Exception e1)
1807
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1808
+ {
1809
+ e1.printStackTrace();
1810
+ }
1811
+ }
1812
+ });
1813
+
1814
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1815
+ creditsPanel.add(ogaLabel);
1816
+
1817
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1818
+ creditButton.setToolTipText("https://3delicious.net");
1819
+
1820
+ creditButton.addMouseListener(new MouseAdapter()
1821
+ {
1822
+ public void mouseClicked(MouseEvent e)
1823
+ {
1824
+ try
1825
+ {
1826
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1827
+ } catch (Exception e1)
1828
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1829
+ {
1830
+ e1.printStackTrace();
1831
+ }
1832
+ }
1833
+ });
1834
+
1835
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1836
+ creditButton.setToolTipText("https://archive3d.net");
1837
+
1838
+ creditButton.addMouseListener(new MouseAdapter()
1839
+ {
1840
+ public void mouseClicked(MouseEvent e)
1841
+ {
1842
+ try
1843
+ {
1844
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1845
+ } catch (Exception e1)
1846
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1847
+ {
1848
+ e1.printStackTrace();
1849
+ }
1850
+ }
1851
+ });
1852
+
1853
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1854
+ creditButton.setToolTipText("https://turbosquid.com");
1855
+
1856
+ creditButton.addMouseListener(new MouseAdapter()
1857
+ {
1858
+ public void mouseClicked(MouseEvent e)
1859
+ {
1860
+ try
1861
+ {
1862
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1863
+ } catch (Exception e1)
1864
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1865
+ {
1866
+ e1.printStackTrace();
1867
+ }
1868
+ }
1869
+ });
1870
+
1871
+ for (int i=6; --i>=0;)
1872
+ {
1873
+ creditsPanel.add(new cGridBag());
1874
+ }
1875
+
1876
+ tabbedPane.add(creditsPanel);
1877
+ tabbedPane.setToolTipTextAt(3, "Credits");
1878
+
1879
+ if (Globals.ADVANCED)
1880
+ {
1881
+ tabbedPane.add(infoPanel);
1882
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1883
+ tabbedPane.setToolTipTextAt(4, "Information");
1884
+ }
16151885
16161886 /*
16171887 cTree jTree = new cTree(null);
....@@ -1633,13 +1903,13 @@
16331903 jtp.add(tree);
16341904 */
16351905
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");
1906
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1907
+// bigPanel.setContinuousLayout(true);
1908
+// bigPanel.setOneTouchExpandable(true);
1909
+// bigPanel.setDividerLocation(0.8);
1910
+// bigPanel.setDividerSize(15);
1911
+// bigPanel.setResizeWeight(0.15);
1912
+// bigPanel.setName("Scene");
16431913
16441914 //bigPanel.setLayout(new BorderLayout());
16451915 //bigPanel.setSize(new Dimension(10,10));
....@@ -1683,6 +1953,23 @@
16831953 // aConstraints.gridheight = 1;
16841954
16851955 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1956
+
1957
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1958
+ new java.beans.PropertyChangeListener()
1959
+ {
1960
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1961
+ {
1962
+ if ((Integer)pce.getOldValue() == 1)
1963
+ {
1964
+ if (radio.layout != expandedLayout)
1965
+ {
1966
+ radio.layout = expandedLayout;
1967
+ radio.layout.doClick();
1968
+ }
1969
+ }
1970
+ }
1971
+ });
1972
+
16861973 framePanel.setContinuousLayout(false);
16871974 framePanel.setOneTouchExpandable(false);
16881975 //.setDividerLocation(0.8);
....@@ -1692,7 +1979,7 @@
16921979
16931980 frame.getContentPane().setLayout(new BorderLayout());
16941981 /**/
1695
- JTabbedPane worldPane = new JTabbedPane();
1982
+ //JTabbedPane worldPane = new JTabbedPane();
16961983 //worldPane.add(bigPanel);
16971984 //worldPane.add(worldPanel);
16981985 /**/
....@@ -1706,7 +1993,7 @@
17061993
17071994 cameraView.requestFocusInWindow();
17081995
1709
- gridPanel.setDividerLocation(1.0);
1996
+// gridPanel.setDividerLocation(1.0);
17101997
17111998 frame.validate();
17121999
....@@ -1741,7 +2028,7 @@
17412028 {
17422029 cGridBag presetpanel = new cGridBag().setVertical(true);
17432030
1744
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
2031
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
17452032 skin.setToolTipText("Skin");
17462033 skin.addMouseListener(new MouseAdapter()
17472034 {
....@@ -1752,7 +2039,15 @@
17522039
17532040 // Skin
17542041 colorField.setFloat(material.color);
1755
- saturationField.setFloat(material.modulation);
2042
+ float saturation = material.modulation;
2043
+
2044
+ if (!cameraView.Skinshader)
2045
+ {
2046
+ saturation /= 1.5;
2047
+ }
2048
+
2049
+ saturationField.setFloat(saturation);
2050
+
17562051 subsurfaceField.setFloat(material.subsurface);
17572052 selfshadowField.setFloat(material.diffuseness);
17582053 diffusenessField.setFloat(material.factor);
....@@ -1771,7 +2066,7 @@
17712066 });
17722067 presetpanel.add(skin);
17732068
1774
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2069
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
17752070 lambert.setToolTipText("Diffuse");
17762071 lambert.addMouseListener(new MouseAdapter()
17772072 {
....@@ -1789,7 +2084,7 @@
17892084 });
17902085 presetpanel.add(lambert);
17912086
1792
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2087
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
17932088 diffuse2.setToolTipText("Diffuse2");
17942089 diffuse2.addMouseListener(new MouseAdapter()
17952090 {
....@@ -1807,7 +2102,7 @@
18072102 });
18082103 presetpanel.add(diffuse2);
18092104
1810
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2105
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
18112106 diffusemoon.setToolTipText("Moon");
18122107 diffusemoon.addMouseListener(new MouseAdapter()
18132108 {
....@@ -1825,7 +2120,7 @@
18252120 });
18262121 presetpanel.add(diffusemoon);
18272122
1828
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2123
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
18292124 diffusemoon2.setToolTipText("Moon2");
18302125 diffusemoon2.addMouseListener(new MouseAdapter()
18312126 {
....@@ -1843,7 +2138,7 @@
18432138 });
18442139 presetpanel.add(diffusemoon2);
18452140
1846
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2141
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
18472142 diffusemoon3.setToolTipText("Moon3");
18482143 diffusemoon3.addMouseListener(new MouseAdapter()
18492144 {
....@@ -1861,7 +2156,7 @@
18612156 });
18622157 presetpanel.add(diffusemoon3);
18632158
1864
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2159
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
18652160 diffusesheen.setToolTipText("Sheen");
18662161 diffusesheen.addMouseListener(new MouseAdapter()
18672162 {
....@@ -1878,7 +2173,7 @@
18782173 });
18792174 presetpanel.add(diffusesheen);
18802175
1881
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2176
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
18822177 rough.setToolTipText("Rough metal");
18832178 rough.addMouseListener(new MouseAdapter()
18842179 {
....@@ -1896,7 +2191,7 @@
18962191 });
18972192 presetpanel.add(rough);
18982193
1899
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2194
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
19002195 rough2.setToolTipText("Medium metal");
19012196 rough2.addMouseListener(new MouseAdapter()
19022197 {
....@@ -1914,7 +2209,7 @@
19142209 });
19152210 presetpanel.add(rough2);
19162211
1917
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2212
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
19182213 shini0.setToolTipText("Shiny");
19192214 shini0.addMouseListener(new MouseAdapter()
19202215 {
....@@ -1932,7 +2227,7 @@
19322227 });
19332228 presetpanel.add(shini0);
19342229
1935
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2230
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
19362231 shini1.setToolTipText("Shiny2");
19372232 shini1.addMouseListener(new MouseAdapter()
19382233 {
....@@ -1950,7 +2245,7 @@
19502245 });
19512246 presetpanel.add(shini1);
19522247
1953
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2248
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
19542249 shini2.setToolTipText("Shiny3");
19552250 shini2.addMouseListener(new MouseAdapter()
19562251 {
....@@ -1968,7 +2263,7 @@
19682263 });
19692264 presetpanel.add(shini2);
19702265
1971
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2266
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
19722267 aniso.setToolTipText("AnisoU");
19732268 aniso.addMouseListener(new MouseAdapter()
19742269 {
....@@ -1986,7 +2281,7 @@
19862281 });
19872282 presetpanel.add(aniso);
19882283
1989
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2284
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
19902285 aniso2.setToolTipText("AnisoV");
19912286 aniso2.addMouseListener(new MouseAdapter()
19922287 {
....@@ -2004,7 +2299,7 @@
20042299 });
20052300 presetpanel.add(aniso2);
20062301
2007
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2302
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
20082303 aniso3.setToolTipText("AnisoUV");
20092304 aniso3.addMouseListener(new MouseAdapter()
20102305 {
....@@ -2022,7 +2317,7 @@
20222317 });
20232318 presetpanel.add(aniso3);
20242319
2025
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2320
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
20262321 velvet0.setToolTipText("Velvet");
20272322 velvet0.addMouseListener(new MouseAdapter()
20282323 {
....@@ -2044,7 +2339,7 @@
20442339 });
20452340 presetpanel.add(velvet0);
20462341
2047
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2342
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
20482343 bump0.setToolTipText("Bump texture");
20492344 bump0.addMouseListener(new MouseAdapter()
20502345 {
....@@ -2063,7 +2358,22 @@
20632358 });
20642359 presetpanel.add(bump0);
20652360
2066
- cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2361
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2362
+ borderShader.setToolTipText("Border fade");
2363
+ borderShader.addMouseListener(new MouseAdapter()
2364
+ {
2365
+ public void mouseClicked(MouseEvent e)
2366
+ {
2367
+ borderfadeField.setFloat(0.5);
2368
+ opacityField.setFloat(0.75);
2369
+
2370
+ materialtouched = true;
2371
+ applySelf();
2372
+ }
2373
+ });
2374
+ presetpanel.add(borderShader);
2375
+
2376
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
20672377 halo.setToolTipText("Halo");
20682378 halo.addMouseListener(new MouseAdapter()
20692379 {
....@@ -2080,7 +2390,7 @@
20802390 });
20812391 presetpanel.add(halo);
20822392
2083
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2393
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
20842394 candle.setToolTipText("Candle");
20852395 candle.addMouseListener(new MouseAdapter()
20862396 {
....@@ -2102,6 +2412,25 @@
21022412 });
21032413 presetpanel.add(candle);
21042414
2415
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2416
+ shadowShader.setToolTipText("Shadow");
2417
+ shadowShader.addMouseListener(new MouseAdapter()
2418
+ {
2419
+ public void mouseClicked(MouseEvent e)
2420
+ {
2421
+ diffuseField.setFloat(0.001);
2422
+ ambientField.setFloat(0.001);
2423
+ cameraField.setFloat(0.001);
2424
+ specularField.setFloat(0.001);
2425
+ fakedepthField.setFloat(0.001);
2426
+ opacityField.setFloat(0.6);
2427
+
2428
+ materialtouched = true;
2429
+ applySelf();
2430
+ }
2431
+ });
2432
+ presetpanel.add(shadowShader);
2433
+
21052434 cGridBag panel = new cGridBag().setVertical(true);
21062435
21072436 presetpanel.preferredWidth = 1;
....@@ -2118,19 +2447,19 @@
21182447
21192448 cGridBag editBar = new cGridBag().setVertical(false);
21202449
2121
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2450
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
21222451 createMaterialButton.setToolTipText("Create material");
21232452
21242453 /*
21252454 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
21262455 */
21272456
2128
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2457
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
21292458 clearMaterialButton.setToolTipText("Clear material");
21302459
21312460 if (Globals.ADVANCED)
21322461 {
2133
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2462
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
21342463 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
21352464 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
21362465 }
....@@ -2151,9 +2480,20 @@
21512480
21522481 cGridBag huepanel = new cGridBag();
21532482 cGridBag huelabel = new cGridBag();
2154
- skin = GetLabel("icons/hue.png", false);
2155
- skin.fit = true;
2156
- huelabel.add(skin);
2483
+ cLabel hue = GetLabel("icons/hue.png", false);
2484
+ hue.fit = true;
2485
+
2486
+ hue.addMouseListener(new MouseAdapter()
2487
+ {
2488
+ public void mousePressed(MouseEvent e)
2489
+ {
2490
+ int x = e.getX();
2491
+
2492
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2493
+ }
2494
+ });
2495
+
2496
+ huelabel.add(hue);
21572497 huelabel.preferredWidth = 20;
21582498 huepanel.add(new cGridBag()); // Label
21592499 huepanel.add(huelabel); // Field/slider
....@@ -3429,32 +3769,8 @@
34293769
34303770 if (multiplyToggle != null)
34313771 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
- }
3772
+
3773
+ AllocProjectedVertices(object);
34583774
34593775 SetMaterial(mat, object.projectedVertices);
34603776 }
....@@ -3574,6 +3890,17 @@
35743890 public void itemStateChanged(ItemEvent event)
35753891 {
35763892 // System.out.println("Propagate = " + propagate);
3893
+ if (event.getSource() == pinButton)
3894
+ {
3895
+ copy.pinned ^= true;
3896
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3897
+ {
3898
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3899
+ copy.CloseUI();
3900
+ //copy.editWindow.refreshContents();
3901
+ }
3902
+ }
3903
+ else
35773904 if (event.getSource() == propagateToggle)
35783905 {
35793906 propagate ^= true;
....@@ -3753,7 +4080,7 @@
37534080 //System.out.println("ObjEditor " + event);
37544081 applySelf0(true);
37554082 //parent.applySelf();
3756
- objEditor.refreshContents();
4083
+ // conflicts with requestFocus objEditor.refreshContents();
37574084 } else if (source == resetButton)
37584085 {
37594086 CameraPane.fullreset = true;
....@@ -3933,11 +4260,18 @@
39334260
39344261 void New()
39354262 {
3936
- while (copy.Size() > 1)
4263
+ while (copy.Size() > 0)
39374264 {
3938
- copy.remove(1);
4265
+ copy.remove(0);
39394266 }
39404267
4268
+ copy.selection.clear();
4269
+
4270
+ if (copy == Grafreed.grafreed.universe)
4271
+ {
4272
+ CreateCameras();
4273
+ cameraView.SetCamera(GetCamera(copy, 0));
4274
+ }
39414275 ResetModel();
39424276 objEditor.refreshContents();
39434277 }
....@@ -4046,7 +4380,7 @@
40464380 {
40474381 //Save(true);
40484382 Replace();
4049
- SetUndoStates();
4383
+ SetVersionStates();
40504384 }
40514385
40524386 private boolean Equal(byte[] compress, byte[] name)
....@@ -4065,8 +4399,6 @@
40654399 return true;
40664400 }
40674401
4068
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4069
-
40704402 void DeleteVersion()
40714403 {
40724404 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4074,19 +4406,23 @@
40744406 copy.versionlist[i] = copy.versionlist[i+1];
40754407 }
40764408
4077
- CopyChanged();
4409
+ if (copy.versionlist[copy.versionindex] == null)
4410
+ copy.versionindex -= 1;
40784411
4079
- SetUndoStates();
4412
+ if (copy.versionindex != -1)
4413
+ CopyChanged();
4414
+
4415
+ SetVersionStates();
40804416 }
40814417
40824418 public boolean Save(boolean user)
40834419 {
40844420 System.err.println("Save");
4085
- //Replace();
4421
+ Replace();
40864422
4087
- cRadio tab = GetCurrentTab();
4423
+ //cRadio tab = GetCurrentTab();
40884424
4089
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
4425
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
40904426
40914427 boolean thesame = false;
40924428
....@@ -4122,7 +4458,7 @@
41224458 // copy.versionlist[i] = null;
41234459 // }
41244460
4125
- SetUndoStates();
4461
+ SetVersionStates();
41264462
41274463 // test save
41284464 if (false)
....@@ -4180,14 +4516,14 @@
41804516
41814517 void CopyChanged()
41824518 {
4183
- Object3D obj = copy.versionlist[copy.versionindex];
4519
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
41844520
4185
- SetUndoStates();
4521
+ SetVersionStates();
41864522
41874523 boolean temp = CameraPane.SWITCH;
41884524 CameraPane.SWITCH = false;
41894525
4190
- copy.ExtractBigData(versiontable);
4526
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
41914527
41924528 copy.clear();
41934529
....@@ -4199,7 +4535,7 @@
41994535 copy.add(obj.get(i));
42004536 }
42014537
4202
- copy.RestoreBigData(versiontable);
4538
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
42034539
42044540 CameraPane.SWITCH = temp;
42054541
....@@ -4249,23 +4585,45 @@
42494585 return count;
42504586 }
42514587
4252
- void SetUndoStates()
4588
+ public cGridBag versionSliderPane;
4589
+
4590
+ void SetVersionStates()
42534591 {
4254
- cRadio tab = GetCurrentTab();
4592
+ //if (true)
4593
+ // return;
4594
+
4595
+ //cRadio tab = GetCurrentTab();
42554596
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;
4597
+ if (copy.versionlist == null)
4598
+ {
4599
+ saveVersionButton.setEnabled(false);
4600
+ restoreButton.setEnabled(false);
4601
+ replaceButton.setEnabled(false);
4602
+ previousVersionButton.setEnabled(false);
4603
+ nextVersionButton.setEnabled(false);
4604
+ deleteVersionButton.setEnabled(false);
4605
+ versionSliderPane.setVisible(false);
4606
+ }
4607
+ else
4608
+ {
4609
+ restoreButton.setEnabled(copy.versionindex != -1);
4610
+ replaceButton.setEnabled(copy.versionindex != -1);
4611
+
4612
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4613
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4614
+
4615
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4616
+ //copy.versionlist[copy.versionindex + 1] != null);
4617
+
4618
+ muteSlider = true;
4619
+ versionSlider.setMinimum(0);
4620
+ versionSlider.setMaximum(VersionCount() - 1);
4621
+ versionSlider.setInteger(copy.versionindex);
4622
+ versionSlider.setEnabled(copy.versionindex != -1);
4623
+ muteSlider = false;
4624
+
4625
+ versionSliderPane.setVisible(true);
4626
+ }
42694627 }
42704628
42714629 public boolean PreviousVersion()
....@@ -4275,7 +4633,7 @@
42754633
42764634 System.err.println("Undo");
42774635
4278
- cRadio tab = GetCurrentTab();
4636
+ //cRadio tab = GetCurrentTab();
42794637
42804638 if (copy.versionindex == 0)
42814639 {
....@@ -4307,7 +4665,7 @@
43074665 {
43084666 System.err.println("Restore");
43094667
4310
- cRadio tab = GetCurrentTab();
4668
+ //cRadio tab = GetCurrentTab();
43114669
43124670 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43134671 {
....@@ -4323,9 +4681,9 @@
43234681
43244682 public boolean Replace()
43254683 {
4326
- System.err.println("Replace");
4684
+ //System.err.println("Replace");
43274685
4328
- cRadio tab = GetCurrentTab();
4686
+ //cRadio tab = GetCurrentTab();
43294687
43304688 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43314689 {
....@@ -4333,7 +4691,7 @@
43334691 return false;
43344692 }
43354693
4336
- copy.versionlist[copy.versionindex] = CompressCopy();
4694
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
43374695
43384696 return true;
43394697 }
....@@ -4343,7 +4701,7 @@
43434701 // Option?
43444702 Replace();
43454703
4346
- cRadio tab = GetCurrentTab();
4704
+ //cRadio tab = GetCurrentTab();
43474705
43484706 if (copy.versionlist[copy.versionindex + 1] == null)
43494707 {
....@@ -4550,6 +4908,12 @@
45504908 // else
45514909 // applySelf(true);
45524910 // }
4911
+
4912
+ boolean Equal(double a, double b)
4913
+ {
4914
+ return Math.abs(a - b) < 0.001;
4915
+ }
4916
+
45534917 void applySelf0(boolean name)
45544918 {
45554919 if (name)
....@@ -4599,29 +4963,52 @@
45994963 {
46004964 cMaterial mat = copy.material;
46014965
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));
4966
+ if (!Equal(colorField.getFloat(), mat.color))
4967
+ colorField.SetToolTipValue((mat.color));
4968
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4969
+ saturationField.SetToolTipValue((mat.modulation));
4970
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4971
+ metalnessField.SetToolTipValue((mat.metalness));
4972
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4973
+ diffuseField.SetToolTipValue((mat.diffuse));
4974
+ if (!Equal(specularField.getFloat(), mat.specular))
4975
+ specularField.SetToolTipValue((mat.specular));
4976
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4977
+ shininessField.SetToolTipValue((mat.shininess));
4978
+ if (!Equal(shiftField.getFloat(), mat.shift))
4979
+ shiftField.SetToolTipValue((mat.shift));
4980
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4981
+ ambientField.SetToolTipValue((mat.ambient));
4982
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4983
+ lightareaField.SetToolTipValue((mat.lightarea));
4984
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4985
+ diffusenessField.SetToolTipValue((mat.factor));
4986
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4987
+ velvetField.SetToolTipValue((mat.velvet));
4988
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4989
+ sheenField.SetToolTipValue((mat.sheen));
4990
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4991
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4992
+ if (!Equal(backlitField.getFloat(), mat.bump))
4993
+ backlitField.SetToolTipValue((mat.bump));
4994
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4995
+ anisoField.SetToolTipValue((mat.aniso));
4996
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4997
+ anisoVField.SetToolTipValue((mat.anisoV));
4998
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4999
+ cameraField.SetToolTipValue((mat.cameralight));
5000
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
5001
+ selfshadowField.SetToolTipValue((mat.diffuseness));
5002
+ if (!Equal(shadowField.getFloat(), mat.shadow))
5003
+ shadowField.SetToolTipValue((mat.shadow));
5004
+ if (!Equal(textureField.getFloat(), mat.texture))
5005
+ textureField.SetToolTipValue((mat.texture));
5006
+ if (!Equal(opacityField.getFloat(), mat.opacity))
5007
+ opacityField.SetToolTipValue((mat.opacity));
5008
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
5009
+ fakedepthField.SetToolTipValue((mat.fakedepth));
5010
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
5011
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
46255012 }
46265013
46275014 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4656,15 +5043,17 @@
46565043
46575044 public void stateChanged(ChangeEvent e)
46585045 {
4659
- // assert(false);
5046
+ // assert(false);
46605047 if (e.getSource() == versionSlider)
46615048 {
46625049 if (muteSlider)
46635050 return;
46645051
5052
+ Replace();
5053
+
46655054 int version = versionSlider.getInteger();
46665055
4667
- if (copy.versionlist[version] != null)
5056
+ if (version != -1 && copy.versionlist[version] != null)
46685057 {
46695058 copy.versionindex = version;
46705059 CopyChanged();
....@@ -4708,7 +5097,7 @@
47085097 //System.out.println("stateChanged = " + this);
47095098 materialtouched = true;
47105099
4711
- if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
5100
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
47125101 {
47135102 saturationField.setFloat(1);
47145103 }
....@@ -5023,7 +5412,9 @@
50235412 }
50245413
50255414 if (previousVersionButton != null && copy.versionlist != null)
5026
- SetUndoStates();
5415
+ SetVersionStates();
5416
+
5417
+ cameraView.requestFocusInWindow();
50275418 }
50285419
50295420 static TweenManager tweenManager = new TweenManager();
....@@ -5055,7 +5446,7 @@
50555446 // group = (Composite) group.get(0);
50565447 // }
50575448
5058
- System.out.println("makeSomething of " + thing);
5449
+ //System.out.println("makeSomething of " + thing);
50595450
50605451 /*
50615452 if (deselect && jList != null)
....@@ -5409,11 +5800,15 @@
54095800
54105801 copy.versionlist = readobj.versionlist;
54115802 copy.versionindex = readobj.versionindex;
5803
+ copy.versiontable = readobj.versiontable;
54125804
54135805 if (copy.versionlist == null)
54145806 {
5807
+ // Backward compatibility
54155808 copy.versionlist = new Object3D[100];
54165809 copy.versionindex = -1;
5810
+
5811
+ //Save(true);
54175812 }
54185813
54195814 //? SetUndoStates();
....@@ -5505,6 +5900,8 @@
55055900
55065901 void save()
55075902 {
5903
+ Replace();
5904
+
55085905 if (lastname == null)
55095906 {
55105907 return;
....@@ -5747,6 +6144,7 @@
57476144 ButtonGroup buttonGroup;
57486145
57496146 cGridBag toolboxPanel;
6147
+ cGridBag skyboxPanel;
57506148 cGridBag materialPanel;
57516149 cGridBag ctrlPanel;
57526150
....@@ -5758,6 +6156,7 @@
57586156 boolean materialFlushed;
57596157 Object3D latestObject;
57606158
6159
+ cGridBag transformPanel;
57616160 cGridBag XYZPanel;
57626161
57636162 JSplitPane gridPanel;
....@@ -5851,6 +6250,7 @@
58516250 cNumberSlider anisoField;
58526251 JLabel anisoVLabel;
58536252 cNumberSlider anisoVField;
6253
+
58546254 JLabel cameraLabel;
58556255 cNumberSlider cameraField;
58566256 JLabel selfshadowLabel;
....@@ -5865,6 +6265,7 @@
58656265 cNumberSlider fakedepthField;
58666266 JLabel shadowbiasLabel;
58676267 cNumberSlider shadowbiasField;
6268
+
58686269 JLabel bumpLabel;
58696270 cNumberSlider bumpField;
58706271 JLabel noiseLabel;