One can now select the technique in the shader node editor through a combo box in the tool bar

experimental
Nehon 10 years ago
parent 1286fa0fba
commit ff877160e8
  1. 17
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/EditableMatDefFile.java
  2. 1
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties
  3. 1
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java
  4. 66
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorToolBar.form
  5. 105
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorToolBar.java
  6. 37
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorlElement.java
  7. 2
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/OutBusPanel.java
  8. 26
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/navigator/node/ShaderNodeNode.java
  9. 4
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/navigator/node/TechniqueNode.java
  10. 8
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/shadervisual/MatDefShaderElement.java
  11. 2
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java

@ -61,12 +61,9 @@ public class EditableMatDefFile {
private TechniqueBlock currentTechnique; private TechniqueBlock currentTechnique;
private MaterialDef materialDef; private MaterialDef materialDef;
private ProjectAssetManager assetManager; private ProjectAssetManager assetManager;
// MatParamTopComponent matParamComponent;
private ShaderGenerator glsl100; private ShaderGenerator glsl100;
private ShaderGenerator glsl150; private ShaderGenerator glsl150;
private final String selectedTechnique = "Default"; private final static String GLSL100 = "GLSL100";
private final static String GLSL100 = "GLSL100";
private final static String GLSL150 = "GLSL150";
private Lookup lookup; private Lookup lookup;
private boolean loaded = false; private boolean loaded = false;
private boolean dirty = false; private boolean dirty = false;
@ -137,7 +134,9 @@ public class EditableMatDefFile {
} }
} }
if (materialDef != null && !matParseError) { if (materialDef != null && !matParseError) {
currentTechnique = matDefStructure.getTechniques().get(0); if(currentTechnique == null){
currentTechnique = matDefStructure.getTechniques().get(0);
}
registerListener(matDefStructure); registerListener(matDefStructure);
obj.getLookupContents().add(matDefStructure); obj.getLookupContents().add(matDefStructure);
@ -170,7 +169,7 @@ public class EditableMatDefFile {
public String getShaderCode(String version, Shader.ShaderType type) { public String getShaderCode(String version, Shader.ShaderType type) {
try { try {
material.selectTechnique("Default", SceneApplication.getApplication().getRenderManager()); material.selectTechnique(currentTechnique.getName(), SceneApplication.getApplication().getRenderManager());
Shader s; Shader s;
if (version.equals(GLSL100)) { if (version.equals(GLSL100)) {
glsl100.initialize(material.getActiveTechnique()); glsl100.initialize(material.getActiveTechnique());
@ -194,6 +193,10 @@ public class EditableMatDefFile {
public TechniqueBlock getCurrentTechnique() { public TechniqueBlock getCurrentTechnique() {
return currentTechnique; return currentTechnique;
} }
public void setCurrentTechnique(TechniqueBlock tech){
this.currentTechnique = tech;
}
public MatDefBlock getMatDefStructure() { public MatDefBlock getMatDefStructure() {
return matDefStructure; return matDefStructure;

@ -12,3 +12,4 @@ BackdropPanel.bringToFrontButton.toolTipText=Toggle back/front
NodeToolBar.codeButton.toolTipText=Display code NodeToolBar.codeButton.toolTipText=Display code
NodeToolBar.deleteButton.toolTipText=Delete node NodeToolBar.deleteButton.toolTipText=Delete node
NodeToolBar.deleteButton.text= NodeToolBar.deleteButton.text=
MatDefEditorToolBar.jLabel1.text=Technique

@ -5,6 +5,7 @@
package com.jme3.gde.materialdefinition.editor; package com.jme3.gde.materialdefinition.editor;
import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.materialdefinition.dialog.AddAttributeDialog; import com.jme3.gde.materialdefinition.dialog.AddAttributeDialog;
import com.jme3.gde.materialdefinition.dialog.AddMaterialParameterDialog; import com.jme3.gde.materialdefinition.dialog.AddMaterialParameterDialog;
import com.jme3.gde.materialdefinition.dialog.AddNodeDialog; import com.jme3.gde.materialdefinition.dialog.AddNodeDialog;

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[474, 25]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" pref="71" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="techniqueComboBox" min="-2" pref="136" max="-2" attributes="0"/>
<EmptySpace min="0" pref="337" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" pref="25" max="32767" attributes="0"/>
<Component id="techniqueComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/materialdefinition/editor/Bundle.properties" key="MatDefEditorToolBar.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="techniqueComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="techniqueComboBoxActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

@ -0,0 +1,105 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.materialdefinition.editor;
import com.jme3.gde.materialdefinition.fileStructure.TechniqueBlock;
import java.awt.Component;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
/**
*
* @author Nehon
*/
public class MatDefEditorToolBar extends javax.swing.JPanel {
private MatDefEditorlElement parent;
private final DefaultComboBoxModel<TechniqueBlock> comboModel = new DefaultComboBoxModel<TechniqueBlock>();
/**
* Creates new form MatDefEditorToolBar
*/
public MatDefEditorToolBar() {
initComponents();
techniqueComboBox.setModel(comboModel);
final DefaultListCellRenderer renderer = new DefaultListCellRenderer();
techniqueComboBox.setRenderer(new ListCellRenderer<TechniqueBlock>() {
public Component getListCellRendererComponent(JList list, TechniqueBlock value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel c = (JLabel)renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
c.setText(value.getName());
return c;
}
});
}
public void setParent(MatDefEditorlElement parent) {
this.parent = parent;
}
public void addTechnique(List<TechniqueBlock> tech){
for (TechniqueBlock tech1 : tech) {
comboModel.addElement(tech1);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
techniqueComboBox = new javax.swing.JComboBox();
setPreferredSize(new java.awt.Dimension(474, 25));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(MatDefEditorToolBar.class, "MatDefEditorToolBar.jLabel1.text")); // NOI18N
techniqueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
techniqueComboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
techniqueComboBoxActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(techniqueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 337, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
.addComponent(techniqueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
}// </editor-fold>//GEN-END:initComponents
private void techniqueComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_techniqueComboBoxActionPerformed
parent.switchTechnique((TechniqueBlock)techniqueComboBox.getSelectedItem());
}//GEN-LAST:event_techniqueComboBoxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JComboBox techniqueComboBox;
// End of variables declaration//GEN-END:variables
}

@ -32,6 +32,7 @@
package com.jme3.gde.materialdefinition.editor; package com.jme3.gde.materialdefinition.editor;
import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.materialdefinition.EditableMatDefFile; import com.jme3.gde.materialdefinition.EditableMatDefFile;
import com.jme3.gde.materialdefinition.MatDefDataObject; import com.jme3.gde.materialdefinition.MatDefDataObject;
import com.jme3.gde.materialdefinition.MatDefMetaData; import com.jme3.gde.materialdefinition.MatDefMetaData;
@ -44,6 +45,7 @@ import com.jme3.gde.materialdefinition.fileStructure.leaves.MatParamBlock;
import com.jme3.gde.materialdefinition.fileStructure.leaves.OutputMappingBlock; import com.jme3.gde.materialdefinition.fileStructure.leaves.OutputMappingBlock;
import com.jme3.gde.materialdefinition.fileStructure.leaves.WorldParamBlock; import com.jme3.gde.materialdefinition.fileStructure.leaves.WorldParamBlock;
import com.jme3.gde.materialdefinition.navigator.MatDefNavigatorPanel; import com.jme3.gde.materialdefinition.navigator.MatDefNavigatorPanel;
import com.jme3.gde.materialdefinition.shadervisual.MatDefShaderElement;
import com.jme3.gde.materialdefinition.utils.MaterialUtils; import com.jme3.gde.materialdefinition.utils.MaterialUtils;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.shader.Shader; import com.jme3.shader.Shader;
@ -69,7 +71,6 @@ import javax.swing.Action;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JToolBar;
import org.netbeans.core.spi.multiview.CloseOperationState; import org.netbeans.core.spi.multiview.CloseOperationState;
import org.netbeans.core.spi.multiview.MultiViewElement; import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.MultiViewElementCallback; import org.netbeans.core.spi.multiview.MultiViewElementCallback;
@ -80,7 +81,6 @@ import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil; import org.openide.filesystems.FileUtil;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.text.EditorSupport;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.LookupEvent; import org.openide.util.LookupEvent;
@ -101,12 +101,13 @@ import org.openide.windows.TopComponent;
public final class MatDefEditorlElement extends JPanel implements MultiViewElement { public final class MatDefEditorlElement extends JPanel implements MultiViewElement {
protected MatDefDataObject obj; protected MatDefDataObject obj;
private JToolBar toolbar = new JToolBar(); private final MatDefEditorToolBar toolbar = new MatDefEditorToolBar();
private transient MultiViewElementCallback callback; private transient MultiViewElementCallback callback;
InstanceContent content; InstanceContent content;
Selectable prevNode; Selectable prevNode;
MatDefMetaData metaData; MatDefMetaData metaData;
@SuppressWarnings("LeakingThisInConstructor")
public MatDefEditorlElement(final Lookup lkp) { public MatDefEditorlElement(final Lookup lkp) {
initComponents(); initComponents();
obj = lkp.lookup(MatDefDataObject.class); obj = lkp.lookup(MatDefDataObject.class);
@ -115,7 +116,9 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
final EditableMatDefFile file = obj.getEditableFile(); final EditableMatDefFile file = obj.getEditableFile();
shaderEditPanel1.setVisible(false); shaderEditPanel1.setVisible(false);
shaderEditPanel1.setParent(this); shaderEditPanel1.setParent(this);
reload(file, lkp); toolbar.setParent(this);
toolbar.addTechnique(lkp.lookup(MatDefBlock.class).getTechniques());
reload(file, lkp);
} }
private void initDiagram(Lookup lkp) throws NumberFormatException { private void initDiagram(Lookup lkp) throws NumberFormatException {
@ -127,7 +130,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
ProjectAssetManager manager = obj.getLookup().lookup(ProjectAssetManager.class); ProjectAssetManager manager = obj.getLookup().lookup(ProjectAssetManager.class);
final MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class); final MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class);
TechniqueBlock technique = getTechnique(matDef); TechniqueBlock technique = getTechnique();
diagram1.setCurrentTechniqueName(technique.getName()); diagram1.setCurrentTechniqueName(technique.getName());
@ -219,6 +222,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
diagram1.revalidate(); diagram1.revalidate();
jScrollPane1.addComponentListener(diagram1); jScrollPane1.addComponentListener(diagram1);
mat.selectTechnique(obj.getEditableFile().getCurrentTechnique().getName(), SceneApplication.getApplication().getRenderManager());
diagram1.refreshPreviews(mat); diagram1.refreshPreviews(mat);
final Lookup.Result<Material> resMat = obj.getLookup().lookupResult(Material.class); final Lookup.Result<Material> resMat = obj.getLookup().lookupResult(Material.class);
resMat.addLookupListener(new LookupListener() { resMat.addLookupListener(new LookupListener() {
@ -226,6 +230,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
Collection<? extends Material> col = (Collection<? extends Material>) resMat.allInstances(); Collection<? extends Material> col = (Collection<? extends Material>) resMat.allInstances();
if (!col.isEmpty()) { if (!col.isEmpty()) {
Material material = col.iterator().next(); Material material = col.iterator().next();
material.selectTechnique(obj.getEditableFile().getCurrentTechnique().getName(), SceneApplication.getApplication().getRenderManager());
diagram1.refreshPreviews(material); diagram1.refreshPreviews(material);
} }
} }
@ -247,6 +252,11 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
} }
} }
public void switchTechnique(TechniqueBlock tech) {
obj.getEditableFile().setCurrentTechnique(tech);
reload(obj.getEditableFile(), obj.getLookup());
}
@Override @Override
public String getName() { public String getName() {
return "MatDefVisualElement"; return "MatDefVisualElement";
@ -278,6 +288,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
Collection<? extends Material> col = (Collection<? extends Material>) resMat.allInstances(); Collection<? extends Material> col = (Collection<? extends Material>) resMat.allInstances();
if (!col.isEmpty()) { if (!col.isEmpty()) {
Material material = col.iterator().next(); Material material = col.iterator().next();
material.selectTechnique(obj.getEditableFile().getCurrentTechnique().getName(), SceneApplication.getApplication().getRenderManager());
diagram1.refreshPreviews(material); diagram1.refreshPreviews(material);
} }
@ -510,8 +521,7 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
} }
public void notifyAddNode(ShaderNodeBlock node, ShaderNodeDefinition def) { public void notifyAddNode(ShaderNodeBlock node, ShaderNodeDefinition def) {
MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class); TechniqueBlock technique = getTechnique();
TechniqueBlock technique = getTechnique(matDef);
if (def.getType() == Shader.ShaderType.Vertex) { if (def.getType() == Shader.ShaderType.Vertex) {
technique.addVertexShaderNode(node); technique.addVertexShaderNode(node);
} else if (def.getType() == Shader.ShaderType.Fragment) { } else if (def.getType() == Shader.ShaderType.Fragment) {
@ -526,15 +536,14 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
} }
public void notifyAddWorldParam(String name) { public void notifyAddWorldParam(String name) {
MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class);
WorldParamBlock param = new WorldParamBlock(name); WorldParamBlock param = new WorldParamBlock(name);
getTechnique(matDef).addWorldParam(param); getTechnique().addWorldParam(param);
} }
public void notifyRemoveNode(NodePanel node) { public void notifyRemoveNode(NodePanel node) {
MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class); MatDefBlock matDef = obj.getLookup().lookup(MatDefBlock.class);
if (node.getType() == NodePanel.NodeType.Fragment || node.getType() == NodePanel.NodeType.Vertex) { if (node.getType() == NodePanel.NodeType.Fragment || node.getType() == NodePanel.NodeType.Vertex) {
TechniqueBlock technique = getTechnique(matDef); TechniqueBlock technique = getTechnique();
for (ShaderNodeBlock shaderNodeBlock : technique.getShaderNodes()) { for (ShaderNodeBlock shaderNodeBlock : technique.getShaderNodes()) {
if (shaderNodeBlock.getName().equals(node.getName())) { if (shaderNodeBlock.getName().equals(node.getName())) {
technique.removeShaderNode(shaderNodeBlock); technique.removeShaderNode(shaderNodeBlock);
@ -543,9 +552,9 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
} else if (node.getType() == NodePanel.NodeType.MatParam) { } else if (node.getType() == NodePanel.NodeType.MatParam) {
matDef.removeMatParam(new MatParamBlock("", node.getKey().replaceAll("MatParam.", ""), "", "")); matDef.removeMatParam(new MatParamBlock("", node.getKey().replaceAll("MatParam.", ""), "", ""));
} else if (node.getType() == NodePanel.NodeType.WorldParam) { } else if (node.getType() == NodePanel.NodeType.WorldParam) {
getTechnique(matDef).removeWorldParam(new WorldParamBlock(node.getKey().replaceAll("WorldParam.", ""))); getTechnique().removeWorldParam(new WorldParamBlock(node.getKey().replaceAll("WorldParam.", "")));
} else if (node.getType() == NodePanel.NodeType.Attribute) { } else if (node.getType() == NodePanel.NodeType.Attribute) {
getTechnique(matDef).cleanupMappings("Attr", node.getKey().replaceAll("Attr.", "")); getTechnique().cleanupMappings("Attr", node.getKey().replaceAll("Attr.", ""));
} }
} }
@ -634,8 +643,8 @@ public final class MatDefEditorlElement extends JPanel implements MultiViewEleme
} }
private TechniqueBlock getTechnique(MatDefBlock matDef) { private TechniqueBlock getTechnique() {
TechniqueBlock technique = matDef.getTechniques().get(0); TechniqueBlock technique = obj.getEditableFile().getCurrentTechnique();
return technique; return technique;
} }

@ -4,6 +4,7 @@
*/ */
package com.jme3.gde.materialdefinition.editor; package com.jme3.gde.materialdefinition.editor;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.materialdefinition.fileStructure.leaves.InputMappingBlock; import com.jme3.gde.materialdefinition.fileStructure.leaves.InputMappingBlock;
import com.jme3.gde.materialdefinition.fileStructure.leaves.OutputMappingBlock; import com.jme3.gde.materialdefinition.fileStructure.leaves.OutputMappingBlock;
import com.jme3.material.Material; import com.jme3.material.Material;
@ -183,6 +184,7 @@ public class OutBusPanel extends DraggablePanel implements ComponentListener, Se
preview.showMaterial(mat); preview.showMaterial(mat);
} else { } else {
Material vmat = mat.clone(); Material vmat = mat.clone();
vmat.selectTechnique(mat.getActiveTechnique().getDef().getName(), SceneApplication.getApplication().getRenderManager());
vmat.getAdditionalRenderState().setWireframe(true); vmat.getAdditionalRenderState().setWireframe(true);
preview.showMaterial(vmat); preview.showMaterial(vmat);
} }

@ -38,26 +38,11 @@ public class ShaderNodeNode extends AbstractMatDefNode implements Selectable, Pr
ShaderNodeBlock shaderNode; ShaderNodeBlock shaderNode;
ShaderNodeDefinition def; ShaderNodeDefinition def;
String key = ""; String key = "";
String techName = "";
public ShaderNodeNode(final Lookup lookup, final ShaderNodeBlock shaderNode) { public ShaderNodeNode(final Lookup lookup, final ShaderNodeBlock shaderNode, final String techName) {
// super(Children.create(new ChildFactory<MappingBlock>() {
// @Override
// protected boolean createKeys(List<MappingBlock> list) {
// list.addAll(shaderNode.getInputs());
// List<OutputMappingBlock> out = shaderNode.getOutputs();
// if (out != null) {
// list.addAll(shaderNode.getOutputs());
// }
//
// return true;
// }
//
// @Override
// protected Node createNodeForKey(MappingBlock key) {
// return new MappingNode(lookup, key);
// }
// }, true), lookup);
super(new MappingNodeChildren(lookup, shaderNode), lookup); super(new MappingNodeChildren(lookup, shaderNode), lookup);
this.techName = techName;
this.shaderNode = shaderNode; this.shaderNode = shaderNode;
setName(shaderNode.getName()); setName(shaderNode.getName());
key = makeKey(); key = makeKey();
@ -138,9 +123,8 @@ public class ShaderNodeNode extends AbstractMatDefNode implements Selectable, Pr
} }
} }
private String makeKey() { private String makeKey() {
String defName = lookup.lookup(MatDefDataObject.class).getEditableFile().getCurrentTechnique().getName(); return techName + "/" + getName();
return defName + "/" + getName();
} }
public String getKey() { public String getKey() {

@ -56,7 +56,7 @@ public class TechniqueNode extends AbstractMatDefNode implements Selectable, Pro
} }
protected TechniqueBlock getDef() { public TechniqueBlock getDef() {
return def; return def;
} }
@ -116,7 +116,7 @@ public class TechniqueNode extends AbstractMatDefNode implements Selectable, Pro
@Override @Override
protected Node[] createNodes(ShaderNodeBlock key) { protected Node[] createNodes(ShaderNodeBlock key) {
return new Node[]{new ShaderNodeNode(lookup, key)}; return new Node[]{new ShaderNodeNode(lookup, key, def.getName())};
} }
} }
} }

@ -31,12 +31,9 @@
*/ */
package com.jme3.gde.materialdefinition.shadervisual; package com.jme3.gde.materialdefinition.shadervisual;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.materialdefinition.EditableMatDefFile;
import com.jme3.gde.materialdefinition.MatDefDataObject; import com.jme3.gde.materialdefinition.MatDefDataObject;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.text.EditorKit; import javax.swing.text.EditorKit;
import org.netbeans.core.spi.multiview.CloseOperationState; import org.netbeans.core.spi.multiview.CloseOperationState;
@ -58,10 +55,11 @@ position = 3000)
@Messages("LBL_MatDef_SHADER=Shader") @Messages("LBL_MatDef_SHADER=Shader")
public final class MatDefShaderElement extends JPanel implements MultiViewElement { public final class MatDefShaderElement extends JPanel implements MultiViewElement {
private MatDefDataObject obj; private final MatDefDataObject obj;
private ShaderVisualToolBar toolbar = new ShaderVisualToolBar(); private final ShaderVisualToolBar toolbar = new ShaderVisualToolBar();
private transient MultiViewElementCallback callback; private transient MultiViewElementCallback callback;
@SuppressWarnings("LeakingThisInConstructor")
public MatDefShaderElement(Lookup lkp) { public MatDefShaderElement(Lookup lkp) {
obj = lkp.lookup(MatDefDataObject.class); obj = lkp.lookup(MatDefDataObject.class);
assert obj != null; assert obj != null;

@ -147,7 +147,7 @@ public class MaterialPreviewRenderer implements SceneListener {
for (MatParam matParam : mat.getParams()) { for (MatParam matParam : mat.getParams()) {
dummy.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue()); dummy.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue());
} }
dummy.selectTechnique(mat.getActiveTechnique().getDef().getName(), SceneApplication.getApplication().getRenderManager());
dummy.getAdditionalRenderState().set(mat.getAdditionalRenderState()); dummy.getAdditionalRenderState().set(mat.getAdditionalRenderState());
//creating a dummy geom and assigning the dummy material to it //creating a dummy geom and assigning the dummy material to it

Loading…
Cancel
Save