Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
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 Object3D[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 Object3D[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*/
....@@ -848,6 +848,8 @@
848848 //frame.setVisible(true);
849849 }
850850 frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
851853 }
852854
853855 private Object3D CompressCopy()
....@@ -858,13 +860,13 @@
858860 copy.ExtractBigData(versiontable);
859861 // if (copy == client)
860862
861
- Object3D versions[] = copy.versions;
862
- copy.versions = null;
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
863865
864866 //byte[] compress = Compress(copy);
865867 Object3D compress = (Object3D)Grafreed.clone(copy);
866868
867
- copy.versions = versions;
869
+ copy.versionlist = versions;
868870
869871 copy.RestoreBigData(versiontable);
870872
....@@ -994,6 +996,7 @@
994996 {
995997 SetupMaterial(materialPanel);
996998 }
999
+
9971000 //SetupName();
9981001 //SetupViews();
9991002 }
....@@ -1551,7 +1554,7 @@
15511554 //tmp.setName("Edit");
15521555 objectPanel.add(materialPanel);
15531556 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
- objectPanel.setToolTipTextAt(0, "Material panel");
1557
+ objectPanel.setToolTipTextAt(0, "Material");
15551558
15561559 // JPanel north = new JPanel(new BorderLayout());
15571560 // north.setName("Edit");
....@@ -1559,20 +1562,20 @@
15591562 // objectPanel.add(north);
15601563 objectPanel.add(editPanel);
15611564 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
- objectPanel.setToolTipTextAt(1, "Edit panel");
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
15631566
15641567 //if (Globals.ADVANCED)
15651568 objectPanel.add(infoPanel);
15661569 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
- objectPanel.setToolTipTextAt(2, "Info panel");
1570
+ objectPanel.setToolTipTextAt(2, "Information");
15681571
15691572 objectPanel.add(XYZPanel);
15701573 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
- objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
15721575
15731576 objectPanel.add(toolboxPanel);
15741577 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
- objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
15761579
15771580 /*
15781581 aConstraints.gridx = 0;
....@@ -1734,12 +1737,85 @@
17341737 ctrlPanel.removeAll();
17351738 }
17361739
1737
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
17381741 {
1739
- /*
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
+ /*
17401816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17411817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1742
- */
1818
+ */
17431819
17441820 cGridBag editBar = new cGridBag().setVertical(false);
17451821
....@@ -1776,7 +1852,9 @@
17761852
17771853 cGridBag huepanel = new cGridBag();
17781854 cGridBag huelabel = new cGridBag();
1779
- huelabel.add(GetLabel("icons/hue.png", false));
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
17801858 huelabel.preferredWidth = 20;
17811859 huepanel.add(new cGridBag()); // Label
17821860 huepanel.add(huelabel); // Field/slider
....@@ -1797,7 +1875,7 @@
17971875 cGridBag modulation = new cGridBag();
17981876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17991877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1800
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
18011879 colorSection.add(modulation);
18021880
18031881 cGridBag opacity = new cGridBag();
....@@ -2990,7 +3068,7 @@
29903068
29913069 freezematerial = true;
29923070 colorField.setFloat(mat.color);
2993
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
29943072 metalnessField.setFloat(mat.metalness);
29953073 diffuseField.setFloat(mat.diffuse);
29963074 specularField.setFloat(mat.specular);
....@@ -3301,6 +3379,7 @@
33013379 } else if (event.getSource() == liveCB)
33023380 {
33033381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
33043383 return;
33053384 } else if (event.getSource() == selectableCB)
33063385 {
....@@ -3310,7 +3389,7 @@
33103389 {
33113390 copy.hide ^= true;
33123391 copy.Touch(); // display list issue
3313
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
33143393 return;
33153394 } else if (event.getSource() == link2masterCB)
33163395 {
....@@ -3668,6 +3747,7 @@
36683747 {
36693748 //Save(true);
36703749 Replace();
3750
+ SetUndoStates();
36713751 }
36723752
36733753 private boolean Equal(byte[] compress, byte[] name)
....@@ -3688,13 +3768,26 @@
36883768
36893769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36903770
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
+
36913783 public boolean Save(boolean user)
36923784 {
36933785 System.err.println("Save");
3786
+ //Replace();
36943787
36953788 cRadio tab = GetCurrentTab();
36963789
3697
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
36983791
36993792 boolean thesame = false;
37003793
....@@ -3706,10 +3799,15 @@
37063799 //EditorFrame.m_MainFrame.requestFocusInWindow();
37073800 if (!thesame)
37083801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
37093807 //tab.user[tab.versionindex] = user;
37103808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37113809
3712
- copy.versions[++copy.versionindex] = compress;
3810
+ copy.versionlist[++copy.versionindex] = compress;
37133811
37143812 // if (increment)
37153813 // tab.versionindex++;
....@@ -3719,11 +3817,11 @@
37193817
37203818 //assert(hashtable.isEmpty());
37213819
3722
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3723
- {
3724
- //tab.user[i] = false;
3725
- copy.versions[i] = null;
3726
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
37273825
37283826 SetUndoStates();
37293827
....@@ -3748,9 +3846,43 @@
37483846
37493847 return !thesame;
37503848 }
3751
-
3752
- void CopyChanged(Object3D obj)
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
37533853 {
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
+
37543886 SetUndoStates();
37553887
37563888 boolean temp = CameraPane.SWITCH;
....@@ -3772,6 +3904,7 @@
37723904
37733905 CameraPane.SWITCH = temp;
37743906
3907
+ RefreshSelection();
37753908 //assert(hashtable.isEmpty());
37763909
37773910 copy.Touch();
....@@ -3792,13 +3925,15 @@
37923925 }
37933926 }
37943927
3795
- refreshContents();
3928
+ refreshContents(true);
37963929 }
37973930
3798
- cButton undoButton;
3931
+ cButton previousVersionButton;
37993932 cButton restoreButton;
38003933 cButton replaceButton;
3801
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
38023937
38033938 boolean muteSlider;
38043939
....@@ -3806,9 +3941,9 @@
38063941 {
38073942 int count = 0;
38083943
3809
- for (int i = copy.versions.length; --i >= 0;)
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
38103945 {
3811
- if (copy.versions[i] != null)
3946
+ if (copy.versionlist[i] != null)
38123947 count++;
38133948 }
38143949
....@@ -3819,11 +3954,14 @@
38193954 {
38203955 cRadio tab = GetCurrentTab();
38213956
3822
- restoreButton.setEnabled(copy.versionindex != -1);
3823
- replaceButton.setEnabled(copy.versionindex != -1);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
38243959
3825
- undoButton.setEnabled(copy.versionindex > 0);
3826
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
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);
38273965
38283966 muteSlider = true;
38293967 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3831,7 +3969,7 @@
38313969 muteSlider = false;
38323970 }
38333971
3834
- public boolean Undo()
3972
+ public boolean PreviousVersion()
38353973 {
38363974 // Option?
38373975 Replace();
....@@ -3861,7 +3999,7 @@
38613999
38624000 copy.versionindex -= 1;
38634001
3864
- CopyChanged((Object3D)copy.versions[copy.versionindex]);
4002
+ CopyChanged();
38654003
38664004 return true;
38674005 }
....@@ -3872,14 +4010,14 @@
38724010
38734011 cRadio tab = GetCurrentTab();
38744012
3875
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38764014 {
38774015 java.awt.Toolkit.getDefaultToolkit().beep();
38784016 return false;
38794017 }
38804018
38814019 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
- CopyChanged(copy.versions[copy.versionindex]);
4020
+ CopyChanged();
38834021
38844022 return true;
38854023 }
....@@ -3890,25 +4028,25 @@
38904028
38914029 cRadio tab = GetCurrentTab();
38924030
3893
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38944032 {
38954033 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38964034 return false;
38974035 }
38984036
3899
- copy.versions[copy.versionindex] = CompressCopy();
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
39004038
39014039 return true;
39024040 }
39034041
3904
- public void Redo()
4042
+ public void NextVersion()
39054043 {
39064044 // Option?
39074045 Replace();
39084046
39094047 cRadio tab = GetCurrentTab();
39104048
3911
- if (copy.versions[copy.versionindex + 1] == null)
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
39124050 {
39134051 java.awt.Toolkit.getDefaultToolkit().beep();
39144052 return;
....@@ -3916,7 +4054,7 @@
39164054
39174055 copy.versionindex += 1;
39184056
3919
- CopyChanged(copy.versions[copy.versionindex]);
4057
+ CopyChanged();
39204058
39214059 //if (!tab.user[tab.versionindex])
39224060 // tab.graphs[tab.versionindex] = null;
....@@ -4130,7 +4268,7 @@
41304268 //copy.material = new cMaterial(copy.GetMaterial());
41314269
41324270 current.color = (float) colorField.getFloat();
4133
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
41344272 current.metalness = (float) metalnessField.getFloat();
41354273 current.diffuse = (float) diffuseField.getFloat();
41364274 current.specular = (float) specularField.getFloat();
....@@ -4163,7 +4301,7 @@
41634301 cMaterial mat = copy.material;
41644302
41654303 colorField.SetToolTipValue((mat.color));
4166
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
41674305 metalnessField.SetToolTipValue((mat.metalness));
41684306 diffuseField.SetToolTipValue((mat.diffuse));
41694307 specularField.SetToolTipValue((mat.specular));
....@@ -4227,9 +4365,10 @@
42274365
42284366 int version = versionSlider.getInteger();
42294367
4230
- if (copy.versions[version] != null)
4368
+ if (copy.versionlist[version] != null)
42314369 {
4232
- CopyChanged(copy.versions[copy.versionindex = version]);
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
42334372 }
42344373
42354374 return;
....@@ -4269,6 +4408,12 @@
42694408 {
42704409 //System.out.println("stateChanged = " + this);
42714410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
42724417 applySelf();
42734418 //System.out.println("this = " + this);
42744419 //System.out.println("PARENT = " + parent);
....@@ -4568,6 +4713,7 @@
45684713 {
45694714 if (GetTree() != null)
45704715 {
4716
+ GetTree().revalidate();
45714717 GetTree().repaint();
45724718 }
45734719
....@@ -4576,6 +4722,9 @@
45764722 ctrlPanel.validate(); // ? new
45774723 ctrlPanel.repaint();
45784724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
45794728 }
45804729
45814730 static TweenManager tweenManager = new TweenManager();
....@@ -4959,12 +5108,12 @@
49595108 c.addChild(csg);
49605109 }
49615110
4962
- copy.versions = readobj.versions;
5111
+ copy.versionlist = readobj.versionlist;
49635112 copy.versionindex = readobj.versionindex;
49645113
4965
- if (copy.versions == null)
5114
+ if (copy.versionlist == null)
49665115 {
4967
- copy.versions = new Object3D[100];
5116
+ copy.versionlist = new Object3D[100];
49685117 copy.versionindex = -1;
49695118 }
49705119
....@@ -4980,7 +5129,7 @@
49805129 {
49815130 if (Grafreed.standAlone)
49825131 {
4983
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49845133 browser.show();
49855134 String filename = browser.getFile();
49865135 if (filename != null && filename.length() > 0)
....@@ -5372,7 +5521,7 @@
53725521 JLabel colorLabel;
53735522 cNumberSlider colorField;
53745523 JLabel modulationLabel;
5375
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
53765525 JLabel metalnessLabel;
53775526 cNumberSlider metalnessField;
53785527 JLabel diffuseLabel;