Scripted node stuff

Forums: Scripted node stuff
Forum for OctaneRender Lua scripting examples, discussion and support.

Re: Scripted node stuff

Postby grimm » Sun Dec 07, 2014 11:31 pm

grimm Sun Dec 07, 2014 11:31 pm
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 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: Scripted node stuff

Postby grimm » Mon Dec 08, 2014 1:12 am

grimm Mon Dec 08, 2014 1:12 am
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 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: Scripted node stuff

Postby stratified » Mon Dec 08, 2014 1:40 am

stratified Mon Dec 08, 2014 1:40 am
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
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Scripted node stuff

Postby grimm » Mon Dec 08, 2014 1:43 am

grimm Mon Dec 08, 2014 1:43 am
Cool, thanks, I will do that. :)

Jason
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: Scripted node stuff

Postby grimm » Mon Dec 08, 2014 1:54 am

grimm Mon Dec 08, 2014 1:54 am
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 308 times


Thanks again,

Jason
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: Scripted node stuff

Postby stratified » Mon Dec 08, 2014 2:06 am

stratified Mon Dec 08, 2014 2:06 am
Hey Jason,

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

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

Re: Scripted node stuff

Postby grimm » Mon Dec 08, 2014 2:08 am

grimm Mon Dec 08, 2014 2:08 am
Here you go:

anim_texture.lua
(2.15 KiB) Downloaded 308 times
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: Scripted node stuff

Postby stratified » Mon Dec 08, 2014 2:14 am

stratified Mon Dec 08, 2014 2:14 am
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
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Scripted node stuff

Postby grimm » Mon Dec 08, 2014 2:21 am

grimm Mon Dec 08, 2014 2:21 am
*AAARG!* Thanks Thomas,

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

Jason
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
Previous

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 10 guests

Fri Apr 19, 2024 3:42 am [ UTC ]