Beispiel #1
0
    def createMotionTrail(self, ctrls):

        cmds.waitCursor(state=True)
        self.saveTwistObjsInfo()
        self.createMainGroup()

        for loopCtrl in ctrls:
            ctrlName = self.getCtrlName(loopCtrl)
            groupNode = self.createCtrlGroup(ctrlName)

            if not groupNode: continue

            motionTrail = "%s_aTools_motionTrail" % ctrlName
            offsetNode = "%s_aTools_offset" % ctrlName
            currentLocators = [motionTrail, offsetNode]

            for loopLocator in currentLocators:
                animMod.createNull(loopLocator)
            cmds.hide(currentLocators)

            motionTrailList = self.createMotionTrailNode(offsetNode)
            motionTrailTransform = motionTrailList[0]
            motionTrailAttr = motionTrailList[1]
            motionTrailNode = motionTrailList[2]
            self.nodeInfo[ctrlName] = {
                "ctrlNode": loopCtrl,
                "offsetNode": offsetNode,
                "groupNode": groupNode,
                "motionTrailTransform": motionTrailTransform,
                "motionTrailAttr": motionTrailAttr,
                "motionTrailNode": motionTrailNode,
                "lineColor": self.lineColorCycle.next()
            }

            with G.aToolsBar.createAToolsNode:

                cmds.parent(offsetNode, motionTrail)
                cmds.parent(motionTrail, groupNode)
                cmds.parent(motionTrailTransform, groupNode)
                cmds.parent(groupNode, self.mainGroupNode)
                cmds.parentConstraint(loopCtrl, motionTrail)

            if self.offsetCtrlsPosition.has_key(ctrlName):
                offsetNodePosition = self.offsetCtrlsPosition[ctrlName][0]
                if offsetNodePosition != (0, 0, 0):
                    cmds.setAttr("%s.translate" % offsetNode,
                                 offsetNodePosition[0], offsetNodePosition[1],
                                 offsetNodePosition[2])

            self.makeDirty(ctrlName)

        cmds.select(ctrls)
        self.updateMotionTrail(lightningMode=True)
        self.updateKeysTimes()
        self.updateSortedRange()
        cmds.waitCursor(state=False)
Beispiel #2
0
def cameraOrientMoveManip():
    selection = cmds.ls(selection=True)
    if len(selection) == 0: return

    shotCamera = animMod.getShotCamera()
    if not shotCamera or not cmds.objExists(shotCamera):
        cmds.warning("No shot camera detected.")
        return

    cmds.refresh(suspend=True)

    sourceObjs = selection[0:-1]
    targetObj = selection[-1]
    locator = animMod.createNull("tempCameraOrient_locator")
    cameraNode = utilMod.getCamFromSelection([shotCamera])[0]

    G.aToolsBar.align.align([locator], targetObj, translate=True, rotate=False)
    with G.aToolsBar.createAToolsNode:
        constraint = cmds.aimConstraint(cameraNode,
                                        locator,
                                        name="tempCameraOrient_constraint",
                                        aimVector=[0, 0, 1],
                                        worldUpType="objectrotation",
                                        worldUpObject=cameraNode,
                                        maintainOffset=False)[0]

    cmds.select(selection)
    cmds.select(locator, add=True)
    orientMoveManip()

    if cmds.objExists(locator): cmds.delete(locator)
    if cmds.objExists(constraint): cmds.delete(constraint)

    cmds.refresh(suspend=False)
Beispiel #3
0
def cameraOrientMoveManip():
    selection   = cmds.ls(selection=True)    
    if len(selection) == 0: return
    
    shotCamera = animMod.getShotCamera()    
    if not shotCamera or not cmds.objExists(shotCamera): 
        cmds.warning("No shot camera detected.")
        return
    
    cmds.refresh(suspend=True)
    
    sourceObjs      = selection[0:-1]
    targetObj       = selection[-1]    
    locator         = animMod.createNull("tempCameraOrient_locator")
    cameraNode      = utilMod.getCamFromSelection([shotCamera])[0]
        
    G.aToolsBar.align.align([locator], targetObj, translate=True, rotate=False)   
    with G.aToolsBar.createAToolsNode: constraint = cmds.aimConstraint(cameraNode, locator, name="tempCameraOrient_constraint", aimVector=[0, 0, 1], worldUpType="objectrotation", worldUpObject=cameraNode, maintainOffset=False)[0]

    cmds.select(selection)
    cmds.select(locator, add=True)
    orientMoveManip()
  
    if cmds.objExists(locator):         cmds.delete(locator)
    if cmds.objExists(constraint):      cmds.delete(constraint)
    
    cmds.refresh(suspend=False)
Beispiel #4
0
 def createMotionTrail(self, ctrls):
     
     cmds.waitCursor(state=True)
     self.saveTwistObjsInfo()        
     self.createMainGroup()
     
     for loopCtrl in ctrls: 
         ctrlName                    = self.getCtrlName(loopCtrl)
         groupNode                   = self.createCtrlGroup(ctrlName)
         
         if not groupNode: continue
         
         motionTrail                 = "%s_aTools_motionTrail"%ctrlName
         offsetNode                  = "%s_aTools_offset"%ctrlName
         currentLocators             = [motionTrail, offsetNode]
         
         for loopLocator in currentLocators: animMod.createNull(loopLocator)
         cmds.hide(currentLocators)
         
         motionTrailList             = self.createMotionTrailNode(offsetNode)
         motionTrailTransform        = motionTrailList[0]
         motionTrailAttr             = motionTrailList[1]
         motionTrailNode             = motionTrailList[2]
         self.nodeInfo[ctrlName]     = {"ctrlNode":loopCtrl, "offsetNode":offsetNode, "groupNode":groupNode, "motionTrailTransform":motionTrailTransform, "motionTrailAttr":motionTrailAttr, "motionTrailNode":motionTrailNode, "lineColor":self.lineColorCycle.next()}            
         
         
         with G.aToolsBar.createAToolsNode: 
             
             cmds.parent(offsetNode, motionTrail) 
             cmds.parent(motionTrail, groupNode)
             cmds.parent(motionTrailTransform, groupNode)
             cmds.parent(groupNode, self.mainGroupNode)
             cmds.parentConstraint(loopCtrl, motionTrail)
             
         
         if self.offsetCtrlsPosition.has_key(ctrlName): 
             offsetNodePosition = self.offsetCtrlsPosition[ctrlName][0]
             if offsetNodePosition != (0,0,0): cmds.setAttr("%s.translate"%offsetNode, offsetNodePosition[0], offsetNodePosition[1], offsetNodePosition[2])
        
         self.makeDirty(ctrlName)
         
     cmds.select(ctrls)
     self.updateMotionTrail(lightningMode=True)
     self.updateKeysTimes() 
     self.updateSortedRange() 
     cmds.waitCursor(state=False)
Beispiel #5
0
    def copy(self, *args):
        #print "copy"
        self.selection   = cmds.ls(selection=True)
        
        if len(self.selection) < 1: 
            cmds.warning("You need to select at least 2 objects.")
            return
        if len(self.selection) == 1:
            self.copyWorld()
            return
        
        if len(self.selection) > 20: 
            message         = "Too many objects selected, continue?"
            confirm         = cmds.confirmDialog( title='Confirm', message=message, button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
            if confirm != 'Yes': return  
        
        cmds.refresh(suspend=True)
        cmds.undoInfo(stateWithoutFlush=False)        
        self.flushCopyCache(force=True)        
        self.scriptJob()       
        
        self.sourceObjs = self.selection[0:-1]
        self.targetObj  = self.selection[-1] 
        selObjects      = utilMod.getNameSpace(self.selection)[1]                
        self.locators   = []
        
        self.locatorGroup = animMod.group(name=self.locatorGroupName)      
        G.aToolsBar.align.align([self.locatorGroup], self.targetObj)
        self.locators.append(self.locatorGroup) 
         
        
        for loopObj in self.sourceObjs:
            
            nameSpace       = utilMod.getNameSpace([loopObj])
            loopSelName     = "%s_%s"%(nameSpace[0][0], nameSpace[1][0]) 
            locatorName     = "fakeConstrain_%s"%loopSelName 
            
            locator = animMod.createNull(locatorName)            
            self.locators.append(locator)
            with G.aToolsBar.createAToolsNode: cmds.parent(locator, self.locatorGroup)            
            G.aToolsBar.align.align([locator], loopObj)
            
            matrix     = cmds.xform(locator, query=True, matrix=True)

            self.copyCache.append(matrix)
        
        self.clearLocators()
        
        cmds.select(self.selection)
        
        cmds.iconTextButton("fakeConstrainBtn", edit=True, image= uiMod.getImagePath("specialTools_fake_constrain_active"),         highlightImage= uiMod.getImagePath("specialTools_fake_constrain_active copy"))
       
        cmds.refresh(suspend=False)
        cmds.undoInfo(stateWithoutFlush=True)
Beispiel #6
0
 def create(self, *args):
     
     
     img = cmds.iconTextButton("TempCustomPivotBtn", query=True, image=True)
     onOff = (img[-10:-4] == "active")
     if onOff: 
         self.clear()
         cmds.select(self.sel)
         return
     
     cmds.undoInfo(openChunk=True)
     cmds.undoInfo(closeChunk=True)
     cmds.undoInfo(openChunk=True)
     cmds.undoInfo(closeChunk=True)
     cmds.undoInfo(openChunk=True)
     cmds.undoInfo(closeChunk=True)
     cmds.undoInfo(openChunk=True)
     
     self.clear()       
     
     
     getCurves  = animMod.getAnimCurves()
     animCurves = getCurves[0]
     getFrom    = getCurves[1] 
     
     if animCurves:        
         keyTimes            = animMod.getTarget("keyTimes", animCurves, getFrom)
           
     self.sel = cmds.ls(selection=True)
     if not self.sel: return
             
     cmds.iconTextButton("TempCustomPivotBtn", edit=True, image= uiMod.getImagePath("specialTools_create_temp_custom_pivot_active"),         highlightImage= uiMod.getImagePath("specialTools_create_temp_custom_pivot_active"))
    
     targetObj  = self.sel[-1]  
     aToolsMod.saveInfoWithScene(self.STORE_NODE, self.CTRLS, self.sel)
     
     currentFrame = cmds.currentTime(query=True) 
     aToolsMod.saveInfoWithScene(self.STORE_NODE, self.CURRENTFRAME, currentFrame)
     
     locators = []
     for loopSel in self.sel: 
         nameSpace       = utilMod.getNameSpace([loopSel])
         loopSelName     = "%s_%s"%(nameSpace[0][0], nameSpace[1][0])  
         locatorName     = "tempCustomPivot_%s"%loopSelName
         
         locator = animMod.createNull(locatorName)
         locators.append(locator)
     
         G.aToolsBar.align.align([locator], loopSel)
     
         
     locatorGroup = "tempCustomPivot_group"
     animMod.group(name=locatorGroup)        
     G.aToolsBar.align.align([locatorGroup], targetObj)
     with G.aToolsBar.createAToolsNode: cmds.parent(locators, locatorGroup)
     cmds.select(locatorGroup, replace=True)
     
     locators.append(locatorGroup)   
     
     aToolsMod.saveInfoWithScene(self.STORE_NODE, self.LOCATORS, locators)
  
     #parent ctrls to locator
     constraints = ["%s_tempCustomPivot_constraint"%loopConstraint for loopConstraint in self.sel]
     
     aToolsMod.saveInfoWithScene(self.STORE_NODE, self.CONSTRAINTS, constraints)
     
     for n, loopSel in enumerate(self.sel):
         with G.aToolsBar.createAToolsNode: cmds.parentConstraint(locators[n], loopSel, name=constraints[n], maintainOffset=True)
         constraintNode = "%s.blendParent1"%loopSel
         if not cmds.objExists(constraintNode): continue
         cmds.setKeyframe(constraintNode)
         if keyTimes:
             for loopTime in keyTimes[0]:
                 cmds.setKeyframe("%s.tx"%locatorGroup, time=(loopTime,loopTime))
                 if loopTime != currentFrame:
                     cmds.setKeyframe(constraintNode, time=(loopTime,loopTime), value=0)
     
     #enter edit mode
     cmds.setToolTo(cmds.currentCtx())
     cmds.ctxEditMode()
     
     #scriptjob    
     cmds.scriptJob(runOnce = True, killWithScene = True,  event =('SelectionChanged',  self.scriptJob_SelectionChanged))
Beispiel #7
0
 def paste(self, type="onlyKeys"):
     
     cmds.refresh(suspend=True)        
         
     selObjects      = utilMod.getNameSpace(self.selection)[1]  
     self.locators   = []
     
     if self.targetObj != "world":
         #CREATE
         self.locatorGroup = animMod.group(name=self.locatorGroupName)   
          
         for n, loopObj in enumerate(self.sourceObjs):
             
             nameSpace       = utilMod.getNameSpace([loopObj])
             loopSelName     = "%s_%s"%(nameSpace[0][0], nameSpace[1][0]) 
             locatorName     = "fakeConstrain_%s"%loopSelName 
             
             locator = animMod.createNull(locatorName)            
             self.locators.append(locator)
             with G.aToolsBar.createAToolsNode: cmds.parent(locator, self.locatorGroup)   
            
         self.locators.append(self.locatorGroup)
     
     currFrame   = cmds.currentTime(query=True)
     getCurves   = animMod.getAnimCurves()
     animCurves  = getCurves[0]
     getFrom     = getCurves[1]         
     
     if animCurves:
         keysSel = animMod.getTarget("keysSel", animCurves, getFrom)
         keysSel = utilMod.mergeLists(keysSel)    
         if keysSel == []:
              keysSel = [currFrame]   
     else:
         keysSel = [currFrame]
     
     frames = keysSel
     
     if type == "allFrames":
         frameRange = animMod.getTimelineRange(float=False)
         frames = list(range(int(frameRange[0]),int(frameRange[1])))
         
     if self.targetObj != "world":
         G.aToolsBar.align.align([self.locatorGroup], self.targetObj, frames=frames)
                     
     for n, loopObj in enumerate(self.sourceObjs):
              
         matrix     = self.copyCache[n]         
         
         if self.targetObj != "world":
             cmds.xform(self.locators[n], matrix=matrix)
                     
             G.aToolsBar.align.align([loopObj], self.locators[n], frames=frames, showProgress=True)
             
         else:
             for loopFrame in frames:
                 cmds.currentTime(loopFrame)          
                 cmds.xform(loopObj, ws=True, matrix=matrix)
             
             cmds.currentTime(currFrame)
                     
         for loopFrame in frames:
             for loopAttr in ["translate", "rotate"]:
                 breakdown = (loopFrame not in keysSel)
                 cmds.keyframe(loopObj, edit=True, attribute=loopAttr, time=(loopFrame, loopFrame), breakdown=breakdown)
     
         
     if self.targetObj != "world":
         self.clearLocators()     
         cmds.select(self.selection) 
     
     cmds.refresh(suspend=False)