[Closed] Smooth motion script
So, I’ve made this script that smooths out an object’s motion.
It works great, and was something I’ve been missing for years.
There’s just one issue, it doesn’t work with network rendering, which basically makes it unusable for me. The render machines open up the file and go to the correct frame, but they never start rendering.
My current hypothesis is that it’s because the script looks forward and backward in time, but I may be wrong.
If anyone wants to have a crack at finding what’s wrong I would be very grateful.
This script would be very useful, if only it worked with network rendering.
For anyone who wants to try it; select any object with a linear animation applied to it. This script will add a position script controller with a few values controlled by spinners in an attribute holder modifier placed on the same object.
Show motion paths to better see what’s happening.
try destroyDialog SmoothAnim catch()
rollout smoothAnim "SmoothAnim" width:85 height:24
(
button 'smoothA' "Smooth/remove" pos:[0,0] width:85 height:24 align:#left
on smoothA pressed do (
if($.modifiers[#SmoothAnim]!=undefined) then (
deleteModifier $ ($.modifiers[#SmoothAnim])
$.pos.controller=copy $.controller[1].Position_XYZ
)else(
animstate=0
if animButtonState==1 then (
animstate=1
set animate off
)
obj = $
em = emptymodifier()
em.name = "SmoothAnim"
global smoothsettings = attributes smoothValues (
parameters main rollout:settings (
smoothness type:#float ui:smoothspin default:10
bias type:#float ui:biasspin default:0
samples type:#integer ui:samplesspin default:8
)
rollout settings "SmoothAnim" (
spinner smoothspin "Smoothness" range:[0, 100, 10] type:#float
spinner biasspin "Bias" range:[-20, 20, 0] type:#float
spinner samplesspin "Samples" range:[1, 20, 0] type:#integer
)
)
custAttributes.add em smoothsettings
addmodifier obj em
em.smoothValues.smoothness.controller = bezier_float()
em.smoothValues.bias.controller = bezier_float()
em.smoothValues.samples.controller = bezier_float()
pl=Position_List()
ps=Position_Script()
$.pos.controller = pl
$.pos.controller.Available.controller = ps
ps.addTarget "smoothness" $.modifiers[#SmoothAnim].smoothValues.smoothness.controller
ps.addTarget "bias" $.modifiers[#SmoothAnim].smoothValues.bias.controller
ps.addTarget "samples" $.modifiers[#SmoothAnim].smoothValues.samples.controller
ps.addNode "thisobj" $
ps.setExpression("outpos=0
outpos=at time (F+bias) thisobj.controller[1].Position_XYZ.Pos
for i=1 to samples do (
outpos+=at time (( F - ((smoothness)/samples)*i)+bias) thisobj.controller[1].Position_XYZ.Pos
outpos+=at time (( F + ((smoothness)/samples)*i)+bias) thisobj.controller[1].Position_XYZ.Pos
)
outpos/=(samples*2+1)
outpos"
)
$.pos.controller.weight[1] = 0
$.pos.controller.setActive 1
if animstate==1 then (
set animate on
)
)
)
)
createdialog SmoothAnim style:#(#style_toolwindow, #style_sysmenu)