コード例 #1
0
ファイル: spiderWebCreator.py プロジェクト: skarone/PipeL
def createCurveaBasedOnLocator( prevLoc, loc, baseName, hrsSys ):
	leastSquaresMod = mn.createNode( 'leastSquaresModifier' )
	origCurv = crv.Curve( mc.curve( d = 1, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
	index = mm.eval( 'getNextFreeMultiIndex( "'+ hrsSys.name +'.inputHair", 0 )' )
	origCurv.name = 'spiderWeb_base_'+ baseName + '_' + str( index ) + '_CRV'
	mc.rebuildCurve( origCurv.name, rpo = 1, rt = 0, end = 1, kr = 0, kcp = 1, kep = 1, kt =0, s= 4, d = 1, tol = 0.01  )
	origCurv.a.intermediateObject.v = 1
	controledCurv = origCurv.duplicate()
	origCurv.shape.attr( 'worldSpace[0]' ) >> leastSquaresMod.a.inputNurbsObject
	prevLoc.attr( 'worldPosition[0]')      >> leastSquaresMod.attr( 'pointConstraint[0].pointPositionXYZ' )
	leastSquaresMod.attr( 'pointConstraint[0].pointConstraintU' ).v = 0
	loc.attr( 'worldPosition[0]')          >> leastSquaresMod.attr( 'pointConstraint[1].pointPositionXYZ' )
	leastSquaresMod.attr( 'pointConstraint[1].pointConstraintU' ).v = 1
	leastSquaresMod.a.outputNurbsObject    >> controledCurv.shape.a.create
	controledCurv.shape.attr( 'worldMatrix[0]' ) >> leastSquaresMod.a.worldSpaceToObjectSpace
	fol = mn.createNode( 'follicle' )
	fol.a.restPose.v = 1
	fol.a.startDirection.v = 1
	fol.a.pointLock.v = 3
	fol.a.degree.v = 3
	fol.a.sampleDensity.v = 3
	fol.a.outHair >> hrsSys.attr( 'inputHair[' + str( index ) + ']' )
	hrsSys.attr( 'outputHair[' + str( index ) + ']' ) >> fol.a.currentPosition
	controledCurv.shape.attr( 'worldSpace[0]' ) >> fol.a.startPosition
	curv = crv.Curve( mc.curve( d = 3, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
	curv.name = 'spiderWeb_' + baseName + '_' + str( index ) + '_CRV'
	fol.a.outCurve >> curv.a.create
	folPar = fol.parent
	folPar.name = 'spiderWeb_' + baseName + '_' + str( index ) + '_FOL'
	return curv, folPar
コード例 #2
0
ファイル: eyes.py プロジェクト: skarone/PipeL
	def _createPerEye(self, side, geos ):
		mc.select( geos )
		clu = mn.Node( mc.cluster( n = side + '_Eye_CLU' )[1] )
		print clu.name
		mc.select( geos )
		lat = mn.Nodes( mc.lattice( n = side + '_Eye_LAT', objectCentered = True ) )
		ctl = crv.Curve( side + '_Eye_ctl' )
		ctl.create( 'circleZ' )
		print ctl.name
		par = mn.Node( mc.parentConstraint( clu, ctl, mo = False )[0])
		par.delete()
		ctl.a.tz.v = self.distance_control_sb.value() + ctl.a.tz.v
		mc.makeIdentity( ctl, a = True, t = 1, r = 1, s = 1 )
		loc = mn.createNode( 'locator' ).parent
		loc.name = side + '_Eye_Top_Loc'
		par = mn.Node( mc.aimConstraint( ctl, clu, mo = True, aimVector=[1,0,0],
										upVector=[0,1,0], worldUpType='object',
										worldUpObject=loc )[0])
		trf = mn.createNode( 'transform' )
		trf.name = side + '_Eye_Def_grp'
		lat[1].parent = trf
		lat[2].parent = trf
		clu.parent = trf
		loc.parent = trf
		return trf, ctl
コード例 #3
0
ファイル: stickyControl.py プロジェクト: skarone/PipeL
	def create(self):
		"""create Control system
		1- Create Joint on position
		2- Create Muscle Constraint
		3- Create Curve Control
		4- Make Connections
		"""
		self.rivet = self._createConstraint()
		self._createJoint()
		control = self._createControl()
		trf.snap( self.rivet.name , control.name )
		nullTrf = mn.createNode( 'transform' )
		nullTrf.name = self.name + '_baseControl'
		trf.snap( self.rivet.name , nullTrf.name )
		nullTrf.parent = self.rivet
		control.parent = nullTrf
		#make connections
		multi = mn.createNode( 'multiplyDivide' )
		multi.name = self.name + '_multi'
		multi.a.input2.v = [-1,-1,-1]
		multi.a.output >> nullTrf.a.translate
		control.a.t >> multi.a.input1
		control.a.t >> self.skinJoint.a.t
		control.a.r >> self.skinJoint.a.r
		control.a.s >> self.skinJoint.a.s
コード例 #4
0
ファイル: head.py プロジェクト: skarone/PipeL
	def __init__(self, objs = [], vertices = []):
		self.objs = objs
		self.vertices = vertices
		#lattice  -divisions 2 3 2 -objectCentered true  -ol 1;
		#mc.select( self.objs, self.vertices )
		#CREATION
		grp = mn.Node( mc.group( n = "head_toon_GRP", em = True ) )
		deGrp = mn.Node( mc.group( n = "head_toon_deformer_GRP", em = True ) )
		deGrp.parent = grp
		deGrp.a.v.v = False
		deGrp.a.v.locked = True
		latNods = mc.lattice( self.objs, self.vertices, divisions = [ 2,3,2], objectCentered = True, ol = 1, n = 'head_toon_LAT' )
		latBase = mn.Node( latNods[2] )
		latBase.parent = deGrp
		lat = mn.Node( latNods[1] )
		lat.parent = deGrp
		#mc.select( lat + ".pt[0:1][2][0]", lat + ".pt[0:1][2][1]" )
		topClus = mn.Node( mc.cluster(  lat.shape.name + ".pt[0:1][2][0]", lat.shape.name + ".pt[0:1][2][1]", n = 'top_face_toon_CLU' )[1] )
		topClus.a.v.v = False
		topClus.a.v.locked = True
		#mc.select( lat + ".pt[0:1][1][0]", lat + ".pt[0:1][1][1]" )
		midClus = mn.Node( mc.cluster(  lat.shape.name + ".pt[0:1][1][0]", lat.shape.name + ".pt[0:1][1][1]", n = 'mid_face_toon_CLU' )[1] )
		#mc.select( lat + ".pt[0:1][0][0]", lat + ".pt[0:1][0][1]" )
		lowClus = mn.Node( mc.cluster(  lat.shape.name + ".pt[0:1][0][0]", lat.shape.name + ".pt[0:1][0][1]", n = 'low_face_toon_CLU' )[1] )
		ctl = crv.Curve( "head_toon_CTL" )
		ctl = ctl.create( "sphere" )
		ctl.a.t.v = topClus.worldPosition
		mc.makeIdentity( ctl.name, apply = True, t = 1, r = 1, s = 1, n = 2 )
		topClus.parent = ctl
		midClus.parent = deGrp
		lowClus.parent = deGrp
		ctl.parent = grp
		#CONSTRAINS
		midClus.a.r >> topClus.a.r
		mc.pointConstraint( topClus.name, lowClus.name, midClus.name, mo = True )
		#SCALE FOR MID CLUSTER
		dist = mn.createNode( 'distanceBetween', n = 'head_toon_DIS' )
		ctl.a.worldMatrix >> dist.a.inMatrix1
		ctl.a.rp >> dist.a.point1
		lowClus.a.worldMatrix >> dist.a.inMatrix2
		lowClus.a.rp >> dist.a.point2
		mul = mn.createNode( 'multiplyDivide', n = 'head_toon_scale_MUL' )
		mul.a.input1.v = [dist.a.distance.v]*3
		mul.a.operation.v = 2
		dist.a.distance >> mul.a.input2X
		dist.a.distance >> mul.a.input2Y
		dist.a.distance >> mul.a.input2Z
		mul.a.output >> midClus.a.s
		#AIM CONSTRAINT
		upLocGrp = mn.Node( mc.group( n = "head_upVector_GRP", em = True ) )
		upLocGrp.a.t.v = midClus.worldPosition
		mc.makeIdentity( upLocGrp.name, apply = True, t = 1, r = 1, s = 1, n = 2 )
		upLocGrp.parent = deGrp
		mc.orientConstraint( ctl.name, lowClus.name, upLocGrp.name, mo = True )
		upLoc = mn.Node( mc.spaceLocator( n = 'head_upVector_LOC' )[0] )
		upLoc.a.t.v = midClus.worldPosition
		upLoc.a.tz.v = upLoc.a.tz.v + 5
		mc.aimConstraint( topClus.name, midClus.name, mo = True, weight = 1, aimVector = [1, 0, 0], upVector = [0, 1, 0], worldUpType = "object", worldUpObject = upLoc.name )
		upLoc.parent = upLocGrp
		mc.pointConstraint( topClus.name, lowClus.name, upLoc.name, mo = True )
コード例 #5
0
ファイル: hairSystem.py プロジェクト: Rotomator/PipeL
    def create(self):
        """create hairsystem for lock"""
        numFace = mc.polyEvaluate(self.mesh.shape.name, f=True)
        numVert = mc.polyEvaluate(self.mesh.shape.name, v=True)
        if not self.hairSystem:
            print 'There is no hairSystem assigned to this HairLock --> init with one or assign one.... '
        if not numFace % 2 or not numVert == (numFace + 3):
            print 'This mesh dosen\'t have odd number of faces', self.mesh.name, 'SKYPING'
            return
        self._curveMesh = mn.createNode('curvesFromMesh')
        self._curveMesh.name = self.mesh.name + '_curveMesh'
        self.mesh.shape.a.outMesh >> self._curveMesh.a.inMesh
        self.mesh.shape.a.worldMatrix >> self._curveMesh.a.inWorldMatrix
        for i in range(5):
            hairCurve = mn.createNode('nurbsCurve')
            hairCurveParent = hairCurve.parent
            hairCurveParent.name = self.mesh.name + '_%i' % i + '_crv'
            hairCurve = hairCurveParent.shape
            self._curveMesh.attr('outCurve[%i' % i + ']') >> hairCurve.a.create

            follicle = mn.createNode('follicle')
            folliclePar = follicle.parent
            folliclePar.name = self.mesh.name + '_%i' % i + '_foll'
            follicle = folliclePar.shape
            hairSustemOutHairSize = self.hairSystem.a.outputHair.size
            follicle.a.outHair >> self.hairSystem.attr(
                'inputHair[%i' % hairSustemOutHairSize + ']')
            #follicle.a.outHair >> self.hairSystem.attr( 'inputHair[%i'%i + ']' )
            hairCurve.a.worldSpace >> follicle.a.startPosition
            self.hairSystem.attr('outputHair[%i' % hairSustemOutHairSize +
                                 ']') >> follicle.a.currentPosition
            self._follicles.append(follicle)
            self._curves.append(hairCurve)
            #if there is a scalp mesh use that for the position of the follicle
            if self.scalp:
                self.scalp.shape.a.outMesh >> follicle.a.inputMesh
                self.scalp.a.worldMatrix >> follicle.a.inputWorldMatrix
                u, v = self._getUVCoordFromScalpForFollicle(hairCurve)
                follicle.a.parameterV.v = v
                follicle.a.parameterU.v = u
                #hairCurveParent.parent        = folliclePar
            else:
                self.mesh.shape.a.outMesh >> follicle.a.inputMesh
                self.mesh.a.worldMatrix >> follicle.a.inputWorldMatrix
                follicle.a.parameterV.v = 0.5
                follicle.a.parameterU.v = 0.5
            follicle.a.overrideDynamics.v = 0
            follicle.a.startDirection.v = 1
            follicle.a.clumpWidthMult.v = 1.5
            follicle.a.densityMult.v = 0.5
            follicle.a.sampleDensity.v = 1.5
            follicle.a.outTranslate >> follicle.parent.a.translate
            follicle.a.outRotate >> follicle.parent.a.rotate
コード例 #6
0
ファイル: hair.py プロジェクト: skarone/PipeL
	def create(self):
		"""create hairsystem for lock"""
		numFace = mc.polyEvaluate( self.mesh.shape.name, f = True )
		numVert = mc.polyEvaluate( self.mesh.shape.name, v = True )
		if not self.hairSystem:
			print 'There is no hairSystem assigned to this HairLock --> init with one or assign one.... '
		if not numFace % 2 or not numVert == ( numFace + 3 ):
			print 'This mesh dosen\'t have odd number of faces', self.mesh.name, 'SKYPING'
			return
		self._curveMesh = mn.createNode('curvesFromMesh' )
		self._curveMesh.name = self.mesh.name + '_curveMesh'
		self.mesh.shape.a.outMesh     >> self._curveMesh.a.inMesh
		self.mesh.shape.a.worldMatrix >> self._curveMesh.a.inWorldMatrix
		for i in range(5):	
			hairCurve = mn.createNode('nurbsCurve' )
			hairCurveParent = hairCurve.parent
			hairCurveParent.name = self.mesh.name + '_%i'%i + '_crv'
			hairCurve = hairCurveParent.shape
			self._curveMesh.attr( 'outCurve[%i'%i + ']' ) >> hairCurve.a.create
			
			follicle = mn.createNode('follicle')
			folliclePar = follicle.parent
			folliclePar.name = self.mesh.name + '_%i'%i + '_foll'
			follicle = folliclePar.shape
			hairSustemOutHairSize = self.hairSystem.a.outputHair.size 
			follicle.a.outHair >> self.hairSystem.attr( 'inputHair[%i'%hairSustemOutHairSize + ']' )
			#follicle.a.outHair >> self.hairSystem.attr( 'inputHair[%i'%i + ']' )
			hairCurve.a.worldSpace >> follicle.a.startPosition
			self.hairSystem.attr( 'outputHair[%i'%hairSustemOutHairSize + ']' ) >> follicle.a.currentPosition
			self._follicles.append(follicle)
			self._curves.append(hairCurve)
			#if there is a scalp mesh use that for the position of the follicle
			if self.scalp:
				self.scalp.shape.a.outMesh >> follicle.a.inputMesh
				self.scalp.a.worldMatrix   >> follicle.a.inputWorldMatrix
				u,v = self._getUVCoordFromScalpForFollicle( hairCurve )
				follicle.a.parameterV.v       = v
				follicle.a.parameterU.v       = u
				#hairCurveParent.parent        = folliclePar
			else:
				self.mesh.shape.a.outMesh  >> follicle.a.inputMesh
				self.mesh.a.worldMatrix    >> follicle.a.inputWorldMatrix
				follicle.a.parameterV.v       = 0.5
				follicle.a.parameterU.v       = 0.5
			follicle.a.overrideDynamics.v = 0
			follicle.a.startDirection.v   = 1
			follicle.a.clumpWidthMult.v   = 1.5
			follicle.a.densityMult.v      = 0.5
			follicle.a.sampleDensity.v    = 1.5
			follicle.a.outTranslate >> follicle.parent.a.translate
			follicle.a.outRotate >> follicle.parent.a.rotate
コード例 #7
0
ファイル: poseManUi.py プロジェクト: skarone/PipeL
	def __init__(self, project, pose = None, parent  = uiH.getMayaWindow() ):
		if uiH.USEPYQT:
			super(base, self).__init__(parent)
		else:
			super(PoseThumbnailCreatorUi, self).__init__(parent)
		self.setupUi(self)
		self.project = project
		self.pose = pose
		layout = mui.MQtUtil.fullName(long(shiboken.getCppPointer(self.viewport_lay)[0]))
		self.cam = mn.Node( 'Capture_Pose' )
		if not self.cam.exists:
			self.camShape = mn.createNode( 'camera', ss = True )
			self.camShape.parent.name = 'Capture_Pose'
			mc.viewSet( self.cam.name, p = True )
			self.cam.shape.a.focalLength.v = 100
			self.cam.a.v.v = 0
		self.executer = mc.modelPanel( mbv = False, camera = self.cam.name, p = layout )
		mc.modelEditor(self.executer, e = True, grid = 0, da = "smoothShaded", allObjects = 0, nurbsSurfaces = 1, polymeshes = 1, subdivSurfaces = 1 )
		#self.viewport_lay.addWidget( uiH.toQtObject( self.executer ) )
		self.setObjectName( 'PoseThumbnailCreatorUi' )
		self._makeConnections()
		self.saveCameraPreset = 0 #READ, 1.. WRITE
		self.settings = sti.Settings()
		gen = self.settings.General
		skin = gen[ "skin" ]
		if skin:
			uiH.loadSkin( self, skin )
		if pose:
			self.poseName_le.setText( pose.name )
		self.fillSections()
コード例 #8
0
ファイル: blendshape.py プロジェクト: skarone/PipeL
	def makeCorrectiveBlend(self, mesh1, mesh2 ):
		"""create a corrective blendshape"""
		self.attr( mesh1 ).v = 1
		self.attr( mesh2 ).v = 1
		corrective = self.baseMesh.duplicate( mesh1 + mesh2 + '_corrective' )
		corrective.a.corrective.add( at = 'bool' )
		self.a.envelope.v = 0
		dummy = self.baseMesh.duplicate( mesh1 + mesh2 + '_dummy' )
		dummy.a.dummy.add( at = 'bool' )
		self.a.envelope.v = 1
		blend = BlendShapeNode( mesh1 + mesh2 + '_blend' )
		blend.create( [mesh1, mesh2, corrective], dummy )
		blend.attr( mesh1 ).v = -1
		blend.attr( mesh2 ).v = -1
		blend.attr( corrective.name ).v = 1
		self.addMesh( dummy.name )
		#connect mesh1 and mesh 2 to controls dummy weight
		mul = mn.createNode( 'multiplyDivide' )
		mul.name = mesh1 + mesh2 + '_MUL'
		self.attr( mesh1 ) >> mul.a.input1X
		self.attr( mesh2 ) >> mul.a.input2X
		mul.a.outputX >> self.attr( dummy.name )
		self.attr( mesh1 ).v = 0
		self.attr( mesh2 ).v = 0
		return dummy, corrective
コード例 #9
0
ファイル: aov.py プロジェクト: skarone/PipeL
def createMotionVectorAov( name = 'mBlur' ):
	"""create motion vector aov"""
	#mblur = create( 'aiAOV_' + name, name, 5, False  )
	mblur = mn.Node( 'aiAOV_motionvector' )
	mBlurShader = mn.createNode( 'aiMotionVector' )
	mBlurShader.a.raw.v = 1
	mBlurShader.a.outColor >> mblur.a.defaultValue
コード例 #10
0
ファイル: stickyControl.py プロジェクト: skarone/PipeL
	def _createConstraint(self):
		"""create constraint to mesh for the control"""
		edge1, edge2 = self._getClosestEdgesFromMesh()
		rebuild,loft  = self._loftFromEdges( edge1, edge2 )
		u,v = self._uvParamFromPositionOnLoft( rebuild )
		rivet = mn.createNode( 'cMuscleSurfAttach' )
		rivet.a.v.v = 0
		rivet.a.uLoc.v = u
		rivet.a.vLoc.v = v
		rivet.a.edgeIdx1.v = edge1
		rivet.a.edgeIdx2.v = edge2
		rivet.a.fixPolyFlip.v = 1
		rivetPar = rivet.parent
		self.mesh.a.worldMesh >> rivet.a.surfIn
		#check if flip is better than not
		tmpTrans1 = rivet.a.outTranslate.v[0]
		rivet.a.fixPolyFlip.v = 0
		tmpTrans2 = rivet.a.outTranslate.v[0]
		vec1 = api.MVector( self.initPosition[0] - tmpTrans1[0],
							self.initPosition[0] - tmpTrans1[0],
							self.initPosition[0] - tmpTrans1[0])
		vec2 = api.MVector( self.initPosition[0] - tmpTrans2[0],
							self.initPosition[0] - tmpTrans2[0],
							self.initPosition[0] - tmpTrans2[0])
		if vec2.length() > vec1.length():
			rivet.a.fixPolyFlip.v = 1

		rivet.a.outRotate >> rivetPar.a.rotate
		rivet.a.outTranslate >> rivetPar.a.translate
		#need to check if the uv are ok or we have to flip them

		rivetPar.name = self.name + '_rivet'
		return rivetPar
コード例 #11
0
ファイル: createControls.py プロジェクト: skarone/PipeL
def createControl( si, shape = 'circleX', childsAlso = True, par = None, lastAlso = False, constraint = True, connect = False, offsetGroup = True ):
	if not lastAlso and not si.children:
		return
	if shape == 'joint':
		mc.select( cl = True )
		curv = mn.Node( mc.joint( n = si.name + "_jnt" ) )
	elif shape == 'locator':
		curv = mn.Node( mc.spaceLocator( n = si.name + '_loc' )[0] )
	else:
		curv = crv.Curve( si.name + "_ctl" )
		curv = curv.create( shape )
	if offsetGroup:
		grp = mn.createNode( "transform", ss = True )
		grp.name = si.name + "_grp"
		trf.snap( si, grp )
		curv.parent = grp
		curv.a.t.v  = [0]*3
		curv.a.r.v  = [0]*3
		if par:
			grp.parent = par
	else:
		trf.snap( si, curv )
		curv.freeze()
	if constraint:
		mc.parentConstraint( curv, si, mo = True )
		mc.scaleConstraint( curv, si, mo = True )
	if connect:
		curv.a.t >> si.a.t
		curv.a.r >> si.a.r
		curv.a.s >> si.a.s
	if childsAlso and si.children:
		for c in si.children:
			c = mn.Node( c.name.split( '|' )[-1] )
			createControl( c, shape, True, curv, lastAlso, constraint, connect, offsetGroup )
コード例 #12
0
ファイル: stickyControl.py プロジェクト: skarone/PipeL
	def _uvParamFromPositionOnLoft(self, loft):
		"""return the uvs values to set up on constrain"""
		clos = mn.createNode( 'closestPointOnSurface' )
		loft.a.outputSurface >> clos.a.inputSurface
		clos.a.inPosition.v = self.initPosition
		u = clos.a.parameterU.v
		v = clos.a.parameterV.v
		clos.delete()
		return u,v
コード例 #13
0
ファイル: stickyControl.py プロジェクト: skarone/PipeL
	def _getClosestEdgesFromMesh(self):
		"""return the closets edges from the mesh to use"""
		clos = mn.createNode( 'closestPointOnMesh' )
		self.mesh.a.worldMesh >> clos.a.inMesh
		clos.a.inPosition.v = self.initPosition
		closeFace = clos.a.closestFaceIndex.v
		edges = mc.polyInfo( self.mesh.name + '.f[%i'%closeFace + ']', faceToEdge = True )
		edges = edges[0].split()
		edge1 = int( edges[2] )
		edge2 = int( edges[4] )
		clos.delete()
		return edge1, edge2
コード例 #14
0
ファイル: pointOnCurve.py プロジェクト: skarone/PipeL
def createTransformsForSelection( cur ):
	curv = crv.Curve( cur )
	#create transforms constrained to a curve based on selected objcets
	trfs = []
	for r in mn.ls( sl = True ):
		pnt = PointOnCurve( curv )
		nd = nodeAt( curv.uParam( r.worldPosition ) )
		grp = mn.createNode( "transform" )
		grp.name = r.name + '_curve_cons_grp'
		nd.a.position >> grp.a.t
		trfs.append( grp )
	return trfs
コード例 #15
0
ファイル: hair.py プロジェクト: skarone/PipeL
	def _getUVCoordFromScalpForFollicle(self, curve):
		"""return the closest uv coord for the follicle based on first cv of the curve"""
		if not self.scalp:
			print 'There is no scalp mesh for this process'
			return 
		clos = mn.createNode( 'closestPointOnMesh' )
		self.scalp.shape.a.worldMesh >> clos.a.inMesh
		pos = mc.xform( curve.name + '.cv[0]', q = True, ws = True, t = True )
		clos.a.inPosition.v = pos
		u = clos.a.parameterU.v
		v = clos.a.parameterV.v
		clos.delete()
		return u,v
コード例 #16
0
ファイル: hairSystem.py プロジェクト: Rotomator/PipeL
 def _getUVCoordFromScalpForFollicle(self, curve):
     """return the closest uv coord for the follicle based on first cv of the curve"""
     if not self.scalp:
         print 'There is no scalp mesh for this process'
         return
     clos = mn.createNode('closestPointOnMesh')
     self.scalp.shape.a.worldMesh >> clos.a.inMesh
     pos = mc.xform(curve.name + '.cv[0]', q=True, ws=True, t=True)
     clos.a.inPosition.v = pos
     u = clos.a.parameterU.v
     v = clos.a.parameterV.v
     clos.delete()
     return u, v
コード例 #17
0
ファイル: hair.py プロジェクト: skarone/PipeL
def hairSystemAutomator( sysName = '', scalp = None ):
	"""creates a hair system based on selected lock meshes, 
	if you specify a scalp it will use that to place follicles"""
	hair_polygons = mn.ls(sl=1)
	all_grp = mn.Node( mc.group( n = sysName + '_hair_grp', em = True ) )
	hairSystem = mn.createNode('hairSystem')
	hairSystemPar = hairSystem.parent
	hairSystemPar.name = sysName + '_hairSystem'
	hairSystem = hairSystemPar.shape
	hairSystemPar.parent = all_grp
	pfxHair = mn.createNode( 'pfxHair' )
	pfxHairPar = pfxHair.parent
	pfxHairPar.name = sysName + '_pfxHair'
	pfxHairPar.parent = all_grp
	pfxHair = pfxHairPar.shape
	foll_grp = mn.Node( mc.group( n = sysName + '_foll_grp', em = True ) )
	foll_grp.parent = all_grp
	curve_grp = mn.Node( mc.group( n = sysName + '_crv_grp', em = True ) )
	curve_grp.parent = all_grp
	allFollicles = []
	allHairCurves = []
	allFtbHairCurves = []
	hairCount = 0
	plugCount = 0
	badMesh = []
	for hair_poly in hair_polygons:
		hairLock = HairLock( hair_poly, hairSystem, scalp )
		hairLock.create()
		for i in range( 5 ):
			hairLock.follicles[i].parent = foll_grp
			#if not scalp:
			hairLock.curves[i].parent    = curve_grp
	#hairSystem.attr( "clumpFlatness[0].clumpFlatness_Position" ).v = 0
	#hairSystem.attr( "clumpFlatness[0].clumpFlatness_FloatValue" ).v = 0.5
	hairSystem.a.simulationMethod.v = 1
	hairSystem.a.outputRenderHairs >> pfxHair.a.renderHairs
	ti = mn.Node( 'time1' )
	ti.a.outTime >> hairSystem.a.currentTime
コード例 #18
0
ファイル: hairSystem.py プロジェクト: Rotomator/PipeL
def hairSystemAutomator(sysName='', scalp=None):
    """creates a hair system based on selected lock meshes,
	if you specify a scalp it will use that to place follicles"""
    hair_polygons = mn.ls(sl=1)
    all_grp = mn.Node(mc.group(n=sysName + '_hair_grp', em=True))
    hairSystem = mn.createNode('hairSystem')
    hairSystemPar = hairSystem.parent
    hairSystemPar.name = sysName + '_hairSystem'
    hairSystemPar.parent = all_grp
    hairSystem = hairSystemPar.shape
    pfxHair = mn.createNode('pfxHair')
    pfxHairPar = pfxHair.parent
    pfxHairPar.name = sysName + '_pfxHair'
    pfxHairPar.parent = all_grp
    pfxHair = pfxHairPar.shape
    foll_grp = mn.Node(mc.group(n=sysName + '_foll_grp', em=True))
    foll_grp.parent = all_grp
    curve_grp = mn.Node(mc.group(n=sysName + '_crv_grp', em=True))
    curve_grp.parent = all_grp
    allFollicles = []
    allHairCurves = []
    allFtbHairCurves = []
    hairCount = 0
    plugCount = 0
    badMesh = []
    for hair_poly in hair_polygons:
        hairLock = HairLock(hair_poly, hairSystem, scalp)
        hairLock.create()
        for i in range(5):
            hairLock.follicles[i].parent = foll_grp
            #if not scalp:
            hairLock.curves[i].parent = curve_grp
    #hairSystem.attr( "clumpFlatness[0].clumpFlatness_Position" ).v = 0
    #hairSystem.attr( "clumpFlatness[0].clumpFlatness_FloatValue" ).v = 0.5
    hairSystem.a.simulationMethod.v = 1
    hairSystem.a.outputRenderHairs >> pfxHair.a.renderHairs
    ti = mn.Node('time1')
    ti.a.outTime >> hairSystem.a.currentTime
コード例 #19
0
ファイル: stickyControl.py プロジェクト: skarone/PipeL
	def _loftFromEdges( self, edge1, edge2 ):
		"""Create a loft nurbs from edges"""
		#EDGE 1
		edge1_cme = mn.createNode('curveFromMeshEdge',n='edfe1')
		self.mesh.a.worldMesh >> edge1_cme.a.inputMesh
		edge1_cme.attr( 'edgeIndex[0]' ).v = edge1
		
		#EDGE 2
		edge2_cme = mn.createNode('curveFromMeshEdge',n='edfe2')
		self.mesh.a.worldMesh >> edge2_cme.a.inputMesh
		edge2_cme.attr( 'edgeIndex[0]' ).v = edge2
		
		mesh_lft = mn.createNode('loft',n='loft')
		edge1_cme.a.outputCurve >> mesh_lft.attr( 'inputCurve[0]' )
		edge2_cme.a.outputCurve >> mesh_lft.attr( 'inputCurve[1]' )
		mesh_lft.a.degree.v = 1
		rebuild = mn.createNode( 'rebuildSurface', n = 'rebuild' )
		mesh_lft.a.outputSurface >> rebuild.a.inputSurface
		rebuild.a.spansU.v = 0
		rebuild.a.spansV.v = 0
		rebuild.a.degreeU.v = 1
		rebuild.a.degreeV.v = 1
		rebuild.a.keepRange.v = 0
		return rebuild, mesh_lft
コード例 #20
0
ファイル: eyes.py プロジェクト: skarone/PipeL
	def create(self):
		"""docstring for create"""
		leftEyes = self._textToNodes( self.leftEyesGeo_le )
		leftTrf, leftCtl = self._createPerEye( 'l', leftEyes )
		rightEyes = self._textToNodes( self.rightEyesGeo_le )
		rightTrf, rightCtl = self._createPerEye( 'r', rightEyes )
		trf = mn.createNode( 'transform' )
		trf.name = 'Eyes_Def_grp'
		leftTrf.parent = trf
		rightTrf.parent  = trf
		ctl = crv.Curve( 'eyes_ctl' )
		ctl.create( 'square' )
		par = mn.Node( mc.parentConstraint( leftCtl, rightCtl,ctl, mo = False )[0])
		par.delete()
		ctl.a.rx.v = 90
		mc.makeIdentity( ctl, a = True, t = 1, r = 1, s = 1 )
		leftCtl.parent = ctl
		rightCtl.parent = ctl
コード例 #21
0
ファイル: multiFollow.py プロジェクト: skarone/PipeL
def createFollow( obj, constraintObjects ):
	"""create a constraint, and add attribute to object to control"""
	obj = mn.Node( obj )
	objectToConstraint = mn.Node( mc.group( obj.name, n = obj.name + '_grp' ) )
	cons = mn.Node( mc.parentConstraint( constraintObjects, objectToConstraint, mo = True )[0] )
	enum = ''
	attrName = 'follow'
	for a in constraintObjects:
		enum += a + ':'
	if not obj.attr( attrName ).exists:
		obj.a.follow.add( at = "enum", en = enum, k = True )
	else:
		attrName += '2'
		obj.attr( attrName ).add( at = "enum", en = enum, k = True )
	for i,a in enumerate( constraintObjects ):
		cond = mn.createNode( 'condition', n = obj.name + a + '_COND' )
		cond.a.colorIfTrueR.v  = 1
		cond.a.colorIfFalseR.v = 0
		cond.a.secondTerm.v    = i
		obj.attr( attrName ) >> cond.a.firstTerm
		cond.a.outColorR >> cons.attr( a + 'W' + str( i ) )
コード例 #22
0
 def __init__(self, project, pose=None, parent=uiH.getMayaWindow()):
     if uiH.USEPYQT:
         super(base, self).__init__(parent)
     else:
         super(PoseThumbnailCreatorUi, self).__init__(parent)
     self.setupUi(self)
     self.project = project
     self.pose = pose
     layout = mui.MQtUtil.fullName(
         long(shiboken.getCppPointer(self.viewport_lay)[0]))
     self.cam = mn.Node('Capture_Pose')
     if not self.cam.exists:
         self.camShape = mn.createNode('camera', ss=True)
         self.camShape.parent.name = 'Capture_Pose'
         mc.viewSet(self.cam.name, p=True)
         self.cam.shape.a.focalLength.v = 100
         self.cam.a.v.v = 0
     self.executer = mc.modelPanel(mbv=False,
                                   camera=self.cam.name,
                                   p=layout)
     mc.modelEditor(self.executer,
                    e=True,
                    grid=0,
                    da="smoothShaded",
                    allObjects=0,
                    nurbsSurfaces=1,
                    polymeshes=1,
                    subdivSurfaces=1)
     #self.viewport_lay.addWidget( uiH.toQtObject( self.executer ) )
     self.setObjectName('PoseThumbnailCreatorUi')
     self._makeConnections()
     self.saveCameraPreset = 0  #READ, 1.. WRITE
     self.settings = sti.Settings()
     gen = self.settings.General
     skin = gen["skin"]
     if skin:
         uiH.loadSkin(self, skin)
     if pose:
         self.poseName_le.setText(pose.name)
     self.fillSections()
コード例 #23
0
ファイル: utils.py プロジェクト: skarone/PipeL
def createGammaForNode( node, useExistingGama = True, gammaValue = 0.454 ):
	outputs = node.a.outColor.output
	if outputs:
		newGam = None
		if useExistingGama:
			newGam = [ o.node for o in outputs if o.node.type == 'gammaCorrect' ]
			if newGam:
				newGam = newGam[0]
		if not newGam:
			newGam = mn.createNode( 'gammaCorrect' )
			newGam.name = node.name + '_GAM'
		newGam.a.gammaX.v = gammaValue
		newGam.a.gammaY.v = gammaValue
		newGam.a.gammaZ.v = gammaValue
		try:
			node.a.outColor >> newGam.a.value
		except:
			pass
		for o in outputs:
			if o.node.type == 'gammaCorrect':
				continue
			newGam.a.outValue >> o
コード例 #24
0
ファイル: blendshape.py プロジェクト: skarone/PipeL
	def createReflectionTable(self, axis = 'x', vertexList = []):
		"""create the table that relates vertex from one side to the other"""
		#createVertexList from one side
		xVerts = []
		tolerance = 0.0001
		self._reflectionTable = {}
		if not vertexList:
			vertexList = mn.ls( self.baseMesh.name + '.vtx[*]', fl = True )
		else:
			vertexList = mn.Nodes( [ self.baseMesh.name + '.' + a.split( '.' )[-1] for a in vertexList ] )
		for a in vertexList:
			vPos = mc.xform( a, q = True, os = True, t = True )
			if vPos[self.AXIS[axis]] + tolerance >= 0 or vPos[self.AXIS[axis]] - tolerance >= 0:
				xVerts.append( int( a.name[a.name.index('[')+1: a.name.index( ']' )]) )
		clos = mn.createNode( 'closestPointOnMesh' )
		self.baseMesh.a.worldMesh >> clos.a.inMesh
		for v in xVerts:
			vPos = mc.xform( self.baseMesh.name + '.vtx[' + str( v ) + ']', q = True, os = True, t = True )
			vPos[self.AXIS[axis]] *= -1
			clos.a.inPosition.v = [vPos[0],vPos[1],vPos[2] ]
			self._reflectionTable[v] = clos.a.closestVertexIndex.v
		clos.delete()
コード例 #25
0
ファイル: eyelids.py プロジェクト: skarone/PipeL
	def createCurves(self, verteces, locs, baseName ):
		"""create the curves to controls the locators"""
		grp = mn.Node( mc.group( n = baseName + '_CRV_GRP', em = True ) )
		tmp = mn.Node( mc.curve( n = baseName + "High" + '_CRV', d = 1, p = verteces, k = [ i for i in range( len( verteces ) ) ] ) )
		tmp.name = baseName + "High" + '_CRV'
		highCurve = crv.Curve( tmp.shape.name.split( '|' )[-1] )
		highCurve.parent = grp
		#attach locs to curve
		for l in locs:
			pos = mc.xform( l.name, q = True, ws = 1, t = 1 )
			u = highCurve.uParam( pos )
			pci = mn.createNode( "pointOnCurveInfo" )
			pci.name = l.name.replace( '_LOC', '_PCI' )
			highCurve.a.worldSpace >> pci.a.inputCurve
			pci.a.parameter.v = u
			pci.a.position >> l.a.t
		lowCurve = highCurve.rebuild( keep = True )
		lowCurve.name = tmp.name.replace( 'High', 'Low' )
		lowCurve.parent = grp
		wir = mn.Node( mc.wire( tmp.name, gw = False, en = 1.000000, ce = 0.000000, li = 0.000000, w = lowCurve.name )[0] )
		wir.name = tmp.name.replace( '_CRV', '_WR' )
		return crv.Curve( lowCurve.name ), grp
コード例 #26
0
ファイル: cacheFile.py プロジェクト: skarone/PipeL
	def importForAsset2(self, asset, customNamespace = None ):
		"""import cache and assign to asset"""
		#reference render asset
		#connect cache to objects
		nodes = asset.shadingPath.reference( customNamespace )
		#filter meshes
		mshs = mn.ls( nodes, typ = 'mesh', ni = True, l = True )
		mshs.select()
		abcNode = self.imp( mode = 'import', connect = "/", createIfNotFound = True )
		#reconnect via polyTransfer so we can use the original uvs from shape
		attrs = abcNode.listAttr( c = True, m = True, ro = True, hd = True )
		for a in attrs:
			out = a.output
			if not out:
				continue
			for o in out:
				midMesh = mn.createNode( 'mesh' )
				o.disconnect()
				a >> midMesh.a.inMesh
				polyTrans = mc.transferAttributes( midMesh.name, o.node.name, transferPositions = 1, transferNormals = 1, transferUVs = 0, transferColors = 0, sampleSpace = 5, searchMethod = 3 )
				midMesh.a.intermediateObject.v = 1
				midMesh.parent.delete()
		nodes[0]()
		rf.reloadSelected()
コード例 #27
0
ファイル: pointOnCurve.py プロジェクト: skarone/PipeL
	def nodeAt(self, parameter):
		"""return a node connected to the curve at the parameter"""
		node = mn.createNode( 'pointOnCurveInfo' )
		self.curve.a.worldSpace >> node.a.inputCurve
		node.a.parameter.v = parameter
		return node
コード例 #28
0
import general.mayaNode.mayaNode as mn
import random as rd
import maya.cmds as mc
rbfNode = mn.createNode('rbfSolver')
baseSphere = mn.Node('pSphere1')
sha = baseSphere.shader.a.surfaceShader.input.node
distance = 30
samples = mn.createNode('transform')
samples.name = 'samples'
samplesCount = 30
centersCount = 5
for n in range(samplesCount):
    newSphere = baseSphere.duplicate()
    newSha = sha.duplicate()
    newSphere.a.t.v = [
        rd.uniform(-(distance), distance),
        rd.uniform(-(distance), distance),
        rd.uniform(-(distance), distance)
    ]
    newSha.a.outColor.v = [
        rd.uniform(0, 1), rd.uniform(0, 1),
        rd.uniform(0, 1)
    ]
    mc.select(newSphere)
    mc.hyperShade(a=newSha)
    newSphere.a.t >> rbfNode.attr("inPos[" + str(n) + "]")
    newSha.a.outColorR >> rbfNode.attr("inValues[" + str(n) + "].inValue[0]")
    newSha.a.outColorG >> rbfNode.attr("inValues[" + str(n) + "].inValue[1]")
    newSha.a.outColorB >> rbfNode.attr("inValues[" + str(n) + "].inValue[2]")
    newSphere.parent = samples
コード例 #29
0
ファイル: _spiderWebCreator.py プロジェクト: skarone/PipeL
def create( loops = 10 ):
	"""create a spider web based on a polygon mesh, select a vertex for the center of the web and a edge loop for the border"""
	sel = mc.ls( sl = True, fl = True )
	if not sel:
		mc.warning( 'Select a vertex for the center of the web and a loop of edges for the border' )
		return
	vert = sel[0]
	vertPos = mc.xform( vert, q = True, ws = True, t = True )
	edges = sel[1:]
	exists = True
	finalNameSpace = ''
	num = 0
	while exists:
		if not mc.namespace( ex = 'spiderWeb' + str( num ) ):
			exists = False
			finalNameSpace = 'spiderWeb' + str( num )
		num += 1
	space = mn.Namespace( finalNameSpace )
	space.create()

	softs = []
	with space.set():
		baseGrp = mn.Node( mc.createNode('transform') )
		baseGrp.name = 'spiderWeb_grp'
		crvsGrp = mn.Node( mc.createNode('transform') )
		crvsGrp.name = 'spiderWeb_CRV_grp'
		trfLocs = mn.createNode( 'transform' )
		trfLocs.name = 'spiderWeb_LOC_grp'
		trfLocs.a.v.v = 0
		trfFols = mn.createNode( 'transform' )
		trfFols.name = 'spiderWeb_FOL_grp'
		trfFols.a.v.v = 0
		hrsSys = mn.createNode( 'hairSystem' )
		mn.Node( 'time1' ).a.outTime >> hrsSys.a.currentTime
		crvsGrp.parent = baseGrp
		trfLocs.parent = baseGrp
		trfFols.parent = baseGrp
		hrsSys.parent.parent = baseGrp
		crvs = []
		vertecesOnEdges = mc.ls( mc.polyListComponentConversion( edges, fromEdge = True, toVertex = True ), fl = True )
		tmpVertEdges = vertecesOnEdges
		orderedVertices = []
		nextVert = tmpVertEdges[0]
		counter = 0
		while not len(tmpVertEdges) == 0:
			edgeOnVertex = mc.polyListComponentConversion( nextVert, fromVertex = True, toEdge = True )
			orderedVertices.append( nextVert )
			tmpVertEdges.remove( nextVert )
			for e in edgeOnVertex:
				vertsOnEdg = mc.ls( mc.polyListComponentConversion( e, fromEdge = True, toVertex = True ), fl = True )
				for v in vertsOnEdg:
					if v in tmpVertEdges:
						nextVert = v
						break

		for i,v in enumerate( orderedVertices ):
			vPos = mc.xform( v, q = True, ws = True, t = True )
			curv = crv.Curve( mc.curve( d = 3, ep = [vertPos, vPos] ) )
			mc.rebuildCurve( curv.name, rpo = 1, rt = 0, end = 1, kr = 0, kcp = 1, kep = 1, kt =0, s= 4, d = 3, tol = 0.01  )
			curv.name = 'spiderWeb_guide_' + str( i ) + '_CRV'
			crvs.append( curv )
			curv.parent = crvsGrp

		i = 0
		minVal = mc.arclen( crvs[0] )
		maxVal = mc.arclen( crvs[0] )
		for c in crvs:
			if mc.arclen( c ) < minVal:
				minVal = mc.arclen( c )
			if mc.arclen( c ) > maxVal:
				maxVal = mc.arclen( c )    
		prevLoc = ''

		count = 0
		for a in drange( 0.0, 1.0, ( 1.0 / len( crvs ) / loops ) ):
			if i == ( len( crvs ) ):
				i = 0
			c = crvs[i]
			i += 1
			offset = a * ( maxVal ) / mc.arclen( c )
			offset = offset + random.uniform(-0.01,0.01)
			if c.shape.a.maxValue.v < offset:
				break
			pointOnCur = pntcrv.PointOnCurve( c )
			nod = pointOnCur.nodeAt( offset )
			loc = mn.Node( mc.spaceLocator(  )[0] )
			nod.a.position >> loc.a.translate
			if prevLoc:
				#create curve based on locators position
				leastSquaresMod = mn.createNode( 'leastSquaresModifier' )
				prevLoc.name = 'spiderWeb_' + str( count ) + '_LOC'
				origCurv = crv.Curve( mc.curve( d = 1, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
				origCurv.name = 'spiderWeb_base_' + str( count ) + '_CRV'
				mc.rebuildCurve( origCurv.name, rpo = 1, rt = 0, end = 1, kr = 0, kcp = 1, kep = 1, kt =0, s= 4, d = 1, tol = 0.01  )
				origCurv.a.intermediateObject.v = 1
				controledCurv = origCurv.duplicate()
				origCurv.shape.attr( 'worldSpace[0]' ) >> leastSquaresMod.a.inputNurbsObject
				prevLoc.attr( 'worldPosition[0]')      >> leastSquaresMod.attr( 'pointConstraint[0].pointPositionXYZ' )
				leastSquaresMod.attr( 'pointConstraint[0].pointConstraintU' ).v = 0
				loc.attr( 'worldPosition[0]')          >> leastSquaresMod.attr( 'pointConstraint[1].pointPositionXYZ' )
				leastSquaresMod.attr( 'pointConstraint[1].pointConstraintU' ).v = 1
				leastSquaresMod.a.outputNurbsObject    >> controledCurv.shape.a.create
				controledCurv.shape.attr( 'worldMatrix[0]' ) >> leastSquaresMod.a.worldSpaceToObjectSpace
				fol = mn.createNode( 'follicle' )
				fol.a.restPose.v = 1
				fol.a.startDirection.v = 1
				fol.a.pointLock.v = 3
				fol.a.degree.v = 3
				fol.a.sampleDensity.v = 3
				fol.a.outHair >> hrsSys.attr( 'inputHair[' + str( count ) + ']' )
				fol.parent.parent = trfFols
				hrsSys.attr( 'outputHair[' + str( count ) + ']' ) >> fol.a.currentPosition
				controledCurv.shape.attr( 'worldSpace[0]' ) >> fol.a.startPosition
				curv = crv.Curve( mc.curve( d = 3, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
				curv.name = 'spiderWeb_spiral_' + str( count ) + '_CRV'
				fol.a.outCurve >> curv.a.create
				fol.parent.name = 'spiderWeb_' + str( count ) + '_FOL'
				curv.parent = crvsGrp
				count += 1
			loc.parent = trfLocs
			prevLoc = loc
		hrsSys.parent.name = 'spiderWeb_HRS'
コード例 #30
0
ファイル: spiderWebCreator.py プロジェクト: skarone/PipeL
def create( loops = 10, dynamicGuides = False ):
	"""create a spider web based on a polygon mesh, select a vertex for the center of the web and a edge loop for the border"""
	sel = mc.ls( sl = True, fl = True )
	if not sel:
		mc.warning( 'Select a vertex for the center of the web and a loop of edges for the border' )
		return
	vert = sel[0]
	vertPos = mc.xform( vert, q = True, ws = True, t = True )
	edges = sel[1:]
	exists = True
	finalNameSpace = ''
	num = 0
	while exists:
		if not mc.namespace( ex = 'spiderWeb' + str( num ) ):
			exists = False
			finalNameSpace = 'spiderWeb' + str( num )
		num += 1
	space = mn.Namespace( finalNameSpace )
	space.create()
	with space.set():
		#create Base Groups
		baseGrp = mn.Node( mc.createNode('transform') )
		baseGrp.name = 'spiderWeb_grp'
		baseGrp.a.CurveWidth.add( dv = 0.010 )
		baseGrp.a.CurveShader.add( uac = True, attributeType='float3' )
		baseGrp.a.red.add( attributeType='float', parent='CurveShader' )
		baseGrp.a.green.add( attributeType='float', parent='CurveShader' )
		baseGrp.a.blue.add( attributeType='float', parent='CurveShader' )
		shader = mn.createNode( 'aiHair' )
		baseGrp.a.CurveShader.v = [1,1,1]
		crvsGrp = mn.Node( mc.createNode('transform') )
		crvsGrp.name = 'spiderWeb_CRV_grp'
		trfLocs = mn.createNode( 'transform' )
		trfLocs.name = 'spiderWeb_LOC_grp'
		trfLocs.a.v.v = 0
		trfFols = mn.createNode( 'transform' )
		trfFols.name = 'spiderWeb_FOL_grp'
		trfFols.a.v.v = 0
		crvsGrp.parent = baseGrp
		trfLocs.parent = baseGrp
		trfFols.parent = baseGrp
		hrsSys = mn.createNode( 'hairSystem' )
		mn.Node( 'time1' ).a.outTime >> hrsSys.a.currentTime
		hrsSys.parent.parent = baseGrp
		####
		vertecesOnEdges = mc.ls( mc.polyListComponentConversion( edges, fromEdge = True, toVertex = True ), fl = True )
		orderedVertices = getOrderedVerteces( vertecesOnEdges )
		crvs, fols, locs = createGuideCurves( orderedVertices, vertPos, hrsSys, dynamicGuides )
		for c in crvs:
			baseGrp.a.CurveWidth >> c.shape.a.aiCurveWidth
			shader.a.outColor >> c.shape.a.aiCurveShader
		mn.Nodes( crvs ).parent( crvsGrp )
		if fols:
			mn.Nodes( fols ).parent( trfFols )
		if locs:
			mn.Nodes( locs ).parent( trfLocs )
		crvs,fols,locs = createSpiralCurves( crvs, loops, hrsSys )
		for c in crvs:
			baseGrp.a.CurveWidth >> c.shape.a.aiCurveWidth
			shader.a.outColor >> c.shape.a.aiCurveShader
		mn.Nodes( crvs ).parent( crvsGrp )
		mn.Nodes( fols ).parent( trfFols )
		mn.Nodes( locs ).parent( trfLocs )
		hrsSys.parent.name = 'spiderWeb_HRS'
コード例 #31
0
ファイル: renderOcc.py プロジェクト: skarone/PipeL
def createShader(aovNode):
	"""docstring for createShader"""
	#Create Utility base Shader
	utilMat = mn.Node( 'OccUtil_MAT')
	if not utilMat.exists:
		utilMat = mn.createNode( 'aiUtility' )
		utilMat.a.shadeMode.v = 2
		utilMat.name = 'OccUtil_MAT'
	#Create TripleSwitch
	tripleSwitch = mn.Node( 'OccTripleSwith_TS')
	if not tripleSwitch.exists:
		tripleSwitch = mn.createNode( 'tripleShadingSwitch' )
		tripleSwitch.name = 'OccTripleSwith_TS'
	if not tripleSwitch.a.output.isConnected( utilMat.a.color ):
		tripleSwitch.a.output >> utilMat.a.color
	#Create OCC Shader
	occMat = mn.Node( 'Occ_MAT' )
	if not occMat.exists:
		occMat = mn.createNode( 'aiAmbientOcclusion' )
		occMat.name = 'Occ_MAT'
	if not occMat.a.outColor.isConnected( tripleSwitch.a.default ):
		occMat.a.outColor >> tripleSwitch.a.default
	count = 0
	#get shapes with customs attributes
	for sha in mn.ls( typ = 'mesh', ni = True ):
		if sha.a.iris_Occ.exists:
			#create Iris for this shape
			irisMat = mn.Node( 'irisOcc_MAT' )
			if not irisMat.exists:
				irisMat = mn.createNode( 'surfaceShader' )
				irisMat.name = 'irisOcc_MAT'
			#connect shape with tripleswitch and irisMat
			if not sha.attr('instObjGroups[0]').isConnected( tripleSwitch.attr( 'input[' + str(count) +'].inShape')):
				sha.attr('instObjGroups[0]') >> tripleSwitch.attr( 'input[' + str(count) +'].inShape')
			if not irisMat.a.outColor.isConnected( tripleSwitch.attr( 'input[' + str(count) +'].inTriple') ):
				irisMat.a.outColor >> tripleSwitch.attr( 'input[' + str(count) +'].inTriple')
			count += 1
			continue
		if sha.a.texture_Occ.exists:
			#create Occ with texture for this shape
			occMat = mn.Node( sha.name + 'Occ_MAT' )
			if not occMat.exists:
				occMat = mn.createNode( 'aiAmbientOcclusion' )
				occMat.name = sha.name + 'Occ_MAT'
			fileMat = mn.Node( sha.name + 'file_Occ_MAT' )
			if not fileMat.exists:
				fileMat = mn.createNode( 'file' )
				fileMat.name = sha.name + 'file_Occ_MAT'
			fileMat.a.ftn.v = sha.a.texture_Occ.v
			if not fileMat.a.outColor.isConnected( occMat.a.white ):
				fileMat.a.outColor >> occMat.a.white
			if not sha.attr('instObjGroups[0]').isConnected( tripleSwitch.attr( 'input[' + str(count) +'].inShape') ):
				sha.attr('instObjGroups[0]') >> tripleSwitch.attr( 'input[' + str(count) +'].inShape')
			if not occMat.a.outColor.isConnected( tripleSwitch.attr( 'input[' + str(count) +'].inTriple') ):
				occMat.a.outColor >> tripleSwitch.attr( 'input[' + str(count) +'].inTriple')
			count += 1
		if sha.a.hideForOcc.exists:
			sha.a.castsShadows.v = False
			sha.a.primaryVisibility.v = False
	#Connect Shader to AOV
	if not utilMat.a.outColor.isConnected( aovNode.a.defaultValue ):
		utilMat.a.outColor >> aovNode.a.defaultValue
コード例 #32
0
ファイル: testPlug.py プロジェクト: skarone/PipeL
import general.mayaNode.mayaNode as mn
import random as rd
import maya.cmds as mc
rbfNode = mn.createNode( 'rbfSolver' )
baseSphere = mn.Node( 'pSphere1' )
sha = baseSphere.shader.a.surfaceShader.input.node
distance = 30
samples = mn.createNode( 'transform' )
samples.name = 'samples'
samplesCount = 30
centersCount = 5
for n in range(samplesCount):
    newSphere = baseSphere.duplicate()
    newSha = sha.duplicate()
    newSphere.a.t.v = [rd.uniform( -(distance),distance ),
                        rd.uniform( -(distance),distance ),
                        rd.uniform( -(distance),distance )]
    newSha.a.outColor.v = [rd.uniform(0,1),
                            rd.uniform(0,1),
                            rd.uniform(0,1)]
    mc.select( newSphere )
    mc.hyperShade( a = newSha )
    newSphere.a.t >> rbfNode.attr( "inPos[" + str( n ) + "]" )
    newSha.a.outColorR >> rbfNode.attr( "inValues[" + str( n ) + "].inValue[0]" )
    newSha.a.outColorG >> rbfNode.attr( "inValues[" + str( n ) + "].inValue[1]" )
    newSha.a.outColorB >> rbfNode.attr( "inValues[" + str( n ) + "].inValue[2]" )
    newSphere.parent = samples

centers = mn.createNode( 'transform' )
centers.name = 'centers_grp'
for n in range(centersCount):