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,9 +296,9 @@
282296 client = inClient;
283297 copy = client;
284298
285
- if (copy.versions == null)
299
+ if (copy.versionlist == null)
286300 {
287
- copy.versions = new byte[100][];
301
+ copy.versionlist = new Object3D[100];
288302 copy.versionindex = -1;
289303 }
290304
....@@ -301,9 +315,9 @@
301315 client = inClient;
302316 copy = client;
303317
304
- if (copy.versions == null)
318
+ if (copy.versionlist == null)
305319 {
306
- copy.versions = new byte[100][];
320
+ copy.versionlist = new Object3D[100];
307321 copy.versionindex = -1;
308322 }
309323
....@@ -339,10 +353,10 @@
339353 copy = localCopy;
340354 copy.editWindow = this;
341355
342
- if (copy.versions == null)
356
+ if (copy.versionlist == null)
343357 {
344
- copy.versions = new byte[100][];
345
- copy.versionindex = -1;
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
346360 }
347361
348362 SetupMenu();
....@@ -437,11 +451,12 @@
437451
438452 toolbarPanel = new JPanel();
439453 toolbarPanel.setName("Toolbar");
454
+
440455 treePanel = new cGridBag();
441456 treePanel.setName("Tree");
442457
443458 editPanel = new cGridBag().setVertical(true);
444
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
445460
446461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
447462
....@@ -449,11 +464,11 @@
449464 editPanel.add(editCommandsPanel);
450465 editPanel.add(ctrlPanel);
451466
452
- toolboxPanel = new cGridBag().setVertical(false);
453
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
454469
455
- materialPanel = new cGridBag().setVertical(true);
456
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
457472
458473 /*JTextPane*/
459474 infoarea = createTextPane();
....@@ -461,6 +476,7 @@
461476
462477 infoarea.setEditable(true);
463478 SetText();
479
+
464480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
465481 // infoarea.setOpaque(false);
466482 // //infoarea.setForeground(textcolor);
....@@ -468,7 +484,7 @@
468484 // TEXTAREA infoarea.setWrapStyleWord(true);
469485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
470486 infoPanel.setPreferredSize(new Dimension(1, 1));
471
- infoPanel.setName("Info");
487
+ //infoPanel.setName("Info");
472488 //infoPanel.setLayout(new BorderLayout());
473489 //infoPanel.add(createTextPane());
474490
....@@ -832,9 +848,11 @@
832848 //frame.setVisible(true);
833849 }
834850 frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
835853 }
836854
837
- private byte[] CompressCopy()
855
+ private Object3D CompressCopy()
838856 {
839857 boolean temp = CameraPane.SWITCH;
840858 CameraPane.SWITCH = false;
....@@ -842,12 +860,13 @@
842860 copy.ExtractBigData(versiontable);
843861 // if (copy == client)
844862
845
- byte[] versions[] = copy.versions;
846
- copy.versions = null;
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
847865
848
- byte[] compress = Compress(copy);
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
849868
850
- copy.versions = versions;
869
+ copy.versionlist = versions;
851870
852871 copy.RestoreBigData(versiontable);
853872
....@@ -977,6 +996,7 @@
977996 {
978997 SetupMaterial(materialPanel);
979998 }
999
+
9801000 //SetupName();
9811001 //SetupViews();
9821002 }
....@@ -986,7 +1006,7 @@
9861006 // NumberSlider vDivsField;
9871007 // JCheckBox endcaps;
9881008 JCheckBox liveCB;
989
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9901010 JCheckBox hideCB;
9911011 JCheckBox link2masterCB;
9921012 JCheckBox markCB;
....@@ -1198,13 +1218,16 @@
11981218
11991219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12001220 liveCB.setToolTipText("Animate object");
1201
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1202
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
12031223 // Return();
1224
+
12041225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12051226 hideCB.setToolTipText("Hide object");
12061227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
12071228 markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12081231
12091232 setupPanel2 = new cGridBag().setVertical(false);
12101233
....@@ -1492,6 +1515,7 @@
14921515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14931516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14941517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
14951519
14961520 /*
14971521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1529,16 +1553,29 @@
15291553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15301554 //tmp.setName("Edit");
15311555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
15321559 // JPanel north = new JPanel(new BorderLayout());
15331560 // north.setName("Edit");
15341561 // north.add(ctrlPanel, BorderLayout.NORTH);
15351562 // objectPanel.add(north);
15361563 objectPanel.add(editPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15371566
15381567 //if (Globals.ADVANCED)
15391568 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");
15401575
15411576 objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15421579
15431580 /*
15441581 aConstraints.gridx = 0;
....@@ -1559,7 +1596,7 @@
15591596 scrollpane.addMouseWheelListener(this); // Default not fast enough
15601597
15611598 /*JTabbedPane*/ scenePanel = new cGridBag();
1562
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
15631600
15641601 JTabbedPane tabbedPane = new JTabbedPane();
15651602 tabbedPane.add(scrollpane);
....@@ -1637,7 +1674,7 @@
16371674 bigThree = new cGridBag();
16381675 bigThree.addComponent(scenePanel);
16391676 bigThree.addComponent(centralPanel);
1640
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
16411678
16421679 // // SIDE EFFECT!!!
16431680 // aConstraints.gridx = 0;
....@@ -1678,7 +1715,6 @@
16781715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16791716 frame.addWindowListener(new WindowAdapter()
16801717 {
1681
-
16821718 public void windowClosing(WindowEvent e)
16831719 {
16841720 Close();
....@@ -1701,12 +1737,85 @@
17011737 ctrlPanel.removeAll();
17021738 }
17031739
1704
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
17051741 {
1706
- /*
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
+ /*
17071816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17081817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1709
- */
1818
+ */
17101819
17111820 cGridBag editBar = new cGridBag().setVertical(false);
17121821
....@@ -1740,27 +1849,50 @@
17401849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17411850
17421851 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);
17431865
17441866 cGridBag color = new cGridBag();
1745
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1746
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1747
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
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
+
17481872 //colorField.preferredWidth = 200;
17491873 colorSection.add(color);
17501874
17511875 cGridBag modulation = new cGridBag();
17521876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17531877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1754
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17551879 colorSection.add(modulation);
17561880
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
+
17571889 cGridBag texture = new cGridBag();
17581890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17591891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17601892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17611893 colorSection.add(texture);
17621894
1763
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17641896
17651897 panel.add(colorSection);
17661898
....@@ -1816,7 +1948,7 @@
18161948 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18171949 diffuseSection.add(shadowbias);
18181950
1819
- panel.add(new JSeparator());
1951
+ panel.add(GetSeparator());
18201952
18211953 panel.add(diffuseSection);
18221954
....@@ -1879,7 +2011,7 @@
18792011 specularSection.add(anisoV);
18802012
18812013
1882
- panel.add(new JSeparator());
2014
+ panel.add(GetSeparator());
18832015
18842016 panel.add(specularSection);
18852017
....@@ -1904,12 +2036,6 @@
19042036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19052037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19062038 colorSection.add(backlit);
1907
-
1908
- cGridBag opacity = new cGridBag();
1909
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1910
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1911
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1912
- colorSection.add(opacity);
19132039
19142040 //panel.add(new JSeparator());
19152041
....@@ -1955,7 +2081,7 @@
19552081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19562082 textureSection.add(opacityPower);
19572083
1958
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
19592085
19602086 panel.add(textureSection);
19612087
....@@ -2942,7 +3068,7 @@
29423068
29433069 freezematerial = true;
29443070 colorField.setFloat(mat.color);
2945
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29463072 metalnessField.setFloat(mat.metalness);
29473073 diffuseField.setFloat(mat.diffuse);
29483074 specularField.setFloat(mat.specular);
....@@ -3253,8 +3379,9 @@
32533379 } else if (event.getSource() == liveCB)
32543380 {
32553381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
32563383 return;
3257
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
32583385 {
32593386 copy.dontselect ^= true;
32603387 return;
....@@ -3262,7 +3389,7 @@
32623389 {
32633390 copy.hide ^= true;
32643391 copy.Touch(); // display list issue
3265
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
32663393 return;
32673394 } else if (event.getSource() == link2masterCB)
32683395 {
....@@ -3518,6 +3645,7 @@
35183645
35193646 static public byte[] Compress(Object3D o)
35203647 {
3648
+ // Slower to actually compress.
35213649 try
35223650 {
35233651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3619,6 +3747,7 @@
36193747 {
36203748 //Save(true);
36213749 Replace();
3750
+ SetUndoStates();
36223751 }
36233752
36243753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3639,29 +3768,46 @@
36393768
36403769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36413770
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
+
36423783 public boolean Save(boolean user)
36433784 {
36443785 System.err.println("Save");
3786
+ //Replace();
36453787
36463788 cRadio tab = GetCurrentTab();
36473789
3648
- byte[] compress = CompressCopy();
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36493791
36503792 boolean thesame = false;
36513793
3652
- // Quick heuristic using length. Works only when stream is compressed.
3653
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3654
- {
3655
- thesame = true;
3656
- }
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
36573798
36583799 //EditorFrame.m_MainFrame.requestFocusInWindow();
36593800 if (!thesame)
36603801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
36613807 //tab.user[tab.versionindex] = user;
36623808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36633809
3664
- copy.versions[++copy.versionindex] = compress;
3810
+ copy.versionlist[++copy.versionindex] = compress;
36653811
36663812 // if (increment)
36673813 // tab.versionindex++;
....@@ -3671,11 +3817,11 @@
36713817
36723818 //assert(hashtable.isEmpty());
36733819
3674
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3675
- {
3676
- //tab.user[i] = false;
3677
- copy.versions[i] = null;
3678
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
36793825
36803826 SetUndoStates();
36813827
....@@ -3700,9 +3846,43 @@
37003846
37013847 return !thesame;
37023848 }
3703
-
3704
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
37053853 {
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
+
37063886 SetUndoStates();
37073887
37083888 boolean temp = CameraPane.SWITCH;
....@@ -3712,6 +3892,9 @@
37123892
37133893 copy.clear();
37143894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
37153898 for (int i=0; i<obj.Size(); i++)
37163899 {
37173900 copy.add(obj.get(i));
....@@ -3721,6 +3904,7 @@
37213904
37223905 CameraPane.SWITCH = temp;
37233906
3907
+ RefreshSelection();
37243908 //assert(hashtable.isEmpty());
37253909
37263910 copy.Touch();
....@@ -3741,13 +3925,15 @@
37413925 }
37423926 }
37433927
3744
- refreshContents();
3928
+ refreshContents(true);
37453929 }
37463930
3747
- cButton undoButton;
3931
+ cButton previousVersionButton;
37483932 cButton restoreButton;
37493933 cButton replaceButton;
3750
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
37513937
37523938 boolean muteSlider;
37533939
....@@ -3755,9 +3941,9 @@
37553941 {
37563942 int count = 0;
37573943
3758
- for (int i = copy.versions.length; --i >= 0;)
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
37593945 {
3760
- if (copy.versions[i] != null)
3946
+ if (copy.versionlist[i] != null)
37613947 count++;
37623948 }
37633949
....@@ -3768,11 +3954,14 @@
37683954 {
37693955 cRadio tab = GetCurrentTab();
37703956
3771
- restoreButton.setEnabled(copy.versionindex != -1);
3772
- replaceButton.setEnabled(copy.versionindex != -1);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
37733959
3774
- undoButton.setEnabled(copy.versionindex > 0);
3775
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
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);
37763965
37773966 muteSlider = true;
37783967 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3780,7 +3969,7 @@
37803969 muteSlider = false;
37813970 }
37823971
3783
- public boolean Undo()
3972
+ public boolean PreviousVersion()
37843973 {
37853974 // Option?
37863975 Replace();
....@@ -3810,7 +3999,7 @@
38103999
38114000 copy.versionindex -= 1;
38124001
3813
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged();
38144003
38154004 return true;
38164005 }
....@@ -3821,13 +4010,14 @@
38214010
38224011 cRadio tab = GetCurrentTab();
38234012
3824
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38254014 {
38264015 java.awt.Toolkit.getDefaultToolkit().beep();
38274016 return false;
38284017 }
38294018
3830
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
38314021
38324022 return true;
38334023 }
....@@ -3838,25 +4028,25 @@
38384028
38394029 cRadio tab = GetCurrentTab();
38404030
3841
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38424032 {
38434033 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38444034 return false;
38454035 }
38464036
3847
- copy.versions[copy.versionindex] = CompressCopy();
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
38484038
38494039 return true;
38504040 }
38514041
3852
- public void Redo()
4042
+ public void NextVersion()
38534043 {
38544044 // Option?
38554045 Replace();
38564046
38574047 cRadio tab = GetCurrentTab();
38584048
3859
- if (copy.versions[copy.versionindex + 1] == null)
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
38604050 {
38614051 java.awt.Toolkit.getDefaultToolkit().beep();
38624052 return;
....@@ -3864,7 +4054,7 @@
38644054
38654055 copy.versionindex += 1;
38664056
3867
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4057
+ CopyChanged();
38684058
38694059 //if (!tab.user[tab.versionindex])
38704060 // tab.graphs[tab.versionindex] = null;
....@@ -4078,7 +4268,7 @@
40784268 //copy.material = new cMaterial(copy.GetMaterial());
40794269
40804270 current.color = (float) colorField.getFloat();
4081
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
40824272 current.metalness = (float) metalnessField.getFloat();
40834273 current.diffuse = (float) diffuseField.getFloat();
40844274 current.specular = (float) specularField.getFloat();
....@@ -4111,7 +4301,7 @@
41114301 cMaterial mat = copy.material;
41124302
41134303 colorField.SetToolTipValue((mat.color));
4114
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
41154305 metalnessField.SetToolTipValue((mat.metalness));
41164306 diffuseField.SetToolTipValue((mat.diffuse));
41174307 specularField.SetToolTipValue((mat.specular));
....@@ -4175,9 +4365,10 @@
41754365
41764366 int version = versionSlider.getInteger();
41774367
4178
- if (copy.versions[version] != null)
4368
+ if (copy.versionlist[version] != null)
41794369 {
4180
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
41814372 }
41824373
41834374 return;
....@@ -4217,6 +4408,12 @@
42174408 {
42184409 //System.out.println("stateChanged = " + this);
42194410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
42204417 applySelf();
42214418 //System.out.println("this = " + this);
42224419 //System.out.println("PARENT = " + parent);
....@@ -4516,6 +4713,7 @@
45164713 {
45174714 if (GetTree() != null)
45184715 {
4716
+ GetTree().revalidate();
45194717 GetTree().repaint();
45204718 }
45214719
....@@ -4524,6 +4722,9 @@
45244722 ctrlPanel.validate(); // ? new
45254723 ctrlPanel.repaint();
45264724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
45274728 }
45284729
45294730 static TweenManager tweenManager = new TweenManager();
....@@ -4772,7 +4973,9 @@
47724973 readobj.ResetDisplayList();
47734974 } catch (Exception e)
47744975 {
4775
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
47764979 try
47774980 {
47784981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4852,6 +5055,8 @@
48525055 {
48535056 //readobj.deepCopySelf(copy);
48545057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
48555060 for (int i = 0; i < readobj.size(); i++)
48565061 {
48575062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4892,6 +5097,7 @@
48925097 }
48935098 } catch (ClassCastException e)
48945099 {
5100
+ e.printStackTrace();
48955101 assert (false);
48965102 Composite c = (Composite) copy;
48975103 c.children.clear();
....@@ -4902,12 +5108,12 @@
49025108 c.addChild(csg);
49035109 }
49045110
4905
- copy.versions = readobj.versions;
5111
+ copy.versionlist = readobj.versionlist;
49065112 copy.versionindex = readobj.versionindex;
49075113
4908
- if (copy.versions == null)
5114
+ if (copy.versionlist == null)
49095115 {
4910
- copy.versions = new byte[100][];
5116
+ copy.versionlist = new Object3D[100];
49115117 copy.versionindex = -1;
49125118 }
49135119
....@@ -4923,7 +5129,7 @@
49235129 {
49245130 if (Grafreed.standAlone)
49255131 {
4926
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49275133 browser.show();
49285134 String filename = browser.getFile();
49295135 if (filename != null && filename.length() > 0)
....@@ -5022,6 +5228,7 @@
50225228 //ps.print(buffer.toString());
50235229 } catch (IOException e)
50245230 {
5231
+ e.printStackTrace();
50255232 }
50265233 }
50275234
....@@ -5314,7 +5521,7 @@
53145521 JLabel colorLabel;
53155522 cNumberSlider colorField;
53165523 JLabel modulationLabel;
5317
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
53185525 JLabel metalnessLabel;
53195526 cNumberSlider metalnessField;
53205527 JLabel diffuseLabel;