Hi Zay,
Here's a basic skeleton script, all it does is collect all the materials in the mesh node in a list. What you do with them is up to you... .
Code: Select all
-- Script to do "something" with the materials of a loaded OBJ mesh.
-- Get the selected mesh.
local mesh = octane.project.getSelection()[1]
assert(mesh:getProperties().type == octane.NT_GEO_MESH, "mesh expected")
-- Get all the materials of the selected mesh.
local mats = {}
for pinIx = 1, mesh:getPinCount() do
local matNode = mesh:getConnectedNodeIx(pinIx)
if matNode then
print(string.format("pin %d -> material %s", pinIx, matNode:getProperties().name))
-- collect the connected nodes
table.insert(mats, matNode)
end
end
-- We have the materials in a list, do something with them ...
For example, you could write a script that ask the user which OBJ file to load and display a window with some presets that can be configured. When the mesh is loaded, those presets will be used (e.g. create glossy materials for materials slots that weren't loaded, set the roughness to 1, ...).
I hope this snippet helps...
cheers,
Thomas