Ejemplo n.º 1
0
def rig_crankshaft():
	#cmds.file("/jobs/pennzoilPennzoilNaturalGas_5402237/build/piston/release/work/mayaScene/pistonBuild/vLatest/mayaScene_pistonBuild_vLatest.ma",
	#          i=True, type="mayaAscii", ignoreVersion=True,rpr="mayaScene_pistonBuild_vLatest",options="v=0",pr=True,loadReferenceDepth="all")
	#setup variables for existing nodes
	global_ctrl=pm.PyNode('global_CTRL')
	global_loc=pm.PyNode('global_LOC')
	crankshaft_ctrl = pm.PyNode('crankshaft_CTRL')
	crankshaft_loc = pm.PyNode('crankshaft_LOC')
	display_ctrl = mpc.rig_makeCtrlLabel('display')
	
	#create piston controls
	for piston in range(0,global_loc.numPistons.get()):
		ctrl_offset = mpc.rig_ctrlDuplicate(crankshaft_ctrl, 'piston'+string.uppercase[piston]+'_mover')
		weight_loc = pm.PyNode('weight%s_LOC'%string.uppercase[piston])
		rod_loc = pm.PyNode('rod%s_LOC'%string.uppercase[piston])
		head_loc = pm.PyNode('head%s_LOC'%string.uppercase[piston])
		piston_loc = pm.PyNode('piston%s_LOC'%string.uppercase[piston])
		if ctrl_offset[0]:
			pm.delete( pm.parentConstraint(weight_loc, ctrl_offset[0] ) )
			ctrl_offset[0].rx.set(90)
			pm.parentConstraint(ctrl_offset[2], piston_loc, mo=True)
		else:
			pm.delete( pm.parentConstraint(weight_loc, ctrl_offset[1] ) )
			pm.parentConstraint(ctrl_offset[2], piston_loc, mo=True)
		mpc.rig_ctrlLock([ctrl_offset[1]], ['tx','ty','tz','rz','ry','sx','sy','sz','v'], setKeyable=False, lock=True)
		mpc.rig_ctrlColor(ctrl_offset[1], 15)
		
	#setup connections
	pm.delete( pm.parentConstraint(  crankshaft_ctrl.getParent(), crankshaft_loc ) )
	pm.parentConstraint( crankshaft_ctrl, crankshaft_loc,  mo=True )
	
	#parent + create groups + lock down ctrls
	grp_csr = pm.group(em=True,n='crankshaftRig_GRP')
	grp_model = pm.group(em=True,n='model_GRP')
	grp_nodes = pm.group(em=True,n='nodes_GRP')
	grp_model.setParent(grp_csr)
	grp_nodes.setParent(grp_csr)
	global_ctrl.getParent().setParent(grp_csr)
	global_loc.setParent(grp_nodes)
	global_loc.visibility.set(0)
	display_ctrl.getParent().setParent(global_ctrl)
	display_ctrl.getParent().ty.set(pm.xform('headA_LOC', q=True , t=True, ws=True)[1])
	mpc.rig_ctrlLock([crankshaft_ctrl], ['tx','ty','tz','rz','ry','sx','sy','sz','v'], setKeyable=False, lock=True)
	pm.scaleConstraint( global_ctrl, grp_nodes, mo=True )
	display_ctrl.addAttr('displayLocators', at='long', min=0,max=1, k=True)
	display_ctrl.displayLocators.connect(global_loc.v, f=True)
	
	if pm.objExists('pistons_lodA_GRP'):
		pm.PyNode('pistons_lodA_GRP').setParent(grp_model)
	
	#Create Sets
	rp_set = mpc.rig_setsCreateHubSet([grp_csr], 'crankshaft', 'rigPuppet')
	ac_set = mpc.rig_setsCreateHubSet(pm.ls('*CTRL'), 'crankshaft','animCurves')
	gc_set = mpc.rig_setsCreateHubSet(pm.ls('*GEO'), 'crankshaft','geometryCache')
	pm.delete('hubMayaScenePistonBuildSet')
	pm.sets(rp_set, add=(ac_set, gc_set))
Ejemplo n.º 2
0
def aw_bakeCam():
	'''Takes a camera, duplicates it, bakes it and then 
	'''
	localUser = os.environ[ 'USER' ]
	localProject=os.environ[ 'MAYA_PROJECT' ]
	shotName=localProject.split("/")[-2]
	cams=pm.ls(sl=True)
	#Selection error checking
	for cam in cams:
		if cam.getShape().type()=='camera':
			#Store and set new camera
			camName = (shotName + "_CAM")
			cam_dup=pm.camera(n=camName)[0]
			copyCamSettings(cam,cam_dup)
			secureCam(cam_dup,lock=False)
			#Parent Constrain
			pc=pm.parentConstraint(cam,cam_dup)
			#Set start and end frame and bake to sequence
			begFrame = pm.playbackOptions(q=True,ast=True)
			endFrame = pm.playbackOptions(q=True,aet=True)
			pm.bakeResults(cam_dup,
						sparseAnimCurveBake=False,
						removeBakedAttributeFromLayer=False,
						bakeOnOverrideLayer=False,
						preserveOutsideKeys=True,
						simulation=True,
						sampleBy=1,
						shape=True,
						t=(begFrame,endFrame),
						at=["tx", "ty", "tz", "rx", "ry", "rz"],
						disableImplicitControl=True,
						controlPoints=False)
			#Clean up and delete
			pm.delete(pc)
			attachImagePlane( cam_dup, localProject, localUser, shotName )
			secureCam(cam_dup,lock=False)
			mpc.rig_setsCreateHubSet([pm.PyNode(cam_dup)], cam_dup, 'camera')