Beispiel #1
0
def lucky_facial(body):
    # body est le mesh de base sur lequel on va mettre les plaques
    plaques = mc.ls(sl=True)
    recup_plaques = []
    recup_locators = []

    for ind, mesh in enumerate(plaques):
        # create locator and snap it to mesh
        locator = mc.spaceLocator(n=mesh + '_loc', p=(0, 0, 0))
        tool.snap_from_to(mesh, locator)
        recup_locators.append(locator)
        # recup name part to name ctrl
        no_ns = mesh.split(':')[1]
        recup = no_ns.split('_')[-2]
        recup_plaques.append(recup)

    # ctrlTuple est une liste de tuples
    ctrl_tuple = tool.more_ctrl(recup_plaques)
    # snap aux locs
    for i, locator in enumerate(recup_locators):
        tool.snap_from_to(locator, ctrl_tuple[i][1])

    # skin and shrinkwrap
    for ind, mesh in enumerate(plaques):
        mc.skinCluster(mesh, ctrl_tuple[ind][0], tsb=True, rui=True)
        deform = mc.deformer('shrinkWrap_facial', e=True, g=mesh)
        deform = 'shrinkWrap_facial'
        if not mc.objExists(deform):
            deform = mc.deformer(mesh, n='shrinkWrap_facial', type='shrinkWrap')[0]
            mc.setAttr(deform + '.projection', 3)
            mc.setAttr(deform + '.bidirectional', 1)
            mc.connectAttr(body + '.worldMesh[0]', deform + '.targetGeom')
        mc.polyMoveFacet(ltz=float(ind + 1) / 1000)
Beispiel #2
0
def createGear():
    teeth = 16
    teethLength = 0.2

    # name
    nsTmp = "Gear" + str(rnd.randint(1000, 9999))
    cmds.select(clear=True)
    cmds.namespace(add=nsTmp)
    cmds.namespace(set=nsTmp)
    # query colour from UI
    rgb = cmds.colorSliderGrp('gearColour', q=True, rgbValue=True)

    # base
    gear = cmds.polyCylinder(r=0.7, h=0.4, sx=32)

    # extrude teeth
    for i in range(31):
        if (i % 2 == 0):
            cmds.select(gear[0] + ".f[" + str(i) + "]")
            cmds.polyExtrudeFacet(ltz=0.1)
            cmds.polyExtrudeFacet(ltz=0.1)
            cmds.polyMoveFacet(lsx=0.5)

    # decor
    tmp = cmds.polyCylinder(r=0.6, h=0.2)
    cmds.move(0.2, moveY=True, a=True)
    gear = cmds.polyCBoolOp(gear, tmp, op=2, ch=False)
    tmp = cmds.polyCylinder(r=0.6, h=0.2)
    cmds.move(-0.2, moveY=True, a=True)
    gear = cmds.polyCBoolOp(gear, tmp, op=2, ch=False)
    # center
    cylind = cmds.polyCylinder(r=0.3, h=0.6)
    #create x shape
    x = cmds.polyCube(w=0.5, h=0.6, d=0.2)
    tmp = cmds.polyCube(w=0.2, h=0.6, d=0.5)
    #combine them
    x = cmds.polyCBoolOp(x, tmp, op=1)
    x2 = cmds.duplicate(x)
    # remove from center
    cylind = cmds.polyCBoolOp(cylind, x, op=2)
    # remove from base
    gear = cmds.polyCBoolOp(gear, x2, op=2)

    # add material
    myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
    cmds.setAttr(nsTmp + ":blckMat.color",
                 rgb[0],
                 rgb[1],
                 rgb[2],
                 type='double3')

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.move(0.3, moveY=True, a=True)
    cmds.delete(ch=True)

    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
Beispiel #3
0
def extractMeshForJoints(joints, tolerance=0.25, expand=0):
    '''
	given a list of joints this will extract the mesh influenced by these joints into
	a separate object.  the default tolerance is high because verts are converted to
	faces which generally results in a larger than expected set of faces
	'''
    faces = []
    joints = map(str, joints)
    for j in joints:
        faces += jointFacesForMaya(j, tolerance, False)

    if not faces:
        return None

    theJoint = joints[0]

    meshes = extractFaces(faces)
    grp = cmd.group(em=True, name='%s_mesh#' % theJoint)
    cmd.delete(cmd.parentConstraint(theJoint, grp))

    for m in meshes:
        #unlock all xform attrs
        for at in 't', 'r', 's':
            cmd.setAttr('%s.%s' % (m, at), l=False)
            for ax in 'x', 'y', 'z':
                cmd.setAttr('%s.%s%s' % (m, at, ax), l=False)

        if expand > 0:
            cmd.polyMoveFacet("%s.vtx[*]" % m, ch=False, ltz=expand)

        #parent to the grp and freeze transforms to ensure the shape's space is the same as its new parent
        cmd.parent(m, grp)
        cmd.makeIdentity(m, a=True, t=True, r=True, s=True)

        #parent all shapes to the grp
        cmd.parent(cmd.listRelatives(m, s=True, pa=True),
                   grp,
                   add=True,
                   s=True)

        #delete the mesh transform
        cmd.delete(m)

    #remove any intermediate objects...
    for shape in listRelatives(grp, s=True, pa=True):
        if getAttr('%s.intermediateObject' % shape):
            delete(shape)

    return grp
Beispiel #4
0
def extractMeshForJoints( joints, tolerance=0.25, expand=0 ):
	'''
	given a list of joints this will extract the mesh influenced by these joints into
	a separate object.  the default tolerance is high because verts are converted to
	faces which generally results in a larger than expected set of faces
	'''
	faces = []
	joints = map( str, joints )
	for j in joints:
		faces += jointFacesForMaya( j, tolerance, False )

	if not faces:
		return None

	theJoint = joints[ 0 ]

	meshes = extractFaces( faces )
	grp = cmd.group( em=True, name='%s_mesh#' % theJoint )
	cmd.delete( cmd.parentConstraint( theJoint, grp ) )

	for m in meshes:
		#unlock all xform attrs
		for at in 't', 'r', 's':
			cmd.setAttr( '%s.%s' % (m, at), l=False )
			for ax in 'x', 'y', 'z':
				cmd.setAttr( '%s.%s%s' % (m, at, ax), l=False )

		if expand > 0:
			cmd.polyMoveFacet( "%s.vtx[*]" % m, ch=False, ltz=expand )

		#parent to the grp and freeze transforms to ensure the shape's space is the same as its new parent
		cmd.parent( m, grp )
		cmd.makeIdentity( m, a=True, t=True, r=True, s=True )

		#parent all shapes to the grp
		cmd.parent( cmd.listRelatives( m, s=True, pa=True ), grp, add=True, s=True )

		#delete the mesh transform
		cmd.delete( m )

	#remove any intermediate objects...
	for shape in listRelatives( grp, s=True, pa=True ):
		if getAttr( '%s.intermediateObject' % shape ):
			delete( shape )

	return grp
def add_to_system():
    # on selectionne des mesh et un joint.
    depart = mc.ls(sl=True)
    bone = []
    ajout = []
    for i in depart:
        if mc.objectType(i, i='joint') == 1:
            bone.append(i)
        else:
            ajout.append(i)

    if len(bone) >= 1:
        bone = bone[0]

    for ind, plane in enumerate(ajout):
        mc.skinCluster(plane, bone, tsb=True, rui=True)
        swName = mc.listHistory(plane)[2]
        deform = mc.deformer(swName, e=True, g=plane)
        mc.polyMoveFacet(plane, ltz=float(ind + 2) / 1000)
def lucky_facial(body, deformname):
    # body est le mesh de base sur lequel on va mettre les plaques
    plaques = mc.ls(sl=True)
    recup_plaques = []
    recup_locators = []
    if len(plaques) == 0:
        return

    for ind, mesh in enumerate(plaques):
        # create locator and snap it to mesh
        locator = mc.spaceLocator(n=mesh + '_loc', p=(0, 0, 0))
        tool.snap_from_to(mesh, locator)
        recup_locators.append(locator)
        # recup name part to name ctrl
        nohi = mesh.split('_')[1:-1]
        recup = '_'.join(nohi)
        recup_plaques.append(recup)

    # ctrlTuple est une liste de tuples
    ctrl_tuple = tool.more_ctrl(recup_plaques)
    # snap aux locs
    for i, locator in enumerate(recup_locators):
        tool.snap_from_to(locator, ctrl_tuple[i][1])
        mc.delete(locator)

    # skin and shrinkwrap
    for ind, mesh in enumerate(plaques):
        mc.skinCluster(mesh, ctrl_tuple[ind][0], tsb=True, rui=True)

        deform = deformname
        if not mc.objExists(deform):
            deform = mc.deformer(mesh, n=deformname, type='shrinkWrap')[0]
            mc.setAttr(deform + '.projection', 3)
            mc.setAttr(deform + '.closestIfNoIntersection', 1)
            mc.setAttr(deform + '.bidirectional', 1)
            mc.connectAttr(body + '.worldMesh[0]', deform + '.targetGeom')

        deform = mc.deformer(deformname, e=True, g=mesh)
        mc.polyMoveFacet(mesh, ltz=float(ind + 2) / 1000)

    print('First pass successfully done ! ROGER')
Beispiel #7
0
def imprint(ground, obj, step_distance=1):
    obj_start_pos = get_position(obj)
    _, bbox_y, _ = cmds.polyEvaluate([obj], b=True)
    cmds.move(0,
              bbox_y[0],
              0,
              "{}.scalePivot".format(obj),
              "{}.rotatePivot".format(obj),
              r=True,
              a=True)
    cmds.move(0, 0, 0, [obj], a=True, ws=True, rpr=True)
    obj_new_pos = get_position(obj)
    num_steps = abs(int((obj_start_pos[1] - obj_new_pos[1]) // step_distance))
    for i in range(num_steps):
        cmds.move(0, -1, 0, [obj], r=True, os=True, wd=True)
        intersection_points = get_intersection(ground, obj)
        _, bbox_ground_y, _ = cmds.polyEvaluate(ground, b=True)
        _, bbox_obj_y, _ = cmds.polyEvaluate(obj, b=True)
        diff = bbox_obj_y[0] - bbox_ground_y[0]
        cmds.select(*intersection_points)
        cmds.polyMoveFacet(ty=diff)
Beispiel #8
0
def createRack():
    rgb = cmds.colorSliderGrp('rackColour', q=True, rgbValue=True)

    # name
    nsTmp = "Rack" + str(rnd.randint(1000, 9999))

    cmds.select(clear=True)
    cmds.namespace(add=nsTmp)
    cmds.namespace(set=nsTmp)

    # base
    rack = cmds.polyCube(h=0.6, w=1.5, d=6, sz=24)

    # extrude teeth
    for i in range(24):
        if (i % 2 == 1):
            cmds.select(rack[0] + ".f[" + str(i) + "]")
            cmds.polyExtrudeFacet(ltz=0.3)
            cmds.polyExtrudeFacet(ltz=0.3)
            cmds.polyMoveFacet(lsx=0.1)

    tmp = cmds.polyCube(h=0.6, w=1.5, d=2)
    cmds.move(-3.753, moveZ=True)
    rack = cmds.polyCBoolOp(rack, tmp, op=2)
    tmp = cmds.polyCube(h=0.6, w=1.5, d=2)

    # add material
    myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
    cmds.setAttr(nsTmp + ":blckMat.color",
                 rgb[0],
                 rgb[1],
                 rgb[2],
                 type='double3')

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.move(0.4, moveY=True, a=True)
    cmds.delete(ch=True)

    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
Beispiel #9
0
cmds.parent(master_crv, main_group)

master = BodyPart('master', c, 'master_crv')

# ROOT/HIP
# ----------------
root_crv = cmds.circle(name='root_center_crv', radius=0.18)
cmds.move(0, 1.102, 0)
cmds.rotate(90, 0, 0)
paintCurve('root_center_crv', c)

root_geo = cmds.polyCube(name='root_center_geo', sy=2, sx=2)
cmds.scale(0.154, 0.154, 0.122)
cmds.move(0, 1.093, 0)
cmds.polyMoveFacet('root_center_geo.f[10]', 'root_center_geo.f[11]', ty=-0.07)
cmds.polyMoveEdge('root_center_geo.e[30]', 'root_center_geo.e[31]', sx=1.35)
cmds.polyMoveEdge('root_center_geo.e[27]', 'root_center_geo.e[29]', sx=1.45)
cmds.polyMoveEdge('root_center_geo.e[16]',
                  'root_center_geo.e[13]',
                  'root_center_geo.e[22]',
                  'root_center_geo.e[25]',
                  sz=1.25)

root = BodyPart('root', c, 'root_center_crv', 'root_center_geo')
root.defineFather(master)

# WAIST
# ----------------
create_joint('waist', c, [0, 1.201, 0])