local AnimateScatter = {} -- variables declared in the script scope are visible for all functions in our -- script for as long as the scripted graph is not deleted or reloaded (in -- programming terms, our two functions become "closures"). local inputs, scatter -- onInit function, this is called once in the beginning. function AnimateScatter.onInit(self, graph) -- evaluate on time change self:setEvaluateTimeChanges(true) -- input and output infos local inputInfos = { {label = "first_file", type = octane.PT_STRING, defaultNodeType=octane.NT_FILE, filePattern="*.txt"}, {label = "geometry", type = octane.PT_GEOMETRY} } local outputInfos = { {label = "geometry", type = octane.PT_GEOMETRY} } -- GET THE SEQUENCE NUMBER OF THE TEXT FILE LOADED, WITH SOMETHING LIKE: -- check if we have a file name given local prefix, sequenceMatch, suffix -- If we have a file name, check where to substitute the sequence number: -- pattern tutorial here: http://lua-users.org/wiki/PatternsTutorial if file ~= "" then -- strip png extension file = file:gsub("%.txt$", "") -- split file into prefix, sequence number and suffix -- make sure the sequence number is in the final file name part prefix, sequenceMatch, suffix = file:match("(.-)(%d+)([^\\/]*)$") -- if the file name doesn't contain a sequence number, the match fails -- so just assume it is all prefix. if sequenceMatch == nil then prefix = file sequenceMatch = "00000" suffix = "" end -- pattern for string.format. seqPattern = "%0"..sequenceMatch:len().."d" -- add png extension suffix = suffix..".txt" -- display resulting file name fileEditor.text = prefix..sequenceMatch..suffix end -- use these functions to set up input and output linkers. This will keep -- existing linkers so existing connections in the parent graph are kept. inputs = graph:setInputLinkers(inputInfos) local outputs = graph:setOutputLinkers(outputInfos) -- set up a node to give the graph some output value scatter = octane.node.create{ type=octane.NT_GEO_SCATTER, name="scatter", graphOwner=graph } outputs[1]:connectTo("input", scatter) end -- this function is called every time the value of an input linker changes function AnimateScatter.onEvaluate(self, graph) -- GET THE CURRENT FRAME AND LOOK FOR A FILE WITH THAT SEQUENCE NUMBER ?? -- IF IT EXISTS, LOAD IT INTO NT_GEO_SCATTER ?? -- OUTPUT THE SCATTERED GEOMETRY TO THE OUTPUT PIN ?? end return AnimateScatter