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,7 +848,32 @@
814848 //frame.setVisible(true);
815849 }
816850 frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
817853 }
854
+
855
+ private Object3D CompressCopy()
856
+ {
857
+ boolean temp = CameraPane.SWITCH;
858
+ CameraPane.SWITCH = false;
859
+
860
+ copy.ExtractBigData(versiontable);
861
+ // if (copy == client)
862
+
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
865
+
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
868
+
869
+ copy.versionlist = versions;
870
+
871
+ copy.RestoreBigData(versiontable);
872
+
873
+ CameraPane.SWITCH = temp;
874
+
875
+ return compress;
876
+ }
818877
819878 private JTextPane createTextPane()
820879 {
....@@ -937,6 +996,7 @@
937996 {
938997 SetupMaterial(materialPanel);
939998 }
999
+
9401000 //SetupName();
9411001 //SetupViews();
9421002 }
....@@ -946,7 +1006,7 @@
9461006 // NumberSlider vDivsField;
9471007 // JCheckBox endcaps;
9481008 JCheckBox liveCB;
949
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9501010 JCheckBox hideCB;
9511011 JCheckBox link2masterCB;
9521012 JCheckBox markCB;
....@@ -1158,13 +1218,16 @@
11581218
11591219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11601220 liveCB.setToolTipText("Animate object");
1161
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
11631223 // Return();
1224
+
11641225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11651226 hideCB.setToolTipText("Hide object");
11661227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11671228 markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11681231
11691232 setupPanel2 = new cGridBag().setVertical(false);
11701233
....@@ -1452,6 +1515,7 @@
14521515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14531516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14541517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
14551519
14561520 /*
14571521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1489,16 +1553,29 @@
14891553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14901554 //tmp.setName("Edit");
14911555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
14921559 // JPanel north = new JPanel(new BorderLayout());
14931560 // north.setName("Edit");
14941561 // north.add(ctrlPanel, BorderLayout.NORTH);
14951562 // objectPanel.add(north);
14961563 objectPanel.add(editPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
14971566
14981567 //if (Globals.ADVANCED)
14991568 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");
15001575
15011576 objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15021579
15031580 /*
15041581 aConstraints.gridx = 0;
....@@ -1519,7 +1596,7 @@
15191596 scrollpane.addMouseWheelListener(this); // Default not fast enough
15201597
15211598 /*JTabbedPane*/ scenePanel = new cGridBag();
1522
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
15231600
15241601 JTabbedPane tabbedPane = new JTabbedPane();
15251602 tabbedPane.add(scrollpane);
....@@ -1597,7 +1674,7 @@
15971674 bigThree = new cGridBag();
15981675 bigThree.addComponent(scenePanel);
15991676 bigThree.addComponent(centralPanel);
1600
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
16011678
16021679 // // SIDE EFFECT!!!
16031680 // aConstraints.gridx = 0;
....@@ -1638,7 +1715,6 @@
16381715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16391716 frame.addWindowListener(new WindowAdapter()
16401717 {
1641
-
16421718 public void windowClosing(WindowEvent e)
16431719 {
16441720 Close();
....@@ -1661,12 +1737,85 @@
16611737 ctrlPanel.removeAll();
16621738 }
16631739
1664
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
16651741 {
1666
- /*
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
+ /*
16671816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16681817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1669
- */
1818
+ */
16701819
16711820 cGridBag editBar = new cGridBag().setVertical(false);
16721821
....@@ -1700,27 +1849,50 @@
17001849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17011850
17021851 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);
17031865
17041866 cGridBag color = new cGridBag();
1705
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1706
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1707
- 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
+
17081872 //colorField.preferredWidth = 200;
17091873 colorSection.add(color);
17101874
17111875 cGridBag modulation = new cGridBag();
17121876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17131877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1714
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17151879 colorSection.add(modulation);
17161880
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
+
17171889 cGridBag texture = new cGridBag();
17181890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17191891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17201892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17211893 colorSection.add(texture);
17221894
1723
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17241896
17251897 panel.add(colorSection);
17261898
....@@ -1776,7 +1948,7 @@
17761948 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17771949 diffuseSection.add(shadowbias);
17781950
1779
- panel.add(new JSeparator());
1951
+ panel.add(GetSeparator());
17801952
17811953 panel.add(diffuseSection);
17821954
....@@ -1839,7 +2011,7 @@
18392011 specularSection.add(anisoV);
18402012
18412013
1842
- panel.add(new JSeparator());
2014
+ panel.add(GetSeparator());
18432015
18442016 panel.add(specularSection);
18452017
....@@ -1864,12 +2036,6 @@
18642036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18652037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18662038 colorSection.add(backlit);
1867
-
1868
- cGridBag opacity = new cGridBag();
1869
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1870
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1871
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1872
- colorSection.add(opacity);
18732039
18742040 //panel.add(new JSeparator());
18752041
....@@ -1915,7 +2081,7 @@
19152081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19162082 textureSection.add(opacityPower);
19172083
1918
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
19192085
19202086 panel.add(textureSection);
19212087
....@@ -2902,7 +3068,7 @@
29023068
29033069 freezematerial = true;
29043070 colorField.setFloat(mat.color);
2905
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29063072 metalnessField.setFloat(mat.metalness);
29073073 diffuseField.setFloat(mat.diffuse);
29083074 specularField.setFloat(mat.specular);
....@@ -3213,8 +3379,9 @@
32133379 } else if (event.getSource() == liveCB)
32143380 {
32153381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
32163383 return;
3217
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
32183385 {
32193386 copy.dontselect ^= true;
32203387 return;
....@@ -3222,7 +3389,7 @@
32223389 {
32233390 copy.hide ^= true;
32243391 copy.Touch(); // display list issue
3225
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
32263393 return;
32273394 } else if (event.getSource() == link2masterCB)
32283395 {
....@@ -3478,6 +3645,7 @@
34783645
34793646 static public byte[] Compress(Object3D o)
34803647 {
3648
+ // Slower to actually compress.
34813649 try
34823650 {
34833651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3574,11 +3742,12 @@
35743742 return null;
35753743 }
35763744
3577
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35783745
35793746 public void Save()
35803747 {
3581
- Save(true);
3748
+ //Save(true);
3749
+ Replace();
3750
+ SetUndoStates();
35823751 }
35833752
35843753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3597,50 +3766,62 @@
35973766 return true;
35983767 }
35993768
3769
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3770
+
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
+
36003783 public boolean Save(boolean user)
36013784 {
36023785 System.err.println("Save");
3786
+ //Replace();
36033787
36043788 cRadio tab = GetCurrentTab();
36053789
3606
- boolean temp = CameraPane.SWITCH;
3607
- CameraPane.SWITCH = false;
3608
-
3609
- copy.ExtractBigData(hashtable);
3610
-
3611
- byte[] compress = Compress(copy);
3612
-
3613
- CameraPane.SWITCH = temp;
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36143791
36153792 boolean thesame = false;
36163793
3617
- // Quick heuristic using length. Works only when stream is compressed.
3618
- if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3619
- {
3620
- thesame = true;
3621
- }
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
36223798
36233799 //EditorFrame.m_MainFrame.requestFocusInWindow();
36243800 if (!thesame)
36253801 {
3626
- //tab.user[tab.undoindex] = user;
3627
- boolean increment = tab.graphs[tab.undoindex] == null;
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
36283806
3629
- tab.graphs[tab.undoindex] = compress;
3807
+ //tab.user[tab.versionindex] = user;
3808
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36303809
3631
- if (increment)
3632
- tab.undoindex++;
3810
+ copy.versionlist[++copy.versionindex] = compress;
3811
+
3812
+ // if (increment)
3813
+ // tab.versionindex++;
36333814 }
36343815
3635
- copy.RestoreBigData(hashtable);
3816
+ //copy.RestoreBigData(versiontable);
36363817
36373818 //assert(hashtable.isEmpty());
36383819
3639
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3640
- {
3641
- //tab.user[i] = false;
3642
- // tab.graphs[i] = null;
3643
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
36443825
36453826 SetUndoStates();
36463827
....@@ -3649,7 +3830,7 @@
36493830 {
36503831 try
36513832 {
3652
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3833
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
36533834 ObjectOutputStream p = new ObjectOutputStream(ostream);
36543835
36553836 p.writeObject(copy);
....@@ -3665,27 +3846,65 @@
36653846
36663847 return !thesame;
36673848 }
3668
-
3669
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
36703853 {
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
+
36713886 SetUndoStates();
36723887
36733888 boolean temp = CameraPane.SWITCH;
36743889 CameraPane.SWITCH = false;
36753890
3676
- copy.ExtractBigData(hashtable);
3891
+ copy.ExtractBigData(versiontable);
36773892
36783893 copy.clear();
36793894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
36803898 for (int i=0; i<obj.Size(); i++)
36813899 {
36823900 copy.add(obj.get(i));
36833901 }
36843902
3685
- copy.RestoreBigData(hashtable);
3903
+ copy.RestoreBigData(versiontable);
36863904
36873905 CameraPane.SWITCH = temp;
36883906
3907
+ RefreshSelection();
36893908 //assert(hashtable.isEmpty());
36903909
36913910 copy.Touch();
....@@ -3706,68 +3925,139 @@
37063925 }
37073926 }
37083927
3709
- refreshContents();
3928
+ refreshContents(true);
37103929 }
37113930
3712
- cButton undoButton;
3713
- cButton redoButton;
3931
+ cButton previousVersionButton;
3932
+ cButton restoreButton;
3933
+ cButton replaceButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
37143937
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
+
37153953 void SetUndoStates()
37163954 {
37173955 cRadio tab = GetCurrentTab();
37183956
3719
- undoButton.setEnabled(tab.undoindex > 0);
3720
- redoButton.setEnabled(tab.graphs[tab.undoindex + 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;
37213970 }
37223971
3723
- public boolean Undo()
3972
+ public boolean PreviousVersion()
37243973 {
3974
+ // Option?
3975
+ Replace();
3976
+
37253977 System.err.println("Undo");
37263978
37273979 cRadio tab = GetCurrentTab();
37283980
3729
- if (tab.undoindex == 0)
3981
+ if (copy.versionindex == 0)
37303982 {
37313983 java.awt.Toolkit.getDefaultToolkit().beep();
37323984 return false;
37333985 }
37343986
3735
- if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
3736
- {
3737
- if (Save(false))
3738
- tab.undoindex -= 1;
3739
- else
3740
- {
3741
- if (tab.undoindex <= 0)
3742
- return false;
3743
- else
3744
- tab.undoindex -= 1;
3745
- }
3746
- }
3987
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3988
+// {
3989
+// if (Save(false))
3990
+// tab.versionindex -= 1;
3991
+// else
3992
+// {
3993
+// if (tab.versionindex <= 0)
3994
+// return false;
3995
+// else
3996
+// tab.versionindex -= 1;
3997
+// }
3998
+// }
37473999
3748
- tab.undoindex -= 1;
4000
+ copy.versionindex -= 1;
37494001
3750
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged();
37514003
37524004 return true;
37534005 }
37544006
3755
- public void Redo()
4007
+ public boolean Restore()
37564008 {
4009
+ System.err.println("Restore");
4010
+
37574011 cRadio tab = GetCurrentTab();
37584012
3759
- if (tab.graphs[tab.undoindex + 1] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4014
+ {
4015
+ java.awt.Toolkit.getDefaultToolkit().beep();
4016
+ return false;
4017
+ }
4018
+
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
4021
+
4022
+ return true;
4023
+ }
4024
+
4025
+ public boolean Replace()
4026
+ {
4027
+ System.err.println("Replace");
4028
+
4029
+ cRadio tab = GetCurrentTab();
4030
+
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4032
+ {
4033
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4034
+ return false;
4035
+ }
4036
+
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
4038
+
4039
+ return true;
4040
+ }
4041
+
4042
+ public void NextVersion()
4043
+ {
4044
+ // Option?
4045
+ Replace();
4046
+
4047
+ cRadio tab = GetCurrentTab();
4048
+
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
37604050 {
37614051 java.awt.Toolkit.getDefaultToolkit().beep();
37624052 return;
37634053 }
37644054
3765
- tab.undoindex += 1;
4055
+ copy.versionindex += 1;
37664056
3767
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4057
+ CopyChanged();
37684058
3769
- //if (!tab.user[tab.undoindex])
3770
- // tab.graphs[tab.undoindex] = null;
4059
+ //if (!tab.user[tab.versionindex])
4060
+ // tab.graphs[tab.versionindex] = null;
37714061 }
37724062
37734063 void ImportGFD()
....@@ -3978,7 +4268,7 @@
39784268 //copy.material = new cMaterial(copy.GetMaterial());
39794269
39804270 current.color = (float) colorField.getFloat();
3981
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
39824272 current.metalness = (float) metalnessField.getFloat();
39834273 current.diffuse = (float) diffuseField.getFloat();
39844274 current.specular = (float) specularField.getFloat();
....@@ -4011,7 +4301,7 @@
40114301 cMaterial mat = copy.material;
40124302
40134303 colorField.SetToolTipValue((mat.color));
4014
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
40154305 metalnessField.SetToolTipValue((mat.metalness));
40164306 diffuseField.SetToolTipValue((mat.diffuse));
40174307 specularField.SetToolTipValue((mat.specular));
....@@ -4063,9 +4353,26 @@
40634353 //copy.Touch();
40644354 }
40654355
4356
+ cNumberSlider versionSlider;
4357
+
40664358 public void stateChanged(ChangeEvent e)
40674359 {
40684360 // assert(false);
4361
+ if (e.getSource() == versionSlider)
4362
+ {
4363
+ if (muteSlider)
4364
+ return;
4365
+
4366
+ int version = versionSlider.getInteger();
4367
+
4368
+ if (copy.versionlist[version] != null)
4369
+ {
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
4372
+ }
4373
+
4374
+ return;
4375
+ }
40694376
40704377 if (freezematerial)
40714378 {
....@@ -4101,6 +4408,12 @@
41014408 {
41024409 //System.out.println("stateChanged = " + this);
41034410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
41044417 applySelf();
41054418 //System.out.println("this = " + this);
41064419 //System.out.println("PARENT = " + parent);
....@@ -4400,6 +4713,7 @@
44004713 {
44014714 if (GetTree() != null)
44024715 {
4716
+ GetTree().revalidate();
44034717 GetTree().repaint();
44044718 }
44054719
....@@ -4408,13 +4722,16 @@
44084722 ctrlPanel.validate(); // ? new
44094723 ctrlPanel.repaint();
44104724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
44114728 }
44124729
44134730 static TweenManager tweenManager = new TweenManager();
44144731
44154732 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
44164733 {
4417
- if (Globals.SAVEONMAKE) // && resetmodel)
4734
+ if (Globals.REPLACEONMAKE) // && resetmodel)
44184735 Save();
44194736 //Tween.set(thing, 0).target(1).start(tweenManager);
44204737 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4656,7 +4973,9 @@
46564973 readobj.ResetDisplayList();
46574974 } catch (Exception e)
46584975 {
4659
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
46604979 try
46614980 {
46624981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4736,6 +5055,8 @@
47365055 {
47375056 //readobj.deepCopySelf(copy);
47385057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
47395060 for (int i = 0; i < readobj.size(); i++)
47405061 {
47415062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4776,6 +5097,7 @@
47765097 }
47775098 } catch (ClassCastException e)
47785099 {
5100
+ e.printStackTrace();
47795101 assert (false);
47805102 Composite c = (Composite) copy;
47815103 c.children.clear();
....@@ -4786,6 +5108,17 @@
47865108 c.addChild(csg);
47875109 }
47885110
5111
+ copy.versionlist = readobj.versionlist;
5112
+ copy.versionindex = readobj.versionindex;
5113
+
5114
+ if (copy.versionlist == null)
5115
+ {
5116
+ copy.versionlist = new Object3D[100];
5117
+ copy.versionindex = -1;
5118
+ }
5119
+
5120
+ //? SetUndoStates();
5121
+
47895122 ResetModel();
47905123 copy.HardTouch(); // recompile?
47915124 refreshContents();
....@@ -4796,7 +5129,7 @@
47965129 {
47975130 if (Grafreed.standAlone)
47985131 {
4799
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
48005133 browser.show();
48015134 String filename = browser.getFile();
48025135 if (filename != null && filename.length() > 0)
....@@ -4895,6 +5228,7 @@
48955228 //ps.print(buffer.toString());
48965229 } catch (IOException e)
48975230 {
5231
+ e.printStackTrace();
48985232 }
48995233 }
49005234
....@@ -5187,7 +5521,7 @@
51875521 JLabel colorLabel;
51885522 cNumberSlider colorField;
51895523 JLabel modulationLabel;
5190
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
51915525 JLabel metalnessLabel;
51925526 cNumberSlider metalnessField;
51935527 JLabel diffuseLabel;