Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
ObjEditor.java
....@@ -848,6 +848,8 @@
848848 //frame.setVisible(true);
849849 }
850850 frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
851853 }
852854
853855 private Object3D CompressCopy()
....@@ -1738,20 +1740,52 @@
17381740 void SetupMaterial(cGridBag materialpanel)
17391741 {
17401742 cGridBag presetpanel = new cGridBag().setVertical(true);
1741
- cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
- label.addMouseListener(new MouseAdapter()
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
17431745 {
17441746 public void mouseClicked(MouseEvent e)
17451747 {
1746
- colorField.setFloat(0);
1747
- saturationField.setFloat(1);
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
+
17481766 materialtouched = true;
17491767 applySelf();
17501768 }
17511769 });
1752
- presetpanel.add(label);
1770
+ presetpanel.add(skin);
17531771
1754
- presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
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
+
17551789 presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
17561790 presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
17571791 presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
....@@ -1768,9 +1802,6 @@
17681802 presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
17691803 presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
17701804 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));
17741805
17751806 cGridBag panel = new cGridBag().setVertical(true);
17761807
....@@ -1821,9 +1852,9 @@
18211852
18221853 cGridBag huepanel = new cGridBag();
18231854 cGridBag huelabel = new cGridBag();
1824
- label = GetLabel("icons/hue.png", false);
1825
- label.fit = true;
1826
- huelabel.add(label);
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
18271858 huelabel.preferredWidth = 20;
18281859 huepanel.add(new cGridBag()); // Label
18291860 huepanel.add(huelabel); // Field/slider
....@@ -3737,14 +3768,26 @@
37373768
37383769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
37393770
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
+
37403783 public boolean Save(boolean user)
37413784 {
37423785 System.err.println("Save");
3743
- Replace();
3786
+ //Replace();
37443787
37453788 cRadio tab = GetCurrentTab();
37463789
3747
- Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
37483791
37493792 boolean thesame = false;
37503793
....@@ -3756,6 +3799,11 @@
37563799 //EditorFrame.m_MainFrame.requestFocusInWindow();
37573800 if (!thesame)
37583801 {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
37593807 //tab.user[tab.versionindex] = user;
37603808 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
37613809
....@@ -3769,11 +3817,11 @@
37693817
37703818 //assert(hashtable.isEmpty());
37713819
3772
- for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3773
- {
3774
- //tab.user[i] = false;
3775
- copy.versionlist[i] = null;
3776
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
37773825
37783826 SetUndoStates();
37793827
....@@ -3828,11 +3876,13 @@
38283876 GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
38293877 flashIt = true;
38303878
3831
- refreshContents(false);
3879
+ //refreshContents(false);
38323880 }
38333881
3834
- void CopyChanged(Object3D obj)
3882
+ void CopyChanged()
38353883 {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
38363886 SetUndoStates();
38373887
38383888 boolean temp = CameraPane.SWITCH;
....@@ -3875,13 +3925,15 @@
38753925 }
38763926 }
38773927
3878
- refreshContents();
3928
+ refreshContents(true);
38793929 }
38803930
3881
- cButton undoButton;
3931
+ cButton previousVersionButton;
38823932 cButton restoreButton;
38833933 cButton replaceButton;
3884
- cButton redoButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
38853937
38863938 boolean muteSlider;
38873939
....@@ -3902,11 +3954,14 @@
39023954 {
39033955 cRadio tab = GetCurrentTab();
39043956
3905
- restoreButton.setEnabled(copy.versionindex != -1);
3906
- replaceButton.setEnabled(copy.versionindex != -1);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
39073959
3908
- undoButton.setEnabled(copy.versionindex > 0);
3909
- redoButton.setEnabled(copy.versionlist[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);
39103965
39113966 muteSlider = true;
39123967 versionSlider.setMaximum(VersionCount() - 1);
....@@ -3914,7 +3969,7 @@
39143969 muteSlider = false;
39153970 }
39163971
3917
- public boolean Undo()
3972
+ public boolean PreviousVersion()
39183973 {
39193974 // Option?
39203975 Replace();
....@@ -3944,7 +3999,7 @@
39443999
39454000 copy.versionindex -= 1;
39464001
3947
- CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
4002
+ CopyChanged();
39484003
39494004 return true;
39504005 }
....@@ -3962,7 +4017,7 @@
39624017 }
39634018
39644019 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
- CopyChanged(copy.versionlist[copy.versionindex]);
4020
+ CopyChanged();
39664021
39674022 return true;
39684023 }
....@@ -3984,7 +4039,7 @@
39844039 return true;
39854040 }
39864041
3987
- public void Redo()
4042
+ public void NextVersion()
39884043 {
39894044 // Option?
39904045 Replace();
....@@ -3999,7 +4054,7 @@
39994054
40004055 copy.versionindex += 1;
40014056
4002
- CopyChanged(copy.versionlist[copy.versionindex]);
4057
+ CopyChanged();
40034058
40044059 //if (!tab.user[tab.versionindex])
40054060 // tab.graphs[tab.versionindex] = null;
....@@ -4312,7 +4367,8 @@
43124367
43134368 if (copy.versionlist[version] != null)
43144369 {
4315
- CopyChanged(copy.versionlist[copy.versionindex = version]);
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
43164372 }
43174373
43184374 return;
....@@ -4666,6 +4722,9 @@
46664722 ctrlPanel.validate(); // ? new
46674723 ctrlPanel.repaint();
46684724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
46694728 }
46704729
46714730 static TweenManager tweenManager = new TweenManager();
....@@ -5070,7 +5129,7 @@
50705129 {
50715130 if (Grafreed.standAlone)
50725131 {
5073
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
50745133 browser.show();
50755134 String filename = browser.getFile();
50765135 if (filename != null && filename.length() > 0)