Search in sources :

Example 1 with ShaderNodeStage

use of com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage in project talos by rockbite.

the class ShaderAddon method buildMenu.

@Override
public void buildMenu(MenuBar menuBar) {
    Menu menu = new Menu("Shader Graph");
    MenuItem newFile = new MenuItem("New Shader");
    menu.addItem(newFile);
    MenuItem openFile = new MenuItem("Open Shader");
    menu.addItem(openFile);
    MenuItem exportRaw = new MenuItem("Export RAW");
    menu.addItem(exportRaw);
    MenuItem exportPNG = new MenuItem("Export PNG");
    menu.addItem(exportPNG);
    MenuItem exportSequence = new MenuItem("Export Sequence");
    menu.addItem(exportSequence);
    newFile.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().ProjectController().newProject(SHADER_PROJECT);
        }
    });
    openFile.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().UIStage().openProjectAction(SHADER_PROJECT);
        }
    });
    exportRaw.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // export RAW logic
            TalosMain.Instance().UIStage().showSaveFileChooser(".frag", new FileChooserAdapter() {

                @Override
                public void selected(Array<FileHandle> files) {
                    String fragShader = ((ShaderNodeStage) (nodeStage)).getFragShader();
                    FileHandle file = files.get(0);
                    file.writeString(fragShader, false);
                }
            });
        }
    });
    exportPNG.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // export RAW logic
            TalosMain.Instance().UIStage().showSaveFileChooser(".png", new FileChooserAdapter() {

                @Override
                public void selected(Array<FileHandle> files) {
                    FileHandle file = files.get(0);
                    Pixmap pixmap = ((ShaderNodeStage) (nodeStage)).exportPixmap();
                    if (pixmap != null) {
                        PixmapIO.writePNG(file, pixmap);
                        pixmap.dispose();
                    }
                }
            });
        }
    });
    exportSequence.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().UIStage().getStage().addActor(exportSequenceDialog.fadeIn());
        }
    });
    menuBar.addMenu(menu);
}
Also used : Array(com.badlogic.gdx.utils.Array) ShaderNodeStage(com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage) FileHandle(com.badlogic.gdx.files.FileHandle) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Menu(com.kotcrab.vis.ui.widget.Menu) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 2 with ShaderNodeStage

use of com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage in project talos by rockbite.

the class ShaderAddon method init.

@Override
public void init() {
    SHADER_PROJECT = new ShaderProject(this);
    nodeStage = new ShaderNodeStage(TalosMain.Instance().UIStage().getSkin());
    nodeStage.init();
    buildUI();
}
Also used : ShaderNodeStage(com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage)

Example 3 with ShaderNodeStage

use of com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage 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

ShaderNodeStage (com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage)3 FileHandle (com.badlogic.gdx.files.FileHandle)1 Pixmap (com.badlogic.gdx.graphics.Pixmap)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 Array (com.badlogic.gdx.utils.Array)1 XmlReader (com.badlogic.gdx.utils.XmlReader)1 Menu (com.kotcrab.vis.ui.widget.Menu)1 MenuItem (com.kotcrab.vis.ui.widget.MenuItem)1 FileChooserAdapter (com.kotcrab.vis.ui.widget.file.FileChooserAdapter)1 NodeWidget (com.talosvfx.talos.editor.nodes.NodeWidget)1