Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
ObjEditor.java
....@@ -296,9 +296,9 @@
296296 client = inClient;
297297 copy = client;
298298
299
- if (copy.versions == null)
299
+ if (copy.versionlist == null)
300300 {
301
- copy.versions = new byte[100][];
301
+ copy.versionlist = new Object3D[100];
302302 copy.versionindex = -1;
303303 }
304304
....@@ -315,9 +315,9 @@
315315 client = inClient;
316316 copy = client;
317317
318
- if (copy.versions == null)
318
+ if (copy.versionlist == null)
319319 {
320
- copy.versions = new byte[100][];
320
+ copy.versionlist = new Object3D[100];
321321 copy.versionindex = -1;
322322 }
323323
....@@ -353,7 +353,7 @@
353353 copy = localCopy;
354354 copy.editWindow = this;
355355
356
- if (copy.versions == null)
356
+ if (copy.versionlist == null)
357357 {
358358 // copy.versions = new byte[100][];
359359 // copy.versionindex = -1;
....@@ -467,7 +467,7 @@
467467 toolboxPanel = new cGridBag().setVertical(true);
468468 //toolboxPanel.setName("Toolbox");
469469
470
- materialPanel = new cGridBag().setVertical(true);
470
+ materialPanel = new cGridBag().setVertical(false);
471471 //materialPanel.setName("Material");
472472
473473 /*JTextPane*/
....@@ -850,7 +850,7 @@
850850 frame.validate();
851851 }
852852
853
- private byte[] CompressCopy()
853
+ private Object3D CompressCopy()
854854 {
855855 boolean temp = CameraPane.SWITCH;
856856 CameraPane.SWITCH = false;
....@@ -858,12 +858,13 @@
858858 copy.ExtractBigData(versiontable);
859859 // if (copy == client)
860860
861
- byte[] versions[] = copy.versions;
862
- copy.versions = null;
861
+ Object3D versions[] = copy.versionlist;
862
+ copy.versionlist = null;
863863
864
- byte[] compress = Compress(copy);
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
865866
866
- copy.versions = versions;
867
+ copy.versionlist = versions;
867868
868869 copy.RestoreBigData(versiontable);
869870
....@@ -993,6 +994,7 @@
993994 {
994995 SetupMaterial(materialPanel);
995996 }
997
+
996998 //SetupName();
997999 //SetupViews();
9981000 }
....@@ -1550,7 +1552,7 @@
15501552 //tmp.setName("Edit");
15511553 objectPanel.add(materialPanel);
15521554 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
- objectPanel.setToolTipTextAt(0, "Material panel");
1555
+ objectPanel.setToolTipTextAt(0, "Material");
15541556
15551557 // JPanel north = new JPanel(new BorderLayout());
15561558 // north.setName("Edit");
....@@ -1558,20 +1560,20 @@
15581560 // objectPanel.add(north);
15591561 objectPanel.add(editPanel);
15601562 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
- objectPanel.setToolTipTextAt(1, "Edit panel");
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15621564
15631565 //if (Globals.ADVANCED)
15641566 objectPanel.add(infoPanel);
15651567 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
- objectPanel.setToolTipTextAt(2, "Info panel");
1568
+ objectPanel.setToolTipTextAt(2, "Information");
15671569
15681570 objectPanel.add(XYZPanel);
15691571 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
- objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15711573
15721574 objectPanel.add(toolboxPanel);
15731575 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
- objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15751577
15761578 /*
15771579 aConstraints.gridx = 0;
....@@ -1733,12 +1735,56 @@
17331735 ctrlPanel.removeAll();
17341736 }
17351737
1736
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
17371739 {
1738
- /*
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
+ /*
17391785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17401786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1741
- */
1787
+ */
17421788
17431789 cGridBag editBar = new cGridBag().setVertical(false);
17441790
....@@ -1775,7 +1821,9 @@
17751821
17761822 cGridBag huepanel = new cGridBag();
17771823 cGridBag huelabel = new cGridBag();
1778
- huelabel.add(GetLabel("icons/hue.png", false));
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
17791827 huelabel.preferredWidth = 20;
17801828 huepanel.add(new cGridBag()); // Label
17811829 huepanel.add(huelabel); // Field/slider
....@@ -1796,7 +1844,7 @@
17961844 cGridBag modulation = new cGridBag();
17971845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17981846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1799
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
18001848 colorSection.add(modulation);
18011849
18021850 cGridBag opacity = new cGridBag();
....@@ -2989,7 +3037,7 @@
29893037
29903038 freezematerial = true;
29913039 colorField.setFloat(mat.color);
2992
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
29933041 metalnessField.setFloat(mat.metalness);
29943042 diffuseField.setFloat(mat.diffuse);
29953043 specularField.setFloat(mat.specular);
....@@ -3300,6 +3348,7 @@
33003348 } else if (event.getSource() == liveCB)
33013349 {
33023350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
33033352 return;
33043353 } else if (event.getSource() == selectableCB)
33053354 {
....@@ -3309,7 +3358,7 @@
33093358 {
33103359 copy.hide ^= true;
33113360 copy.Touch(); // display list issue
3312
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
33133362 return;
33143363 } else if (event.getSource() == link2masterCB)
33153364 {
....@@ -3565,6 +3614,7 @@
35653614
35663615 static public byte[] Compress(Object3D o)
35673616 {
3617
+ // Slower to actually compress.
35683618 try
35693619 {
35703620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3666,6 +3716,7 @@
36663716 {
36673717 //Save(true);
36683718 Replace();
3719
+ SetUndoStates();
36693720 }
36703721
36713722 private boolean Equal(byte[] compress, byte[] name)
....@@ -3689,18 +3740,18 @@
36893740 public boolean Save(boolean user)
36903741 {
36913742 System.err.println("Save");
3743
+ Replace();
36923744
36933745 cRadio tab = GetCurrentTab();
36943746
3695
- byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
36963748
36973749 boolean thesame = false;
36983750
3699
- // Quick heuristic using length. Works only when stream is compressed.
3700
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3701
- {
3702
- thesame = true;
3703
- }
3751
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3752
+// {
3753
+// thesame = true;
3754
+// }
37043755
37053756 //EditorFrame.m_MainFrame.requestFocusInWindow();
37063757 if (!thesame)
....@@ -3708,7 +3759,7 @@
37083759 //tab.user[tab.versionindex] = user;
37093760 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37103761
3711
- copy.versions[++copy.versionindex] = compress;
3762
+ copy.versionlist[++copy.versionindex] = compress;
37123763
37133764 // if (increment)
37143765 // tab.versionindex++;
....@@ -3718,10 +3769,10 @@
37183769
37193770 //assert(hashtable.isEmpty());
37203771
3721
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
37223773 {
37233774 //tab.user[i] = false;
3724
- copy.versions[i] = null;
3775
+ copy.versionlist[i] = null;
37253776 }
37263777
37273778 SetUndoStates();
....@@ -3747,6 +3798,38 @@
37473798
37483799 return !thesame;
37493800 }
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
+ }
37503833
37513834 void CopyChanged(Object3D obj)
37523835 {
....@@ -3771,6 +3854,7 @@
37713854
37723855 CameraPane.SWITCH = temp;
37733856
3857
+ RefreshSelection();
37743858 //assert(hashtable.isEmpty());
37753859
37763860 copy.Touch();
....@@ -3805,9 +3889,9 @@
38053889 {
38063890 int count = 0;
38073891
3808
- for (int i = copy.versions.length; --i >= 0;)
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
38093893 {
3810
- if (copy.versions[i] != null)
3894
+ if (copy.versionlist[i] != null)
38113895 count++;
38123896 }
38133897
....@@ -3822,7 +3906,7 @@
38223906 replaceButton.setEnabled(copy.versionindex != -1);
38233907
38243908 undoButton.setEnabled(copy.versionindex > 0);
3825
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
38263910
38273911 muteSlider = true;
38283912 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3860,7 +3944,7 @@
38603944
38613945 copy.versionindex -= 1;
38623946
3863
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
38643948
38653949 return true;
38663950 }
....@@ -3871,13 +3955,14 @@
38713955
38723956 cRadio tab = GetCurrentTab();
38733957
3874
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38753959 {
38763960 java.awt.Toolkit.getDefaultToolkit().beep();
38773961 return false;
38783962 }
38793963
3880
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
38813966
38823967 return true;
38833968 }
....@@ -3888,13 +3973,13 @@
38883973
38893974 cRadio tab = GetCurrentTab();
38903975
3891
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38923977 {
38933978 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38943979 return false;
38953980 }
38963981
3897
- copy.versions[copy.versionindex] = CompressCopy();
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
38983983
38993984 return true;
39003985 }
....@@ -3906,7 +3991,7 @@
39063991
39073992 cRadio tab = GetCurrentTab();
39083993
3909
- if (copy.versions[copy.versionindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
39103995 {
39113996 java.awt.Toolkit.getDefaultToolkit().beep();
39123997 return;
....@@ -3914,7 +3999,7 @@
39143999
39154000 copy.versionindex += 1;
39164001
3917
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
39184003
39194004 //if (!tab.user[tab.versionindex])
39204005 // tab.graphs[tab.versionindex] = null;
....@@ -4128,7 +4213,7 @@
41284213 //copy.material = new cMaterial(copy.GetMaterial());
41294214
41304215 current.color = (float) colorField.getFloat();
4131
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
41324217 current.metalness = (float) metalnessField.getFloat();
41334218 current.diffuse = (float) diffuseField.getFloat();
41344219 current.specular = (float) specularField.getFloat();
....@@ -4161,7 +4246,7 @@
41614246 cMaterial mat = copy.material;
41624247
41634248 colorField.SetToolTipValue((mat.color));
4164
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
41654250 metalnessField.SetToolTipValue((mat.metalness));
41664251 diffuseField.SetToolTipValue((mat.diffuse));
41674252 specularField.SetToolTipValue((mat.specular));
....@@ -4225,9 +4310,9 @@
42254310
42264311 int version = versionSlider.getInteger();
42274312
4228
- if (copy.versions[version] != null)
4313
+ if (copy.versionlist[version] != null)
42294314 {
4230
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
42314316 }
42324317
42334318 return;
....@@ -4267,6 +4352,12 @@
42674352 {
42684353 //System.out.println("stateChanged = " + this);
42694354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
42704361 applySelf();
42714362 //System.out.println("this = " + this);
42724363 //System.out.println("PARENT = " + parent);
....@@ -4566,6 +4657,7 @@
45664657 {
45674658 if (GetTree() != null)
45684659 {
4660
+ GetTree().revalidate();
45694661 GetTree().repaint();
45704662 }
45714663
....@@ -4957,12 +5049,12 @@
49575049 c.addChild(csg);
49585050 }
49595051
4960
- copy.versions = readobj.versions;
5052
+ copy.versionlist = readobj.versionlist;
49615053 copy.versionindex = readobj.versionindex;
49625054
4963
- if (copy.versions == null)
5055
+ if (copy.versionlist == null)
49645056 {
4965
- copy.versions = new byte[100][];
5057
+ copy.versionlist = new Object3D[100];
49665058 copy.versionindex = -1;
49675059 }
49685060
....@@ -5370,7 +5462,7 @@
53705462 JLabel colorLabel;
53715463 cNumberSlider colorField;
53725464 JLabel modulationLabel;
5373
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
53745466 JLabel metalnessLabel;
53755467 cNumberSlider metalnessField;
53765468 JLabel diffuseLabel;