Grimm's take on the turntable anim script

Forums: Grimm's take on the turntable anim script
Forum for OctaneRender Lua scripting examples, discussion and support.

Re: Grimm's take on the turntable anim script

Postby stratified » Thu Jan 02, 2014 11:55 pm

stratified Thu Jan 02, 2014 11:55 pm
The advantage of using Octane via Blender is that you way more flexibility while to Lua scripts are just tailored for a single animation type. They are nowhere near as flexible as using Blender. My guess is that at some point we'll have some pretty advanced scripts (for example, Jason is improving his script in every iteration) but I would be surprised if someone would come up with the same flexibility as you would expect from host apps. It's possible but it would require a huge amount of work...

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Grimm's take on the turntable anim script

Postby r-username » Fri Jan 03, 2014 12:49 am

r-username Fri Jan 03, 2014 12:49 am
stratified wrote:They are nowhere near as flexible as using Blender.


I agree 100%.
Just to clarify it's the most common animation types that I think there should be lua scripts for.

In fact with all the great additions to the turntable script, pan/truck (cam left right) is the only script really needed now.

Thanks again for the great software
cheers, s
i7 960 - W7x64 - 12 GB - 2x GTX 780ti
http://www.startsimple.com/ - http://www.gigavr.com/
r-username
Licensed Customer
Licensed Customer
 
Posts: 217
Joined: Thu Nov 24, 2011 3:39 pm

Re: Grimm's take on the turntable anim script

Postby stratified » Fri Jan 03, 2014 1:32 am

stratified Fri Jan 03, 2014 1:32 am
r-username wrote:
stratified wrote:They are nowhere near as flexible as using Blender.


I agree 100%.
Just to clarify it's the most common animation types that I think there should be lua scripts for.

In fact with all the great additions to the turntable script, pan/truck (cam left right) is the only script really needed now.

Thanks again for the great software
cheers, s


Well, I hope this isn't the only script that's needed for now. For example, I'd like to see a tool to edit scatter nodes. Right now it's so cumbersome in Octane that there's even a third-party app called "Phantom Scatter" just to do this. I think something like that would be a great script as well and it might make the author a nice buck.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Grimm's take on the turntable anim script

Postby stratified » Fri Jan 03, 2014 1:46 am

stratified Fri Jan 03, 2014 1:46 am
pixelrush wrote:I tried a wee experiment in Solidworks. The path here is a projected one arising from an ellipse and a parabola. I then divided the path equally into 24 (edit actually I see one is accidentally repeated) and used a macro to save out the co-ords to a txt file.
This was quite quick and easy to do. Virtually any imaginable geometry could be used as a basis for obtaining the camera position for each frame. All it needs is to be read into the script.
You are right though, how much functionality is enough considering cg apps do this natively?
Still at least if someone wanted to, they could do this type of thing, although you are 'not supposed to'. Just don't tell Uncle Roeland about it :)


reading in the values generated by Solidworks is trivial, it's actually building a usable user interface that works with generic curves that's the hard problem.

But I think it's still pretty cool that users can draw a path in an app and then use this in Octane.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Grimm's take on the turntable anim script

Postby pixelrush » Fri Jan 03, 2014 3:38 am

pixelrush Fri Jan 03, 2014 3:38 am
Well it may be trivial for some of us, a lot of research effort for normal people :)
..and Uncle Roeland doesn't want alien generic curve stuff littering his program. :arrow: :evil:
I was thinking of making some generic paths/point lists though for the 'library' with '1.0' as the basis if reading was implemented ie xyz readily scalable in the script. std ellipse 0.5x1.0 -> 7.5mx15.0m with slider.
The thing is too not every app that might ulitise Octane for rendering is a cg one. If you come from Inventor, AutoCAD, SolidWorks or SolidEdge ie engineering programs, they don't have this capability.
Also cg programs don't tend to generate geometrically precise paths like an ellipse, parabola, lissajous figure...
Here attached is a messy sketch as I was thinking about how to do the bits r-username wanted.
Points for endeavour, right? 8-)
I think getting the info and doing the linear calcs ought to be easy enough.
I wont start this myself though because someone like Grimm will finish it before I do a couple of lines ;)
Attachments
camera handling.jpg
i7-3820 @4.3Ghz | 24gb | Win7pro-64
GTS 250 display + 2 x GTX 780 cuda| driver 331.65
Octane v1.55
User avatar
pixelrush
Licensed Customer
Licensed Customer
 
Posts: 1618
Joined: Mon Jan 11, 2010 7:11 pm
Location: Nelson, New Zealand

Re: Grimm's take on the turntable anim script

Postby pixelrush » Fri Jan 03, 2014 9:32 am

pixelrush Fri Jan 03, 2014 9:32 am
BTW unless I am mistaken there is a problem stopping the preview and animation in v0.7.
The [Stop Render] button is greyed out.
i7-3820 @4.3Ghz | 24gb | Win7pro-64
GTS 250 display + 2 x GTX 780 cuda| driver 331.65
Octane v1.55
User avatar
pixelrush
Licensed Customer
Licensed Customer
 
Posts: 1618
Joined: Mon Jan 11, 2010 7:11 pm
Location: Nelson, New Zealand

Re: Grimm's take on the turntable anim script

Postby grimm » Fri Jan 03, 2014 11:09 pm

grimm Fri Jan 03, 2014 11:09 pm
stratified wrote:Hi Jason,

It isn't mandatory to select the render target before running the script. I used that approach because it was used in the turntable animation in older Octane versions. You could use the combo box exclusively. It's less usefull (I think) if the user has 10 render targets, all named "Render Target". You could give some visual clues by selecting the render target in the editor but I don't think it's worth it. That's just my opinion of course and it's your code. You already made it way more useful than the script we presented initially.

BTW: You don't have to credit Roeland and me in the header of your script. The code we provide can just be used. Of course we don't guarantee that it won't stop the universe.

cheers,
Thomas


Thanks Thomas, although I don't want the universe to end, I wouldn't feel right if I didn't credit you and Roeland. It would be too much like stealing for me to do that. :D

You make a very good point on the 10 render targets, all with the same name. I put this code together and tested it on 1.24, but it's running very strangely in that for the most part it works except when I don't have a node selected or I select a camera group.

Code: Select all
-- Returns all the items, even those owned by nested graphs.
local function getAllItems(graph)
    local all = {}
    for i, item in ipairs(graph:getOwnedItems()) do
        -- for graphs we recursively collect all the items
        if item:getProperties().isGraph then
            local nested = getAllItems(item)
            -- merge the tables
            for j, nestedItem in ipairs(nested) do
                table.insert(all, nestedItem)
            end
        else
            table.insert(all, item)
        end
    end
    return all
end

-- Returns copies of the original scene graph, the camera node and the rendertarget.
-- This prevents us from modifying the original scene.
function getSceneCopy()
    -- get the selected render target
    local selectedRt = octane.project.getSelection()[1]

    -- find the index of the selected render target node
    local idx = -1
    local allNodes
    local selectedTarg

    -- no node has been selected
    if selectedRt == nil then
print "no node"
        allNodes = getAllItems(octane.nodegraph.getRootGraph())
        -- find first render target in root graph
        for i, item in ipairs(allNodes) do
            if item:getProperties().type == octane.NT_RENDERTARGET then
                idx = i
                selectedTarg = item:getProperties().name
                break
            end
        end

    -- graph/linker node is selected
    elseif selectedRt:getProperties().isGraph then
print "graph node"
        local nodes = getAllItems(selectedRt)
        local rtNode
        -- find first render target in selected graph
        for i, item in ipairs(nodes) do
            if item:getProperties().type == octane.NT_RENDERTARGET then
                rtNode = item
                break
            end
        end
        -- now find the render target in the root graph
        allNodes = getAllItems(octane.nodegraph.getRootGraph())
        for i, item in ipairs(allNodes) do
            if item == rtNode then
                idx = i
                selectedTarg = item:getProperties().name
                break
            end
        end

    -- render target node has been selected
    elseif selectedRt:getProperties().type == octane.NT_RENDERTARGET then
print "render target node"
        allNodes = getAllItems(octane.nodegraph.getRootGraph())
        -- find the render target in the root graph
        for i, item in ipairs(allNodes) do
            if item == selectedRt then
                idx = i
                selectedTarg = item:getProperties().name
                break
            end
        end
    -- some other node has been selected so error out
    else
        showError("TurntableG Error!", "You have selected a node that can't be used, please select a render target node or a group with a render target in it.", true)
    end

    -- see if we could find the node
    if idx == -1 then showError("TurntableG Error!","Could not select a render target node!", true) end
   
    -- create a full copy of the project so that we don't modify the original project
    local copyScene = octane.nodegraph.createRootGraph("Project Copy")
    copyScene:copyFrom(octane.nodegraph.getRootGraph():getOwnedItems())
    local copies = getAllItems(copyScene)
    copyRt = copies[idx]
   
    local copyCam = copyRt:getInputNode(octane.P_CAMERA)

    -- Find all render targets
    local renderTargets = octane.nodegraph.getRootGraph():findNodes(octane.NT_RENDERTARGET)
    local renTargList = {}
    for i, item in ipairs(renderTargets) do
        -- renTargList[item:getProperties().name] = item
        renTargList[#renTargList + 1] = item:getProperties().name
    end

    return copyScene, copyRt, copyCam, renTargList, selectedTarg
end


Did some more testing on this, even when you select a render target node, I'm getting random nodes returned from the getSceneCopy() function. Sometimes it is lucky and it gets the correct node. Most of the time it gets some other random node. Very strange?

Thanks,

Jason
Last edited by grimm on Fri Jan 03, 2014 11:29 pm, edited 1 time in total.
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Grimm's take on the turntable anim script

Postby grimm » Fri Jan 03, 2014 11:14 pm

grimm Fri Jan 03, 2014 11:14 pm
pixelrush wrote:BTW unless I am mistaken there is a problem stopping the preview and animation in v0.7.
The [Stop Render] button is greyed out.


I just tried it with Octane 1.24 and it worked. Maybe I fixed something since then. V0.8 is almost ready, try that and see if it works.

Thanks,

Jason

Note: now that I think about it, you might try re-downloading the zip file and see if it fixes the problem.
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Grimm's take on the turntable anim script

Postby pixelrush » Sat Jan 04, 2014 2:55 am

pixelrush Sat Jan 04, 2014 2:55 am
Re-downloaded and its working correctly. 8-)
Not sure what caused that :roll: anyway its ok.
Looking forward to v0.8 ;)
Really appreciate you doing this/sharing with us. :D
A steep learning experience for me I am afraid :geek:
i7-3820 @4.3Ghz | 24gb | Win7pro-64
GTS 250 display + 2 x GTX 780 cuda| driver 331.65
Octane v1.55
User avatar
pixelrush
Licensed Customer
Licensed Customer
 
Posts: 1618
Joined: Mon Jan 11, 2010 7:11 pm
Location: Nelson, New Zealand

Re: Grimm's take on the turntable anim script

Postby stratified » Sat Jan 04, 2014 4:42 am

stratified Sat Jan 04, 2014 4:42 am
grimm wrote:
stratified wrote:Hi Jason,

It isn't mandatory to select the render target before running the script. I used that approach because it was used in the turntable animation in older Octane versions. You could use the combo box exclusively. It's less usefull (I think) if the user has 10 render targets, all named "Render Target". You could give some visual clues by selecting the render target in the editor but I don't think it's worth it. That's just my opinion of course and it's your code. You already made it way more useful than the script we presented initially.

BTW: You don't have to credit Roeland and me in the header of your script. The code we provide can just be used. Of course we don't guarantee that it won't stop the universe.

cheers,
Thomas


Thanks Thomas, although I don't want the universe to end, I wouldn't feel right if I didn't credit you and Roeland. It would be too much like stealing for me to do that. :D

You make a very good point on the 10 render targets, all with the same name. I put this code together and tested it on 1.24, but it's running very strangely in that for the most part it works except when I don't have a node selected or I select a camera group.

Code: Select all
-- Returns all the items, even those owned by nested graphs.
local function getAllItems(graph)
    local all = {}
    for i, item in ipairs(graph:getOwnedItems()) do
        -- for graphs we recursively collect all the items
        if item:getProperties().isGraph then
            local nested = getAllItems(item)
            -- merge the tables
            for j, nestedItem in ipairs(nested) do
                table.insert(all, nestedItem)
            end
        else
            table.insert(all, item)
        end
    end
    return all
end

-- Returns copies of the original scene graph, the camera node and the rendertarget.
-- This prevents us from modifying the original scene.
function getSceneCopy()
    -- get the selected render target
    local selectedRt = octane.project.getSelection()[1]

    -- find the index of the selected render target node
    local idx = -1
    local allNodes
    local selectedTarg

    -- no node has been selected
    if selectedRt == nil then
print "no node"
        allNodes = getAllItems(octane.nodegraph.getRootGraph())
        -- find first render target in root graph
        for i, item in ipairs(allNodes) do
            if item:getProperties().type == octane.NT_RENDERTARGET then
                idx = i
                selectedTarg = item:getProperties().name
                break
            end
        end

    -- graph/linker node is selected
    elseif selectedRt:getProperties().isGraph then
print "graph node"
        local nodes = getAllItems(selectedRt)
        local rtNode
        -- find first render target in selected graph
        for i, item in ipairs(nodes) do
            if item:getProperties().type == octane.NT_RENDERTARGET then
                rtNode = item
                break
            end
        end
        -- now find the render target in the root graph
        allNodes = getAllItems(octane.nodegraph.getRootGraph())
        for i, item in ipairs(allNodes) do
            if item == rtNode then
                idx = i
                selectedTarg = item:getProperties().name
                break
            end
        end

    -- render target node has been selected
    elseif selectedRt:getProperties().type == octane.NT_RENDERTARGET then
print "render target node"
        allNodes = getAllItems(octane.nodegraph.getRootGraph())
        -- find the render target in the root graph
        for i, item in ipairs(allNodes) do
            if item == selectedRt then
                idx = i
                selectedTarg = item:getProperties().name
                break
            end
        end
    -- some other node has been selected so error out
    else
        showError("TurntableG Error!", "You have selected a node that can't be used, please select a render target node or a group with a render target in it.", true)
    end

    -- see if we could find the node
    if idx == -1 then showError("TurntableG Error!","Could not select a render target node!", true) end
   
    -- create a full copy of the project so that we don't modify the original project
    local copyScene = octane.nodegraph.createRootGraph("Project Copy")
    copyScene:copyFrom(octane.nodegraph.getRootGraph():getOwnedItems())
    local copies = getAllItems(copyScene)
    copyRt = copies[idx]
   
    local copyCam = copyRt:getInputNode(octane.P_CAMERA)

    -- Find all render targets
    local renderTargets = octane.nodegraph.getRootGraph():findNodes(octane.NT_RENDERTARGET)
    local renTargList = {}
    for i, item in ipairs(renderTargets) do
        -- renTargList[item:getProperties().name] = item
        renTargList[#renTargList + 1] = item:getProperties().name
    end

    return copyScene, copyRt, copyCam, renTargList, selectedTarg
end


Did some more testing on this, even when you select a render target node, I'm getting random nodes returned from the getSceneCopy() function. Sometimes it is lucky and it gets the correct node. Most of the time it gets some other random node. Very strange?

Thanks,

Jason


Hi Jason,

I think the issue is that you're trying to index copies with the index found by scanning allNodes. You're implicitly relying on the fact that the order of these tables is the same. I tested it and sometimes it is, sometimes it's not. That's why you get these strange errors.

It all boils down to finding the copy of the selected render target and this is a bit tricky. I'll think about it some more, maybe we can simplify it somehow.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand
PreviousNext

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 2 guests

Tue Apr 16, 2024 10:23 pm [ UTC ]