예제 #1
0
 def kmSetToFace(self):
     selectionList = mc.ls(selection=True, type='transform')
     if selectionList:
         for obj in selectionList:
             mc.polySetToFaceNormal()
         sel = mc.select(selectionList)
     else:
         print ">> No selection"
예제 #2
0
def prep(transform):
  # Select the transform
  cmds.select(transform, replace=True)
  # Fix normals
  cmds.polySetToFaceNormal()
  # Delete history
  cmds.delete(constructionHistory=True)
  # Scale 10x
  cmds.scale(centerPivot=True, scaleXYZ=10)
  # Freeze transformations
  cmds.makeIdentity(apply=True, translate=True, rotate=True, scale=True, normal=1)
예제 #3
0
def maya_mel_make_poly_geometry(mesh, verbose=False):
    first_triangle = True
    used = [False for _ in mesh.vertices]
    for triangle in mesh.triangles:
        i = triangle[0]
        j = triangle[1]
        k = triangle[2]

        pi = mesh.vertices[i]
        pj = mesh.vertices[j]
        pk = mesh.vertices[k]

        pattern = int(used[k]) << 2 | int(used[j]) << 1 | int(used[i]) << 0

        if pattern == 0:
            if first_triangle:
                cmds.polyCreateFacet(constructionHistory=False, p=[pi, pj, pk], name=mesh.name)
                first_triangle = False
            else:
                cmds.polyAppendVertex(constructionHistory=False, a=[pi, pj, pk])
        elif pattern == 1:
            cmds.polyAppendVertex(constructionHistory=False, a=[i, pj, pk])
        elif pattern == 2:
            cmds.polyAppendVertex(constructionHistory=False, a=[pi, j, pk])
        elif pattern == 3:
            cmds.polyAppendVertex(constructionHistory=False, a=[i, j, pk])
        elif pattern == 4:
            cmds.polyAppendVertex(constructionHistory=False, a=[pi, pj, k])
        elif pattern == 5:
            cmds.polyAppendVertex(constructionHistory=False, a=[i, pj, k])
        elif pattern == 6:
            cmds.polyAppendVertex(constructionHistory=False, a=[pi, j, k])
        elif pattern == 7:
            cmds.polyAppendVertex(constructionHistory=False, a=[i, j, k])
        else:
            raise RuntimeError('Internal error, illegal pattern value detected')
        used[i] = True
        used[j] = True
        used[k] = True
    cmds.polySetToFaceNormal()
    if verbose:
        print 'Created maya poly mesh of', mesh.name
예제 #4
0
def fixNormals(*arg):
    ''' Fix normal for every selected objects'''
    if commonTools.testSelection() == None:
        cmds.warning('Nothing is selected')
    else:
        sel = commonTools.testSelection()
        selAD = cmds.listRelatives(sel, ad=True)
        selShapes = cmds.listRelatives(sel, shapes=True,
                                       fullPath=True)  # List selected shapes
        for i in selAD:  # Fix normal angles
            cmds.polyNormalPerVertex(i, ufn=True)  # Unlock normals
            cmds.polySetToFaceNormal(i)  # Set to face
            cmds.polySoftEdge(i, a=60)  # Set normal angle to 60
        for i in selShapes:  # Disable opposite normals
            cmds.setAttr('%s.doubleSided' % i, 0)
            cmds.setAttr('%s.opposite' % i, 0)
            cmds.setAttr('%s.doubleSided' % i, 1)
        cmds.select(clear=True)
        cmds.select(sel, r=True)
        cmds.inViewMessage(amg='Done ! Remember to delete history.',
                           pos='midCenter',
                           fade=True)
예제 #5
0
def maya_api_create_scene(data):
    for geometry in data.geometries:
        maya_api_create_mesh(geometry)

    for body in data.bodies:
        maya_api_make_instance_copy(body[0], body[1])

    for geometry in data.geometries:
        maya_mel_hide(geometry.name)

    for channel in data.channels:
        maya_api_addkeys(channel.name + '.tx', channel.time, channel.tx)
        maya_api_addkeys(channel.name + '.ty', channel.time, channel.ty)
        maya_api_addkeys(channel.name + '.tz', channel.time, channel.tz)
        maya_api_addkeys(channel.name + '.rx', channel.time, channel.rx)
        maya_api_addkeys(channel.name + '.ry', channel.time, channel.ry)
        maya_api_addkeys(channel.name + '.rz', channel.time, channel.rz)
        maya_mel_fix_euler_angles(channel.name)

    cmds.select(clear=True)
    cmds.select(cmds.ls('body*'), visible=True)
    cmds.polySetToFaceNormal()
    cmds.group(name='World')
    cmds.sets(forceElement='initialShadingGroup')