by markchang » Wed Jun 07, 2017 8:41 am
import proxy
import numpy as np
import events3d
human = G.app.selectedHuman
mhclofile = u'data/clothes/male_casualsuit01/male_casualsuit01.mhpxy'
pxy = proxy.loadProxy(human, mhclofile, type='Clothes')
mesh,obj = pxy.loadMeshAndObject(human)
mesh.setPickable(True)
gui3d.app.addObject(obj)
mesh2 = obj.getSeedMesh()
fit_to_posed = False
pxy.update(mesh2, fit_to_posed)
mesh2.update()
obj.setSubdivided(human.isSubdivided())
human.addClothesProxy(pxy)
vertsMask = np.ones(human.meshData.getVertexCount(), dtype=bool)
proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, pxy)
# Apply accumulated mask from previous clothes layers on this clothing piece
obj.changeVertexMask(proxyVertMask)
if pxy.deleteVerts is not None and len(pxy.deleteVerts > 0):
log.debug("Loaded %s deleted verts (%s faces) from %s proxy.", np.count_nonzero(pxy.deleteVerts), len(human.meshData.getFacesForVertices(np.argwhere(pxy.deleteVerts)[...,0])),pxy.name)
# Modify accumulated (basemesh) verts mask
verts = np.argwhere(pxy.deleteVerts)[...,0]
vertsMask[verts] = False
human.changeVertexMask(vertsMask)
event = events3d.HumanEvent(human, 'proxy')
event.pxy = 'clothes'
human.callEvent('onChanged', event)