Point-based animation applied while rendering

41 views
Skip to first unread message

Nicolas Castagne

unread,
Jul 11, 2014, 4:33:31 AM7/11/14
to python_in...@googlegroups.com

Dear all,

I am new to this group, and somewhat new to Maya, and I am looking for directions to start a new Maya Python script.

On the one side, I have large files encoding the sampled movement of a large number of 3D points.
These movements can be parsed using Python - no problem here.

My goal is to let these "moving 3D points" control various Maya objects (points, locaters, clusters, nurbs's control points, polygons, etc).

I know that, for each of the moving points, I could attach a keyframe to a node, and pre-load all the movement as keyframes.

However, since I am not interested in keyframes, I would like to set up a system that, while runing the Maya animation, on each frame :
- reads the current points' positions in the file
- applies the new position to the Maya scene (eg move chosen "points", eg locators, in the Maya scene)
- then, and only then, starts the frame's rendering pipeline

Hence, to some extend, I would need to "hook" into Maya's in-time loop.

Since I am very new to Maya-Python, I hardly figure out where to start.

Would you have any advice, examples, or entries in the API ?


Thank you very much in advance,
Nicolas & team

Manuel Macha

unread,
Jul 11, 2014, 5:25:45 AM7/11/14
to python_in...@googlegroups.com
It seems to me that what you describe as Maya's 'in-time' loop could be achieved using expressions.
Have a look at Maya's-Online help for expressions and see if you can make sense of it.



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7bcc7658-e131-4477-9504-692c0b9c6aed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Jul 11, 2014, 5:33:45 AM7/11/14
to python_in...@googlegroups.com

Hi Nicolas, and welcome.

Have a look at the script node. It’ll let you run Python on a per-frame basis and you should be able to apply your data from there.
http://download.autodesk.com/global/docs/maya2013/en_us/Nodes/script.html

It does however sound quite taxing from a performance perspective and for that you might be better off writing a plug-in in either C++ or C#




For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Message has been deleted

Nicolas Castagne

unread,
Jul 28, 2014, 9:25:45 AM7/28/14
to python_in...@googlegroups.com
Hello all,

Thanks for your answers Manuel and Marcus.

The notion of "Script Node" is apparently very appropriate, with a "on software frame render" setting.
Thank you Marcus.


However, it raises two question we could not solve so far.

First question :
Is it possible to pass a Python variable to a Script Node ?
My idea is :
   1/ open my motion file BEFORE launching Maya's loop (parse the file header, check a series of things, etc)
   2/ pass a File object to the script node, so that on each Maya frame the corresponding data are read in the file.
However, I then need to let my scipt node access the File variable...

More generally, I think there is probably a mean to let a script node access parameters (Python variables, etc). But which is it ?


Second question :
Apparently, a "script nodes" deletes itself when executed. Well... This sound a bit strange to me... Is there a mean to let a "on software frame render" script node be permanent, and be executed on each frame ?


Thank you very much for your upcoming answers,
best-

Nicolas (& colleagues)

Nicolas Castagne

unread,
Jul 28, 2014, 11:59:34 AM7/28/14
to python_in...@googlegroups.com
Auto-answer to my own message : I got time to look arround myself and got some success.


Execute the following Maya script :

testVar=5
cmds.scriptNode( n='test script node R', bs='print "current time is %f" %maya.cmds.currentTime(q=1); print "value of testVar : %i" %testVar;', st=7, stp='python' )

Note that the "st" flag is 7 => "Execute on time changed"



Then play the animation. 
It outputs :

current time is 1.000000
value of testVar : 5
current time is 2.000000
value of testVar : 5

... and so forth.


Rational : 
1/ python script node has access to the interpreter's global variables
2/ when set as "Execute on time changed", a script node is not auto-deleted once executed.

just the behaviour we were looking for.

Nicolas Castagne

unread,
Jul 28, 2014, 12:05:12 PM7/28/14
to python_in...@googlegroups.com
Yet another small new question...

Is there a mean to pass a value to a Python script node (as we pass a value to a function) ?

Thanks,
Nicolas
Reply all
Reply to author
Forward
0 new messages