Ejemplo n.º 1
0
def Fond(Stre, Freq, Ampl, colors={222, 202, 163}):
    cmds.file(f=True, new=True)

    # Stre=cmds.floatSliderGrp(field_strenth,q=True,v=True)
    # Freq=cmds.floatSliderGrp(field_frequency,q=True,v=True)
    # Ampl=cmds.floatSliderGrp(field_amplitude,q=True,v=True)

    #---------Creation Objet--------#
    cmds.polyCube(w=20, d=20, h=8, sx=80, sz=80, name="roche")  #20 20 / 50
    cmds.polySphere(r=10, sa=60, sy=60, name="contenant")  #8 / 12
    cmds.move(0, 6.5, 0, "contenant")
    cmds.polyBoolOp('contenant', 'roche', op=3, n='fond')
    cmds.delete(ch=True)
    cmds.move(0, -4, 0, "fond")

    #---------Selection Face--------#
    for i in range(0, 1707):
        cmds.select("fond.f[" + str(i) + "]", add=True)
        sl = cmds.ls(sl=True)

    #---------Texture Deformer--------#

    td = cmds.textureDeformer(s=Stre, ps="World", name="Textu".format(sl))
    n = cmds.shadingNode("noise".format(sl), asTexture=True)

    #--------Attributre Noise-------#
    cmds.setAttr("noise1.threshold", 0.014)
    cmds.setAttr("noise1.amplitude", Ampl)
    cmds.setAttr("noise1.ratio", 0.15)
    cmds.setAttr("noise1.frequency", Freq)
    cmds.setAttr("noise1.falloff", 1)

    cmds.connectAttr(n + ".outColor", td[0] + ".texture", force=True)

    Color = cmds.shadingNode('aiStandardSurface', name="colo", asShader=True)
    cmds.setAttr("colo.specular", 0)
    cmds.setAttr(Color + ".baseColor", colors[0], colors[1], colors[2])

    cmds.select("fond", hi=True, add=True)
    cmds.hyperShade(assign=Color)


#cmds.window()
#cmds.columnLayout()
#sliderStrenght=cmds.floatSliderGrp(field=True,label="Strenth",minValue=0,maxValue=3,value=1.5,w=400)
#sliderFreq=cmds.floatSliderGrp(field=True,label="Frequency",minValue=0,maxValue=1,value=0.3,w=400)
#sliderAmplitude=cmds.floatSliderGrp(field=True,label="Amplitude",minValue=0,maxValue=1,value=0.4,w=400)

#cmds.button(label="Fond", c="Fond()")
#cmds.showWindow()
Ejemplo n.º 2
0
def textureDeformer(*args, **kwargs):
    res = cmds.textureDeformer(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
Ejemplo n.º 3
0
def dupe_live_geo(*args):
    """
	duplicates geo and adds the texture deformers to it
	"""

    sel = cmds.ls(sl=True, type="transform")
    for obj in sel:
        # dupeSpecial, input cons
        par = cmds.listRelatives(obj, p=True)
        if par:
            par = par[0]
        dupe = cmds.duplicate(obj, rr=True, ic=True)
        neon = cmds.rename(dupe, "{0}_neonGeo".format(obj))

        #glass
        cmds.select(obj, r=True)
        gtDef, gtXform = cmds.textureDeformer(
            strength=0.0,
            offset=0.0,
            vectorSpace="Object",
            direction="Normal",
            pointSpace="UV",
            name="{0}_textureDef".format(obj))
        gtextTrans = cmds.rename(gtXform, "{0}_glass_TextureDef".format(obj))
        cmds.setAttr("{0}.texture".format(gtDef), 1, 1, 1)

        # neon
        cmds.select(neon, r=True)
        tDef, tXform = cmds.textureDeformer(strength=0.02,
                                            offset=-0.05,
                                            vectorSpace="Object",
                                            direction="Normal",
                                            pointSpace="UV",
                                            name="{0}_textureDef".format(neon))
        textTrans = cmds.rename(tXform, "{0}_neon_TextureDef".format(obj))

        noiseText = cmds.shadingNode("fractal",
                                     asTexture=True,
                                     name="{0}_fractal".format(obj))
        noisePlace = cmds.shadingNode("place2dTexture",
                                      asUtility=True,
                                      name="{0}_factalPlace".format(obj))
        cmds.connectAttr("{0}.outUV".format(noisePlace),
                         "{0}.uv".format(noiseText))
        cmds.connectAttr("{0}.outUvFilterSize".format(noisePlace),
                         "{0}.uvFilterSize".format(noiseText))
        cmds.connectAttr("{0}.outColor".format(noiseText),
                         "{0}.texture".format(tDef),
                         force=True)

        # lightmesh
        lightmeshtmp = cmds.duplicate(obj, rr=True, ic=True)
        lightmesh = cmds.rename(lightmeshtmp, "{0}_lgtMeshGeo".format(obj))
        cmds.select(lightmesh, r=True)
        lmTDef, lmTxform = cmds.textureDeformer(
            offset=0.0,
            strength=0,
            vectorSpace="Object",
            direction="Normal",
            pointSpace="UV",
            name="{0}_textureDef".format(lightmesh))
        lmTextTrans = cmds.rename(lmTxform,
                                  "{0}_lightmesh_TextureDef".format(obj))
        cmds.setAttr("{0}.texture".format(lmTDef), 1, 1, 1)
        outerShpOrig = cmds.listRelatives(lightmesh, s=True, f=True)[0]
        outerShp = cmds.rename(outerShpOrig, "{0}_shape".format(lightmesh))
        outerShpAttrs = [
            "rsAOCaster", "rsSelfShadows", "rsShadowReceiver",
            "rsShadowCaster", "rsSecondaryRayVisible", "rsPrimaryRayVisible",
            "rsGiVisible", "rsCausticVisible", "rsGiCaster"
        ]
        for attr in outerShpAttrs:
            cmds.setAttr("{0}.rsEnableVisibilityOverrides".format(outerShp), 1)
            cmds.setAttr("{0}.{1}".format(outerShp, attr), 0)

        # make the red shift physical light and connect it to the outer geo. . . Set some init values on that
        lighttmp = mel.eval("redshiftCreateLight(\"RedshiftPhysicalLight\")")
        physLight = "{0}_meshlight".format(obj)
        physLight = cmds.rename(lighttmp, physLight)
        physLightShp = cmds.listRelatives(physLight, s=True)[0]
        # move light to camera
        rig.snapTo(lightmesh, physLight)
        if par:
            cmds.parent(physLight, par)
            cmds.parent(textTrans, par)
            cmds.parent(lmTextTrans, par)
            cmds.parent(gtextTrans, par)

        cmds.setAttr("{0}.v".format(physLight), 1)
        cmds.setAttr("{0}.t".format(physLight), 0, 0, 0)
        cmds.setAttr("{0}.r".format(physLight), 0, 0, 0)
        cmds.setAttr("{0}.s".format(physLight), 1, 1, 1)
Ejemplo n.º 4
0
def dupe_abc(*args):
    """
	creates a rig structure of the alembic objs with texture deformers added, etc and parents to camera
	"""
    cam = camera_check()
    if not cam:
        cmds.warning("no camera selected in window")

    sel = cmds.ls(sl=True)
    ctrlList = []

    rslight = cmds.checkBoxGrp(widgets["lightCBG"], q=True, v1=True)
    if rslight:
        rig.plugin_load("redshift4maya")

    tubes = [x for x in sel if not x.endswith("plane")]

    for geo in tubes:
        geoName = geo
        neon = cmds.duplicate(geo,
                              rr=True,
                              un=True,
                              name="{0}_neonInner".format(geo))[0]
        lightmesh = cmds.duplicate(geo,
                                   rr=True,
                                   un=True,
                                   name="{0}_lightOuter".format(geo))[0]
        geo = cmds.rename(geo, "{0}_glass".format(geo))

        ##### OUTER LIGHT
        cmds.select(lightmesh, r=True)
        lmTDef, lmTxform = cmds.textureDeformer(
            offset=0.0075,
            vectorSpace="Object",
            direction="Normal",
            pointSpace="UV",
            name="{0}_textureDef".format(lightmesh))
        lmTextTrans = cmds.rename(lmTxform,
                                  "{0}_lightmesh_TextureDef".format(geo))
        cmds.setAttr("{0}.texture".format(lmTDef), 1, 1, 1)
        outerShpOrig = cmds.listRelatives(lightmesh, s=True, f=True)[0]
        outerShp = cmds.rename(outerShpOrig, "{0}_shape".format(lightmesh))
        outerShpAttrs = [
            "rsAOCaster", "rsSelfShadows", "rsShadowReceiver",
            "rsShadowCaster", "rsSecondaryRayVisible", "rsPrimaryRayVisible",
            "rsGiVisible", "rsCausticVisible", "rsGiCaster"
        ]
        for attr in outerShpAttrs:
            cmds.setAttr("{0}.rsEnableVisibilityOverrides".format(outerShp), 1)
            cmds.setAttr("{0}.{1}".format(outerShp, attr), 0)

        ### GLASS
        cmds.select(geo)
        gTDef, gTxform = cmds.textureDeformer(
            offset=0.00,
            strength=0.00,
            vectorSpace="Object",
            direction="Normal",
            pointSpace="Local",
            name="{0}_textureDef".format(geo))
        gTextTrans = cmds.rename(gTxform, "{0}_glass_TextureDef".format(geo))
        cmds.setAttr("{0}.texture".format(gTDef), 1, 1, 1)

        #### NEON
        cmds.select(neon, r=True)
        nTDef, nTxform = cmds.textureDeformer(
            offset=-0.05,
            strength=0.02,
            vectorSpace="Object",
            direction="Normal",
            pointSpace="Local",
            name="{0}_textureDef".format(neon))
        nTextTrans = cmds.rename(nTxform, "{0}_neon_TextureDef".format(geo))
        innerShpOrig = cmds.listRelatives(neon, s=True, f=True)[0]
        innerShp = cmds.rename(innerShpOrig, "{0}_shape".format(neon))
        innerShpAttrs = ["rsShadowReceiver", "rsShadowCaster"]
        for attr in innerShpAttrs:
            cmds.setAttr("{0}.rsEnableVisibilityOverrides".format(innerShp), 1)
            cmds.setAttr("{0}.{1}".format(innerShp, attr))

        noiseText = cmds.shadingNode("fractal",
                                     asTexture=True,
                                     name="{0}_fractal".format(neon))
        noisePlace = cmds.shadingNode("place2dTexture",
                                      asUtility=True,
                                      name="{0}_factalPlace".format(neon))
        cmds.connectAttr("{0}.outUV".format(noisePlace),
                         "{0}.uv".format(noiseText))
        cmds.connectAttr("{0}.outUvFilterSize".format(noisePlace),
                         "{0}.uvFilterSize".format(noiseText))
        cmds.connectAttr("{0}.outColor".format(noiseText),
                         "{0}.texture".format(nTDef),
                         force=True)

        # light and finishing up
        if rslight:
            # make the red shift physical light and connect it to the outer geo. . . Set some init values on that
            lighttmp = mel.eval(
                "redshiftCreateLight(\"RedshiftPhysicalLight\")")
            physLight = "{0}_meshlight".format(geoName)
            physLight = cmds.rename(lighttmp, physLight)
            physLightShp = cmds.listRelatives(physLight, s=True)[0]
            # move light to camera
            rig.snapTo(lightmesh, physLight)
            cmds.setAttr("{0}.v".format(physLight), 0)
            # cmds.setAttr("{0}.areaShape".format(physLightShp), 4)
            # link the light with lightmesh (HOW THE HELL TO DO THIS?)

        # add controls to the main geo
        ctrl = rig.createControl(type="star",
                                 color="red",
                                 axis="y",
                                 name="{0}_CTRL".format(geoName))
        ctrlShp = cmds.listRelatives(ctrl, s=True)[0]
        rig.snapTo(cam, ctrl)
        objList = [lmTextTrans, nTextTrans, gTextTrans, neon, lightmesh, geo]
        if rslight:
            objList.append(physLight)
        cmds.parent(objList, ctrl)
        cmds.parent(ctrl, cam)
        cmds.setAttr("{0}.v".format(lightmesh), 0)

        cmds.addAttr(ctrl,
                     ln="thisCtrlVis",
                     at="short",
                     min=0,
                     max=1,
                     dv=0,
                     k=True)
        cmds.addAttr(ctrl,
                     ln="lightMeshTxStrength",
                     at="float",
                     min=0,
                     max=1.0,
                     dv=0.00,
                     k=True)
        cmds.addAttr(ctrl,
                     ln="neonTxStrength",
                     at="float",
                     min=0,
                     max=1.0,
                     dv=0.02,
                     k=True)
        cmds.addAttr(ctrl,
                     ln="glassTxStrength",
                     at="float",
                     min=0,
                     max=1.0,
                     dv=0.0,
                     k=True)
        cmds.addAttr(ctrl,
                     ln="lightMeshTxOffset",
                     at="float",
                     min=-1.0,
                     max=1.0,
                     dv=0.0075,
                     k=True)
        cmds.addAttr(ctrl,
                     ln="neonTxOffset",
                     at="float",
                     min=-1.0,
                     max=1.0,
                     dv=-0.03,
                     k=True)
        cmds.addAttr(ctrl,
                     ln="glassTxOffset",
                     at="float",
                     min=-1.0,
                     max=1.0,
                     dv=0.00,
                     k=True)

        cmds.connectAttr("{0}.thisCtrlVis".format(ctrl),
                         "{0}.visibility".format(ctrlShp))
        cmds.connectAttr("{0}.lightMeshTxStrength".format(ctrl),
                         "{0}.strength".format(lmTDef))
        cmds.connectAttr("{0}.neonTxStrength".format(ctrl),
                         "{0}.strength".format(nTDef))
        cmds.connectAttr("{0}.glassTxStrength".format(ctrl),
                         "{0}.strength".format(gTDef))
        cmds.connectAttr("{0}.lightMeshTxOffset".format(ctrl),
                         "{0}.offset".format(lmTDef))
        cmds.connectAttr("{0}.neonTxOffset".format(ctrl),
                         "{0}.offset".format(nTDef))
        cmds.connectAttr("{0}.glassTxOffset".format(ctrl),
                         "{0}.offset".format(gTDef))

        ctrlList.append(ctrl)

    cmds.select(ctrlList, r=True)
Ejemplo n.º 5
0
import os
import zTools.zbw_rig as rig
"""
select the control obj, then all the geo tubes and run
"""

sel = cmds.ls(sl=True)
ctrl = sel[0]
objs = sel[1:]
for obj in objs:
    par = cmds.listRelatives(obj, p=True)[0]

    cmds.select(obj, r=True)
    gTDef, gTxform = cmds.textureDeformer(offset=-0.00,
                                          strength=0.00,
                                          vectorSpace="Object",
                                          direction="Normal",
                                          pointSpace="UV",
                                          name="{0}_glass_textDef".format(obj))
    gTextTrans = cmds.rename(gTxform, "{0}_glass_TextureDef".format(obj))
    cmds.setAttr("{0}.texture".format(gTDef), 1, 1, 1)

    neon = cmds.duplicate(obj, rr=True, ic=True,
                          name="{0}_neon".format(obj))[0]
    cmds.select(neon, r=True)
    nTDef, nTxform = cmds.textureDeformer(offset=-0.00,
                                          strength=0.00,
                                          vectorSpace="Object",
                                          direction="Normal",
                                          pointSpace="UV",
                                          name="{0}_neon_textDef".format(obj))
    nTextTrans = cmds.rename(nTxform, "{0}_TextureDef".format(neon))