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