Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
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
....@@ -816,7 +850,7 @@
816850 frame.validate();
817851 }
818852
819
- private byte[] CompressCopy()
853
+ private Object3D CompressCopy()
820854 {
821855 boolean temp = CameraPane.SWITCH;
822856 CameraPane.SWITCH = false;
....@@ -824,12 +858,13 @@
824858 copy.ExtractBigData(versiontable);
825859 // if (copy == client)
826860
827
- byte[] versions[] = copy.versions;
828
- copy.versions = null;
861
+ Object3D versions[] = copy.versionlist;
862
+ copy.versionlist = null;
829863
830
- byte[] compress = Compress(copy);
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
831866
832
- copy.versions = versions;
867
+ copy.versionlist = versions;
833868
834869 copy.RestoreBigData(versiontable);
835870
....@@ -959,6 +994,7 @@
959994 {
960995 SetupMaterial(materialPanel);
961996 }
997
+
962998 //SetupName();
963999 //SetupViews();
9641000 }
....@@ -968,7 +1004,7 @@
9681004 // NumberSlider vDivsField;
9691005 // JCheckBox endcaps;
9701006 JCheckBox liveCB;
971
- JCheckBox selectCB;
1007
+ JCheckBox selectableCB;
9721008 JCheckBox hideCB;
9731009 JCheckBox link2masterCB;
9741010 JCheckBox markCB;
....@@ -1180,13 +1216,16 @@
11801216
11811217 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11821218 liveCB.setToolTipText("Animate object");
1183
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1184
- selectCB.setToolTipText("Make object selectable");
1219
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1220
+ selectableCB.setToolTipText("Make object selectable");
11851221 // Return();
1222
+
11861223 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11871224 hideCB.setToolTipText("Hide object");
11881225 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11891226 markCB.setToolTipText("As animation target transform");
1227
+
1228
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11901229
11911230 setupPanel2 = new cGridBag().setVertical(false);
11921231
....@@ -1474,6 +1513,7 @@
14741513 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14751514 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14761515 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1516
+ //XYZPanel.setName("XYZ");
14771517
14781518 /*
14791519 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1511,16 +1551,29 @@
15111551 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15121552 //tmp.setName("Edit");
15131553 objectPanel.add(materialPanel);
1554
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
+ objectPanel.setToolTipTextAt(0, "Material");
1556
+
15141557 // JPanel north = new JPanel(new BorderLayout());
15151558 // north.setName("Edit");
15161559 // north.add(ctrlPanel, BorderLayout.NORTH);
15171560 // objectPanel.add(north);
15181561 objectPanel.add(editPanel);
1562
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15191564
15201565 //if (Globals.ADVANCED)
15211566 objectPanel.add(infoPanel);
1567
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
+ objectPanel.setToolTipTextAt(2, "Information");
1569
+
1570
+ objectPanel.add(XYZPanel);
1571
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15221573
15231574 objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15241577
15251578 /*
15261579 aConstraints.gridx = 0;
....@@ -1541,7 +1594,7 @@
15411594 scrollpane.addMouseWheelListener(this); // Default not fast enough
15421595
15431596 /*JTabbedPane*/ scenePanel = new cGridBag();
1544
- scenePanel.preferredWidth = 6;
1597
+ scenePanel.preferredWidth = 5;
15451598
15461599 JTabbedPane tabbedPane = new JTabbedPane();
15471600 tabbedPane.add(scrollpane);
....@@ -1619,7 +1672,7 @@
16191672 bigThree = new cGridBag();
16201673 bigThree.addComponent(scenePanel);
16211674 bigThree.addComponent(centralPanel);
1622
- bigThree.addComponent(XYZPanel);
1675
+ //bigThree.addComponent(XYZPanel);
16231676
16241677 // // SIDE EFFECT!!!
16251678 // aConstraints.gridx = 0;
....@@ -1660,7 +1713,6 @@
16601713 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16611714 frame.addWindowListener(new WindowAdapter()
16621715 {
1663
-
16641716 public void windowClosing(WindowEvent e)
16651717 {
16661718 Close();
....@@ -1683,12 +1735,56 @@
16831735 ctrlPanel.removeAll();
16841736 }
16851737
1686
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
16871739 {
1688
- /*
1740
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1741
+ cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
+ label.addMouseListener(new MouseAdapter()
1743
+ {
1744
+ public void mouseClicked(MouseEvent e)
1745
+ {
1746
+ colorField.setFloat(0);
1747
+ saturationField.setFloat(1);
1748
+ materialtouched = true;
1749
+ applySelf();
1750
+ }
1751
+ });
1752
+ presetpanel.add(label);
1753
+
1754
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
1774
+
1775
+ cGridBag panel = new cGridBag().setVertical(true);
1776
+
1777
+ presetpanel.preferredWidth = 1;
1778
+
1779
+ materialpanel.add(panel);
1780
+ materialpanel.add(presetpanel);
1781
+
1782
+ panel.preferredWidth = 8;
1783
+
1784
+ /*
16891785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16901786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- */
1787
+ */
16921788
16931789 cGridBag editBar = new cGridBag().setVertical(false);
16941790
....@@ -1722,27 +1818,50 @@
17221818 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17231819
17241820 cGridBag colorSection = new cGridBag().setVertical(true);
1821
+
1822
+ cGridBag huepanel = new cGridBag();
1823
+ cGridBag huelabel = new cGridBag();
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
1827
+ huelabel.preferredWidth = 20;
1828
+ huepanel.add(new cGridBag()); // Label
1829
+ huepanel.add(huelabel); // Field/slider
1830
+
1831
+ huepanel.preferredHeight = 7;
1832
+
1833
+ colorSection.add(huepanel);
17251834
17261835 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);
1836
+
1837
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1838
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1839
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1840
+
17301841 //colorField.preferredWidth = 200;
17311842 colorSection.add(color);
17321843
17331844 cGridBag modulation = new cGridBag();
17341845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17351846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1736
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17371848 colorSection.add(modulation);
17381849
1850
+ cGridBag opacity = new cGridBag();
1851
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1852
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1853
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1854
+ colorSection.add(opacity);
1855
+
1856
+ colorSection.add(GetSeparator());
1857
+
17391858 cGridBag texture = new cGridBag();
17401859 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17411860 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17421861 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17431862 colorSection.add(texture);
17441863
1745
- panel.add(new JSeparator());
1864
+ panel.add(GetSeparator());
17461865
17471866 panel.add(colorSection);
17481867
....@@ -1798,7 +1917,7 @@
17981917 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17991918 diffuseSection.add(shadowbias);
18001919
1801
- panel.add(new JSeparator());
1920
+ panel.add(GetSeparator());
18021921
18031922 panel.add(diffuseSection);
18041923
....@@ -1861,7 +1980,7 @@
18611980 specularSection.add(anisoV);
18621981
18631982
1864
- panel.add(new JSeparator());
1983
+ panel.add(GetSeparator());
18651984
18661985 panel.add(specularSection);
18671986
....@@ -1886,12 +2005,6 @@
18862005 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18872006 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18882007 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);
18952008
18962009 //panel.add(new JSeparator());
18972010
....@@ -1937,7 +2050,7 @@
19372050 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19382051 textureSection.add(opacityPower);
19392052
1940
- panel.add(new JSeparator());
2053
+ panel.add(GetSeparator());
19412054
19422055 panel.add(textureSection);
19432056
....@@ -2924,7 +3037,7 @@
29243037
29253038 freezematerial = true;
29263039 colorField.setFloat(mat.color);
2927
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
29283041 metalnessField.setFloat(mat.metalness);
29293042 diffuseField.setFloat(mat.diffuse);
29303043 specularField.setFloat(mat.specular);
....@@ -3235,8 +3348,9 @@
32353348 } else if (event.getSource() == liveCB)
32363349 {
32373350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
32383352 return;
3239
- } else if (event.getSource() == selectCB)
3353
+ } else if (event.getSource() == selectableCB)
32403354 {
32413355 copy.dontselect ^= true;
32423356 return;
....@@ -3244,7 +3358,7 @@
32443358 {
32453359 copy.hide ^= true;
32463360 copy.Touch(); // display list issue
3247
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
32483362 return;
32493363 } else if (event.getSource() == link2masterCB)
32503364 {
....@@ -3500,6 +3614,7 @@
35003614
35013615 static public byte[] Compress(Object3D o)
35023616 {
3617
+ // Slower to actually compress.
35033618 try
35043619 {
35053620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3601,6 +3716,7 @@
36013716 {
36023717 //Save(true);
36033718 Replace();
3719
+ SetUndoStates();
36043720 }
36053721
36063722 private boolean Equal(byte[] compress, byte[] name)
....@@ -3624,18 +3740,18 @@
36243740 public boolean Save(boolean user)
36253741 {
36263742 System.err.println("Save");
3743
+ Replace();
36273744
36283745 cRadio tab = GetCurrentTab();
36293746
3630
- byte[] compress = CompressCopy();
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
36313748
36323749 boolean thesame = false;
36333750
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
- }
3751
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3752
+// {
3753
+// thesame = true;
3754
+// }
36393755
36403756 //EditorFrame.m_MainFrame.requestFocusInWindow();
36413757 if (!thesame)
....@@ -3643,7 +3759,7 @@
36433759 //tab.user[tab.versionindex] = user;
36443760 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36453761
3646
- copy.versions[++copy.versionindex] = compress;
3762
+ copy.versionlist[++copy.versionindex] = compress;
36473763
36483764 // if (increment)
36493765 // tab.versionindex++;
....@@ -3653,10 +3769,10 @@
36533769
36543770 //assert(hashtable.isEmpty());
36553771
3656
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
36573773 {
36583774 //tab.user[i] = false;
3659
- copy.versions[i] = null;
3775
+ copy.versionlist[i] = null;
36603776 }
36613777
36623778 SetUndoStates();
....@@ -3682,6 +3798,38 @@
36823798
36833799 return !thesame;
36843800 }
3801
+
3802
+ boolean flashIt = true;
3803
+
3804
+ void RefreshSelection()
3805
+ {
3806
+ Object3D selection = new Object3D();
3807
+
3808
+ for (int i = 0; i < copy.selection.size(); i++)
3809
+ {
3810
+ Object3D elem = copy.selection.elementAt(i);
3811
+
3812
+ Object3D obj = copy.GetObject(elem.GetUUID());
3813
+
3814
+ if (obj == null)
3815
+ {
3816
+ copy.selection.remove(i--);
3817
+ }
3818
+ else
3819
+ {
3820
+ selection.add(obj);
3821
+ copy.selection.setElementAt(obj, i);
3822
+ }
3823
+ }
3824
+
3825
+ flashIt = false;
3826
+ GetTree().clearSelection();
3827
+ for (int i = 0; i < selection.size(); i++)
3828
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3829
+ flashIt = true;
3830
+
3831
+ refreshContents(false);
3832
+ }
36853833
36863834 void CopyChanged(Object3D obj)
36873835 {
....@@ -3694,6 +3842,9 @@
36943842
36953843 copy.clear();
36963844
3845
+ copy.skyboxname = obj.skyboxname;
3846
+ copy.skyboxext = obj.skyboxext;
3847
+
36973848 for (int i=0; i<obj.Size(); i++)
36983849 {
36993850 copy.add(obj.get(i));
....@@ -3703,6 +3854,7 @@
37033854
37043855 CameraPane.SWITCH = temp;
37053856
3857
+ RefreshSelection();
37063858 //assert(hashtable.isEmpty());
37073859
37083860 copy.Touch();
....@@ -3731,18 +3883,42 @@
37313883 cButton replaceButton;
37323884 cButton redoButton;
37333885
3886
+ boolean muteSlider;
3887
+
3888
+ int VersionCount()
3889
+ {
3890
+ int count = 0;
3891
+
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
3893
+ {
3894
+ if (copy.versionlist[i] != null)
3895
+ count++;
3896
+ }
3897
+
3898
+ return count;
3899
+ }
3900
+
37343901 void SetUndoStates()
37353902 {
37363903 cRadio tab = GetCurrentTab();
37373904
37383905 restoreButton.setEnabled(copy.versionindex != -1);
37393906 replaceButton.setEnabled(copy.versionindex != -1);
3907
+
37403908 undoButton.setEnabled(copy.versionindex > 0);
3741
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3910
+
3911
+ muteSlider = true;
3912
+ versionSlider.setMaximum(VersionCount() - 1);
3913
+ versionSlider.setInteger(copy.versionindex);
3914
+ muteSlider = false;
37423915 }
37433916
37443917 public boolean Undo()
37453918 {
3919
+ // Option?
3920
+ Replace();
3921
+
37463922 System.err.println("Undo");
37473923
37483924 cRadio tab = GetCurrentTab();
....@@ -3768,7 +3944,7 @@
37683944
37693945 copy.versionindex -= 1;
37703946
3771
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
37723948
37733949 return true;
37743950 }
....@@ -3779,13 +3955,14 @@
37793955
37803956 cRadio tab = GetCurrentTab();
37813957
3782
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
37833959 {
37843960 java.awt.Toolkit.getDefaultToolkit().beep();
37853961 return false;
37863962 }
37873963
3788
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
37893966
37903967 return true;
37913968 }
....@@ -3796,22 +3973,25 @@
37963973
37973974 cRadio tab = GetCurrentTab();
37983975
3799
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38003977 {
38013978 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38023979 return false;
38033980 }
38043981
3805
- copy.versions[copy.versionindex] = CompressCopy();
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
38063983
38073984 return true;
38083985 }
38093986
38103987 public void Redo()
38113988 {
3989
+ // Option?
3990
+ Replace();
3991
+
38123992 cRadio tab = GetCurrentTab();
38133993
3814
- if (copy.versions[copy.versionindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
38153995 {
38163996 java.awt.Toolkit.getDefaultToolkit().beep();
38173997 return;
....@@ -3819,7 +3999,7 @@
38193999
38204000 copy.versionindex += 1;
38214001
3822
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
38234003
38244004 //if (!tab.user[tab.versionindex])
38254005 // tab.graphs[tab.versionindex] = null;
....@@ -4033,7 +4213,7 @@
40334213 //copy.material = new cMaterial(copy.GetMaterial());
40344214
40354215 current.color = (float) colorField.getFloat();
4036
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
40374217 current.metalness = (float) metalnessField.getFloat();
40384218 current.diffuse = (float) diffuseField.getFloat();
40394219 current.specular = (float) specularField.getFloat();
....@@ -4066,7 +4246,7 @@
40664246 cMaterial mat = copy.material;
40674247
40684248 colorField.SetToolTipValue((mat.color));
4069
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
40704250 metalnessField.SetToolTipValue((mat.metalness));
40714251 diffuseField.SetToolTipValue((mat.diffuse));
40724252 specularField.SetToolTipValue((mat.specular));
....@@ -4118,18 +4298,21 @@
41184298 //copy.Touch();
41194299 }
41204300
4121
- cNumberSlider versionField;
4301
+ cNumberSlider versionSlider;
41224302
41234303 public void stateChanged(ChangeEvent e)
41244304 {
41254305 // assert(false);
4126
- if (e.getSource() == versionField)
4306
+ if (e.getSource() == versionSlider)
41274307 {
4128
- int version = versionField.getInteger();
4308
+ if (muteSlider)
4309
+ return;
41294310
4130
- if (copy.versions[version] != null)
4311
+ int version = versionSlider.getInteger();
4312
+
4313
+ if (copy.versionlist[version] != null)
41314314 {
4132
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
41334316 }
41344317
41354318 return;
....@@ -4169,6 +4352,12 @@
41694352 {
41704353 //System.out.println("stateChanged = " + this);
41714354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
41724361 applySelf();
41734362 //System.out.println("this = " + this);
41744363 //System.out.println("PARENT = " + parent);
....@@ -4468,6 +4657,7 @@
44684657 {
44694658 if (GetTree() != null)
44704659 {
4660
+ GetTree().revalidate();
44714661 GetTree().repaint();
44724662 }
44734663
....@@ -4724,7 +4914,9 @@
47244914 readobj.ResetDisplayList();
47254915 } catch (Exception e)
47264916 {
4727
- //e.printStackTrace();
4917
+ if (!e.toString().contains("GZIP"))
4918
+ e.printStackTrace();
4919
+
47284920 try
47294921 {
47304922 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4804,6 +4996,8 @@
48044996 {
48054997 //readobj.deepCopySelf(copy);
48064998 copy.clear(); // june 2014
4999
+ copy.skyboxname = readobj.skyboxname;
5000
+ copy.skyboxext = readobj.skyboxext;
48075001 for (int i = 0; i < readobj.size(); i++)
48085002 {
48095003 Object3D child = readobj.get(i); // reserve(i);
....@@ -4844,6 +5038,7 @@
48445038 }
48455039 } catch (ClassCastException e)
48465040 {
5041
+ e.printStackTrace();
48475042 assert (false);
48485043 Composite c = (Composite) copy;
48495044 c.children.clear();
....@@ -4854,10 +5049,16 @@
48545049 c.addChild(csg);
48555050 }
48565051
4857
- copy.versions = readobj.versions;
5052
+ copy.versionlist = readobj.versionlist;
48585053 copy.versionindex = readobj.versionindex;
48595054
4860
- SetUndoStates();
5055
+ if (copy.versionlist == null)
5056
+ {
5057
+ copy.versionlist = new Object3D[100];
5058
+ copy.versionindex = -1;
5059
+ }
5060
+
5061
+ //? SetUndoStates();
48615062
48625063 ResetModel();
48635064 copy.HardTouch(); // recompile?
....@@ -4968,6 +5169,7 @@
49685169 //ps.print(buffer.toString());
49695170 } catch (IOException e)
49705171 {
5172
+ e.printStackTrace();
49715173 }
49725174 }
49735175
....@@ -5260,7 +5462,7 @@
52605462 JLabel colorLabel;
52615463 cNumberSlider colorField;
52625464 JLabel modulationLabel;
5263
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
52645466 JLabel metalnessLabel;
52655467 cNumberSlider metalnessField;
52665468 JLabel diffuseLabel;