Pro_Pack : Animation¶
ProPack animation module deals with the more complex animation functions such as the r9Anim format handling and animation re-director systems.
>>> # import statement for the module via the r9pro decompiler
>>> from Red9.pro_pack import r9pro
>>> r9pro.r9import('r9panim')
>>> import r9panim
This module is extensions to the main animation support through the Red9 StudioPack and requires the StudioPack codebase to run
Main Classes
AnimationStore ([parent]) |
|
AnimMap ([filterSettings, timerange]) |
New base class for the Red9 Animation Format - r9Anim This inherits most of it’s node handling directly from the DataMap class in Red9.core.Red9_PoseSaver making it incredibly flexible when it comes to mapping animation data between nodes and rigs. |
Anim_Redirect (*args, **kws) |
Utilises the AnimPointCloud to allow animation to be re-directed via guide and reference meshes. |
AnimPointCloud (nodes[, filterSettings, ...]) |
This relies heavily on the PosePointCloud base class. |
Anim_Transfer ([mrig]) |
main animation transfer class for bouncing data to and from fbx |
LimbMatchingUI (*args, **kws) |
Basic UI for the FK/IK matching used by metaData |
-
anim_redirect_ui
()¶ stub for the pro openUI call
-
class
AnimationUI
(parent=None)¶ Bases:
PySide.QtGui.QMainWindow
,Ui_MainWindow
-
timeWithinRange
(baseRange, testRange, mode, idtext='')¶ test for the range handling in the UI / AnimMap **kws
Parameters: - baseRange – [start,end] which we want to see if our testRange falls within
- testRange – [start,end] that we’re testing
- mode – ‘byRange_start’, ‘byRange_end’, ‘’ modifies the ranges sent to test, if * byRange_start - then we send [None,end] to test, ignoring the start and only testing if the end falls within bound * byRange_end - then we send [start,None] to test, ignoring the end and only testing if the start falls within bound <<<<<<< HEAD * byRange - we test that the testRange falls within both the baseRanges start and end times * byAll - we don’t test, we just pass everything through ======= * byall - we test that the testRange falls within both the baseRanges start and end times >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
- idtext – used only by the log.info call as a display hint
-
animMap_validate_preload
(mrig, filepath=None, infoDict=None, match='exact')¶ generic call that raises a user prompt, used by the Animation_Load UI to validate the internal AnimMap mRig type about to be loaded matches the given mRig class, if there’s a mismatch then raise a confirmDialog for the user to choose whether to abort of not.
this is a separate function so it can be used by multiple UI’s and not have to run through the AnimMap base code, verify before we hit the load calls ;)
Parameters: - mrig – mrig to test against
- filepath – if given we load that r9Anim Map to extract the infoDict
- infoDict – we may have already consumed this r9Anim file so we can pass the infoDict in directly to save loading that data again
- match – not implemented yet
TODO: add a test to see if the infoDict has timecode, else we bail the TC flag is set and warn!!
======= >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
animMap_validate_presave
(mrig)¶ generic call that raises a user prompt, used by the Animation_Save UI to validate that the mrig about to be saved is NOT on an active Binder, and therefore has no keys!
this is a separate function so it can be used by multiple UI’s and not have to run through the AnimMap base code, verify before we hit the load calls ;)
Parameters: mrig – mrig to test against
-
class
AnimationStore
(parent=None)¶ Bases:
PySide.QtGui.QMainWindow
,Ui_MainWindow
-
saveAnimMap
(*args)¶ main save wrapper for the animationUI
-
loadAnimMap
(*args)¶ main load wrapper for the animationUI
-
-
class
AnimMap
(filterSettings=None, timerange=(), *args, **kws)¶ Bases:
Red9.core.Red9_PoseSaver.DataMap
New base class for the Red9 Animation Format - r9Anim This inherits most of it’s node handling directly from the DataMap class in Red9.core.Red9_PoseSaver making it incredibly flexible when it comes to mapping animation data between nodes and rigs.
Like the PoseSaver this is capable of loading animation data relatively against a given node, allowing you to load libraries of animations one after another in different spaces to that which they were saved.
Vimeo example : https://vimeo.com/167872211
>>> from Red9.pro_pack import r9pro >>> r9pro.r9import('r9panim') >>> import r9panim >>> >>> dm=r9PAnim.AnimMap() >>> >>> # like the pose saver you can load in a given filterSettings object directly >>> dm.settings.read(os.path.join(r9Setup.red9Presets(),'Red9_DevRig.cfg')) >>> dm.settings.incRoots=True >>> >>># OR modify it on the fly in the class >>> dm.settings.metaData=True >>> dm.settings.nodeTypes=['nurbsCurve'] >>> >>> rootNode='Red9:Main_Ctr' >>> filepath='d:/test' >>> >>> # saving >>> dm.saveAnim(rootNode, filepath) >>> >>> # basic loading >>> dm.offset=20 >>> dm.loadAnim(rootNode, filepath) >>> >>> # load relative to a given startFrame >>> dm.loadAnim(rootNode, filepath, loadAsStored=False, loadFromFrm=20) >>> >>> # loading relative to a given node >>> dm.loadAnim(rootNode, filepath, loadAsStored=False, loadFromFrm=70, referenceNode=cmds.ls(sl=True)[0])
Note
like many of these more complex calls this is bound directly to the mRig all the same flags are supported and the behaviour is also extended by way of a postload handler, currently designed to restore exportLoops and audio data that are gathered in the format on save from mRig
>>> mrig=r9Meta.getMetaRigs()[0] >>> mrig.loadAnimation(filepath)
I’m not passing any data in terms of nodes here, We’ll deal with those in the PoseSave and PoseLoad calls. Leaves this open for expansion
Parameters: - filterSettings – specify a filterSettings object, or just use the settings that are bound to the class instance
- timerange – specify a timerange to process, else use the default Red9 behaviour
-
buildBlocks_fill
(nodes=None)¶ Main capture routines to build the DataMap, see the Red9.core.Red9_PoseSaver for more details here
-
saveAnim
(nodes, filepath=None, useFilter=True, timerange=(), storeThumbnail=False, force=False)¶ Save the animation out to an r9Anim file. Note that this currently stores JUST the animation data and doesn’t sample. It will however temporarily flatten animCurves to capture the collapsed effect of all.
Parameters: - nodes – if use filter is on this is the root of the systems to filter from, else it’s given nodes to process
- filepath – r9Anim file to load
- useFilter – do we process all children of this rig or just selected
- timerange – specific a timerange to store, else store all
- storeThumbnail – this will be an avi but currently it’s a pose thumbnail
- force – allow force write on a read only file
-
loadAnim
(*args, **kws)¶ Load a given r9Anim file, this is the same system as the r9Pose file system, all the base handling comes from the r9Pose.DataMap base class
Parameters: - nodes – if given load the data to only these. If given and filter=True this is the rootNode for the filter.
- filepath – file to load - if not given the pose is loaded from a cached instance on this class.
- useFilter – If the pose has an active Filter_Settings block and this is True then use the filter on the destination hierarchy.
- loadAsStored – load the anim data from the original time
- loadFromFrm – if not loadAsStored, load the animation data from a given frame by comparing the internal startFrm stored in the animMap with the given frame <<<<<<< HEAD
- loadFromTimecode – load against a given SMPTE timecode / frm binding, calculating the offset of the data to load against a given timecode reference. IF timecodeBinding isn’t set then we gather the reference timecode from the mRig’s internal data, else we use the timecode binding supplied
- timecodeBinding – (frm, str(‘00:00:00:00’)) Tuple where the first arg is the frame at which the second arg’s SMPTE timecode has been set as reference, basically we’re saying that the timecode at frm is x ======= >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
- referenceNode – reference node used as the offset Node for relative loading
- manageRanges – do we (0, 1, 2) = leave, extend or set the timeranges according to the anim data loaded
- manageFileName – if True and the current Maya scene has no filename other than a blank scene (ie freshly loaded rig) then we take the r9Anim’s filename and rename the Maya scene accordingly
- keyStatics – if True then we key everything in the data at startFrame so that all non-keyed and static attrs that are stored internally as a pose are keyed.
- blendRange – None or int : 1 is default. If an int is passed then we use this as the hold range for the data, setting a key at time=startFarme-blendRange to hold the current data before we load the new keys. Note that this also turns on the keyStatics to ensure the data is preserved
-
extractData_Export
(manageExport='byAll', sort=False)¶ Extract the key IDs for the exportLoops found in the r9Anim file, this passes through the manageExport code to match loop timings with the r9Anim offset/start and end ranges
Parameters: - manageExport – byAll, byRange_start, byRange_end, byRange uses the timeWithinRange call
- sort – sort the returned data by the endFrame in each loops data
-
extractData_Audio
(manageAudio='byAll', sort=False)¶ Extract the key IDs for the AudioNodes found in the r9Anim file, this passes through the manageExport code to match loop timings with the r9Anim offset/start and end ranges
Parameters: - manageExport – byAll, byRange_start, byRange_end, uses the timeWithinRange call
- sort – sort the returned data by the endFrame in each loops data
-
class
Anim_Redirect
(*args, **kws)¶ Bases:
object
Utilises the AnimPointCloud to allow animation to be re-directed via guide and reference meshes. This generates a spline based gyuide that you can edit to redirect animation around a scene and because it uses the pointCloud setups nothing is bound to the animation data itself
Vimeo demo: https://vimeo.com/126124902
-
classmethod
show
()¶
-
classmethod
-
class
AnimPointCloud
(nodes, filterSettings=None, meshes=None, time=(), *args, **kws)¶ Bases:
Red9.core.Red9_PoseSaver.PosePointCloud
This relies heavily on the PosePointCloud base class. This means we can hook directly into the renderMeshes variable to find the Geo for reference
Utilises the AnimPointCloud to allow animation to be re-directed via guide and reference meshes. This generates a spline based gyuide that you can edit to redirect animation around a scene and because it uses the pointCloud setups nothing is bound to the animation data itself
>>> from Red9.pro_pack import r9pro >>> r9pro.r9import('r9panim') >>> import r9panim >>> >>> ppt=r9proAnim.AnimPointCloud(nodes='MRig:Locomotion_Root_Ctrl') >>> ppt.settings.read('Red9_DevRig.cfg') >>> ppt.time=r9Anim.timeLineRangeGet() >>> >>> # build the cloud reference, select the point to use as root reference >>> ppt.build() >>> >>> # apply any offsets you may have made >>> ppt.apply()
Parameters: - nodes – nodes or the root node of the hierarchy to process
- filterSettings – specific filterSettings object to pass in, else we bind one to settings internally
- meshes – meshes used as reference Geo when constructing the pointCloud nodes
- time – timerange to process
-
syncdatafromCurrentInstance
()¶ upgrade the sync call to include anim specific data
-
generateVisualReference
()¶
-
generateAnimationReference
()¶ generate a spline track to represent the animation over time and add reference meshes for start and end frames
-
snapPosePntstoNodes
()¶ snap each pntCloud point to their respective Maya nodes over time. This call is used in the UI to ‘ReSync’ the anim cloud if you’ve modified the tracking point and need to sync the cloud to the modified track point
-
snapNodestoPosePnts
()¶ snap each MAYA node to it’s respective pntCloud point over time.
-
build
(rootReference=None, raw=False)¶ Main build call to generate the system
Parameters: - rootReference – the node used for the initial pivot location
- raw – Build the cloud system but do NOT snap the cloud to the animation data
-
apply
()¶ pull data back from the cloud and snap the animationData to track
-
class
Interpolation
¶ Bases:
object
Generate interpolation values :param str_value: attr value of first keyframe :param end_value: attr value of second keyframe
-
space
¶ Returns: return the value between str_value and end_value
-
easeinquad
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutquad
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutquad
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeincubic
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutcubic
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutcubic
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinquart
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutquart
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutquart
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinquint
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutquint
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutquint
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinback
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutback
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutback
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinelastic
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutelastic
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutelastic
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutbounce
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinbounce
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutbounce
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeIncirc
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutcirc
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutcirc
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinexpo
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutexpo
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutexpo
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinsine
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeoutsine
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
easeinoutsine
(factor)¶ Parameters: factor – factor = current key iteration / by the number of keys between str_value and end_value Returns: current animation value
-
-
class
Keyer
(animcurve=None, frame=None, direction=True, samples=1)¶ Bases:
object
-
getkeyframedata
(animcurve_frame)¶
-
goforward
¶
-
gobackward
¶
-
str_frame
¶
-
end_frame
¶
-
str_value
¶
-
end_value
¶
-
time
¶
-
future_keys
¶
-
getselectedkeys
()¶
-
iterselectedkeys
()¶
-
setkeysonselection
(interpolationtype)¶
-
setkeys
(interpolationtype)¶
-
-
class
Keyerui
(uifile='D:/Red9_Core/Red9_Core_Main/Red9/pro_pack\UI\uifiles\interpolationkeyer.ui', *args, **kwargs)¶ Bases:
Red9.pro_pack.UI.uibase.BaseUI
-
setdirection
()¶
-
setamples
()¶
-
-
class
Anim_Transfer
(mrig=None)¶ Bases:
object
main animation transfer class for bouncing data to and from fbx
-
get_mrig
()¶ Returns: first MetaRigs found in the scene
-
get_data_from_binder
(binder_hik=None)¶
-
get_data_from_mrig
(mrig=None)¶ propagate the data from the mRig
-
get_binder_joints
()¶ Returns: list of all joint names in binder skeleton
-
set_timerange_from_binder_joints
()¶ set scene timeranges using the animation ranges for binder joints animation
-
set_timerange_from_rig_ctrls
(timeline=False)¶ set the current timeranges from the extent of the animation found on the mRig controllers
<<<<<<< HEADParameters: timeline – set the Maya timeranges as well as the internal start/end data
-
delete_exportloops
()¶
<<<<<<< HEAD
delete all export loops currently connected to the mRigs ExportTag
=======delete all export loops in the export tag
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
delete_animation_on_binder_skeleton
()¶
<<<<<<< HEAD
delete all animation on binder skeleton
=======delete any animation on binder skeleton
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
add_export_loop
(loopname=None)¶
<<<<<<< HEAD
add an export loop to mRigs ExportTag, the timeranges for this are taken from the internal start and end frames setup during the transfer
Parameters: loopname – name for export loop add export loop to character export tag :param loopname: name for export loop
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
openbinderfile
(binderfile=None)¶
<<<<<<< HEAD
open a character binder file in current Maya session
=======open a character binder file in current Maya setion
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e<<<<<<< HEAD Parameters: bndfile – path to character binder file =======Bndfile: path to character binder file >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21eReturns: path to character binder file
-
scenebasename
¶
<<<<<<< HEAD
base name of the Maya scene less the extension
-
-
scenename
¶
<<<<<<< HEAD
current Maya sceneName
-
scenedir
¶
-
rigs_to_fbx
(mayafiles, prefix='', usecurrentscene=False)¶ wrap over multiple files for processing
-
rig_to_fbx
(startFrame=None, endFrame=None, filepath=None, prefix='', export=True)¶ from a given Red9 Puppet Rig output a clean FBX skeleton anim via a bound duplicated skeleton method
Parameters: - startFrame – start frame of the output
- endFrame – end frame of the output <<<<<<< HEAD
- filepath – filepath to write to
- prefix – simple prefix for the scenename on output
- export – the main export call to fbx, if this is False then we just prep the file for export, without calling the FBX output =======
- filepath – filepath to write
- prefix – simple prefix for the scenename on output
- export – the main export call to fbx, without this we just prep the file >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
bake_hi
(root)¶
<<<<<<< HEAD
simple bake hierarchy from a given root node, used to bake the data to the clean skeleton hierarchy that we ultimately output to FBX. This code also runs a filterCurve call on the baked data to reduce it’s footprint
=======bake hierarchy animation and filter sample the generated animation curves
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21eParameters: root – string: root node of the hierarchy
-
export_to_fbx
(node, filepath)¶
<<<<<<< HEAD
export a given node to fbx
=======export node to fbx :param node: string: name of node to be exported if node is a
root of a hierarchy, all hierarchy will be exported<<<<<<< HEAD Parameters: =======- node – string: name of node to be exported if node is a root of a hierarchy, all hierarchy will be exported
- filepath – string: file path to export to
Parameters: filepath – string: file path to export to >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
clean_joint_hi
(root)¶ Delete everything that is not a joint from a hierarchy and set display attrs of the joints to default values
Parameters: root – string: root joint of the hierarchy Returns: list : list of strings, names of deleted nodes from the hierarchy
-
fbx_to_binder
(fbxfiles, binderfile=None, usecurrentscene=False, bake=False, runFilter=True, useTakeData=False)¶
<<<<<<< HEAD
Main FBX > Binder call, (PRO_TO_BND) loads the FBX file in, loads the binder in, and transfers the data
=======Main FBX > Binder call, loads the FBX file in, loads the binder in, and transfers the data
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21eParameters: - fbxfiles – list of fbx files to transfer
- binderfile – BND binder file to use in the transfer
- usecurrentscene – if true use the current scene, which then expects a binder file to be already loaded
- bake – do we bake the results to the Red9 puppet and clean-up after our-selves? <<<<<<< HEAD
- runFilter – do we run the curve filter on the baked animation to try and optimise the results, removing static data etc =======
- runFilter – do we run the curve filter on the baked results to try and optimise the results, removing statics etc >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
- useTakeData – if True use the internal fbx take[1]’s timeSpan when setting the ranges
-
bakebinder
(runFilter=True)¶ generic call to bake the binder data down to the rig and clean-up
-
track_to_locator
(nodes=None, timerange=True)¶ for each nodes create a locator named accordingly and track it over the selected time
Parameters: - nodes – nodes to track, if not passed in them we use the selected objects
- timerange – do we track timerange or not, uses the same Red9 timerange handler as everything else
-
class
LimbMatchingUI
(*args, **kws)¶ Bases:
object
Basic UI for the FK/IK matching used by metaData
-
classmethod
show
()¶
-
classmethod
-
class
Fbx_To_Bnd_ui
(fbxfiles=None, parent=None)¶ Bases:
PySide.QtGui.QMainWindow
,Ui_mw_fbx_to_bnd
Main window for CI animation transfer from fbx to a rerd9 binder rig
-
buildpresets
()¶ populate the presets comboBox from the Project object if set
-
setuisettings
()¶ populate ui settings using SETTINGS data
-
setbinder
(browse=True, *args)¶ set the binder file from the browse button or the change of the preset combo
-
setusecurrentscene
()¶
-
setbake
()¶ manage the bake flag and warn about the r9Anim outputs
-
runfilter
()¶
-
setr9anim
()¶ set the r9Anim settings
-
setp4Managed
()¶ ui callback for perforce icaf management
-
setupLogFile
()¶ creates a log file for the anim transfer code
-
<<<<<<< HEAD
staticMetaObject
= <PySide.QtCore.QMetaObject object at 0x0000000012DA4048>¶
=======
staticMetaObject
= <PySide.QtCore.QMetaObject object at 0x0000000012FED9C8>¶ >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e-
writeToLog
(line)¶ func to call to write the supplied data to the log file. Closes it every time, because the batch can kill maya outright.
-
transfer
()¶ Main transfer wrap from the UI, including the export call
-