More controls when connecting inputs and outputs in the node editor

experimental
Nehon 10 years ago
parent 9500b43aa9
commit 1286fa0fba
  1. 15
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Dot.java
  2. 3
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java
  3. 19
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/OutBusPanel.java
  4. 8
      sdk/jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/ShaderNodeSource

@ -5,6 +5,7 @@
package com.jme3.gde.materialdefinition.editor;
import com.jme3.gde.materialdefinition.icons.Icons;
import com.jme3.shader.Shader;
import com.jme3.shader.ShaderUtils;
import java.awt.Component;
import java.awt.Dimension;
@ -27,6 +28,7 @@ public class Dot extends JPanel implements MouseInputListener {
protected ImageIcon prevImg;
private String type;
private ParamType paramType;
protected Shader.ShaderType shaderType;
private String text = "";
private DraggablePanel node;
private int index = 1;
@ -46,6 +48,7 @@ public class Dot extends JPanel implements MouseInputListener {
Both
}
@SuppressWarnings("LeakingThisInConstructor")
public Dot() {
super();
setMaximumSize(new Dimension(10, 10));
@ -54,6 +57,11 @@ public class Dot extends JPanel implements MouseInputListener {
setSize(10, 10);
addMouseMotionListener(this);
addMouseListener(this);
}
public void setShaderTypr(Shader.ShaderType shaderType){
this.shaderType = shaderType;
}
@Override
@ -143,14 +151,15 @@ public class Dot extends JPanel implements MouseInputListener {
}
public boolean canConnect(Dot pair) {
if (pair == null) {
if (pair == null || paramType == ParamType.Input ||
((pair.getNode() instanceof OutBusPanel || node instanceof OutBusPanel) && shaderType != pair.shaderType)) {
img = Icons.imgOrange;
repaint();
return false;
}
if (matches(pair.getType(), type) && (pair.getParamType() != paramType
|| pair.getParamType() == ParamType.Both
|| paramType == ParamType.Both)

@ -54,6 +54,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
private String techName;
private NodeToolBar toolBar;
protected List<String> filePaths = new ArrayList<String>();
protected Shader.ShaderType shaderType;
// private List listeners = Collections.synchronizedList(new LinkedList());
//
@ -99,6 +100,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
@SuppressWarnings("LeakingThisInConstructor")
public NodePanel(ShaderNodeBlock node, ShaderNodeDefinition def) {
super();
shaderType = def.getType();
if (def.getType() == Shader.ShaderType.Vertex) {
type = NodePanel.NodeType.Vertex;
} else {
@ -419,6 +421,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha
public Dot createDot(String type, Dot.ParamType paramType, String paramName) {
Dot dot1 = new Dot();
dot1.setShaderTypr(shaderType);
dot1.setNode(this);
dot1.setText(paramName);
dot1.setParamType(paramType);

@ -33,20 +33,16 @@ public class OutBusPanel extends DraggablePanel implements ComponentListener, Se
private Color color = new Color(220, 220, 70);
private String name = "";
private InnerPanel panel;
private MatPanel preview;
private Shader.ShaderType type;
private final InnerPanel panel;
private final MatPanel preview;
private final Shader.ShaderType type;
public OutBusPanel(String name, Shader.ShaderType type) {
this(name);
super(true);
this.type = type;
if (type == Shader.ShaderType.Fragment) {
this.color = new Color(114, 200, 255);
}
}
private OutBusPanel(String name) {
super(true);
setBounds(0, 0, 300, 50);
JLabel title = new JLabel();
this.name = name;
@ -96,7 +92,11 @@ public class OutBusPanel extends DraggablePanel implements ComponentListener, Se
});
}
public Shader.ShaderType getType(){
return type;
}
@Override
protected void paintComponent(Graphics g1) {
Graphics2D g = (Graphics2D) g1;
@ -236,6 +236,7 @@ public class OutBusPanel extends DraggablePanel implements ComponentListener, Se
boolean dragging = false;
public InnerPanel() {
this.shaderType = OutBusPanel.this.type;
setOpaque(false);
setNode(OutBusPanel.this);
setParamType(Dot.ParamType.Both);

@ -1,11 +1,11 @@
void main(){
<#list inputParams as param>
<#list inputParams as param>
//@input ${param[0]} ${param[1]} ${param[2]}
</#list>
<#list outputParams as param>
<#list outputParams as param>
//@output ${param[0]} ${param[1]} ${param[2]}
</#list>
</#list>
//insert glsl code here
}
Loading…
Cancel
Save