Search in sources :

Example 1 with NodeWidget

use of com.talosvfx.talos.editor.nodes.NodeWidget in project talos by rockbite.

the class ShaderNodeStage method exportPixmap.

public Pixmap exportPixmap() {
    if (colorOutput == null)
        return null;
    frameBuffer.begin();
    spriteBatch.begin();
    Vector2 tmp = new Vector2();
    Vector2 targetSize = new Vector2(64, 64);
    for (NodeWidget nodeWidget : nodeBoard.nodes) {
        if (nodeWidget instanceof SampleTextureNode) {
            SampleTextureNode node = (SampleTextureNode) nodeWidget;
            Texture texture = node.getValue();
            if (texture.getWidth() > targetSize.x) {
                targetSize.x = texture.getWidth();
            }
            if (texture.getHeight() > targetSize.y) {
                targetSize.y = texture.getHeight();
            }
        }
    }
    viewport.update((int) targetSize.x, (int) targetSize.y);
    spriteBatch.setProjectionMatrix(viewport.getCamera().combined);
    tmp.set(colorOutput.getShaderBox().getX(), colorOutput.getShaderBox().getY());
    colorOutput.getShaderBox().setPosition(0, 0);
    colorOutput.getShaderBox().draw(spriteBatch, 1f);
    colorOutput.getShaderBox().setPosition(tmp.x, tmp.y);
    spriteBatch.end();
    Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, (int) targetSize.x, (int) targetSize.y);
    frameBuffer.end();
    return pixmap;
}
Also used : SampleTextureNode(com.talosvfx.talos.editor.addons.shader.nodes.SampleTextureNode) Vector2(com.badlogic.gdx.math.Vector2) NodeWidget(com.talosvfx.talos.editor.nodes.NodeWidget)

Example 2 with NodeWidget

use of com.talosvfx.talos.editor.nodes.NodeWidget in project talos by rockbite.

the class ShaderNodeStage method createNode.

@Override
public NodeWidget createNode(String nodeName, float x, float y) {
    if (!nodeName.equals("ColorOutput")) {
        return super.createNode(nodeName, x, y);
    } else {
        if (colorOutput == null) {
            NodeWidget node = super.createNode(nodeName, x, y);
            colorOutput = (ColorOutput) node;
            return node;
        }
    }
    return null;
}
Also used : NodeWidget(com.talosvfx.talos.editor.nodes.NodeWidget)

Example 3 with NodeWidget

use of com.talosvfx.talos.editor.nodes.NodeWidget in project talos by rockbite.

the class ExternalShaderNode method addUniformInput.

private void addUniformInput(String uniformName, String method, String[] args) {
    String xml = "<value port=\"input\" name=\"" + uniformName + "\" type=\"float\">" + uniformName + "</value>";
    XmlReader reader = new XmlReader();
    XmlReader.Element elem = reader.parse(xml);
    addRow(elem, 0, 0, false, customContainer, true);
    String moduleName = "FloatUniform";
    // todo: check this cast
    ShaderNodeStage nodeStage = (ShaderNodeStage) TalosMain.Instance().getNodeStage();
    NodeWidget node = nodeStage.createNode(moduleName, this.getX() - 200, this.getY());
    UniformNode uniformNode = (UniformNode) node;
    node.constructNode(nodeStage.getNodeListPopup().getModuleByName(moduleName));
    Notifications.fireEvent(Notifications.obtainEvent(NodeCreatedEvent.class).set(node));
    nodeStage.getNodeBoard().makeConnection(node, this, "out", uniformName);
    ((UniformNode) node).setValue(0.5f);
    uniformNode.setUniformName(uniformName);
}
Also used : ShaderNodeStage(com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage) NodeWidget(com.talosvfx.talos.editor.nodes.NodeWidget) XmlReader(com.badlogic.gdx.utils.XmlReader)

Aggregations

NodeWidget (com.talosvfx.talos.editor.nodes.NodeWidget)3 Vector2 (com.badlogic.gdx.math.Vector2)1 XmlReader (com.badlogic.gdx.utils.XmlReader)1 SampleTextureNode (com.talosvfx.talos.editor.addons.shader.nodes.SampleTextureNode)1 ShaderNodeStage (com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage)1