Normand Briere
2019-08-19 22e8ab6479334206f97b0093f6c5ffd14610cce3
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,32 +951,53 @@
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();
961
+
962
+ cameraView.requestFocusInWindow();
851963 }
852964
853
- 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)
854974 {
855975 boolean temp = CameraPane.SWITCH;
856976 CameraPane.SWITCH = false;
857977
858
- 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);
859982 // if (copy == client)
860983
861
- Object3D versions[] = copy.versionlist;
862
- 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;
863991
864992 //byte[] compress = Compress(copy);
865
- Object3D compress = (Object3D)Grafreed.clone(copy);
993
+ Object3D compress = (Object3D)Grafreed.clone(object);
866994
867
- copy.versionlist = versions;
995
+ object.parent = parent;
868996
869
- copy.RestoreBigData(versiontable);
997
+ object.versionlist = versions;
998
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
999
+
1000
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
8701001
8711002 CameraPane.SWITCH = temp;
8721003
....@@ -1203,6 +1334,18 @@
12031334
12041335 namePanel = new cGridBag();
12051336
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
+
12061349 nameField = AddText(namePanel, copy.GetName());
12071350 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
12081351 oe.ctrlPanel.add(namePanel);
....@@ -1216,14 +1359,14 @@
12161359
12171360 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12181361 liveCB.setToolTipText("Animate object");
1362
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1363
+ markCB.setToolTipText("Set target transform");
12191364 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12201365 selectableCB.setToolTipText("Make object selectable");
12211366 // Return();
12221367
12231368 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12241369 hideCB.setToolTipText("Hide object");
1225
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1226
- markCB.setToolTipText("As animation target transform");
12271370
12281371 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12291372
....@@ -1425,22 +1568,9 @@
14251568
14261569 if (cam == null || !(copy.get(0) instanceof cGroup))
14271570 {
1428
- System.out.println("CREATE CAMERAS");
1429
- cams = new cTemplate();
1430
- cams.name = "Cameras";
1431
- copy.insertElementAt(cams, 0);
1432
- //cams.parent = copy;
1433
-
1434
- cam = new Camera(); // LA.newVector(3, 2, 1));
1435
- cams.addChild(cam);
1436
- cam = new Camera(1);
1437
- cams.addChild(cam);
1438
- cam = new Camera(2);
1439
- cams.addChild(cam);
1440
- cam = new Camera(3);
1441
- cams.addChild(cam);
1442
- cam = new Camera(4); // Light
1443
- cams.addChild(cam);
1571
+ if (Globals.DEBUG)
1572
+ System.out.println("CREATE CAMERAS");
1573
+ cams = CreateCameras();
14441574 } else
14451575 {
14461576 cams = (cGroup) copy.get(0);
....@@ -1506,6 +1636,45 @@
15061636 //frontView.object = copy;
15071637 //sideView.object = copy;
15081638
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
+
15091678 XYZPanel = new cGridBag().setVertical(true);
15101679 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15111680
....@@ -1515,6 +1684,9 @@
15151684 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15161685 //XYZPanel.setName("XYZ");
15171686
1687
+ transformPanel.add(resetTransformPanel);
1688
+ transformPanel.add(XYZPanel);
1689
+
15181690 /*
15191691 gridPanel = new JPanel(); //new BorderLayout());
15201692 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1522,12 +1694,12 @@
15221694 gridPanel.add(cameraView);
15231695 gridPanel.add(XYZPanel);
15241696 */
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);
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);
15311703
15321704 // aConstraints.weighty = 0;
15331705 //System.out.println("THIS = " + this);
....@@ -1550,31 +1722,34 @@
15501722
15511723 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15521724 //tmp.setName("Edit");
1725
+ objectPanel.add(skyboxPanel);
1726
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1727
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1728
+
1729
+ objectPanel.add(toolboxPanel);
1730
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1731
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1732
+
15531733 objectPanel.add(materialPanel);
1554
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
- objectPanel.setToolTipTextAt(0, "Material");
1734
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1735
+ objectPanel.setToolTipTextAt(2, "Material");
15561736
15571737 // JPanel north = new JPanel(new BorderLayout());
15581738 // north.setName("Edit");
15591739 // north.add(ctrlPanel, BorderLayout.NORTH);
15601740 // objectPanel.add(north);
15611741 objectPanel.add(editPanel);
1562
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
- objectPanel.setToolTipTextAt(1, "Edit controls");
1742
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1743
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15641744
1565
- //if (Globals.ADVANCED)
1566
- objectPanel.add(infoPanel);
1567
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
- objectPanel.setToolTipTextAt(2, "Information");
1745
+ objectPanel.add(transformPanel);
1746
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1747
+ objectPanel.setToolTipTextAt(4, "TRS transform");
15691748
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
-
1749
+ patchMaterial = true;
1750
+ cameraView.patchMaterial = this;
1751
+ objectPanel.setSelectedIndex(2);
1752
+
15781753 /*
15791754 aConstraints.gridx = 0;
15801755 aConstraints.gridwidth = 1;
....@@ -1594,7 +1769,7 @@
15941769 scrollpane.addMouseWheelListener(this); // Default not fast enough
15951770
15961771 /*JTabbedPane*/ scenePanel = new cGridBag();
1597
- scenePanel.preferredWidth = 5;
1772
+ scenePanel.preferredWidth = 6;
15981773
15991774 JTabbedPane tabbedPane = new JTabbedPane();
16001775 tabbedPane.add(scrollpane);
....@@ -1605,11 +1780,108 @@
16051780
16061781 AddOptions(optionsPanel); //, aConstraints);
16071782
1608
- tabbedPane.add(optionsPanel);
1609
-
16101783 tabbedPane.add(FSPane = new cFileSystemPane(this));
16111784
1785
+ tabbedPane.add(optionsPanel);
1786
+
16121787 scenePanel.add(tabbedPane);
1788
+
1789
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1790
+ creditsPanel.setName("Credits");
1791
+
1792
+ cLabel ogaLabel = new cLabel(" Most 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
+ }
16131885
16141886 /*
16151887 cTree jTree = new cTree(null);
....@@ -1631,13 +1903,13 @@
16311903 jtp.add(tree);
16321904 */
16331905
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");
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");
16411913
16421914 //bigPanel.setLayout(new BorderLayout());
16431915 //bigPanel.setSize(new Dimension(10,10));
....@@ -1681,6 +1953,23 @@
16811953 // aConstraints.gridheight = 1;
16821954
16831955 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
+
16841973 framePanel.setContinuousLayout(false);
16851974 framePanel.setOneTouchExpandable(false);
16861975 //.setDividerLocation(0.8);
....@@ -1690,7 +1979,7 @@
16901979
16911980 frame.getContentPane().setLayout(new BorderLayout());
16921981 /**/
1693
- JTabbedPane worldPane = new JTabbedPane();
1982
+ //JTabbedPane worldPane = new JTabbedPane();
16941983 //worldPane.add(bigPanel);
16951984 //worldPane.add(worldPanel);
16961985 /**/
....@@ -1704,7 +1993,7 @@
17041993
17051994 cameraView.requestFocusInWindow();
17061995
1707
- gridPanel.setDividerLocation(1.0);
1996
+// gridPanel.setDividerLocation(1.0);
17081997
17091998 frame.validate();
17101999
....@@ -1738,46 +2027,416 @@
17382027 void SetupMaterial(cGridBag materialpanel)
17392028 {
17402029 cGridBag presetpanel = new cGridBag().setVertical(true);
1741
- cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
- label.addMouseListener(new MouseAdapter()
2030
+
2031
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
2032
+ skin.setToolTipText("Skin");
2033
+ skin.addMouseListener(new MouseAdapter()
17432034 {
17442035 public void mouseClicked(MouseEvent e)
17452036 {
1746
- colorField.setFloat(0);
1747
- saturationField.setFloat(1);
2037
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
2038
+ cMaterial material = object.material;
2039
+
2040
+ // Skin
2041
+ colorField.setFloat(material.color);
2042
+ float saturation = material.modulation;
2043
+
2044
+ if (!cameraView.Skinshader)
2045
+ {
2046
+ saturation /= 1.5;
2047
+ }
2048
+
2049
+ saturationField.setFloat(saturation);
2050
+
2051
+ subsurfaceField.setFloat(material.subsurface);
2052
+ selfshadowField.setFloat(material.diffuseness);
2053
+ diffusenessField.setFloat(material.factor);
2054
+ shininessField.setFloat(material.shininess);
2055
+ shadowbiasField.setFloat(material.shadowbias);
2056
+ diffuseField.setFloat(material.diffuse);
2057
+ specularField.setFloat(material.specular);
2058
+
2059
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2060
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2061
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2062
+
17482063 materialtouched = true;
17492064 applySelf();
17502065 }
17512066 });
1752
- presetpanel.add(label);
2067
+ presetpanel.add(skin);
17532068
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));
2069
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2070
+ lambert.setToolTipText("Diffuse");
2071
+ lambert.addMouseListener(new MouseAdapter()
2072
+ {
2073
+ public void mouseClicked(MouseEvent e)
2074
+ {
2075
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2076
+ cMaterial material = object.material;
2077
+
2078
+ diffusenessField.setFloat(material.factor);
2079
+ selfshadowField.setFloat(material.diffuseness);
2080
+
2081
+ materialtouched = true;
2082
+ applySelf();
2083
+ }
2084
+ });
2085
+ presetpanel.add(lambert);
2086
+
2087
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2088
+ diffuse2.setToolTipText("Diffuse2");
2089
+ diffuse2.addMouseListener(new MouseAdapter()
2090
+ {
2091
+ public void mouseClicked(MouseEvent e)
2092
+ {
2093
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2094
+ cMaterial material = object.material;
2095
+
2096
+ diffusenessField.setFloat(material.factor);
2097
+ selfshadowField.setFloat(material.diffuseness);
2098
+
2099
+ materialtouched = true;
2100
+ applySelf();
2101
+ }
2102
+ });
2103
+ presetpanel.add(diffuse2);
2104
+
2105
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2106
+ diffusemoon.setToolTipText("Moon");
2107
+ diffusemoon.addMouseListener(new MouseAdapter()
2108
+ {
2109
+ public void mouseClicked(MouseEvent e)
2110
+ {
2111
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2112
+ cMaterial material = object.material;
2113
+
2114
+ diffusenessField.setFloat(material.factor);
2115
+ selfshadowField.setFloat(material.diffuseness);
2116
+
2117
+ materialtouched = true;
2118
+ applySelf();
2119
+ }
2120
+ });
2121
+ presetpanel.add(diffusemoon);
2122
+
2123
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2124
+ diffusemoon2.setToolTipText("Moon2");
2125
+ diffusemoon2.addMouseListener(new MouseAdapter()
2126
+ {
2127
+ public void mouseClicked(MouseEvent e)
2128
+ {
2129
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2130
+ cMaterial material = object.material;
2131
+
2132
+ diffusenessField.setFloat(material.factor);
2133
+ selfshadowField.setFloat(material.diffuseness);
2134
+
2135
+ materialtouched = true;
2136
+ applySelf();
2137
+ }
2138
+ });
2139
+ presetpanel.add(diffusemoon2);
2140
+
2141
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2142
+ diffusemoon3.setToolTipText("Moon3");
2143
+ diffusemoon3.addMouseListener(new MouseAdapter()
2144
+ {
2145
+ public void mouseClicked(MouseEvent e)
2146
+ {
2147
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2148
+ cMaterial material = object.material;
2149
+
2150
+ diffusenessField.setFloat(material.factor);
2151
+ selfshadowField.setFloat(material.diffuseness);
2152
+
2153
+ materialtouched = true;
2154
+ applySelf();
2155
+ }
2156
+ });
2157
+ presetpanel.add(diffusemoon3);
2158
+
2159
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2160
+ diffusesheen.setToolTipText("Sheen");
2161
+ diffusesheen.addMouseListener(new MouseAdapter()
2162
+ {
2163
+ public void mouseClicked(MouseEvent e)
2164
+ {
2165
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2166
+ cMaterial material = object.material;
2167
+
2168
+ sheenField.setFloat(material.sheen);
2169
+
2170
+ materialtouched = true;
2171
+ applySelf();
2172
+ }
2173
+ });
2174
+ presetpanel.add(diffusesheen);
2175
+
2176
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2177
+ rough.setToolTipText("Rough metal");
2178
+ rough.addMouseListener(new MouseAdapter()
2179
+ {
2180
+ public void mouseClicked(MouseEvent e)
2181
+ {
2182
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2183
+ cMaterial material = object.material;
2184
+
2185
+ shininessField.setFloat(material.shininess);
2186
+ velvetField.setFloat(material.velvet);
2187
+
2188
+ materialtouched = true;
2189
+ applySelf();
2190
+ }
2191
+ });
2192
+ presetpanel.add(rough);
2193
+
2194
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2195
+ rough2.setToolTipText("Medium metal");
2196
+ rough2.addMouseListener(new MouseAdapter()
2197
+ {
2198
+ public void mouseClicked(MouseEvent e)
2199
+ {
2200
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2201
+ cMaterial material = object.material;
2202
+
2203
+ shininessField.setFloat(material.shininess);
2204
+ lightareaField.setFloat(material.lightarea);
2205
+
2206
+ materialtouched = true;
2207
+ applySelf();
2208
+ }
2209
+ });
2210
+ presetpanel.add(rough2);
2211
+
2212
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2213
+ shini0.setToolTipText("Shiny");
2214
+ shini0.addMouseListener(new MouseAdapter()
2215
+ {
2216
+ public void mouseClicked(MouseEvent e)
2217
+ {
2218
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2219
+ cMaterial material = object.material;
2220
+
2221
+ shininessField.setFloat(material.shininess);
2222
+ lightareaField.setFloat(material.lightarea);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(shini0);
2229
+
2230
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2231
+ shini1.setToolTipText("Shiny2");
2232
+ shini1.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ shininessField.setFloat(material.shininess);
2240
+ lightareaField.setFloat(material.lightarea);
2241
+
2242
+ materialtouched = true;
2243
+ applySelf();
2244
+ }
2245
+ });
2246
+ presetpanel.add(shini1);
2247
+
2248
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2249
+ shini2.setToolTipText("Shiny3");
2250
+ shini2.addMouseListener(new MouseAdapter()
2251
+ {
2252
+ public void mouseClicked(MouseEvent e)
2253
+ {
2254
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2255
+ cMaterial material = object.material;
2256
+
2257
+ shininessField.setFloat(material.shininess);
2258
+ lightareaField.setFloat(material.lightarea);
2259
+
2260
+ materialtouched = true;
2261
+ applySelf();
2262
+ }
2263
+ });
2264
+ presetpanel.add(shini2);
2265
+
2266
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2267
+ aniso.setToolTipText("AnisoU");
2268
+ aniso.addMouseListener(new MouseAdapter()
2269
+ {
2270
+ public void mouseClicked(MouseEvent e)
2271
+ {
2272
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2273
+ cMaterial material = object.material;
2274
+
2275
+ anisoField.setFloat(material.aniso);
2276
+ anisoVField.setFloat(material.anisoV);
2277
+
2278
+ materialtouched = true;
2279
+ applySelf();
2280
+ }
2281
+ });
2282
+ presetpanel.add(aniso);
2283
+
2284
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2285
+ aniso2.setToolTipText("AnisoV");
2286
+ aniso2.addMouseListener(new MouseAdapter()
2287
+ {
2288
+ public void mouseClicked(MouseEvent e)
2289
+ {
2290
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2291
+ cMaterial material = object.material;
2292
+
2293
+ anisoField.setFloat(material.aniso);
2294
+ anisoVField.setFloat(material.anisoV);
2295
+
2296
+ materialtouched = true;
2297
+ applySelf();
2298
+ }
2299
+ });
2300
+ presetpanel.add(aniso2);
2301
+
2302
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2303
+ aniso3.setToolTipText("AnisoUV");
2304
+ aniso3.addMouseListener(new MouseAdapter()
2305
+ {
2306
+ public void mouseClicked(MouseEvent e)
2307
+ {
2308
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2309
+ cMaterial material = object.material;
2310
+
2311
+ anisoField.setFloat(material.aniso);
2312
+ anisoVField.setFloat(material.anisoV);
2313
+
2314
+ materialtouched = true;
2315
+ applySelf();
2316
+ }
2317
+ });
2318
+ presetpanel.add(aniso3);
2319
+
2320
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2321
+ velvet0.setToolTipText("Velvet");
2322
+ velvet0.addMouseListener(new MouseAdapter()
2323
+ {
2324
+ public void mouseClicked(MouseEvent e)
2325
+ {
2326
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2327
+ cMaterial material = object.material;
2328
+
2329
+ diffusenessField.setFloat(material.factor);
2330
+ selfshadowField.setFloat(material.diffuseness);
2331
+ sheenField.setFloat(material.sheen);
2332
+ shininessField.setFloat(material.shininess);
2333
+ velvetField.setFloat(material.velvet);
2334
+ shiftField.setFloat(material.shift);
2335
+
2336
+ materialtouched = true;
2337
+ applySelf();
2338
+ }
2339
+ });
2340
+ presetpanel.add(velvet0);
2341
+
2342
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2343
+ bump0.setToolTipText("Bump texture");
2344
+ bump0.addMouseListener(new MouseAdapter()
2345
+ {
2346
+ public void mouseClicked(MouseEvent e)
2347
+ {
2348
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2349
+ cMaterial material = object.material;
2350
+
2351
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2352
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2353
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2354
+
2355
+ materialtouched = true;
2356
+ applySelf();
2357
+ }
2358
+ });
2359
+ presetpanel.add(bump0);
2360
+
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);
2377
+ halo.setToolTipText("Halo");
2378
+ halo.addMouseListener(new MouseAdapter()
2379
+ {
2380
+ public void mouseClicked(MouseEvent e)
2381
+ {
2382
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2383
+ cMaterial material = object.material;
2384
+
2385
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2386
+
2387
+ materialtouched = true;
2388
+ applySelf();
2389
+ }
2390
+ });
2391
+ presetpanel.add(halo);
2392
+
2393
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2394
+ candle.setToolTipText("Candle");
2395
+ candle.addMouseListener(new MouseAdapter()
2396
+ {
2397
+ public void mouseClicked(MouseEvent e)
2398
+ {
2399
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2400
+ cMaterial material = object.material;
2401
+
2402
+ subsurfaceField.setFloat(material.subsurface);
2403
+ shadowbiasField.setFloat(material.shadowbias);
2404
+ ambientField.setFloat(material.ambient);
2405
+ specularField.setFloat(material.specular);
2406
+ lightareaField.setFloat(material.lightarea);
2407
+ shininessField.setFloat(material.shininess);
2408
+
2409
+ materialtouched = true;
2410
+ applySelf();
2411
+ }
2412
+ });
2413
+ presetpanel.add(candle);
2414
+
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);
17742433
17752434 cGridBag panel = new cGridBag().setVertical(true);
17762435
17772436 presetpanel.preferredWidth = 1;
17782437
1779
- materialpanel.add(panel);
17802438 materialpanel.add(presetpanel);
2439
+ materialpanel.add(panel);
17812440
17822441 panel.preferredWidth = 8;
17832442
....@@ -1788,19 +2447,19 @@
17882447
17892448 cGridBag editBar = new cGridBag().setVertical(false);
17902449
1791
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2450
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
17922451 createMaterialButton.setToolTipText("Create material");
17932452
17942453 /*
17952454 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
17962455 */
17972456
1798
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2457
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
17992458 clearMaterialButton.setToolTipText("Clear material");
18002459
18012460 if (Globals.ADVANCED)
18022461 {
1803
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2462
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
18042463 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
18052464 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
18062465 }
....@@ -1821,9 +2480,20 @@
18212480
18222481 cGridBag huepanel = new cGridBag();
18232482 cGridBag huelabel = new cGridBag();
1824
- label = GetLabel("icons/hue.png", false);
1825
- label.fit = true;
1826
- huelabel.add(label);
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);
18272497 huelabel.preferredWidth = 20;
18282498 huepanel.add(new cGridBag()); // Label
18292499 huepanel.add(huelabel); // Field/slider
....@@ -3099,32 +3769,8 @@
30993769
31003770 if (multiplyToggle != null)
31013771 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
- }
3772
+
3773
+ AllocProjectedVertices(object);
31283774
31293775 SetMaterial(mat, object.projectedVertices);
31303776 }
....@@ -3244,6 +3890,17 @@
32443890 public void itemStateChanged(ItemEvent event)
32453891 {
32463892 // 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
32473904 if (event.getSource() == propagateToggle)
32483905 {
32493906 propagate ^= true;
....@@ -3423,7 +4080,7 @@
34234080 //System.out.println("ObjEditor " + event);
34244081 applySelf0(true);
34254082 //parent.applySelf();
3426
- objEditor.refreshContents();
4083
+ // conflicts with requestFocus objEditor.refreshContents();
34274084 } else if (source == resetButton)
34284085 {
34294086 CameraPane.fullreset = true;
....@@ -3603,11 +4260,18 @@
36034260
36044261 void New()
36054262 {
3606
- while (copy.Size() > 1)
4263
+ while (copy.Size() > 0)
36074264 {
3608
- copy.remove(1);
4265
+ copy.remove(0);
36094266 }
36104267
4268
+ copy.selection.clear();
4269
+
4270
+ if (copy == Grafreed.grafreed.universe)
4271
+ {
4272
+ CreateCameras();
4273
+ cameraView.SetCamera(GetCamera(copy, 0));
4274
+ }
36114275 ResetModel();
36124276 objEditor.refreshContents();
36134277 }
....@@ -3716,7 +4380,7 @@
37164380 {
37174381 //Save(true);
37184382 Replace();
3719
- SetUndoStates();
4383
+ SetVersionStates();
37204384 }
37214385
37224386 private boolean Equal(byte[] compress, byte[] name)
....@@ -3735,16 +4399,30 @@
37354399 return true;
37364400 }
37374401
3738
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4402
+ void DeleteVersion()
4403
+ {
4404
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4405
+ {
4406
+ copy.versionlist[i] = copy.versionlist[i+1];
4407
+ }
4408
+
4409
+ if (copy.versionlist[copy.versionindex] == null)
4410
+ copy.versionindex -= 1;
4411
+
4412
+ if (copy.versionindex != -1)
4413
+ CopyChanged();
4414
+
4415
+ SetVersionStates();
4416
+ }
37394417
37404418 public boolean Save(boolean user)
37414419 {
37424420 System.err.println("Save");
37434421 Replace();
37444422
3745
- cRadio tab = GetCurrentTab();
4423
+ //cRadio tab = GetCurrentTab();
37464424
3747
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
4425
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
37484426
37494427 boolean thesame = false;
37504428
....@@ -3756,6 +4434,11 @@
37564434 //EditorFrame.m_MainFrame.requestFocusInWindow();
37574435 if (!thesame)
37584436 {
4437
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4438
+ {
4439
+ copy.versionlist[i] = copy.versionlist[i-1];
4440
+ }
4441
+
37594442 //tab.user[tab.versionindex] = user;
37604443 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37614444
....@@ -3769,13 +4452,13 @@
37694452
37704453 //assert(hashtable.isEmpty());
37714454
3772
- for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3773
- {
3774
- //tab.user[i] = false;
3775
- copy.versionlist[i] = null;
3776
- }
4455
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4456
+// {
4457
+// //tab.user[i] = false;
4458
+// copy.versionlist[i] = null;
4459
+// }
37774460
3778
- SetUndoStates();
4461
+ SetVersionStates();
37794462
37804463 // test save
37814464 if (false)
....@@ -3828,17 +4511,19 @@
38284511 GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
38294512 flashIt = true;
38304513
3831
- refreshContents(false);
4514
+ //refreshContents(false);
38324515 }
38334516
3834
- void CopyChanged(Object3D obj)
4517
+ void CopyChanged()
38354518 {
3836
- SetUndoStates();
4519
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4520
+
4521
+ SetVersionStates();
38374522
38384523 boolean temp = CameraPane.SWITCH;
38394524 CameraPane.SWITCH = false;
38404525
3841
- copy.ExtractBigData(versiontable);
4526
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
38424527
38434528 copy.clear();
38444529
....@@ -3850,7 +4535,7 @@
38504535 copy.add(obj.get(i));
38514536 }
38524537
3853
- copy.RestoreBigData(versiontable);
4538
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
38544539
38554540 CameraPane.SWITCH = temp;
38564541
....@@ -3875,13 +4560,15 @@
38754560 }
38764561 }
38774562
3878
- refreshContents();
4563
+ refreshContents(true);
38794564 }
38804565
3881
- cButton undoButton;
4566
+ cButton previousVersionButton;
38824567 cButton restoreButton;
38834568 cButton replaceButton;
3884
- cButton redoButton;
4569
+ cButton nextVersionButton;
4570
+ cButton saveVersionButton;
4571
+ cButton deleteVersionButton;
38854572
38864573 boolean muteSlider;
38874574
....@@ -3898,30 +4585,55 @@
38984585 return count;
38994586 }
39004587
3901
- void SetUndoStates()
4588
+ public cGridBag versionSliderPane;
4589
+
4590
+ void SetVersionStates()
39024591 {
3903
- cRadio tab = GetCurrentTab();
4592
+ //if (true)
4593
+ // return;
4594
+
4595
+ //cRadio tab = GetCurrentTab();
39044596
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;
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
+ }
39154627 }
39164628
3917
- public boolean Undo()
4629
+ public boolean PreviousVersion()
39184630 {
39194631 // Option?
39204632 Replace();
39214633
39224634 System.err.println("Undo");
39234635
3924
- cRadio tab = GetCurrentTab();
4636
+ //cRadio tab = GetCurrentTab();
39254637
39264638 if (copy.versionindex == 0)
39274639 {
....@@ -3944,7 +4656,7 @@
39444656
39454657 copy.versionindex -= 1;
39464658
3947
- CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
4659
+ CopyChanged();
39484660
39494661 return true;
39504662 }
....@@ -3953,7 +4665,7 @@
39534665 {
39544666 System.err.println("Restore");
39554667
3956
- cRadio tab = GetCurrentTab();
4668
+ //cRadio tab = GetCurrentTab();
39574669
39584670 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
39594671 {
....@@ -3962,16 +4674,16 @@
39624674 }
39634675
39644676 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
- CopyChanged(copy.versionlist[copy.versionindex]);
4677
+ CopyChanged();
39664678
39674679 return true;
39684680 }
39694681
39704682 public boolean Replace()
39714683 {
3972
- System.err.println("Replace");
4684
+ //System.err.println("Replace");
39734685
3974
- cRadio tab = GetCurrentTab();
4686
+ //cRadio tab = GetCurrentTab();
39754687
39764688 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
39774689 {
....@@ -3979,17 +4691,17 @@
39794691 return false;
39804692 }
39814693
3982
- copy.versionlist[copy.versionindex] = CompressCopy();
4694
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
39834695
39844696 return true;
39854697 }
39864698
3987
- public void Redo()
4699
+ public void NextVersion()
39884700 {
39894701 // Option?
39904702 Replace();
39914703
3992
- cRadio tab = GetCurrentTab();
4704
+ //cRadio tab = GetCurrentTab();
39934705
39944706 if (copy.versionlist[copy.versionindex + 1] == null)
39954707 {
....@@ -3999,7 +4711,7 @@
39994711
40004712 copy.versionindex += 1;
40014713
4002
- CopyChanged(copy.versionlist[copy.versionindex]);
4714
+ CopyChanged();
40034715
40044716 //if (!tab.user[tab.versionindex])
40054717 // tab.graphs[tab.versionindex] = null;
....@@ -4196,6 +4908,12 @@
41964908 // else
41974909 // applySelf(true);
41984910 // }
4911
+
4912
+ boolean Equal(double a, double b)
4913
+ {
4914
+ return Math.abs(a - b) < 0.001;
4915
+ }
4916
+
41994917 void applySelf0(boolean name)
42004918 {
42014919 if (name)
....@@ -4245,29 +4963,52 @@
42454963 {
42464964 cMaterial mat = copy.material;
42474965
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));
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));
42715012 }
42725013
42735014 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4302,17 +5043,20 @@
43025043
43035044 public void stateChanged(ChangeEvent e)
43045045 {
4305
- // assert(false);
5046
+ // assert(false);
43065047 if (e.getSource() == versionSlider)
43075048 {
43085049 if (muteSlider)
43095050 return;
43105051
5052
+ Replace();
5053
+
43115054 int version = versionSlider.getInteger();
43125055
4313
- if (copy.versionlist[version] != null)
5056
+ if (version != -1 && copy.versionlist[version] != null)
43145057 {
4315
- CopyChanged(copy.versionlist[copy.versionindex = version]);
5058
+ copy.versionindex = version;
5059
+ CopyChanged();
43165060 }
43175061
43185062 return;
....@@ -4353,7 +5097,7 @@
43535097 //System.out.println("stateChanged = " + this);
43545098 materialtouched = true;
43555099
4356
- if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
5100
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
43575101 {
43585102 saturationField.setFloat(1);
43595103 }
....@@ -4666,6 +5410,11 @@
46665410 ctrlPanel.validate(); // ? new
46675411 ctrlPanel.repaint();
46685412 }
5413
+
5414
+ if (previousVersionButton != null && copy.versionlist != null)
5415
+ SetVersionStates();
5416
+
5417
+ cameraView.requestFocusInWindow();
46695418 }
46705419
46715420 static TweenManager tweenManager = new TweenManager();
....@@ -4697,7 +5446,7 @@
46975446 // group = (Composite) group.get(0);
46985447 // }
46995448
4700
- System.out.println("makeSomething of " + thing);
5449
+ //System.out.println("makeSomething of " + thing);
47015450
47025451 /*
47035452 if (deselect && jList != null)
....@@ -5051,11 +5800,15 @@
50515800
50525801 copy.versionlist = readobj.versionlist;
50535802 copy.versionindex = readobj.versionindex;
5803
+ copy.versiontable = readobj.versiontable;
50545804
50555805 if (copy.versionlist == null)
50565806 {
5807
+ // Backward compatibility
50575808 copy.versionlist = new Object3D[100];
50585809 copy.versionindex = -1;
5810
+
5811
+ //Save(true);
50595812 }
50605813
50615814 //? SetUndoStates();
....@@ -5070,7 +5823,7 @@
50705823 {
50715824 if (Grafreed.standAlone)
50725825 {
5073
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5826
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
50745827 browser.show();
50755828 String filename = browser.getFile();
50765829 if (filename != null && filename.length() > 0)
....@@ -5147,6 +5900,8 @@
51475900
51485901 void save()
51495902 {
5903
+ Replace();
5904
+
51505905 if (lastname == null)
51515906 {
51525907 return;
....@@ -5389,6 +6144,7 @@
53896144 ButtonGroup buttonGroup;
53906145
53916146 cGridBag toolboxPanel;
6147
+ cGridBag skyboxPanel;
53926148 cGridBag materialPanel;
53936149 cGridBag ctrlPanel;
53946150
....@@ -5400,6 +6156,7 @@
54006156 boolean materialFlushed;
54016157 Object3D latestObject;
54026158
6159
+ cGridBag transformPanel;
54036160 cGridBag XYZPanel;
54046161
54056162 JSplitPane gridPanel;
....@@ -5493,6 +6250,7 @@
54936250 cNumberSlider anisoField;
54946251 JLabel anisoVLabel;
54956252 cNumberSlider anisoVField;
6253
+
54966254 JLabel cameraLabel;
54976255 cNumberSlider cameraField;
54986256 JLabel selfshadowLabel;
....@@ -5507,6 +6265,7 @@
55076265 cNumberSlider fakedepthField;
55086266 JLabel shadowbiasLabel;
55096267 cNumberSlider shadowbiasField;
6268
+
55106269 JLabel bumpLabel;
55116270 cNumberSlider bumpField;
55126271 JLabel noiseLabel;