From 0c85af6e46f48b7425d59fc776b193c06a4a1f52 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 04 Aug 2019 12:08:30 -0400 Subject: [PATCH] Material icons --- ObjEditor.java | 174 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 132 insertions(+), 42 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index 963fa06..4f2f437 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -296,9 +296,9 @@ client = inClient; copy = client; - if (copy.versions == null) + if (copy.versionlist == null) { - copy.versions = new Object3D[100]; + copy.versionlist = new Object3D[100]; copy.versionindex = -1; } @@ -315,9 +315,9 @@ client = inClient; copy = client; - if (copy.versions == null) + if (copy.versionlist == null) { - copy.versions = new Object3D[100]; + copy.versionlist = new Object3D[100]; copy.versionindex = -1; } @@ -353,7 +353,7 @@ copy = localCopy; copy.editWindow = this; - if (copy.versions == null) + if (copy.versionlist == null) { // copy.versions = new byte[100][]; // copy.versionindex = -1; @@ -467,7 +467,7 @@ toolboxPanel = new cGridBag().setVertical(true); //toolboxPanel.setName("Toolbox"); - materialPanel = new cGridBag().setVertical(true); + materialPanel = new cGridBag().setVertical(false); //materialPanel.setName("Material"); /*JTextPane*/ @@ -858,13 +858,13 @@ copy.ExtractBigData(versiontable); // if (copy == client) - Object3D versions[] = copy.versions; - copy.versions = null; + Object3D versions[] = copy.versionlist; + copy.versionlist = null; //byte[] compress = Compress(copy); Object3D compress = (Object3D)Grafreed.clone(copy); - copy.versions = versions; + copy.versionlist = versions; copy.RestoreBigData(versiontable); @@ -994,6 +994,7 @@ { SetupMaterial(materialPanel); } + //SetupName(); //SetupViews(); } @@ -1551,7 +1552,7 @@ //tmp.setName("Edit"); objectPanel.add(materialPanel); objectPanel.setIconAt(0, GetIcon("icons/material.png")); - objectPanel.setToolTipTextAt(0, "Material panel"); + objectPanel.setToolTipTextAt(0, "Material"); // JPanel north = new JPanel(new BorderLayout()); // north.setName("Edit"); @@ -1559,20 +1560,20 @@ // objectPanel.add(north); objectPanel.add(editPanel); objectPanel.setIconAt(1, GetIcon("icons/write.png")); - objectPanel.setToolTipTextAt(1, "Edit panel"); + objectPanel.setToolTipTextAt(1, "Edit controls"); //if (Globals.ADVANCED) objectPanel.add(infoPanel); objectPanel.setIconAt(2, GetIcon("icons/info.png")); - objectPanel.setToolTipTextAt(2, "Info panel"); + objectPanel.setToolTipTextAt(2, "Information"); objectPanel.add(XYZPanel); objectPanel.setIconAt(3, GetIcon("icons/XYZ.png")); - objectPanel.setToolTipTextAt(3, "XYZ/RGB panel"); + objectPanel.setToolTipTextAt(3, "XYZ/RGB transform"); objectPanel.add(toolboxPanel); objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); - objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel"); + objectPanel.setToolTipTextAt(4, "Objects & backgrounds"); /* aConstraints.gridx = 0; @@ -1734,12 +1735,56 @@ ctrlPanel.removeAll(); } - void SetupMaterial(cGridBag panel) + void SetupMaterial(cGridBag materialpanel) { - /* + cGridBag presetpanel = new cGridBag().setVertical(true); + cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF); + label.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + colorField.setFloat(0); + saturationField.setFloat(1); + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(label); + + presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF)); + presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF)); + + cGridBag panel = new cGridBag().setVertical(true); + + presetpanel.preferredWidth = 1; + + materialpanel.add(panel); + materialpanel.add(presetpanel); + + panel.preferredWidth = 8; + + /* ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints); materialLabel.setHorizontalAlignment(SwingConstants.TRAILING); - */ + */ cGridBag editBar = new cGridBag().setVertical(false); @@ -1776,7 +1821,9 @@ cGridBag huepanel = new cGridBag(); cGridBag huelabel = new cGridBag(); - huelabel.add(GetLabel("icons/hue.png", false)); + label = GetLabel("icons/hue.png", false); + label.fit = true; + huelabel.add(label); huelabel.preferredWidth = 20; huepanel.add(new cGridBag()); // Label huepanel.add(huelabel); // Field/slider @@ -1797,7 +1844,7 @@ cGridBag modulation = new cGridBag(); modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints); modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING); - modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); + modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); colorSection.add(modulation); cGridBag opacity = new cGridBag(); @@ -2990,7 +3037,7 @@ freezematerial = true; colorField.setFloat(mat.color); - modulationField.setFloat(mat.modulation); + saturationField.setFloat(mat.modulation); metalnessField.setFloat(mat.metalness); diffuseField.setFloat(mat.diffuse); specularField.setFloat(mat.specular); @@ -3301,6 +3348,7 @@ } else if (event.getSource() == liveCB) { copy.live ^= true; + objEditor.refreshContents(true); // To show item colors return; } else if (event.getSource() == selectableCB) { @@ -3310,7 +3358,7 @@ { copy.hide ^= true; copy.Touch(); // display list issue - objEditor.refreshContents(); + objEditor.refreshContents(true); // To show item colors return; } else if (event.getSource() == link2masterCB) { @@ -3668,6 +3716,7 @@ { //Save(true); Replace(); + SetUndoStates(); } private boolean Equal(byte[] compress, byte[] name) @@ -3691,6 +3740,7 @@ public boolean Save(boolean user) { System.err.println("Save"); + Replace(); cRadio tab = GetCurrentTab(); @@ -3709,7 +3759,7 @@ //tab.user[tab.versionindex] = user; //boolean increment = true; // tab.graphs[tab.versionindex] == null; - copy.versions[++copy.versionindex] = compress; + copy.versionlist[++copy.versionindex] = compress; // if (increment) // tab.versionindex++; @@ -3719,10 +3769,10 @@ //assert(hashtable.isEmpty()); - for (int i = copy.versionindex+1; i < copy.versions.length; i++) + for (int i = copy.versionindex+1; i < copy.versionlist.length; i++) { //tab.user[i] = false; - copy.versions[i] = null; + copy.versionlist[i] = null; } SetUndoStates(); @@ -3748,6 +3798,38 @@ return !thesame; } + + boolean flashIt = true; + + void RefreshSelection() + { + Object3D selection = new Object3D(); + + for (int i = 0; i < copy.selection.size(); i++) + { + Object3D elem = copy.selection.elementAt(i); + + Object3D obj = copy.GetObject(elem.GetUUID()); + + if (obj == null) + { + copy.selection.remove(i--); + } + else + { + selection.add(obj); + copy.selection.setElementAt(obj, i); + } + } + + flashIt = false; + GetTree().clearSelection(); + for (int i = 0; i < selection.size(); i++) + GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath()); + flashIt = true; + + refreshContents(false); + } void CopyChanged(Object3D obj) { @@ -3772,6 +3854,7 @@ CameraPane.SWITCH = temp; + RefreshSelection(); //assert(hashtable.isEmpty()); copy.Touch(); @@ -3806,9 +3889,9 @@ { int count = 0; - for (int i = copy.versions.length; --i >= 0;) + for (int i = copy.versionlist.length; --i >= 0;) { - if (copy.versions[i] != null) + if (copy.versionlist[i] != null) count++; } @@ -3823,7 +3906,7 @@ replaceButton.setEnabled(copy.versionindex != -1); undoButton.setEnabled(copy.versionindex > 0); - redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); + redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); muteSlider = true; versionSlider.setMaximum(VersionCount() - 1); @@ -3861,7 +3944,7 @@ copy.versionindex -= 1; - CopyChanged((Object3D)copy.versions[copy.versionindex]); + CopyChanged((Object3D)copy.versionlist[copy.versionindex]); return true; } @@ -3872,14 +3955,14 @@ cRadio tab = GetCurrentTab(); - if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) + if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) { java.awt.Toolkit.getDefaultToolkit().beep(); return false; } //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); - CopyChanged(copy.versions[copy.versionindex]); + CopyChanged(copy.versionlist[copy.versionindex]); return true; } @@ -3890,13 +3973,13 @@ cRadio tab = GetCurrentTab(); - if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) + if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) { // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); return false; } - copy.versions[copy.versionindex] = CompressCopy(); + copy.versionlist[copy.versionindex] = CompressCopy(); return true; } @@ -3908,7 +3991,7 @@ cRadio tab = GetCurrentTab(); - if (copy.versions[copy.versionindex + 1] == null) + if (copy.versionlist[copy.versionindex + 1] == null) { java.awt.Toolkit.getDefaultToolkit().beep(); return; @@ -3916,7 +3999,7 @@ copy.versionindex += 1; - CopyChanged(copy.versions[copy.versionindex]); + CopyChanged(copy.versionlist[copy.versionindex]); //if (!tab.user[tab.versionindex]) // tab.graphs[tab.versionindex] = null; @@ -4130,7 +4213,7 @@ //copy.material = new cMaterial(copy.GetMaterial()); current.color = (float) colorField.getFloat(); - current.modulation = (float) modulationField.getFloat(); + current.modulation = (float) saturationField.getFloat(); current.metalness = (float) metalnessField.getFloat(); current.diffuse = (float) diffuseField.getFloat(); current.specular = (float) specularField.getFloat(); @@ -4163,7 +4246,7 @@ cMaterial mat = copy.material; colorField.SetToolTipValue((mat.color)); - modulationField.SetToolTipValue((mat.modulation)); + saturationField.SetToolTipValue((mat.modulation)); metalnessField.SetToolTipValue((mat.metalness)); diffuseField.SetToolTipValue((mat.diffuse)); specularField.SetToolTipValue((mat.specular)); @@ -4227,9 +4310,9 @@ int version = versionSlider.getInteger(); - if (copy.versions[version] != null) + if (copy.versionlist[version] != null) { - CopyChanged(copy.versions[copy.versionindex = version]); + CopyChanged(copy.versionlist[copy.versionindex = version]); } return; @@ -4269,6 +4352,12 @@ { //System.out.println("stateChanged = " + this); materialtouched = true; + + if (e.getSource() == colorField && saturationField.getFloat() == 0.001) + { + saturationField.setFloat(1); + } + applySelf(); //System.out.println("this = " + this); //System.out.println("PARENT = " + parent); @@ -4568,6 +4657,7 @@ { if (GetTree() != null) { + GetTree().revalidate(); GetTree().repaint(); } @@ -4959,12 +5049,12 @@ c.addChild(csg); } - copy.versions = readobj.versions; + copy.versionlist = readobj.versionlist; copy.versionindex = readobj.versionindex; - if (copy.versions == null) + if (copy.versionlist == null) { - copy.versions = new Object3D[100]; + copy.versionlist = new Object3D[100]; copy.versionindex = -1; } @@ -5372,7 +5462,7 @@ JLabel colorLabel; cNumberSlider colorField; JLabel modulationLabel; - cNumberSlider modulationField; + cNumberSlider saturationField; JLabel metalnessLabel; cNumberSlider metalnessField; JLabel diffuseLabel; -- Gitblit v1.6.2