Get transformation from alembic?

Forums: Get transformation from alembic?
Forum for OctaneRender Lua scripting examples, discussion and support.

Get transformation from alembic?

Postby doca » Sun Oct 16, 2016 12:37 am

doca Sun Oct 16, 2016 12:37 am
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,
Doca
doca
Licensed Customer
Licensed Customer
 
Posts: 90
Joined: Sat Mar 13, 2010 12:12 pm

Re: Get transformation from alembic?

Postby doca » Wed Nov 02, 2016 7:26 am

doca Wed Nov 02, 2016 7:26 am
Not possible?
doca
Licensed Customer
Licensed Customer
 
Posts: 90
Joined: Sat Mar 13, 2010 12:12 pm

Re: Get transformation from alembic?

Postby calus » Wed Nov 02, 2016 5:39 pm

calus Wed Nov 02, 2016 5:39 pm
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.
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: Get transformation from alembic?

Postby calus » Wed Nov 02, 2016 11:23 pm

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

cameraTransform.orbx
script Node
(2.82 KiB) Downloaded 707 times

Seems to work nicely. :)

octane_2016-11-03_10-03-56.png
usage


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)

    graph.name = graphName
    graph:unfold()
end

-- 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)
    end
end

function CamTransform.onEvaluate(self, graph)
    convertInputs()
end

return CamTransform
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: Get transformation from alembic?

Postby doca » Sun Nov 06, 2016 8:42 am

doca Sun Nov 06, 2016 8:42 am
GREAT!!! It works! Thank you very much!
doca
Licensed Customer
Licensed Customer
 
Posts: 90
Joined: Sat Mar 13, 2010 12:12 pm

Re: Get transformation from alembic?

Postby treddie » Wed Jan 11, 2017 9:03 pm

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

One question. Does Octane use it's own variant of LUA, or is it generic LUA?
Win7 | Geforce TitanX w/ 12Gb | Geforce GTX-560 w/ 2Gb | 6-Core 3.5GHz | 32Gb | Cinema4D w RipTide Importer and OctaneExporter Plugs.
treddie
Licensed Customer
Licensed Customer
 
Posts: 739
Joined: Fri Mar 23, 2012 5:44 am

Re: Get transformation from alembic?

Postby roeland » Thu Jan 12, 2017 2:17 am

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

--
Roeland
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1808
Joined: Wed Mar 09, 2011 10:09 pm

Re: Get transformation from alembic?

Postby treddie » Thu Jan 12, 2017 9:39 pm

treddie Thu Jan 12, 2017 9:39 pm
Thanks, Roeland!
Win7 | Geforce TitanX w/ 12Gb | Geforce GTX-560 w/ 2Gb | 6-Core 3.5GHz | 32Gb | Cinema4D w RipTide Importer and OctaneExporter Plugs.
treddie
Licensed Customer
Licensed Customer
 
Posts: 739
Joined: Fri Mar 23, 2012 5:44 am

Re: Get transformation from alembic?

Postby gardeler » Sun Jan 22, 2017 8:38 pm

gardeler Sun Jan 22, 2017 8:38 pm
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.
gardeler
Licensed Customer
Licensed Customer
 
Posts: 121
Joined: Fri Feb 22, 2013 5:10 pm

Re: Get transformation from alembic?

Postby roeland » Mon Jan 23, 2017 9:05 pm

roeland Mon Jan 23, 2017 9:05 pm
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.

--
Roeland
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1808
Joined: Wed Mar 09, 2011 10:09 pm
Next

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 5 guests

Thu Mar 28, 2024 5:39 pm [ UTC ]