Urgent help!

Forums: Urgent help!
Forum for OctaneRender Lua scripting examples, discussion and support.

Urgent help!

Postby gardeler » Fri Dec 13, 2013 2:54 pm

gardeler Fri Dec 13, 2013 2:54 pm
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!

Thanks

Martin
gardeler
Licensed Customer
Licensed Customer
 
Posts: 121
Joined: Fri Feb 22, 2013 5:10 pm

Re: Urgent help!

Postby stratified » Fri Dec 13, 2013 10:45 pm

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

You could read up on scripting in this excellent online book http://www.lua.org/pil/contents.html. 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
octane.project.load("/home/thomas/Documents/octane-scenes/cube-test.ocs")

NB_FRAMES = 5
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
NB_FRAMES = 10
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)
end


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.

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

Re: Urgent help!

Postby arh-osa » Sat Dec 14, 2013 10:33 pm

arh-osa Sat Dec 14, 2013 10:33 pm
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.
SketchUp Pro 8/ Maya 2012 / W7 64bit / Intel i7 870 / 8GB / 2*GeForce gtx 680 4GB
arh-osa
Licensed Customer
Licensed Customer
 
Posts: 41
Joined: Sun Jun 03, 2012 11:07 am
Location: Russia

Re: Urgent help!

Postby Tugpsx » Sun Dec 15, 2013 2:41 am

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

Functions

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.

Properties

octane.file.PROPS_SPECIAL_DIRECTORIES Table with the absolute path's to special directories on the user's system
Dell Win Vista 32 | NVIDIA Quadro NVS135M | Core2 Duo T7500 2.20GHz | 4GB
CyberPowerPC Win 7 64| NVIDIA GTX660Ti (3G) GTX480(1.5G) | 16GB
Tugpsx
Licensed Customer
Licensed Customer
 
Posts: 1058
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL

Re: Urgent help!

Postby stratified » Sun Dec 15, 2013 4:47 am

stratified Sun Dec 15, 2013 4:47 am
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.

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

Re: Urgent help!

Postby arh-osa » Wed Dec 18, 2013 12:01 am

arh-osa Wed Dec 18, 2013 12:01 am
Thank you! It would be a very useful thing :roll:
SketchUp Pro 8/ Maya 2012 / W7 64bit / Intel i7 870 / 8GB / 2*GeForce gtx 680 4GB
arh-osa
Licensed Customer
Licensed Customer
 
Posts: 41
Joined: Sun Jun 03, 2012 11:07 am
Location: Russia

Re: Urgent help!

Postby stratified » Wed Dec 18, 2013 12:04 am

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

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

Re: Urgent help!

Postby faruk » Thu Apr 09, 2015 2:48 pm

faruk Thu Apr 09, 2015 2:48 pm
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,

Faruk
faruk
Licensed Customer
Licensed Customer
 
Posts: 1
Joined: Tue Mar 17, 2015 3:40 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Sat Oct 19, 2019 4:17 am [ UTC ]