Message 1 of 5
Get deltas between two anim curves?

Not applicable
02-24-2018
10:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'm wondering if there's a quick way to get the "delta" animation curve between two anim curves using OpenMaya.
As of now, I'm just going through each frame and subtracting the values from one to the other and storing the difference as a vector.
My goal is to be able to nullify all but the "jiggle" from a particle dynamics simulation so that can be used as an additive animation layer instead of override.
Thanks,
Ben
Here's what I have so far:
import maya.cmds as cmds import maya.OpenMaya as om def translation_dynamics(cc=None,stiffness=1.5): if not cc: return start_time = cmds.playbackOptions(q=1,min=1) end_time = cmds.playbackOptions(q=1,max=1) cmds.currentTime(start_time) cc_loc = cmds.spaceLocator()[0] cmds.matchTransform(cc_loc,cc) cmds.parent(cc_loc,cc,a=1) cc_pos = cmds.xform(cc,q=1,t=1,ws=1) n_particle = cmds.nParticle(p=cc_pos,c=1) particle_shape = cmds.pickWalk(n_particle,d="down")[0] cmds.goal(n_particle,g=cc_loc) particle_loc = cmds.spaceLocator()[0] cmds.matchTransform(cc_loc,cc) cmds.connectAttr(particle_shape + ".worldCentroid",particle_loc + ".t") # a low dynamics weight will make the particle end closer to the cc cmds.setAttr(particle_shape + ".dynamicsWeight",.001) cmds.setAttr(particle_shape + ".damp",.001) cmds.setAttr(particle_shape + ".goalSmoothness",stiffness) # bake simulation on particle_loc cmds.bakeResults(particle_loc,t=(start_time,end_time),simulation=1) cmds.delete(cmds.pickWalk(n_particle,d="right")[0],n_particle,cc_loc) # make anim layer cmds.select(cc) lyr = cmds.animLayer(cc + "_tDynamics",addSelectedObjects=1,override=1) # TODO: make the translation additive instead of override. # will need to calculate the translational vectors for each frame cmds.pointConstraint(particle_loc,cc,mo=1,layer=lyr) cmds.bakeResults(cc,t=(start_time,end_time),simulation=1,dl=lyr) cmds.delete(particle_loc) translation_dynamics(cc=cmds.ls(sl=1)[0])