Ejemplo n.º 1
0
def gen_pick_img(path, force, crop, auto_id, skip_lights, skip_shaders):
    img_path = "C:/work/ids/{0}.exr".format(FileSystem.name(path))
    exr_path = img_path.replace(".exr", ".objectId.exr")
    rgb_path = img_path.replace(".exr", "_rgb.png")
    ids_path = img_path.replace(".exr", "_ids.png")
    id_cache = img_path.replace(".exr", "_nodes.json")

    # reuse cached results

    if (not force) and FileSystem.valid(img_path):
        jconf = JsonConfig(id_cache)
        return exr_path, rgb_path, ids_path, dict(jconf)

    # render and extract existing ids

    from cgev.vray import sdk
    from cgev.vray import VRayScene

    sdk.enableFrameBuffer = True
    r = VRayScene(path, renderMode="production")
    token = r.renderIdPass(path=img_path, auto_id=auto_id, crop=crop,
                           skip_lights=skip_lights, skip_shaders=skip_shaders)
    r.release()

    # cache ids mapping

    jconf = JsonConfig(token[3])
    jconf.save(id_cache)

    return token
Ejemplo n.º 2
0
    for arg in sys.argv[1:]:
        if FileSystem.isPath(arg):
            path = arg
        elif arg in ["--force", "-f"]:
            force = True
        elif arg in ["--auto", "-a"]:
            auto_id = True
        elif arg in ["--lights", "-l"]:
            skip_lights = True
        elif arg in ["--shaders", "-s"]:
            skip_shaders = True
        elif arg in ["--crop", "-c"]:
            crop = [640, 480]

    if not FileSystem.valid(path):
        dbg("ERROR : invalid scene {0}", path)
        sys.exit(1)

    exr, rgb, png, ids = gen_pick_img(path, force, crop,
                                      auto_id, skip_lights, skip_shaders)

    if ids:
        tmp = generate_object_colors(max(ids.values()))
        mapping = dict()
        for k, v in tmp.iteritems():
            mapping[v] = k
    else:
        mapping = dict()

    app = QtGui.QApplication.instance()