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)
....@@ -60,26 +74,40 @@
6074 return new cCheckBox(icon, border);
6175 }
6276
63
- private ImageIcon GetIcon(String name)
77
+ ImageIcon GetIcon(String name)
6478 {
6579 try
6680 {
6781 BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
6882
69
- if (image.getWidth() != 24 && image.getHeight() != 24)
70
- {
71
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
72
- Graphics2D g = resized.createGraphics();
73
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
76
- g.dispose();
77
-
78
- image = resized;
79
- }
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
+// }
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
....@@ -436,7 +464,7 @@
436464 editPanel.add(editCommandsPanel);
437465 editPanel.add(ctrlPanel);
438466
439
- toolboxPanel = new cGridBag().setVertical(false);
467
+ toolboxPanel = new cGridBag().setVertical(true);
440468 //toolboxPanel.setName("Toolbox");
441469
442470 materialPanel = new cGridBag().setVertical(true);
....@@ -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
....@@ -1195,6 +1224,8 @@
11951224 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11961225 markCB.setToolTipText("As animation target transform");
11971226
1227
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1228
+
11981229 setupPanel2 = new cGridBag().setVertical(false);
11991230
12001231 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
....@@ -1520,22 +1551,28 @@
15201551 //tmp.setName("Edit");
15211552 objectPanel.add(materialPanel);
15221553 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
15231556 // JPanel north = new JPanel(new BorderLayout());
15241557 // north.setName("Edit");
15251558 // north.add(ctrlPanel, BorderLayout.NORTH);
15261559 // objectPanel.add(north);
15271560 objectPanel.add(editPanel);
15281561 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
+ objectPanel.setToolTipTextAt(1, "Edit panel");
15291563
15301564 //if (Globals.ADVANCED)
15311565 objectPanel.add(infoPanel);
15321566 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
+ objectPanel.setToolTipTextAt(2, "Info panel");
15331568
15341569 objectPanel.add(XYZPanel);
15351570 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15361572
15371573 objectPanel.add(toolboxPanel);
15381574 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15391576
15401577 /*
15411578 aConstraints.gridx = 0;
....@@ -1675,7 +1712,6 @@
16751712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16761713 frame.addWindowListener(new WindowAdapter()
16771714 {
1678
-
16791715 public void windowClosing(WindowEvent e)
16801716 {
16811717 Close();
....@@ -1737,27 +1773,48 @@
17371773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17381774
17391775 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);
17401787
17411788 cGridBag color = new cGridBag();
1742
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1743
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1744
- 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
+
17451794 //colorField.preferredWidth = 200;
17461795 colorSection.add(color);
17471796
17481797 cGridBag modulation = new cGridBag();
17491798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17501799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1751
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17521801 colorSection.add(modulation);
17531802
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
+
17541811 cGridBag texture = new cGridBag();
17551812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17561813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17571814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17581815 colorSection.add(texture);
17591816
1760
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
17611818
17621819 panel.add(colorSection);
17631820
....@@ -1813,7 +1870,7 @@
18131870 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18141871 diffuseSection.add(shadowbias);
18151872
1816
- panel.add(new JSeparator());
1873
+ panel.add(GetSeparator());
18171874
18181875 panel.add(diffuseSection);
18191876
....@@ -1876,7 +1933,7 @@
18761933 specularSection.add(anisoV);
18771934
18781935
1879
- panel.add(new JSeparator());
1936
+ panel.add(GetSeparator());
18801937
18811938 panel.add(specularSection);
18821939
....@@ -1901,12 +1958,6 @@
19011958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19021959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19031960 colorSection.add(backlit);
1904
-
1905
- cGridBag opacity = new cGridBag();
1906
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1907
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1908
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1909
- colorSection.add(opacity);
19101961
19111962 //panel.add(new JSeparator());
19121963
....@@ -1952,7 +2003,7 @@
19522003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19532004 textureSection.add(opacityPower);
19542005
1955
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
19562007
19572008 panel.add(textureSection);
19582009
....@@ -3515,6 +3566,7 @@
35153566
35163567 static public byte[] Compress(Object3D o)
35173568 {
3569
+ // Slower to actually compress.
35183570 try
35193571 {
35203572 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3642,15 +3694,14 @@
36423694
36433695 cRadio tab = GetCurrentTab();
36443696
3645
- byte[] compress = CompressCopy();
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
36463698
36473699 boolean thesame = false;
36483700
3649
- // Quick heuristic using length. Works only when stream is compressed.
3650
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3651
- {
3652
- thesame = true;
3653
- }
3701
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3702
+// {
3703
+// thesame = true;
3704
+// }
36543705
36553706 //EditorFrame.m_MainFrame.requestFocusInWindow();
36563707 if (!thesame)
....@@ -3709,6 +3760,9 @@
37093760
37103761 copy.clear();
37113762
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
37123766 for (int i=0; i<obj.Size(); i++)
37133767 {
37143768 copy.add(obj.get(i));
....@@ -3807,7 +3861,7 @@
38073861
38083862 copy.versionindex -= 1;
38093863
3810
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+ CopyChanged((Object3D)copy.versions[copy.versionindex]);
38113865
38123866 return true;
38133867 }
....@@ -3824,7 +3878,8 @@
38243878 return false;
38253879 }
38263880
3827
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
38283883
38293884 return true;
38303885 }
....@@ -3861,7 +3916,7 @@
38613916
38623917 copy.versionindex += 1;
38633918
3864
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3919
+ CopyChanged(copy.versions[copy.versionindex]);
38653920
38663921 //if (!tab.user[tab.versionindex])
38673922 // tab.graphs[tab.versionindex] = null;
....@@ -4174,7 +4229,7 @@
41744229
41754230 if (copy.versions[version] != null)
41764231 {
4177
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4232
+ CopyChanged(copy.versions[copy.versionindex = version]);
41784233 }
41794234
41804235 return;
....@@ -4769,7 +4824,9 @@
47694824 readobj.ResetDisplayList();
47704825 } catch (Exception e)
47714826 {
4772
- e.printStackTrace();
4827
+ if (!e.toString().contains("GZIP"))
4828
+ e.printStackTrace();
4829
+
47734830 try
47744831 {
47754832 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4849,6 +4906,8 @@
48494906 {
48504907 //readobj.deepCopySelf(copy);
48514908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
48524911 for (int i = 0; i < readobj.size(); i++)
48534912 {
48544913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4905,7 +4964,7 @@
49054964
49064965 if (copy.versions == null)
49074966 {
4908
- copy.versions = new byte[100][];
4967
+ copy.versions = new Object3D[100];
49094968 copy.versionindex = -1;
49104969 }
49114970