Page 1 of 1

Urgent help!

PostPosted: Fri Dec 13, 2013 2:54 pm
by gardeler
Trying to render an animation out but have no scripting experience.

I would like to set a start and end. number of samples and write path. (the usual stuff)

I can't find out how to set time on the time slider, so I can make it step forward? Please help!



Re: Urgent help!

PostPosted: Fri Dec 13, 2013 10:45 pm
by stratified
Hi Martin,

You could read up on scripting in this excellent online book We assume here on the scripting forum some Lua knowledge.

I haven't found the time yet to write a tutorial scripting animations in Lua. Trying to render an animation is a bit generic, could you specify more what you're trying to animate?

Here's a little example that zooms out the camera:

Code: Select all
-- load project to render

SAVE_DIR  = "/tmp"

-- fetch the render target, assume the project has a render target
rtNode = octane.nodegraph.getRootGraph():findFirstNode(octane.NT_RENDERTARGET)
if rtNode == nil then error("no render target found") end

-- fetch the camera position node
camPos = rtNode:getConnectedNode(octane.P_CAMERA):getConnectedNode(octane.P_POSITION)

-- set up an animator on the camera position. this will go from time 0 -> 1
-- and will zoom out the camera
camPos:setAnimator(octane.A_VALUE, { 0, 1 }, { { 5, 5, 5 }, { 10, 10, 10 } }, 2)

-- render out 10 frames
for i=1,NB_FRAMES do
    print("render frame ", i)

    -- render out 100 pixels of the render target
    octane.render.start{ maxSamples=100, renderTargetNode=rtNode }

    -- save the rendered image to disk
    path = string.format("frame_%d.png", i)
    octane.render.saveImage(path, octane.render.imageType.PNG16)
    print("saved image ", path)

    -- update the time on the root graph
    octane.nodegraph:getRootGraph():updateTime(i * ( 1 / NB_FRAMES), true)

The takeaway here is that you define an animator on the camera position (the value attribute of the position float node). In a loop we render each frame, save the frame to disk and update the time on the root graph (scene graph) before we render the next frame.

I know I'm just throwing some code at you right now but I'm a bit time pressed Today. I'll try to make some time to write up an animation tutorial next week.


Re: Urgent help!

PostPosted: Sat Dec 14, 2013 10:33 pm
by arh-osa
Hi Thomas!
How to get info about currently open project (filename, path, etc.)?
I'd like to use it in output names, but can't find it in API Browser.

Re: Urgent help!

PostPosted: Sun Dec 15, 2013 2:41 am
by Tugpsx
How about these, use one of his earlier scripts to export all api options in HTMLformat and you will see in these 2 sections


octane.file.checkPathExists Checks if an absolute path exists on the system.
octane.file.checksum Calculates a checksum based on the file's contents.
octane.file.getFileExtension Returns the extension. (e.g. /foo/bar.txt would return .txt)
octane.file.getFileName Returns the last section of a path name. (e.g. /foo/bar.txt would return bar.txt and /foo/bar would return bar.
octane.file.getFileNameWithoutExtenstion Returns the last part of the filename, without the extension. (e.g. /foo/bar.txt returns bar.
octane.file.getParentDirectory Returns the directory that contains this file or dir.
octane.file.getSpecialDirectories Returns a table with full path's to common directories on the user's system.


octane.file.PROPS_SPECIAL_DIRECTORIES Table with the absolute path's to special directories on the user's system

Re: Urgent help!

PostPosted: Sun Dec 15, 2013 4:47 am
by stratified
hi there,

you can indeed use the file API if you already have the path for the project file.

However, there's no way to query the path of the current project. We'll add a function to query the current project path. Something like octane.project.getCurrentProject() which would return the full path to the current project.


Re: Urgent help!

PostPosted: Wed Dec 18, 2013 12:01 am
by arh-osa
Thank you! It would be a very useful thing :roll:

Re: Urgent help!

PostPosted: Wed Dec 18, 2013 12:04 am
by stratified
this will be in the next 1.23 release candidate.


Re: Urgent help!

PostPosted: Thu Apr 09, 2015 2:48 pm
by faruk
Dear Thomas,

I have tried to read this Lua book, but I can't figure out how to apply anything to octane. All I want to make is a node that says something like this: for frame 1 to 100 animate value from 1 to 10 and to have it drive animation of a texture parameter like turbulence, or anything that needs an animated input.

Can you please help me with this?

All the best,