Page 2 of 2

Re: Scripted node stuff

PostPosted: Sun Dec 07, 2014 11:31 pm
by grimm
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

Re: Scripted node stuff

PostPosted: Mon Dec 08, 2014 1:12 am
by grimm
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

Re: Scripted node stuff

PostPosted: Mon Dec 08, 2014 1:40 am
by stratified
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

Re: Scripted node stuff

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

Jason

Re: Scripted node stuff

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


Thanks again,

Jason

Re: Scripted node stuff

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

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

cheers,
Thomas

Re: Scripted node stuff

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

anim_texture.lua
(2.15 KiB) Downloaded 308 times

Re: Scripted node stuff

PostPosted: Mon Dec 08, 2014 2:14 am
by stratified
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

Re: Scripted node stuff

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

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

Jason