Normand Briere
2019-08-16 83d0c2fa0bd2e96448f776144e1a89cdb1bb6998
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
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
63109 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() > 48 && image.getHeight() > 48)
70
- {
71
- BufferedImage resized = new BufferedImage(48, 48, 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, 48, 48, 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][];
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
331406 // copy.versionindex = -1;
332
- }
407
+//
408
+// Save(true);
409
+// }
333410
334411 SetupMenu();
335412
....@@ -398,6 +475,8 @@
398475
399476 ChangeListener changeListener = new ChangeListener()
400477 {
478
+ //String name;
479
+
401480 public void stateChanged(ChangeEvent changeEvent)
402481 {
403482 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -416,7 +495,37 @@
416495 // EditSelection(false);
417496 // }
418497
419
- refreshContents(false); // To refresh Info tab
498
+// if (objectPanel.getSelectedIndex() == 4)
499
+// {
500
+// name = copy.skyboxname;
501
+//
502
+// if (name == null)
503
+// {
504
+// name = "";
505
+// }
506
+//
507
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
508
+// copy.skyboxext = "jpg";
509
+// }
510
+// else
511
+// {
512
+// if (name != null)
513
+// {
514
+// if (name.equals(""))
515
+// {
516
+// copy.skyboxname = null;
517
+// copy.skyboxext = null;
518
+// }
519
+// else
520
+// {
521
+// copy.skyboxname = name;
522
+// }
523
+// }
524
+// }
525
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
526
+
527
+// refreshContents(false); // To refresh Info tab
528
+ cameraView.repaint();
420529 }
421530 };
422531 objectPanel.addChangeListener(changeListener);
....@@ -439,7 +548,9 @@
439548 toolboxPanel = new cGridBag().setVertical(true);
440549 //toolboxPanel.setName("Toolbox");
441550
442
- materialPanel = new cGridBag().setVertical(true);
551
+ skyboxPanel = new cGridBag().setVertical(true);
552
+
553
+ materialPanel = new cGridBag().setVertical(false);
443554 //materialPanel.setName("Material");
444555
445556 /*JTextPane*/
....@@ -723,6 +834,7 @@
723834 boolean maximized;
724835
725836 cButton fullscreenLayout;
837
+ cButton expandedLayout;
726838
727839 void Minimize()
728840 {
....@@ -762,10 +874,12 @@
762874 cButton minButton;
763875 cButton maxButton;
764876 cButton fullButton;
877
+ cButton collapseButton;
878
+ cButton maximize3DButton;
765879
766880 void ToggleFullScreen()
767881 {
768
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
882
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769883
770884 cameraView.ToggleFullScreen();
771885
....@@ -786,13 +900,13 @@
786900 // X frame.getContentPane().remove(/*"Center",*/bigThree);
787901 // X framePanel.add(bigThree);
788902 // X frame.getContentPane().add(/*"Center",*/framePanel);
789
- framePanel.setDividerLocation(46);
903
+// framePanel.setDividerLocation(46); // icons are 24x24
790904
791905 //frame.setVisible(true);
792
- radio.layout = keepButton;
906
+// radio.layout = keepButton;
793907 //theFrame = null;
794908 keepButton = null;
795
- radio.layout.doClick();
909
+// radio.layout.doClick();
796910
797911 } else
798912 {
....@@ -813,31 +927,48 @@
813927 // X frame.getContentPane().remove(/*"Center",*/framePanel);
814928 // X framePanel.remove(bigThree);
815929 // X frame.getContentPane().add(/*"Center",*/bigThree);
816
- framePanel.setDividerLocation(0);
930
+// framePanel.setDividerLocation(0);
817931
818
- radio.layout = fullscreenLayout;
819
- radio.layout.doClick();
932
+// radio.layout = fullscreenLayout;
933
+// radio.layout.doClick();
820934 //frame.setVisible(true);
821935 }
822936 frame.validate();
937
+
938
+ cameraView.requestFocusInWindow();
823939 }
824940
825
- private byte[] CompressCopy()
941
+ void CollapseToolbar()
942
+ {
943
+ framePanel.setDividerLocation(0);
944
+ //frame.validate();
945
+
946
+ cameraView.requestFocusInWindow();
947
+ }
948
+
949
+ private Object3D Duplicate(Object3D object)
826950 {
827951 boolean temp = CameraPane.SWITCH;
828952 CameraPane.SWITCH = false;
829953
830
- copy.ExtractBigData(versiontable);
954
+ if (Grafreed.grafreed.universe.versiontable == null)
955
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
956
+
957
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
831958 // if (copy == client)
832959
833
- byte[] versions[] = copy.versions;
834
- copy.versions = null;
960
+ Object3D versions[] = object.versionlist;
961
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
962
+ object.versionlist = null;
963
+ object.versiontable = null;
835964
836
- byte[] compress = Compress(copy);
965
+ //byte[] compress = Compress(copy);
966
+ Object3D compress = (Object3D)Grafreed.clone(object);
837967
838
- copy.versions = versions;
968
+ object.versionlist = versions;
969
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
839970
840
- copy.RestoreBigData(versiontable);
971
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
841972
842973 CameraPane.SWITCH = temp;
843974
....@@ -965,6 +1096,7 @@
9651096 {
9661097 SetupMaterial(materialPanel);
9671098 }
1099
+
9681100 //SetupName();
9691101 //SetupViews();
9701102 }
....@@ -1173,6 +1305,18 @@
11731305
11741306 namePanel = new cGridBag();
11751307
1308
+ //if (copy.pinned)
1309
+ {
1310
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1311
+ pinButton.setSelected(copy.pinned);
1312
+ cGridBag t = new cGridBag();
1313
+ t.preferredWidth = 2;
1314
+ t.add(pinButton);
1315
+ namePanel.add(t);
1316
+
1317
+ pinButton.addItemListener(this);
1318
+ }
1319
+
11761320 nameField = AddText(namePanel, copy.GetName());
11771321 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11781322 oe.ctrlPanel.add(namePanel);
....@@ -1186,14 +1330,14 @@
11861330
11871331 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11881332 liveCB.setToolTipText("Animate object");
1333
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1334
+ markCB.setToolTipText("Set target transform");
11891335 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
11901336 selectableCB.setToolTipText("Make object selectable");
11911337 // Return();
11921338
11931339 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11941340 hideCB.setToolTipText("Hide object");
1195
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1196
- markCB.setToolTipText("As animation target transform");
11971341
11981342 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11991343
....@@ -1395,6 +1539,7 @@
13951539
13961540 if (cam == null || !(copy.get(0) instanceof cGroup))
13971541 {
1542
+ if (Globals.DEBUG)
13981543 System.out.println("CREATE CAMERAS");
13991544 cams = new cTemplate();
14001545 cams.name = "Cameras";
....@@ -1520,25 +1665,30 @@
15201665
15211666 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15221667 //tmp.setName("Edit");
1668
+ objectPanel.add(toolboxPanel);
1669
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1670
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1671
+
15231672 objectPanel.add(materialPanel);
1524
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1673
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1674
+ objectPanel.setToolTipTextAt(1, "Material");
1675
+
1676
+ objectPanel.add(skyboxPanel);
1677
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1678
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1679
+
15251680 // JPanel north = new JPanel(new BorderLayout());
15261681 // north.setName("Edit");
15271682 // north.add(ctrlPanel, BorderLayout.NORTH);
15281683 // objectPanel.add(north);
15291684 objectPanel.add(editPanel);
1530
- objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1531
-
1532
- //if (Globals.ADVANCED)
1533
- objectPanel.add(infoPanel);
1534
- objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1685
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1686
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15351687
15361688 objectPanel.add(XYZPanel);
1537
- objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1689
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1690
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15381691
1539
- objectPanel.add(toolboxPanel);
1540
- objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1541
-
15421692 /*
15431693 aConstraints.gridx = 0;
15441694 aConstraints.gridwidth = 1;
....@@ -1575,6 +1725,11 @@
15751725
15761726 scenePanel.add(tabbedPane);
15771727
1728
+ //if (Globals.ADVANCED)
1729
+// tabbedPane.add(infoPanel);
1730
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1731
+// tabbedPane.setToolTipTextAt(3, "Information");
1732
+
15781733 /*
15791734 cTree jTree = new cTree(null);
15801735 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1634,8 +1789,8 @@
16341789 /**/
16351790
16361791 bigThree = new cGridBag();
1637
- bigThree.addComponent(centralPanel);
16381792 bigThree.addComponent(scenePanel);
1793
+ bigThree.addComponent(centralPanel);
16391794 //bigThree.addComponent(XYZPanel);
16401795
16411796 // // SIDE EFFECT!!!
....@@ -1645,6 +1800,23 @@
16451800 // aConstraints.gridheight = 1;
16461801
16471802 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1803
+
1804
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1805
+ new java.beans.PropertyChangeListener()
1806
+ {
1807
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1808
+ {
1809
+ if ((Integer)pce.getOldValue() == 1)
1810
+ {
1811
+ if (radio.layout != expandedLayout)
1812
+ {
1813
+ radio.layout = expandedLayout;
1814
+ radio.layout.doClick();
1815
+ }
1816
+ }
1817
+ }
1818
+ });
1819
+
16481820 framePanel.setContinuousLayout(false);
16491821 framePanel.setOneTouchExpandable(false);
16501822 //.setDividerLocation(0.8);
....@@ -1654,7 +1826,7 @@
16541826
16551827 frame.getContentPane().setLayout(new BorderLayout());
16561828 /**/
1657
- JTabbedPane worldPane = new JTabbedPane();
1829
+ //JTabbedPane worldPane = new JTabbedPane();
16581830 //worldPane.add(bigPanel);
16591831 //worldPane.add(worldPanel);
16601832 /**/
....@@ -1677,7 +1849,6 @@
16771849 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16781850 frame.addWindowListener(new WindowAdapter()
16791851 {
1680
-
16811852 public void windowClosing(WindowEvent e)
16821853 {
16831854 Close();
....@@ -1700,12 +1871,418 @@
17001871 ctrlPanel.removeAll();
17011872 }
17021873
1703
- void SetupMaterial(cGridBag panel)
1874
+ void SetupMaterial(cGridBag materialpanel)
17041875 {
1705
- /*
1876
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1877
+
1878
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1879
+ skin.setToolTipText("Skin");
1880
+ skin.addMouseListener(new MouseAdapter()
1881
+ {
1882
+ public void mouseClicked(MouseEvent e)
1883
+ {
1884
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1885
+ cMaterial material = object.material;
1886
+
1887
+ // Skin
1888
+ colorField.setFloat(material.color);
1889
+ saturationField.setFloat(material.modulation);
1890
+ subsurfaceField.setFloat(material.subsurface);
1891
+ selfshadowField.setFloat(material.diffuseness);
1892
+ diffusenessField.setFloat(material.factor);
1893
+ shininessField.setFloat(material.shininess);
1894
+ shadowbiasField.setFloat(material.shadowbias);
1895
+ diffuseField.setFloat(material.diffuse);
1896
+ specularField.setFloat(material.specular);
1897
+
1898
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1899
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1900
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1901
+
1902
+ materialtouched = true;
1903
+ applySelf();
1904
+ }
1905
+ });
1906
+ presetpanel.add(skin);
1907
+
1908
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1909
+ lambert.setToolTipText("Diffuse");
1910
+ lambert.addMouseListener(new MouseAdapter()
1911
+ {
1912
+ public void mouseClicked(MouseEvent e)
1913
+ {
1914
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1915
+ cMaterial material = object.material;
1916
+
1917
+ diffusenessField.setFloat(material.factor);
1918
+ selfshadowField.setFloat(material.diffuseness);
1919
+
1920
+ materialtouched = true;
1921
+ applySelf();
1922
+ }
1923
+ });
1924
+ presetpanel.add(lambert);
1925
+
1926
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1927
+ diffuse2.setToolTipText("Diffuse2");
1928
+ diffuse2.addMouseListener(new MouseAdapter()
1929
+ {
1930
+ public void mouseClicked(MouseEvent e)
1931
+ {
1932
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1933
+ cMaterial material = object.material;
1934
+
1935
+ diffusenessField.setFloat(material.factor);
1936
+ selfshadowField.setFloat(material.diffuseness);
1937
+
1938
+ materialtouched = true;
1939
+ applySelf();
1940
+ }
1941
+ });
1942
+ presetpanel.add(diffuse2);
1943
+
1944
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1945
+ diffusemoon.setToolTipText("Moon");
1946
+ diffusemoon.addMouseListener(new MouseAdapter()
1947
+ {
1948
+ public void mouseClicked(MouseEvent e)
1949
+ {
1950
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1951
+ cMaterial material = object.material;
1952
+
1953
+ diffusenessField.setFloat(material.factor);
1954
+ selfshadowField.setFloat(material.diffuseness);
1955
+
1956
+ materialtouched = true;
1957
+ applySelf();
1958
+ }
1959
+ });
1960
+ presetpanel.add(diffusemoon);
1961
+
1962
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1963
+ diffusemoon2.setToolTipText("Moon2");
1964
+ diffusemoon2.addMouseListener(new MouseAdapter()
1965
+ {
1966
+ public void mouseClicked(MouseEvent e)
1967
+ {
1968
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1969
+ cMaterial material = object.material;
1970
+
1971
+ diffusenessField.setFloat(material.factor);
1972
+ selfshadowField.setFloat(material.diffuseness);
1973
+
1974
+ materialtouched = true;
1975
+ applySelf();
1976
+ }
1977
+ });
1978
+ presetpanel.add(diffusemoon2);
1979
+
1980
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1981
+ diffusemoon3.setToolTipText("Moon3");
1982
+ diffusemoon3.addMouseListener(new MouseAdapter()
1983
+ {
1984
+ public void mouseClicked(MouseEvent e)
1985
+ {
1986
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1987
+ cMaterial material = object.material;
1988
+
1989
+ diffusenessField.setFloat(material.factor);
1990
+ selfshadowField.setFloat(material.diffuseness);
1991
+
1992
+ materialtouched = true;
1993
+ applySelf();
1994
+ }
1995
+ });
1996
+ presetpanel.add(diffusemoon3);
1997
+
1998
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1999
+ diffusesheen.setToolTipText("Sheen");
2000
+ diffusesheen.addMouseListener(new MouseAdapter()
2001
+ {
2002
+ public void mouseClicked(MouseEvent e)
2003
+ {
2004
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2005
+ cMaterial material = object.material;
2006
+
2007
+ sheenField.setFloat(material.sheen);
2008
+
2009
+ materialtouched = true;
2010
+ applySelf();
2011
+ }
2012
+ });
2013
+ presetpanel.add(diffusesheen);
2014
+
2015
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2016
+ rough.setToolTipText("Rough metal");
2017
+ rough.addMouseListener(new MouseAdapter()
2018
+ {
2019
+ public void mouseClicked(MouseEvent e)
2020
+ {
2021
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2022
+ cMaterial material = object.material;
2023
+
2024
+ shininessField.setFloat(material.shininess);
2025
+ velvetField.setFloat(material.velvet);
2026
+
2027
+ materialtouched = true;
2028
+ applySelf();
2029
+ }
2030
+ });
2031
+ presetpanel.add(rough);
2032
+
2033
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2034
+ rough2.setToolTipText("Medium metal");
2035
+ rough2.addMouseListener(new MouseAdapter()
2036
+ {
2037
+ public void mouseClicked(MouseEvent e)
2038
+ {
2039
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2040
+ cMaterial material = object.material;
2041
+
2042
+ shininessField.setFloat(material.shininess);
2043
+ lightareaField.setFloat(material.lightarea);
2044
+
2045
+ materialtouched = true;
2046
+ applySelf();
2047
+ }
2048
+ });
2049
+ presetpanel.add(rough2);
2050
+
2051
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2052
+ shini0.setToolTipText("Shiny");
2053
+ shini0.addMouseListener(new MouseAdapter()
2054
+ {
2055
+ public void mouseClicked(MouseEvent e)
2056
+ {
2057
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2058
+ cMaterial material = object.material;
2059
+
2060
+ shininessField.setFloat(material.shininess);
2061
+ lightareaField.setFloat(material.lightarea);
2062
+
2063
+ materialtouched = true;
2064
+ applySelf();
2065
+ }
2066
+ });
2067
+ presetpanel.add(shini0);
2068
+
2069
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2070
+ shini1.setToolTipText("Shiny2");
2071
+ shini1.addMouseListener(new MouseAdapter()
2072
+ {
2073
+ public void mouseClicked(MouseEvent e)
2074
+ {
2075
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2076
+ cMaterial material = object.material;
2077
+
2078
+ shininessField.setFloat(material.shininess);
2079
+ lightareaField.setFloat(material.lightarea);
2080
+
2081
+ materialtouched = true;
2082
+ applySelf();
2083
+ }
2084
+ });
2085
+ presetpanel.add(shini1);
2086
+
2087
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2088
+ shini2.setToolTipText("Shiny3");
2089
+ shini2.addMouseListener(new MouseAdapter()
2090
+ {
2091
+ public void mouseClicked(MouseEvent e)
2092
+ {
2093
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2094
+ cMaterial material = object.material;
2095
+
2096
+ shininessField.setFloat(material.shininess);
2097
+ lightareaField.setFloat(material.lightarea);
2098
+
2099
+ materialtouched = true;
2100
+ applySelf();
2101
+ }
2102
+ });
2103
+ presetpanel.add(shini2);
2104
+
2105
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2106
+ aniso.setToolTipText("AnisoU");
2107
+ aniso.addMouseListener(new MouseAdapter()
2108
+ {
2109
+ public void mouseClicked(MouseEvent e)
2110
+ {
2111
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2112
+ cMaterial material = object.material;
2113
+
2114
+ anisoField.setFloat(material.aniso);
2115
+ anisoVField.setFloat(material.anisoV);
2116
+
2117
+ materialtouched = true;
2118
+ applySelf();
2119
+ }
2120
+ });
2121
+ presetpanel.add(aniso);
2122
+
2123
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2124
+ aniso2.setToolTipText("AnisoV");
2125
+ aniso2.addMouseListener(new MouseAdapter()
2126
+ {
2127
+ public void mouseClicked(MouseEvent e)
2128
+ {
2129
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2130
+ cMaterial material = object.material;
2131
+
2132
+ anisoField.setFloat(material.aniso);
2133
+ anisoVField.setFloat(material.anisoV);
2134
+
2135
+ materialtouched = true;
2136
+ applySelf();
2137
+ }
2138
+ });
2139
+ presetpanel.add(aniso2);
2140
+
2141
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2142
+ aniso3.setToolTipText("AnisoUV");
2143
+ aniso3.addMouseListener(new MouseAdapter()
2144
+ {
2145
+ public void mouseClicked(MouseEvent e)
2146
+ {
2147
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2148
+ cMaterial material = object.material;
2149
+
2150
+ anisoField.setFloat(material.aniso);
2151
+ anisoVField.setFloat(material.anisoV);
2152
+
2153
+ materialtouched = true;
2154
+ applySelf();
2155
+ }
2156
+ });
2157
+ presetpanel.add(aniso3);
2158
+
2159
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2160
+ velvet0.setToolTipText("Velvet");
2161
+ velvet0.addMouseListener(new MouseAdapter()
2162
+ {
2163
+ public void mouseClicked(MouseEvent e)
2164
+ {
2165
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2166
+ cMaterial material = object.material;
2167
+
2168
+ diffusenessField.setFloat(material.factor);
2169
+ selfshadowField.setFloat(material.diffuseness);
2170
+ sheenField.setFloat(material.sheen);
2171
+ shininessField.setFloat(material.shininess);
2172
+ velvetField.setFloat(material.velvet);
2173
+ shiftField.setFloat(material.shift);
2174
+
2175
+ materialtouched = true;
2176
+ applySelf();
2177
+ }
2178
+ });
2179
+ presetpanel.add(velvet0);
2180
+
2181
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2182
+ bump0.setToolTipText("Bump texture");
2183
+ bump0.addMouseListener(new MouseAdapter()
2184
+ {
2185
+ public void mouseClicked(MouseEvent e)
2186
+ {
2187
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2188
+ cMaterial material = object.material;
2189
+
2190
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2191
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2192
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2193
+
2194
+ materialtouched = true;
2195
+ applySelf();
2196
+ }
2197
+ });
2198
+ presetpanel.add(bump0);
2199
+
2200
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2201
+ borderShader.setToolTipText("Border fade");
2202
+ borderShader.addMouseListener(new MouseAdapter()
2203
+ {
2204
+ public void mouseClicked(MouseEvent e)
2205
+ {
2206
+ borderfadeField.setFloat(0.5);
2207
+ opacityField.setFloat(0.75);
2208
+
2209
+ materialtouched = true;
2210
+ applySelf();
2211
+ }
2212
+ });
2213
+ presetpanel.add(borderShader);
2214
+
2215
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2216
+ halo.setToolTipText("Halo");
2217
+ halo.addMouseListener(new MouseAdapter()
2218
+ {
2219
+ public void mouseClicked(MouseEvent e)
2220
+ {
2221
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2222
+ cMaterial material = object.material;
2223
+
2224
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2225
+
2226
+ materialtouched = true;
2227
+ applySelf();
2228
+ }
2229
+ });
2230
+ presetpanel.add(halo);
2231
+
2232
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2233
+ candle.setToolTipText("Candle");
2234
+ candle.addMouseListener(new MouseAdapter()
2235
+ {
2236
+ public void mouseClicked(MouseEvent e)
2237
+ {
2238
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2239
+ cMaterial material = object.material;
2240
+
2241
+ subsurfaceField.setFloat(material.subsurface);
2242
+ shadowbiasField.setFloat(material.shadowbias);
2243
+ ambientField.setFloat(material.ambient);
2244
+ specularField.setFloat(material.specular);
2245
+ lightareaField.setFloat(material.lightarea);
2246
+ shininessField.setFloat(material.shininess);
2247
+
2248
+ materialtouched = true;
2249
+ applySelf();
2250
+ }
2251
+ });
2252
+ presetpanel.add(candle);
2253
+
2254
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2255
+ shadowShader.setToolTipText("Shadow");
2256
+ shadowShader.addMouseListener(new MouseAdapter()
2257
+ {
2258
+ public void mouseClicked(MouseEvent e)
2259
+ {
2260
+ diffuseField.setFloat(0.001);
2261
+ ambientField.setFloat(0.001);
2262
+ cameraField.setFloat(0.001);
2263
+ specularField.setFloat(0.001);
2264
+ fakedepthField.setFloat(0.001);
2265
+ opacityField.setFloat(0.6);
2266
+
2267
+ materialtouched = true;
2268
+ applySelf();
2269
+ }
2270
+ });
2271
+ presetpanel.add(shadowShader);
2272
+
2273
+ cGridBag panel = new cGridBag().setVertical(true);
2274
+
2275
+ presetpanel.preferredWidth = 1;
2276
+
2277
+ materialpanel.add(presetpanel);
2278
+ materialpanel.add(panel);
2279
+
2280
+ panel.preferredWidth = 8;
2281
+
2282
+ /*
17062283 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17072284 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1708
- */
2285
+ */
17092286
17102287 cGridBag editBar = new cGridBag().setVertical(false);
17112288
....@@ -1739,27 +2316,61 @@
17392316 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17402317
17412318 cGridBag colorSection = new cGridBag().setVertical(true);
2319
+
2320
+ cGridBag huepanel = new cGridBag();
2321
+ cGridBag huelabel = new cGridBag();
2322
+ cLabel hue = GetLabel("icons/hue.png", false);
2323
+ hue.fit = true;
2324
+
2325
+ hue.addMouseListener(new MouseAdapter()
2326
+ {
2327
+ public void mousePressed(MouseEvent e)
2328
+ {
2329
+ int x = e.getX();
2330
+
2331
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2332
+ }
2333
+ });
2334
+
2335
+ huelabel.add(hue);
2336
+ huelabel.preferredWidth = 20;
2337
+ huepanel.add(new cGridBag()); // Label
2338
+ huepanel.add(huelabel); // Field/slider
2339
+
2340
+ huepanel.preferredHeight = 7;
2341
+
2342
+ colorSection.add(huepanel);
17422343
17432344 cGridBag color = new cGridBag();
1744
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1745
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1746
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2345
+
2346
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2347
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2348
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2349
+
17472350 //colorField.preferredWidth = 200;
17482351 colorSection.add(color);
17492352
17502353 cGridBag modulation = new cGridBag();
17512354 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17522355 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1753
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2356
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17542357 colorSection.add(modulation);
17552358
2359
+ cGridBag opacity = new cGridBag();
2360
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2361
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2362
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2363
+ colorSection.add(opacity);
2364
+
2365
+ colorSection.add(GetSeparator());
2366
+
17562367 cGridBag texture = new cGridBag();
17572368 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17582369 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17592370 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17602371 colorSection.add(texture);
17612372
1762
- panel.add(new JSeparator());
2373
+ panel.add(GetSeparator());
17632374
17642375 panel.add(colorSection);
17652376
....@@ -1815,7 +2426,7 @@
18152426 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18162427 diffuseSection.add(shadowbias);
18172428
1818
- panel.add(new JSeparator());
2429
+ panel.add(GetSeparator());
18192430
18202431 panel.add(diffuseSection);
18212432
....@@ -1878,7 +2489,7 @@
18782489 specularSection.add(anisoV);
18792490
18802491
1881
- panel.add(new JSeparator());
2492
+ panel.add(GetSeparator());
18822493
18832494 panel.add(specularSection);
18842495
....@@ -1903,12 +2514,6 @@
19032514 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19042515 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19052516 colorSection.add(backlit);
1906
-
1907
- cGridBag opacity = new cGridBag();
1908
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1909
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1910
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1911
- colorSection.add(opacity);
19122517
19132518 //panel.add(new JSeparator());
19142519
....@@ -1954,7 +2559,7 @@
19542559 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19552560 textureSection.add(opacityPower);
19562561
1957
- panel.add(new JSeparator());
2562
+ panel.add(GetSeparator());
19582563
19592564 panel.add(textureSection);
19602565
....@@ -2941,7 +3546,7 @@
29413546
29423547 freezematerial = true;
29433548 colorField.setFloat(mat.color);
2944
- modulationField.setFloat(mat.modulation);
3549
+ saturationField.setFloat(mat.modulation);
29453550 metalnessField.setFloat(mat.metalness);
29463551 diffuseField.setFloat(mat.diffuse);
29473552 specularField.setFloat(mat.specular);
....@@ -3003,32 +3608,8 @@
30033608
30043609 if (multiplyToggle != null)
30053610 multiplyToggle.setSelected(mat.multiply);
3006
-
3007
- assert (object.projectedVertices != null);
3008
-
3009
- if (object.projectedVertices.length <= 2)
3010
- {
3011
- // Side effect...
3012
- Object3D.cVector2[] keep = object.projectedVertices;
3013
- object.projectedVertices = new Object3D.cVector2[3];
3014
- for (int i = 0; i < 3; i++)
3015
- {
3016
- if (i < keep.length)
3017
- {
3018
- object.projectedVertices[i] = keep[i];
3019
- } else
3020
- {
3021
- object.projectedVertices[i] = new Object3D.cVector2();
3022
- }
3023
- /*
3024
- if(keep.length == 0)
3025
- object.projectedVertices[0] = new Object3D.cVector2();
3026
- else
3027
- object.projectedVertices[0] = keep[0];
3028
- object.projectedVertices[1] = new Object3D.cVector2();
3029
- */
3030
- }
3031
- }
3611
+
3612
+ AllocProjectedVertices(object);
30323613
30333614 SetMaterial(mat, object.projectedVertices);
30343615 }
....@@ -3148,6 +3729,17 @@
31483729 public void itemStateChanged(ItemEvent event)
31493730 {
31503731 // System.out.println("Propagate = " + propagate);
3732
+ if (event.getSource() == pinButton)
3733
+ {
3734
+ copy.pinned ^= true;
3735
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3736
+ {
3737
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3738
+ copy.CloseUI();
3739
+ //copy.editWindow.refreshContents();
3740
+ }
3741
+ }
3742
+ else
31513743 if (event.getSource() == propagateToggle)
31523744 {
31533745 propagate ^= true;
....@@ -3252,6 +3844,7 @@
32523844 } else if (event.getSource() == liveCB)
32533845 {
32543846 copy.live ^= true;
3847
+ objEditor.refreshContents(true); // To show item colors
32553848 return;
32563849 } else if (event.getSource() == selectableCB)
32573850 {
....@@ -3261,7 +3854,7 @@
32613854 {
32623855 copy.hide ^= true;
32633856 copy.Touch(); // display list issue
3264
- objEditor.refreshContents();
3857
+ objEditor.refreshContents(true); // To show item colors
32653858 return;
32663859 } else if (event.getSource() == link2masterCB)
32673860 {
....@@ -3326,7 +3919,7 @@
33263919 //System.out.println("ObjEditor " + event);
33273920 applySelf0(true);
33283921 //parent.applySelf();
3329
- objEditor.refreshContents();
3922
+ // conflicts with requestFocus objEditor.refreshContents();
33303923 } else if (source == resetButton)
33313924 {
33323925 CameraPane.fullreset = true;
....@@ -3517,6 +4110,7 @@
35174110
35184111 static public byte[] Compress(Object3D o)
35194112 {
4113
+ // Slower to actually compress.
35204114 try
35214115 {
35224116 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3618,6 +4212,7 @@
36184212 {
36194213 //Save(true);
36204214 Replace();
4215
+ SetVersionStates();
36214216 }
36224217
36234218 private boolean Equal(byte[] compress, byte[] name)
....@@ -3636,31 +4231,50 @@
36364231 return true;
36374232 }
36384233
3639
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4234
+ void DeleteVersion()
4235
+ {
4236
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4237
+ {
4238
+ copy.versionlist[i] = copy.versionlist[i+1];
4239
+ }
4240
+
4241
+ if (copy.versionlist[copy.versionindex] == null)
4242
+ copy.versionindex -= 1;
4243
+
4244
+ if (copy.versionindex != -1)
4245
+ CopyChanged();
4246
+
4247
+ SetVersionStates();
4248
+ }
36404249
36414250 public boolean Save(boolean user)
36424251 {
36434252 System.err.println("Save");
4253
+ Replace();
36444254
3645
- cRadio tab = GetCurrentTab();
4255
+ //cRadio tab = GetCurrentTab();
36464256
3647
- byte[] compress = CompressCopy();
4257
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36484258
36494259 boolean thesame = false;
36504260
3651
- // Quick heuristic using length. Works only when stream is compressed.
3652
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3653
- {
3654
- thesame = true;
3655
- }
4261
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4262
+// {
4263
+// thesame = true;
4264
+// }
36564265
36574266 //EditorFrame.m_MainFrame.requestFocusInWindow();
36584267 if (!thesame)
36594268 {
4269
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4270
+ {
4271
+ copy.versionlist[i] = copy.versionlist[i-1];
4272
+ }
4273
+
36604274 //tab.user[tab.versionindex] = user;
36614275 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36624276
3663
- copy.versions[++copy.versionindex] = compress;
4277
+ copy.versionlist[++copy.versionindex] = compress;
36644278
36654279 // if (increment)
36664280 // tab.versionindex++;
....@@ -3670,13 +4284,13 @@
36704284
36714285 //assert(hashtable.isEmpty());
36724286
3673
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3674
- {
3675
- //tab.user[i] = false;
3676
- copy.versions[i] = null;
3677
- }
4287
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4288
+// {
4289
+// //tab.user[i] = false;
4290
+// copy.versionlist[i] = null;
4291
+// }
36784292
3679
- SetUndoStates();
4293
+ SetVersionStates();
36804294
36814295 // test save
36824296 if (false)
....@@ -3699,27 +4313,65 @@
36994313
37004314 return !thesame;
37014315 }
3702
-
3703
- void CopyChanged(Object3D obj)
4316
+
4317
+ boolean flashIt = true;
4318
+
4319
+ void RefreshSelection()
37044320 {
3705
- SetUndoStates();
4321
+ Object3D selection = new Object3D();
4322
+
4323
+ for (int i = 0; i < copy.selection.size(); i++)
4324
+ {
4325
+ Object3D elem = copy.selection.elementAt(i);
4326
+
4327
+ Object3D obj = copy.GetObject(elem.GetUUID());
4328
+
4329
+ if (obj == null)
4330
+ {
4331
+ copy.selection.remove(i--);
4332
+ }
4333
+ else
4334
+ {
4335
+ selection.add(obj);
4336
+ copy.selection.setElementAt(obj, i);
4337
+ }
4338
+ }
4339
+
4340
+ flashIt = false;
4341
+ GetTree().clearSelection();
4342
+ for (int i = 0; i < selection.size(); i++)
4343
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4344
+ flashIt = true;
4345
+
4346
+ //refreshContents(false);
4347
+ }
4348
+
4349
+ void CopyChanged()
4350
+ {
4351
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4352
+
4353
+ SetVersionStates();
37064354
37074355 boolean temp = CameraPane.SWITCH;
37084356 CameraPane.SWITCH = false;
37094357
3710
- copy.ExtractBigData(versiontable);
4358
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
37114359
37124360 copy.clear();
37134361
4362
+ copy.skyboxname = obj.skyboxname;
4363
+ copy.skyboxext = obj.skyboxext;
4364
+
37144365 for (int i=0; i<obj.Size(); i++)
37154366 {
37164367 copy.add(obj.get(i));
37174368 }
37184369
3719
- copy.RestoreBigData(versiontable);
4370
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
37204371
37214372 CameraPane.SWITCH = temp;
37224373
4374
+ RefreshSelection();
37234375 //assert(hashtable.isEmpty());
37244376
37254377 copy.Touch();
....@@ -3740,13 +4392,15 @@
37404392 }
37414393 }
37424394
3743
- refreshContents();
4395
+ refreshContents(true);
37444396 }
37454397
3746
- cButton undoButton;
4398
+ cButton previousVersionButton;
37474399 cButton restoreButton;
37484400 cButton replaceButton;
3749
- cButton redoButton;
4401
+ cButton nextVersionButton;
4402
+ cButton saveVersionButton;
4403
+ cButton deleteVersionButton;
37504404
37514405 boolean muteSlider;
37524406
....@@ -3754,39 +4408,47 @@
37544408 {
37554409 int count = 0;
37564410
3757
- for (int i = copy.versions.length; --i >= 0;)
4411
+ for (int i = copy.versionlist.length; --i >= 0;)
37584412 {
3759
- if (copy.versions[i] != null)
4413
+ if (copy.versionlist[i] != null)
37604414 count++;
37614415 }
37624416
37634417 return count;
37644418 }
37654419
3766
- void SetUndoStates()
4420
+ void SetVersionStates()
37674421 {
3768
- cRadio tab = GetCurrentTab();
4422
+ //if (true)
4423
+ // return;
4424
+
4425
+ //cRadio tab = GetCurrentTab();
37694426
37704427 restoreButton.setEnabled(copy.versionindex != -1);
37714428 replaceButton.setEnabled(copy.versionindex != -1);
37724429
3773
- undoButton.setEnabled(copy.versionindex > 0);
3774
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4430
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4431
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4432
+
4433
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4434
+ //copy.versionlist[copy.versionindex + 1] != null);
37754435
37764436 muteSlider = true;
4437
+ versionSlider.setMinimum(0);
37774438 versionSlider.setMaximum(VersionCount() - 1);
37784439 versionSlider.setInteger(copy.versionindex);
4440
+ versionSlider.setEnabled(copy.versionindex != -1);
37794441 muteSlider = false;
37804442 }
37814443
3782
- public boolean Undo()
4444
+ public boolean PreviousVersion()
37834445 {
37844446 // Option?
37854447 Replace();
37864448
37874449 System.err.println("Undo");
37884450
3789
- cRadio tab = GetCurrentTab();
4451
+ //cRadio tab = GetCurrentTab();
37904452
37914453 if (copy.versionindex == 0)
37924454 {
....@@ -3809,7 +4471,7 @@
38094471
38104472 copy.versionindex -= 1;
38114473
3812
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4474
+ CopyChanged();
38134475
38144476 return true;
38154477 }
....@@ -3818,44 +4480,45 @@
38184480 {
38194481 System.err.println("Restore");
38204482
3821
- cRadio tab = GetCurrentTab();
4483
+ //cRadio tab = GetCurrentTab();
38224484
3823
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4485
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38244486 {
38254487 java.awt.Toolkit.getDefaultToolkit().beep();
38264488 return false;
38274489 }
38284490
3829
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4491
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4492
+ CopyChanged();
38304493
38314494 return true;
38324495 }
38334496
38344497 public boolean Replace()
38354498 {
3836
- System.err.println("Replace");
4499
+ //System.err.println("Replace");
38374500
3838
- cRadio tab = GetCurrentTab();
4501
+ //cRadio tab = GetCurrentTab();
38394502
3840
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4503
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38414504 {
38424505 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38434506 return false;
38444507 }
38454508
3846
- copy.versions[copy.versionindex] = CompressCopy();
4509
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38474510
38484511 return true;
38494512 }
38504513
3851
- public void Redo()
4514
+ public void NextVersion()
38524515 {
38534516 // Option?
38544517 Replace();
38554518
3856
- cRadio tab = GetCurrentTab();
4519
+ //cRadio tab = GetCurrentTab();
38574520
3858
- if (copy.versions[copy.versionindex + 1] == null)
4521
+ if (copy.versionlist[copy.versionindex + 1] == null)
38594522 {
38604523 java.awt.Toolkit.getDefaultToolkit().beep();
38614524 return;
....@@ -3863,7 +4526,7 @@
38634526
38644527 copy.versionindex += 1;
38654528
3866
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4529
+ CopyChanged();
38674530
38684531 //if (!tab.user[tab.versionindex])
38694532 // tab.graphs[tab.versionindex] = null;
....@@ -4077,7 +4740,7 @@
40774740 //copy.material = new cMaterial(copy.GetMaterial());
40784741
40794742 current.color = (float) colorField.getFloat();
4080
- current.modulation = (float) modulationField.getFloat();
4743
+ current.modulation = (float) saturationField.getFloat();
40814744 current.metalness = (float) metalnessField.getFloat();
40824745 current.diffuse = (float) diffuseField.getFloat();
40834746 current.specular = (float) specularField.getFloat();
....@@ -4110,7 +4773,7 @@
41104773 cMaterial mat = copy.material;
41114774
41124775 colorField.SetToolTipValue((mat.color));
4113
- modulationField.SetToolTipValue((mat.modulation));
4776
+ saturationField.SetToolTipValue((mat.modulation));
41144777 metalnessField.SetToolTipValue((mat.metalness));
41154778 diffuseField.SetToolTipValue((mat.diffuse));
41164779 specularField.SetToolTipValue((mat.specular));
....@@ -4172,11 +4835,14 @@
41724835 if (muteSlider)
41734836 return;
41744837
4838
+ Replace();
4839
+
41754840 int version = versionSlider.getInteger();
41764841
4177
- if (copy.versions[version] != null)
4842
+ if (version != -1 && copy.versionlist[version] != null)
41784843 {
4179
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4844
+ copy.versionindex = version;
4845
+ CopyChanged();
41804846 }
41814847
41824848 return;
....@@ -4216,6 +4882,12 @@
42164882 {
42174883 //System.out.println("stateChanged = " + this);
42184884 materialtouched = true;
4885
+
4886
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4887
+ {
4888
+ saturationField.setFloat(1);
4889
+ }
4890
+
42194891 applySelf();
42204892 //System.out.println("this = " + this);
42214893 //System.out.println("PARENT = " + parent);
....@@ -4515,6 +5187,7 @@
45155187 {
45165188 if (GetTree() != null)
45175189 {
5190
+ GetTree().revalidate();
45185191 GetTree().repaint();
45195192 }
45205193
....@@ -4523,6 +5196,11 @@
45235196 ctrlPanel.validate(); // ? new
45245197 ctrlPanel.repaint();
45255198 }
5199
+
5200
+ if (previousVersionButton != null && copy.versionlist != null)
5201
+ SetVersionStates();
5202
+
5203
+ cameraView.requestFocusInWindow();
45265204 }
45275205
45285206 static TweenManager tweenManager = new TweenManager();
....@@ -4554,7 +5232,7 @@
45545232 // group = (Composite) group.get(0);
45555233 // }
45565234
4557
- System.out.println("makeSomething of " + thing);
5235
+ //System.out.println("makeSomething of " + thing);
45585236
45595237 /*
45605238 if (deselect && jList != null)
....@@ -4853,6 +5531,8 @@
48535531 {
48545532 //readobj.deepCopySelf(copy);
48555533 copy.clear(); // june 2014
5534
+ copy.skyboxname = readobj.skyboxname;
5535
+ copy.skyboxext = readobj.skyboxext;
48565536 for (int i = 0; i < readobj.size(); i++)
48575537 {
48585538 Object3D child = readobj.get(i); // reserve(i);
....@@ -4904,13 +5584,17 @@
49045584 c.addChild(csg);
49055585 }
49065586
4907
- copy.versions = readobj.versions;
5587
+ copy.versionlist = readobj.versionlist;
49085588 copy.versionindex = readobj.versionindex;
5589
+ copy.versiontable = readobj.versiontable;
49095590
4910
- if (copy.versions == null)
5591
+ if (copy.versionlist == null)
49115592 {
4912
- copy.versions = new byte[100][];
5593
+ // Backward compatibility
5594
+ copy.versionlist = new Object3D[100];
49135595 copy.versionindex = -1;
5596
+
5597
+ //Save(true);
49145598 }
49155599
49165600 //? SetUndoStates();
....@@ -4925,7 +5609,7 @@
49255609 {
49265610 if (Grafreed.standAlone)
49275611 {
4928
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5612
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49295613 browser.show();
49305614 String filename = browser.getFile();
49315615 if (filename != null && filename.length() > 0)
....@@ -5002,6 +5686,8 @@
50025686
50035687 void save()
50045688 {
5689
+ Replace();
5690
+
50055691 if (lastname == null)
50065692 {
50075693 return;
....@@ -5244,6 +5930,7 @@
52445930 ButtonGroup buttonGroup;
52455931
52465932 cGridBag toolboxPanel;
5933
+ cGridBag skyboxPanel;
52475934 cGridBag materialPanel;
52485935 cGridBag ctrlPanel;
52495936
....@@ -5317,7 +6004,7 @@
53176004 JLabel colorLabel;
53186005 cNumberSlider colorField;
53196006 JLabel modulationLabel;
5320
- cNumberSlider modulationField;
6007
+ cNumberSlider saturationField;
53216008 JLabel metalnessLabel;
53226009 cNumberSlider metalnessField;
53236010 JLabel diffuseLabel;
....@@ -5348,6 +6035,7 @@
53486035 cNumberSlider anisoField;
53496036 JLabel anisoVLabel;
53506037 cNumberSlider anisoVField;
6038
+
53516039 JLabel cameraLabel;
53526040 cNumberSlider cameraField;
53536041 JLabel selfshadowLabel;
....@@ -5362,6 +6050,7 @@
53626050 cNumberSlider fakedepthField;
53636051 JLabel shadowbiasLabel;
53646052 cNumberSlider shadowbiasField;
6053
+
53656054 JLabel bumpLabel;
53666055 cNumberSlider bumpField;
53676056 JLabel noiseLabel;