Forum: Poser Python Scripting


Subject: Moving morphs between different figures

Cage opened this issue on Dec 20, 2006 · 1232 posts


Spanki posted Tue, 18 March 2008 at 5:44 PM

Quote - Here's a quick test of the .pyd, doing shrinkwrapping. ...

I hadn't tested it yet, but here's a better version of vertnorms() for you...

def vertnorms(vpolys,pnorms):<br></br>
    """<br></br>
    [Spanki]<br></br>
    normals of vertices, computed as the average of
the face normals of the polygons which use each vertex<br></br>
    returns a Numeric array<br></br>
    """<br></br>
    vnorms = [Vector(0.0,0.0,0.0) for i in
range(len(vpolys))]<br></br>
    for vi in range(len(vpolys)):<br></br>
        polys = vpolys[vi]<br></br>
        numNorms =
len(polys)<br></br>
        if numNorms ==
0:           
# make sure we have some normals, so we...<br></br>
           
print vi, numNorms<br></br>
           
continue                
# ...don't divide by zero crash due to a bad mesh.<br></br>
        numNorms = 1.0 /
numNorms    # convert numNorms to inv_numNorms, so
we can multiply instead of divide<br></br>
        for p in polys:<br></br>
           
vnorms[vi] += pnorms[p]<br></br>
        vnorms[vi] =
~vnorms[vi].scale(numNorms) # get average (multiply by
inv_numNorms) and make into a unit vector<br></br>
    return vnorms<br></br>

...mostly, I just replaced the single-letter 'l' variable with 'numNorms' (for clarity) then inverted it, so we could multiply by it instead of dividing, then passed that to the vector.scale() method, normalizing the result.

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.