Page 1 of 1
Scale and scatter files inside Standalone?
Posted: Thu Apr 28, 2016 3:47 pm
by Zay
When rescaling objects in standalone is there any way to get the scatter files follow the rescale?
I don't have the scene anymore for my 3D app to generate new scatter files, so is there any way I can recalculate the scatter file inside Standalone when rescaling objects that uses the scatter files?
Re: Scale and scatter files inside Standalone?
Posted: Thu Apr 28, 2016 11:42 pm
by haze
If I understand correctly, you have a scatter node connected to a placement node, and you'd like to rescale your scatter files and get them out again. Here is a lua script that will do it. Create a placement node, connect it to the output pin of the scatter node, make the changes in the placement node, then ensure it is still selected and run this script - it will create a new scatter node with your placement node's changes made to it. Then you can copy the transforms from this scatter node.
Code: Select all
local placement = octane.project.getSelection()[1]
if not placement or placement:getNodeInfo().type ~= octane.nodeType.NT_GEO_PLACEMENT then
octane.gui.showError("Please select a placement node.", "Select placement")
return
end
local placementTransform = placement:getConnectedNode(octane.pinId.P_TRANSFORM)
local postMatrix = placementTransform:getAttribute(octane.attributeId.A_TRANSFORM)
local scatter = placement:getConnectedNode(octane.pinId.P_GEOMETRY)
if scatter:getNodeInfo().type ~= octane.nodeType.NT_GEO_SCATTER then
octane.gui.showError("Script only works for placement connected to scatter node at the moment.", "Error")
return
end
-- scatter has attribute array A_TRANSFORMS of matrix type
local transforms = scatter:getAttribute(octane.attributeId.A_TRANSFORMS)
local newTransforms = {}
for k,v in pairs(transforms) do
print("dealing with transform " .. k)
newTransforms[k] = octane.matrix.mul(v, postMatrix)
end
local bakedScatter = octane.node.create {
name = "Baked Scatter",
type = octane.nodeType.NT_GEO_SCATTER
}
bakedScatter:setAttribute(octane.attributeId.A_TRANSFORMS, newTransforms)
Re: Scale and scatter files inside Standalone?
Posted: Fri Apr 29, 2016 3:07 pm
by Zay
This is awesome! Thank you Haze
