Ejemplo n.º 1
0
def main(data_path, radius=700, divisions=100, intensity=15, exposure=11.5):
    with open(data_path, "r") as f:
        data = json.load(f)

    sphere_name, _ = cmds.polySphere(radius=radius, sx=divisions, sy=divisions)
    # Flipping UVs and rotating to match default arnold dome light position
    cmds.select("{}.map[0:]".format(sphere_name))
    cmds.polyFlipUV(usePivot=True, pivotU=0.5, pivotV=0.5)
    cmds.setAttr("{}.rotateY".format(sphere_name), 86.4)

    for i in range(data["num_lights"]):
        bbox_points = data[str(i)]["bbox_points"]
        mid_point = data[str(i)]["mid_point"]
        tex_path = data[str(i)]["rect_tex"]

        bbox_world = [get_uv_position(sphere_name, i) for i in bbox_points]
        mid_pos = get_uv_position(sphere_name, mid_point)
        light = place_light(mid_pos, bbox_world)

        file_node = cmds.shadingNode("file", asTexture=True)
        cmds.setAttr("{}.fileTextureName".format(file_node),
                     tex_path,
                     type="string")

        light_shape = cmds.listRelatives(light)[0]
        cmds.connectAttr("{}.outColor".format(file_node),
                         "{}.color".format(light_shape))

        cmds.setAttr("{}.intensity".format(light_shape), intensity)
        cmds.setAttr("{}.exposure".format(light_shape), exposure)

    hdr_path = data["hdr"]
    light_dome = mutils.createLocator("aiSkyDomeLight", asLight=True)[1]
    light_dome_shape = cmds.listRelatives(light_dome)[0]
    hdr_file_node = cmds.shadingNode("file", asTexture=True)
    cmds.setAttr("{}.fileTextureName".format(hdr_file_node),
                 hdr_path,
                 type="string")
    cmds.connectAttr("{}.outColor".format(hdr_file_node),
                     "{}.color".format(light_dome_shape))

    cmds.delete(sphere_name)
Ejemplo n.º 2
0
    def mirror(cls, object, axis):
        if axis == "x":
            mirror_channel = '.scaleX'
        elif axis == "y":
            mirror_channel = '.scaleY'
        elif axis == "z":
            mirror_channel = '.scaleZ'

        # get info
        name = object.split("|")[-1]
        hierarchy = mc.listRelatives(object, fullPath=True) or [""]
        hierarchy_list = hierarchy[0].split("|")
        hierarchy_root = "|".join(hierarchy_list[:-2]) or "|"
        # do duplicate
        object_mirror = mc.duplicate(object, name=name + "_MIRROR")
        i_grp_temp = mc.group(empty=True, name="txMirrorer_temp")
        mc.parent(object_mirror[0], "txMirrorer_temp")
        # do mirroring
        mc.xform(i_grp_temp,
                 worldSpace=True,
                 scalePivot=[0, 0, 0],
                 rotatePivot=[0, 0, 0])
        mc.setAttr(i_grp_temp + mirror_channel, -1)
        # put the mirrored back to original hierarchy
        if hierarchy_root == "|":
            mc.parent(object_mirror[0], world=True)
        else:
            mc.parent(object_mirror[0], hierarchy_root)
        mc.delete(i_grp_temp)
        # do UV flip
        list_mirrored_mesh = mc.listRelatives(object_mirror[0],
                                              allDescendents=True,
                                              type="mesh",
                                              fullPath=True) or []
        if list_mirrored_mesh:
            for j in list_mirrored_mesh:
                mc.polyFlipUV(j)
        mc.select(object_mirror[0])
Ejemplo n.º 3
0
def polyFlipUV(*args, **kwargs):
    res = cmds.polyFlipUV(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
Ejemplo n.º 4
0
def flipUVsByWorld(*args):
    sel = cmds.ls(sl=True, fl=True)
    for obj in sel:
        cmds.polyFlipUV(obj, local=False)