We are working with quite big >40GB Alembic files and unfortunately Octane 2.xx fails to animate/refresh some of them properly.
So, I have tried to make a scripted node graph that loads geometry mesh from separate OBJ files and it works fine.
What I haven't been able to figure out so far is how to connect materials to this scripted graph.
Even a single material input would be very helpful as an example.
This is the first LUA script that I am working with and it seems that for some reason I can't access/copy the materials using self:getInputValue(inputs[4]).
I would appreciate it a lot if someone could help me to get the materials working in this script.
Alternatively there can be input mesh "guide" node that is connected to several materials so that we could copy/connect many materials.
Best Regards,
Hando
- Code: Select all
local AnimTexture = {}
local frameTime = 0
function getFrame(currentTime)
return math.floor((currentTime + (frameTime / 2))/frameTime)
end
function AnimTexture.onInit(self, graph)
graph:updateProperties({name = "Animated Mesh"})
local inputInfos = {
{type=octane.PT_STRING, label="File Name", defaultNodeType=octane.NT_FILE},
{type=octane.PT_INT, label="Number of Digits", defaultNodeType=octane.NT_INT, defaultValue=3},
{type=octane.PT_INT, label="Frames per Second", defaultNodeType=octane.NT_INT, defaultValue=30},
-- {type=octane.PT_MATERIAL, label="Material", defaultNodeType=octane.NT_IN_MATERIAL },
-- {type=octane.PT_GEOMETRY, label="Material Guide", defaultNodeType=octane.NT_GEO_MESH }
}
local outputInfos = {
{type=octane.PT_GEOMETRY, label="Animated Mesh"}
}
inputs = graph:setInputLinkers(inputInfos)
outputs = graph:setOutputLinkers(outputInfos)
self:setEvaluateTimeChanges(true)
mesh = octane.node.create{ type = octane.NT_GEO_MESH, name = "Anim Mesh", graphOwner=graph }
outputs[1]:connectTo("input", mesh)
end
function AnimTexture.onEvaluate(self, graph)
if self:timeWasChanged() then
fileName = self:getInputValue(inputs[1])
numDigits = self:getInputValue(inputs[2])
sceneFps = self:getInputValue(inputs[3])
frameTime = 1.0/sceneFps
local frameNum = getFrame(graph.time)
parentPath = octane.file.getParentDirectory(fileName)
baseFile = octane.file.getFileNameWithoutExtension(fileName)
fileExt = octane.file.getFileExtension(fileName)
cleanFile = string.sub(baseFile, 1, baseFile:len() - numDigits)
numFormat = "%0"..numDigits.."u"
finalFile = octane.file.join(parentPath, cleanFile..string.format(numFormat, frameNum)..fileExt)
mesh:setAttribute(octane.A_FILENAME, finalFile)
mesh:setAttribute(octane.A_RELOAD, true)
end
return true
end
return AnimTexture