Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
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());
....@@ -314,7 +388,8 @@
314388 //parent = p;
315389
316390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
317
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
318393 //gd.setFullScreenWindow(this);
319394 //setResizable(false);
320395 //if (!isDisplayable())
....@@ -325,11 +400,13 @@
325400 copy = localCopy;
326401 copy.editWindow = this;
327402
328
- if (copy.versions == null)
329
- {
330
- copy.versions = new byte[100][];
331
- copy.versionindex = -1;
332
- }
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
333410
334411 SetupMenu();
335412
....@@ -349,6 +426,9 @@
349426
350427 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
351428
429
+ // This is to refresh the UI of the material panel.
430
+ boolean patchMaterial;
431
+
352432 void SetupMenu()
353433 {
354434 frame.setMenuBar(menuBar = new MenuBar());
....@@ -398,6 +478,8 @@
398478
399479 ChangeListener changeListener = new ChangeListener()
400480 {
481
+ //String name;
482
+
401483 public void stateChanged(ChangeEvent changeEvent)
402484 {
403485 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -416,7 +498,37 @@
416498 // EditSelection(false);
417499 // }
418500
419
- refreshContents(false); // To refresh Info tab
501
+// if (objectPanel.getSelectedIndex() == 4)
502
+// {
503
+// name = copy.skyboxname;
504
+//
505
+// if (name == null)
506
+// {
507
+// name = "";
508
+// }
509
+//
510
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
511
+// copy.skyboxext = "jpg";
512
+// }
513
+// else
514
+// {
515
+// if (name != null)
516
+// {
517
+// if (name.equals(""))
518
+// {
519
+// copy.skyboxname = null;
520
+// copy.skyboxext = null;
521
+// }
522
+// else
523
+// {
524
+// copy.skyboxname = name;
525
+// }
526
+// }
527
+// }
528
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
529
+
530
+// refreshContents(false); // To refresh Info tab
531
+ cameraView.repaint();
420532 }
421533 };
422534 objectPanel.addChangeListener(changeListener);
....@@ -436,10 +548,12 @@
436548 editPanel.add(editCommandsPanel);
437549 editPanel.add(ctrlPanel);
438550
439
- toolboxPanel = new cGridBag().setVertical(false);
551
+ toolboxPanel = new cGridBag().setVertical(true);
440552 //toolboxPanel.setName("Toolbox");
441553
442
- materialPanel = new cGridBag().setVertical(true);
554
+ skyboxPanel = new cGridBag().setVertical(true);
555
+
556
+ materialPanel = new cGridBag().setVertical(false);
443557 //materialPanel.setName("Material");
444558
445559 /*JTextPane*/
....@@ -723,6 +837,7 @@
723837 boolean maximized;
724838
725839 cButton fullscreenLayout;
840
+ cButton expandedLayout;
726841
727842 void Minimize()
728843 {
....@@ -762,10 +877,12 @@
762877 cButton minButton;
763878 cButton maxButton;
764879 cButton fullButton;
880
+ cButton collapseButton;
881
+ cButton maximize3DButton;
765882
766883 void ToggleFullScreen()
767884 {
768
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
885
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769886
770887 cameraView.ToggleFullScreen();
771888
....@@ -786,13 +903,13 @@
786903 // X frame.getContentPane().remove(/*"Center",*/bigThree);
787904 // X framePanel.add(bigThree);
788905 // X frame.getContentPane().add(/*"Center",*/framePanel);
789
- framePanel.setDividerLocation(46);
906
+// framePanel.setDividerLocation(46); // icons are 24x24
790907
791908 //frame.setVisible(true);
792
- radio.layout = keepButton;
909
+// radio.layout = keepButton;
793910 //theFrame = null;
794911 keepButton = null;
795
- radio.layout.doClick();
912
+// radio.layout.doClick();
796913
797914 } else
798915 {
....@@ -813,31 +930,48 @@
813930 // X frame.getContentPane().remove(/*"Center",*/framePanel);
814931 // X framePanel.remove(bigThree);
815932 // X frame.getContentPane().add(/*"Center",*/bigThree);
816
- framePanel.setDividerLocation(0);
933
+// framePanel.setDividerLocation(0);
817934
818
- radio.layout = fullscreenLayout;
819
- radio.layout.doClick();
935
+// radio.layout = fullscreenLayout;
936
+// radio.layout.doClick();
820937 //frame.setVisible(true);
821938 }
822939 frame.validate();
940
+
941
+ cameraView.requestFocusInWindow();
823942 }
824943
825
- private byte[] CompressCopy()
944
+ void CollapseToolbar()
945
+ {
946
+ framePanel.setDividerLocation(0);
947
+ //frame.validate();
948
+
949
+ cameraView.requestFocusInWindow();
950
+ }
951
+
952
+ private Object3D Duplicate(Object3D object)
826953 {
827954 boolean temp = CameraPane.SWITCH;
828955 CameraPane.SWITCH = false;
829956
830
- copy.ExtractBigData(versiontable);
957
+ if (Grafreed.grafreed.universe.versiontable == null)
958
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
959
+
960
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
831961 // if (copy == client)
832962
833
- byte[] versions[] = copy.versions;
834
- copy.versions = null;
963
+ Object3D versions[] = object.versionlist;
964
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
965
+ object.versionlist = null;
966
+ object.versiontable = null;
835967
836
- byte[] compress = Compress(copy);
968
+ //byte[] compress = Compress(copy);
969
+ Object3D compress = (Object3D)Grafreed.clone(object);
837970
838
- copy.versions = versions;
971
+ object.versionlist = versions;
972
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
839973
840
- copy.RestoreBigData(versiontable);
974
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
841975
842976 CameraPane.SWITCH = temp;
843977
....@@ -965,6 +1099,7 @@
9651099 {
9661100 SetupMaterial(materialPanel);
9671101 }
1102
+
9681103 //SetupName();
9691104 //SetupViews();
9701105 }
....@@ -974,7 +1109,7 @@
9741109 // NumberSlider vDivsField;
9751110 // JCheckBox endcaps;
9761111 JCheckBox liveCB;
977
- JCheckBox selectCB;
1112
+ JCheckBox selectableCB;
9781113 JCheckBox hideCB;
9791114 JCheckBox link2masterCB;
9801115 JCheckBox markCB;
....@@ -1173,6 +1308,18 @@
11731308
11741309 namePanel = new cGridBag();
11751310
1311
+ //if (copy.pinned)
1312
+ {
1313
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1314
+ pinButton.setSelected(copy.pinned);
1315
+ cGridBag t = new cGridBag();
1316
+ t.preferredWidth = 2;
1317
+ t.add(pinButton);
1318
+ namePanel.add(t);
1319
+
1320
+ pinButton.addItemListener(this);
1321
+ }
1322
+
11761323 nameField = AddText(namePanel, copy.GetName());
11771324 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11781325 oe.ctrlPanel.add(namePanel);
....@@ -1186,13 +1333,16 @@
11861333
11871334 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11881335 liveCB.setToolTipText("Animate object");
1189
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
- selectCB.setToolTipText("Make object selectable");
1336
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1337
+ markCB.setToolTipText("Set target transform");
1338
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1339
+ selectableCB.setToolTipText("Make object selectable");
11911340 // Return();
1341
+
11921342 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11931343 hideCB.setToolTipText("Hide object");
1194
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1195
- markCB.setToolTipText("As animation target transform");
1344
+
1345
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11961346
11971347 setupPanel2 = new cGridBag().setVertical(false);
11981348
....@@ -1392,6 +1542,7 @@
13921542
13931543 if (cam == null || !(copy.get(0) instanceof cGroup))
13941544 {
1545
+ if (Globals.DEBUG)
13951546 System.out.println("CREATE CAMERAS");
13961547 cams = new cTemplate();
13971548 cams.name = "Cameras";
....@@ -1517,25 +1668,34 @@
15171668
15181669 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15191670 //tmp.setName("Edit");
1671
+ objectPanel.add(toolboxPanel);
1672
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1673
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1674
+
15201675 objectPanel.add(materialPanel);
1521
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1676
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1677
+ objectPanel.setToolTipTextAt(1, "Material");
1678
+
1679
+ objectPanel.add(skyboxPanel);
1680
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1681
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1682
+
15221683 // JPanel north = new JPanel(new BorderLayout());
15231684 // north.setName("Edit");
15241685 // north.add(ctrlPanel, BorderLayout.NORTH);
15251686 // objectPanel.add(north);
15261687 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"));
1688
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1689
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15321690
15331691 objectPanel.add(XYZPanel);
1534
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1692
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1693
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15351694
1536
- objectPanel.add(toolboxPanel);
1537
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1538
-
1695
+ patchMaterial = true;
1696
+ cameraView.patchMaterial = this;
1697
+ objectPanel.setSelectedIndex(1);
1698
+
15391699 /*
15401700 aConstraints.gridx = 0;
15411701 aConstraints.gridwidth = 1;
....@@ -1572,6 +1732,11 @@
15721732
15731733 scenePanel.add(tabbedPane);
15741734
1735
+ //if (Globals.ADVANCED)
1736
+// tabbedPane.add(infoPanel);
1737
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1738
+// tabbedPane.setToolTipTextAt(3, "Information");
1739
+
15751740 /*
15761741 cTree jTree = new cTree(null);
15771742 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1642,6 +1807,23 @@
16421807 // aConstraints.gridheight = 1;
16431808
16441809 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1810
+
1811
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1812
+ new java.beans.PropertyChangeListener()
1813
+ {
1814
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1815
+ {
1816
+ if ((Integer)pce.getOldValue() == 1)
1817
+ {
1818
+ if (radio.layout != expandedLayout)
1819
+ {
1820
+ radio.layout = expandedLayout;
1821
+ radio.layout.doClick();
1822
+ }
1823
+ }
1824
+ }
1825
+ });
1826
+
16451827 framePanel.setContinuousLayout(false);
16461828 framePanel.setOneTouchExpandable(false);
16471829 //.setDividerLocation(0.8);
....@@ -1651,7 +1833,7 @@
16511833
16521834 frame.getContentPane().setLayout(new BorderLayout());
16531835 /**/
1654
- JTabbedPane worldPane = new JTabbedPane();
1836
+ //JTabbedPane worldPane = new JTabbedPane();
16551837 //worldPane.add(bigPanel);
16561838 //worldPane.add(worldPanel);
16571839 /**/
....@@ -1674,7 +1856,6 @@
16741856 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16751857 frame.addWindowListener(new WindowAdapter()
16761858 {
1677
-
16781859 public void windowClosing(WindowEvent e)
16791860 {
16801861 Close();
....@@ -1697,12 +1878,426 @@
16971878 ctrlPanel.removeAll();
16981879 }
16991880
1700
- void SetupMaterial(cGridBag panel)
1881
+ void SetupMaterial(cGridBag materialpanel)
17011882 {
1702
- /*
1883
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1884
+
1885
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1886
+ skin.setToolTipText("Skin");
1887
+ skin.addMouseListener(new MouseAdapter()
1888
+ {
1889
+ public void mouseClicked(MouseEvent e)
1890
+ {
1891
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1892
+ cMaterial material = object.material;
1893
+
1894
+ // Skin
1895
+ colorField.setFloat(material.color);
1896
+ float saturation = material.modulation;
1897
+
1898
+ if (!cameraView.Skinshader)
1899
+ {
1900
+ saturation /= 1.5;
1901
+ }
1902
+
1903
+ saturationField.setFloat(saturation);
1904
+
1905
+ subsurfaceField.setFloat(material.subsurface);
1906
+ selfshadowField.setFloat(material.diffuseness);
1907
+ diffusenessField.setFloat(material.factor);
1908
+ shininessField.setFloat(material.shininess);
1909
+ shadowbiasField.setFloat(material.shadowbias);
1910
+ diffuseField.setFloat(material.diffuse);
1911
+ specularField.setFloat(material.specular);
1912
+
1913
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1914
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1915
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1916
+
1917
+ materialtouched = true;
1918
+ applySelf();
1919
+ }
1920
+ });
1921
+ presetpanel.add(skin);
1922
+
1923
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1924
+ lambert.setToolTipText("Diffuse");
1925
+ lambert.addMouseListener(new MouseAdapter()
1926
+ {
1927
+ public void mouseClicked(MouseEvent e)
1928
+ {
1929
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1930
+ cMaterial material = object.material;
1931
+
1932
+ diffusenessField.setFloat(material.factor);
1933
+ selfshadowField.setFloat(material.diffuseness);
1934
+
1935
+ materialtouched = true;
1936
+ applySelf();
1937
+ }
1938
+ });
1939
+ presetpanel.add(lambert);
1940
+
1941
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1942
+ diffuse2.setToolTipText("Diffuse2");
1943
+ diffuse2.addMouseListener(new MouseAdapter()
1944
+ {
1945
+ public void mouseClicked(MouseEvent e)
1946
+ {
1947
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1948
+ cMaterial material = object.material;
1949
+
1950
+ diffusenessField.setFloat(material.factor);
1951
+ selfshadowField.setFloat(material.diffuseness);
1952
+
1953
+ materialtouched = true;
1954
+ applySelf();
1955
+ }
1956
+ });
1957
+ presetpanel.add(diffuse2);
1958
+
1959
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1960
+ diffusemoon.setToolTipText("Moon");
1961
+ diffusemoon.addMouseListener(new MouseAdapter()
1962
+ {
1963
+ public void mouseClicked(MouseEvent e)
1964
+ {
1965
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1966
+ cMaterial material = object.material;
1967
+
1968
+ diffusenessField.setFloat(material.factor);
1969
+ selfshadowField.setFloat(material.diffuseness);
1970
+
1971
+ materialtouched = true;
1972
+ applySelf();
1973
+ }
1974
+ });
1975
+ presetpanel.add(diffusemoon);
1976
+
1977
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1978
+ diffusemoon2.setToolTipText("Moon2");
1979
+ diffusemoon2.addMouseListener(new MouseAdapter()
1980
+ {
1981
+ public void mouseClicked(MouseEvent e)
1982
+ {
1983
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1984
+ cMaterial material = object.material;
1985
+
1986
+ diffusenessField.setFloat(material.factor);
1987
+ selfshadowField.setFloat(material.diffuseness);
1988
+
1989
+ materialtouched = true;
1990
+ applySelf();
1991
+ }
1992
+ });
1993
+ presetpanel.add(diffusemoon2);
1994
+
1995
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1996
+ diffusemoon3.setToolTipText("Moon3");
1997
+ diffusemoon3.addMouseListener(new MouseAdapter()
1998
+ {
1999
+ public void mouseClicked(MouseEvent e)
2000
+ {
2001
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2002
+ cMaterial material = object.material;
2003
+
2004
+ diffusenessField.setFloat(material.factor);
2005
+ selfshadowField.setFloat(material.diffuseness);
2006
+
2007
+ materialtouched = true;
2008
+ applySelf();
2009
+ }
2010
+ });
2011
+ presetpanel.add(diffusemoon3);
2012
+
2013
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2014
+ diffusesheen.setToolTipText("Sheen");
2015
+ diffusesheen.addMouseListener(new MouseAdapter()
2016
+ {
2017
+ public void mouseClicked(MouseEvent e)
2018
+ {
2019
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2020
+ cMaterial material = object.material;
2021
+
2022
+ sheenField.setFloat(material.sheen);
2023
+
2024
+ materialtouched = true;
2025
+ applySelf();
2026
+ }
2027
+ });
2028
+ presetpanel.add(diffusesheen);
2029
+
2030
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2031
+ rough.setToolTipText("Rough metal");
2032
+ rough.addMouseListener(new MouseAdapter()
2033
+ {
2034
+ public void mouseClicked(MouseEvent e)
2035
+ {
2036
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2037
+ cMaterial material = object.material;
2038
+
2039
+ shininessField.setFloat(material.shininess);
2040
+ velvetField.setFloat(material.velvet);
2041
+
2042
+ materialtouched = true;
2043
+ applySelf();
2044
+ }
2045
+ });
2046
+ presetpanel.add(rough);
2047
+
2048
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2049
+ rough2.setToolTipText("Medium metal");
2050
+ rough2.addMouseListener(new MouseAdapter()
2051
+ {
2052
+ public void mouseClicked(MouseEvent e)
2053
+ {
2054
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2055
+ cMaterial material = object.material;
2056
+
2057
+ shininessField.setFloat(material.shininess);
2058
+ lightareaField.setFloat(material.lightarea);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(rough2);
2065
+
2066
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2067
+ shini0.setToolTipText("Shiny");
2068
+ shini0.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ shininessField.setFloat(material.shininess);
2076
+ lightareaField.setFloat(material.lightarea);
2077
+
2078
+ materialtouched = true;
2079
+ applySelf();
2080
+ }
2081
+ });
2082
+ presetpanel.add(shini0);
2083
+
2084
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2085
+ shini1.setToolTipText("Shiny2");
2086
+ shini1.addMouseListener(new MouseAdapter()
2087
+ {
2088
+ public void mouseClicked(MouseEvent e)
2089
+ {
2090
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2091
+ cMaterial material = object.material;
2092
+
2093
+ shininessField.setFloat(material.shininess);
2094
+ lightareaField.setFloat(material.lightarea);
2095
+
2096
+ materialtouched = true;
2097
+ applySelf();
2098
+ }
2099
+ });
2100
+ presetpanel.add(shini1);
2101
+
2102
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2103
+ shini2.setToolTipText("Shiny3");
2104
+ shini2.addMouseListener(new MouseAdapter()
2105
+ {
2106
+ public void mouseClicked(MouseEvent e)
2107
+ {
2108
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2109
+ cMaterial material = object.material;
2110
+
2111
+ shininessField.setFloat(material.shininess);
2112
+ lightareaField.setFloat(material.lightarea);
2113
+
2114
+ materialtouched = true;
2115
+ applySelf();
2116
+ }
2117
+ });
2118
+ presetpanel.add(shini2);
2119
+
2120
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2121
+ aniso.setToolTipText("AnisoU");
2122
+ aniso.addMouseListener(new MouseAdapter()
2123
+ {
2124
+ public void mouseClicked(MouseEvent e)
2125
+ {
2126
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2127
+ cMaterial material = object.material;
2128
+
2129
+ anisoField.setFloat(material.aniso);
2130
+ anisoVField.setFloat(material.anisoV);
2131
+
2132
+ materialtouched = true;
2133
+ applySelf();
2134
+ }
2135
+ });
2136
+ presetpanel.add(aniso);
2137
+
2138
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2139
+ aniso2.setToolTipText("AnisoV");
2140
+ aniso2.addMouseListener(new MouseAdapter()
2141
+ {
2142
+ public void mouseClicked(MouseEvent e)
2143
+ {
2144
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2145
+ cMaterial material = object.material;
2146
+
2147
+ anisoField.setFloat(material.aniso);
2148
+ anisoVField.setFloat(material.anisoV);
2149
+
2150
+ materialtouched = true;
2151
+ applySelf();
2152
+ }
2153
+ });
2154
+ presetpanel.add(aniso2);
2155
+
2156
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2157
+ aniso3.setToolTipText("AnisoUV");
2158
+ aniso3.addMouseListener(new MouseAdapter()
2159
+ {
2160
+ public void mouseClicked(MouseEvent e)
2161
+ {
2162
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2163
+ cMaterial material = object.material;
2164
+
2165
+ anisoField.setFloat(material.aniso);
2166
+ anisoVField.setFloat(material.anisoV);
2167
+
2168
+ materialtouched = true;
2169
+ applySelf();
2170
+ }
2171
+ });
2172
+ presetpanel.add(aniso3);
2173
+
2174
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2175
+ velvet0.setToolTipText("Velvet");
2176
+ velvet0.addMouseListener(new MouseAdapter()
2177
+ {
2178
+ public void mouseClicked(MouseEvent e)
2179
+ {
2180
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2181
+ cMaterial material = object.material;
2182
+
2183
+ diffusenessField.setFloat(material.factor);
2184
+ selfshadowField.setFloat(material.diffuseness);
2185
+ sheenField.setFloat(material.sheen);
2186
+ shininessField.setFloat(material.shininess);
2187
+ velvetField.setFloat(material.velvet);
2188
+ shiftField.setFloat(material.shift);
2189
+
2190
+ materialtouched = true;
2191
+ applySelf();
2192
+ }
2193
+ });
2194
+ presetpanel.add(velvet0);
2195
+
2196
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2197
+ bump0.setToolTipText("Bump texture");
2198
+ bump0.addMouseListener(new MouseAdapter()
2199
+ {
2200
+ public void mouseClicked(MouseEvent e)
2201
+ {
2202
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2203
+ cMaterial material = object.material;
2204
+
2205
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2206
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2207
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2208
+
2209
+ materialtouched = true;
2210
+ applySelf();
2211
+ }
2212
+ });
2213
+ presetpanel.add(bump0);
2214
+
2215
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2216
+ borderShader.setToolTipText("Border fade");
2217
+ borderShader.addMouseListener(new MouseAdapter()
2218
+ {
2219
+ public void mouseClicked(MouseEvent e)
2220
+ {
2221
+ borderfadeField.setFloat(0.5);
2222
+ opacityField.setFloat(0.75);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(borderShader);
2229
+
2230
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2231
+ halo.setToolTipText("Halo");
2232
+ halo.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2240
+
2241
+ materialtouched = true;
2242
+ applySelf();
2243
+ }
2244
+ });
2245
+ presetpanel.add(halo);
2246
+
2247
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2248
+ candle.setToolTipText("Candle");
2249
+ candle.addMouseListener(new MouseAdapter()
2250
+ {
2251
+ public void mouseClicked(MouseEvent e)
2252
+ {
2253
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2254
+ cMaterial material = object.material;
2255
+
2256
+ subsurfaceField.setFloat(material.subsurface);
2257
+ shadowbiasField.setFloat(material.shadowbias);
2258
+ ambientField.setFloat(material.ambient);
2259
+ specularField.setFloat(material.specular);
2260
+ lightareaField.setFloat(material.lightarea);
2261
+ shininessField.setFloat(material.shininess);
2262
+
2263
+ materialtouched = true;
2264
+ applySelf();
2265
+ }
2266
+ });
2267
+ presetpanel.add(candle);
2268
+
2269
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2270
+ shadowShader.setToolTipText("Shadow");
2271
+ shadowShader.addMouseListener(new MouseAdapter()
2272
+ {
2273
+ public void mouseClicked(MouseEvent e)
2274
+ {
2275
+ diffuseField.setFloat(0.001);
2276
+ ambientField.setFloat(0.001);
2277
+ cameraField.setFloat(0.001);
2278
+ specularField.setFloat(0.001);
2279
+ fakedepthField.setFloat(0.001);
2280
+ opacityField.setFloat(0.6);
2281
+
2282
+ materialtouched = true;
2283
+ applySelf();
2284
+ }
2285
+ });
2286
+ presetpanel.add(shadowShader);
2287
+
2288
+ cGridBag panel = new cGridBag().setVertical(true);
2289
+
2290
+ presetpanel.preferredWidth = 1;
2291
+
2292
+ materialpanel.add(presetpanel);
2293
+ materialpanel.add(panel);
2294
+
2295
+ panel.preferredWidth = 8;
2296
+
2297
+ /*
17032298 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17042299 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1705
- */
2300
+ */
17062301
17072302 cGridBag editBar = new cGridBag().setVertical(false);
17082303
....@@ -1736,27 +2331,61 @@
17362331 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17372332
17382333 cGridBag colorSection = new cGridBag().setVertical(true);
2334
+
2335
+ cGridBag huepanel = new cGridBag();
2336
+ cGridBag huelabel = new cGridBag();
2337
+ cLabel hue = GetLabel("icons/hue.png", false);
2338
+ hue.fit = true;
2339
+
2340
+ hue.addMouseListener(new MouseAdapter()
2341
+ {
2342
+ public void mousePressed(MouseEvent e)
2343
+ {
2344
+ int x = e.getX();
2345
+
2346
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2347
+ }
2348
+ });
2349
+
2350
+ huelabel.add(hue);
2351
+ huelabel.preferredWidth = 20;
2352
+ huepanel.add(new cGridBag()); // Label
2353
+ huepanel.add(huelabel); // Field/slider
2354
+
2355
+ huepanel.preferredHeight = 7;
2356
+
2357
+ colorSection.add(huepanel);
17392358
17402359 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);
2360
+
2361
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2362
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2363
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2364
+
17442365 //colorField.preferredWidth = 200;
17452366 colorSection.add(color);
17462367
17472368 cGridBag modulation = new cGridBag();
17482369 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17492370 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1750
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2371
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17512372 colorSection.add(modulation);
17522373
2374
+ cGridBag opacity = new cGridBag();
2375
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2376
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2377
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2378
+ colorSection.add(opacity);
2379
+
2380
+ colorSection.add(GetSeparator());
2381
+
17532382 cGridBag texture = new cGridBag();
17542383 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17552384 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17562385 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17572386 colorSection.add(texture);
17582387
1759
- panel.add(new JSeparator());
2388
+ panel.add(GetSeparator());
17602389
17612390 panel.add(colorSection);
17622391
....@@ -1812,7 +2441,7 @@
18122441 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18132442 diffuseSection.add(shadowbias);
18142443
1815
- panel.add(new JSeparator());
2444
+ panel.add(GetSeparator());
18162445
18172446 panel.add(diffuseSection);
18182447
....@@ -1875,7 +2504,7 @@
18752504 specularSection.add(anisoV);
18762505
18772506
1878
- panel.add(new JSeparator());
2507
+ panel.add(GetSeparator());
18792508
18802509 panel.add(specularSection);
18812510
....@@ -1900,12 +2529,6 @@
19002529 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19012530 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19022531 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);
19092532
19102533 //panel.add(new JSeparator());
19112534
....@@ -1951,7 +2574,7 @@
19512574 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19522575 textureSection.add(opacityPower);
19532576
1954
- panel.add(new JSeparator());
2577
+ panel.add(GetSeparator());
19552578
19562579 panel.add(textureSection);
19572580
....@@ -2938,7 +3561,7 @@
29383561
29393562 freezematerial = true;
29403563 colorField.setFloat(mat.color);
2941
- modulationField.setFloat(mat.modulation);
3564
+ saturationField.setFloat(mat.modulation);
29423565 metalnessField.setFloat(mat.metalness);
29433566 diffuseField.setFloat(mat.diffuse);
29443567 specularField.setFloat(mat.specular);
....@@ -3000,32 +3623,8 @@
30003623
30013624 if (multiplyToggle != null)
30023625 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
- }
3626
+
3627
+ AllocProjectedVertices(object);
30293628
30303629 SetMaterial(mat, object.projectedVertices);
30313630 }
....@@ -3145,6 +3744,17 @@
31453744 public void itemStateChanged(ItemEvent event)
31463745 {
31473746 // System.out.println("Propagate = " + propagate);
3747
+ if (event.getSource() == pinButton)
3748
+ {
3749
+ copy.pinned ^= true;
3750
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3751
+ {
3752
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3753
+ copy.CloseUI();
3754
+ //copy.editWindow.refreshContents();
3755
+ }
3756
+ }
3757
+ else
31483758 if (event.getSource() == propagateToggle)
31493759 {
31503760 propagate ^= true;
....@@ -3249,8 +3859,9 @@
32493859 } else if (event.getSource() == liveCB)
32503860 {
32513861 copy.live ^= true;
3862
+ objEditor.refreshContents(true); // To show item colors
32523863 return;
3253
- } else if (event.getSource() == selectCB)
3864
+ } else if (event.getSource() == selectableCB)
32543865 {
32553866 copy.dontselect ^= true;
32563867 return;
....@@ -3258,7 +3869,7 @@
32583869 {
32593870 copy.hide ^= true;
32603871 copy.Touch(); // display list issue
3261
- objEditor.refreshContents();
3872
+ objEditor.refreshContents(true); // To show item colors
32623873 return;
32633874 } else if (event.getSource() == link2masterCB)
32643875 {
....@@ -3323,7 +3934,7 @@
33233934 //System.out.println("ObjEditor " + event);
33243935 applySelf0(true);
33253936 //parent.applySelf();
3326
- objEditor.refreshContents();
3937
+ // conflicts with requestFocus objEditor.refreshContents();
33273938 } else if (source == resetButton)
33283939 {
33293940 CameraPane.fullreset = true;
....@@ -3514,6 +4125,7 @@
35144125
35154126 static public byte[] Compress(Object3D o)
35164127 {
4128
+ // Slower to actually compress.
35174129 try
35184130 {
35194131 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3615,6 +4227,7 @@
36154227 {
36164228 //Save(true);
36174229 Replace();
4230
+ SetVersionStates();
36184231 }
36194232
36204233 private boolean Equal(byte[] compress, byte[] name)
....@@ -3633,31 +4246,50 @@
36334246 return true;
36344247 }
36354248
3636
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4249
+ void DeleteVersion()
4250
+ {
4251
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4252
+ {
4253
+ copy.versionlist[i] = copy.versionlist[i+1];
4254
+ }
4255
+
4256
+ if (copy.versionlist[copy.versionindex] == null)
4257
+ copy.versionindex -= 1;
4258
+
4259
+ if (copy.versionindex != -1)
4260
+ CopyChanged();
4261
+
4262
+ SetVersionStates();
4263
+ }
36374264
36384265 public boolean Save(boolean user)
36394266 {
36404267 System.err.println("Save");
4268
+ Replace();
36414269
3642
- cRadio tab = GetCurrentTab();
4270
+ //cRadio tab = GetCurrentTab();
36434271
3644
- byte[] compress = CompressCopy();
4272
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36454273
36464274 boolean thesame = false;
36474275
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
- }
4276
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4277
+// {
4278
+// thesame = true;
4279
+// }
36534280
36544281 //EditorFrame.m_MainFrame.requestFocusInWindow();
36554282 if (!thesame)
36564283 {
4284
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4285
+ {
4286
+ copy.versionlist[i] = copy.versionlist[i-1];
4287
+ }
4288
+
36574289 //tab.user[tab.versionindex] = user;
36584290 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36594291
3660
- copy.versions[++copy.versionindex] = compress;
4292
+ copy.versionlist[++copy.versionindex] = compress;
36614293
36624294 // if (increment)
36634295 // tab.versionindex++;
....@@ -3667,13 +4299,13 @@
36674299
36684300 //assert(hashtable.isEmpty());
36694301
3670
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3671
- {
3672
- //tab.user[i] = false;
3673
- copy.versions[i] = null;
3674
- }
4302
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4303
+// {
4304
+// //tab.user[i] = false;
4305
+// copy.versionlist[i] = null;
4306
+// }
36754307
3676
- SetUndoStates();
4308
+ SetVersionStates();
36774309
36784310 // test save
36794311 if (false)
....@@ -3696,27 +4328,65 @@
36964328
36974329 return !thesame;
36984330 }
3699
-
3700
- void CopyChanged(Object3D obj)
4331
+
4332
+ boolean flashIt = true;
4333
+
4334
+ void RefreshSelection()
37014335 {
3702
- SetUndoStates();
4336
+ Object3D selection = new Object3D();
4337
+
4338
+ for (int i = 0; i < copy.selection.size(); i++)
4339
+ {
4340
+ Object3D elem = copy.selection.elementAt(i);
4341
+
4342
+ Object3D obj = copy.GetObject(elem.GetUUID());
4343
+
4344
+ if (obj == null)
4345
+ {
4346
+ copy.selection.remove(i--);
4347
+ }
4348
+ else
4349
+ {
4350
+ selection.add(obj);
4351
+ copy.selection.setElementAt(obj, i);
4352
+ }
4353
+ }
4354
+
4355
+ flashIt = false;
4356
+ GetTree().clearSelection();
4357
+ for (int i = 0; i < selection.size(); i++)
4358
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4359
+ flashIt = true;
4360
+
4361
+ //refreshContents(false);
4362
+ }
4363
+
4364
+ void CopyChanged()
4365
+ {
4366
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4367
+
4368
+ SetVersionStates();
37034369
37044370 boolean temp = CameraPane.SWITCH;
37054371 CameraPane.SWITCH = false;
37064372
3707
- copy.ExtractBigData(versiontable);
4373
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
37084374
37094375 copy.clear();
37104376
4377
+ copy.skyboxname = obj.skyboxname;
4378
+ copy.skyboxext = obj.skyboxext;
4379
+
37114380 for (int i=0; i<obj.Size(); i++)
37124381 {
37134382 copy.add(obj.get(i));
37144383 }
37154384
3716
- copy.RestoreBigData(versiontable);
4385
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
37174386
37184387 CameraPane.SWITCH = temp;
37194388
4389
+ RefreshSelection();
37204390 //assert(hashtable.isEmpty());
37214391
37224392 copy.Touch();
....@@ -3737,13 +4407,15 @@
37374407 }
37384408 }
37394409
3740
- refreshContents();
4410
+ refreshContents(true);
37414411 }
37424412
3743
- cButton undoButton;
4413
+ cButton previousVersionButton;
37444414 cButton restoreButton;
37454415 cButton replaceButton;
3746
- cButton redoButton;
4416
+ cButton nextVersionButton;
4417
+ cButton saveVersionButton;
4418
+ cButton deleteVersionButton;
37474419
37484420 boolean muteSlider;
37494421
....@@ -3751,39 +4423,47 @@
37514423 {
37524424 int count = 0;
37534425
3754
- for (int i = copy.versions.length; --i >= 0;)
4426
+ for (int i = copy.versionlist.length; --i >= 0;)
37554427 {
3756
- if (copy.versions[i] != null)
4428
+ if (copy.versionlist[i] != null)
37574429 count++;
37584430 }
37594431
37604432 return count;
37614433 }
37624434
3763
- void SetUndoStates()
4435
+ void SetVersionStates()
37644436 {
3765
- cRadio tab = GetCurrentTab();
4437
+ //if (true)
4438
+ // return;
4439
+
4440
+ //cRadio tab = GetCurrentTab();
37664441
37674442 restoreButton.setEnabled(copy.versionindex != -1);
37684443 replaceButton.setEnabled(copy.versionindex != -1);
37694444
3770
- undoButton.setEnabled(copy.versionindex > 0);
3771
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4445
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4446
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4447
+
4448
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4449
+ //copy.versionlist[copy.versionindex + 1] != null);
37724450
37734451 muteSlider = true;
4452
+ versionSlider.setMinimum(0);
37744453 versionSlider.setMaximum(VersionCount() - 1);
37754454 versionSlider.setInteger(copy.versionindex);
4455
+ versionSlider.setEnabled(copy.versionindex != -1);
37764456 muteSlider = false;
37774457 }
37784458
3779
- public boolean Undo()
4459
+ public boolean PreviousVersion()
37804460 {
37814461 // Option?
37824462 Replace();
37834463
37844464 System.err.println("Undo");
37854465
3786
- cRadio tab = GetCurrentTab();
4466
+ //cRadio tab = GetCurrentTab();
37874467
37884468 if (copy.versionindex == 0)
37894469 {
....@@ -3806,7 +4486,7 @@
38064486
38074487 copy.versionindex -= 1;
38084488
3809
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4489
+ CopyChanged();
38104490
38114491 return true;
38124492 }
....@@ -3815,44 +4495,45 @@
38154495 {
38164496 System.err.println("Restore");
38174497
3818
- cRadio tab = GetCurrentTab();
4498
+ //cRadio tab = GetCurrentTab();
38194499
3820
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4500
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38214501 {
38224502 java.awt.Toolkit.getDefaultToolkit().beep();
38234503 return false;
38244504 }
38254505
3826
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4506
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4507
+ CopyChanged();
38274508
38284509 return true;
38294510 }
38304511
38314512 public boolean Replace()
38324513 {
3833
- System.err.println("Replace");
4514
+ //System.err.println("Replace");
38344515
3835
- cRadio tab = GetCurrentTab();
4516
+ //cRadio tab = GetCurrentTab();
38364517
3837
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4518
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38384519 {
38394520 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38404521 return false;
38414522 }
38424523
3843
- copy.versions[copy.versionindex] = CompressCopy();
4524
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38444525
38454526 return true;
38464527 }
38474528
3848
- public void Redo()
4529
+ public void NextVersion()
38494530 {
38504531 // Option?
38514532 Replace();
38524533
3853
- cRadio tab = GetCurrentTab();
4534
+ //cRadio tab = GetCurrentTab();
38544535
3855
- if (copy.versions[copy.versionindex + 1] == null)
4536
+ if (copy.versionlist[copy.versionindex + 1] == null)
38564537 {
38574538 java.awt.Toolkit.getDefaultToolkit().beep();
38584539 return;
....@@ -3860,7 +4541,7 @@
38604541
38614542 copy.versionindex += 1;
38624543
3863
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4544
+ CopyChanged();
38644545
38654546 //if (!tab.user[tab.versionindex])
38664547 // tab.graphs[tab.versionindex] = null;
....@@ -4074,7 +4755,7 @@
40744755 //copy.material = new cMaterial(copy.GetMaterial());
40754756
40764757 current.color = (float) colorField.getFloat();
4077
- current.modulation = (float) modulationField.getFloat();
4758
+ current.modulation = (float) saturationField.getFloat();
40784759 current.metalness = (float) metalnessField.getFloat();
40794760 current.diffuse = (float) diffuseField.getFloat();
40804761 current.specular = (float) specularField.getFloat();
....@@ -4107,7 +4788,7 @@
41074788 cMaterial mat = copy.material;
41084789
41094790 colorField.SetToolTipValue((mat.color));
4110
- modulationField.SetToolTipValue((mat.modulation));
4791
+ saturationField.SetToolTipValue((mat.modulation));
41114792 metalnessField.SetToolTipValue((mat.metalness));
41124793 diffuseField.SetToolTipValue((mat.diffuse));
41134794 specularField.SetToolTipValue((mat.specular));
....@@ -4169,11 +4850,14 @@
41694850 if (muteSlider)
41704851 return;
41714852
4853
+ Replace();
4854
+
41724855 int version = versionSlider.getInteger();
41734856
4174
- if (copy.versions[version] != null)
4857
+ if (version != -1 && copy.versionlist[version] != null)
41754858 {
4176
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4859
+ copy.versionindex = version;
4860
+ CopyChanged();
41774861 }
41784862
41794863 return;
....@@ -4213,6 +4897,12 @@
42134897 {
42144898 //System.out.println("stateChanged = " + this);
42154899 materialtouched = true;
4900
+
4901
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4902
+ {
4903
+ saturationField.setFloat(1);
4904
+ }
4905
+
42164906 applySelf();
42174907 //System.out.println("this = " + this);
42184908 //System.out.println("PARENT = " + parent);
....@@ -4512,6 +5202,7 @@
45125202 {
45135203 if (GetTree() != null)
45145204 {
5205
+ GetTree().revalidate();
45155206 GetTree().repaint();
45165207 }
45175208
....@@ -4520,6 +5211,11 @@
45205211 ctrlPanel.validate(); // ? new
45215212 ctrlPanel.repaint();
45225213 }
5214
+
5215
+ if (previousVersionButton != null && copy.versionlist != null)
5216
+ SetVersionStates();
5217
+
5218
+ cameraView.requestFocusInWindow();
45235219 }
45245220
45255221 static TweenManager tweenManager = new TweenManager();
....@@ -4551,7 +5247,7 @@
45515247 // group = (Composite) group.get(0);
45525248 // }
45535249
4554
- System.out.println("makeSomething of " + thing);
5250
+ //System.out.println("makeSomething of " + thing);
45555251
45565252 /*
45575253 if (deselect && jList != null)
....@@ -4768,7 +5464,9 @@
47685464 readobj.ResetDisplayList();
47695465 } catch (Exception e)
47705466 {
4771
- //e.printStackTrace();
5467
+ if (!e.toString().contains("GZIP"))
5468
+ e.printStackTrace();
5469
+
47725470 try
47735471 {
47745472 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4848,6 +5546,8 @@
48485546 {
48495547 //readobj.deepCopySelf(copy);
48505548 copy.clear(); // june 2014
5549
+ copy.skyboxname = readobj.skyboxname;
5550
+ copy.skyboxext = readobj.skyboxext;
48515551 for (int i = 0; i < readobj.size(); i++)
48525552 {
48535553 Object3D child = readobj.get(i); // reserve(i);
....@@ -4888,6 +5588,7 @@
48885588 }
48895589 } catch (ClassCastException e)
48905590 {
5591
+ e.printStackTrace();
48915592 assert (false);
48925593 Composite c = (Composite) copy;
48935594 c.children.clear();
....@@ -4898,13 +5599,17 @@
48985599 c.addChild(csg);
48995600 }
49005601
4901
- copy.versions = readobj.versions;
5602
+ copy.versionlist = readobj.versionlist;
49025603 copy.versionindex = readobj.versionindex;
5604
+ copy.versiontable = readobj.versiontable;
49035605
4904
- if (copy.versions == null)
5606
+ if (copy.versionlist == null)
49055607 {
4906
- copy.versions = new byte[100][];
5608
+ // Backward compatibility
5609
+ copy.versionlist = new Object3D[100];
49075610 copy.versionindex = -1;
5611
+
5612
+ //Save(true);
49085613 }
49095614
49105615 //? SetUndoStates();
....@@ -4919,7 +5624,7 @@
49195624 {
49205625 if (Grafreed.standAlone)
49215626 {
4922
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5627
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49235628 browser.show();
49245629 String filename = browser.getFile();
49255630 if (filename != null && filename.length() > 0)
....@@ -4996,6 +5701,8 @@
49965701
49975702 void save()
49985703 {
5704
+ Replace();
5705
+
49995706 if (lastname == null)
50005707 {
50015708 return;
....@@ -5018,6 +5725,7 @@
50185725 //ps.print(buffer.toString());
50195726 } catch (IOException e)
50205727 {
5728
+ e.printStackTrace();
50215729 }
50225730 }
50235731
....@@ -5237,6 +5945,7 @@
52375945 ButtonGroup buttonGroup;
52385946
52395947 cGridBag toolboxPanel;
5948
+ cGridBag skyboxPanel;
52405949 cGridBag materialPanel;
52415950 cGridBag ctrlPanel;
52425951
....@@ -5310,7 +6019,7 @@
53106019 JLabel colorLabel;
53116020 cNumberSlider colorField;
53126021 JLabel modulationLabel;
5313
- cNumberSlider modulationField;
6022
+ cNumberSlider saturationField;
53146023 JLabel metalnessLabel;
53156024 cNumberSlider metalnessField;
53166025 JLabel diffuseLabel;
....@@ -5341,6 +6050,7 @@
53416050 cNumberSlider anisoField;
53426051 JLabel anisoVLabel;
53436052 cNumberSlider anisoVField;
6053
+
53446054 JLabel cameraLabel;
53456055 cNumberSlider cameraField;
53466056 JLabel selfshadowLabel;
....@@ -5355,6 +6065,7 @@
53556065 cNumberSlider fakedepthField;
53566066 JLabel shadowbiasLabel;
53576067 cNumberSlider shadowbiasField;
6068
+
53586069 JLabel bumpLabel;
53596070 cNumberSlider bumpField;
53606071 JLabel noiseLabel;