Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
ObjEditor.java
....@@ -41,11 +41,25 @@
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 {
4755 ImageIcon icon = GetIcon(name);
4856 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);
4963 }
5064
5165 cToggleButton GetToggleButton(String name, boolean border)
....@@ -80,6 +94,20 @@
8094
8195 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
8296 return icon;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
83111 }
84112 catch (Exception e)
85113 {
....@@ -270,7 +298,7 @@
270298
271299 if (copy.versions == null)
272300 {
273
- copy.versions = new byte[100][];
301
+ copy.versions = new Object3D[100];
274302 copy.versionindex = -1;
275303 }
276304
....@@ -289,7 +317,7 @@
289317
290318 if (copy.versions == null)
291319 {
292
- copy.versions = new byte[100][];
320
+ copy.versions = new Object3D[100];
293321 copy.versionindex = -1;
294322 }
295323
....@@ -822,7 +850,7 @@
822850 frame.validate();
823851 }
824852
825
- private byte[] CompressCopy()
853
+ private Object3D CompressCopy()
826854 {
827855 boolean temp = CameraPane.SWITCH;
828856 CameraPane.SWITCH = false;
....@@ -830,10 +858,11 @@
830858 copy.ExtractBigData(versiontable);
831859 // if (copy == client)
832860
833
- byte[] versions[] = copy.versions;
861
+ Object3D versions[] = copy.versions;
834862 copy.versions = null;
835863
836
- byte[] compress = Compress(copy);
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
837866
838867 copy.versions = versions;
839868
....@@ -1522,22 +1551,28 @@
15221551 //tmp.setName("Edit");
15231552 objectPanel.add(materialPanel);
15241553 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
15251556 // JPanel north = new JPanel(new BorderLayout());
15261557 // north.setName("Edit");
15271558 // north.add(ctrlPanel, BorderLayout.NORTH);
15281559 // objectPanel.add(north);
15291560 objectPanel.add(editPanel);
15301561 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
+ objectPanel.setToolTipTextAt(1, "Edit panel");
15311563
15321564 //if (Globals.ADVANCED)
15331565 objectPanel.add(infoPanel);
15341566 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
+ objectPanel.setToolTipTextAt(2, "Info panel");
15351568
15361569 objectPanel.add(XYZPanel);
15371570 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15381572
15391573 objectPanel.add(toolboxPanel);
15401574 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15411576
15421577 /*
15431578 aConstraints.gridx = 0;
....@@ -1634,8 +1669,8 @@
16341669 /**/
16351670
16361671 bigThree = new cGridBag();
1637
- bigThree.addComponent(centralPanel);
16381672 bigThree.addComponent(scenePanel);
1673
+ bigThree.addComponent(centralPanel);
16391674 //bigThree.addComponent(XYZPanel);
16401675
16411676 // // SIDE EFFECT!!!
....@@ -1677,7 +1712,6 @@
16771712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16781713 frame.addWindowListener(new WindowAdapter()
16791714 {
1680
-
16811715 public void windowClosing(WindowEvent e)
16821716 {
16831717 Close();
....@@ -1739,27 +1773,48 @@
17391773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17401774
17411775 cGridBag colorSection = new cGridBag().setVertical(true);
1776
+
1777
+ cGridBag huepanel = new cGridBag();
1778
+ cGridBag huelabel = new cGridBag();
1779
+ huelabel.add(GetLabel("icons/hue.png", false));
1780
+ huelabel.preferredWidth = 20;
1781
+ huepanel.add(new cGridBag()); // Label
1782
+ huepanel.add(huelabel); // Field/slider
1783
+
1784
+ huepanel.preferredHeight = 7;
1785
+
1786
+ colorSection.add(huepanel);
17421787
17431788 cGridBag color = new cGridBag();
1744
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1745
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1746
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1789
+
1790
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1791
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1792
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1793
+
17471794 //colorField.preferredWidth = 200;
17481795 colorSection.add(color);
17491796
17501797 cGridBag modulation = new cGridBag();
17511798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17521799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1753
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17541801 colorSection.add(modulation);
17551802
1803
+ cGridBag opacity = new cGridBag();
1804
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1805
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1806
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1807
+ colorSection.add(opacity);
1808
+
1809
+ colorSection.add(GetSeparator());
1810
+
17561811 cGridBag texture = new cGridBag();
17571812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17581813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17591814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17601815 colorSection.add(texture);
17611816
1762
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
17631818
17641819 panel.add(colorSection);
17651820
....@@ -1815,7 +1870,7 @@
18151870 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18161871 diffuseSection.add(shadowbias);
18171872
1818
- panel.add(new JSeparator());
1873
+ panel.add(GetSeparator());
18191874
18201875 panel.add(diffuseSection);
18211876
....@@ -1878,7 +1933,7 @@
18781933 specularSection.add(anisoV);
18791934
18801935
1881
- panel.add(new JSeparator());
1936
+ panel.add(GetSeparator());
18821937
18831938 panel.add(specularSection);
18841939
....@@ -1903,12 +1958,6 @@
19031958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19041959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19051960 colorSection.add(backlit);
1906
-
1907
- cGridBag opacity = new cGridBag();
1908
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1909
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1910
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1911
- colorSection.add(opacity);
19121961
19131962 //panel.add(new JSeparator());
19141963
....@@ -1954,7 +2003,7 @@
19542003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19552004 textureSection.add(opacityPower);
19562005
1957
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
19582007
19592008 panel.add(textureSection);
19602009
....@@ -3517,6 +3566,7 @@
35173566
35183567 static public byte[] Compress(Object3D o)
35193568 {
3569
+ // Slower to actually compress.
35203570 try
35213571 {
35223572 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3644,15 +3694,14 @@
36443694
36453695 cRadio tab = GetCurrentTab();
36463696
3647
- byte[] compress = CompressCopy();
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
36483698
36493699 boolean thesame = false;
36503700
3651
- // Quick heuristic using length. Works only when stream is compressed.
3652
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3653
- {
3654
- thesame = true;
3655
- }
3701
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3702
+// {
3703
+// thesame = true;
3704
+// }
36563705
36573706 //EditorFrame.m_MainFrame.requestFocusInWindow();
36583707 if (!thesame)
....@@ -3711,6 +3760,9 @@
37113760
37123761 copy.clear();
37133762
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
37143766 for (int i=0; i<obj.Size(); i++)
37153767 {
37163768 copy.add(obj.get(i));
....@@ -3809,7 +3861,7 @@
38093861
38103862 copy.versionindex -= 1;
38113863
3812
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+ CopyChanged((Object3D)copy.versions[copy.versionindex]);
38133865
38143866 return true;
38153867 }
....@@ -3826,7 +3878,8 @@
38263878 return false;
38273879 }
38283880
3829
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
38303883
38313884 return true;
38323885 }
....@@ -3863,7 +3916,7 @@
38633916
38643917 copy.versionindex += 1;
38653918
3866
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3919
+ CopyChanged(copy.versions[copy.versionindex]);
38673920
38683921 //if (!tab.user[tab.versionindex])
38693922 // tab.graphs[tab.versionindex] = null;
....@@ -4176,7 +4229,7 @@
41764229
41774230 if (copy.versions[version] != null)
41784231 {
4179
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4232
+ CopyChanged(copy.versions[copy.versionindex = version]);
41804233 }
41814234
41824235 return;
....@@ -4853,6 +4906,8 @@
48534906 {
48544907 //readobj.deepCopySelf(copy);
48554908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
48564911 for (int i = 0; i < readobj.size(); i++)
48574912 {
48584913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4909,7 +4964,7 @@
49094964
49104965 if (copy.versions == null)
49114966 {
4912
- copy.versions = new byte[100][];
4967
+ copy.versions = new Object3D[100];
49134968 copy.versionindex = -1;
49144969 }
49154970