Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,11 +42,54 @@
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 cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
4482
4583 cButton GetButton(String name, boolean border)
4684 {
4785 ImageIcon icon = GetIcon(name);
4886 return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
4993 }
5094
5195 cToggleButton GetToggleButton(String name, boolean border)
....@@ -60,26 +104,52 @@
60104 return new cCheckBox(icon, border);
61105 }
62106
63
- private ImageIcon GetIcon(String name)
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
117
+ try
118
+ {
119
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
138
+ }
139
+ catch (Exception e)
140
+ {
141
+ //icons.put(name, null);
142
+ return null;
143
+ }
144
+ }
145
+
146
+ BufferedImage GetImage(String name)
64147 {
65148 try
66149 {
67150 BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
68151
69
- if (image.getWidth() != 24 && image.getHeight() != 24)
70
- {
71
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
72
- Graphics2D g = resized.createGraphics();
73
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
76
- g.dispose();
77
-
78
- image = resized;
79
- }
80
-
81
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
82
- return icon;
152
+ return image;
83153 }
84154 catch (Exception e)
85155 {
....@@ -268,11 +338,13 @@
268338 client = inClient;
269339 copy = client;
270340
271
- if (copy.versions == null)
272
- {
273
- copy.versions = new byte[100][];
274
- copy.versionindex = -1;
275
- }
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
276348
277349 // "this" is not called: SetupUI2(objEditor);
278350 }
....@@ -287,10 +359,12 @@
287359 client = inClient;
288360 copy = client;
289361
290
- if (copy.versions == null)
362
+ if (copy.versionlist == null)
291363 {
292
- copy.versions = new byte[100][];
364
+ copy.versionlist = new Object3D[100];
293365 copy.versionindex = -1;
366
+
367
+// Save(true);
294368 }
295369
296370 SetupUI2(callee.GetEditor());
....@@ -325,11 +399,13 @@
325399 copy = localCopy;
326400 copy.editWindow = this;
327401
328
- if (copy.versions == null)
329
- {
330
- copy.versions = new byte[100][];
331
- copy.versionindex = -1;
332
- }
402
+// if (copy.versionlist == null)
403
+// {
404
+// copy.versionlist = new Object3D[100];
405
+// copy.versionindex = -1;
406
+//
407
+// Save(true);
408
+// }
333409
334410 SetupMenu();
335411
....@@ -398,6 +474,8 @@
398474
399475 ChangeListener changeListener = new ChangeListener()
400476 {
477
+ //String name;
478
+
401479 public void stateChanged(ChangeEvent changeEvent)
402480 {
403481 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -416,7 +494,37 @@
416494 // EditSelection(false);
417495 // }
418496
419
- refreshContents(false); // To refresh Info tab
497
+// if (objectPanel.getSelectedIndex() == 4)
498
+// {
499
+// name = copy.skyboxname;
500
+//
501
+// if (name == null)
502
+// {
503
+// name = "";
504
+// }
505
+//
506
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
507
+// copy.skyboxext = "jpg";
508
+// }
509
+// else
510
+// {
511
+// if (name != null)
512
+// {
513
+// if (name.equals(""))
514
+// {
515
+// copy.skyboxname = null;
516
+// copy.skyboxext = null;
517
+// }
518
+// else
519
+// {
520
+// copy.skyboxname = name;
521
+// }
522
+// }
523
+// }
524
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
525
+
526
+// refreshContents(false); // To refresh Info tab
527
+ cameraView.repaint();
420528 }
421529 };
422530 objectPanel.addChangeListener(changeListener);
....@@ -436,10 +544,12 @@
436544 editPanel.add(editCommandsPanel);
437545 editPanel.add(ctrlPanel);
438546
439
- toolboxPanel = new cGridBag().setVertical(false);
547
+ toolboxPanel = new cGridBag().setVertical(true);
440548 //toolboxPanel.setName("Toolbox");
441549
442
- materialPanel = new cGridBag().setVertical(true);
550
+ skyboxPanel = new cGridBag().setVertical(true);
551
+
552
+ materialPanel = new cGridBag().setVertical(false);
443553 //materialPanel.setName("Material");
444554
445555 /*JTextPane*/
....@@ -723,6 +833,7 @@
723833 boolean maximized;
724834
725835 cButton fullscreenLayout;
836
+ cButton expandedLayout;
726837
727838 void Minimize()
728839 {
....@@ -762,10 +873,12 @@
762873 cButton minButton;
763874 cButton maxButton;
764875 cButton fullButton;
876
+ cButton collapseButton;
877
+ cButton maximize3DButton;
765878
766879 void ToggleFullScreen()
767880 {
768
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
881
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769882
770883 cameraView.ToggleFullScreen();
771884
....@@ -786,13 +899,13 @@
786899 // X frame.getContentPane().remove(/*"Center",*/bigThree);
787900 // X framePanel.add(bigThree);
788901 // X frame.getContentPane().add(/*"Center",*/framePanel);
789
- framePanel.setDividerLocation(46);
902
+// framePanel.setDividerLocation(46); // icons are 24x24
790903
791904 //frame.setVisible(true);
792
- radio.layout = keepButton;
905
+// radio.layout = keepButton;
793906 //theFrame = null;
794907 keepButton = null;
795
- radio.layout.doClick();
908
+// radio.layout.doClick();
796909
797910 } else
798911 {
....@@ -813,31 +926,42 @@
813926 // X frame.getContentPane().remove(/*"Center",*/framePanel);
814927 // X framePanel.remove(bigThree);
815928 // X frame.getContentPane().add(/*"Center",*/bigThree);
816
- framePanel.setDividerLocation(0);
929
+// framePanel.setDividerLocation(0);
817930
818
- radio.layout = fullscreenLayout;
819
- radio.layout.doClick();
931
+// radio.layout = fullscreenLayout;
932
+// radio.layout.doClick();
820933 //frame.setVisible(true);
821934 }
822935 frame.validate();
936
+
937
+ cameraView.requestFocusInWindow();
823938 }
824939
825
- private byte[] CompressCopy()
940
+ void CollapseToolbar()
941
+ {
942
+ framePanel.setDividerLocation(0);
943
+ //frame.validate();
944
+
945
+ cameraView.requestFocusInWindow();
946
+ }
947
+
948
+ private Object3D Duplicate(Object3D object)
826949 {
827950 boolean temp = CameraPane.SWITCH;
828951 CameraPane.SWITCH = false;
829952
830
- copy.ExtractBigData(versiontable);
953
+ object.ExtractBigData(versiontable);
831954 // if (copy == client)
832955
833
- byte[] versions[] = copy.versions;
834
- copy.versions = null;
956
+ Object3D versions[] = object.versionlist;
957
+ object.versionlist = null;
835958
836
- byte[] compress = Compress(copy);
959
+ //byte[] compress = Compress(copy);
960
+ Object3D compress = (Object3D)Grafreed.clone(object);
837961
838
- copy.versions = versions;
962
+ object.versionlist = versions;
839963
840
- copy.RestoreBigData(versiontable);
964
+ object.RestoreBigData(versiontable);
841965
842966 CameraPane.SWITCH = temp;
843967
....@@ -965,6 +1089,7 @@
9651089 {
9661090 SetupMaterial(materialPanel);
9671091 }
1092
+
9681093 //SetupName();
9691094 //SetupViews();
9701095 }
....@@ -974,7 +1099,7 @@
9741099 // NumberSlider vDivsField;
9751100 // JCheckBox endcaps;
9761101 JCheckBox liveCB;
977
- JCheckBox selectCB;
1102
+ JCheckBox selectableCB;
9781103 JCheckBox hideCB;
9791104 JCheckBox link2masterCB;
9801105 JCheckBox markCB;
....@@ -1173,6 +1298,18 @@
11731298
11741299 namePanel = new cGridBag();
11751300
1301
+ //if (copy.pinned)
1302
+ {
1303
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1304
+ pinButton.setSelected(copy.pinned);
1305
+ cGridBag t = new cGridBag();
1306
+ t.preferredWidth = 2;
1307
+ t.add(pinButton);
1308
+ namePanel.add(t);
1309
+
1310
+ pinButton.addItemListener(this);
1311
+ }
1312
+
11761313 nameField = AddText(namePanel, copy.GetName());
11771314 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11781315 oe.ctrlPanel.add(namePanel);
....@@ -1186,13 +1323,16 @@
11861323
11871324 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11881325 liveCB.setToolTipText("Animate object");
1189
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
- selectCB.setToolTipText("Make object selectable");
1326
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1327
+ selectableCB.setToolTipText("Make object selectable");
11911328 // Return();
1329
+
11921330 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11931331 hideCB.setToolTipText("Hide object");
11941332 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11951333 markCB.setToolTipText("As animation target transform");
1334
+
1335
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11961336
11971337 setupPanel2 = new cGridBag().setVertical(false);
11981338
....@@ -1519,23 +1659,28 @@
15191659 //tmp.setName("Edit");
15201660 objectPanel.add(materialPanel);
15211661 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1662
+ objectPanel.setToolTipTextAt(0, "Material");
1663
+
1664
+ objectPanel.add(toolboxPanel);
1665
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1666
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1667
+
1668
+ objectPanel.add(skyboxPanel);
1669
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1670
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1671
+
15221672 // JPanel north = new JPanel(new BorderLayout());
15231673 // north.setName("Edit");
15241674 // north.add(ctrlPanel, BorderLayout.NORTH);
15251675 // objectPanel.add(north);
15261676 objectPanel.add(editPanel);
1527
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1528
-
1529
- //if (Globals.ADVANCED)
1530
- objectPanel.add(infoPanel);
1531
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1677
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1678
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15321679
15331680 objectPanel.add(XYZPanel);
1534
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1681
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1682
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15351683
1536
- objectPanel.add(toolboxPanel);
1537
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1538
-
15391684 /*
15401685 aConstraints.gridx = 0;
15411686 aConstraints.gridwidth = 1;
....@@ -1572,6 +1717,11 @@
15721717
15731718 scenePanel.add(tabbedPane);
15741719
1720
+ //if (Globals.ADVANCED)
1721
+// tabbedPane.add(infoPanel);
1722
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1723
+// tabbedPane.setToolTipTextAt(3, "Information");
1724
+
15751725 /*
15761726 cTree jTree = new cTree(null);
15771727 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1642,6 +1792,23 @@
16421792 // aConstraints.gridheight = 1;
16431793
16441794 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1795
+
1796
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1797
+ new java.beans.PropertyChangeListener()
1798
+ {
1799
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1800
+ {
1801
+ if ((Integer)pce.getOldValue() == 1)
1802
+ {
1803
+ if (radio.layout != expandedLayout)
1804
+ {
1805
+ radio.layout = expandedLayout;
1806
+ radio.layout.doClick();
1807
+ }
1808
+ }
1809
+ }
1810
+ });
1811
+
16451812 framePanel.setContinuousLayout(false);
16461813 framePanel.setOneTouchExpandable(false);
16471814 //.setDividerLocation(0.8);
....@@ -1651,7 +1818,7 @@
16511818
16521819 frame.getContentPane().setLayout(new BorderLayout());
16531820 /**/
1654
- JTabbedPane worldPane = new JTabbedPane();
1821
+ //JTabbedPane worldPane = new JTabbedPane();
16551822 //worldPane.add(bigPanel);
16561823 //worldPane.add(worldPanel);
16571824 /**/
....@@ -1674,7 +1841,6 @@
16741841 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16751842 frame.addWindowListener(new WindowAdapter()
16761843 {
1677
-
16781844 public void windowClosing(WindowEvent e)
16791845 {
16801846 Close();
....@@ -1697,12 +1863,418 @@
16971863 ctrlPanel.removeAll();
16981864 }
16991865
1700
- void SetupMaterial(cGridBag panel)
1866
+ void SetupMaterial(cGridBag materialpanel)
17011867 {
1702
- /*
1868
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1869
+
1870
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1871
+ skin.setToolTipText("Skin");
1872
+ skin.addMouseListener(new MouseAdapter()
1873
+ {
1874
+ public void mouseClicked(MouseEvent e)
1875
+ {
1876
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1877
+ cMaterial material = object.material;
1878
+
1879
+ // Skin
1880
+ colorField.setFloat(material.color);
1881
+ saturationField.setFloat(material.modulation);
1882
+ subsurfaceField.setFloat(material.subsurface);
1883
+ selfshadowField.setFloat(material.diffuseness);
1884
+ diffusenessField.setFloat(material.factor);
1885
+ shininessField.setFloat(material.shininess);
1886
+ shadowbiasField.setFloat(material.shadowbias);
1887
+ diffuseField.setFloat(material.diffuse);
1888
+ specularField.setFloat(material.specular);
1889
+
1890
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1891
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1892
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1893
+
1894
+ materialtouched = true;
1895
+ applySelf();
1896
+ }
1897
+ });
1898
+ presetpanel.add(skin);
1899
+
1900
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1901
+ lambert.setToolTipText("Diffuse");
1902
+ lambert.addMouseListener(new MouseAdapter()
1903
+ {
1904
+ public void mouseClicked(MouseEvent e)
1905
+ {
1906
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1907
+ cMaterial material = object.material;
1908
+
1909
+ diffusenessField.setFloat(material.factor);
1910
+ selfshadowField.setFloat(material.diffuseness);
1911
+
1912
+ materialtouched = true;
1913
+ applySelf();
1914
+ }
1915
+ });
1916
+ presetpanel.add(lambert);
1917
+
1918
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1919
+ diffuse2.setToolTipText("Diffuse2");
1920
+ diffuse2.addMouseListener(new MouseAdapter()
1921
+ {
1922
+ public void mouseClicked(MouseEvent e)
1923
+ {
1924
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1925
+ cMaterial material = object.material;
1926
+
1927
+ diffusenessField.setFloat(material.factor);
1928
+ selfshadowField.setFloat(material.diffuseness);
1929
+
1930
+ materialtouched = true;
1931
+ applySelf();
1932
+ }
1933
+ });
1934
+ presetpanel.add(diffuse2);
1935
+
1936
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1937
+ diffusemoon.setToolTipText("Moon");
1938
+ diffusemoon.addMouseListener(new MouseAdapter()
1939
+ {
1940
+ public void mouseClicked(MouseEvent e)
1941
+ {
1942
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1943
+ cMaterial material = object.material;
1944
+
1945
+ diffusenessField.setFloat(material.factor);
1946
+ selfshadowField.setFloat(material.diffuseness);
1947
+
1948
+ materialtouched = true;
1949
+ applySelf();
1950
+ }
1951
+ });
1952
+ presetpanel.add(diffusemoon);
1953
+
1954
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1955
+ diffusemoon2.setToolTipText("Moon2");
1956
+ diffusemoon2.addMouseListener(new MouseAdapter()
1957
+ {
1958
+ public void mouseClicked(MouseEvent e)
1959
+ {
1960
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1961
+ cMaterial material = object.material;
1962
+
1963
+ diffusenessField.setFloat(material.factor);
1964
+ selfshadowField.setFloat(material.diffuseness);
1965
+
1966
+ materialtouched = true;
1967
+ applySelf();
1968
+ }
1969
+ });
1970
+ presetpanel.add(diffusemoon2);
1971
+
1972
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1973
+ diffusemoon3.setToolTipText("Moon3");
1974
+ diffusemoon3.addMouseListener(new MouseAdapter()
1975
+ {
1976
+ public void mouseClicked(MouseEvent e)
1977
+ {
1978
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1979
+ cMaterial material = object.material;
1980
+
1981
+ diffusenessField.setFloat(material.factor);
1982
+ selfshadowField.setFloat(material.diffuseness);
1983
+
1984
+ materialtouched = true;
1985
+ applySelf();
1986
+ }
1987
+ });
1988
+ presetpanel.add(diffusemoon3);
1989
+
1990
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1991
+ diffusesheen.setToolTipText("Sheen");
1992
+ diffusesheen.addMouseListener(new MouseAdapter()
1993
+ {
1994
+ public void mouseClicked(MouseEvent e)
1995
+ {
1996
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1997
+ cMaterial material = object.material;
1998
+
1999
+ sheenField.setFloat(material.sheen);
2000
+
2001
+ materialtouched = true;
2002
+ applySelf();
2003
+ }
2004
+ });
2005
+ presetpanel.add(diffusesheen);
2006
+
2007
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2008
+ rough.setToolTipText("Rough metal");
2009
+ rough.addMouseListener(new MouseAdapter()
2010
+ {
2011
+ public void mouseClicked(MouseEvent e)
2012
+ {
2013
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2014
+ cMaterial material = object.material;
2015
+
2016
+ shininessField.setFloat(material.shininess);
2017
+ velvetField.setFloat(material.velvet);
2018
+
2019
+ materialtouched = true;
2020
+ applySelf();
2021
+ }
2022
+ });
2023
+ presetpanel.add(rough);
2024
+
2025
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2026
+ rough2.setToolTipText("Medium metal");
2027
+ rough2.addMouseListener(new MouseAdapter()
2028
+ {
2029
+ public void mouseClicked(MouseEvent e)
2030
+ {
2031
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2032
+ cMaterial material = object.material;
2033
+
2034
+ shininessField.setFloat(material.shininess);
2035
+ lightareaField.setFloat(material.lightarea);
2036
+
2037
+ materialtouched = true;
2038
+ applySelf();
2039
+ }
2040
+ });
2041
+ presetpanel.add(rough2);
2042
+
2043
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2044
+ shini0.setToolTipText("Shiny");
2045
+ shini0.addMouseListener(new MouseAdapter()
2046
+ {
2047
+ public void mouseClicked(MouseEvent e)
2048
+ {
2049
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2050
+ cMaterial material = object.material;
2051
+
2052
+ shininessField.setFloat(material.shininess);
2053
+ lightareaField.setFloat(material.lightarea);
2054
+
2055
+ materialtouched = true;
2056
+ applySelf();
2057
+ }
2058
+ });
2059
+ presetpanel.add(shini0);
2060
+
2061
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2062
+ shini1.setToolTipText("Shiny2");
2063
+ shini1.addMouseListener(new MouseAdapter()
2064
+ {
2065
+ public void mouseClicked(MouseEvent e)
2066
+ {
2067
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2068
+ cMaterial material = object.material;
2069
+
2070
+ shininessField.setFloat(material.shininess);
2071
+ lightareaField.setFloat(material.lightarea);
2072
+
2073
+ materialtouched = true;
2074
+ applySelf();
2075
+ }
2076
+ });
2077
+ presetpanel.add(shini1);
2078
+
2079
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2080
+ shini2.setToolTipText("Shiny3");
2081
+ shini2.addMouseListener(new MouseAdapter()
2082
+ {
2083
+ public void mouseClicked(MouseEvent e)
2084
+ {
2085
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2086
+ cMaterial material = object.material;
2087
+
2088
+ shininessField.setFloat(material.shininess);
2089
+ lightareaField.setFloat(material.lightarea);
2090
+
2091
+ materialtouched = true;
2092
+ applySelf();
2093
+ }
2094
+ });
2095
+ presetpanel.add(shini2);
2096
+
2097
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2098
+ aniso.setToolTipText("AnisoU");
2099
+ aniso.addMouseListener(new MouseAdapter()
2100
+ {
2101
+ public void mouseClicked(MouseEvent e)
2102
+ {
2103
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2104
+ cMaterial material = object.material;
2105
+
2106
+ anisoField.setFloat(material.aniso);
2107
+ anisoVField.setFloat(material.anisoV);
2108
+
2109
+ materialtouched = true;
2110
+ applySelf();
2111
+ }
2112
+ });
2113
+ presetpanel.add(aniso);
2114
+
2115
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2116
+ aniso2.setToolTipText("AnisoV");
2117
+ aniso2.addMouseListener(new MouseAdapter()
2118
+ {
2119
+ public void mouseClicked(MouseEvent e)
2120
+ {
2121
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2122
+ cMaterial material = object.material;
2123
+
2124
+ anisoField.setFloat(material.aniso);
2125
+ anisoVField.setFloat(material.anisoV);
2126
+
2127
+ materialtouched = true;
2128
+ applySelf();
2129
+ }
2130
+ });
2131
+ presetpanel.add(aniso2);
2132
+
2133
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2134
+ aniso3.setToolTipText("AnisoUV");
2135
+ aniso3.addMouseListener(new MouseAdapter()
2136
+ {
2137
+ public void mouseClicked(MouseEvent e)
2138
+ {
2139
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2140
+ cMaterial material = object.material;
2141
+
2142
+ anisoField.setFloat(material.aniso);
2143
+ anisoVField.setFloat(material.anisoV);
2144
+
2145
+ materialtouched = true;
2146
+ applySelf();
2147
+ }
2148
+ });
2149
+ presetpanel.add(aniso3);
2150
+
2151
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2152
+ velvet0.setToolTipText("Velvet");
2153
+ velvet0.addMouseListener(new MouseAdapter()
2154
+ {
2155
+ public void mouseClicked(MouseEvent e)
2156
+ {
2157
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2158
+ cMaterial material = object.material;
2159
+
2160
+ diffusenessField.setFloat(material.factor);
2161
+ selfshadowField.setFloat(material.diffuseness);
2162
+ sheenField.setFloat(material.sheen);
2163
+ shininessField.setFloat(material.shininess);
2164
+ velvetField.setFloat(material.velvet);
2165
+ shiftField.setFloat(material.shift);
2166
+
2167
+ materialtouched = true;
2168
+ applySelf();
2169
+ }
2170
+ });
2171
+ presetpanel.add(velvet0);
2172
+
2173
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2174
+ bump0.setToolTipText("Bump texture");
2175
+ bump0.addMouseListener(new MouseAdapter()
2176
+ {
2177
+ public void mouseClicked(MouseEvent e)
2178
+ {
2179
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2180
+ cMaterial material = object.material;
2181
+
2182
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2183
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2184
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2185
+
2186
+ materialtouched = true;
2187
+ applySelf();
2188
+ }
2189
+ });
2190
+ presetpanel.add(bump0);
2191
+
2192
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2193
+ borderShader.setToolTipText("Border fade");
2194
+ borderShader.addMouseListener(new MouseAdapter()
2195
+ {
2196
+ public void mouseClicked(MouseEvent e)
2197
+ {
2198
+ borderfadeField.setFloat(0.5);
2199
+ opacityField.setFloat(0.6);
2200
+
2201
+ materialtouched = true;
2202
+ applySelf();
2203
+ }
2204
+ });
2205
+ presetpanel.add(borderShader);
2206
+
2207
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2208
+ halo.setToolTipText("Halo");
2209
+ halo.addMouseListener(new MouseAdapter()
2210
+ {
2211
+ public void mouseClicked(MouseEvent e)
2212
+ {
2213
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2214
+ cMaterial material = object.material;
2215
+
2216
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2217
+
2218
+ materialtouched = true;
2219
+ applySelf();
2220
+ }
2221
+ });
2222
+ presetpanel.add(halo);
2223
+
2224
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2225
+ candle.setToolTipText("Candle");
2226
+ candle.addMouseListener(new MouseAdapter()
2227
+ {
2228
+ public void mouseClicked(MouseEvent e)
2229
+ {
2230
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2231
+ cMaterial material = object.material;
2232
+
2233
+ subsurfaceField.setFloat(material.subsurface);
2234
+ shadowbiasField.setFloat(material.shadowbias);
2235
+ ambientField.setFloat(material.ambient);
2236
+ specularField.setFloat(material.specular);
2237
+ lightareaField.setFloat(material.lightarea);
2238
+ shininessField.setFloat(material.shininess);
2239
+
2240
+ materialtouched = true;
2241
+ applySelf();
2242
+ }
2243
+ });
2244
+ presetpanel.add(candle);
2245
+
2246
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2247
+ shadowShader.setToolTipText("Shadow");
2248
+ shadowShader.addMouseListener(new MouseAdapter()
2249
+ {
2250
+ public void mouseClicked(MouseEvent e)
2251
+ {
2252
+ diffuseField.setFloat(0.001);
2253
+ ambientField.setFloat(0.001);
2254
+ cameraField.setFloat(0.001);
2255
+ specularField.setFloat(0.001);
2256
+ fakedepthField.setFloat(0.001);
2257
+ opacityField.setFloat(0.6);
2258
+
2259
+ materialtouched = true;
2260
+ applySelf();
2261
+ }
2262
+ });
2263
+ presetpanel.add(shadowShader);
2264
+
2265
+ cGridBag panel = new cGridBag().setVertical(true);
2266
+
2267
+ presetpanel.preferredWidth = 1;
2268
+
2269
+ materialpanel.add(presetpanel);
2270
+ materialpanel.add(panel);
2271
+
2272
+ panel.preferredWidth = 8;
2273
+
2274
+ /*
17032275 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17042276 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1705
- */
2277
+ */
17062278
17072279 cGridBag editBar = new cGridBag().setVertical(false);
17082280
....@@ -1736,27 +2308,50 @@
17362308 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17372309
17382310 cGridBag colorSection = new cGridBag().setVertical(true);
2311
+
2312
+ cGridBag huepanel = new cGridBag();
2313
+ cGridBag huelabel = new cGridBag();
2314
+ skin = GetLabel("icons/hue.png", false);
2315
+ skin.fit = true;
2316
+ huelabel.add(skin);
2317
+ huelabel.preferredWidth = 20;
2318
+ huepanel.add(new cGridBag()); // Label
2319
+ huepanel.add(huelabel); // Field/slider
2320
+
2321
+ huepanel.preferredHeight = 7;
2322
+
2323
+ colorSection.add(huepanel);
17392324
17402325 cGridBag color = new cGridBag();
1741
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1742
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1743
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2326
+
2327
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2328
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2329
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2330
+
17442331 //colorField.preferredWidth = 200;
17452332 colorSection.add(color);
17462333
17472334 cGridBag modulation = new cGridBag();
17482335 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17492336 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1750
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2337
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17512338 colorSection.add(modulation);
17522339
2340
+ cGridBag opacity = new cGridBag();
2341
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2342
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2343
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2344
+ colorSection.add(opacity);
2345
+
2346
+ colorSection.add(GetSeparator());
2347
+
17532348 cGridBag texture = new cGridBag();
17542349 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17552350 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17562351 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17572352 colorSection.add(texture);
17582353
1759
- panel.add(new JSeparator());
2354
+ panel.add(GetSeparator());
17602355
17612356 panel.add(colorSection);
17622357
....@@ -1812,7 +2407,7 @@
18122407 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18132408 diffuseSection.add(shadowbias);
18142409
1815
- panel.add(new JSeparator());
2410
+ panel.add(GetSeparator());
18162411
18172412 panel.add(diffuseSection);
18182413
....@@ -1875,7 +2470,7 @@
18752470 specularSection.add(anisoV);
18762471
18772472
1878
- panel.add(new JSeparator());
2473
+ panel.add(GetSeparator());
18792474
18802475 panel.add(specularSection);
18812476
....@@ -1900,12 +2495,6 @@
19002495 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19012496 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19022497 colorSection.add(backlit);
1903
-
1904
- cGridBag opacity = new cGridBag();
1905
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1906
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1907
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1908
- colorSection.add(opacity);
19092498
19102499 //panel.add(new JSeparator());
19112500
....@@ -1951,7 +2540,7 @@
19512540 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19522541 textureSection.add(opacityPower);
19532542
1954
- panel.add(new JSeparator());
2543
+ panel.add(GetSeparator());
19552544
19562545 panel.add(textureSection);
19572546
....@@ -2938,7 +3527,7 @@
29383527
29393528 freezematerial = true;
29403529 colorField.setFloat(mat.color);
2941
- modulationField.setFloat(mat.modulation);
3530
+ saturationField.setFloat(mat.modulation);
29423531 metalnessField.setFloat(mat.metalness);
29433532 diffuseField.setFloat(mat.diffuse);
29443533 specularField.setFloat(mat.specular);
....@@ -3000,32 +3589,8 @@
30003589
30013590 if (multiplyToggle != null)
30023591 multiplyToggle.setSelected(mat.multiply);
3003
-
3004
- assert (object.projectedVertices != null);
3005
-
3006
- if (object.projectedVertices.length <= 2)
3007
- {
3008
- // Side effect...
3009
- Object3D.cVector2[] keep = object.projectedVertices;
3010
- object.projectedVertices = new Object3D.cVector2[3];
3011
- for (int i = 0; i < 3; i++)
3012
- {
3013
- if (i < keep.length)
3014
- {
3015
- object.projectedVertices[i] = keep[i];
3016
- } else
3017
- {
3018
- object.projectedVertices[i] = new Object3D.cVector2();
3019
- }
3020
- /*
3021
- if(keep.length == 0)
3022
- object.projectedVertices[0] = new Object3D.cVector2();
3023
- else
3024
- object.projectedVertices[0] = keep[0];
3025
- object.projectedVertices[1] = new Object3D.cVector2();
3026
- */
3027
- }
3028
- }
3592
+
3593
+ AllocProjectedVertices(object);
30293594
30303595 SetMaterial(mat, object.projectedVertices);
30313596 }
....@@ -3145,6 +3710,17 @@
31453710 public void itemStateChanged(ItemEvent event)
31463711 {
31473712 // System.out.println("Propagate = " + propagate);
3713
+ if (event.getSource() == pinButton)
3714
+ {
3715
+ copy.pinned ^= true;
3716
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3717
+ {
3718
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3719
+ copy.CloseUI();
3720
+ //copy.editWindow.refreshContents();
3721
+ }
3722
+ }
3723
+ else
31483724 if (event.getSource() == propagateToggle)
31493725 {
31503726 propagate ^= true;
....@@ -3249,8 +3825,9 @@
32493825 } else if (event.getSource() == liveCB)
32503826 {
32513827 copy.live ^= true;
3828
+ objEditor.refreshContents(true); // To show item colors
32523829 return;
3253
- } else if (event.getSource() == selectCB)
3830
+ } else if (event.getSource() == selectableCB)
32543831 {
32553832 copy.dontselect ^= true;
32563833 return;
....@@ -3258,7 +3835,7 @@
32583835 {
32593836 copy.hide ^= true;
32603837 copy.Touch(); // display list issue
3261
- objEditor.refreshContents();
3838
+ objEditor.refreshContents(true); // To show item colors
32623839 return;
32633840 } else if (event.getSource() == link2masterCB)
32643841 {
....@@ -3514,6 +4091,7 @@
35144091
35154092 static public byte[] Compress(Object3D o)
35164093 {
4094
+ // Slower to actually compress.
35174095 try
35184096 {
35194097 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3615,6 +4193,7 @@
36154193 {
36164194 //Save(true);
36174195 Replace();
4196
+ SetVersionStates();
36184197 }
36194198
36204199 private boolean Equal(byte[] compress, byte[] name)
....@@ -3635,29 +4214,46 @@
36354214
36364215 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36374216
4217
+ void DeleteVersion()
4218
+ {
4219
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4220
+ {
4221
+ copy.versionlist[i] = copy.versionlist[i+1];
4222
+ }
4223
+
4224
+ CopyChanged();
4225
+
4226
+ SetVersionStates();
4227
+ }
4228
+
36384229 public boolean Save(boolean user)
36394230 {
36404231 System.err.println("Save");
4232
+ Replace();
36414233
3642
- cRadio tab = GetCurrentTab();
4234
+ //cRadio tab = GetCurrentTab();
36434235
3644
- byte[] compress = CompressCopy();
4236
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36454237
36464238 boolean thesame = false;
36474239
3648
- // Quick heuristic using length. Works only when stream is compressed.
3649
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3650
- {
3651
- thesame = true;
3652
- }
4240
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4241
+// {
4242
+// thesame = true;
4243
+// }
36534244
36544245 //EditorFrame.m_MainFrame.requestFocusInWindow();
36554246 if (!thesame)
36564247 {
4248
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4249
+ {
4250
+ copy.versionlist[i] = copy.versionlist[i-1];
4251
+ }
4252
+
36574253 //tab.user[tab.versionindex] = user;
36584254 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36594255
3660
- copy.versions[++copy.versionindex] = compress;
4256
+ copy.versionlist[++copy.versionindex] = compress;
36614257
36624258 // if (increment)
36634259 // tab.versionindex++;
....@@ -3667,13 +4263,13 @@
36674263
36684264 //assert(hashtable.isEmpty());
36694265
3670
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3671
- {
3672
- //tab.user[i] = false;
3673
- copy.versions[i] = null;
3674
- }
4266
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4267
+// {
4268
+// //tab.user[i] = false;
4269
+// copy.versionlist[i] = null;
4270
+// }
36754271
3676
- SetUndoStates();
4272
+ SetVersionStates();
36774273
36784274 // test save
36794275 if (false)
....@@ -3696,10 +4292,44 @@
36964292
36974293 return !thesame;
36984294 }
3699
-
3700
- void CopyChanged(Object3D obj)
4295
+
4296
+ boolean flashIt = true;
4297
+
4298
+ void RefreshSelection()
37014299 {
3702
- SetUndoStates();
4300
+ Object3D selection = new Object3D();
4301
+
4302
+ for (int i = 0; i < copy.selection.size(); i++)
4303
+ {
4304
+ Object3D elem = copy.selection.elementAt(i);
4305
+
4306
+ Object3D obj = copy.GetObject(elem.GetUUID());
4307
+
4308
+ if (obj == null)
4309
+ {
4310
+ copy.selection.remove(i--);
4311
+ }
4312
+ else
4313
+ {
4314
+ selection.add(obj);
4315
+ copy.selection.setElementAt(obj, i);
4316
+ }
4317
+ }
4318
+
4319
+ flashIt = false;
4320
+ GetTree().clearSelection();
4321
+ for (int i = 0; i < selection.size(); i++)
4322
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4323
+ flashIt = true;
4324
+
4325
+ //refreshContents(false);
4326
+ }
4327
+
4328
+ void CopyChanged()
4329
+ {
4330
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4331
+
4332
+ SetVersionStates();
37034333
37044334 boolean temp = CameraPane.SWITCH;
37054335 CameraPane.SWITCH = false;
....@@ -3708,6 +4338,9 @@
37084338
37094339 copy.clear();
37104340
4341
+ copy.skyboxname = obj.skyboxname;
4342
+ copy.skyboxext = obj.skyboxext;
4343
+
37114344 for (int i=0; i<obj.Size(); i++)
37124345 {
37134346 copy.add(obj.get(i));
....@@ -3717,6 +4350,7 @@
37174350
37184351 CameraPane.SWITCH = temp;
37194352
4353
+ RefreshSelection();
37204354 //assert(hashtable.isEmpty());
37214355
37224356 copy.Touch();
....@@ -3737,13 +4371,15 @@
37374371 }
37384372 }
37394373
3740
- refreshContents();
4374
+ refreshContents(true);
37414375 }
37424376
3743
- cButton undoButton;
4377
+ cButton previousVersionButton;
37444378 cButton restoreButton;
37454379 cButton replaceButton;
3746
- cButton redoButton;
4380
+ cButton nextVersionButton;
4381
+ cButton saveVersionButton;
4382
+ cButton deleteVersionButton;
37474383
37484384 boolean muteSlider;
37494385
....@@ -3751,39 +4387,47 @@
37514387 {
37524388 int count = 0;
37534389
3754
- for (int i = copy.versions.length; --i >= 0;)
4390
+ for (int i = copy.versionlist.length; --i >= 0;)
37554391 {
3756
- if (copy.versions[i] != null)
4392
+ if (copy.versionlist[i] != null)
37574393 count++;
37584394 }
37594395
37604396 return count;
37614397 }
37624398
3763
- void SetUndoStates()
4399
+ void SetVersionStates()
37644400 {
3765
- cRadio tab = GetCurrentTab();
4401
+ //if (true)
4402
+ // return;
4403
+
4404
+ //cRadio tab = GetCurrentTab();
37664405
37674406 restoreButton.setEnabled(copy.versionindex != -1);
37684407 replaceButton.setEnabled(copy.versionindex != -1);
37694408
3770
- undoButton.setEnabled(copy.versionindex > 0);
3771
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4409
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4410
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4411
+
4412
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4413
+ copy.versionlist[copy.versionindex + 1] != null);
37724414
37734415 muteSlider = true;
4416
+ versionSlider.setMinimum(0);
37744417 versionSlider.setMaximum(VersionCount() - 1);
37754418 versionSlider.setInteger(copy.versionindex);
4419
+ versionSlider.setEnabled(copy.versionindex != -1);
37764420 muteSlider = false;
37774421 }
37784422
3779
- public boolean Undo()
4423
+ public boolean PreviousVersion()
37804424 {
37814425 // Option?
37824426 Replace();
37834427
37844428 System.err.println("Undo");
37854429
3786
- cRadio tab = GetCurrentTab();
4430
+ //cRadio tab = GetCurrentTab();
37874431
37884432 if (copy.versionindex == 0)
37894433 {
....@@ -3806,7 +4450,7 @@
38064450
38074451 copy.versionindex -= 1;
38084452
3809
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4453
+ CopyChanged();
38104454
38114455 return true;
38124456 }
....@@ -3815,15 +4459,16 @@
38154459 {
38164460 System.err.println("Restore");
38174461
3818
- cRadio tab = GetCurrentTab();
4462
+ //cRadio tab = GetCurrentTab();
38194463
3820
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4464
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38214465 {
38224466 java.awt.Toolkit.getDefaultToolkit().beep();
38234467 return false;
38244468 }
38254469
3826
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4470
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4471
+ CopyChanged();
38274472
38284473 return true;
38294474 }
....@@ -3832,27 +4477,27 @@
38324477 {
38334478 System.err.println("Replace");
38344479
3835
- cRadio tab = GetCurrentTab();
4480
+ //cRadio tab = GetCurrentTab();
38364481
3837
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4482
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38384483 {
38394484 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38404485 return false;
38414486 }
38424487
3843
- copy.versions[copy.versionindex] = CompressCopy();
4488
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38444489
38454490 return true;
38464491 }
38474492
3848
- public void Redo()
4493
+ public void NextVersion()
38494494 {
38504495 // Option?
38514496 Replace();
38524497
3853
- cRadio tab = GetCurrentTab();
4498
+ //cRadio tab = GetCurrentTab();
38544499
3855
- if (copy.versions[copy.versionindex + 1] == null)
4500
+ if (copy.versionlist[copy.versionindex + 1] == null)
38564501 {
38574502 java.awt.Toolkit.getDefaultToolkit().beep();
38584503 return;
....@@ -3860,7 +4505,7 @@
38604505
38614506 copy.versionindex += 1;
38624507
3863
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4508
+ CopyChanged();
38644509
38654510 //if (!tab.user[tab.versionindex])
38664511 // tab.graphs[tab.versionindex] = null;
....@@ -4074,7 +4719,7 @@
40744719 //copy.material = new cMaterial(copy.GetMaterial());
40754720
40764721 current.color = (float) colorField.getFloat();
4077
- current.modulation = (float) modulationField.getFloat();
4722
+ current.modulation = (float) saturationField.getFloat();
40784723 current.metalness = (float) metalnessField.getFloat();
40794724 current.diffuse = (float) diffuseField.getFloat();
40804725 current.specular = (float) specularField.getFloat();
....@@ -4107,7 +4752,7 @@
41074752 cMaterial mat = copy.material;
41084753
41094754 colorField.SetToolTipValue((mat.color));
4110
- modulationField.SetToolTipValue((mat.modulation));
4755
+ saturationField.SetToolTipValue((mat.modulation));
41114756 metalnessField.SetToolTipValue((mat.metalness));
41124757 diffuseField.SetToolTipValue((mat.diffuse));
41134758 specularField.SetToolTipValue((mat.specular));
....@@ -4169,11 +4814,14 @@
41694814 if (muteSlider)
41704815 return;
41714816
4817
+ Replace();
4818
+
41724819 int version = versionSlider.getInteger();
41734820
4174
- if (copy.versions[version] != null)
4821
+ if (version != -1 && copy.versionlist[version] != null)
41754822 {
4176
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4823
+ copy.versionindex = version;
4824
+ CopyChanged();
41774825 }
41784826
41794827 return;
....@@ -4213,6 +4861,12 @@
42134861 {
42144862 //System.out.println("stateChanged = " + this);
42154863 materialtouched = true;
4864
+
4865
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4866
+ {
4867
+ saturationField.setFloat(1);
4868
+ }
4869
+
42164870 applySelf();
42174871 //System.out.println("this = " + this);
42184872 //System.out.println("PARENT = " + parent);
....@@ -4512,6 +5166,7 @@
45125166 {
45135167 if (GetTree() != null)
45145168 {
5169
+ GetTree().revalidate();
45155170 GetTree().repaint();
45165171 }
45175172
....@@ -4520,6 +5175,9 @@
45205175 ctrlPanel.validate(); // ? new
45215176 ctrlPanel.repaint();
45225177 }
5178
+
5179
+ if (previousVersionButton != null && copy.versionlist != null)
5180
+ SetVersionStates();
45235181 }
45245182
45255183 static TweenManager tweenManager = new TweenManager();
....@@ -4768,7 +5426,9 @@
47685426 readobj.ResetDisplayList();
47695427 } catch (Exception e)
47705428 {
4771
- //e.printStackTrace();
5429
+ if (!e.toString().contains("GZIP"))
5430
+ e.printStackTrace();
5431
+
47725432 try
47735433 {
47745434 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4848,6 +5508,8 @@
48485508 {
48495509 //readobj.deepCopySelf(copy);
48505510 copy.clear(); // june 2014
5511
+ copy.skyboxname = readobj.skyboxname;
5512
+ copy.skyboxext = readobj.skyboxext;
48515513 for (int i = 0; i < readobj.size(); i++)
48525514 {
48535515 Object3D child = readobj.get(i); // reserve(i);
....@@ -4888,6 +5550,7 @@
48885550 }
48895551 } catch (ClassCastException e)
48905552 {
5553
+ e.printStackTrace();
48915554 assert (false);
48925555 Composite c = (Composite) copy;
48935556 c.children.clear();
....@@ -4898,13 +5561,16 @@
48985561 c.addChild(csg);
48995562 }
49005563
4901
- copy.versions = readobj.versions;
5564
+ copy.versionlist = readobj.versionlist;
49025565 copy.versionindex = readobj.versionindex;
49035566
4904
- if (copy.versions == null)
5567
+ if (copy.versionlist == null)
49055568 {
4906
- copy.versions = new byte[100][];
5569
+ // Backward compatibility
5570
+ copy.versionlist = new Object3D[100];
49075571 copy.versionindex = -1;
5572
+
5573
+ //Save(true);
49085574 }
49095575
49105576 //? SetUndoStates();
....@@ -4919,7 +5585,7 @@
49195585 {
49205586 if (Grafreed.standAlone)
49215587 {
4922
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5588
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49235589 browser.show();
49245590 String filename = browser.getFile();
49255591 if (filename != null && filename.length() > 0)
....@@ -4996,6 +5662,8 @@
49965662
49975663 void save()
49985664 {
5665
+ Replace();
5666
+
49995667 if (lastname == null)
50005668 {
50015669 return;
....@@ -5018,6 +5686,7 @@
50185686 //ps.print(buffer.toString());
50195687 } catch (IOException e)
50205688 {
5689
+ e.printStackTrace();
50215690 }
50225691 }
50235692
....@@ -5237,6 +5906,7 @@
52375906 ButtonGroup buttonGroup;
52385907
52395908 cGridBag toolboxPanel;
5909
+ cGridBag skyboxPanel;
52405910 cGridBag materialPanel;
52415911 cGridBag ctrlPanel;
52425912
....@@ -5310,7 +5980,7 @@
53105980 JLabel colorLabel;
53115981 cNumberSlider colorField;
53125982 JLabel modulationLabel;
5313
- cNumberSlider modulationField;
5983
+ cNumberSlider saturationField;
53145984 JLabel metalnessLabel;
53155985 cNumberSlider metalnessField;
53165986 JLabel diffuseLabel;
....@@ -5341,6 +6011,7 @@
53416011 cNumberSlider anisoField;
53426012 JLabel anisoVLabel;
53436013 cNumberSlider anisoVField;
6014
+
53446015 JLabel cameraLabel;
53456016 cNumberSlider cameraField;
53466017 JLabel selfshadowLabel;
....@@ -5355,6 +6026,7 @@
53556026 cNumberSlider fakedepthField;
53566027 JLabel shadowbiasLabel;
53576028 cNumberSlider shadowbiasField;
6029
+
53586030 JLabel bumpLabel;
53596031 cNumberSlider bumpField;
53606032 JLabel noiseLabel;