Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
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,12 +122,26 @@
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));
82
-
137
+ BufferedImage image;
138
+
139
+ if (name.endsWith("jpg"))
140
+ // Much faster!
141
+ image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
142
+ else
143
+ image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
144
+
83145 // if (image.getWidth() > 48 && image.getHeight() > 48)
84146 // {
85147 // BufferedImage resized = new BufferedImage(48, 48, image.getType());
....@@ -93,10 +155,14 @@
93155 // }
94156
95157 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
158
+
159
+ icons.put(name, icon);
160
+
96161 return icon;
97162 }
98163 catch (Exception e)
99164 {
165
+ //icons.put(name, null);
100166 return null;
101167 }
102168 }
....@@ -296,11 +362,13 @@
296362 client = inClient;
297363 copy = client;
298364
299
- if (copy.versionlist == null)
300
- {
301
- copy.versionlist = new Object3D[100];
302
- copy.versionindex = -1;
303
- }
365
+// if (copy.versionlist == null)
366
+// {
367
+// copy.versionlist = new Object3D[100];
368
+// copy.versionindex = -1;
369
+//
370
+// callee.Save(true);
371
+// }
304372
305373 // "this" is not called: SetupUI2(objEditor);
306374 }
....@@ -315,12 +383,6 @@
315383 client = inClient;
316384 copy = client;
317385
318
- if (copy.versionlist == null)
319
- {
320
- copy.versionlist = new Object3D[100];
321
- copy.versionindex = -1;
322
- }
323
-
324386 SetupUI2(callee.GetEditor());
325387 }
326388
....@@ -342,7 +404,8 @@
342404 //parent = p;
343405
344406 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
345
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
407
+ if (Globals.DEBUG)
408
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
346409 //gd.setFullScreenWindow(this);
347410 //setResizable(false);
348411 //if (!isDisplayable())
....@@ -353,11 +416,13 @@
353416 copy = localCopy;
354417 copy.editWindow = this;
355418
356
- if (copy.versionlist == null)
357
- {
358
-// copy.versions = new byte[100][];
419
+// if (copy.versionlist == null)
420
+// {
421
+// copy.versionlist = new Object3D[100];
359422 // copy.versionindex = -1;
360
- }
423
+//
424
+// Save(true);
425
+// }
361426
362427 SetupMenu();
363428
....@@ -377,6 +442,9 @@
377442
378443 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379444
445
+ // This is to refresh the UI of the material panel.
446
+ boolean patchMaterial;
447
+
380448 void SetupMenu()
381449 {
382450 frame.setMenuBar(menuBar = new MenuBar());
....@@ -390,8 +458,11 @@
390458 importOBJItem.addActionListener(this);
391459 import3DSItem = menu.add(new MenuItem("3DS file..."));
392460 import3DSItem.addActionListener(this);
461
+ if (Globals.ADVANCED)
462
+ {
393463 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
394464 importVRMLX3DItem.addActionListener(this);
465
+ }
395466 menu.add("-");
396467 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
397468 importGFDItem.addActionListener(this);
....@@ -426,6 +497,8 @@
426497
427498 ChangeListener changeListener = new ChangeListener()
428499 {
500
+ //String name;
501
+
429502 public void stateChanged(ChangeEvent changeEvent)
430503 {
431504 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -444,7 +517,37 @@
444517 // EditSelection(false);
445518 // }
446519
447
- refreshContents(false); // To refresh Info tab
520
+// if (objectPanel.getSelectedIndex() == 4)
521
+// {
522
+// name = copy.skyboxname;
523
+//
524
+// if (name == null)
525
+// {
526
+// name = "";
527
+// }
528
+//
529
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
530
+// copy.skyboxext = "jpg";
531
+// }
532
+// else
533
+// {
534
+// if (name != null)
535
+// {
536
+// if (name.equals(""))
537
+// {
538
+// copy.skyboxname = null;
539
+// copy.skyboxext = null;
540
+// }
541
+// else
542
+// {
543
+// copy.skyboxname = name;
544
+// }
545
+// }
546
+// }
547
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
548
+
549
+// refreshContents(false); // To refresh Info tab
550
+ cameraView.repaint();
448551 }
449552 };
450553 objectPanel.addChangeListener(changeListener);
....@@ -466,6 +569,8 @@
466569
467570 toolboxPanel = new cGridBag().setVertical(true);
468571 //toolboxPanel.setName("Toolbox");
572
+
573
+ skyboxPanel = new cGridBag().setVertical(true);
469574
470575 materialPanel = new cGridBag().setVertical(false);
471576 //materialPanel.setName("Material");
....@@ -751,6 +856,7 @@
751856 boolean maximized;
752857
753858 cButton fullscreenLayout;
859
+ cButton expandedLayout;
754860
755861 void Minimize()
756862 {
....@@ -790,10 +896,12 @@
790896 cButton minButton;
791897 cButton maxButton;
792898 cButton fullButton;
899
+ cButton collapseButton;
900
+ cButton maximize3DButton;
793901
794902 void ToggleFullScreen()
795903 {
796
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
904
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797905
798906 cameraView.ToggleFullScreen();
799907
....@@ -814,13 +922,13 @@
814922 // X frame.getContentPane().remove(/*"Center",*/bigThree);
815923 // X framePanel.add(bigThree);
816924 // X frame.getContentPane().add(/*"Center",*/framePanel);
817
- framePanel.setDividerLocation(46);
925
+// framePanel.setDividerLocation(46); // icons are 24x24
818926
819927 //frame.setVisible(true);
820
- radio.layout = keepButton;
928
+// radio.layout = keepButton;
821929 //theFrame = null;
822930 keepButton = null;
823
- radio.layout.doClick();
931
+// radio.layout.doClick();
824932
825933 } else
826934 {
....@@ -841,10 +949,10 @@
841949 // X frame.getContentPane().remove(/*"Center",*/framePanel);
842950 // X framePanel.remove(bigThree);
843951 // X frame.getContentPane().add(/*"Center",*/bigThree);
844
- framePanel.setDividerLocation(0);
952
+// framePanel.setDividerLocation(0);
845953
846
- radio.layout = fullscreenLayout;
847
- radio.layout.doClick();
954
+// radio.layout = fullscreenLayout;
955
+// radio.layout.doClick();
848956 //frame.setVisible(true);
849957 }
850958 frame.validate();
....@@ -852,23 +960,42 @@
852960 cameraView.requestFocusInWindow();
853961 }
854962
855
- private Object3D CompressCopy()
963
+ void CollapseToolbar()
964
+ {
965
+ framePanel.setDividerLocation(0);
966
+ //frame.validate();
967
+
968
+ cameraView.requestFocusInWindow();
969
+ }
970
+
971
+ private Object3D Duplicate(Object3D object)
856972 {
857973 boolean temp = CameraPane.SWITCH;
858974 CameraPane.SWITCH = false;
859975
860
- copy.ExtractBigData(versiontable);
976
+ if (Grafreed.grafreed.universe.versiontable == null)
977
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
978
+
979
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
861980 // if (copy == client)
862981
863
- Object3D versions[] = copy.versionlist;
864
- copy.versionlist = null;
982
+ Object3D versions[] = object.versionlist;
983
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
984
+ object.versionlist = null;
985
+ object.versiontable = null;
986
+
987
+ Object3D parent = object.parent;
988
+ object.parent = null;
865989
866990 //byte[] compress = Compress(copy);
867
- Object3D compress = (Object3D)Grafreed.clone(copy);
991
+ Object3D compress = (Object3D)Grafreed.clone(object);
868992
869
- copy.versionlist = versions;
993
+ object.parent = parent;
870994
871
- copy.RestoreBigData(versiontable);
995
+ object.versionlist = versions;
996
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
997
+
998
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
872999
8731000 CameraPane.SWITCH = temp;
8741001
....@@ -1205,6 +1332,18 @@
12051332
12061333 namePanel = new cGridBag();
12071334
1335
+ //if (copy.pinned)
1336
+ {
1337
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1338
+ pinButton.setSelected(copy.pinned);
1339
+ cGridBag t = new cGridBag();
1340
+ t.preferredWidth = 2;
1341
+ t.add(pinButton);
1342
+ namePanel.add(t);
1343
+
1344
+ pinButton.addItemListener(this);
1345
+ }
1346
+
12081347 nameField = AddText(namePanel, copy.GetName());
12091348 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
12101349 oe.ctrlPanel.add(namePanel);
....@@ -1218,14 +1357,14 @@
12181357
12191358 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12201359 liveCB.setToolTipText("Animate object");
1360
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1361
+ markCB.setToolTipText("Set target transform");
12211362 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
12221363 selectableCB.setToolTipText("Make object selectable");
12231364 // Return();
12241365
12251366 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12261367 hideCB.setToolTipText("Hide object");
1227
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1228
- markCB.setToolTipText("As animation target transform");
12291368
12301369 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12311370
....@@ -1427,22 +1566,9 @@
14271566
14281567 if (cam == null || !(copy.get(0) instanceof cGroup))
14291568 {
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);
1569
+ if (Globals.DEBUG)
1570
+ System.out.println("CREATE CAMERAS");
1571
+ cams = CreateCameras();
14461572 } else
14471573 {
14481574 cams = (cGroup) copy.get(0);
....@@ -1508,6 +1634,45 @@
15081634 //frontView.object = copy;
15091635 //sideView.object = copy;
15101636
1637
+ transformPanel = new cGridBag().setVertical(true);
1638
+
1639
+ cGridBag resetTransformPanel = new cGridBag();
1640
+
1641
+ resetTransformPanel.preferredHeight = 2;
1642
+
1643
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1644
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1645
+ resetTransform.addMouseListener(new MouseAdapter()
1646
+ {
1647
+ public void mouseClicked(MouseEvent e)
1648
+ {
1649
+ ResetTransform();
1650
+ }
1651
+ });
1652
+ resetTransformPanel.add(resetTransform);
1653
+
1654
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1655
+ resetTransform.setToolTipText("Reset Translation only");
1656
+ resetTransform.addMouseListener(new MouseAdapter()
1657
+ {
1658
+ public void mouseClicked(MouseEvent e)
1659
+ {
1660
+ ResetTransform(1);
1661
+ }
1662
+ });
1663
+ resetTransformPanel.add(resetTransform);
1664
+
1665
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1666
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1667
+ resetTransform.addMouseListener(new MouseAdapter()
1668
+ {
1669
+ public void mouseClicked(MouseEvent e)
1670
+ {
1671
+ ResetTransform(2);
1672
+ }
1673
+ });
1674
+ resetTransformPanel.add(resetTransform);
1675
+
15111676 XYZPanel = new cGridBag().setVertical(true);
15121677 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
15131678
....@@ -1517,6 +1682,9 @@
15171682 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
15181683 //XYZPanel.setName("XYZ");
15191684
1685
+ transformPanel.add(resetTransformPanel);
1686
+ transformPanel.add(XYZPanel);
1687
+
15201688 /*
15211689 gridPanel = new JPanel(); //new BorderLayout());
15221690 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1524,12 +1692,12 @@
15241692 gridPanel.add(cameraView);
15251693 gridPanel.add(XYZPanel);
15261694 */
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);
1695
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1696
+// gridPanel.setContinuousLayout(true);
1697
+// gridPanel.setOneTouchExpandable(true);
1698
+// gridPanel.setDividerLocation(1.0);
1699
+// gridPanel.setDividerSize(9);
1700
+// gridPanel.setResizeWeight(0.85);
15331701
15341702 // aConstraints.weighty = 0;
15351703 //System.out.println("THIS = " + this);
....@@ -1552,31 +1720,34 @@
15521720
15531721 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15541722 //tmp.setName("Edit");
1723
+ objectPanel.add(skyboxPanel);
1724
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1725
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1726
+
1727
+ objectPanel.add(toolboxPanel);
1728
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1729
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1730
+
15551731 objectPanel.add(materialPanel);
1556
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
- objectPanel.setToolTipTextAt(0, "Material");
1732
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1733
+ objectPanel.setToolTipTextAt(2, "Material");
15581734
15591735 // JPanel north = new JPanel(new BorderLayout());
15601736 // north.setName("Edit");
15611737 // north.add(ctrlPanel, BorderLayout.NORTH);
15621738 // objectPanel.add(north);
15631739 objectPanel.add(editPanel);
1564
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
- objectPanel.setToolTipTextAt(1, "Edit controls");
1740
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1741
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15661742
1567
- //if (Globals.ADVANCED)
1568
- objectPanel.add(infoPanel);
1569
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
- objectPanel.setToolTipTextAt(2, "Information");
1743
+ objectPanel.add(transformPanel);
1744
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1745
+ objectPanel.setToolTipTextAt(4, "TRS transform");
15711746
1572
- objectPanel.add(XYZPanel);
1573
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
- objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1575
-
1576
- objectPanel.add(toolboxPanel);
1577
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
- objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
1579
-
1747
+ patchMaterial = true;
1748
+ cameraView.patchMaterial = this;
1749
+ objectPanel.setSelectedIndex(2);
1750
+
15801751 /*
15811752 aConstraints.gridx = 0;
15821753 aConstraints.gridwidth = 1;
....@@ -1607,11 +1778,108 @@
16071778
16081779 AddOptions(optionsPanel); //, aConstraints);
16091780
1610
- tabbedPane.add(optionsPanel);
1611
-
16121781 tabbedPane.add(FSPane = new cFileSystemPane(this));
16131782
1783
+ tabbedPane.add(optionsPanel);
1784
+
16141785 scenePanel.add(tabbedPane);
1786
+
1787
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1788
+ creditsPanel.setName("Credits");
1789
+
1790
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1791
+ creditsPanel.add(ogaLabel);
1792
+
1793
+ cButton creditButton;
1794
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1795
+ creditButton.setToolTipText("https://opengameart.org");
1796
+
1797
+ creditButton.addMouseListener(new MouseAdapter()
1798
+ {
1799
+ public void mouseClicked(MouseEvent e)
1800
+ {
1801
+ try
1802
+ {
1803
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1804
+ } catch (Exception e1)
1805
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1806
+ {
1807
+ e1.printStackTrace();
1808
+ }
1809
+ }
1810
+ });
1811
+
1812
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1813
+ creditsPanel.add(ogaLabel);
1814
+
1815
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1816
+ creditButton.setToolTipText("https://3delicious.net");
1817
+
1818
+ creditButton.addMouseListener(new MouseAdapter()
1819
+ {
1820
+ public void mouseClicked(MouseEvent e)
1821
+ {
1822
+ try
1823
+ {
1824
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1825
+ } catch (Exception e1)
1826
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1827
+ {
1828
+ e1.printStackTrace();
1829
+ }
1830
+ }
1831
+ });
1832
+
1833
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1834
+ creditButton.setToolTipText("https://archive3d.net");
1835
+
1836
+ creditButton.addMouseListener(new MouseAdapter()
1837
+ {
1838
+ public void mouseClicked(MouseEvent e)
1839
+ {
1840
+ try
1841
+ {
1842
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1843
+ } catch (Exception e1)
1844
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1845
+ {
1846
+ e1.printStackTrace();
1847
+ }
1848
+ }
1849
+ });
1850
+
1851
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1852
+ creditButton.setToolTipText("https://turbosquid.com");
1853
+
1854
+ creditButton.addMouseListener(new MouseAdapter()
1855
+ {
1856
+ public void mouseClicked(MouseEvent e)
1857
+ {
1858
+ try
1859
+ {
1860
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1861
+ } catch (Exception e1)
1862
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1863
+ {
1864
+ e1.printStackTrace();
1865
+ }
1866
+ }
1867
+ });
1868
+
1869
+ for (int i=6; --i>=0;)
1870
+ {
1871
+ creditsPanel.add(new cGridBag());
1872
+ }
1873
+
1874
+ tabbedPane.add(creditsPanel);
1875
+ tabbedPane.setToolTipTextAt(3, "Credits");
1876
+
1877
+ if (Globals.ADVANCED)
1878
+ {
1879
+ objectPanel.add(infoPanel);
1880
+ objectPanel.setIconAt(5, GetIcon("icons/info.png"));
1881
+ objectPanel.setToolTipTextAt(4, "Information");
1882
+ }
16151883
16161884 /*
16171885 cTree jTree = new cTree(null);
....@@ -1633,13 +1901,13 @@
16331901 jtp.add(tree);
16341902 */
16351903
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");
1904
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1905
+// bigPanel.setContinuousLayout(true);
1906
+// bigPanel.setOneTouchExpandable(true);
1907
+// bigPanel.setDividerLocation(0.8);
1908
+// bigPanel.setDividerSize(15);
1909
+// bigPanel.setResizeWeight(0.15);
1910
+// bigPanel.setName("Scene");
16431911
16441912 //bigPanel.setLayout(new BorderLayout());
16451913 //bigPanel.setSize(new Dimension(10,10));
....@@ -1683,6 +1951,23 @@
16831951 // aConstraints.gridheight = 1;
16841952
16851953 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1954
+
1955
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1956
+ new java.beans.PropertyChangeListener()
1957
+ {
1958
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1959
+ {
1960
+ if ((Integer)pce.getOldValue() == 1)
1961
+ {
1962
+ if (radio.layout != expandedLayout)
1963
+ {
1964
+ radio.layout = expandedLayout;
1965
+ radio.layout.doClick();
1966
+ }
1967
+ }
1968
+ }
1969
+ });
1970
+
16861971 framePanel.setContinuousLayout(false);
16871972 framePanel.setOneTouchExpandable(false);
16881973 //.setDividerLocation(0.8);
....@@ -1692,7 +1977,7 @@
16921977
16931978 frame.getContentPane().setLayout(new BorderLayout());
16941979 /**/
1695
- JTabbedPane worldPane = new JTabbedPane();
1980
+ //JTabbedPane worldPane = new JTabbedPane();
16961981 //worldPane.add(bigPanel);
16971982 //worldPane.add(worldPanel);
16981983 /**/
....@@ -1706,7 +1991,7 @@
17061991
17071992 cameraView.requestFocusInWindow();
17081993
1709
- gridPanel.setDividerLocation(1.0);
1994
+// gridPanel.setDividerLocation(1.0);
17101995
17111996 frame.validate();
17121997
....@@ -1741,7 +2026,7 @@
17412026 {
17422027 cGridBag presetpanel = new cGridBag().setVertical(true);
17432028
1744
- cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
2029
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
17452030 skin.setToolTipText("Skin");
17462031 skin.addMouseListener(new MouseAdapter()
17472032 {
....@@ -1752,7 +2037,15 @@
17522037
17532038 // Skin
17542039 colorField.setFloat(material.color);
1755
- saturationField.setFloat(material.modulation);
2040
+ float saturation = material.modulation;
2041
+
2042
+ if (!cameraView.Skinshader)
2043
+ {
2044
+ saturation /= 1.5;
2045
+ }
2046
+
2047
+ saturationField.setFloat(saturation);
2048
+
17562049 subsurfaceField.setFloat(material.subsurface);
17572050 selfshadowField.setFloat(material.diffuseness);
17582051 diffusenessField.setFloat(material.factor);
....@@ -1771,7 +2064,7 @@
17712064 });
17722065 presetpanel.add(skin);
17732066
1774
- cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
2067
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
17752068 lambert.setToolTipText("Diffuse");
17762069 lambert.addMouseListener(new MouseAdapter()
17772070 {
....@@ -1789,7 +2082,7 @@
17892082 });
17902083 presetpanel.add(lambert);
17912084
1792
- cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
2085
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
17932086 diffuse2.setToolTipText("Diffuse2");
17942087 diffuse2.addMouseListener(new MouseAdapter()
17952088 {
....@@ -1807,7 +2100,7 @@
18072100 });
18082101 presetpanel.add(diffuse2);
18092102
1810
- cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2103
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
18112104 diffusemoon.setToolTipText("Moon");
18122105 diffusemoon.addMouseListener(new MouseAdapter()
18132106 {
....@@ -1825,7 +2118,7 @@
18252118 });
18262119 presetpanel.add(diffusemoon);
18272120
1828
- cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2121
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
18292122 diffusemoon2.setToolTipText("Moon2");
18302123 diffusemoon2.addMouseListener(new MouseAdapter()
18312124 {
....@@ -1843,7 +2136,7 @@
18432136 });
18442137 presetpanel.add(diffusemoon2);
18452138
1846
- cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2139
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
18472140 diffusemoon3.setToolTipText("Moon3");
18482141 diffusemoon3.addMouseListener(new MouseAdapter()
18492142 {
....@@ -1861,7 +2154,7 @@
18612154 });
18622155 presetpanel.add(diffusemoon3);
18632156
1864
- cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2157
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
18652158 diffusesheen.setToolTipText("Sheen");
18662159 diffusesheen.addMouseListener(new MouseAdapter()
18672160 {
....@@ -1878,7 +2171,7 @@
18782171 });
18792172 presetpanel.add(diffusesheen);
18802173
1881
- cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2174
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
18822175 rough.setToolTipText("Rough metal");
18832176 rough.addMouseListener(new MouseAdapter()
18842177 {
....@@ -1896,7 +2189,7 @@
18962189 });
18972190 presetpanel.add(rough);
18982191
1899
- cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2192
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
19002193 rough2.setToolTipText("Medium metal");
19012194 rough2.addMouseListener(new MouseAdapter()
19022195 {
....@@ -1914,7 +2207,7 @@
19142207 });
19152208 presetpanel.add(rough2);
19162209
1917
- cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2210
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
19182211 shini0.setToolTipText("Shiny");
19192212 shini0.addMouseListener(new MouseAdapter()
19202213 {
....@@ -1932,7 +2225,7 @@
19322225 });
19332226 presetpanel.add(shini0);
19342227
1935
- cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2228
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
19362229 shini1.setToolTipText("Shiny2");
19372230 shini1.addMouseListener(new MouseAdapter()
19382231 {
....@@ -1950,7 +2243,7 @@
19502243 });
19512244 presetpanel.add(shini1);
19522245
1953
- cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2246
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
19542247 shini2.setToolTipText("Shiny3");
19552248 shini2.addMouseListener(new MouseAdapter()
19562249 {
....@@ -1968,7 +2261,7 @@
19682261 });
19692262 presetpanel.add(shini2);
19702263
1971
- cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2264
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
19722265 aniso.setToolTipText("AnisoU");
19732266 aniso.addMouseListener(new MouseAdapter()
19742267 {
....@@ -1986,7 +2279,7 @@
19862279 });
19872280 presetpanel.add(aniso);
19882281
1989
- cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2282
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
19902283 aniso2.setToolTipText("AnisoV");
19912284 aniso2.addMouseListener(new MouseAdapter()
19922285 {
....@@ -2004,7 +2297,7 @@
20042297 });
20052298 presetpanel.add(aniso2);
20062299
2007
- cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2300
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
20082301 aniso3.setToolTipText("AnisoUV");
20092302 aniso3.addMouseListener(new MouseAdapter()
20102303 {
....@@ -2022,7 +2315,7 @@
20222315 });
20232316 presetpanel.add(aniso3);
20242317
2025
- cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2318
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
20262319 velvet0.setToolTipText("Velvet");
20272320 velvet0.addMouseListener(new MouseAdapter()
20282321 {
....@@ -2044,7 +2337,7 @@
20442337 });
20452338 presetpanel.add(velvet0);
20462339
2047
- cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2340
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
20482341 bump0.setToolTipText("Bump texture");
20492342 bump0.addMouseListener(new MouseAdapter()
20502343 {
....@@ -2063,7 +2356,22 @@
20632356 });
20642357 presetpanel.add(bump0);
20652358
2066
- cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2359
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2360
+ borderShader.setToolTipText("Border fade");
2361
+ borderShader.addMouseListener(new MouseAdapter()
2362
+ {
2363
+ public void mouseClicked(MouseEvent e)
2364
+ {
2365
+ borderfadeField.setFloat(0.4);
2366
+ opacityField.setFloat(0.75);
2367
+
2368
+ materialtouched = true;
2369
+ applySelf();
2370
+ }
2371
+ });
2372
+ presetpanel.add(borderShader);
2373
+
2374
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
20672375 halo.setToolTipText("Halo");
20682376 halo.addMouseListener(new MouseAdapter()
20692377 {
....@@ -2080,7 +2388,7 @@
20802388 });
20812389 presetpanel.add(halo);
20822390
2083
- cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2391
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
20842392 candle.setToolTipText("Candle");
20852393 candle.addMouseListener(new MouseAdapter()
20862394 {
....@@ -2102,6 +2410,67 @@
21022410 });
21032411 presetpanel.add(candle);
21042412
2413
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2414
+ shadowShader.setToolTipText("Shadow");
2415
+ shadowShader.addMouseListener(new MouseAdapter()
2416
+ {
2417
+ public void mouseClicked(MouseEvent e)
2418
+ {
2419
+ diffuseField.setFloat(0.001);
2420
+ ambientField.setFloat(0.001);
2421
+ cameraField.setFloat(0.001);
2422
+ specularField.setFloat(0.001);
2423
+ fakedepthField.setFloat(0.001);
2424
+ opacityField.setFloat(0.6);
2425
+
2426
+ materialtouched = true;
2427
+ applySelf();
2428
+ }
2429
+ });
2430
+ presetpanel.add(shadowShader);
2431
+
2432
+ cLabel para0 = GetLabel("icons/shadericons/parallax0.png", !Globals.NIMBUSLAF);
2433
+ para0.setToolTipText("No parallax");
2434
+ para0.addMouseListener(new MouseAdapter()
2435
+ {
2436
+ public void mouseClicked(MouseEvent e)
2437
+ {
2438
+ parallaxField.setFloat(0.125);
2439
+
2440
+ materialtouched = true;
2441
+ applySelf();
2442
+ }
2443
+ });
2444
+ presetpanel.add(para0);
2445
+
2446
+ cLabel para1 = GetLabel("icons/shadericons/parallax1.png", !Globals.NIMBUSLAF);
2447
+ para1.setToolTipText("With parallax");
2448
+ para1.addMouseListener(new MouseAdapter()
2449
+ {
2450
+ public void mouseClicked(MouseEvent e)
2451
+ {
2452
+ parallaxField.setFloat(0.13);
2453
+
2454
+ materialtouched = true;
2455
+ applySelf();
2456
+ }
2457
+ });
2458
+ presetpanel.add(para1);
2459
+
2460
+ cLabel para2 = GetLabel("icons/shadericons/parallax2.png", !Globals.NIMBUSLAF);
2461
+ para2.setToolTipText("Reset parallax");
2462
+ para2.addMouseListener(new MouseAdapter()
2463
+ {
2464
+ public void mouseClicked(MouseEvent e)
2465
+ {
2466
+ parallaxField.setFloat(0.14);
2467
+
2468
+ materialtouched = true;
2469
+ applySelf();
2470
+ }
2471
+ });
2472
+ presetpanel.add(para2);
2473
+
21052474 cGridBag panel = new cGridBag().setVertical(true);
21062475
21072476 presetpanel.preferredWidth = 1;
....@@ -2118,19 +2487,19 @@
21182487
21192488 cGridBag editBar = new cGridBag().setVertical(false);
21202489
2121
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2490
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
21222491 createMaterialButton.setToolTipText("Create material");
21232492
21242493 /*
21252494 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
21262495 */
21272496
2128
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2497
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
21292498 clearMaterialButton.setToolTipText("Clear material");
21302499
21312500 if (Globals.ADVANCED)
21322501 {
2133
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2502
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
21342503 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
21352504 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
21362505 }
....@@ -2151,9 +2520,20 @@
21512520
21522521 cGridBag huepanel = new cGridBag();
21532522 cGridBag huelabel = new cGridBag();
2154
- skin = GetLabel("icons/hue.png", false);
2155
- skin.fit = true;
2156
- huelabel.add(skin);
2523
+ cLabel hue = GetLabel("icons/hue.png", false);
2524
+ hue.fit = true;
2525
+
2526
+ hue.addMouseListener(new MouseAdapter()
2527
+ {
2528
+ public void mousePressed(MouseEvent e)
2529
+ {
2530
+ int x = e.getX();
2531
+
2532
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2533
+ }
2534
+ });
2535
+
2536
+ huelabel.add(hue);
21572537 huelabel.preferredWidth = 20;
21582538 huepanel.add(new cGridBag()); // Label
21592539 huepanel.add(huelabel); // Field/slider
....@@ -2336,6 +2716,12 @@
23362716 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
23372717 colorSection.add(backlit);
23382718
2719
+ cGridBag parallax = new cGridBag();
2720
+ parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
2721
+ parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2722
+ parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints);
2723
+ colorSection.add(parallax);
2724
+
23392725 //panel.add(new JSeparator());
23402726
23412727 //panel.add(globalSection);
....@@ -3387,6 +3773,7 @@
33873773 shadowField.setFloat(mat.shadow);
33883774 textureField.setFloat(mat.texture);
33893775 opacityField.setFloat(mat.opacity);
3776
+ parallaxField.setFloat(mat.parallax + 0.125f);
33903777 fakedepthField.setFloat(mat.fakedepth);
33913778 shadowbiasField.setFloat(mat.shadowbias);
33923779 bumpField.setInteger(1); // dec 2013
....@@ -3429,32 +3816,8 @@
34293816
34303817 if (multiplyToggle != null)
34313818 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
- }
3819
+
3820
+ AllocProjectedVertices(object);
34583821
34593822 SetMaterial(mat, object.projectedVertices);
34603823 }
....@@ -3574,6 +3937,17 @@
35743937 public void itemStateChanged(ItemEvent event)
35753938 {
35763939 // System.out.println("Propagate = " + propagate);
3940
+ if (event.getSource() == pinButton)
3941
+ {
3942
+ copy.pinned ^= true;
3943
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3944
+ {
3945
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3946
+ copy.CloseUI();
3947
+ //copy.editWindow.refreshContents();
3948
+ }
3949
+ }
3950
+ else
35773951 if (event.getSource() == propagateToggle)
35783952 {
35793953 propagate ^= true;
....@@ -3753,7 +4127,7 @@
37534127 //System.out.println("ObjEditor " + event);
37544128 applySelf0(true);
37554129 //parent.applySelf();
3756
- objEditor.refreshContents();
4130
+ // conflicts with requestFocus objEditor.refreshContents();
37574131 } else if (source == resetButton)
37584132 {
37594133 CameraPane.fullreset = true;
....@@ -3933,11 +4307,18 @@
39334307
39344308 void New()
39354309 {
3936
- while (copy.Size() > 1)
4310
+ while (copy.Size() > 0)
39374311 {
3938
- copy.remove(1);
4312
+ copy.remove(0);
39394313 }
39404314
4315
+ copy.selection.clear();
4316
+
4317
+ if (copy == Grafreed.grafreed.universe)
4318
+ {
4319
+ CreateCameras();
4320
+ cameraView.SetCamera(GetCamera(copy, 0));
4321
+ }
39414322 ResetModel();
39424323 objEditor.refreshContents();
39434324 }
....@@ -4046,7 +4427,7 @@
40464427 {
40474428 //Save(true);
40484429 Replace();
4049
- SetUndoStates();
4430
+ SetVersionStates();
40504431 }
40514432
40524433 private boolean Equal(byte[] compress, byte[] name)
....@@ -4065,8 +4446,6 @@
40654446 return true;
40664447 }
40674448
4068
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4069
-
40704449 void DeleteVersion()
40714450 {
40724451 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4074,19 +4453,27 @@
40744453 copy.versionlist[i] = copy.versionlist[i+1];
40754454 }
40764455
4077
- CopyChanged();
4456
+ if (copy.versionlist[copy.versionindex] == null)
4457
+ copy.versionindex -= 1;
40784458
4079
- SetUndoStates();
4459
+ if (copy.versionindex != -1)
4460
+ CopyChanged();
4461
+
4462
+ SetVersionStates();
40804463 }
40814464
40824465 public boolean Save(boolean user)
40834466 {
40844467 System.err.println("Save");
4085
- //Replace();
4468
+ Replace();
40864469
4087
- cRadio tab = GetCurrentTab();
4470
+ if (copy.versionlist == null)
4471
+ {
4472
+ copy.versionlist = new Object3D[100];
4473
+ copy.versionindex = -1;
4474
+ }
40884475
4089
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
4476
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
40904477
40914478 boolean thesame = false;
40924479
....@@ -4122,7 +4509,7 @@
41224509 // copy.versionlist[i] = null;
41234510 // }
41244511
4125
- SetUndoStates();
4512
+ SetVersionStates();
41264513
41274514 // test save
41284515 if (false)
....@@ -4180,14 +4567,14 @@
41804567
41814568 void CopyChanged()
41824569 {
4183
- Object3D obj = copy.versionlist[copy.versionindex];
4570
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
41844571
4185
- SetUndoStates();
4572
+ SetVersionStates();
41864573
41874574 boolean temp = CameraPane.SWITCH;
41884575 CameraPane.SWITCH = false;
41894576
4190
- copy.ExtractBigData(versiontable);
4577
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
41914578
41924579 copy.clear();
41934580
....@@ -4199,7 +4586,7 @@
41994586 copy.add(obj.get(i));
42004587 }
42014588
4202
- copy.RestoreBigData(versiontable);
4589
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
42034590
42044591 CameraPane.SWITCH = temp;
42054592
....@@ -4249,23 +4636,45 @@
42494636 return count;
42504637 }
42514638
4252
- void SetUndoStates()
4639
+ public cGridBag versionSliderPane;
4640
+
4641
+ void SetVersionStates()
42534642 {
4254
- cRadio tab = GetCurrentTab();
4643
+ //if (true)
4644
+ // return;
4645
+
4646
+ //cRadio tab = GetCurrentTab();
42554647
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;
4648
+ if (copy.versionindex == -2)
4649
+ {
4650
+ saveVersionButton.setEnabled(false);
4651
+ restoreButton.setEnabled(false);
4652
+ replaceButton.setEnabled(false);
4653
+ previousVersionButton.setEnabled(false);
4654
+ nextVersionButton.setEnabled(false);
4655
+ deleteVersionButton.setEnabled(false);
4656
+ versionSliderPane.setVisible(false);
4657
+ }
4658
+ else
4659
+ {
4660
+ restoreButton.setEnabled(copy.versionindex != -1);
4661
+ replaceButton.setEnabled(copy.versionindex != -1);
4662
+
4663
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4664
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4665
+
4666
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4667
+ //copy.versionlist[copy.versionindex + 1] != null);
4668
+
4669
+ muteSlider = true;
4670
+ versionSlider.setMinimum(0);
4671
+ versionSlider.setMaximum(VersionCount() - 1);
4672
+ versionSlider.setInteger(copy.versionindex);
4673
+ versionSlider.setEnabled(copy.versionindex != -1);
4674
+ muteSlider = false;
4675
+
4676
+ versionSliderPane.setVisible(true);
4677
+ }
42694678 }
42704679
42714680 public boolean PreviousVersion()
....@@ -4275,7 +4684,7 @@
42754684
42764685 System.err.println("Undo");
42774686
4278
- cRadio tab = GetCurrentTab();
4687
+ //cRadio tab = GetCurrentTab();
42794688
42804689 if (copy.versionindex == 0)
42814690 {
....@@ -4307,7 +4716,7 @@
43074716 {
43084717 System.err.println("Restore");
43094718
4310
- cRadio tab = GetCurrentTab();
4719
+ //cRadio tab = GetCurrentTab();
43114720
43124721 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43134722 {
....@@ -4323,9 +4732,9 @@
43234732
43244733 public boolean Replace()
43254734 {
4326
- System.err.println("Replace");
4735
+ //System.err.println("Replace");
43274736
4328
- cRadio tab = GetCurrentTab();
4737
+ //cRadio tab = GetCurrentTab();
43294738
43304739 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43314740 {
....@@ -4333,7 +4742,7 @@
43334742 return false;
43344743 }
43354744
4336
- copy.versionlist[copy.versionindex] = CompressCopy();
4745
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
43374746
43384747 return true;
43394748 }
....@@ -4343,7 +4752,7 @@
43434752 // Option?
43444753 Replace();
43454754
4346
- cRadio tab = GetCurrentTab();
4755
+ //cRadio tab = GetCurrentTab();
43474756
43484757 if (copy.versionlist[copy.versionindex + 1] == null)
43494758 {
....@@ -4550,6 +4959,12 @@
45504959 // else
45514960 // applySelf(true);
45524961 // }
4962
+
4963
+ boolean Equal(double a, double b)
4964
+ {
4965
+ return Math.abs(a - b) < 0.001;
4966
+ }
4967
+
45534968 void applySelf0(boolean name)
45544969 {
45554970 if (name)
....@@ -4587,6 +5002,7 @@
45875002 current.shadow = (float) shadowField.getFloat();
45885003 current.texture = (float) textureField.getFloat();
45895004 current.opacity = (float) opacityField.getFloat();
5005
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
45905006 current.fakedepth = (float) fakedepthField.getFloat();
45915007 current.shadowbias = (float) shadowbiasField.getFloat();
45925008
....@@ -4599,29 +5015,54 @@
45995015 {
46005016 cMaterial mat = copy.material;
46015017
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));
5018
+ if (!Equal(colorField.getFloat(), mat.color))
5019
+ colorField.SetToolTipValue((mat.color));
5020
+ if (!Equal(saturationField.getFloat(), mat.modulation))
5021
+ saturationField.SetToolTipValue((mat.modulation));
5022
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
5023
+ metalnessField.SetToolTipValue((mat.metalness));
5024
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
5025
+ diffuseField.SetToolTipValue((mat.diffuse));
5026
+ if (!Equal(specularField.getFloat(), mat.specular))
5027
+ specularField.SetToolTipValue((mat.specular));
5028
+ if (!Equal(shininessField.getFloat(), mat.shininess))
5029
+ shininessField.SetToolTipValue((mat.shininess));
5030
+ if (!Equal(shiftField.getFloat(), mat.shift))
5031
+ shiftField.SetToolTipValue((mat.shift));
5032
+ if (!Equal(ambientField.getFloat(), mat.ambient))
5033
+ ambientField.SetToolTipValue((mat.ambient));
5034
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
5035
+ lightareaField.SetToolTipValue((mat.lightarea));
5036
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
5037
+ diffusenessField.SetToolTipValue((mat.factor));
5038
+ if (!Equal(velvetField.getFloat(), mat.velvet))
5039
+ velvetField.SetToolTipValue((mat.velvet));
5040
+ if (!Equal(sheenField.getFloat(), mat.sheen))
5041
+ sheenField.SetToolTipValue((mat.sheen));
5042
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
5043
+ subsurfaceField.SetToolTipValue((mat.subsurface));
5044
+ if (!Equal(backlitField.getFloat(), mat.bump))
5045
+ backlitField.SetToolTipValue((mat.bump));
5046
+ if (!Equal(anisoField.getFloat(), mat.aniso))
5047
+ anisoField.SetToolTipValue((mat.aniso));
5048
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
5049
+ anisoVField.SetToolTipValue((mat.anisoV));
5050
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
5051
+ cameraField.SetToolTipValue((mat.cameralight));
5052
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
5053
+ selfshadowField.SetToolTipValue((mat.diffuseness));
5054
+ if (!Equal(shadowField.getFloat(), mat.shadow))
5055
+ shadowField.SetToolTipValue((mat.shadow));
5056
+ if (!Equal(textureField.getFloat(), mat.texture))
5057
+ textureField.SetToolTipValue((mat.texture));
5058
+ if (!Equal(opacityField.getFloat(), mat.opacity))
5059
+ opacityField.SetToolTipValue((mat.opacity));
5060
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5061
+ parallaxField.SetToolTipValue((mat.parallax));
5062
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
5063
+ fakedepthField.SetToolTipValue((mat.fakedepth));
5064
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
5065
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
46255066 }
46265067
46275068 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4656,15 +5097,17 @@
46565097
46575098 public void stateChanged(ChangeEvent e)
46585099 {
4659
- // assert(false);
5100
+ // assert(false);
46605101 if (e.getSource() == versionSlider)
46615102 {
46625103 if (muteSlider)
46635104 return;
46645105
5106
+ Replace();
5107
+
46655108 int version = versionSlider.getInteger();
46665109
4667
- if (copy.versionlist[version] != null)
5110
+ if (version != -1 && copy.versionlist[version] != null)
46685111 {
46695112 copy.versionindex = version;
46705113 CopyChanged();
....@@ -4708,7 +5151,7 @@
47085151 //System.out.println("stateChanged = " + this);
47095152 materialtouched = true;
47105153
4711
- if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
5154
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
47125155 {
47135156 saturationField.setFloat(1);
47145157 }
....@@ -5023,7 +5466,9 @@
50235466 }
50245467
50255468 if (previousVersionButton != null && copy.versionlist != null)
5026
- SetUndoStates();
5469
+ SetVersionStates();
5470
+
5471
+ cameraView.requestFocusInWindow();
50275472 }
50285473
50295474 static TweenManager tweenManager = new TweenManager();
....@@ -5055,7 +5500,7 @@
50555500 // group = (Composite) group.get(0);
50565501 // }
50575502
5058
- System.out.println("makeSomething of " + thing);
5503
+ //System.out.println("makeSomething of " + thing);
50595504
50605505 /*
50615506 if (deselect && jList != null)
....@@ -5409,11 +5854,15 @@
54095854
54105855 copy.versionlist = readobj.versionlist;
54115856 copy.versionindex = readobj.versionindex;
5857
+ copy.versiontable = readobj.versiontable;
54125858
54135859 if (copy.versionlist == null)
54145860 {
5861
+ // Backward compatibility
54155862 copy.versionlist = new Object3D[100];
54165863 copy.versionindex = -1;
5864
+
5865
+ //Save(true);
54175866 }
54185867
54195868 //? SetUndoStates();
....@@ -5505,6 +5954,8 @@
55055954
55065955 void save()
55075956 {
5957
+ Replace();
5958
+
55085959 if (lastname == null)
55095960 {
55105961 return;
....@@ -5747,6 +6198,7 @@
57476198 ButtonGroup buttonGroup;
57486199
57496200 cGridBag toolboxPanel;
6201
+ cGridBag skyboxPanel;
57506202 cGridBag materialPanel;
57516203 cGridBag ctrlPanel;
57526204
....@@ -5758,6 +6210,7 @@
57586210 boolean materialFlushed;
57596211 Object3D latestObject;
57606212
6213
+ cGridBag transformPanel;
57616214 cGridBag XYZPanel;
57626215
57636216 JSplitPane gridPanel;
....@@ -5851,6 +6304,7 @@
58516304 cNumberSlider anisoField;
58526305 JLabel anisoVLabel;
58536306 cNumberSlider anisoVField;
6307
+
58546308 JLabel cameraLabel;
58556309 cNumberSlider cameraField;
58566310 JLabel selfshadowLabel;
....@@ -5861,10 +6315,13 @@
58616315 cNumberSlider textureField;
58626316 JLabel opacityLabel;
58636317 cNumberSlider opacityField;
6318
+ JLabel parallaxLabel;
6319
+ cNumberSlider parallaxField;
58646320 JLabel fakedepthLabel;
58656321 cNumberSlider fakedepthField;
58666322 JLabel shadowbiasLabel;
58676323 cNumberSlider shadowbiasField;
6324
+
58686325 JLabel bumpLabel;
58696326 cNumberSlider bumpField;
58706327 JLabel noiseLabel;