Esempio n. 1
0
                                              'cgmObject',
                                              setClass=True)
                    mi_group.parent = mi_follicleAttachTrans

                #Create decompose node --------------------------------------------------------------
                mi_worldTranslate = cgmMeta.cgmNode(nodeType='decomposeMatrix')
                mi_worldTranslate.doStore('cgmName', self.mi_obj)
                mi_worldTranslate.doName()
                self.mi_worldTranslate = mi_worldTranslate

                attributes.doConnectAttr(
                    "%s.worldMatrix" % (mi_controlLoc.mNode),
                    "%s.%s" % (mi_worldTranslate.mNode, 'inputMatrix'))

                #Create node --------------------------------------------------------------
                mi_cpos = NodeF.createNormalizedClosestPointNode(
                    self.mi_obj, self.mi_targetSurface)

                attributes.doConnectAttr(
                    (mi_cpos.mNode + '.out_uNormal'),
                    (mi_follicleFollowShape.mNode + '.parameterU'))
                attributes.doConnectAttr(
                    (mi_cpos.mNode + '.out_vNormal'),
                    (mi_follicleFollowShape.mNode + '.parameterV'))
                #attributes.doConnectAttr  ((mi_controlLoc.mNode+'.translate'),(mi_cpos.mNode+'.inPosition'))
                attributes.doConnectAttr(
                    (mi_worldTranslate.mNode + '.outputTranslate'),
                    (mi_cpos.mNode + '.inPosition'))

                #Constrain =====================================================================
                #mc.pointConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
                #mc.orientConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
Esempio n. 2
0
	def _create(self):
	    #>> Quick links ============================================================================ 
	    d_closestInfo = self.d_closestInfo
	    
	    if self.b_attachControlLoc or not self.b_createControlLoc:
		try:#>>> Follicle ============================================================================	    
		    l_follicleInfo = nodes.createFollicleOnMesh(self.mi_targetSurface.mNode)
		    mi_follicleAttachTrans = cgmMeta.asMeta(l_follicleInfo[1],'cgmObject',setClass=True)
		    mi_follicleAttachShape = cgmMeta.asMeta(l_follicleInfo[0],'cgmNode')	    
		    
		    #> Name ----------------------------------------------------------------------------------
		    mi_follicleAttachTrans.doStore('cgmName',self.mi_obj.mNode)
		    mi_follicleAttachTrans.addAttr('cgmTypeModifier','attach',lock=True)
		    mi_follicleAttachTrans.doName()
		    
		    #>Set follicle value ---------------------------------------------------------------------
		    mi_follicleAttachShape.parameterU = d_closestInfo['normalizedU']
		    mi_follicleAttachShape.parameterV = d_closestInfo['normalizedV']
		    
		    self.mi_follicleAttachTrans = mi_follicleAttachTrans#link
		    self.mi_follicleAttachShape = mi_follicleAttachShape#link
		    self.mi_obj.connectChildNode(mi_follicleAttachTrans,"follicleAttach","targetObject")
		    self.md_return["follicleAttach"] = mi_follicleAttachTrans
		    self.md_return["follicleAttachShape"] = mi_follicleAttachShape
		except Exception,error:raise StandardError,"!Attach Follicle! | %s"%(error)
	    
	    if not self.b_createControlLoc:#If we don't have a control loc setup, we're just attaching to the surface
		try:#Groups =======================================================================================
		    mi_followGroup = self.mi_obj.doDuplicateTransform(True)
		    mi_followGroup.doStore('cgmName',self.mi_obj.mNode)
		    mi_followGroup.addAttr('cgmTypeModifier','follow',lock=True)
		    mi_followGroup.doName()	    
		    mi_followGroup.parent = mi_follicleAttachTrans
		    
		    if self.b_parentToFollowGroup:
			#raise StandardError,"shouldn't be here"		    
			self.mi_obj.parent = mi_followGroup	
			self.md_return["followGroup"] = mi_followGroup
		    else:
			#Driver loc -----------------------------------------------------------------------
			mi_driverLoc = self.mi_obj.doLoc()
			mi_driverLoc.doStore('cgmName',self.mi_obj.mNode)
			mi_driverLoc.addAttr('cgmTypeModifier','driver',lock=True)
			mi_driverLoc.doName()
			self.mi_driverLoc = mi_driverLoc
			mi_driverLoc.parent = mi_followGroup
			mi_driverLoc.visibility = False
		    
			self.md_return["driverLoc"] = mi_driverLoc
			#Constrain =====================================================================
			#mc.pointConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
			#mc.orientConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)  
			if self.b_pointAttach:
			    mc.pointConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
			else:
			    mc.parentConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
			
		except Exception,error:raise StandardError,"!Groups - no control Loc setup! | %s"%(error)
		
		
	    else:#Setup control loc stuff
		try:#>>> Follicle ============================================================================
		    l_follicleInfo = nodes.createFollicleOnMesh(self.mi_targetSurface.mNode)
		    mi_follicleFollowTrans = cgmMeta.asMeta(l_follicleInfo[1],'cgmObject',setClass=True)
		    mi_follicleFollowShape = cgmMeta.asMeta(l_follicleInfo[0],'cgmNode')
		    
		    #> Name ----------------------------------------------------------------------------------
		    mi_follicleFollowTrans.doStore('cgmName',self.mi_obj.mNode)
		    mi_follicleFollowTrans.addAttr('cgmTypeModifier','follow',lock=True)
		    mi_follicleFollowTrans.doName()
		    
		    #>Set follicle value ---------------------------------------------------------------------
		    mi_follicleFollowShape.parameterU = d_closestInfo['normalizedU']
		    mi_follicleFollowShape.parameterV = d_closestInfo['normalizedV']
		    
		    self.mi_follicleFollowTrans = mi_follicleFollowTrans#link
		    self.mi_follicleFollowShape = mi_follicleFollowShape#link
		    self.md_return["follicleFollow"] = mi_follicleFollowTrans
		    self.md_return["follicleFollowShape"] = mi_follicleFollowShape
		    
		    self.mi_obj.connectChildNode(mi_follicleFollowTrans,"follicleFollow")
		    
		    #Groups =======================================================================================
		    mi_followGroup = mi_follicleFollowTrans.duplicateTransform()
		    mi_followGroup.doStore('cgmName',self.mi_obj.mNode)
		    mi_followGroup.addAttr('cgmTypeModifier','follow',lock=True)
		    mi_followGroup.doName()
		    self.mi_followGroup = mi_followGroup
		    self.mi_followGroup.parent = mi_follicleFollowTrans
		    self.md_return["followGroup"] = mi_followGroup	
		    
		except Exception,error:raise StandardError,"!Follicle - attach Loc setup! | %s"%(error)
		    
		mi_offsetGroup = self.mi_obj.duplicateTransform()
		mi_offsetGroup.doStore('cgmName',self.mi_obj.mNode)
		mi_offsetGroup.addAttr('cgmTypeModifier','offset',lock=True)
		mi_offsetGroup.doName()
		mi_offsetGroup.parent = mi_followGroup
		self.mi_offsetGroup = mi_offsetGroup 
		self.md_return["offsetGroup"] = mi_offsetGroup
		
		if self.b_attachControlLoc:mi_follicleFollowTrans.connectChildNode(mi_offsetGroup,"followOffsetGroup","follicle")
	
		mi_zeroGroup = cgmMeta.asMeta( mi_offsetGroup.doGroup(True),'cgmObject',setClass=True)	 
		mi_zeroGroup.doStore('cgmName',self.mi_obj.mNode)
		mi_zeroGroup.addAttr('cgmTypeModifier','zero',lock=True)
		mi_zeroGroup.doName()	    
		mi_zeroGroup.parent = mi_followGroup
		self.mi_zeroGroup = mi_zeroGroup
		self.md_return["zeroGroup"] = mi_zeroGroup	
		    
		#Driver loc -----------------------------------------------------------------------
		mi_driverLoc = self.mi_obj.doLoc()
		mi_driverLoc.doStore('cgmName',self.mi_obj.mNode)
		mi_driverLoc.addAttr('cgmTypeModifier','driver',lock=True)
		mi_driverLoc.doName()
		self.mi_driverLoc = mi_driverLoc
		mi_driverLoc.parent = mi_offsetGroup
		mi_driverLoc.visibility = False
		
		self.md_return["driverLoc"] = mi_driverLoc
		
		#Closest setup =====================================================================
		mi_controlLoc = self.mi_obj.doLoc()
		mi_controlLoc.doStore('cgmName',self.mi_obj.mNode)
		mi_controlLoc.addAttr('cgmTypeModifier','control',lock=True)
		mi_controlLoc.doName()
		self.mi_controlLoc = mi_controlLoc
		self.md_return["controlLoc"] = mi_controlLoc
		
		if self.b_attachControlLoc:
		    mi_group = cgmMeta.asMeta( mi_controlLoc.doGroup(),'cgmObject',setClass=True )
		    mi_group.parent = mi_follicleAttachTrans
		    
		#Create decompose node --------------------------------------------------------------
		mi_worldTranslate = cgmMeta.cgmNode(nodeType = 'decomposeMatrix')
		mi_worldTranslate.doStore('cgmName',self.mi_obj.mNode)
		mi_worldTranslate.doName()
		self.mi_worldTranslate = mi_worldTranslate
	    
		attributes.doConnectAttr("%s.worldMatrix"%(mi_controlLoc.mNode),"%s.%s"%(mi_worldTranslate.mNode,'inputMatrix'))
		
		#Create node --------------------------------------------------------------
		mi_cpos = NodeF.createNormalizedClosestPointNode(self.mi_obj,self.mi_targetSurface)
    
		attributes.doConnectAttr ((mi_cpos.mNode+'.out_uNormal'),(mi_follicleFollowShape.mNode+'.parameterU'))
		attributes.doConnectAttr  ((mi_cpos.mNode+'.out_vNormal'),(mi_follicleFollowShape.mNode+'.parameterV'))
		#attributes.doConnectAttr  ((mi_controlLoc.mNode+'.translate'),(mi_cpos.mNode+'.inPosition'))
		attributes.doConnectAttr  ((mi_worldTranslate.mNode+'.outputTranslate'),(mi_cpos.mNode+'.inPosition'))
		
		#Constrain =====================================================================
		#mc.pointConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
		#mc.orientConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)    
		
		if self.b_pointAttach:
		    mc.pointConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
		else:
		    mc.parentConstraint(self.mi_driverLoc.mNode, self.mi_obj.mNode, maintainOffset = True)
		    
		if self.b_attachControlLoc:
		    for attr in self.mi_orientation.p_string[0]:
			attributes.doConnectAttr  ((mi_controlLoc.mNode+'.t%s'%attr),(mi_offsetGroup.mNode+'.t%s'%attr))
		    
		if self.b_createUpLoc:#Make our up loc =============================================================
		    mi_upLoc = mi_zeroGroup.doLoc()
		    mi_upLoc.doStore('cgmName',self.mi_obj.mNode)
		    mi_upLoc.addAttr('cgmTypeModifier','up',lock=True)
		    mi_upLoc.doName()
		    mi_upLoc.parent = mi_zeroGroup
		    self.md_return["upLoc"] = mi_upLoc
		    mi_follicleFollowTrans.connectChildNode(mi_upLoc,"followUpLoc","follicle")
		    
		    #Move it ----------------------------------------------------------------------------------------
		    mi_upLoc.__setattr__("t%s"%self.mi_orientation.p_string[0],self.f_offset)
	    
	    if self.md_return.get("follicleFollow"):
		mi_follicleFollowTrans.connectChild(mi_driverLoc,"driverLoc","follicle")
				
	    return self.md_return