コード例 #1
0
ファイル: projection.py プロジェクト: RuliLG/makehuman
def mapUVGL():
    """
    Project the UV map topology of the selected human mesh onto a texture.
    """

    mesh = gui3d.app.selectedHuman.mesh

    W = 2048
    H = 2048
    
    dstImg = mh.Texture(size=(W,H), components=3)

    log.debug("mapUVGL: begin setup")

    fuvs = mesh.index
    edges = np.array([fuvs, np.roll(fuvs, 1, axis=-1)]).transpose([1,2,0]).reshape((-1,2))
    del fuvs
    edges = np.where((edges[:,0] < edges[:,1])[:,None], edges, edges[:,::-1])
    ec = edges[:,0] + (edges[:,1] << 16)
    del edges
    ec = np.unique(ec)
    edges = np.array([ec & 0xFFFF, ec >> 16]).transpose()
    del ec

    log.debug("mapUVGL: begin render")

    coords = mesh.r_texco
    edges = np.ascontiguousarray(edges, dtype=np.uint32)

    dstImg = mh.renderSkin(dstImg, 2, coords, index = edges, clearColor = (0, 0, 0, 255))

    log.debug("mapUV: end render")

    return dstImg.convert(3)
コード例 #2
0
ファイル: projection.py プロジェクト: RuliLG/makehuman
def mapImageGL(srcImg, mesh, leftTop, rightBottom):
    log.debug("mapImageGL: 1")

    dstImg = gui3d.app.selectedHuman.meshData.object3d.textureTex

    dstW = dstImg.width
    dstH = dstImg.height

    left, top = leftTop
    right, bottom = rightBottom

    camera = getCamera(mesh)

    coords = mesh.r_texco

    texmat = gui3d.app.modelCamera.getConvertToScreenMatrix(mesh)
    texmat = matrix.scale((1/(right - left), 1/(top - bottom), 1)) * matrix.translate((-left, -bottom, 0)) * texmat
    texmat = np.asarray(texmat)

    texco = mesh.r_coord

    alpha = np.sum(mesh.r_vnorm * camera[None,:], axis=-1)
    alpha = np.maximum(alpha, 0)
    color = (np.array([0, 0, 0, 0])[None,...] + alpha[...,None]) * 255

    color = np.ascontiguousarray(color, dtype=np.uint8)
    texco = np.ascontiguousarray(texco, dtype=np.float32)

    result = mh.renderSkin(dstImg, mesh.vertsPerPrimitive, coords, index = mesh.index,
                           texture = srcImg, UVs = texco, textureMatrix = texmat,
                           color = color, clearColor = None)

    return result
コード例 #3
0
ファイル: projection.py プロジェクト: ihavenick/MakeHuman
def mapMask(dimensions = (1024, 1024)):
    """
    Create a texture map mask, for finding the texture map borders.
    """
    
    mesh = gui3d.app.selectedHuman.mesh
    return mh.renderSkin(dimensions, mesh.vertsPerPrimitive, mesh.r_texco,
                         index = mesh.index, clearColor = (0, 0, 0, 0))
コード例 #4
0
ファイル: projection.py プロジェクト: TeoTwawki/makehuman
def mapMask(dimensions = (1024, 1024), mesh = None):
    """
    Create a texture map mask, for finding the texture map borders.
    """
    if mh.hasRenderSkin():
        try:
            if mesh is None:
                mesh = G.app.selectedHuman.mesh
            return mh.renderSkin(dimensions, mesh.vertsPerPrimitive,
                                 mesh.r_texco, index = mesh.index,
                                 clearColor = (0, 0, 0, 0))
        except Exception, e:
            log.debug(e)
            log.debug("Hardware skin rendering failed, falling back to software render.")
            return mapMaskSoft(dimensions, mesh)
コード例 #5
0
def mapMask(dimensions = (1024, 1024), mesh = None):
    """
    Create a texture map mask, for finding the texture map borders.
    """
    if mh.hasRenderSkin():
        try:
            if mesh is None:
                mesh = G.app.selectedHuman.mesh
            return mh.renderSkin(dimensions, mesh.vertsPerPrimitive,
                                 mesh.r_texco, index = mesh.index,
                                 clearColor = (0, 0, 0, 0))
        except Exception, e:
            log.debug(e)
            log.debug("Hardware skin rendering failed, falling back to software render.")
            return mapMaskSoft(dimensions, mesh)
コード例 #6
0
ファイル: projection.py プロジェクト: hackerlank/testzatfits
def mapLightingGL(
        lightpos=(-10.99, 20.0, 20.0), mesh=None, res=(1024, 1024), border=1):
    """
    Create a lightmap for the selected human (hardware accelerated).
    """
    progress = Progress()(0)

    if mesh is None:
        mesh = G.app.selectedHuman.mesh

    W = res[0]
    H = res[1]

    delta = lightpos - mesh.coord
    ld = vnormalize(delta)
    del delta
    s = np.sum(ld * mesh.vnorm, axis=-1)
    del ld
    s = np.maximum(0, np.minimum(255, (s * 256))).astype(np.uint8)
    mesh.color[..., :3] = s[..., None]
    mesh.color[..., 3] = 255
    del s

    progress(0.1)
    mesh.markCoords(colr=True)
    mesh.update()

    coords = mesh.r_texco
    colors = mesh.r_color

    progress(0.2, 0.5)
    dstImg = mh.renderSkin((W, H),
                           mesh.vertsPerPrimitive,
                           coords,
                           index=mesh.index,
                           color=colors,
                           clearColor=(0, 0, 0, 0))

    progress(0.5, 0.99)
    dstImg = fixSeams(dstImg, mesh, border)

    mesh.setColor([255, 255, 255, 255])

    log.debug('mapLightingGL: %s', dstImg.data.shape)

    progress(1)
    return dstImg
コード例 #7
0
ファイル: projection.py プロジェクト: hackerlank/testzatfits
def mapUVGL():
    """
    Project the UV map topology of the selected human mesh onto a texture 
    (hardware accelerated).
    """
    progress = Progress()(0)

    if mesh is None:
        mesh = G.app.selectedHuman.mesh

    W = 2048
    H = 2048

    dstImg = mh.Texture(size=(W, H), components=3)

    log.debug("mapUVGL: begin setup")

    fuvs = mesh.index
    edges = np.array([fuvs, np.roll(fuvs, 1, axis=-1)]).transpose([1, 2,
                                                                   0]).reshape(
                                                                       (-1, 2))
    del fuvs
    edges = np.where((edges[:, 0] < edges[:, 1])[:, None], edges,
                     edges[:, ::-1])
    ec = edges[:, 0] + (edges[:, 1] << 16)
    del edges
    ec = np.unique(ec)
    edges = np.array([ec & 0xFFFF, ec >> 16]).transpose()
    del ec

    log.debug("mapUVGL: begin render")

    coords = mesh.r_texco
    edges = np.ascontiguousarray(edges, dtype=np.uint32)

    progress(0.6, 0.99)
    dstImg = mh.renderSkin(dstImg,
                           2,
                           coords,
                           index=edges,
                           clearColor=(0, 0, 0, 255))

    log.debug("mapUV: end render")
    progress(1)

    return dstImg.convert(3)
コード例 #8
0
ファイル: projection.py プロジェクト: hackerlank/testzatfits
def mapImageGL(srcImg, mesh, leftTop, rightBottom):
    progress = Progress()(0)
    log.debug("mapImageGL: 1")

    dstImg = G.app.selectedHuman.meshData.object3d.textureTex

    dstW = dstImg.width
    dstH = dstImg.height

    left, top = leftTop
    right, bottom = rightBottom

    camera = getCamera(mesh)

    coords = mesh.r_texco

    texmat = G.app.modelCamera.getConvertToScreenMatrix(mesh)
    texmat = matrix.scale(
        (1 / (right - left), 1 / (top - bottom), 1)) * matrix.translate(
            (-left, -bottom, 0)) * texmat
    texmat = np.asarray(texmat)

    texco = mesh.r_coord

    alpha = np.sum(mesh.r_vnorm * camera[None, :], axis=-1)
    alpha = np.maximum(alpha, 0)
    color = (np.array([0, 0, 0, 0])[None, ...] + alpha[..., None]) * 255

    color = np.ascontiguousarray(color, dtype=np.uint8)
    texco = np.ascontiguousarray(texco, dtype=np.float32)

    progress(0.5, 0.99)
    result = mh.renderSkin(dstImg,
                           mesh.vertsPerPrimitive,
                           coords,
                           index=mesh.index,
                           texture=srcImg,
                           UVs=texco,
                           textureMatrix=texmat,
                           color=color,
                           clearColor=None)

    progress(1)
    return result
コード例 #9
0
ファイル: projection.py プロジェクト: TeoTwawki/makehuman
def mapLightingGL(lightpos = (-10.99, 20.0, 20.0), mesh = None, res = (1024, 1024), border = 1):
    """
    Create a lightmap for the selected human (hardware accelerated).
    """
    progress = Progress() (0)

    if mesh is None:
        mesh = G.app.selectedHuman.mesh

    W = res[0]
    H = res[1]

    delta = lightpos - mesh.coord
    ld = vnormalize(delta)
    del delta
    s = np.sum(ld * mesh.vnorm, axis=-1)
    del ld
    s = np.maximum(0, np.minimum(255, (s * 256))).astype(np.uint8)
    mesh.color[...,:3] = s[...,None]
    mesh.color[...,3] = 255
    del s

    progress(0.1)
    mesh.markCoords(colr = True)
    mesh.update()

    coords = mesh.r_texco
    colors = mesh.r_color

    progress(0.2, 0.5)
    dstImg = mh.renderSkin((W, H), mesh.vertsPerPrimitive, coords, index = mesh.index,
                           color = colors, clearColor = (0, 0, 0, 0))

    progress(0.5, 0.99)
    dstImg = fixSeams(dstImg, mesh, border)

    mesh.setColor([255, 255, 255, 255])

    log.debug('mapLightingGL: %s', dstImg.data.shape)

    progress(1)
    return dstImg
コード例 #10
0
ファイル: projection.py プロジェクト: michelamorim/makehuman
def mapLightingGL():
    """
    Create a lightmap for the selected human.
    """

    mesh = gui3d.app.selectedHuman.mesh

    W = 1024
    H = 1024

    delta = (-10.99, 20.0, 20.0) - mesh.coord
    ld = vnorm(delta)
    del delta
    s = np.sum(ld * mesh.vnorm, axis=-1)
    del ld
    s = np.maximum(0, np.minimum(255, (s * 256))).astype(np.uint8)
    mesh.color[..., :3] = s[..., None]
    mesh.color[..., 3] = 255
    del s

    mesh.markCoords(colr=True)
    mesh.update()

    coords = mesh.r_texco
    colors = mesh.r_color

    dstImg = mh.renderSkin((W, H),
                           mesh.vertsPerPrimitive,
                           coords,
                           index=mesh.index,
                           color=colors,
                           clearColor=(0, 0, 0, 0))

    fixSeams(dstImg)

    mesh.setColor([255, 255, 255, 255])

    log.debug('mapLightingGL: %s', dstImg.data.shape)

    return dstImg
コード例 #11
0
ファイル: projection.py プロジェクト: RuliLG/makehuman
def mapLightingGL():
    """
    Create a lightmap for the selected human.
    """

    mesh = gui3d.app.selectedHuman.mesh

    W = 1024
    H = 1024

    delta = (-10.99, 20.0, 20.0) - mesh.coord
    ld = vnorm(delta)
    del delta
    s = np.sum(ld * mesh.vnorm, axis=-1)
    del ld
    s = np.maximum(0, np.minimum(255, (s * 256))).astype(np.uint8)
    mesh.color[...,:3] = s[...,None]
    mesh.color[...,3] = 255
    del s

    mesh.markCoords(colr = True)
    mesh.update()

    coords = mesh.r_texco
    colors = mesh.r_color

    dstImg = mh.renderSkin((W, H), mesh.vertsPerPrimitive, coords, index = mesh.index,
                           color = colors, clearColor = (0, 0, 0, 0))

    fixSeams(dstImg)

    mesh.setColor([255, 255, 255, 255])

    log.debug('mapLightingGL: %s', dstImg.data.shape)

    return dstImg