Пример #1
0
def _makeOrSet( cameraSet, layerId, objectSet, setObj, add=True ):
	objSet = objectSet
	if not objSet:
		objSet = cmds.createNode( 'objectSet' )
		cmds.cameraSet( cameraSet, edit=True, layer=layerId, objectSet=objSet )
	if add: 
		cmds.sets( setObj, addElement=objSet )
	else:
		cmds.sets( setObj, remove=objSet )
def switchToCamera(*args):
    """
	Switch the viewport editor the specified camera name.
	"""
    if not stereoCameraUtil.runCallbackChecks():
        return
    editor = args[1]
    cameraName = args[0]
    root = cameraName

    # Display an error to the user if the camera set contains no data.
    #
    if cmds.objectType(cameraName, isa="cameraSet"):
        nl = cmds.cameraSet(cameraName, query=True, numLayers=True)
        if nl == 0:
            stereoCameraErrors.displayError('kNoDataInCameraSet', cameraName)

    editor = getValidPanel(editor)

    # Users can switch to a stereo camera using camera sets or via
    # rigs.  If it is a camera set then we don't need to find the
    # root.  We can simply view that camera set.
    #
    if not cmds.objectType(cameraName, isa="cameraSet"):
        root = stereoCameraRig.rigRoot(cameraName)

    cmds.stereoCameraView(editor, edit=True, rigRoot=root)

    if len(args) > 2 and args[2]:
        # The 3rd argument indicates if we should select the camera
        # after assignment. It is tiggered by an option box on the
        # camera switcher.
        #
        cmds.select(cameraName, replace=True)
Пример #3
0
def __attachToCameraSet( rigRoot, cameraSet, objectSet=None ):
	"""
	Attach the rigRoot to the cameraSet and assign it to the camera
	set.  If an objectSet is provided then also attach it to the same layer
	"""
	if not objectSet: 
		cmds.cameraSet( cameraSet, edit=True, appendTo=True, camera=rigRoot )
	else:
		cmds.cameraSet( cameraSet, edit=True, appendTo=True, camera=rigRoot, objectSet=objectSet )
	layerId = cmds.cameraSet( cameraSet, query=True, numLayers=True )-1		
	rigType = stereoCameraRig.rigType( rigRoot )
	definitions = _getDefinition( rigType )
	keywords = {'cameraSet' : cameraSet,
				'layer' : layerId}
	args = [rigRoot]
	_callFromDefinition( definitions, rigType, keywords, args ) 
Пример #4
0
def parentToLayer0Rig( rigRoot, cameraSet=None ):
	"""
	When adding a new layer to a camera set, the most common desired
	placement of that new rig is under the primary camera, which is
	at layer 0. This function performs the task of looking up the
	transform at layer 0 and parenting the new rig under its
	transform. 
	"""
	
	if cameraSet and len(rigRoot)>0:
		layers = cmds.cameraSet( cameraSet, query=True, numLayers=True )
		if layers == 0:
			return
		camSetRig = cmds.cameraSet( cameraSet,
									query=True, layer=0, camera=True )
		camSetRigParent = cmds.ls( camSetRig, long=True, dag=True )[0]
		rigRootToParent = cmds.ls( rigRoot, long=True, dag=True )[0]
			
		if camSetRigParent != rigRootToParent and cmds.objectType( rigRootToParent, isa="transform" ):
			cmds.parent( rigRootToParent, camSetRigParent, relative=True )
Пример #5
0
def _gatherSelObjects():
    """
	Private method that gets the active selection list, finds all selected
	transforms and returns two lists:
	1) a list of cameras attached to camera sets stuff into a python set in the
   	   form  (cameraSet, cameraSet layerId, cameraName, objectSet)
	2) a list of objects to attach to the items found in 1)
	"""
    objects = cmds.ls(type="transform", sl=True)
    cameras = []
    setObj = []
    for x in objects:
        if (stereoCameraRig.isRigRoot(x)):
            cameras.append(x)
        else:
            setObj.append(x)
    camWithSets = []
    for c in cameras:
        connections = cmds.listConnections(c + ".message", t='cameraSet')
        if not connections:
            continue
        # Scan over all unique connections. list(set(connections))
        # uniquifies the list. A camera can belong to the same set
        # twice.
        #
        for con in list(set(connections)):
            layers = cmds.cameraSet(con, query=True, numLayers=True)
            for l in range(layers):
                camera = cmds.cameraSet(con, query=True, layer=l, camera=True)
                if (cmds.ls(camera, l=True) == cmds.ls(c, l=True)):
                    objSet = cmds.cameraSet(con,
                                            query=True,
                                            layer=l,
                                            objectSet=True)
                    camWithSets.append((con, l, camera, objSet))

    if len(camWithSets) == 0:
        stereoCameraErrors.displayError('kNoValidCameraSelected')
    if len(setObj) == 0:
        stereoCameraErrors.displayError('kNoObjectsSelected')
    return (camWithSets, setObj)
Пример #6
0
def __addCameraSetsMenuItem(rigCmd, camCmd, rig):
    """
	"""
    layers = cmds.cameraSet(rig, query=True, numLayers=True)
    if layers == 0:
        return
    cmds.menuItem(label=rig, command=(rigCmd % {'arg1': rig}))

    # Show the cameras under the rig, in a sub menu.
    # Show Left, Center, Right first, then a divider, then
    # other cameras if any.
    labelVal = maya.stringTable['y_stereoCameraMenus.kCameraSet'] % {
        'arg1': rig
    }
    cmds.menuItem(label=labelVal, subMenu=True)
    rigList = []
    for i in range(layers):
        rigList.append(cmds.cameraSet(rig, query=True, layer=i, camera=True))
    for r in rigList:
        __addRigMenuItem(rigCmd, camCmd, r)

    cmds.setParent('..', menu=True)
def switchToCameraSet(*args):
    """
	Switch the viewport editor the specified cameraSet name.
	"""
    if not stereoCameraUtil.runCallbackChecks():
        return
    editor = args[1]
    cameraSetName = args[0]
    editor = getValidPanel(editor)
    if cmds.objectType(cameraSetName, isa="cameraSet"):
        nl = cmds.cameraSet(cameraSetName, query=True, numLayers=True)
        if nl == 0:
            stereoCameraErrors.displayError('kNoDataInCameraSet',
                                            cameraSetName)
        else:
            cmds.stereoCameraView(editor, edit=True, rigRoot=cameraSetName)
Пример #8
0
def cameraSet(*args, **kwargs):
    res = cmds.cameraSet(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res