Ejemplo n.º 1
0
 def polytube(self, p1_x, p1_y, p1_z,
              p2_x, p2_y, p2_z,
              p0_x, p0_y, p0_z,
              p1_r, p2_r,
              polys):
     for i in range(0, polys):
         inc = math.pi * 2.0 / polys
         p = self.get_point_given_dist([p0_x, p0_y, p0_z], [p1_x, p1_y, p1_z], p1_r)
         point1 = self.point_rotate_3d(p0_x, p0_y, p0_z,
                                       p1_x, p1_y, p1_z,
                                       p[0], p[1], p[2],
                                       -(inc * i)
                                       )
         point2 = self.point_rotate_3d(p0_x, p0_y, p0_z,
                                       p1_x, p1_y, p1_z,
                                       p[0], p[1], p[2],
                                       -(inc * i + inc)
                                       )
         p = self.get_point_given_dist([p1_x, p1_y, p1_z], [p2_x, p2_y, p2_z], p2_r)
         point3 = self.point_rotate_3d(p1_x, p1_y, p1_z,
                                       p2_x, p2_y, p2_z,
                                       p[0], p[1], p[2],
                                       -(inc * i)
                                       )
         point4 = self.point_rotate_3d(p1_x, p1_y, p1_z,
                                       p2_x, p2_y, p2_z,
                                       p[0], p[1], p[2],
                                       -(inc * i + inc)
                                       )
         cmds.polyCreateFacet(p=[point2,
                                 point1,
                                 point3,
                                 point4],
                              name='treePart#')
Ejemplo n.º 2
0
def polytube(p1_x, p1_y, p1_z, p2_x, p2_y, p2_z, p1_r, p2_r, a1_x, a1_y, a1_z,
             a2_x, a2_y, a2_z, polys):
    for i in range(0, polys):
        inc = math.pi * 2 / polys
        # points are being repositioned before rotation
        point1 = get_rotations(
            p1_x + p1_r * math.cos(inc * i),  # xyz of the point to be rotated
            p1_y,
            p1_z + p1_r * math.sin(inc * i),
            a1_x,
            a1_y,
            a1_z,  # xyz angles of the rotation
            p1_x,
            p1_y,
            p1_z  # axis of the rotation
        )
        point2 = get_rotations(p1_x + p1_r * math.cos(inc * i + inc), p1_y,
                               p1_z + p1_r * math.sin(inc * i + inc), a1_x,
                               a1_y, a1_z, p1_x, p1_y, p1_z)
        point3 = get_rotations(p2_x + p2_r * math.cos(inc * i), p2_y,
                               p2_z + p2_r * math.sin(inc * i), a2_x, a2_y,
                               a2_z, p1_x, p1_y, p1_z)
        point4 = get_rotations(p2_x + p2_r * math.cos(inc * i + inc), p2_y,
                               p2_z + p2_r * math.sin(inc * i + inc), a2_x,
                               a2_y, a2_z, p1_x, p1_y, p1_z)

        cmds.polyCreateFacet(p=[point2, point1, point3, point4])
def create_orient_group():
    #turn on track selection order
    if ( not mc.selectPref(trackSelectionOrder=1, q=1)):
        mc.selectPref(trackSelectionOrder=True)
    sel =  mc.ls(orderedSelection=True)

    if(sel):
        ctrl = sel.pop()
        verts = sel
        print("verts: ", verts)
        if(len(verts)==3 or len(verts)==6):
            #create helper plane/s. Find normals 
            helper_plane_01 = mc.polyCreateFacet( p=[mc.pointPosition(verts[0]), mc.pointPosition(verts[1]), mc.pointPosition(verts[2])] )
            plane01_str_normal = mc.polyInfo(fn=1)[0].split()
            mc.delete(helper_plane_01)
            plane01_normal = (float(plane01_str_normal[2]), float(plane01_str_normal[3]), float(plane01_str_normal[4]))
            vectorN = om.MVector(plane01_normal[0], plane01_normal[1], plane01_normal[2])

            if (len(verts)==6):
                helper_plane_02 = mc.polyCreateFacet( p=[mc.pointPosition(verts[3]), mc.pointPosition(verts[4]), mc.pointPosition(verts[5])] )
                plane02_str_normal = mc.polyInfo(fn=1)[0].split()
                mc.delete(helper_plane_02)
                plane02_normal = (float(plane02_str_normal[2]), float(plane02_str_normal[3]), float(plane02_str_normal[4]))
                vectorT = om.MVector(plane02_normal[0], plane02_normal[1], plane02_normal[2])
            else:
                # if only one plane is provided, find which one of the world axes is orthogonal to the normal
                if (vectorN*om.MVector(1,0,0) == 0):
                    vectorT = om.MVector(1,0,0)
                elif (vectorN*om.MVector(0,1,0) == 0):
                    vectorT = om.MVector(0,1,0)
                elif (vectorN*om.MVector(0,0,1) == 0):
                    vectorT = om.MVector(0,0,1)
                else:
                    #if none of the axes are aligned with a world axis, ask for more verts to define a 2nd plane
                    warning_msg("No axes are aligned with a world axis. You'll need to select 6 vertices and then ctrl.")
                    return

            #find 3rd vector
            vectorX = vectorN^vectorT

            #create orient grp with same pivot as ctrl then parent ctrl
            orientGrp = mc.group(n=str(ctrl).replace('_Ctrl', '_')+'orientGrp', em=1)
            constraint = mc.parentConstraint( ctrl, orientGrp)
            mc.delete(constraint)
            mc.parent(ctrl, orientGrp)

            #make rotation matrix from vectors
            #keep position and assign rotation matrix to orientGrp 
            orientGrp_matrix = mc.xform(orientGrp,q=1, m=1)
            mc.xform(orientGrp, m=(vectorX.x, vectorX.y, vectorX.z, 0, vectorN.x, vectorN.y, vectorN.z, 0, vectorT.x, vectorT.y, vectorT.z, 0,orientGrp_matrix[12],orientGrp_matrix[13],orientGrp_matrix[14],orientGrp_matrix[15] ))
            #freeze transforms
            mc.makeIdentity(orientGrp, apply=1, t=1, n=0)
        else:
            warning_msg("Please select 3 or 6 vertices and then ctrl")
            return
    else:
        warning_msg("Please select 3 or 6 vertices and then ctrl")
        return
Ejemplo n.º 4
0
Archivo: main.py Proyecto: lepy/mayamvc
def setup_scene():
    #manually create a simple tetrahedron
    p1 = cmds.polyCreateFacet(p=[(0, 0, 0), (1, 0, 0), (0, 0, 1)])
    p2 = cmds.polyCreateFacet(p=[(0, 0, 0), (0, 1, 0), (1, 0, 0)])
    p3 = cmds.polyCreateFacet(p=[(0, 0, 0), (0, 0, 1), (0, 1, 0)])
    p4 = cmds.polyCreateFacet(p=[(0, 0, 1), (1, 0, 0), (0, 1, 0)])
    cmds.polyMergeVertex(cmds.polyUnite(p1, p2, p3, p4, ch=0, name="cage"),
                         ch=0)
    poly_map = [[
        "cage.vtx[0]",
        [
            ("cage.vtx[0]", "cage.vtx[2]", "cage.vtx[3]"),
            ("cage.vtx[0]", "cage.vtx[3]", "cage.vtx[1]"),
            ("cage.vtx[0]", "cage.vtx[1]", "cage.vtx[2]"),
        ]
    ],
                [
                    "cage.vtx[1]",
                    [
                        ("cage.vtx[1]", "cage.vtx[0]", "cage.vtx[3]"),
                        ("cage.vtx[1]", "cage.vtx[3]", "cage.vtx[2]"),
                        ("cage.vtx[1]", "cage.vtx[2]", "cage.vtx[0]"),
                    ]
                ],
                [
                    "cage.vtx[2]",
                    [
                        ("cage.vtx[2]", "cage.vtx[3]", "cage.vtx[0]"),
                        ("cage.vtx[2]", "cage.vtx[1]", "cage.vtx[3]"),
                        ("cage.vtx[2]", "cage.vtx[0]", "cage.vtx[1]"),
                    ]
                ],
                [
                    "cage.vtx[3]",
                    [
                        ("cage.vtx[3]", "cage.vtx[2]", "cage.vtx[1]"),
                        ("cage.vtx[3]", "cage.vtx[1]", "cage.vtx[0]"),
                        ("cage.vtx[3]", "cage.vtx[0]", "cage.vtx[2]"),
                    ]
                ]]
    #debug tetra
    """
	for p in poly_map:
		tris = p[1]
		for t in tris:
			pnts = []
			for vert in t:
				pnt = utils.pnt(vert)
				pnts.append([pnt.x, pnt.y, pnt.z])
			cmds.polyCreateFacet(p=pnts)
	"""

    cage = MayaPolyWrapper(poly_map)
    loc = utils.loc([.1, .1, .1])
    return cage, loc
Ejemplo n.º 5
0
def makeTetra(size):
    
    pointA = [0, 0, 0]
    pointB = [size, 0, 0]    
    pointC = [size/2.0, 0, 0]
    
    # set the Z position for C
    pointC[2] = math.sqrt((size*size) - (size/2.0 * size/2.0))
    pointE = [0, 0, 0]
    
    # average the A, B, and C to get E
    # first add all the values
    for i in range(0,3):
        pointE[i] += pointA[i]
        pointE[i] += pointB[i]
        pointE[i] += pointC[i]
    
    # now divide by 3
    for i in range(0,3):
        pointE[i] = pointE[i] / 3.0
        
    # start point D with the X and Z coordinates of point E
    pointD = [0, 0, 0]
    pointD[0] = pointE[0]
    pointD[2] = pointE[2]
    
    distanceAE = math.sqrt((pointE[0] * pointE[0]) + (pointE[2] * pointE[2]))
    
    # set the Y coordinate of point D
    pointD[1] = math.sqrt((size*size) - (distanceAE * distanceAE))
    
    faces = []
    faces.append(cmds.polyCreateFacet(p=[pointA, pointB, pointC], texture=1))
    faces.append(cmds.polyCreateFacet(p=[pointA, pointD, pointB], texture=1))
    faces.append(cmds.polyCreateFacet(p=[pointB, pointD, pointC], texture=1))
    faces.append(cmds.polyCreateFacet(p=[pointC, pointD, pointA], texture=1))

    cmds.select(faces[0], replace=True)
    for i in range(1, len(faces)):
        cmds.select(faces[i], add=True)

    obj = cmds.polyUnite()
    
    cmds.select(obj[0] + ".vtx[:]")
    cmds.polyMergeVertex(distance=0.0001)
    
    cmds.select(obj[0])
    
    cmds.move(-pointE[0], 0, -pointE[2])
    cmds.xform(pivots=(pointE[0], 0, pointE[2]))
    cmds.makeIdentity(apply=True)
    cmds.delete(ch=True)
def generate(pts):
    """Takes in a list of tuples (set of 3D points) and generates a polygon model"""
    cmds.polyCreateFacet(name="shirt", p=points)
    cmds.polyTriangulate()
    cmds.polyQuad(angle=90)
    cmds.polySubdivideFacet(dv=SUBDIVISIONS)
    cmds.polyTriangulate()
    
    # Center shirt on origin
    centerX = cmds.objectCenter("shirt", x = True, gl = True)
    centerY = cmds.objectCenter("shirt", y = True, gl = True)
    centerZ = cmds.objectCenter("shirt", z = True, gl = True)
    cmds.move(-centerX, -centerY, -centerZ, "shirt", absolute=True)
def generate(pts):
    """Takes in a list of tuples (set of 3D points) and generates a polygon model"""
    cmds.polyCreateFacet(name="shirt", p=points)
    cmds.polyTriangulate()
    cmds.polyQuad(angle=90)
    cmds.polySubdivideFacet(dv=SUBDIVISIONS)
    cmds.polyTriangulate()

    # Center shirt on origin
    centerX = cmds.objectCenter("shirt", x=True, gl=True)
    centerY = cmds.objectCenter("shirt", y=True, gl=True)
    centerZ = cmds.objectCenter("shirt", z=True, gl=True)
    cmds.move(-centerX, -centerY, -centerZ, "shirt", absolute=True)
Ejemplo n.º 8
0
def buildPoly(polyName, polyVtx1, polyVtx2, polyVtx3, polyVtx4):
    print('attempting to build poly')
    print(polyName)
    print(polyVtx1)
    print(polyVtx2)
    print(polyVtx3)
    print(polyVtx4)
    cmds.polyCreateFacet(p=[(polyVtx1[0], polyVtx1[1], polyVtx1[2]),
                            (polyVtx2[0], polyVtx2[1], polyVtx2[2]),
                            (polyVtx3[0], polyVtx3[1], polyVtx3[2]),
                            (polyVtx4[0], polyVtx4[1], polyVtx4[2])],
                         name=polyName)
    cmds.parent(polyName, 'bridgePolys_grp')
Ejemplo n.º 9
0
    def mainFunc(self):
        original_height = float(self.float_height.value())
        #define values
        verts = cmds.ls(os = True)
        verts_pos = cmds.xform(verts, q=True, ws = True, t = True)
        v0 = cmds.xform(verts[0], q=True, ws = True, t = True)
        v1 = cmds.xform(verts[1], q=True, ws = True, t = True)
        v2 = cmds.xform(verts[2], q=True, ws = True, t = True)
        v3 = cmds.xform(verts[3], q=True, ws = True, t = True)
        print v0, v1, v2, v3
        
        """not using numpy
        """
        cp_x = (v0[0]+v1[0]+v2[0]+v3[0])/4
        cp_y = (v0[1]+v1[1]+v2[1]+v3[1])/4
        cp_z = (v0[2]+v1[2]+v2[2]+v3[2])/4
        
        cp = [cp_x, cp_y, cp_z]
        
        """ using numpy
        verts_pos = np.reshape(np.array(verts_pos), (len(verts_pos)/3,3))
        cp = np.average(verts_pos, axis = 0)
        """
        
        object = verts[0].split('.vtx')[0]
        plane = 'bottom_plane'

        #create plane for alignment
        cmds.polyCreateFacet(p =(v0,v1,v2,v3), n = plane)
        self.movePivot(cp, object)
        self.movePivot(cp, plane)
        cmds.parent(object, plane)
        cmds.move(-cp[0],-cp[1],-cp[2], plane)
        self.align_plane(plane)

        #clean up the aid objects
        cmds.parent(plane + '|' + object, world = True)
        #cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=2)
        cmds.delete(plane)
        cmds.delete('locator_center')
        cmds.delete('locator_normal_aim')
        cmds.delete('locator_for_z')
        
        
        bb = cmds.exactWorldBoundingBox()
        height = bb[4] - bb[1]
        print height
        s = original_height/height
        print s
        cmds.scale(s,s,s, object)
Ejemplo n.º 10
0
def pointFaceMesh(pointList, scale=0.05, combine=True, prefix='pointFace'):
    '''
	'''
    # Get encoded point list
    ptList = []
    for point in pointList:
        ptList.append(glTools.utils.base.getPosition(point))

    # Create face for each point
    faceList = []
    vscale = scale * 0.5
    hscale = scale * 0.866
    for pt in ptList:
        face = mc.polyCreateFacet(
            p=[(pt[0], pt[1] + scale,
                pt[2]), (pt[0] + hscale, pt[1] - vscale,
                         pt[2]), (pt[0] - hscale, pt[1] - vscale, pt[2])])[0]
        faceList.append(face)

    # Combine faces to single mesh
    if combine:
        mesh = mc.polyUnite(faceList, ch=False)
        mesh = mc.rename(mesh[0], prefix + '_mesh')

    # Return result
    return mesh
Ejemplo n.º 11
0
 def axisPanelCreate(self , planeName , cur , axis):
         CurveEps = mc.ls(cur + '.ep[:]',fl = True)
         CurveCvs = mc.ls(cur + '.cv[:]',fl = True)
         cvworlds = []
         if axis == 'auto':
                 for i in range(len(CurveCvs)):
                         cv = CurveCvs[i]
                         cvworld = mc.xform(cv,q = True,ws = True,t = True)
                         cvworlds.append(cvworld)
                 axisFacet = mc.polyCreateFacet(p = cvworlds,ch = False,name = planeName + '_axis_Facet')[0]
         else:
                 curOffsetGrp = mc.group(em = True,name = planeName + '_axisPanelOffset')
                 curOffsetZero = mc.group(curOffsetGrp,name = curOffsetGrp + '_zero')
                 axisCurve01 = mc.duplicate(cur)[0]
                 axisCurve02 = mc.duplicate(cur)[0]
                 mc.parent(axisCurve01,curOffsetGrp)
                 mc.setAttr(curOffsetGrp + '.t' + axis,1)
                 mc.parent(axisCurve01,w = True)
                 mc.parent(axisCurve02,curOffsetGrp)
                 mc.setAttr(curOffsetGrp + '.t' + axis,0)
                 mc.parent(axisCurve02,w = True)
                 axisFacet = mc.loft(axisCurve01,axisCurve02,ch = 1,u = 1,c = 0,ar = 1,d = 3,ss = 1,rn = 0,po = 1,rsn = True,name = planeName + '_axis_Facet')[0]
                 mc.select(axisFacet)
                 mc.DeleteHistory()
                 mc.setAttr(curOffsetGrp + '.t' + axis,1)
                 mc.delete(curOffsetZero,axisCurve01,axisCurve02)
         return axisFacet
def polytube(p1_x, p1_y, p1_z, p2_x, p2_y, p2_z, p0_x, p0_y, p0_z, p1_r, p2_r,
             polys):
    for i in range(0, polys):
        inc = math.pi * 2.0 / polys
        # points are being repositioned before rotation

        point1 = PointRotate3D(p0_x, p0_y, p0_z, p1_x, p1_y, p1_z, p1_x + p1_r,
                               p1_y, p1_z, -(inc * i))
        point2 = PointRotate3D(p0_x, p0_y, p0_z, p1_x, p1_y, p1_z, p1_x + p1_r,
                               p1_y, p1_z, -(inc * i + inc))
        point3 = PointRotate3D(p1_x, p1_y, p1_z, p2_x, p2_y, p2_z, p2_x + p2_r,
                               p2_y, p2_z, -(inc * i))
        point4 = PointRotate3D(p1_x, p1_y, p1_z, p2_x, p2_y, p2_z, p2_x + p2_r,
                               p2_y, p2_z, -(inc * i + inc))

        cmds.polyCreateFacet(p=[point2, point1, point3, point4])
Ejemplo n.º 13
0
def pointFaceMesh(pointList,scale=0.05,combine=True,prefix='pointFace'):
	'''
	'''
	# Get encoded point list
	ptList = []
	for point in pointList:
		ptList.append(glTools.utils.base.getPosition(point))
	
	# Create face for each point
	faceList = []
	vscale = scale * 0.5
	hscale = scale * 0.866
	for pt in ptList:
		face = mc.polyCreateFacet(p=[(pt[0],pt[1]+scale,pt[2]),(pt[0]+hscale,pt[1]-vscale,pt[2]),(pt[0]-hscale,pt[1]-vscale,pt[2])])[0]
		face = mc.rename(face,prefix+'_mesh')
		faceList.append(face)
	
	# Define return list
	mesh = faceList
	
	# Combine faces to single mesh
	if combine:
		mesh = mc.polyUnite(faceList,ch=False)
		mesh = [mc.rename(mesh[0],prefix+'_mesh')]
	
	# Return result
	return mesh
Ejemplo n.º 14
0
def makePlane(*args):
	points = []
	cmds.polyCreateFacetCtx(pc=False)
	sel = cmds.ls(sl=True, type="transform")
	for obj in sel:
		loc = cmds.pointPosition((obj + ".rotatePivot"), world=True)
		points.append(loc)
		poly = cmds.polyCreateFacet(p=points)
Ejemplo n.º 15
0
def surfaceToHairGroup(curve_num = 4):
    select_surfaces = mc.ls(sl = True)
    for mesh in select_surfaces:
        v_range = mc.getAttr('%s.mmv' % mesh)[0]
        v_step = v_range[1] / (curve_num - 1)
        # create curves
        curves = []
        for i in range(curve_num):
            d_curve = mc.duplicateCurve('%s.v[%f]' % (mesh, (i * v_step)), ch = True, rn = False, local = False)[0]
            curves.append(d_curve)

        # create polygon
        p = []
        for curve in curves:
            p.append(mc.xform('%s.cv[0]' % curve, q = True, t = True))

        mc.polyCreateFacet(p = p)
Ejemplo n.º 16
0
def makePlane(*args):
	points = []
	cmds.polyCreateFacetCtx(pc=False)
	sel = cmds.ls(sl=True, type="transform")
	for obj in sel:
		loc = cmds.pointPosition((obj + ".rotatePivot"), world=True)
		points.append(loc)
		poly = cmds.polyCreateFacet(p=points)
Ejemplo n.º 17
0
def setup_scene():
	#manually create a simple tetrahedron 
	p1 = cmds.polyCreateFacet(p=[(0,0,0), (1,0,0), (0,0,1)])
	p2 = cmds.polyCreateFacet(p=[(0,0,0), (0,1,0), (1,0,0)])
	p3 = cmds.polyCreateFacet(p=[(0,0,0), (0,0,1), (0,1,0)])
	p4 = cmds.polyCreateFacet(p=[(0,0,1), (1,0,0), (0,1,0)])
	cmds.polyMergeVertex(cmds.polyUnite(p1,p2,p3,p4, ch=0, name = "cage"), ch=0)
	poly_map =[
		["cage.vtx[0]", [ 	("cage.vtx[0]","cage.vtx[2]","cage.vtx[3]"),
							("cage.vtx[0]","cage.vtx[3]","cage.vtx[1]"),
							("cage.vtx[0]","cage.vtx[1]","cage.vtx[2]"),
						]
		],
		["cage.vtx[1]", [ 	("cage.vtx[1]","cage.vtx[0]","cage.vtx[3]"),
							("cage.vtx[1]","cage.vtx[3]","cage.vtx[2]"),
							("cage.vtx[1]","cage.vtx[2]","cage.vtx[0]"),
						]
		],
		["cage.vtx[2]", [ 	("cage.vtx[2]","cage.vtx[3]","cage.vtx[0]"),
							("cage.vtx[2]","cage.vtx[1]","cage.vtx[3]"),
							("cage.vtx[2]","cage.vtx[0]","cage.vtx[1]"),
						]
		],
		["cage.vtx[3]", [ 	("cage.vtx[3]","cage.vtx[2]","cage.vtx[1]"),
							("cage.vtx[3]","cage.vtx[1]","cage.vtx[0]"),
							("cage.vtx[3]","cage.vtx[0]","cage.vtx[2]"),
						]
		]
		]
	#debug tetra
	"""
	for p in poly_map:
		tris = p[1]
		for t in tris:
			pnts = []
			for vert in t:
				pnt = utils.pnt(vert)
				pnts.append([pnt.x, pnt.y, pnt.z])
			cmds.polyCreateFacet(p=pnts)
	"""

	cage = MayaPolyWrapper(poly_map)
	loc = utils.loc([.1,.1,.1])
	return cage, loc
Ejemplo n.º 18
0
def edo_setTriangleView(obj,vtx=[0,1,2]):
    #obj='O_002'
    if cmds.objExists('TRIANGLEVIWE_'+obj):
        cmds.delete('TRIANGLEVIWE_'+obj)
    Ttriangle=[cmds.xform(obj+'.vtx['+str(vtx[0])+']',q=1,ws=1,t=1),cmds.xform(obj+'.vtx['+str(vtx[1])+']',q=1,ws=1,t=1),cmds.xform(obj+'.vtx['+str(vtx[2])+']',q=1,ws=1,t=1)]
    vm=cmds.polyCreateFacet(n='TRIANGLEVIWE_'+obj,ch=1,tx=1,s=1,p=Ttriangle)
    cmds.parent(vm[0],obj)
    cmds.delete(vm[1])
    cmds.polyColorPerVertex(vm[0],r=1,g=1,b=0,a=1,cdo=1)
    return vm[0]
Ejemplo n.º 19
0
 def debugIKPlane(self, index):
     if cmds.objExists("DebugPlane"):
         cmds.delete("DebugPlane")
     planePoint = []
     for Joint in self.IKGroups[index]:
         planePoint.append(
             cmds.xform(Joint,
                        query=True,
                        worldSpace=True,
                        translation=True))
     cmds.polyCreateFacet(name="DebugPlane", point=planePoint)
     shadeGroup = cmds.listConnections("DebugPlaneShape",
                                       type="shadingEngine")
     listConnected = cmds.listConnections(shadeGroup)
     material = cmds.ls(listConnected, materials=True)[0]
     cmds.setAttr(material + ".ambientColor", 0, 1, 0, 0)
     cmds.setAttr(material + ".transparency", 0.7, 0.7, 0.7, 0.7)
     cmds.setAttr("DebugPlane.overrideEnabled", 1)
     cmds.setAttr("DebugPlane.overrideDisplayType", 2)
Ejemplo n.º 20
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
def createEyelidsPlane():
	curSel = cmds.ls(sl=1,fl=1)
	eyeCtr = cmds.xform(curSel[2],ws=1,piv=1,q=1)[0:3]
	eyeCnra = cmds.pointPosition(curSel[0],w=1)
	eyeCnrb = cmds.pointPosition(curSel[1],w=1)

	eyeballPlane = cmds.polyCreateFacet(n='tmp_eyeball_plane',ch=0,p=[eyeCtr,eyeCnra,eyeCnrb])
	eyelidsPlane  = cmds.polyPlane(n='tmp_eyelids_plane')

	cmds.select((eyelidsPlane[0]+'.vtx[60]'),(eyelidsPlane[0]+'.vtx[70:71]'),(eyeballPlane[0]+'.vtx[0:2]'),r=1)
	mel.eval('snap3PointsTo3Points(0)')
	cmds.select(eyelidsPlane,r=1)
	cmds.xform(eyelidsPlane,os=1,r=1,ro=(0,0,90))
	cmds.delete(eyeballPlane)
def fn_createObject_PolyCreate():
    global importedObj

    objList = []

    for p in range(0, len(importedObj.polys), 1):
        facelist = []

        for v in range(0, len(importedObj.polys[p]), 1):
            pVert = importedObj.vertices[importedObj.polys[p][v]]
            facelist.append(pVert)
        objList.append((cmds.polyCreateFacet(p=facelist, ch=False))[0])

    cmds.polyUnite(objList, ch=False, n=importObjectName)
Ejemplo n.º 23
0
 def build(self, file):
     print "start to build"
     osm = pooper.data()
     osm.castData(file)
     osm.freezePoints(100000)
     ct = 0
     pro = self.progressBar(len(osm.buildings), 100)
     for key, val in osm.buildings.items():
         if ct in pro:
             self.valueUpdated.emit(pro[ct])
         ct += 1
         if val.type and val.type.startswith("build"):
             tPoint = self.ps2tuple(osm.points, val.pID)
             if len(tPoint) <= 2: continue
             bid = "b" + str(key)
             cmds.polyCreateFacet(p=tPoint, n=bid)
             if cmds.polyInfo(fn=True)[0].split(' ')[-2][0] == "-":
                 cmds.polyNormal(nm=0)
             if val.height:
                 cmds.select(bid)
                 cmds.xform(cp=True)
                 cmds.polyExtrudeFacet(kft=False, ltz=val.height)
         elif len(val.pID) >= 3 and val.pID[0] == val.pID[-1]:
             tPoint = self.ps2tuple(osm.points, val.pID)
             if len(tPoint) <= 2: continue
             bid = "b" + str(key)
             cmds.polyCreateFacet(p=tPoint, n=bid)
             if cmds.polyInfo(fn=True)[0].split(' ')[-2][0] == "-":
                 cmds.polyNormal(nm=0)
             if val.height:
                 cmds.select(bid)
                 cmds.xform(cp=True)
                 cmds.polyExtrudeFacet(kft=False, ltz=val.height)
         elif "boundary" in val.tags:
             tPoint = self.ps2tuple(osm.points, val.pID)
             if len(tPoint) <= 2: continue
             cmds.curve(p=tPoint, d=1)
 def get_normal(self):
     dplane = None
     if (".f[" in self.components[0]):
         face_verts = mc.polyListComponentConversion(self.components,
                                                     ff=True,
                                                     tv=True)
         verts = mc.ls(face_verts, fl=1)
         dplane = mc.polyCreateFacet(p=[
             mc.pointPosition(verts[0]),
             mc.pointPosition(verts[1]),
             mc.pointPosition(verts[2])
         ])
     else:
         dplane = mc.polyCreateFacet(p=[
             mc.pointPosition(self.components[0]),
             mc.pointPosition(self.components[1]),
             mc.pointPosition(self.components[2])
         ])
     str_normal = mc.polyInfo(dplane, fn=1)[0].split()
     mc.delete(dplane)
     normal_vector = om.MVector(float(str_normal[2]), float(str_normal[3]),
                                float(str_normal[4]))
     normal_vector.normalize()
     return normal_vector
Ejemplo n.º 25
0
def transformFaceMesh(transformList, faceAxis='y', scale=0.05, combine=True, prefix='transformFace'):
    """
    @param transformList:
    @param faceAxis:
    @param scale:
    @param combine:
    @param prefix:
    """
    # Checks
    faceAxis = faceAxis.lower()
    if not ['x', 'y', 'z'].count(faceAxis):
        raise Exception('Invalid axis "' + faceAxis + '"! Enter "x", "y" or "z".')

    # Define face vertex list
    if faceAxis == 'x':
        vtxList = [OpenMaya.MPoint(0, -scale, scale, 1), OpenMaya.MPoint(0, scale, scale, 1),
                   OpenMaya.MPoint(0, scale, -scale, 1), OpenMaya.MPoint(0, -scale, -scale, 1)]
    elif faceAxis == 'y':
        vtxList = [OpenMaya.MPoint(-scale, 0, scale, 1), OpenMaya.MPoint(scale, 0, scale, 1),
                   OpenMaya.MPoint(scale, 0, -scale, 1), OpenMaya.MPoint(-scale, 0, -scale, 1)]
    elif faceAxis == 'z':
        vtxList = [OpenMaya.MPoint(-scale, scale, 0, 1), OpenMaya.MPoint(scale, scale, 0, 1),
                   OpenMaya.MPoint(scale, -scale, 0, 1), OpenMaya.MPoint(-scale, -scale, 0, 1)]

    # Create face for each transform
    faceList = []
    for i in range(len(transformList)):
        # Get world space matrix
        tMatrix = glTools.utils.transform.getMatrix(transformList[i])

        # Create face
        vtx = [v * tMatrix for v in vtxList]
        pts = [(vtx[0][0], vtx[0][1], vtx[0][2]), (vtx[1][0], vtx[1][1], vtx[1][2]), (vtx[2][0], vtx[2][1], vtx[2][2]),
               (vtx[3][0], vtx[3][1], vtx[3][2])]
        face = cmds.polyCreateFacet(p=pts)[0]
        face = cmds.rename(face, prefix + '_' + str(i) + '_mesh')
        faceList.append(face)

    # Define return list
    mesh = faceList

    # Combine faces to single mesh
    if combine:
        mesh = cmds.polyUnite(faceList, ch=False)
        mesh = [cmds.rename(mesh[0], prefix + '_mesh')]

    # Return result
    return mesh
Ejemplo n.º 26
0
def ruCreateLocator(args):
    selection = mc.ls(sl=True)
    vertices = mc.polyListComponentConversion(selection,tv=True)
    verticesPos =  mc.xform(q=True, ws=True, translation=True ) 

    temp = []
    for i in range(0,len(verticesPos),3):
        temp.append((verticesPos[i],verticesPos[i+1],verticesPos[i+2]))

    tempFace = mc.polyCreateFacet(p=temp)
    mc.xform(cp=True)
    tempFacePivotPos = mc.xform(q=True, ws=True, rp = True)
    nameLoc = mc.spaceLocator(name="jointHolder",position=(tempFacePivotPos[0],tempFacePivotPos[1],tempFacePivotPos[2]))
    mc.xform(nameLoc, cp = True)
    mc.delete(tempFace)
    mc.select(clear=True)
Ejemplo n.º 27
0
def ruCreateLocator(args):
    selection = mc.ls(sl=True)
    vertices = mc.polyListComponentConversion(selection,tv=True)
    verticesPos =  mc.xform(q=True, ws=True, translation=True ) 

    temp = []
    for i in range(0,len(verticesPos),3):
        temp.append((verticesPos[i],verticesPos[i+1],verticesPos[i+2]))

    tempFace = mc.polyCreateFacet(p=temp)
    mc.xform(cp=True)
    tempFacePivotPos = mc.xform(q=True, ws=True, rp = True)
    nameLoc = mc.spaceLocator(name="jointHolder",position=(tempFacePivotPos[0],tempFacePivotPos[1],tempFacePivotPos[2]))
    mc.xform(nameLoc, cp = True)
    mc.delete(tempFace)
    mc.select(clear=True)
Ejemplo n.º 28
0
 def create_plane(self , planeName , CvNumOfSpans , cur):
         selCurve = mc.rebuildCurve(cur,ch=1,rpo=0,rt=0,end=1,kr=0,kcp=0,kep=0,kt=0,s=CvNumOfSpans,d=3,tol=0.01)[0]
         mc.select(selCurve)
         mc.DeleteHistory()
         CurveEps = mc.ls(selCurve + '.ep[:]',fl = True)
         worlds = []
         txs = []
         tys = []
         tzs = []
         jnts = []
         for ep in CurveEps:
                 world = mc.xform(ep,q = True,ws = True,t = True)
                 mc.select(cl = True)
                 jnt = mc.joint(p = world)
                 worlds.append(world)
                 tx = ('%.3f'%world[0])
                 ty = ('%.3f'%world[0])
                 tz = ('%.3f'% world[0])
                 jnts.append(jnt)
         #print txs,tys,tzs
         mc.select(cl = True)
         axisLocateJnt = mc.joint(name = planeName + 'axisLocateJnt')
         #mc.group()
         mc.delete(mc.parentConstraint(jnts,axisLocateJnt,mo = False))
         Facet = mc.polyCreateFacet(p = worlds,ch = False)[0]
         FacetShape = mc.listRelatives(Facet,s = True)[0]
         UV = self.closestPointOnModel(FacetShape,axisLocateJnt)
         U = UV[0]
         V = UV[1]
         follic = self.follicCreate(FacetShape,planeName,U,V)
         offsetGrp = mc.group(em = True,name = planeName + '_cv_offset')
         offsetZero = mc.group(offsetGrp,name = offsetGrp + '_zero')
         mc.delete(mc.parentConstraint(follic,offsetZero,mo = False))
         Curve01 = mc.duplicate(selCurve)[0]
         Curve02 = mc.duplicate(selCurve)[0]
         mc.parent(Curve01,offsetGrp)
         mc.setAttr(offsetGrp + '.tz',1)
         mc.parent(Curve01,w = True)
         mc.parent(Curve02,offsetGrp)
         mc.setAttr(offsetGrp + '.tz',0)
         mc.parent(Curve02,w = True)
         mc.delete(jnts,axisLocateJnt,Facet,follic,offsetZero)
         Plane = mc.loft(Curve01,Curve02,ch = True,u = True,c = False,ar = True,d = 3,ss = True,rn = False,po = False,rsn = True,name = planeName)
         mc.select(Plane)
         mc.DeleteHistory()
         mc.delete(selCurve,Curve01,Curve02)
         return Plane
Ejemplo n.º 29
0
def buildMesh(mesh):
    """
    	builds the ModlMesh mesh in scene
	"""
    meshes = []
    for face in mesh.faces:
        verts = [mesh.vertices[i] for i in face.vertex_indices]
        newMesh = cmds.polyCreateFacet(p=verts, ch=False)[0]
        # Apply vertex normals
        # for i,orig_i in enumerate(face.vertex_indices):
        # vertNormal = mesh.vertex_normals[orig_i]
        # cmds.select( newMesh+'.vtxFace[0][%d]'%i, r=True )
        # cmds.polyNormalPerVertex(xyz=vertNormal)
        meshes.append(newMesh)
    finalMesh = cmds.polyUnite(*meshes, ch=False, name=mesh.name)

    return finalMesh
Ejemplo n.º 30
0
def interactive_plane( aJnt ):
	
	try:
		bJnt = cmds.listRelatives( aJnt, children = True, type = 'joint' )[0]
	except TypeError:
		raise RuntimeError( 'You must pass a joint as the parent, %s doesn\'t seem to be a joint.' % hierarchy_parent )
		
	cJnt = cmds.listRelatives( bJnt, children = True, type = 'joint' )[0]
	
	aPos, bPos, cPos = cmds.xform( aJnt, ws = True, q = True, t = True), cmds.xform( bJnt, ws=True, q=True, t=True ), cmds.xform( cJnt, ws=True, q=True, t=True )
	aVec, bVec, cVec = om.MVector( aPos ), om.MVector( bPos ), om.MVector( cPos )
	
	polyFacet = cmds.polyCreateFacet( ch=True, tx=True, p=[aVec, bVec, cVec] )[0]
	plane = cmds.plane( s=10, p=[(aVec.x + bVec.x + cVec.x)/3, (aVec.y+bVec.y+cVec.y)/3, (aVec.z+bVec.z+cVec.z)/3] )
	cmds.delete( cmds.normalConstraint( polyFacet, plane, aimVector=[0,0,1], upVector=[0,1,0] ) )
	
	return polyFacet
Ejemplo n.º 31
0
    def build(self):
        """
        Build the osm file
        """
        print 'Building'

        # first get a group to put everything in
        bld_group = '_buildings'

        if not cmds.ls(bld_group):
            cmds.group(empty=True, n=bld_group)

        # create a something to store the number of the building we are on
        num_buildings = 0

        # go through our ways and find the buildings
        for way in self.ways:
            if 'building' in way.tags:

                positions = []

                for node_id in way.nodes:
                    node = self.nodes[node_id]
                    pos_xy = self.get_relative_coordinates(
                        [float(node.lat), float(node.lon)])
                    positions.append((pos_xy[0], pos_xy[1], 0))

                building = cmds.polyCreateFacet(p=positions)

                centre_pos = self.get_centre_pos(positions)
                cmds.xform(building[0], ws=True, piv=centre_pos)

                # make sure all the vertices have the correct normals
                for i in range(cmds.polyEvaluate(building[0], vertex=True)):
                    cmds.select('{}.vtx[{}]'.format(building[0], i))
                    cmds.polyNormalPerVertex(xyz=(0, 0, 1))

                new_building = cmds.rename(
                    building[0], 'building_{0:03d}'.format(num_buildings + 1))
                cmds.parent(new_building, bld_group)

                num_buildings += 1

        print 'Build {} buildings!'.format(num_buildings)
Ejemplo n.º 32
0
def off_translation(filename):

    print("Debut du parsing")
    f = open(filename, 'r')
    # On passe les lignes inutiles
    line = f.readline()
    line = f.readline()
    if line[0] == '#':
        line = f.readline()
        if line[0] == '#':
            line = f.readline()
    # On considere la ligne comme une liste de string separes par des espaces
    line = line.split(' ')
    nb_vert = int(line[0])
    nb_faces = int(line[1])
    list_vert = []
    list_faces = []
    # On remplit la liste des sommets
    for i in range(0, nb_vert):
        line = f.readline()
        line = line.split(' ')
        coord = [float(line[0]), float(line[1]), float(line[2])]
        list_vert.append(coord)
    line = f.readline()
    line = line.split(' ')
    # On remplit la liste des faces
    for i in range(0, nb_faces):
        index1, index2, index3 = int(line[1]), int(line[2]), int(line[3])
        points = [list_vert[index1], list_vert[index2], list_vert[index3]]
        list_faces.append(points)
        line = f.readline()
        line = line.split(' ')
    f.close()
    print("Parsing fini, debut de la creation du maillage")

    print(list_faces[0])
    # print(list_faces[1])
    obj = cm.polyCreateFacet(ch=False, p=list_faces[0])
    cm.select(obj)
    for i in range(1, nb_faces):
        cm.polyAppendVertex(a=list_faces[i])
    print("Maillage cree")
Ejemplo n.º 33
0
    def createPolygon(self, tis, *a):
        self.executeCondition()
        tis = cmds.treeView('tree_apsbPL', q=1, children=1)  # tree items
        if len(tis) < 3:
            cmds.warning('Position List most more than 3.')
            return 0
        sl = cmds.ls(selection=1)

        cpl = []  # created polygon name list
        for mn in sl:  # mesh name
            if (cmds.nodeType(mn) == 'transform'):
                c = cmds.listRelatives(mn, shapes=1, noIntermediate=1)
                if (len(c) == 0): cmds.warning('Selection most be polygon.')
                else: mn = c[0]
            elif (cmds.nodeType(mn) == 'mesh'):
                mns = mn.split('.')
                if len(mns) > 1: mn = mns[0]
            else: cmds.warning('Selection most be polygon.')

            pl = []  # position list
            for ti in tis:  # tree item
                xList = ti.split(',')
                xx = 0.0
                xy = 0.0
                xz = 0.0
                for sti in xList:  # splited tree item
                    vn = mn + '.' + sti  # vertex name
                    if cmds.objExists(vn):
                        yPos = cmds.xform(vn, q=1, translation=1, worldSpace=1)
                        xx = xx + yPos[0]
                        xy = xy + yPos[1]
                        xz = xz + yPos[2]
                xx = xx / len(xList)
                xy = xy / len(xList)
                xz = xz / len(xList)
                pl.append([xx, xy, xz])

            cpl.append(cmds.polyCreateFacet(point=[pl[0], pl[1], pl[2]])[0])
            for i in range(3, len(tis)):
                cmds.polyAppendVertex(a=[i - 2, i - 1, pl[i]])

        cmds.select(cpl, replace=1)
Ejemplo n.º 34
0
def createPolyFromPosList(posList):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates a poly from position list
    
    ARGUMENTS:
    posList(string) - list of positions
    
    RETURNS:
    Nothin
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    polyBuffer = mc.polyCreateFacet(p = posList,hole = False)
    newFaceVerts = (mc.ls ([polyBuffer[0]+'.vtx[*]'],flatten=True))
    for vert in newFaceVerts:
        cnt = newFaceVerts.index(vert)
        pos = posList[cnt]
        mc.xform(vert,t = [pos[0],pos[1],pos[2]],ws=True)
    return polyBuffer[0]
Ejemplo n.º 35
0
def createPolyFromPosList(posList):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates a poly from position list
    
    ARGUMENTS:
    posList(string) - list of positions
    
    RETURNS:
    Nothin
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    polyBuffer = mc.polyCreateFacet(p=posList, hole=False)
    newFaceVerts = (mc.ls([polyBuffer[0] + '.vtx[*]'], flatten=True))
    for vert in newFaceVerts:
        cnt = newFaceVerts.index(vert)
        pos = posList[cnt]
        mc.xform(vert, t=[pos[0], pos[1], pos[2]], ws=True)
    return polyBuffer[0]
Ejemplo n.º 36
0
def makeFaceWithHole():

    points = []

    # create the inital square
    points.append((-5, -5, 0))
    points.append((5, -5, 0))
    points.append((5, 5, 0))
    points.append((-5, 5, 0))

    # add empty point to start a hole
    points.append(())

    for i in range(32):
        theta = (math.pi * 2) / 32 * i
        x = math.cos(theta) * 2
        y = math.sin(theta) * 2
        points.append((x, y, 0))

    newFace = cmds.polyCreateFacet(p=points)
Ejemplo n.º 37
0
    def jntChainPlane(cls, jntLs):
        '''
		Create a plane conform to joint chain.
		'''

        # Get start, mid, end joint.
        startJnt = jntLs[0]
        midJnt = jntLs[int(len(jntLs) / 2)]
        endJnt = jntLs[-1]

        # Get world position of joints.
        startJntPos = cmds.xform(startJnt, q=True, t=True, ws=True)
        midJntPos = cmds.xform(midJnt, q=True, t=True, ws=True)
        endJntPos = cmds.xform(endJnt, q=True, t=True, ws=True)

        # Create a plane.
        plane = cmds.polyCreateFacet(n='jntUpVecPlane_geo',
                                     p=[startJntPos, midJntPos, endJntPos])[0]

        return plane
Ejemplo n.º 38
0
def makeFaceWithHole():
    points = []

    # Create the initial square
    points.append((-5, -5, 0))
    points.append((5, -5, 0))
    points.append((5, 5, 0))
    points.append((-5, 5, 0))

    # Add empty point to start a hole
    points.append(())

    for i in range(32):
        theta = (math.pi * 2) / 32 * i
        x = math.cos(theta)
        y = math.sin(theta)
        points.append((2 * x, 2 * y, 0))

    newFace = cmds.polyCreateFacet(p=points)
    cmds.polyTriangulate()
    cmds.polyQuad()  # Generally doesn't hurt anything
Ejemplo n.º 39
0
def positionPoleVectorControl(startJoint, endJoint, poleVectorNode, distance):
	"""NOTE: If each joint in your chain has more than 1 joint, make sure the joint that will be part of the IK chain, 
	are the first children, otherwise you will get bad results."""
	#figure out all the joints between startJoint and endJoint
	
	jointChainList = []
	jointChainList.append(startJoint)
	j = 0
	currentJoint = startJoint
	while j==0:
		currentJointChildren = cmds.listRelatives(currentJoint, c=1, type="joint")
		if len(currentJointChildren) > 1:
			cmds.warning("whoo, the specified start joint has more than 1 children, please choose another start joint")
		
			
		nextJoint = currentJointChildren[0]
		if nextJoint == endJoint:
			j=1
		else:
			jointChainList.append(nextJoint)
		currentJoint = nextJoint
	
	jointChainList.append(endJoint)
	
	#get position in space of each joint so we can create the polygon
	coordinatesList = []
	for j in jointChainList:
		jCoord = cmds.xform(j, q=1, ws=1, rp=1)
		coord = tuple(jCoord)
		coordinatesList.append(coord)
	
	polyPlane = cmds.polyCreateFacet( p=coordinatesList )[0]
	alignNodes(poleVectorNode, jointChainList[1])
	
	cmds.delete(cmds.geometryConstraint(polyPlane, poleVectorNode))
	cmds.delete(cmds.normalConstraint(polyPlane, poleVectorNode, upVector=[1, 0, 0], aimVector=[0, 0, 1]))
	
	cmds.xform(poleVectorNode, objectSpace=1, relative=1, t=[distance, distance, 0])
	
	cmds.delete(polyPlane)
Ejemplo n.º 40
0
def convexHull(pointList):
    """
	from maya import cmds
	import sys
	sys.path.insert(0, '/Users/jarlske/Documents/scripts/python/jm_maya/mesh/')
	import delaunay
	reload(delaunay)

	sel = cmds.ls(sl=1)
	pointList = []
	for each in sel:
	    vtxLen = cmds.polyEvaluate(each, vertex=1)
	    for i in range(0, vtxLen):
	        pointList.append(cmds.xform('{0}.vtx[{1}]'.format(each, str(i)), q=1, t=1 ,ws=1))
	geo = delaunay.convexHull(pointList)
	"""
    points = numpy.array(pointList)
    hull = ConvexHull(points)
    facetList = []
    for each in hull.simplices:
        indexList = each.tolist()
        xpoint = [
            pointList[indexList[0]][0], pointList[indexList[0]][1],
            pointList[indexList[0]][2]
        ]
        ypoint = [
            pointList[indexList[1]][0], pointList[indexList[1]][1],
            pointList[indexList[1]][2]
        ]
        zpoint = [
            pointList[indexList[2]][0], pointList[indexList[2]][1],
            pointList[indexList[2]][2]
        ]
        facetList.append(
            cmds.polyCreateFacet(ch=False, p=[xpoint, ypoint, zpoint])[0])
    poly = cmds.polyUnite(facetList, ch=False, mergeUVSets=True)
    cmds.polyMergeVertex(poly, ch=False)
    cmds.polyNormal(poly, normalMode=2, userNormalMode=0, ch=False)
    cmds.select(cl=True)
    return poly
    def alignKneeVectors(self, *args):

        sides = ["_L_", "_R_"]

        for i in sides:

            kneeCon = cmds.ls(self.prefix + i + "Knee_Con")

            cmds.parent(kneeCon, w=True)

            heelPos = cmds.xform(cmds.ls(self.prefix + i + "INV_Heel_Jnt",
                                         type='joint'),
                                 q=True,
                                 t=True,
                                 ws=True)
            hipPos = cmds.xform(cmds.ls(self.prefix + i + "Hip_Jnt",
                                        type='joint'),
                                q=True,
                                t=True,
                                ws=True)
            kneePos = cmds.xform(cmds.ls(self.prefix + i + "Knee_Jnt",
                                         type='joint'),
                                 q=True,
                                 t=True,
                                 ws=True)

            createPolyPoint = cmds.polyCreateFacet(p=[(hipPos), (kneePos),
                                                      (heelPos)],
                                                   ch=False)
            conPointConstraint = cmds.pointConstraint(
                cmds.ls(self.prefix + i + "Knee_Jnt", type='joint'), kneeCon)
            nConstraint = cmds.normalConstraint(createPolyPoint[0], kneeCon)
            cmds.delete(conPointConstraint)
            cmds.delete(nConstraint)
            cmds.delete(createPolyPoint)

            cmds.move(0, 0, 0.3 * self.conRadius, kneeCon, os=True, r=True)
Ejemplo n.º 42
0
        def createSurface( self , name , side , modular ,  *point ):
                pointPos = []
                clusterList = []
                shaderName = name+side+modular+'surface_shader'

                for x in point:
                        pos = self.getSpace(x,type='translate')
                        pointPos.append(pos)

                # create surface.
                surfaceObj = mc.rename( mc.polyCreateFacet(p=pointPos)[0] , name+side+modular+'_surface')
                mc.setAttr(surfaceObj+'.overrideEnabled' , 1)
                mc.setAttr(surfaceObj+'.overrideDisplayType' , 2)

                if mc.objExists('worldPos_loc'):
                        mc.parent(surfaceObj , 'worldPos_loc')
                else:
                        pass

                mc.select(surfaceObj )
                mel.eval('DeleteHistory')
                mc.setAttr(surfaceObj +'.inheritsTransform' , 0)
                mc.select(cl=1)

                # connect surface with points.....
                for i in range( len(pointPos) ):
                        clusterObj = mc.rename( mc.cluster(surfaceObj+'.vtx[%s]'%(i) )[1]  ,  name+side+modular+'_%scluster'%(i)  )
                        mc.parent(clusterObj , point[i])
                        mc.setAttr(clusterObj+'.visibility' , 0)
                        clusterList.append(clusterObj)

                #set surface shader.
                self.appointShader( name, side , modular , shaderName , surfaceObj )
                mc.setAttr(shaderName +'.color' , 0.324643,0.686275,0.29604 , type='double3' , )
                mc.setAttr(shaderName +'.transparency' , 0.422766 ,0.422766 ,0.422766 , type='double3' , )

                return surfaceObj , clusterList
Ejemplo n.º 43
0
def lsOrientJointsToPlane(jntList, downVector=[1,0,0], normalVector=[0,0,1]):
    '''
    arguments:
    jntList - [startJnt, midJnt, endJnt]
    downVector (optional) - vector that points to the child joint, defaults to +X
    normalVector (optional) - vector for axis of rotation, defaults to +Z
    
    todo:
    1. options for orienting startJnt and endJnt when necessary
    2. use API for calculating vectors, instead of creating arbitrary polys and constraints... though this should work for now...
    ''' 
    
    # get joint positions
    startJntPos = mc.xform(jntList[0], q=1, ws=1, t=1)
    midJntPos = mc.xform(jntList[1], q=1, ws=1, t=1)
    endJntPos = mc.xform(jntList[2], q=1, ws=1, t=1)
    
    # create poly to act as rotate plane
    tempPoly = mc.polyCreateFacet(ch=0, p=[startJntPos, midJntPos, endJntPos], n="tempPoly_getNormal")
    
    # create locator to get normal vector 
    tempLoc = mc.spaceLocator(n="tempLoc_getNormal")[0]
    mc.xform(tempLoc, ws=1, t=midJntPos)
    normalCons = mc.normalConstraint(tempPoly, tempLoc) # default: X-axis aligns with normal vector
    mc.delete(normalCons)
    
    # orient midJnt (jntList[1])
    mc.move(1,0,0, tempLoc, os=1, r=1)
    mc.parent(jntList[2], w=1)
    aimCons = mc.aimConstraint(jntList[2], jntList[1], aim=downVector, u=normalVector, wuo=tempLoc, wut=2, wu=[1,0,0])
    mc.delete(aimCons)
    mc.makeIdentity(jntList[1], a=1, r=1)
    mc.parent(jntList[2],jntList[1])
        
    # cleanup
    mc.delete(tempPoly, tempLoc)
Ejemplo n.º 44
0
def fill_cylinder_with_guides(mesh, follicle_grid=4, pattern_shrink=0.0):  
    vloops = mesh_utils.get_cylinder_vert_loops(mesh)
    first_vloop = vloops[0]
    #print first_vloop
    b_positions = []
    for vl in first_vloop:
        b_positions.append( cmds.pointPosition( vl ))

    # I get an ordered array of positions to access later.
    tube_ordered_pos = []
    for i,vert_loop in enumerate(vloops):
        tube_ordered_pos.append([])
        for vid in vert_loop:
            #lx.out(vid)
            pos= cmds.pointPosition( vid )
            tube_ordered_pos[i].extend(pos)
            
    #b_positions.extend(tube_ordered_pos[0])
    
    
    root_disc = cmds.polyCreateFacet(ch=False, tx=1, s=1, p=b_positions)
    #print root_disc
    
    ### I will find the normal of the "face" described by the vertices in the first border/edgeloop
    # Create list of border Point(s)
    b_points = []
    for bpos in b_positions:
        b_points.append(Point(bpos))
    # Calculate average point
    av_point = Point()
    for pt in b_points:
        av_point = av_point+pt
    av_point.div_by_value(len(b_points))
    #print av_point.get_list()
    # Calculate average normal
    t_normals = []
    av_normal = Point()
    for i in range(len(b_points)):
        # Get triangle normal
        nm = get_triangle_normal(av_point,  b_points[i] , b_points[(i+1)%len(b_points)])
        t_normals.append(nm)
    for tn in t_normals:
        av_normal = av_normal+tn
    av_normal.div_by_value(len(b_points))
    av_normal.normalize()
    #print av_normal.get_list()
    #cmds.create
    
    loc_nrm = cmds.spaceLocator(name='cylinder_base_nrm')
    cmds.xform(loc_nrm, ws=True, t=av_normal.get_list() )
    loc_base = cmds.spaceLocator(name='cylinder_disc_rotator')
    ac = cmds.aimConstraint(loc_nrm[0], loc_base[0], mo=False, aimVector=[0,1,0], upVector=[0,1,0], worldUpType="scene" )
    rot = cmds.xform(loc_base, q=True, ws=True, rotation=True)
    #print rot
    cmds.delete(ac)
    #cmds.delete(loc_base)
    cmds.delete(loc_nrm)
    # Move the cylinder base disc to the origin, and unrotate it
    # The disc will have the average point at [0,0,0], and its normal pointing Y
    av_pos = av_point.get_list()
    cmds.xform(root_disc, relative=True, t=[-av_pos[0], -av_pos[1], -av_pos[2]])
    cmds.xform(root_disc, ws=True, absolute=True, rp=[0,0,0], sp=[0,0,0])
    cmds.parent(root_disc, loc_base)
    cmds.xform(loc_base, ws=True, absolute=True, rotation=[0,0,0])
    
    # Finally get the disc position on the xz plane
    n_disc_verts = cmds.polyEvaluate(root_disc, vertex=True)
    xz_disc_positions = cmds.xform('%s.vtx[0:%s]' % (root_disc[0],(n_disc_verts-1)), q=True, ws=True, t=True)


    ### CALCULATE BARICENTRIC COORDS
    unrot_bbox = cmds.exactWorldBoundingBox( root_disc[0] )
    #print unrot_bbox
    # calculate the candidate curve roots (follicle) positions
    candidate_follicles= pattern_honeycomb_points(unrot_bbox, shrink=pattern_shrink, grid_size=follicle_grid)
    #DEBUG follicles
    '''
    for fc in candidate_follicles:
        fol = cmds.spaceLocator()
        cmds.xform(fol, ws=True, t=fc)
    '''
    # From now on, I have to test if the candidate follicle positions hit the triangles of the unrotated face
    # ...and retrieve thei baricentric coords
    # I assume that the baricenter of the unrotated face is ath the origin (0,0,0)
    n_triangles = len(first_vloop)
    # bc_coords will containa a list of list
    # every list will contain the bc coords for every triangle describig the section of a tube
    bcoords = []
    for i in range(n_triangles):
        # I initialiaze the list for every triangle
        bcoords.append([])
        
    for counter, cf in enumerate(candidate_follicles):
        # I test that my current candidate point is inside the unrotated face
        cf_pt = Point(cf)
        #print('Candidate follicle: %s  |     %s,  %s,  %s' % (counter, cf_pt.x, cf_pt.y, cf_pt.z))
        for i in range(n_triangles):
            j = (i+1)%n_triangles # This ensure that the second vert will be 0 when i=n_triangles-1
            first_vert_pt = Point(xz_disc_positions[i*3],xz_disc_positions[i*3+1],xz_disc_positions[i*3+2])
            secnd_vert_pt = Point(xz_disc_positions[j*3],xz_disc_positions[j*3+1],xz_disc_positions[j*3+2])
            u,v,w,hit_test = bc.point_in_a_triangle_test(cf_pt, first_vert_pt, secnd_vert_pt, Point(0.0,0.0,0.0))
            if hit_test:
                bcoords[i].append([u,v,w])
                #print('HIT TEST TRIANGLE %s  |   u:%s  v:%s  w:%s' % (i,u,v,w))
                ###DEBUG HIT TEST
                #fol = cmds.spaceLocator()
                #cmds.xform(fol, ws=True, t=cf)
                break

    # I find the baricenters of every loop
    baricenters = []
    for i in range(len(vloops)):
        baricenter = Point()
        for j in range(len(first_vloop)):
            xx=(tube_ordered_pos[i][j*3])
            yy=(tube_ordered_pos[i][j*3+1])
            zz=(tube_ordered_pos[i][j*3+2])
            baricenter.add_point(Point(xx,yy,zz))
        baricenter.div_by_value(float(len(first_vloop)))
        baricenters.append(baricenter.get_list())
        
    # I fill the triangles with the curves, according the baricentric coords
    out_curves = []
    for i in range(n_triangles):
        for uvw in bcoords[i]:
            curve_vert_pos = []
            for j in range(len(vloops)):
                s = (i+1)%n_triangles
                first_vert_pt= Point(tube_ordered_pos[j][i*3], tube_ordered_pos[j][i*3+1], tube_ordered_pos[j][i*3+2])
                secnd_vert_pt= Point(tube_ordered_pos[j][s*3], tube_ordered_pos[j][s*3+1], tube_ordered_pos[j][s*3+2])
                third_vert_pt= Point(baricenters[j])
                pos = bc.triangle_point_coords(first_vert_pt,secnd_vert_pt,third_vert_pt,uvw[0],uvw[1],uvw[2]).get_list()
                curve_vert_pos.append(pos)
            out_curves.append(curve_vert_pos)
    
    cmds.delete(loc_base)
    gen_curves = []
    for ocp in out_curves:
        gen_crv = createCurve(2, ocp)
        gen_curves.append(gen_crv)
    # Group the curves
    curve_prefix_grp= mesh
    if "|" in mesh:
        curve_prefix_grp = curve_prefix_grp.rpartition('|')[2]
    cmds.group(gen_curves, name="%s_curves" % curve_prefix_grp)
    return(gen_curves)
Ejemplo n.º 45
0
"""
Author: Jennifer Conley
Date Modified: 9/10/11

Description: A script used to quickly create a plane for the correct placement
of ik pv icons from a joint chain selection.


How to run:
import ik_pv
reload (ik_pv)


"""
import maya.cmds as cmds

cmds.select(hierarchy=True)

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

for each in sel:
	space = cmds.xform(each, q=True, t=True, ws=True)
	position_list.append(space)
	
	
print position_list
cmds.polyCreateFacet(ch=True, tx=1, s=1, p=position_list)

Ejemplo n.º 46
0
def pointSampleWeight(samplePt, pntList, weightCalc=[True, True, True], prefix=''):
    """
    """
    # Check prefix
    if not prefix: prefix = 'triSampleWeight'

    # Get tri points
    posList = [cmds.xform(pntList[0], q=True, ws=True, rp=True),
               cmds.xform(pntList[1], q=True, ws=True, rp=True),
               cmds.xform(pntList[2], q=True, ws=True, rp=True)]

    # Build pntFace mesh
    pntFace = cmds.polyCreateFacet(p=posList, n=prefix + '_sample_mesh')[0]
    cmds.setAttr(pntFace + '.inheritsTransform', 0, l=True)

    # Attach triPt locator to pntFace mesh
    pntLoc = glTools.utils.mesh.locatorMesh(pntFace, prefix=prefix)

    # Attach follow pt
    followLoc = cmds.spaceLocator(n=prefix + '_follow_locator')[0]
    followGeoCon = cmds.geometryConstraint(pntFace, followLoc)
    followPntCon = cmds.pointConstraint(samplePt, followLoc)

    # Calculate triArea
    triEdge1_pma = cmds.createNode('plusMinusAverage', n=prefix + '_triEdge1Vec_plusMinusAverage')
    triEdge2_pma = cmds.createNode('plusMinusAverage', n=prefix + '_triEdge2Vec_plusMinusAverage')
    cmds.setAttr(triEdge1_pma + '.operation', 2)  # Subtract
    cmds.setAttr(triEdge2_pma + '.operation', 2)  # Subtract
    cmds.connectAttr(pntLoc[1] + '.worldPosition[0]', triEdge1_pma + '.input3D[0]', f=True)
    cmds.connectAttr(pntLoc[0] + '.worldPosition[0]', triEdge1_pma + '.input3D[1]', f=True)
    cmds.connectAttr(pntLoc[2] + '.worldPosition[0]', triEdge2_pma + '.input3D[0]', f=True)
    cmds.connectAttr(pntLoc[0] + '.worldPosition[0]', triEdge2_pma + '.input3D[1]', f=True)

    triArea_vpn = cmds.createNode('vectorProduct', n=prefix + '_triArea_vectorProduct')
    cmds.setAttr(triArea_vpn + '.operation', 2)  # Cross Product
    cmds.connectAttr(triEdge1_pma + '.output3D', triArea_vpn + '.input1', f=True)
    cmds.connectAttr(triEdge2_pma + '.output3D', triArea_vpn + '.input2', f=True)

    triArea_dist = cmds.createNode('distanceBetween', n=prefix + '_triArea_distanceBetween')
    cmds.connectAttr(triArea_vpn + '.output', triArea_dist + '.point1', f=True)

    # Calculate triPt weights
    for i in range(3):

        # Check weight calculation (bool)
        if weightCalc[i]:
            # Calculate triArea
            pntEdge1_pma = cmds.createNode('plusMinusAverage', n=prefix + '_pt' + str(i) + 'Edge1Vec_plusMinusAverage')
            pntEdge2_pma = cmds.createNode('plusMinusAverage', n=prefix + '_pt' + str(i) + 'Edge2Vec_plusMinusAverage')
            cmds.setAttr(pntEdge1_pma + '.operation', 2)  # Subtract
            cmds.setAttr(pntEdge2_pma + '.operation', 2)  # Subtract
            cmds.connectAttr(pntLoc[(i + 1) % 3] + '.worldPosition[0]', pntEdge1_pma + '.input3D[0]', f=True)
            cmds.connectAttr(followLoc + '.worldPosition[0]', pntEdge1_pma + '.input3D[1]', f=True)
            cmds.connectAttr(pntLoc[(i + 2) % 3] + '.worldPosition[0]', pntEdge2_pma + '.input3D[0]', f=True)
            cmds.connectAttr(followLoc + '.worldPosition[0]', pntEdge2_pma + '.input3D[1]', f=True)

            pntArea_vpn = cmds.createNode('vectorProduct', n=prefix + '_pt' + str(i) + 'Area_vectorProduct')
            cmds.setAttr(pntArea_vpn + '.operation', 2)  # Cross Product
            cmds.connectAttr(pntEdge1_pma + '.output3D', pntArea_vpn + '.input1', f=True)
            cmds.connectAttr(pntEdge2_pma + '.output3D', pntArea_vpn + '.input2', f=True)

            pntArea_dist = cmds.createNode('distanceBetween', n=prefix + '_pt' + str(i) + 'Area_distanceBetween')
            cmds.connectAttr(pntArea_vpn + '.output', pntArea_dist + '.point1', f=True)

            # Divide ptArea by triArea to get weight
            pntWeight_mdn = cmds.createNode('multiplyDivide', n=prefix + '_pt' + str(i) + 'Weight_multiplyDivide')
            cmds.setAttr(pntWeight_mdn + '.operation', 2)  # Divide
            cmds.connectAttr(pntArea_dist + '.distance', pntWeight_mdn + '.input1X', f=True)
            cmds.connectAttr(triArea_dist + '.distance', pntWeight_mdn + '.input2X', f=True)

            # Add weight attribute to pntLoc
            cmds.addAttr(pntLoc[i], ln='weight', min=0.0, max=1.0, dv=0.0)
            cmds.connectAttr(pntWeight_mdn + '.outputX', pntLoc[i] + '.weight', f=True)

    # Group mesh locators
    pntLoc_grp = cmds.group(pntLoc, n=prefix + '_3Point_grp')
    cmds.parent(pntFace, pntLoc_grp)

    # Return result
    return [pntLoc, pntFace, pntLoc_grp]
Ejemplo n.º 47
0
if len(cubeList) > 0:
    cmds.delete(cubeList)

all_poly = []

for lst in buildings_xy:
    tmp = []

    for i in lst[0]:
        (x, z) = i
        x /= -100
        z /= 100
        y = 0
        tmp.append((x, y, z))
    h = lst[1]
    res = cmds.polyCreateFacet(p=tmp, name='buildingpoly#')

    all_poly.append(res)
    thickness = random.uniform(0.1, 0.2)
    assert h >= 0

    normals = cmds.polyInfo(res[0], fn=1)
    normal = float(normals[0].split(":")[1].split()[1])

    # For reversed normals, Just redraw in anticlockwise
    if normal < 0:
        cmds.delete(res[0])
        tmp.reverse()
        res = cmds.polyCreateFacet(p=tmp, name='buildingpoly#')
        normals = cmds.polyInfo(res[0], fn=1)
        normal = float(normals[0].split(":")[1].split()[1])
Ejemplo n.º 48
0
def pointSampleWeight(samplePt, pntList, weightCalc=[True, True, True], prefix=""):
    """
	"""
    # Check prefix
    if not prefix:
        prefix = "triSampleWeight"

    # Get tri points
    posList = [
        mc.xform(pntList[0], q=True, ws=True, rp=True),
        mc.xform(pntList[1], q=True, ws=True, rp=True),
        mc.xform(pntList[2], q=True, ws=True, rp=True),
    ]

    # Build pntFace mesh
    pntFace = mc.polyCreateFacet(p=posList, n=prefix + "_sample_mesh")[0]
    mc.setAttr(pntFace + ".inheritsTransform", 0, l=True)

    # Attach triPt locator to pntFace mesh
    pntLoc = glTools.utils.mesh.locatorMesh(pntFace, prefix=prefix)

    # Attach follow pt
    followLoc = mc.spaceLocator(n=prefix + "_follow_locator")[0]
    followGeoCon = mc.geometryConstraint(pntFace, followLoc)
    followPntCon = mc.pointConstraint(samplePt, followLoc)

    # Calculate triArea
    triEdge1_pma = mc.createNode("plusMinusAverage", n=prefix + "_triEdge1Vec_plusMinusAverage")
    triEdge2_pma = mc.createNode("plusMinusAverage", n=prefix + "_triEdge2Vec_plusMinusAverage")
    mc.setAttr(triEdge1_pma + ".operation", 2)  # Subtract
    mc.setAttr(triEdge2_pma + ".operation", 2)  # Subtract
    mc.connectAttr(pntLoc[1] + ".worldPosition[0]", triEdge1_pma + ".input3D[0]", f=True)
    mc.connectAttr(pntLoc[0] + ".worldPosition[0]", triEdge1_pma + ".input3D[1]", f=True)
    mc.connectAttr(pntLoc[2] + ".worldPosition[0]", triEdge2_pma + ".input3D[0]", f=True)
    mc.connectAttr(pntLoc[0] + ".worldPosition[0]", triEdge2_pma + ".input3D[1]", f=True)

    triArea_vpn = mc.createNode("vectorProduct", n=prefix + "_triArea_vectorProduct")
    mc.setAttr(triArea_vpn + ".operation", 2)  # Cross Product
    mc.connectAttr(triEdge1_pma + ".output3D", triArea_vpn + ".input1", f=True)
    mc.connectAttr(triEdge2_pma + ".output3D", triArea_vpn + ".input2", f=True)

    triArea_dist = mc.createNode("distanceBetween", n=prefix + "_triArea_distanceBetween")
    mc.connectAttr(triArea_vpn + ".output", triArea_dist + ".point1", f=True)

    # Calculate triPt weights
    for i in range(3):

        # Check weight calculation (bool)
        if weightCalc[i]:

            # Calculate triArea
            pntEdge1_pma = mc.createNode("plusMinusAverage", n=prefix + "_pt" + str(i) + "Edge1Vec_plusMinusAverage")
            pntEdge2_pma = mc.createNode("plusMinusAverage", n=prefix + "_pt" + str(i) + "Edge2Vec_plusMinusAverage")
            mc.setAttr(pntEdge1_pma + ".operation", 2)  # Subtract
            mc.setAttr(pntEdge2_pma + ".operation", 2)  # Subtract
            mc.connectAttr(pntLoc[(i + 1) % 3] + ".worldPosition[0]", pntEdge1_pma + ".input3D[0]", f=True)
            mc.connectAttr(followLoc + ".worldPosition[0]", pntEdge1_pma + ".input3D[1]", f=True)
            mc.connectAttr(pntLoc[(i + 2) % 3] + ".worldPosition[0]", pntEdge2_pma + ".input3D[0]", f=True)
            mc.connectAttr(followLoc + ".worldPosition[0]", pntEdge2_pma + ".input3D[1]", f=True)

            pntArea_vpn = mc.createNode("vectorProduct", n=prefix + "_pt" + str(i) + "Area_vectorProduct")
            mc.setAttr(pntArea_vpn + ".operation", 2)  # Cross Product
            mc.connectAttr(pntEdge1_pma + ".output3D", pntArea_vpn + ".input1", f=True)
            mc.connectAttr(pntEdge2_pma + ".output3D", pntArea_vpn + ".input2", f=True)

            pntArea_dist = mc.createNode("distanceBetween", n=prefix + "_pt" + str(i) + "Area_distanceBetween")
            mc.connectAttr(pntArea_vpn + ".output", pntArea_dist + ".point1", f=True)

            # Divide ptArea by triArea to get weight
            pntWeight_mdn = mc.createNode("multiplyDivide", n=prefix + "_pt" + str(i) + "Weight_multiplyDivide")
            mc.setAttr(pntWeight_mdn + ".operation", 2)  # Divide
            mc.connectAttr(pntArea_dist + ".distance", pntWeight_mdn + ".input1X", f=True)
            mc.connectAttr(triArea_dist + ".distance", pntWeight_mdn + ".input2X", f=True)

            # Add weight attribute to pntLoc
            mc.addAttr(pntLoc[i], ln="weight", min=0.0, max=1.0, dv=0.0)
            mc.connectAttr(pntWeight_mdn + ".outputX", pntLoc[i] + ".weight", f=True)

            # Group mesh locators
    pntLoc_grp = mc.group(pntLoc, n=prefix + "_3Point_grp")
    mc.parent(pntFace, pntLoc_grp)

    # Return result
    return [pntLoc, pntFace, pntLoc_grp]
Ejemplo n.º 49
0
def generate(pts):
    """Takes in a list of tuples (set of 3D points) and generates a polygon model"""
    cmds.polyCreateFacet(name="shirt", p=points)
    cmds.polyTriangulate()
    cmds.polySubdivideFacet(dv=SUBDIVISIONS)
    cmds.polyTriangulate()
Ejemplo n.º 50
0
def drawTriangle(mesh, v1, v2, v3):
    p1 = getVertexPosition(mesh, v1)
    p2 = getVertexPosition(mesh, v2)
    p3 = getVertexPosition(mesh, v3)
    cmds.polyCreateFacet(p =(p1,p2,p3), n = 'triangle_' + mesh)
    cmds.parent(mesh, 'triangle_' + mesh)