Exemple #1
0
def writeVertexGroups(fp, config, proxy):
    if proxy and proxy.weights:
        writeRigWeights(fp, proxy.weights)
        return

    if config.vertexWeights:
        if proxy:
            weights = mh2proxy.getProxyWeights(config.vertexWeights, proxy)
        else:
            weights = config.vertexWeights
        writeRigWeights(fp, weights)
    else:
        for file in config.vertexGroupFiles:
            copyVertexGroups(file, fp, proxy)

    #for path in config.customvertexgroups:
    #    print("    %s" % path)
    #    copyVertexGroups(path, fp, proxy)

    if config.cage and not (proxy and proxy.cage):
        fp.write("#if toggle&T_Cage\n")
        copyVertexGroups("cage", fp, proxy)
        fp.write("#endif\n")

    copyVertexGroups("leftright", fp, proxy)
    copyVertexGroups("tight-leftright", fp, proxy)
    copyVertexGroups("skirt-leftright", fp, proxy)
    return
Exemple #2
0
def writeVertexGroups(fp, config, proxy):                
    if proxy and proxy.weights:
        writeRigWeights(fp, proxy.weights)
        return

    if config.vertexWeights:
        if proxy:
            weights = mh2proxy.getProxyWeights(config.vertexWeights, proxy)
        else:
            weights = config.vertexWeights                    
        writeRigWeights(fp, weights)
    else:
        for file in config.vertexGroupFiles:
            copyVertexGroups(file, fp, proxy)
            
    #for path in config.customvertexgroups:
    #    print("    %s" % path)
    #    copyVertexGroups(path, fp, proxy)    

    if config.cage and not (proxy and proxy.cage):
        fp.write("#if toggle&T_Cage\n")
        copyVertexGroups("cage", fp, proxy)    
        fp.write("#endif\n")

    copyVertexGroups("leftright", fp, proxy)    
    copyVertexGroups("tight-leftright", fp, proxy)    
    copyVertexGroups("skirt-leftright", fp, proxy)    
    return
Exemple #3
0
def getProxyWeights(proxy, humanWeights, mesh):
    import mh2proxy

    # Zip vertex indices and weights
    rawWeights = {}
    for (key, val) in humanWeights.items():
        indxs, weights = val
        rawWeights[key] = zip(indxs, weights)
    vertexWeights = mh2proxy.getProxyWeights(rawWeights, proxy)

    # Unzip and normalize weights (and put them in np format)
    boneWeights = {}
    wtot = np.zeros(mesh.getVertexCount(), np.float32)
    for vgroup in vertexWeights.values():
        for vn,w in vgroup:
            wtot[vn] += w

    for bname,vgroup in vertexWeights.items():
        weights = np.zeros(len(vgroup), np.float32)
        verts = []
        n = 0
        for vn,w in vgroup:
            verts.append(vn)
            weights[n] = w/wtot[vn]
            n += 1
        boneWeights[bname] = (verts, weights)

    return boneWeights
def writeVertexGroups(fp, proxy):                
    if proxy and proxy.weights:
        mh2proxy.writeRigWeights(fp, proxy.weights)
        return
    fp.write("#if toggle&T_Armature\n")
    if the.VertexWeights:
        if proxy:
            weights = mh2proxy.getProxyWeights(the.VertexWeights, proxy)
        else:
            weights = the.VertexWeights                    
        mh2proxy.writeRigWeights(fp, weights)
    else:
        for file in the.VertexGroupFiles:
            copyVertGroups(file, fp, proxy)
            
    for path in the.Config.customvertexgroups:
        print("    %s" % path)
        copyVertGroups(path, fp, proxy)    

    if the.Config.cage and not (proxy and proxy.cage):
        fp.write("#if toggle&T_Cage\n")
        copyVertGroups("shared/mhx/templates/vertexgroups-cage25.mhx", fp, proxy)    
        fp.write("#endif\n")
    fp.write("#endif\n")
    copyVertGroups("shared/mhx/templates/vertexgroups-leftright25.mhx", fp, proxy)    
    copyVertGroups("shared/mhx/templates/vertexgroups-tight-leftright25.mhx", fp, proxy)    
    copyVertGroups("shared/mhx/templates/vertexgroups-skirt-leftright25.mhx", fp, proxy)    
    return
def getProxyWeights(proxy, humanWeights, mesh):
    import mh2proxy

    # Zip vertex indices and weights
    rawWeights = {}
    for (key, val) in humanWeights.items():
        indxs, weights = val
        rawWeights[key] = zip(indxs, weights)
    vertexWeights = mh2proxy.getProxyWeights(rawWeights, proxy)

    # Unzip and normalize weights (and put them in np format)
    boneWeights = {}
    wtot = np.zeros(mesh.getVertexCount(), np.float32)
    for vgroup in vertexWeights.values():
        for vn, w in vgroup:
            wtot[vn] += w

    for bname, vgroup in vertexWeights.items():
        weights = np.zeros(len(vgroup), np.float32)
        verts = []
        n = 0
        for vn, w in vgroup:
            verts.append(vn)
            weights[n] = w / wtot[vn]
            n += 1
        boneWeights[bname] = (verts, weights)

    return boneWeights