Notifications
Clear all

[Closed] Averaging keyframes?

Is there a script out there that will take a range of keyframes on a selected channel, say y rotation, and average their values over a user defined number of frames? Is this something someone could quickly write, or is it a big deal. I’m looking for something like the ‘Average’ tool in Combustions math operations dialogue.

Thanks

3 Replies

I believe something like this would work. This is for Y rotation:

 
controllerKeys = $.rotation.controller[2].keys 
keyValues = #() 
avg = 0.0 
for k in controllerKeys do ( 
  append keyValues k.value 
) 
for v in keyValues do ( 
  avg += v 
) 
avg = (avg / (keyValues.count as float)) 

Is this what you are looking for? Not sure how I’d apply this to a specific range.


fn sakAvgTest fMin fMax = (
controllerKeys = $.rotation.controller[2].keys 
keyValues = #() 
avg = 0.0 
for k in controllerKeys do ( 
  if (k.time > fMin AND k.time < fMax) then ( 
	append keyValues k.value 
  ) 
) 
for v in keyValues do ( 
  avg += v 
) 
avg = (avg / (keyValues.count as float)) 
) 

Okay, I think this works. It’s averaging key frame values though

Thats exactly what I needed! Thank you for taking to time to help me. I have motion capture data that was very noisy, and I needed a way of smoothing it out.

Stephen Lebed
Visual Effects Supervisor
Mechnology