Page 1 of 2

Get transformation from alembic?

PostPosted: Sun Oct 16, 2016 12:37 am
by doca
Hello guys, maybe title speaks for itself, but let me explain a little. I do not know how to do scripting, so I am asking for help.
I have a light rig, lets say, some kind of custom reflector, with zeroed transformations and saved in local DB. As I'm working in external application and rendering in Standalone, I export everything with alembic, but somehow lights are always the pain, especially if I want to tweak transformations of them a little.
So, what I need is to alembic export some guide object (I believe that camera is the best suited for that) and extract its transformations and transform my light rig with it. In short: extract transformations from alembic object, and plug that transformation in the transformation pin of Placement node.
I tried to do that with "FromABC2Thin" script that I downloaded here, and I am getting correct position, but there is not correct rotation output.
Thank in advance,

Re: Get transformation from alembic?

PostPosted: Wed Nov 02, 2016 7:26 am
by doca
Not possible?

Re: Get transformation from alembic?

PostPosted: Wed Nov 02, 2016 5:39 pm
by calus
yes it's possible but I think you have to convert the pos, target and up camera vector to a matrix and apply this matrix in an output Transform_Value node.

Re: Get transformation from alembic?

PostPosted: Wed Nov 02, 2016 11:23 pm
by calus
Here it is,
I took some parts from the explodeCamera script node and the camera map script.

script Node
(2.82 KiB) Downloaded 342 times

Seems to work nicely. :)


Code: Select all
-- Take an ABC camera as input and extract its transformation
-- the output tranform can be plugged in a placement node for example.

local CamTransform = {}
-- edit this to change the name of the graph
local graphName = "cameraTransform"

local inputs  = {}
local outputs = {}
local transform = nil

function CamTransform.onInit(self, graph)
    -- camera input pin
    local inputInfos =
        { type = octane.PT_CAMERA, label = "Camera In", defaultNodeType = octane.NT_CAM_THINLENS },
    -- transform output pin
    local outputInfos =
        { type = octane.PT_TRANSFORM, label = "Transform Out"  },
    -- register the pins
    inputs  = graph:setInputLinkers(inputInfos)
    outputs = graph:setOutputLinkers(outputInfos)
    -- create the transform_value node
    transform = octane.node.create{ type = octane.NT_TRANSFORM_VALUE, name = "Transform Value" }
    outputs[1]:connectToIx(1, transform)

    self:setEvaluateTimeChanges(true) = graphName

-- extract camera matrix
function convertInputs()
    local cameraNode = inputs[1]:getInputNodeIx(1)
    if cameraNode ~= nil then
        local pos       = cameraNode:getPinValue(octane.P_POSITION)
        local target    = cameraNode:getPinValue(octane.P_TARGET)
        local up       = octane.vec.normalized(cameraNode:getPinValue(octane.P_UP))

        local Z = octane.vec.normalized(octane.vec.sub(target, pos))
        local X = octane.vec.normalized(octane.vec.cross(up, Z))
        local Y = octane.vec.normalized(octane.vec.cross(Z, X))

        matrix = {
        {X[1], Y[1], Z[1], pos[1]},
        {X[2], Y[2], Z[2], pos[2]},
        {X[3], Y[3], Z[3], pos[3]},

        transform:setAttribute(octane.A_TRANSFORM, matrix)

function CamTransform.onEvaluate(self, graph)

return CamTransform

Re: Get transformation from alembic?

PostPosted: Sun Nov 06, 2016 8:42 am
by doca
GREAT!!! It works! Thank you very much!

Re: Get transformation from alembic?

PostPosted: Wed Jan 11, 2017 9:03 pm
by treddie
Yes. Many THANKS!

One question. Does Octane use it's own variant of LUA, or is it generic LUA?

Re: Get transformation from alembic?

PostPosted: Thu Jan 12, 2017 2:17 am
by roeland
It's standard Lua 5.1, with a group of modules added to interact with Octane.


Re: Get transformation from alembic?

PostPosted: Thu Jan 12, 2017 9:39 pm
by treddie
Thanks, Roeland!

Re: Get transformation from alembic?

PostPosted: Sun Jan 22, 2017 8:38 pm
by gardeler
This is actually one of the things I have missed the most in octane!! BUT it does not work with motionblur? Can that be solved? Also, the Z axis of my object got inverted, but I could work around that with a negative scale on a different place node.

Re: Get transformation from alembic?

PostPosted: Mon Jan 23, 2017 9:05 pm
by roeland
If you want animated data, you can copy any node to a private root node graph in your script, and vary the time of that root node graph to evaluate that node at arbitrary time stamps. In case of nodes inside an alembic archive, these values will be loaded from the Alembic file.