Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
ObjEditor.java
....@@ -41,64 +41,78 @@
4141 JFrame frame;
4242
4343 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4452
4553 cButton GetButton(String name, boolean border)
4654 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5663 }
5764
5865 cToggleButton GetToggleButton(String name, boolean border)
5966 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6969 }
7070
7171 cCheckBox GetCheckBox(String name, boolean border)
7272 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7379 try
7480 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7797 }
7898 catch (Exception e)
7999 {
80
- return new cCheckBox(name, border);
100
+ return null;
81101 }
82102 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
85105 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
89107 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
98111 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
102116 }
103117
104118 // SCRIPT
....@@ -282,6 +296,12 @@
282296 client = inClient;
283297 copy = client;
284298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
285305 // "this" is not called: SetupUI2(objEditor);
286306 }
287307
....@@ -295,6 +315,12 @@
295315 client = inClient;
296316 copy = client;
297317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
298324 SetupUI2(callee.GetEditor());
299325 }
300326
....@@ -327,6 +353,12 @@
327353 copy = localCopy;
328354 copy.editWindow = this;
329355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
330362 SetupMenu();
331363
332364 //SetupName(objEditor); // new
....@@ -419,11 +451,12 @@
419451
420452 toolbarPanel = new JPanel();
421453 toolbarPanel.setName("Toolbar");
454
+
422455 treePanel = new cGridBag();
423456 treePanel.setName("Tree");
424457
425458 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
427460
428461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429462
....@@ -431,11 +464,11 @@
431464 editPanel.add(editCommandsPanel);
432465 editPanel.add(ctrlPanel);
433466
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
436469
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
439472
440473 /*JTextPane*/
441474 infoarea = createTextPane();
....@@ -443,6 +476,7 @@
443476
444477 infoarea.setEditable(true);
445478 SetText();
479
+
446480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447481 // infoarea.setOpaque(false);
448482 // //infoarea.setForeground(textcolor);
....@@ -450,7 +484,7 @@
450484 // TEXTAREA infoarea.setWrapStyleWord(true);
451485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452486 infoPanel.setPreferredSize(new Dimension(1, 1));
453
- infoPanel.setName("Info");
487
+ //infoPanel.setName("Info");
454488 //infoPanel.setLayout(new BorderLayout());
455489 //infoPanel.add(createTextPane());
456490
....@@ -814,9 +848,11 @@
814848 //frame.setVisible(true);
815849 }
816850 frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
817853 }
818854
819
- private byte[] CompressCopy()
855
+ private Object3D CompressCopy()
820856 {
821857 boolean temp = CameraPane.SWITCH;
822858 CameraPane.SWITCH = false;
....@@ -824,12 +860,13 @@
824860 copy.ExtractBigData(versiontable);
825861 // if (copy == client)
826862
827
- byte[] versions[] = copy.versions;
828
- copy.versions = null;
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
829865
830
- byte[] compress = Compress(copy);
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
831868
832
- copy.versions = versions;
869
+ copy.versionlist = versions;
833870
834871 copy.RestoreBigData(versiontable);
835872
....@@ -959,6 +996,7 @@
959996 {
960997 SetupMaterial(materialPanel);
961998 }
999
+
9621000 //SetupName();
9631001 //SetupViews();
9641002 }
....@@ -968,7 +1006,7 @@
9681006 // NumberSlider vDivsField;
9691007 // JCheckBox endcaps;
9701008 JCheckBox liveCB;
971
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9721010 JCheckBox hideCB;
9731011 JCheckBox link2masterCB;
9741012 JCheckBox markCB;
....@@ -1180,13 +1218,16 @@
11801218
11811219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11821220 liveCB.setToolTipText("Animate object");
1183
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1184
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
11851223 // Return();
1224
+
11861225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11871226 hideCB.setToolTipText("Hide object");
11881227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11891228 markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11901231
11911232 setupPanel2 = new cGridBag().setVertical(false);
11921233
....@@ -1474,6 +1515,7 @@
14741515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14751516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14761517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
14771519
14781520 /*
14791521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1511,16 +1553,29 @@
15111553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15121554 //tmp.setName("Edit");
15131555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
15141559 // JPanel north = new JPanel(new BorderLayout());
15151560 // north.setName("Edit");
15161561 // north.add(ctrlPanel, BorderLayout.NORTH);
15171562 // objectPanel.add(north);
15181563 objectPanel.add(editPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15191566
15201567 //if (Globals.ADVANCED)
15211568 objectPanel.add(infoPanel);
1569
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
1571
+
1572
+ objectPanel.add(XYZPanel);
1573
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15221575
15231576 objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15241579
15251580 /*
15261581 aConstraints.gridx = 0;
....@@ -1541,7 +1596,7 @@
15411596 scrollpane.addMouseWheelListener(this); // Default not fast enough
15421597
15431598 /*JTabbedPane*/ scenePanel = new cGridBag();
1544
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
15451600
15461601 JTabbedPane tabbedPane = new JTabbedPane();
15471602 tabbedPane.add(scrollpane);
....@@ -1619,7 +1674,7 @@
16191674 bigThree = new cGridBag();
16201675 bigThree.addComponent(scenePanel);
16211676 bigThree.addComponent(centralPanel);
1622
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
16231678
16241679 // // SIDE EFFECT!!!
16251680 // aConstraints.gridx = 0;
....@@ -1660,7 +1715,6 @@
16601715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16611716 frame.addWindowListener(new WindowAdapter()
16621717 {
1663
-
16641718 public void windowClosing(WindowEvent e)
16651719 {
16661720 Close();
....@@ -1683,12 +1737,85 @@
16831737 ctrlPanel.removeAll();
16841738 }
16851739
1686
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
16871741 {
1688
- /*
1742
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
1745
+ {
1746
+ public void mouseClicked(MouseEvent e)
1747
+ {
1748
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1749
+ cMaterial material = object.material;
1750
+
1751
+ // Skin
1752
+ colorField.setFloat(material.color);
1753
+ saturationField.setFloat(material.modulation);
1754
+ subsurfaceField.setFloat(material.subsurface);
1755
+ selfshadowField.setFloat(material.diffuseness);
1756
+ diffusenessField.setFloat(material.factor);
1757
+ shininessField.setFloat(material.shininess);
1758
+ shadowbiasField.setFloat(material.shadowbias);
1759
+ diffuseField.setFloat(material.diffuse);
1760
+ specularField.setFloat(material.specular);
1761
+
1762
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1763
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1764
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1765
+
1766
+ materialtouched = true;
1767
+ applySelf();
1768
+ }
1769
+ });
1770
+ presetpanel.add(skin);
1771
+
1772
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1773
+ rough2.addMouseListener(new MouseAdapter()
1774
+ {
1775
+ public void mouseClicked(MouseEvent e)
1776
+ {
1777
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1778
+ cMaterial material = object.material;
1779
+
1780
+ shininessField.setFloat(material.shininess);
1781
+ velvetField.setFloat(material.velvet);
1782
+
1783
+ materialtouched = true;
1784
+ applySelf();
1785
+ }
1786
+ });
1787
+ presetpanel.add(rough2);
1788
+
1789
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1790
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1791
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1792
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1793
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1794
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1795
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1796
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1797
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1798
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1799
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1800
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1801
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1802
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1803
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1804
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1805
+
1806
+ cGridBag panel = new cGridBag().setVertical(true);
1807
+
1808
+ presetpanel.preferredWidth = 1;
1809
+
1810
+ materialpanel.add(panel);
1811
+ materialpanel.add(presetpanel);
1812
+
1813
+ panel.preferredWidth = 8;
1814
+
1815
+ /*
16891816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16901817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- */
1818
+ */
16921819
16931820 cGridBag editBar = new cGridBag().setVertical(false);
16941821
....@@ -1722,27 +1849,50 @@
17221849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17231850
17241851 cGridBag colorSection = new cGridBag().setVertical(true);
1852
+
1853
+ cGridBag huepanel = new cGridBag();
1854
+ cGridBag huelabel = new cGridBag();
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
1858
+ huelabel.preferredWidth = 20;
1859
+ huepanel.add(new cGridBag()); // Label
1860
+ huepanel.add(huelabel); // Field/slider
1861
+
1862
+ huepanel.preferredHeight = 7;
1863
+
1864
+ colorSection.add(huepanel);
17251865
17261866 cGridBag color = new cGridBag();
1727
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1728
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1729
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1867
+
1868
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1869
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1871
+
17301872 //colorField.preferredWidth = 200;
17311873 colorSection.add(color);
17321874
17331875 cGridBag modulation = new cGridBag();
17341876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17351877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1736
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17371879 colorSection.add(modulation);
17381880
1881
+ cGridBag opacity = new cGridBag();
1882
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1883
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1884
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1885
+ colorSection.add(opacity);
1886
+
1887
+ colorSection.add(GetSeparator());
1888
+
17391889 cGridBag texture = new cGridBag();
17401890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17411891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17421892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17431893 colorSection.add(texture);
17441894
1745
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17461896
17471897 panel.add(colorSection);
17481898
....@@ -1798,7 +1948,7 @@
17981948 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17991949 diffuseSection.add(shadowbias);
18001950
1801
- panel.add(new JSeparator());
1951
+ panel.add(GetSeparator());
18021952
18031953 panel.add(diffuseSection);
18041954
....@@ -1861,7 +2011,7 @@
18612011 specularSection.add(anisoV);
18622012
18632013
1864
- panel.add(new JSeparator());
2014
+ panel.add(GetSeparator());
18652015
18662016 panel.add(specularSection);
18672017
....@@ -1886,12 +2036,6 @@
18862036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18872037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18882038 colorSection.add(backlit);
1889
-
1890
- cGridBag opacity = new cGridBag();
1891
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1892
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1893
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1894
- colorSection.add(opacity);
18952039
18962040 //panel.add(new JSeparator());
18972041
....@@ -1937,7 +2081,7 @@
19372081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19382082 textureSection.add(opacityPower);
19392083
1940
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
19412085
19422086 panel.add(textureSection);
19432087
....@@ -2924,7 +3068,7 @@
29243068
29253069 freezematerial = true;
29263070 colorField.setFloat(mat.color);
2927
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29283072 metalnessField.setFloat(mat.metalness);
29293073 diffuseField.setFloat(mat.diffuse);
29303074 specularField.setFloat(mat.specular);
....@@ -3235,8 +3379,9 @@
32353379 } else if (event.getSource() == liveCB)
32363380 {
32373381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
32383383 return;
3239
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
32403385 {
32413386 copy.dontselect ^= true;
32423387 return;
....@@ -3244,7 +3389,7 @@
32443389 {
32453390 copy.hide ^= true;
32463391 copy.Touch(); // display list issue
3247
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
32483393 return;
32493394 } else if (event.getSource() == link2masterCB)
32503395 {
....@@ -3500,6 +3645,7 @@
35003645
35013646 static public byte[] Compress(Object3D o)
35023647 {
3648
+ // Slower to actually compress.
35033649 try
35043650 {
35053651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3601,6 +3747,7 @@
36013747 {
36023748 //Save(true);
36033749 Replace();
3750
+ SetUndoStates();
36043751 }
36053752
36063753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3621,29 +3768,46 @@
36213768
36223769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36233770
3771
+ void DeleteVersion()
3772
+ {
3773
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
3774
+ {
3775
+ copy.versionlist[i] = copy.versionlist[i+1];
3776
+ }
3777
+
3778
+ CopyChanged();
3779
+
3780
+ SetUndoStates();
3781
+ }
3782
+
36243783 public boolean Save(boolean user)
36253784 {
36263785 System.err.println("Save");
3786
+ //Replace();
36273787
36283788 cRadio tab = GetCurrentTab();
36293789
3630
- byte[] compress = CompressCopy();
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36313791
36323792 boolean thesame = false;
36333793
3634
- // Quick heuristic using length. Works only when stream is compressed.
3635
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3636
- {
3637
- thesame = true;
3638
- }
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
36393798
36403799 //EditorFrame.m_MainFrame.requestFocusInWindow();
36413800 if (!thesame)
36423801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
36433807 //tab.user[tab.versionindex] = user;
36443808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36453809
3646
- copy.versions[++copy.versionindex] = compress;
3810
+ copy.versionlist[++copy.versionindex] = compress;
36473811
36483812 // if (increment)
36493813 // tab.versionindex++;
....@@ -3653,11 +3817,11 @@
36533817
36543818 //assert(hashtable.isEmpty());
36553819
3656
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3657
- {
3658
- //tab.user[i] = false;
3659
- copy.versions[i] = null;
3660
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
36613825
36623826 SetUndoStates();
36633827
....@@ -3682,9 +3846,43 @@
36823846
36833847 return !thesame;
36843848 }
3685
-
3686
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
36873853 {
3854
+ Object3D selection = new Object3D();
3855
+
3856
+ for (int i = 0; i < copy.selection.size(); i++)
3857
+ {
3858
+ Object3D elem = copy.selection.elementAt(i);
3859
+
3860
+ Object3D obj = copy.GetObject(elem.GetUUID());
3861
+
3862
+ if (obj == null)
3863
+ {
3864
+ copy.selection.remove(i--);
3865
+ }
3866
+ else
3867
+ {
3868
+ selection.add(obj);
3869
+ copy.selection.setElementAt(obj, i);
3870
+ }
3871
+ }
3872
+
3873
+ flashIt = false;
3874
+ GetTree().clearSelection();
3875
+ for (int i = 0; i < selection.size(); i++)
3876
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3877
+ flashIt = true;
3878
+
3879
+ //refreshContents(false);
3880
+ }
3881
+
3882
+ void CopyChanged()
3883
+ {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
36883886 SetUndoStates();
36893887
36903888 boolean temp = CameraPane.SWITCH;
....@@ -3694,6 +3892,9 @@
36943892
36953893 copy.clear();
36963894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
36973898 for (int i=0; i<obj.Size(); i++)
36983899 {
36993900 copy.add(obj.get(i));
....@@ -3703,6 +3904,7 @@
37033904
37043905 CameraPane.SWITCH = temp;
37053906
3907
+ RefreshSelection();
37063908 //assert(hashtable.isEmpty());
37073909
37083910 copy.Touch();
....@@ -3723,26 +3925,55 @@
37233925 }
37243926 }
37253927
3726
- refreshContents();
3928
+ refreshContents(true);
37273929 }
37283930
3729
- cButton undoButton;
3931
+ cButton previousVersionButton;
37303932 cButton restoreButton;
37313933 cButton replaceButton;
3732
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
37333937
3938
+ boolean muteSlider;
3939
+
3940
+ int VersionCount()
3941
+ {
3942
+ int count = 0;
3943
+
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
3945
+ {
3946
+ if (copy.versionlist[i] != null)
3947
+ count++;
3948
+ }
3949
+
3950
+ return count;
3951
+ }
3952
+
37343953 void SetUndoStates()
37353954 {
37363955 cRadio tab = GetCurrentTab();
37373956
3738
- restoreButton.setEnabled(copy.versionindex != -1);
3739
- replaceButton.setEnabled(copy.versionindex != -1);
3740
- undoButton.setEnabled(copy.versionindex > 0);
3741
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
3959
+
3960
+ previousVersionButton.setEnabled(copy.versionindex > 0);
3961
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3962
+
3963
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
3964
+ copy.versionlist[copy.versionindex + 1] != null);
3965
+
3966
+ muteSlider = true;
3967
+ versionSlider.setMaximum(VersionCount() - 1);
3968
+ versionSlider.setInteger(copy.versionindex);
3969
+ muteSlider = false;
37423970 }
37433971
3744
- public boolean Undo()
3972
+ public boolean PreviousVersion()
37453973 {
3974
+ // Option?
3975
+ Replace();
3976
+
37463977 System.err.println("Undo");
37473978
37483979 cRadio tab = GetCurrentTab();
....@@ -3768,7 +3999,7 @@
37683999
37694000 copy.versionindex -= 1;
37704001
3771
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged();
37724003
37734004 return true;
37744005 }
....@@ -3779,13 +4010,14 @@
37794010
37804011 cRadio tab = GetCurrentTab();
37814012
3782
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
37834014 {
37844015 java.awt.Toolkit.getDefaultToolkit().beep();
37854016 return false;
37864017 }
37874018
3788
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
37894021
37904022 return true;
37914023 }
....@@ -3796,22 +4028,25 @@
37964028
37974029 cRadio tab = GetCurrentTab();
37984030
3799
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38004032 {
38014033 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38024034 return false;
38034035 }
38044036
3805
- copy.versions[copy.versionindex] = CompressCopy();
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
38064038
38074039 return true;
38084040 }
38094041
3810
- public void Redo()
4042
+ public void NextVersion()
38114043 {
4044
+ // Option?
4045
+ Replace();
4046
+
38124047 cRadio tab = GetCurrentTab();
38134048
3814
- if (copy.versions[copy.versionindex + 1] == null)
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
38154050 {
38164051 java.awt.Toolkit.getDefaultToolkit().beep();
38174052 return;
....@@ -3819,7 +4054,7 @@
38194054
38204055 copy.versionindex += 1;
38214056
3822
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4057
+ CopyChanged();
38234058
38244059 //if (!tab.user[tab.versionindex])
38254060 // tab.graphs[tab.versionindex] = null;
....@@ -4033,7 +4268,7 @@
40334268 //copy.material = new cMaterial(copy.GetMaterial());
40344269
40354270 current.color = (float) colorField.getFloat();
4036
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
40374272 current.metalness = (float) metalnessField.getFloat();
40384273 current.diffuse = (float) diffuseField.getFloat();
40394274 current.specular = (float) specularField.getFloat();
....@@ -4066,7 +4301,7 @@
40664301 cMaterial mat = copy.material;
40674302
40684303 colorField.SetToolTipValue((mat.color));
4069
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
40704305 metalnessField.SetToolTipValue((mat.metalness));
40714306 diffuseField.SetToolTipValue((mat.diffuse));
40724307 specularField.SetToolTipValue((mat.specular));
....@@ -4118,18 +4353,22 @@
41184353 //copy.Touch();
41194354 }
41204355
4121
- cNumberSlider versionField;
4356
+ cNumberSlider versionSlider;
41224357
41234358 public void stateChanged(ChangeEvent e)
41244359 {
41254360 // assert(false);
4126
- if (e.getSource() == versionField)
4361
+ if (e.getSource() == versionSlider)
41274362 {
4128
- int version = versionField.getInteger();
4363
+ if (muteSlider)
4364
+ return;
41294365
4130
- if (copy.versions[version] != null)
4366
+ int version = versionSlider.getInteger();
4367
+
4368
+ if (copy.versionlist[version] != null)
41314369 {
4132
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
41334372 }
41344373
41354374 return;
....@@ -4169,6 +4408,12 @@
41694408 {
41704409 //System.out.println("stateChanged = " + this);
41714410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
41724417 applySelf();
41734418 //System.out.println("this = " + this);
41744419 //System.out.println("PARENT = " + parent);
....@@ -4468,6 +4713,7 @@
44684713 {
44694714 if (GetTree() != null)
44704715 {
4716
+ GetTree().revalidate();
44714717 GetTree().repaint();
44724718 }
44734719
....@@ -4476,6 +4722,9 @@
44764722 ctrlPanel.validate(); // ? new
44774723 ctrlPanel.repaint();
44784724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
44794728 }
44804729
44814730 static TweenManager tweenManager = new TweenManager();
....@@ -4724,7 +4973,9 @@
47244973 readobj.ResetDisplayList();
47254974 } catch (Exception e)
47264975 {
4727
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
47284979 try
47294980 {
47304981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4804,6 +5055,8 @@
48045055 {
48055056 //readobj.deepCopySelf(copy);
48065057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
48075060 for (int i = 0; i < readobj.size(); i++)
48085061 {
48095062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4844,6 +5097,7 @@
48445097 }
48455098 } catch (ClassCastException e)
48465099 {
5100
+ e.printStackTrace();
48475101 assert (false);
48485102 Composite c = (Composite) copy;
48495103 c.children.clear();
....@@ -4854,10 +5108,16 @@
48545108 c.addChild(csg);
48555109 }
48565110
4857
- copy.versions = readobj.versions;
5111
+ copy.versionlist = readobj.versionlist;
48585112 copy.versionindex = readobj.versionindex;
48595113
4860
- SetUndoStates();
5114
+ if (copy.versionlist == null)
5115
+ {
5116
+ copy.versionlist = new Object3D[100];
5117
+ copy.versionindex = -1;
5118
+ }
5119
+
5120
+ //? SetUndoStates();
48615121
48625122 ResetModel();
48635123 copy.HardTouch(); // recompile?
....@@ -4869,7 +5129,7 @@
48695129 {
48705130 if (Grafreed.standAlone)
48715131 {
4872
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
48735133 browser.show();
48745134 String filename = browser.getFile();
48755135 if (filename != null && filename.length() > 0)
....@@ -4968,6 +5228,7 @@
49685228 //ps.print(buffer.toString());
49695229 } catch (IOException e)
49705230 {
5231
+ e.printStackTrace();
49715232 }
49725233 }
49735234
....@@ -5260,7 +5521,7 @@
52605521 JLabel colorLabel;
52615522 cNumberSlider colorField;
52625523 JLabel modulationLabel;
5263
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
52645525 JLabel metalnessLabel;
52655526 cNumberSlider metalnessField;
52665527 JLabel diffuseLabel;