animating over time into a python script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there, so here's a script adding noise to a 3d object,
and I'm curious to know if its possible to have the noise animated over time?
(I was thinking of multiplying a sin function by time however cannot figure out the way to do it in python)
#add noise to a mesh
import maya.cmds as mc
import random
def addNoise(amt):
selectedObjs = mc.ls(selection=True)
obj = selectedObjs[-1]
numVerts = mc.polyEvaluate(obj, vertex=True)
randAmt = [0, 0, 0]
for i in range(0, numVerts):
for j in range(0, 3):
randAmt[j] = random.random() * (amt*2) - amt
vertexStr = "{0}.vtx[{1}]".format(obj, i)
mc.select(vertexStr, replace=True)
mc.move(randAmt[0], randAmt[1], randAmt[2], relative=True)
mc.select(obj, replace=True)
addNoise (0.05)