Scripted node stuff

Forum for OctaneRender Lua scripting examples, discussion and support.
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

stratified wrote:Hi Jason,

I think you're getting confused by the rounding errors:

Code: Select all

****Event Started****
Scrubber Time - 0.03999999910593
I think this is frame # 0
The time in Octane is represented in floating point. For example if you have 25 fps, the frame duration is 0.04 seconds. In floating point this is represented as 0.03999... . If you then use math.floor(currentTime / frameTime), you will always underestimate the frame number. What you should do is have an epsilon and if you're close enough to the integer, clamp it to the integer. I know it's subtle but there's not much we can do here.
Yarg, fp errors are a pita! Thanks Thomas.
stratified wrote: It is operating in it's own graph. The turntable animation script takes a copy of the root graph of the project but not of the project itself. But octane.project.getSceneGraph() will always return the root graph of the original project. You can get around this by getting the parent graph of the scripted graph which is always the correct one.
Cool I will try that. :)
stratified wrote: Accessing the project settings is the culprit here. I guess the best thing is to always fetch them during evaluation.

cheers,
Thomas
I will move that too for now, thanks again.

Jason
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

stratified wrote: It is operating in it's own graph. The turntable animation script takes a copy of the root graph of the project but not of the project itself. But octane.project.getSceneGraph() will always return the root graph of the original project. You can get around this by getting the parent graph of the scripted graph which is always the correct one.
Hi Thomas,

I can get the parent of the graph easily by doing:

Code: Select all

graph:getProperties().graphOwner
But for the life of me I can't get from there to getting the project properties so I can pull the number of frames per second?!?

I also modified my frame calculator function to this, works much better now: :D

Code: Select all

function getFrame(currentTime)
	local halfFrame = frameTime/2 -- Force fix rounding errors
	return math.floor((currentTime + halfFrame)/frameTime)
end
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

I just tested it and I'm afraid you can't access the project settings either during evaluation until we fixed our bug. As a workaround I would add an extra input pin that configures the frame rate. It's a hassle for the user but I don't see any other way to work around this problem.

cheers,
Thomas
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Cool, thanks, I will do that. :)

Jason
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Hey Thomas,

*sigh* :| Looks like it's something else than accessing the root graph properties at start up. I removed all the properties code when I was adding the other input pin and it still locks up Octane when it is loading the script node script.
script_node_test2.ocs
(34.78 KiB) Downloaded 339 times
Thanks again,

Jason
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Hey Jason,

I need to see your script that is referenced in the ocs (anim_texture.lua).

cheers,
Thomas
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Here you go:
anim_texture.lua
(2.15 KiB) Downloaded 338 times
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

grimm wrote:Here you go:
anim_texture.lua
You can't access the project settings either. Line 28 needs to go. You should have the user configure the fps.

cheers,
Thomas
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

*AAARG!* Thanks Thomas,

The bad lines of code have been thoroughly exercised. :roll: And it's working.

Jason
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
Post Reply

Return to “Lua Scripting”