Normand Briere
2019-08-13 c67de8aca04d988179191ccb52461af00125920e
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,64 +42,78 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
4453
4554 cButton GetButton(String name, boolean border)
4655 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
5664 }
5765
5866 cToggleButton GetToggleButton(String name, boolean border)
5967 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
6970 }
7071
7172 cCheckBox GetCheckBox(String name, boolean border)
7273 {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ ImageIcon GetIcon(String name)
79
+ {
7380 try
7481 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
82
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
83
+
84
+// if (image.getWidth() > 48 && image.getHeight() > 48)
85
+// {
86
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
87
+// Graphics2D g = resized.createGraphics();
88
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
89
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
90
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
91
+// g.dispose();
92
+//
93
+// image = resized;
94
+// }
95
+
96
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
97
+ return icon;
7798 }
7899 catch (Exception e)
79100 {
80
- return new cCheckBox(name, border);
101
+ return null;
81102 }
82103 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
104
+
105
+ BufferedImage GetImage(String name)
85106 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
107
+ try
89108 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
109
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
110
+
111
+ return image;
98112 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
113
+ catch (Exception e)
114
+ {
115
+ return null;
116
+ }
102117 }
103118
104119 // SCRIPT
....@@ -282,11 +297,13 @@
282297 client = inClient;
283298 copy = client;
284299
285
- if (copy.versions == null)
286
- {
287
- copy.versions = new byte[100][];
288
- copy.versionindex = -1;
289
- }
300
+// if (copy.versionlist == null)
301
+// {
302
+// copy.versionlist = new Object3D[100];
303
+// copy.versionindex = -1;
304
+//
305
+// callee.Save(true);
306
+// }
290307
291308 // "this" is not called: SetupUI2(objEditor);
292309 }
....@@ -301,10 +318,12 @@
301318 client = inClient;
302319 copy = client;
303320
304
- if (copy.versions == null)
321
+ if (copy.versionlist == null)
305322 {
306
- copy.versions = new byte[100][];
323
+ copy.versionlist = new Object3D[100];
307324 copy.versionindex = -1;
325
+
326
+// Save(true);
308327 }
309328
310329 SetupUI2(callee.GetEditor());
....@@ -339,11 +358,13 @@
339358 copy = localCopy;
340359 copy.editWindow = this;
341360
342
- if (copy.versions == null)
343
- {
344
- copy.versions = new byte[100][];
345
- copy.versionindex = -1;
346
- }
361
+// if (copy.versionlist == null)
362
+// {
363
+// copy.versionlist = new Object3D[100];
364
+// copy.versionindex = -1;
365
+//
366
+// Save(true);
367
+// }
347368
348369 SetupMenu();
349370
....@@ -412,6 +433,8 @@
412433
413434 ChangeListener changeListener = new ChangeListener()
414435 {
436
+ String name;
437
+
415438 public void stateChanged(ChangeEvent changeEvent)
416439 {
417440 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -430,18 +453,48 @@
430453 // EditSelection(false);
431454 // }
432455
433
- refreshContents(false); // To refresh Info tab
456
+ if (objectPanel.getSelectedIndex() == 4)
457
+ {
458
+ name = copy.skyboxname;
459
+
460
+ if (name == null)
461
+ {
462
+ name = "";
463
+ }
464
+
465
+ copy.skyboxname = "cubemaps/default-skyboxes/rgb";
466
+ copy.skyboxext = "jpg";
467
+ }
468
+ else
469
+ {
470
+ if (name != null)
471
+ {
472
+ if (name.equals(""))
473
+ {
474
+ copy.skyboxname = null;
475
+ copy.skyboxext = null;
476
+ }
477
+ else
478
+ {
479
+ copy.skyboxname = name;
480
+ }
481
+ }
482
+ }
483
+
484
+// refreshContents(false); // To refresh Info tab
485
+ cameraView.repaint();
434486 }
435487 };
436488 objectPanel.addChangeListener(changeListener);
437489
438490 toolbarPanel = new JPanel();
439491 toolbarPanel.setName("Toolbar");
492
+
440493 treePanel = new cGridBag();
441494 treePanel.setName("Tree");
442495
443496 editPanel = new cGridBag().setVertical(true);
444
- editPanel.setName("Edit");
497
+ //editPanel.setName("Edit");
445498
446499 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
447500
....@@ -449,11 +502,13 @@
449502 editPanel.add(editCommandsPanel);
450503 editPanel.add(ctrlPanel);
451504
452
- toolboxPanel = new cGridBag().setVertical(false);
453
- toolboxPanel.setName("Toolbox");
505
+ toolboxPanel = new cGridBag().setVertical(true);
506
+ //toolboxPanel.setName("Toolbox");
454507
455
- materialPanel = new cGridBag().setVertical(true);
456
- materialPanel.setName("Material");
508
+ skyboxPanel = new cGridBag().setVertical(true);
509
+
510
+ materialPanel = new cGridBag().setVertical(false);
511
+ //materialPanel.setName("Material");
457512
458513 /*JTextPane*/
459514 infoarea = createTextPane();
....@@ -461,6 +516,7 @@
461516
462517 infoarea.setEditable(true);
463518 SetText();
519
+
464520 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
465521 // infoarea.setOpaque(false);
466522 // //infoarea.setForeground(textcolor);
....@@ -468,7 +524,7 @@
468524 // TEXTAREA infoarea.setWrapStyleWord(true);
469525 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
470526 infoPanel.setPreferredSize(new Dimension(1, 1));
471
- infoPanel.setName("Info");
527
+ //infoPanel.setName("Info");
472528 //infoPanel.setLayout(new BorderLayout());
473529 //infoPanel.add(createTextPane());
474530
....@@ -735,6 +791,7 @@
735791 boolean maximized;
736792
737793 cButton fullscreenLayout;
794
+ cButton expandedLayout;
738795
739796 void Minimize()
740797 {
....@@ -774,10 +831,12 @@
774831 cButton minButton;
775832 cButton maxButton;
776833 cButton fullButton;
834
+ cButton collapseButton;
835
+ cButton maximize3DButton;
777836
778837 void ToggleFullScreen()
779838 {
780
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
839
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781840
782841 cameraView.ToggleFullScreen();
783842
....@@ -798,13 +857,13 @@
798857 // X frame.getContentPane().remove(/*"Center",*/bigThree);
799858 // X framePanel.add(bigThree);
800859 // X frame.getContentPane().add(/*"Center",*/framePanel);
801
- framePanel.setDividerLocation(46);
860
+// framePanel.setDividerLocation(46); // icons are 24x24
802861
803862 //frame.setVisible(true);
804
- radio.layout = keepButton;
863
+// radio.layout = keepButton;
805864 //theFrame = null;
806865 keepButton = null;
807
- radio.layout.doClick();
866
+// radio.layout.doClick();
808867
809868 } else
810869 {
....@@ -825,31 +884,42 @@
825884 // X frame.getContentPane().remove(/*"Center",*/framePanel);
826885 // X framePanel.remove(bigThree);
827886 // X frame.getContentPane().add(/*"Center",*/bigThree);
828
- framePanel.setDividerLocation(0);
887
+// framePanel.setDividerLocation(0);
829888
830
- radio.layout = fullscreenLayout;
831
- radio.layout.doClick();
889
+// radio.layout = fullscreenLayout;
890
+// radio.layout.doClick();
832891 //frame.setVisible(true);
833892 }
834893 frame.validate();
894
+
895
+ cameraView.requestFocusInWindow();
835896 }
836897
837
- private byte[] CompressCopy()
898
+ void CollapseToolbar()
899
+ {
900
+ framePanel.setDividerLocation(0);
901
+ //frame.validate();
902
+
903
+ cameraView.requestFocusInWindow();
904
+ }
905
+
906
+ private Object3D Duplicate(Object3D object)
838907 {
839908 boolean temp = CameraPane.SWITCH;
840909 CameraPane.SWITCH = false;
841910
842
- copy.ExtractBigData(versiontable);
911
+ object.ExtractBigData(versiontable);
843912 // if (copy == client)
844913
845
- byte[] versions[] = copy.versions;
846
- copy.versions = null;
914
+ Object3D versions[] = object.versionlist;
915
+ object.versionlist = null;
847916
848
- byte[] compress = Compress(copy);
917
+ //byte[] compress = Compress(copy);
918
+ Object3D compress = (Object3D)Grafreed.clone(object);
849919
850
- copy.versions = versions;
920
+ object.versionlist = versions;
851921
852
- copy.RestoreBigData(versiontable);
922
+ object.RestoreBigData(versiontable);
853923
854924 CameraPane.SWITCH = temp;
855925
....@@ -977,6 +1047,7 @@
9771047 {
9781048 SetupMaterial(materialPanel);
9791049 }
1050
+
9801051 //SetupName();
9811052 //SetupViews();
9821053 }
....@@ -986,7 +1057,7 @@
9861057 // NumberSlider vDivsField;
9871058 // JCheckBox endcaps;
9881059 JCheckBox liveCB;
989
- JCheckBox selectCB;
1060
+ JCheckBox selectableCB;
9901061 JCheckBox hideCB;
9911062 JCheckBox link2masterCB;
9921063 JCheckBox markCB;
....@@ -1185,6 +1256,18 @@
11851256
11861257 namePanel = new cGridBag();
11871258
1259
+ //if (copy.pinned)
1260
+ {
1261
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1262
+ pinButton.setSelected(copy.pinned);
1263
+ cGridBag t = new cGridBag();
1264
+ t.preferredWidth = 2;
1265
+ t.add(pinButton);
1266
+ namePanel.add(t);
1267
+
1268
+ pinButton.addItemListener(this);
1269
+ }
1270
+
11881271 nameField = AddText(namePanel, copy.GetName());
11891272 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11901273 oe.ctrlPanel.add(namePanel);
....@@ -1198,13 +1281,16 @@
11981281
11991282 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12001283 liveCB.setToolTipText("Animate object");
1201
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1202
- selectCB.setToolTipText("Make object selectable");
1284
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1285
+ selectableCB.setToolTipText("Make object selectable");
12031286 // Return();
1287
+
12041288 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12051289 hideCB.setToolTipText("Hide object");
12061290 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
12071291 markCB.setToolTipText("As animation target transform");
1292
+
1293
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12081294
12091295 setupPanel2 = new cGridBag().setVertical(false);
12101296
....@@ -1492,6 +1578,7 @@
14921578 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14931579 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14941580 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1581
+ //XYZPanel.setName("XYZ");
14951582
14961583 /*
14971584 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1529,17 +1616,29 @@
15291616 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15301617 //tmp.setName("Edit");
15311618 objectPanel.add(materialPanel);
1619
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1620
+ objectPanel.setToolTipTextAt(0, "Material");
1621
+
1622
+ objectPanel.add(toolboxPanel);
1623
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1624
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1625
+
1626
+ objectPanel.add(skyboxPanel);
1627
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1628
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1629
+
15321630 // JPanel north = new JPanel(new BorderLayout());
15331631 // north.setName("Edit");
15341632 // north.add(ctrlPanel, BorderLayout.NORTH);
15351633 // objectPanel.add(north);
15361634 objectPanel.add(editPanel);
1635
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1636
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15371637
1538
- //if (Globals.ADVANCED)
1539
- objectPanel.add(infoPanel);
1638
+ objectPanel.add(XYZPanel);
1639
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1640
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15401641
1541
- objectPanel.add(toolboxPanel);
1542
-
15431642 /*
15441643 aConstraints.gridx = 0;
15451644 aConstraints.gridwidth = 1;
....@@ -1559,7 +1658,7 @@
15591658 scrollpane.addMouseWheelListener(this); // Default not fast enough
15601659
15611660 /*JTabbedPane*/ scenePanel = new cGridBag();
1562
- scenePanel.preferredWidth = 6;
1661
+ scenePanel.preferredWidth = 5;
15631662
15641663 JTabbedPane tabbedPane = new JTabbedPane();
15651664 tabbedPane.add(scrollpane);
....@@ -1576,6 +1675,11 @@
15761675
15771676 scenePanel.add(tabbedPane);
15781677
1678
+ //if (Globals.ADVANCED)
1679
+ tabbedPane.add(infoPanel);
1680
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1681
+ tabbedPane.setToolTipTextAt(3, "Information");
1682
+
15791683 /*
15801684 cTree jTree = new cTree(null);
15811685 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1637,7 +1741,7 @@
16371741 bigThree = new cGridBag();
16381742 bigThree.addComponent(scenePanel);
16391743 bigThree.addComponent(centralPanel);
1640
- bigThree.addComponent(XYZPanel);
1744
+ //bigThree.addComponent(XYZPanel);
16411745
16421746 // // SIDE EFFECT!!!
16431747 // aConstraints.gridx = 0;
....@@ -1646,6 +1750,23 @@
16461750 // aConstraints.gridheight = 1;
16471751
16481752 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1753
+
1754
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1755
+ new java.beans.PropertyChangeListener()
1756
+ {
1757
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1758
+ {
1759
+ if ((Integer)pce.getOldValue() == 1)
1760
+ {
1761
+ if (radio.layout != expandedLayout)
1762
+ {
1763
+ radio.layout = expandedLayout;
1764
+ radio.layout.doClick();
1765
+ }
1766
+ }
1767
+ }
1768
+ });
1769
+
16491770 framePanel.setContinuousLayout(false);
16501771 framePanel.setOneTouchExpandable(false);
16511772 //.setDividerLocation(0.8);
....@@ -1678,7 +1799,6 @@
16781799 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16791800 frame.addWindowListener(new WindowAdapter()
16801801 {
1681
-
16821802 public void windowClosing(WindowEvent e)
16831803 {
16841804 Close();
....@@ -1701,12 +1821,403 @@
17011821 ctrlPanel.removeAll();
17021822 }
17031823
1704
- void SetupMaterial(cGridBag panel)
1824
+ void SetupMaterial(cGridBag materialpanel)
17051825 {
1706
- /*
1826
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1827
+
1828
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1829
+ skin.setToolTipText("Skin");
1830
+ skin.addMouseListener(new MouseAdapter()
1831
+ {
1832
+ public void mouseClicked(MouseEvent e)
1833
+ {
1834
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1835
+ cMaterial material = object.material;
1836
+
1837
+ // Skin
1838
+ colorField.setFloat(material.color);
1839
+ saturationField.setFloat(material.modulation);
1840
+ subsurfaceField.setFloat(material.subsurface);
1841
+ selfshadowField.setFloat(material.diffuseness);
1842
+ diffusenessField.setFloat(material.factor);
1843
+ shininessField.setFloat(material.shininess);
1844
+ shadowbiasField.setFloat(material.shadowbias);
1845
+ diffuseField.setFloat(material.diffuse);
1846
+ specularField.setFloat(material.specular);
1847
+
1848
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1849
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1850
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1851
+
1852
+ materialtouched = true;
1853
+ applySelf();
1854
+ }
1855
+ });
1856
+ presetpanel.add(skin);
1857
+
1858
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1859
+ lambert.setToolTipText("Diffuse");
1860
+ lambert.addMouseListener(new MouseAdapter()
1861
+ {
1862
+ public void mouseClicked(MouseEvent e)
1863
+ {
1864
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1865
+ cMaterial material = object.material;
1866
+
1867
+ diffusenessField.setFloat(material.factor);
1868
+ selfshadowField.setFloat(material.diffuseness);
1869
+
1870
+ materialtouched = true;
1871
+ applySelf();
1872
+ }
1873
+ });
1874
+ presetpanel.add(lambert);
1875
+
1876
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1877
+ diffuse2.setToolTipText("Diffuse2");
1878
+ diffuse2.addMouseListener(new MouseAdapter()
1879
+ {
1880
+ public void mouseClicked(MouseEvent e)
1881
+ {
1882
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1883
+ cMaterial material = object.material;
1884
+
1885
+ diffusenessField.setFloat(material.factor);
1886
+ selfshadowField.setFloat(material.diffuseness);
1887
+
1888
+ materialtouched = true;
1889
+ applySelf();
1890
+ }
1891
+ });
1892
+ presetpanel.add(diffuse2);
1893
+
1894
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1895
+ diffusemoon.setToolTipText("Moon");
1896
+ diffusemoon.addMouseListener(new MouseAdapter()
1897
+ {
1898
+ public void mouseClicked(MouseEvent e)
1899
+ {
1900
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1901
+ cMaterial material = object.material;
1902
+
1903
+ diffusenessField.setFloat(material.factor);
1904
+ selfshadowField.setFloat(material.diffuseness);
1905
+
1906
+ materialtouched = true;
1907
+ applySelf();
1908
+ }
1909
+ });
1910
+ presetpanel.add(diffusemoon);
1911
+
1912
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1913
+ diffusemoon2.setToolTipText("Moon2");
1914
+ diffusemoon2.addMouseListener(new MouseAdapter()
1915
+ {
1916
+ public void mouseClicked(MouseEvent e)
1917
+ {
1918
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1919
+ cMaterial material = object.material;
1920
+
1921
+ diffusenessField.setFloat(material.factor);
1922
+ selfshadowField.setFloat(material.diffuseness);
1923
+
1924
+ materialtouched = true;
1925
+ applySelf();
1926
+ }
1927
+ });
1928
+ presetpanel.add(diffusemoon2);
1929
+
1930
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1931
+ diffusemoon3.setToolTipText("Moon3");
1932
+ diffusemoon3.addMouseListener(new MouseAdapter()
1933
+ {
1934
+ public void mouseClicked(MouseEvent e)
1935
+ {
1936
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1937
+ cMaterial material = object.material;
1938
+
1939
+ diffusenessField.setFloat(material.factor);
1940
+ selfshadowField.setFloat(material.diffuseness);
1941
+
1942
+ materialtouched = true;
1943
+ applySelf();
1944
+ }
1945
+ });
1946
+ presetpanel.add(diffusemoon3);
1947
+
1948
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1949
+ diffusesheen.setToolTipText("Sheen");
1950
+ diffusesheen.addMouseListener(new MouseAdapter()
1951
+ {
1952
+ public void mouseClicked(MouseEvent e)
1953
+ {
1954
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1955
+ cMaterial material = object.material;
1956
+
1957
+ sheenField.setFloat(material.sheen);
1958
+
1959
+ materialtouched = true;
1960
+ applySelf();
1961
+ }
1962
+ });
1963
+ presetpanel.add(diffusesheen);
1964
+
1965
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1966
+ rough.setToolTipText("Rough metal");
1967
+ rough.addMouseListener(new MouseAdapter()
1968
+ {
1969
+ public void mouseClicked(MouseEvent e)
1970
+ {
1971
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1972
+ cMaterial material = object.material;
1973
+
1974
+ shininessField.setFloat(material.shininess);
1975
+ velvetField.setFloat(material.velvet);
1976
+
1977
+ materialtouched = true;
1978
+ applySelf();
1979
+ }
1980
+ });
1981
+ presetpanel.add(rough);
1982
+
1983
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1984
+ rough2.setToolTipText("Medium metal");
1985
+ rough2.addMouseListener(new MouseAdapter()
1986
+ {
1987
+ public void mouseClicked(MouseEvent e)
1988
+ {
1989
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1990
+ cMaterial material = object.material;
1991
+
1992
+ shininessField.setFloat(material.shininess);
1993
+ lightareaField.setFloat(material.lightarea);
1994
+
1995
+ materialtouched = true;
1996
+ applySelf();
1997
+ }
1998
+ });
1999
+ presetpanel.add(rough2);
2000
+
2001
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2002
+ shini0.setToolTipText("Shiny");
2003
+ shini0.addMouseListener(new MouseAdapter()
2004
+ {
2005
+ public void mouseClicked(MouseEvent e)
2006
+ {
2007
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2008
+ cMaterial material = object.material;
2009
+
2010
+ shininessField.setFloat(material.shininess);
2011
+ lightareaField.setFloat(material.lightarea);
2012
+
2013
+ materialtouched = true;
2014
+ applySelf();
2015
+ }
2016
+ });
2017
+ presetpanel.add(shini0);
2018
+
2019
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2020
+ shini1.setToolTipText("Shiny2");
2021
+ shini1.addMouseListener(new MouseAdapter()
2022
+ {
2023
+ public void mouseClicked(MouseEvent e)
2024
+ {
2025
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2026
+ cMaterial material = object.material;
2027
+
2028
+ shininessField.setFloat(material.shininess);
2029
+ lightareaField.setFloat(material.lightarea);
2030
+
2031
+ materialtouched = true;
2032
+ applySelf();
2033
+ }
2034
+ });
2035
+ presetpanel.add(shini1);
2036
+
2037
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2038
+ shini2.setToolTipText("Shiny3");
2039
+ shini2.addMouseListener(new MouseAdapter()
2040
+ {
2041
+ public void mouseClicked(MouseEvent e)
2042
+ {
2043
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2044
+ cMaterial material = object.material;
2045
+
2046
+ shininessField.setFloat(material.shininess);
2047
+ lightareaField.setFloat(material.lightarea);
2048
+
2049
+ materialtouched = true;
2050
+ applySelf();
2051
+ }
2052
+ });
2053
+ presetpanel.add(shini2);
2054
+
2055
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2056
+ aniso.setToolTipText("AnisoU");
2057
+ aniso.addMouseListener(new MouseAdapter()
2058
+ {
2059
+ public void mouseClicked(MouseEvent e)
2060
+ {
2061
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2062
+ cMaterial material = object.material;
2063
+
2064
+ anisoField.setFloat(material.aniso);
2065
+ anisoVField.setFloat(material.anisoV);
2066
+
2067
+ materialtouched = true;
2068
+ applySelf();
2069
+ }
2070
+ });
2071
+ presetpanel.add(aniso);
2072
+
2073
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2074
+ aniso2.setToolTipText("AnisoV");
2075
+ aniso2.addMouseListener(new MouseAdapter()
2076
+ {
2077
+ public void mouseClicked(MouseEvent e)
2078
+ {
2079
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2080
+ cMaterial material = object.material;
2081
+
2082
+ anisoField.setFloat(material.aniso);
2083
+ anisoVField.setFloat(material.anisoV);
2084
+
2085
+ materialtouched = true;
2086
+ applySelf();
2087
+ }
2088
+ });
2089
+ presetpanel.add(aniso2);
2090
+
2091
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2092
+ aniso3.setToolTipText("AnisoUV");
2093
+ aniso3.addMouseListener(new MouseAdapter()
2094
+ {
2095
+ public void mouseClicked(MouseEvent e)
2096
+ {
2097
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2098
+ cMaterial material = object.material;
2099
+
2100
+ anisoField.setFloat(material.aniso);
2101
+ anisoVField.setFloat(material.anisoV);
2102
+
2103
+ materialtouched = true;
2104
+ applySelf();
2105
+ }
2106
+ });
2107
+ presetpanel.add(aniso3);
2108
+
2109
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2110
+ velvet0.setToolTipText("Velvet");
2111
+ velvet0.addMouseListener(new MouseAdapter()
2112
+ {
2113
+ public void mouseClicked(MouseEvent e)
2114
+ {
2115
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2116
+ cMaterial material = object.material;
2117
+
2118
+ diffusenessField.setFloat(material.factor);
2119
+ selfshadowField.setFloat(material.diffuseness);
2120
+ sheenField.setFloat(material.sheen);
2121
+ shininessField.setFloat(material.shininess);
2122
+ velvetField.setFloat(material.velvet);
2123
+ shiftField.setFloat(material.shift);
2124
+
2125
+ materialtouched = true;
2126
+ applySelf();
2127
+ }
2128
+ });
2129
+ presetpanel.add(velvet0);
2130
+
2131
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2132
+ bump0.setToolTipText("Bump texture");
2133
+ bump0.addMouseListener(new MouseAdapter()
2134
+ {
2135
+ public void mouseClicked(MouseEvent e)
2136
+ {
2137
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2138
+ cMaterial material = object.material;
2139
+
2140
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2141
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2142
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2143
+
2144
+ materialtouched = true;
2145
+ applySelf();
2146
+ }
2147
+ });
2148
+ presetpanel.add(bump0);
2149
+
2150
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2151
+ halo.setToolTipText("Halo");
2152
+ halo.addMouseListener(new MouseAdapter()
2153
+ {
2154
+ public void mouseClicked(MouseEvent e)
2155
+ {
2156
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2157
+ cMaterial material = object.material;
2158
+
2159
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2160
+
2161
+ materialtouched = true;
2162
+ applySelf();
2163
+ }
2164
+ });
2165
+ presetpanel.add(halo);
2166
+
2167
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2168
+ candle.setToolTipText("Candle");
2169
+ candle.addMouseListener(new MouseAdapter()
2170
+ {
2171
+ public void mouseClicked(MouseEvent e)
2172
+ {
2173
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2174
+ cMaterial material = object.material;
2175
+
2176
+ subsurfaceField.setFloat(material.subsurface);
2177
+ shadowbiasField.setFloat(material.shadowbias);
2178
+ ambientField.setFloat(material.ambient);
2179
+ specularField.setFloat(material.specular);
2180
+ lightareaField.setFloat(material.lightarea);
2181
+ shininessField.setFloat(material.shininess);
2182
+
2183
+ materialtouched = true;
2184
+ applySelf();
2185
+ }
2186
+ });
2187
+ presetpanel.add(candle);
2188
+
2189
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2190
+ shadowShader.setToolTipText("Shadow");
2191
+ shadowShader.addMouseListener(new MouseAdapter()
2192
+ {
2193
+ public void mouseClicked(MouseEvent e)
2194
+ {
2195
+ diffuseField.setFloat(0.001);
2196
+ ambientField.setFloat(0.001);
2197
+ cameraField.setFloat(0.001);
2198
+ specularField.setFloat(0.001);
2199
+ fakedepthField.setFloat(0.001);
2200
+ opacityField.setFloat(0.6);
2201
+
2202
+ materialtouched = true;
2203
+ applySelf();
2204
+ }
2205
+ });
2206
+ presetpanel.add(shadowShader);
2207
+
2208
+ cGridBag panel = new cGridBag().setVertical(true);
2209
+
2210
+ presetpanel.preferredWidth = 1;
2211
+
2212
+ materialpanel.add(presetpanel);
2213
+ materialpanel.add(panel);
2214
+
2215
+ panel.preferredWidth = 8;
2216
+
2217
+ /*
17072218 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17082219 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1709
- */
2220
+ */
17102221
17112222 cGridBag editBar = new cGridBag().setVertical(false);
17122223
....@@ -1740,27 +2251,50 @@
17402251 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17412252
17422253 cGridBag colorSection = new cGridBag().setVertical(true);
2254
+
2255
+ cGridBag huepanel = new cGridBag();
2256
+ cGridBag huelabel = new cGridBag();
2257
+ skin = GetLabel("icons/hue.png", false);
2258
+ skin.fit = true;
2259
+ huelabel.add(skin);
2260
+ huelabel.preferredWidth = 20;
2261
+ huepanel.add(new cGridBag()); // Label
2262
+ huepanel.add(huelabel); // Field/slider
2263
+
2264
+ huepanel.preferredHeight = 7;
2265
+
2266
+ colorSection.add(huepanel);
17432267
17442268 cGridBag color = new cGridBag();
1745
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1746
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1747
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2269
+
2270
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2271
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2272
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2273
+
17482274 //colorField.preferredWidth = 200;
17492275 colorSection.add(color);
17502276
17512277 cGridBag modulation = new cGridBag();
17522278 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17532279 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1754
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2280
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17552281 colorSection.add(modulation);
17562282
2283
+ cGridBag opacity = new cGridBag();
2284
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2285
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2286
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2287
+ colorSection.add(opacity);
2288
+
2289
+ colorSection.add(GetSeparator());
2290
+
17572291 cGridBag texture = new cGridBag();
17582292 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17592293 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17602294 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17612295 colorSection.add(texture);
17622296
1763
- panel.add(new JSeparator());
2297
+ panel.add(GetSeparator());
17642298
17652299 panel.add(colorSection);
17662300
....@@ -1816,7 +2350,7 @@
18162350 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18172351 diffuseSection.add(shadowbias);
18182352
1819
- panel.add(new JSeparator());
2353
+ panel.add(GetSeparator());
18202354
18212355 panel.add(diffuseSection);
18222356
....@@ -1879,7 +2413,7 @@
18792413 specularSection.add(anisoV);
18802414
18812415
1882
- panel.add(new JSeparator());
2416
+ panel.add(GetSeparator());
18832417
18842418 panel.add(specularSection);
18852419
....@@ -1904,12 +2438,6 @@
19042438 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19052439 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19062440 colorSection.add(backlit);
1907
-
1908
- cGridBag opacity = new cGridBag();
1909
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1910
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1911
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1912
- colorSection.add(opacity);
19132441
19142442 //panel.add(new JSeparator());
19152443
....@@ -1955,7 +2483,7 @@
19552483 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19562484 textureSection.add(opacityPower);
19572485
1958
- panel.add(new JSeparator());
2486
+ panel.add(GetSeparator());
19592487
19602488 panel.add(textureSection);
19612489
....@@ -2942,7 +3470,7 @@
29423470
29433471 freezematerial = true;
29443472 colorField.setFloat(mat.color);
2945
- modulationField.setFloat(mat.modulation);
3473
+ saturationField.setFloat(mat.modulation);
29463474 metalnessField.setFloat(mat.metalness);
29473475 diffuseField.setFloat(mat.diffuse);
29483476 specularField.setFloat(mat.specular);
....@@ -3149,6 +3677,17 @@
31493677 public void itemStateChanged(ItemEvent event)
31503678 {
31513679 // System.out.println("Propagate = " + propagate);
3680
+ if (event.getSource() == pinButton)
3681
+ {
3682
+ copy.pinned ^= true;
3683
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3684
+ {
3685
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3686
+ copy.CloseUI();
3687
+ //copy.editWindow.refreshContents();
3688
+ }
3689
+ }
3690
+ else
31523691 if (event.getSource() == propagateToggle)
31533692 {
31543693 propagate ^= true;
....@@ -3253,8 +3792,9 @@
32533792 } else if (event.getSource() == liveCB)
32543793 {
32553794 copy.live ^= true;
3795
+ objEditor.refreshContents(true); // To show item colors
32563796 return;
3257
- } else if (event.getSource() == selectCB)
3797
+ } else if (event.getSource() == selectableCB)
32583798 {
32593799 copy.dontselect ^= true;
32603800 return;
....@@ -3262,7 +3802,7 @@
32623802 {
32633803 copy.hide ^= true;
32643804 copy.Touch(); // display list issue
3265
- objEditor.refreshContents();
3805
+ objEditor.refreshContents(true); // To show item colors
32663806 return;
32673807 } else if (event.getSource() == link2masterCB)
32683808 {
....@@ -3518,6 +4058,7 @@
35184058
35194059 static public byte[] Compress(Object3D o)
35204060 {
4061
+ // Slower to actually compress.
35214062 try
35224063 {
35234064 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3619,6 +4160,7 @@
36194160 {
36204161 //Save(true);
36214162 Replace();
4163
+ SetVersionStates();
36224164 }
36234165
36244166 private boolean Equal(byte[] compress, byte[] name)
....@@ -3639,29 +4181,46 @@
36394181
36404182 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36414183
4184
+ void DeleteVersion()
4185
+ {
4186
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4187
+ {
4188
+ copy.versionlist[i] = copy.versionlist[i+1];
4189
+ }
4190
+
4191
+ CopyChanged();
4192
+
4193
+ SetVersionStates();
4194
+ }
4195
+
36424196 public boolean Save(boolean user)
36434197 {
36444198 System.err.println("Save");
4199
+ Replace();
36454200
3646
- cRadio tab = GetCurrentTab();
4201
+ //cRadio tab = GetCurrentTab();
36474202
3648
- byte[] compress = CompressCopy();
4203
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36494204
36504205 boolean thesame = false;
36514206
3652
- // Quick heuristic using length. Works only when stream is compressed.
3653
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3654
- {
3655
- thesame = true;
3656
- }
4207
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4208
+// {
4209
+// thesame = true;
4210
+// }
36574211
36584212 //EditorFrame.m_MainFrame.requestFocusInWindow();
36594213 if (!thesame)
36604214 {
4215
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4216
+ {
4217
+ copy.versionlist[i] = copy.versionlist[i-1];
4218
+ }
4219
+
36614220 //tab.user[tab.versionindex] = user;
36624221 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36634222
3664
- copy.versions[++copy.versionindex] = compress;
4223
+ copy.versionlist[++copy.versionindex] = compress;
36654224
36664225 // if (increment)
36674226 // tab.versionindex++;
....@@ -3671,13 +4230,13 @@
36714230
36724231 //assert(hashtable.isEmpty());
36734232
3674
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3675
- {
3676
- //tab.user[i] = false;
3677
- copy.versions[i] = null;
3678
- }
4233
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4234
+// {
4235
+// //tab.user[i] = false;
4236
+// copy.versionlist[i] = null;
4237
+// }
36794238
3680
- SetUndoStates();
4239
+ SetVersionStates();
36814240
36824241 // test save
36834242 if (false)
....@@ -3700,10 +4259,44 @@
37004259
37014260 return !thesame;
37024261 }
3703
-
3704
- void CopyChanged(Object3D obj)
4262
+
4263
+ boolean flashIt = true;
4264
+
4265
+ void RefreshSelection()
37054266 {
3706
- SetUndoStates();
4267
+ Object3D selection = new Object3D();
4268
+
4269
+ for (int i = 0; i < copy.selection.size(); i++)
4270
+ {
4271
+ Object3D elem = copy.selection.elementAt(i);
4272
+
4273
+ Object3D obj = copy.GetObject(elem.GetUUID());
4274
+
4275
+ if (obj == null)
4276
+ {
4277
+ copy.selection.remove(i--);
4278
+ }
4279
+ else
4280
+ {
4281
+ selection.add(obj);
4282
+ copy.selection.setElementAt(obj, i);
4283
+ }
4284
+ }
4285
+
4286
+ flashIt = false;
4287
+ GetTree().clearSelection();
4288
+ for (int i = 0; i < selection.size(); i++)
4289
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4290
+ flashIt = true;
4291
+
4292
+ //refreshContents(false);
4293
+ }
4294
+
4295
+ void CopyChanged()
4296
+ {
4297
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4298
+
4299
+ SetVersionStates();
37074300
37084301 boolean temp = CameraPane.SWITCH;
37094302 CameraPane.SWITCH = false;
....@@ -3712,6 +4305,9 @@
37124305
37134306 copy.clear();
37144307
4308
+ copy.skyboxname = obj.skyboxname;
4309
+ copy.skyboxext = obj.skyboxext;
4310
+
37154311 for (int i=0; i<obj.Size(); i++)
37164312 {
37174313 copy.add(obj.get(i));
....@@ -3721,6 +4317,7 @@
37214317
37224318 CameraPane.SWITCH = temp;
37234319
4320
+ RefreshSelection();
37244321 //assert(hashtable.isEmpty());
37254322
37264323 copy.Touch();
....@@ -3741,13 +4338,15 @@
37414338 }
37424339 }
37434340
3744
- refreshContents();
4341
+ refreshContents(true);
37454342 }
37464343
3747
- cButton undoButton;
4344
+ cButton previousVersionButton;
37484345 cButton restoreButton;
37494346 cButton replaceButton;
3750
- cButton redoButton;
4347
+ cButton nextVersionButton;
4348
+ cButton saveVersionButton;
4349
+ cButton deleteVersionButton;
37514350
37524351 boolean muteSlider;
37534352
....@@ -3755,39 +4354,47 @@
37554354 {
37564355 int count = 0;
37574356
3758
- for (int i = copy.versions.length; --i >= 0;)
4357
+ for (int i = copy.versionlist.length; --i >= 0;)
37594358 {
3760
- if (copy.versions[i] != null)
4359
+ if (copy.versionlist[i] != null)
37614360 count++;
37624361 }
37634362
37644363 return count;
37654364 }
37664365
3767
- void SetUndoStates()
4366
+ void SetVersionStates()
37684367 {
3769
- cRadio tab = GetCurrentTab();
4368
+ //if (true)
4369
+ // return;
4370
+
4371
+ //cRadio tab = GetCurrentTab();
37704372
37714373 restoreButton.setEnabled(copy.versionindex != -1);
37724374 replaceButton.setEnabled(copy.versionindex != -1);
37734375
3774
- undoButton.setEnabled(copy.versionindex > 0);
3775
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4376
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4377
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4378
+
4379
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4380
+ copy.versionlist[copy.versionindex + 1] != null);
37764381
37774382 muteSlider = true;
4383
+ versionSlider.setMinimum(0);
37784384 versionSlider.setMaximum(VersionCount() - 1);
37794385 versionSlider.setInteger(copy.versionindex);
4386
+ versionSlider.setEnabled(copy.versionindex != -1);
37804387 muteSlider = false;
37814388 }
37824389
3783
- public boolean Undo()
4390
+ public boolean PreviousVersion()
37844391 {
37854392 // Option?
37864393 Replace();
37874394
37884395 System.err.println("Undo");
37894396
3790
- cRadio tab = GetCurrentTab();
4397
+ //cRadio tab = GetCurrentTab();
37914398
37924399 if (copy.versionindex == 0)
37934400 {
....@@ -3810,7 +4417,7 @@
38104417
38114418 copy.versionindex -= 1;
38124419
3813
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4420
+ CopyChanged();
38144421
38154422 return true;
38164423 }
....@@ -3819,15 +4426,16 @@
38194426 {
38204427 System.err.println("Restore");
38214428
3822
- cRadio tab = GetCurrentTab();
4429
+ //cRadio tab = GetCurrentTab();
38234430
3824
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4431
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38254432 {
38264433 java.awt.Toolkit.getDefaultToolkit().beep();
38274434 return false;
38284435 }
38294436
3830
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4437
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4438
+ CopyChanged();
38314439
38324440 return true;
38334441 }
....@@ -3836,27 +4444,27 @@
38364444 {
38374445 System.err.println("Replace");
38384446
3839
- cRadio tab = GetCurrentTab();
4447
+ //cRadio tab = GetCurrentTab();
38404448
3841
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4449
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38424450 {
38434451 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38444452 return false;
38454453 }
38464454
3847
- copy.versions[copy.versionindex] = CompressCopy();
4455
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38484456
38494457 return true;
38504458 }
38514459
3852
- public void Redo()
4460
+ public void NextVersion()
38534461 {
38544462 // Option?
38554463 Replace();
38564464
3857
- cRadio tab = GetCurrentTab();
4465
+ //cRadio tab = GetCurrentTab();
38584466
3859
- if (copy.versions[copy.versionindex + 1] == null)
4467
+ if (copy.versionlist[copy.versionindex + 1] == null)
38604468 {
38614469 java.awt.Toolkit.getDefaultToolkit().beep();
38624470 return;
....@@ -3864,7 +4472,7 @@
38644472
38654473 copy.versionindex += 1;
38664474
3867
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4475
+ CopyChanged();
38684476
38694477 //if (!tab.user[tab.versionindex])
38704478 // tab.graphs[tab.versionindex] = null;
....@@ -4078,7 +4686,7 @@
40784686 //copy.material = new cMaterial(copy.GetMaterial());
40794687
40804688 current.color = (float) colorField.getFloat();
4081
- current.modulation = (float) modulationField.getFloat();
4689
+ current.modulation = (float) saturationField.getFloat();
40824690 current.metalness = (float) metalnessField.getFloat();
40834691 current.diffuse = (float) diffuseField.getFloat();
40844692 current.specular = (float) specularField.getFloat();
....@@ -4111,7 +4719,7 @@
41114719 cMaterial mat = copy.material;
41124720
41134721 colorField.SetToolTipValue((mat.color));
4114
- modulationField.SetToolTipValue((mat.modulation));
4722
+ saturationField.SetToolTipValue((mat.modulation));
41154723 metalnessField.SetToolTipValue((mat.metalness));
41164724 diffuseField.SetToolTipValue((mat.diffuse));
41174725 specularField.SetToolTipValue((mat.specular));
....@@ -4175,9 +4783,10 @@
41754783
41764784 int version = versionSlider.getInteger();
41774785
4178
- if (copy.versions[version] != null)
4786
+ if (version != -1 && copy.versionlist[version] != null)
41794787 {
4180
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4788
+ copy.versionindex = version;
4789
+ CopyChanged();
41814790 }
41824791
41834792 return;
....@@ -4217,6 +4826,12 @@
42174826 {
42184827 //System.out.println("stateChanged = " + this);
42194828 materialtouched = true;
4829
+
4830
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4831
+ {
4832
+ saturationField.setFloat(1);
4833
+ }
4834
+
42204835 applySelf();
42214836 //System.out.println("this = " + this);
42224837 //System.out.println("PARENT = " + parent);
....@@ -4516,6 +5131,7 @@
45165131 {
45175132 if (GetTree() != null)
45185133 {
5134
+ GetTree().revalidate();
45195135 GetTree().repaint();
45205136 }
45215137
....@@ -4524,6 +5140,9 @@
45245140 ctrlPanel.validate(); // ? new
45255141 ctrlPanel.repaint();
45265142 }
5143
+
5144
+ if (previousVersionButton != null && copy.versionlist != null)
5145
+ SetVersionStates();
45275146 }
45285147
45295148 static TweenManager tweenManager = new TweenManager();
....@@ -4772,7 +5391,9 @@
47725391 readobj.ResetDisplayList();
47735392 } catch (Exception e)
47745393 {
4775
- //e.printStackTrace();
5394
+ if (!e.toString().contains("GZIP"))
5395
+ e.printStackTrace();
5396
+
47765397 try
47775398 {
47785399 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4852,6 +5473,8 @@
48525473 {
48535474 //readobj.deepCopySelf(copy);
48545475 copy.clear(); // june 2014
5476
+ copy.skyboxname = readobj.skyboxname;
5477
+ copy.skyboxext = readobj.skyboxext;
48555478 for (int i = 0; i < readobj.size(); i++)
48565479 {
48575480 Object3D child = readobj.get(i); // reserve(i);
....@@ -4892,6 +5515,7 @@
48925515 }
48935516 } catch (ClassCastException e)
48945517 {
5518
+ e.printStackTrace();
48955519 assert (false);
48965520 Composite c = (Composite) copy;
48975521 c.children.clear();
....@@ -4902,13 +5526,16 @@
49025526 c.addChild(csg);
49035527 }
49045528
4905
- copy.versions = readobj.versions;
5529
+ copy.versionlist = readobj.versionlist;
49065530 copy.versionindex = readobj.versionindex;
49075531
4908
- if (copy.versions == null)
5532
+ if (copy.versionlist == null)
49095533 {
4910
- copy.versions = new byte[100][];
5534
+ // Backward compatibility
5535
+ copy.versionlist = new Object3D[100];
49115536 copy.versionindex = -1;
5537
+
5538
+ Save(true);
49125539 }
49135540
49145541 //? SetUndoStates();
....@@ -4923,7 +5550,7 @@
49235550 {
49245551 if (Grafreed.standAlone)
49255552 {
4926
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5553
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49275554 browser.show();
49285555 String filename = browser.getFile();
49295556 if (filename != null && filename.length() > 0)
....@@ -5000,6 +5627,8 @@
50005627
50015628 void save()
50025629 {
5630
+ Replace();
5631
+
50035632 if (lastname == null)
50045633 {
50055634 return;
....@@ -5022,6 +5651,7 @@
50225651 //ps.print(buffer.toString());
50235652 } catch (IOException e)
50245653 {
5654
+ e.printStackTrace();
50255655 }
50265656 }
50275657
....@@ -5241,6 +5871,7 @@
52415871 ButtonGroup buttonGroup;
52425872
52435873 cGridBag toolboxPanel;
5874
+ cGridBag skyboxPanel;
52445875 cGridBag materialPanel;
52455876 cGridBag ctrlPanel;
52465877
....@@ -5314,7 +5945,7 @@
53145945 JLabel colorLabel;
53155946 cNumberSlider colorField;
53165947 JLabel modulationLabel;
5317
- cNumberSlider modulationField;
5948
+ cNumberSlider saturationField;
53185949 JLabel metalnessLabel;
53195950 cNumberSlider metalnessField;
53205951 JLabel diffuseLabel;
....@@ -5345,6 +5976,7 @@
53455976 cNumberSlider anisoField;
53465977 JLabel anisoVLabel;
53475978 cNumberSlider anisoVField;
5979
+
53485980 JLabel cameraLabel;
53495981 cNumberSlider cameraField;
53505982 JLabel selfshadowLabel;
....@@ -5359,6 +5991,7 @@
53595991 cNumberSlider fakedepthField;
53605992 JLabel shadowbiasLabel;
53615993 cNumberSlider shadowbiasField;
5994
+
53625995 JLabel bumpLabel;
53635996 cNumberSlider bumpField;
53645997 JLabel noiseLabel;