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);
}
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();
}
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);
}
Aggregations