Forum: Poser Python Scripting


Subject: Moving morphs between different figures

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


Cage posted Mon, 17 March 2008 at 3:31 PM

One thing that's not present right now is normals for vertices.  Easy enough to generate using Python code, anyway.

The mapping of the polys to tris is very useful! 

I'm wondering: can I do += with your unary operations?  As below:

def vertnorms(vpolys,pnorms):
    """
    [Spanki]
    normals of vertices, computed as the average of the face normals of the polygons which use each vertex
    returns a Numeric array
    """   
    vnorms = [Vector(0.0,0.0,0.0) for i in range(len(vpolys))]
    for vi in range(len(vpolys)):
        polys = vpolys[vi]       
        l = len(polys)       
        if l == 0: # In some unusual geometries, there may be vertices with no polygon associations - we try to skip these.  1/26/08
            print vi, l
            continue # If we don't skip these, we get a divide by zero crash error due to a bad mesh.
        for p in polys:           
            #vnorms[vi] = vnorms[vi]+pnorms[p] #Can we do += with Vector objects?  
            vnorms[vi] += pnorms[p]  # Can we do this???   
        for i in range(3):
            vnorms[vi] /= l       
        vnorms[vi] = ~vnorms[vi] #is this correct?
    return vnorms

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.