Beispiel #1
0
	def position_to_object( self, _obj, _offsetobject=None ) :
		target = _obj
		if( _offsetobject ) : target = _offsetobject

		zerogroup = self.zero_group()
		zerogroup.setTranslation( target.getTranslation( space='world' ), space='world' )
		zerogroup.setRotation( target.getRotation( space='world' ), space='world' )
		
		if( target != _obj ) :
			sdkgroup = self.sdk_group()
			sdkgroup.setTranslation( _obj.getTranslation( space='world' ), space='world' )
			sdkgroup.setRotation( _obj.getRotation( space='world' ), space='world' )

		# record which object we positioned it to
		utils.add_set_attr( self, relatedjointattr, _obj )
Beispiel #2
0
	def _postCreateVirtual( cls, node, **kwargs ) :
		node = pm.PyNode( node )

		utils.add_set_attr( node , settings.attrname, cls.PARTNAME )
		utils.add_set_attr( node , relatedjointattr, '' )
Beispiel #3
0
	def convert_to_virtual( cls, _transform ) :
		if( type( _transform ) == pm.Transform ) :
			return utils.add_set_attr( _transform, settings.attrname, cls.PARTNAME, _keyable=False, _locked=True )
		else :		
			utils.err( '%s is not a transform' % ( _transform.name() ) )	
			return False
Beispiel #4
0
	def connect_rigs( self, _blendcontrol=None ) :

		# get the object the blend attr should be added to
		blendcontrol = _blendcontrol
		if( not blendcontrol ) :
			blendcontrolname = utils.name_from_tags( settings.staticcontrols[ 'ikfkblend' ], 'control' )
			blendcontrol = pm.PyNode( blendcontrolname )

		try :
			# create the blend attr
			blendattrname = utils.name_from_tags( self.tree_root().name, 'blend' )
			self.blendattr = utils.add_set_attr( blendcontrol, blendattrname, 0.0 )
		except :
			utils.err( 'Could not create blend attribute on %s' % ( blendcontrol ) )
			return False

		# blend between rigs onto blendjointchain

		jointchains = self.tree_children( 'jointchain' )
		if( len( jointchains ) != 1 ) :
			utils.err( '%s does not have ONE jointchain in it\'s children. Not sure which to use as the blend chain.' % ( self ) )
			return False
		blendjoints = jointchains[0].all_joints()
		rigs = self.tree_children( '.*Rig' )
		multdivdict = {}

		# set min/max values for blendattr
		self.blendattr.setMin( 0 )
		self.blendattr.setMax( len( self.tree_children( '.*Rig' ) ) - 1 )

		for i, rig in enumerate( rigs ) :	
			for jointchain in rig.tree_children( 'jointchain' ) :
				rigjoints = jointchain.all_joints()
				if( len( rigjoints ) != len( blendjoints ) ) :
					utils.wrn( '%s has a different number of joints to %s. Skipping...' % ( jointchain, jointchains[0] ) )
					continue

				# create a triangle curve with float time offset by j
				# by overlapping each triangle, n number of rigs can be blended
				# _/\____     
				# __/\___   this is how 3 rigs would blend together
				# ___/\__

				animcurve = pm.nodetypes.AnimCurveUL()
				animcurve.rename( utils.name_from_tags( self.tree_root().name, 'blend', rig.PARTNAME, 'animcurveUL' ) )

				offset = i
				pm.setKeyframe( animcurve, f=-1 + offset, v=0 )
				pm.setKeyframe( animcurve, f=0 	+ offset, v=1 )
				pm.setKeyframe( animcurve, f=1 	+ offset, v=0 )
				
				self.blendattr >> animcurve.input

				multdivdict[ rig ] = []

				for rigjoint in rigjoints :
					# vary input of joints rotation by animcurve output
					multdiv = pm.nodetypes.MultiplyDivide()
					multdiv.rename( utils.name_from_tags( rigjoint, 'blend', rig.PARTNAME, 'multiplydivide' ) )
					multdivdict[ rig ].append( multdiv )
					# connect animcurev and rotate to multdiv
					animcurve.output 	>> multdiv.input1X
					animcurve.output 	>> multdiv.input1Y
					animcurve.output 	>> multdiv.input1Z
					rigjoint.rotate		>> multdiv.input2

				for j, blendjoint in enumerate( blendjoints ) :
					# use a PMA node to blend between the rigs
					pma = pm.nodetypes.PlusMinusAverage()
					pma.rename( utils.name_from_tags( blendjoint, 'blend', rig.PARTNAME, 'plusminusaverage' ) )
					pma.operation.set( 1 )

					# connect everything up
					k = 0
					for rig, multdivlist in multdivdict.iteritems() :
						multdivlist[j].output >> pma.input3D[k]
						k += 1

					pma.output3D >> blendjoint.rotate
Beispiel #5
0
	def convert_to_virtual( cls, _joint ) :
		if( type( _joint ) == pm.Joint ) :
			return utils.add_set_attr( _joint, settings.attrname, cls.PARTNAME, _keyable=False, _locked=True )
		else :		
			utils.err( '%s is not a joint' % ( _joint.name() ) )
			return False