Average BlendShape

Download averageBs.py

python, pyfuncs, maya

I had fun to create this script to handle the tree's growth for the Voobox movie I did, working with blendshapes and a large amound of Maya's Average Vertices, to simulate the growth, like that ;

 ⚭ flooding Average Vertice

Which can be associated with a Grow Selection, but result can be .. unpredictable !
Then, connecting the whole thing to a blendShape we get ;

Here is a (simple) example of using the code :

1
averageFlood(cmds.ls(sl=True))

Full code here ;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def averageFlood(selection, iter=2, subiter=10):
    """
    This function apply the polyAverageVertex function a lot of
    time, so you can simulate something growing easily
    :param  selection : the vertices' selection you want to wrap
    :param       iter : the number of iteration, can be useful to
                        max the value when using on a lot of vtx
    """
    import maya.mel as mel
    import maya.cmds as cmds
    # simple flood
    def flood(s):
        cmds.select(s)
        for i in range(subiter):
            cmds.polyAverageVertex(s)
      
    # we get the object name
    o = selection[0].split('.')[0]

    for i in range(iter):
        flood(selection)
        cmds.select(o)
        mel.eval('DeleteHistory;')
    cmds.select(selection)

If you have any questions... =)