diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Dot.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Dot.java index 651d8b2f5..105b2f731 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Dot.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Dot.java @@ -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) diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java index 1ee7ffced..81355ae44 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java @@ -54,6 +54,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha private String techName; private NodeToolBar toolBar; protected List filePaths = new ArrayList(); + 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); diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/OutBusPanel.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/OutBusPanel.java index 42354cfd7..1cadfb0e0 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/OutBusPanel.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/OutBusPanel.java @@ -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); diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/ShaderNodeSource b/sdk/jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/ShaderNodeSource index 6c0fc0542..48380da2a 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/ShaderNodeSource +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/shadernodedefinition/ShaderNodeSource @@ -1,11 +1,11 @@ - + void main(){ - <#list inputParams as param> + <#list inputParams as param> //@input ${param[0]} ${param[1]} ${param[2]} - <#list outputParams as param> + <#list outputParams as param> //@output ${param[0]} ${param[1]} ${param[2]} - + //insert glsl code here } \ No newline at end of file