-- Change the resolution of all the Render Target nodes in the scene in one time -- @author Beppe Gullotta local version = "0.2" -- get the current scene local sceneGraph = octane.project.getSceneGraph() -- get all the Render Target nodes in the scene local renderTargetNodes = octane.nodegraph.findNodes(sceneGraph, 56, true) print(unpack(renderTargetNodes)) -- GUI -- TEXT -- -- lets create a text label local textLbl1 = octane.gui.createLabel { text = "There are ", width = 60, } local textLbl2 = octane.gui.createLabel { text = string.format("%d", #renderTargetNodes), width = 20, textColour = { 255, 255, 0, 255 } } local textLbl3 = octane.gui.createLabel { text = " Render Target nodes in the scene", width = 200, } --local textLbl2 = print(nRT) -- for layouting the text we use a group local textGrp = octane.gui.create { type = octane.gui.componentType.GROUP, text = "", rows = 1, cols = 3, children = { textLbl1, textLbl2, textLbl3 }, padding = { 2 }, inset = { 2 }, } -- RESOLUTION ENTRY -- create the width label local noteLbl1 = octane.gui.create { type = octane.gui.componentType.LABEL, text = "width =", width = 50, } -- create a numeric field for the resolution width local num1 = octane.gui.create { type = octane.gui.componentType.NUMERIC_BOX, minValue = 0, name = "boxX", width = 85, enable = true, value = 1920, maxValue = 1000000 } -- create the height label local noteLbl2 = octane.gui.create { type = octane.gui.componentType.LABEL, text = " height =", width = 50, } -- create a numeric field for the resolution height local num2 = octane.gui.create { type = octane.gui.componentType.NUMERIC_BOX, minValue = 0, name = "boxY", width = 85, enable = true, value = 1080, maxValue = 1000000 } -- for layouting all the elements of the resolution dimensions we use a group local dimGrp = octane.gui.create { type = octane.gui.componentType.GROUP, text = "New Resolution dimensions", rows = 1, cols = 4, children = { noteLbl1, num1, noteLbl2, num2, }, padding = { 2 }, inset = { 5 }, } -- BUTTONS -- local createButton = octane.gui.create { type = octane.gui.componentType.BUTTON, text = "Create", width = 120, height = 20, tooltip = "Change the resolution", } local exitButton = octane.gui.create { type = octane.gui.componentType.BUTTON, text = "Exit", width = 120, height = 20, tooltip = "Exit from the script without changing the resolution", } local buttonGrp = octane.gui.create { type = octane.gui.componentType.GROUP, text = "", rows = 1, cols = 2, children = { createButton, exitButton}, padding = { 5 }, border = false, } -- group that layouts the other groups local layoutGrp = octane.gui.create { type = octane.gui.componentType.GROUP, text = "", rows = 3, cols = 1, children = { textGrp, dimGrp, buttonGrp, }, centre = true, padding = { 2 }, border = false, debug = false, -- true to show the outlines of the group, handy } -- window that holds all components local ResWindow = octane.gui.create { type = octane.gui.componentType.WINDOW, text = "Change resolution v"..version, children = { layoutGrp }, width = layoutGrp:getProperties().width, height = layoutGrp:getProperties().height, } -- END GUI -- -- enable all the ui num1 :updateProperties{ enable = true } num2 :updateProperties{ enable = true } createButton :updateProperties{ enable = true } exitButton :updateProperties{ enable = true } --button functions local function changeRes() ResWindow:closeWindow(true) end local function exitAndDontChangeRes() ResWindow:closeWindow(false) end -- callback handling the GUI elements local function guiCallback(component, event) if component == createButton then changeRes() elseif component == exitButton then exitAndDontChangeRes() print ("ciao") elseif component == ResWindow then --when the window closes, print something if event == octane.gui.eventType.WINDOW_CLOSE then print ("Happy rendering :-)") end end end -- hookup the callback with all the GUI elements num1 :updateProperties { callback = guiCallback } num2 :updateProperties { callback = guiCallback } createButton :updateProperties { callback = guiCallback } exitButton :updateProperties { callback = guiCallback } ResWindow :updateProperties { callback = guiCallback } -- the script will block here until the window closes local create = ResWindow:showWindow() -- stop the script if the user clicked the exit button if not create then return end -- change the resolution of all the Render Target nodes as wanted for i, renderTarget in ipairs(renderTargetNodes) do resNode = octane.node.getInputNode(renderTarget, octane.P_RESOLUTION) resNode:setAttribute(octane.A_VALUE, {num1.value, num2.value, 0}, false) value = resNode:getAttribute(octane.A_VALUE) print(unpack(value)) end