예제 #1
0
def playblast_turntable(submit=True):
    logger = logging.getLogger(__name__)
    # get path
    obj = pipeFile.PathDetails.parse_path()
    local_video_path = obj.local_video_path
    work_video_path = obj.work_video_path
    current_project = obj.project
    # playblast
    model_name = get_model_name.get_model_name()
    resolution = Project(current_project).resolution
    percent = Project(current_project).playblast_percent
    set_image_size.set_image_size(*resolution)
    mc.select(model_name, r=1)
    create_turntable.create_turntable()
    create_parent_dir.create_parent_dir(local_video_path)
    playblaster.playblaster(local_video_path, "tt_camera", 1, 120, resolution,
                            percent, False, None, True)
    remove_turntable.remove_turntable()
    logger.info("playblast done.")
    mc.lookThru("persp")
    if submit:
        Copy.copy(local_video_path, work_video_path)
        logger.info("Copy %s >> %s" % (local_video_path, work_video_path))
        return work_video_path
    else:
        return local_video_path
예제 #2
0
def turntable():
    """
    Main function. Creates turntable. Requires a list of selected objects.
    :return: None
    """
    objs = cmds.ls(selection=True)
    meshes = checkSelection(objs)
    if not meshes:
        cmds.error('Please select a mesh object')
    pivlist = getSelectionPivot(meshes)
    turnCam = createCamera()
    centroid = findCentroid(pivlist)

    # change camera pivot to centroid
    cmds.xform(turnCam[0], ws=True, piv=centroid)

    # animate camera. rotate around y axis.
    firstFrame = str(cmds.playbackOptions(q=True, minTime=True))
    lastFrame = str(cmds.playbackOptions(q=True, maxTime=True))
    cmds.expression(name='TurnTableExpression',
                    string='{0}.rotateY=360*(frame-{1})/{2}-{1};'.format(turnCam[0],
                                                                         firstFrame, lastFrame))

    # create a 3 point light rig.
    keyLight = createLight('areaLight', 'key', centroid)
    fillLight = createLight('areaLight', 'fill', centroid)
    rimLight = createLight('areaLight', 'rim', centroid)
    cmds.lookThru(turnCam[0])
예제 #3
0
 def show(self, *args):
     if not self.__camera:
         self.__camera = mc.lookThru(q=1)
     # ----clear old huds---- #
     self.clear()
     # ----look through current camera ----#
     mc.lookThru(self.__camera)
     # ----set hud color ---- #
     mc.displayColor("headsUpDisplayLabels",
                     self.__hud_color["label_color"])
     mc.displayColor("headsUpDisplayValues",
                     self.__hud_color["value_color"])
     # ----create huds---- #
     for hud in self.__huds:
         label = self.__hud_dict[hud]["label"]
         section = self.__hud_dict[hud]["section"]
         block = mc.headsUpDisplay(nextFreeBlock=section)
         labelWidth = self.__hud_dict[hud]["labelWidth"]
         # event = self.__hud_dict[hud]["event"]
         labelFontSize = self.__hud_dict[hud]["labelFontSize"]
         dataFontSize = self.__hud_dict[hud]["dataFontSize"]
         blockSize = self.__hud_dict[hud]["blockSize"]
         command = self.__hud_dict[hud]["command"].format(
             camera=self.__camera)
         mc.headsUpDisplay(hud,
                           label=label,
                           section=section,
                           block=block,
                           labelWidth=labelWidth,
                           labelFontSize=labelFontSize,
                           dataFontSize=dataFontSize,
                           blockSize=blockSize,
                           attachToRefresh=True,
                           command=command)
예제 #4
0
	def makeCamera(self, arg = None) : 
		self.renderCameraName = mc.textField('%s_newCameraTX' % self.ui, q = True, tx = True)
		self.setRenderSetting()
		self.currentCamera = mc.lookThru(q = True)

		if self.currentCamera : 

			if not mc.objExists(self.renderCameraName) : 
				self.renderCamera = mc.duplicate(self.currentCamera, n = self.renderCameraName)

			else : 
				self.renderCamera = [self.renderCameraName]

			cameraShape = mc.listRelatives(self.renderCamera[0], s = True)[0]

			mc.setAttr('%s.panZoomEnabled' % cameraShape, 1)
			mc.setAttr('%s.renderPanZoom' % cameraShape, 1)
			mc.setAttr('%s.displayResolution' % cameraShape, 1)

			mc.textField('%s_cameraTX' % self.ui, e = True, tx = self.renderCamera[0])
			mc.textField('%s_crrCameraTX' % self.ui, e = True, tx = self.currentCamera)
			mc.lookThru(self.renderCamera[0])

		else : 
			print 'Cannot get current camera'
    def testStaticUsdCamera(self):
        self._StartTest('TranslateRotate_vs_xform')

        mayaPathSegment = mayaUtils.createUfePathSegment('|stage|stageShape')
        #camera1 doesn't work correctly right now because of an xformOp:transform issue MAYA-110515
        #cam1UsdPathSegment = usdUtils.createUfePathSegment('cameras/cam1/camera1')
        #cmds.lookThru('|stage|stageShape,/cameras/cam1/camera1')
        #self.assertSnapshotClose('%s_cam1_unselected.png' % self._testName)

        cmds.lookThru('|stage|stageShape,/cameras/cam2/camera2')
        self.assertSnapshotClose('%s_cam2_unselected.png' % self._testName)

        # create a Ufe transform3d and move cam2 somewhere else and do a snapshot
        cam2UsdPathSegment = usdUtils.createUfePathSegment(
            '/cameras/cam2/camera2')
        cam2Path = ufe.Path([mayaPathSegment, cam2UsdPathSegment])
        cam2Item = ufe.Hierarchy.createItem(cam2Path)
        cam2Transform3d = ufe.Transform3d.transform3d(cam2Item)
        cam2Transform3d.translate(-1, 0, 0)
        self.assertSnapshotClose('%s_cam2_translated.png' % self._testName)

        # create a Ufe Camera and modify the near clip plane and do a snapshot
        # ufe.Camera is not in Ufe 2.0.0 MAYA-110675
        # set the clipping range using the USD API instead
        usdCamera = usdUtils.getPrimFromSceneItem(cam2Item)
        clippingAttr = usdCamera.GetAttribute('clippingRange')
        clippingRange = clippingAttr.Get()
        clippingAttr.Set(Gf.Vec2f(10, 5000))
        self.assertSnapshotClose('%s_cam2_insideNearClipPlane.png' %
                                 self._testName)
예제 #6
0
def turntable():
    """
    Main function. Creates turntable. Requires a list of selected objects.
    :return: None
    """
    objs = cmds.ls(selection=True)
    meshes = checkSelection(objs)
    if not meshes:
        cmds.error('Please select a mesh object')
    pivlist = getSelectionPivot(meshes)
    turnCam = createCamera()
    centroid = findCentroid(pivlist)

    # change camera pivot to centroid
    cmds.xform(turnCam[0], ws=True, piv=centroid)

    # animate camera. rotate around y axis.
    firstFrame = str(cmds.playbackOptions(q=True, minTime=True))
    lastFrame = str(cmds.playbackOptions(q=True, maxTime=True))
    cmds.expression(name='TurnTableExpression',
                    string='{0}.rotateY=360*(frame-{1})/{2}-{1};'.format(
                        turnCam[0], firstFrame, lastFrame))

    # create a 3 point light rig.
    keyLight = createLight('areaLight', 'key', centroid)
    fillLight = createLight('areaLight', 'fill', centroid)
    rimLight = createLight('areaLight', 'rim', centroid)
    cmds.lookThru(turnCam[0])
예제 #7
0
    def save_snapshot(self, geo):
        # Create new camera, isolated selected object, frame and take snapshot
        # Delete cam and return to perspective cam
        self.create_img_cam()
        cmds.lookThru(self.cameraName)
        cmds.select(geo)

        if cmds.isolateSelect('modelPanel4', q=True, state=True):
            cmds.isolateSelect('modelPanel4', state=False)
            cmds.isolateSelect('modelPanel4', state=True)
            cmds.isolateSelect('modelPanel4', addSelected=True)
        else:
            cmds.isolateSelect('modelPanel4', state=True)
            cmds.isolateSelect('modelPanel4', addSelected=True)

        cmds.viewFit()
        imageSnapshot = (os.path.join(self.img_path, geo)) + ".jpg"
        imageSnapshot = os.path.normpath(imageSnapshot)
        cmds.refresh(cv=True, fe = "jpg", fn = imageSnapshot)
        cmds.isolateSelect('modelPanel4', state=False)
        self.return_to_perspCam()
        if self.cameraName:
            cmds.delete(self.cameraName[0])

        return imageSnapshot
예제 #8
0
def createPreviewCamera(objectName):
    cmds.camera()
    cmds.rename("preview")
    mel.eval("cameraMakeNode 2 \"\";")
    selList = cmds.ls(selection=True)
    print(selList)

    previewCam = selList[0]
    previewAim = selList[1]

    boxMin = cmds.getAttr(objectName + ".boundingBoxMin")[0]
    boxMax = cmds.getAttr(objectName + ".boundingBoxMax")[0]

    ## move aim to bbx center
    aimPos = [(boxMax[0] + boxMin[0]) / 2, (boxMax[1] + boxMin[1]) / 2, (boxMax[2] + boxMin[2]) / 2]
    print(aimPos)
    cmds.move(aimPos[0], aimPos[1], aimPos[2], previewAim)

    camPosy = boxMax[1] * 1.7
    camPosx = boxMin[0] + camPosy * 1.2
    camPosz = boxMin[2] + camPosy * 1.2
    cmds.move(camPosx, camPosy, camPosz, previewCam)

    preCamShape = cmds.listRelatives(previewCam, children=True)[0]
    cmds.lookThru(preCamShape, "perspView")
예제 #9
0
 def customizeCamera(self, camera):
     cmds.lookThru(camera)
     cmds.addAttr(camera, ln="Overlay", at="enum", en="No Overlay:Grid:SpiralTopRight:SpiralTopLeft:SpiralBottomRight:SpiralBottomLeft")
     cmds.addAttr(camera, ln="Overlay_Value", at="long")
     cmds.setAttr(camera + '.Overlay', e=True, keyable=True)
     cmds.setAttr(camera + '.Overlay_Value', e=True, keyable=True)
     cmds.expression(s='int $a=%s.Overlay;\r\n' % camera +
                       '%s.Overlay_Value=$a;' % camera+
                       'switch($a) { \r\n' +
                       '  case 0: \r\n' +
                       '    python("camera_overlays.Overlay_Function().noOverlay()"); \r\n' +
                       '    break;\r\n' +
                       '  case 1: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleThirdsGrid()"); \r\n' +
                       '    break;\r\n' +
                       '  case 2: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialTopRight()"); \r\n' +
                       '    break;\r\n' +
                       '  case 3: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialTopLeft()"); \r\n' +
                       '    break;\r\n' +
                       '  case 4: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialBottomRight()"); \r\n' +
                       '    break;\r\n' +
                       '  case 5: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialBottomLeft()"); \r\n' +
                       '}select %s;\r' % camera, ae=False, o="renderCam")
 def changeToPerspCam(self):
     currentCam = cmds.lookThru(q=True)
     if currentCam != 'persp':
         # Select the perspective camera (default = modelPfloatanel4)attributeValue
         cmdStr = "lookThroughModelPanel" + " " + "persp" + " " + "modelPanel4;"
         mel.eval(cmdStr)
         cmds.lookThru('persp')
예제 #11
0
 def customizeCamera(self, camera):
     cmds.lookThru(camera)
     cmds.addAttr(
         camera,
         ln="Overlay",
         at="enum",
         en=
         "No Overlay:Grid:SpiralTopRight:SpiralTopLeft:SpiralBottomRight:SpiralBottomLeft"
     )
     cmds.addAttr(camera, ln="Overlay_Value", at="long")
     cmds.setAttr(camera + '.Overlay', e=True, keyable=True)
     cmds.setAttr(camera + '.Overlay_Value', e=True, keyable=True)
     cmds.expression(
         s='int $a=%s.Overlay;\r\n' % camera +
         '%s.Overlay_Value=$a;' % camera + 'switch($a) { \r\n' +
         '  case 0: \r\n' +
         '    python("camera_overlays.Overlay_Function().noOverlay()"); \r\n'
         + '    break;\r\n' + '  case 1: \r\n' +
         '    python("camera_overlays.Overlay_Function().toggleThirdsGrid()"); \r\n'
         + '    break;\r\n' + '  case 2: \r\n' +
         '    python("camera_overlays.Overlay_Function().toggleGoldenSprialTopRight()"); \r\n'
         + '    break;\r\n' + '  case 3: \r\n' +
         '    python("camera_overlays.Overlay_Function().toggleGoldenSprialTopLeft()"); \r\n'
         + '    break;\r\n' + '  case 4: \r\n' +
         '    python("camera_overlays.Overlay_Function().toggleGoldenSprialBottomRight()"); \r\n'
         + '    break;\r\n' + '  case 5: \r\n' +
         '    python("camera_overlays.Overlay_Function().toggleGoldenSprialBottomLeft()"); \r\n'
         + '}select %s;\r' % camera,
         ae=False,
         o="renderCam")
예제 #12
0
def createPreviewCamera(objectName):
    """
    create object preview camera, frame the object
    :param objectName:
    :return:
    """
    cmds.camera()
    cmds.rename("preview")
    mel.eval("cameraMakeNode 2 \"\";")
    selList = cmds.ls(selection=True)
    # print(selList)

    previewCam = selList[0]
    previewAim = selList[1]

    boxMin = cmds.getAttr(objectName + ".boundingBoxMin")[0]
    boxMax = cmds.getAttr(objectName + ".boundingBoxMax")[0]

    ## move aim to bbx center
    aimPos = [(boxMax[0] + boxMin[0]) / 2, (boxMax[1] + boxMin[1]) / 2, (boxMax[2] + boxMin[2]) / 2]
    # print(aimPos)
    cmds.move(aimPos[0], aimPos[1], aimPos[2], previewAim)

    camPosy = boxMax[1] * 1.7
    camPosx = boxMin[0] + camPosy * 1.2
    camPosz = boxMin[2] + camPosy * 1.2
    cmds.move(camPosx, camPosy, camPosz, previewCam)

    preCamShape = cmds.listRelatives(previewCam, children=True)[0]
    cmds.lookThru(preCamShape, "perspView")
예제 #13
0
 def playBlase(self):
     #拍屏 进入创建的摄像机视角
     cmds.lookThru(CameraName)
     #获得下拉列表当前的文本内容(foramt)
     ComboxText=self.formatCombox.currentText()
     #存储路径与文件名称 nameAndPath
     #拍屏
     cmds.playblast(format=ComboxText,filename=nameAndPath[0])
 def get_thumbnail(self):
     for camera in mc.listCameras():
         if camera == "persp":
             pass
         else:
             mm.eval("viewFit -all;")
             mc.lookThru(camera)
             mc.playblast( cf= "H:\\Image Test\\" + camera + ".jpg" , fr=1, fmt="image", v=False, wh=[500, 300], orn=False,
                 compression="jpg", quality=100, percent=100 )
예제 #15
0
파일: panopticon.py 프로젝트: chirs/studio5
def set_camera_drawing():
    c = cmds.camera(rotation=[0,90,0], position=[0,0,0])

    panels = cmds.getPanel( all=True )
    cmds.lookThru(c[0])

    cmds.setKeyframe(c, attribute='rotateX', t='0sec', value=0)
    cmds.setKeyframe(c, attribute='translateY', t='0sec', value=15)
    cmds.setKeyframe(c, attribute='translateZ', t='0sec', value=0)
예제 #16
0
파일: helpers.py 프로젝트: shdwdln/pbTools
def setCurrentCamera(cam):
    '''
    Sets the current maya viewport camera.

    Args:
        cam(string): the camras name you want to set
    '''
    vpPanel = cmds.getPanel(wf=True)
    cmds.lookThru(vpPanel, cam)
예제 #17
0
def lookThruActiveCam():
    currentCamName = database.read_cache('selected_camera')
    cam = cmds.ls(currentCamName)
    if cam:
        cmds.lookThru(cam[0])
        cmds.refresh(currentView=False)
    else:
        # Todo: should fall back to default camera
        print "no syncSketchPlayer_camera found"
예제 #18
0
def setCurrentCamera(cam):
    '''
    Sets the current maya viewport camera.

    Args:
        cam(string): the camras name you want to set
    '''
    vpPanel = cmds.getPanel(wf=True)
    cmds.lookThru(vpPanel, cam)
예제 #19
0
 def Action_Camera(self, cameraName):
     maya_cmds.undoInfo(stateWithoutFlush=False)
     try:
         if not maya_cmds.objExists(cameraName):
             self.Activity_CreateAll()
         maya_cmds.lookThru(cameraName)
     except Exception as e:
         print >> stderr, str(e)
     maya_cmds.undoInfo(stateWithoutFlush=True)
예제 #20
0
 def lookThrough(self, cam):
     """Look through given camera.
     @param cam: path to camera
     @return: None
     """
     if system.isMaya():
         dag = mc.ls(cam.transform, l=True)
         mc.lookThru(dag)
     else:
         raise (NotImplementedError)
예제 #21
0
파일: panopticon.py 프로젝트: chirs/studio5
def set_camera_moving():
    """
    Set the camera.
    """

    #c = cmds.camera(rotation=[0,90,0], position=[100,0,0])
    c = cmds.camera(rotation=[-28,45,0], position=[28, 21, 28])

    panels = cmds.getPanel( all=True )
    cmds.lookThru(c[0])
예제 #22
0
 def _StartTest(self, testName):
     cmds.file(force=True, new=True)
     mayaUtils.loadPlugin("mayaUsdPlugin")
     self._testName = testName
     testFile = testUtils.getTestScene("camera", self._testName + ".usda")
     mayaUtils.createProxyFromFile(testFile)
     globalSelection = ufe.GlobalSelection.get()
     globalSelection.clear()
     cmds.lookThru('|stage|stageShape,/cam')
     self.assertSnapshotClose('%s_unselected.png' % self._testName)
예제 #23
0
def clearScene(arg):
    '''
    Deletes all objects and shaders in the scene.
    
    args: Dummy argument needed to satisfy the command interface.
    On exit: All objects and shaders in the scene have been deleted, and the active camera
             has been changed to the default "persp" camera.
    '''
    cmds.select(all = True)
    cmds.delete()
    cmds.lookThru("persp")
예제 #24
0
def lookThruPlayblastCam():
    currentCamShape = get_current_camera()
    currentPane = get_active_editor()
    database.save_cache('selected_camera', currentCamShape)
    database.save_cache('current_pane', currentPane)
    cam = cmds.ls("syncSketchPlayer_camera*")
    if cam:
        cmds.lookThru(cam[0])
        cmds.refresh(currentView=True)
    else:
        print "no syncSketchPlayer_camera found"
 def testAnimatedUsdCamera(self):
     self._StartTest('camera_xformOp_transform_rotateX')
     # at time 1 look through the camera and we should see the cube
     cmds.currentTime(1)
     cmds.lookThru('|stage|stageShape,/cam')
     self.assertSnapshotClose('%s_unselected.png' % self._testName)
     # at time 2 the near clip plane increases and the cube is not drawn
     cmds.currentTime(2)
     self.assertSnapshotClose('%s_insideNearClipPlane.png' % self._testName)
     # at time 3 the near clip plane is restored so the cube is drawn, and the camera moves
     cmds.currentTime(3)
     self.assertSnapshotClose('%s_cameraMoved.png' % self._testName)
예제 #26
0
def SetupCamera():
    cam = cmds.camera()
    cmds.lookThru(cam[0])
    cmds.setAttr(cam[1] + ".renderable", True)
    cmds.setAttr("persp.renderable", False)
    cmds.setAttr("top.renderable", False)
    cmds.setAttr("front.renderable", False)
    cmds.setAttr("side.renderable", False)
    cmds.select(cam[0])
    cmds.rotate(-20.738, 48.547, -0.414)
    cmds.move(24.026, 15.354, 21.047)
    cmds.renderSettings(cam=cam[1])
예제 #27
0
def get_objs_in_camera_view(camera_name, min_frame, max_frame):
    mc.lookThru(camera_name)
    all_view_obj = []
    view = omUI.M3dView.active3dView()
    for frame in xrange(min_frame, max_frame + 1):
        mc.currentTime(frame, edit=True)
        om.MGlobal.selectFromScreen(0, 0, view.portWidth(), view.portHeight(),
                                    om.MGlobal.kReplaceList)
        all_view_obj.extend(mc.ls(sl=1))

    all_view_obj = list(set(all_view_obj))
    return all_view_obj
예제 #28
0
    def runImportLight(self, arg=None):
        title = 'Light Template'
        allRefs = mc.file(q=True, r=True)
        rigGrp = 'Rig:Geo_Grp'
        selLight = str(self.ui.light_comboBox.currentText())
        self.selLightPath = '%s/%s' % (self.lightRig, selLight)

        if not mc.objExists('Light_Grp'):
            if not self.selLightPath in allRefs:
                mc.file(self.selLightPath, r=True, uns=True, dns=True)

            mc.setAttr("vraySettings.relements_usereferenced", 1)

        else:
            self.messageBox('Warning', 'Light Rig Exists')

        if not mc.objExists('cam_grp'):
            if not self.turnTableCamera in allRefs:
                mc.file(self.turnTableCamera, r=True, uns=True, dns=True)

            mc.playbackOptions(min=1)
            mc.playbackOptions(max=100)
            mc.lookThru('turntable_cam')
            mc.setAttr('turntable_camShape.renderable', 1)
            allCams = mc.listCameras()

            for eachCam in allCams:
                shape = mc.listRelatives(eachCam, s=True)[0]
                mc.setAttr('%s.renderable' % shape, 0)

                if eachCam == 'turntable_cam':
                    mc.setAttr('%s.renderable' % shape, 1)
                    mc.setAttr('%s.displayFieldChart' % shape, 1)
                    mc.setAttr('%s.displayResolution' % shape, 1)
                    mc.setAttr('%s.overscan' % shape, 1.3)
                    mc.setAttr('%s.backgroundColor' % shape,
                               0.5,
                               0.5,
                               0.5,
                               type='double3')
                    # mc.eval('setAttr "turntable_camShape.backgroundColor" -type double3 0.5 0.5 0.5 ;')

                    if mc.objExists(rigGrp):
                        mc.select(rigGrp)
                        mm.eval('fitPanel -selected;')

                    mc.currentTime(9)

            self.setStatus(title, True)

        else:
            self.messageBox('Warning', 'Turntable Camera Exists')
예제 #29
0
    def __init__(self, camera=None):
        self.__camera = camera
        if not self.__camera:
            self.__camera = mc.lookThru(q=1)
        else:
            mc.lookThru(self.__camera)
        self.__hud_dict = get_hud_conf()
        self.__huds = self.__hud_dict.keys()
        self.__hud_color = self.__hud_dict["color"]
        self.__huds.remove("color")

        OpenMayaUI.MUiMessage.addCameraChangedCallback("modelPanel4",
                                                       cam_call_back)
예제 #30
0
파일: camera.py 프로젝트: chirs/studio5
def main():

    panels = cmds.getPanel( all=True )
    cmds.lookThru(c[0])

    cmds.setKeyframe(c[0], attribute='translateY', t=['0sec',], value=20)
    cmds.setKeyframe(c[0], attribute='translateY', t=['15sec',], value=0)

    cmds.setKeyframe(c[0], attribute='translateZ', t=['3sec',], value=0)
    cmds.setKeyframe(c[0], attribute='translateZ', t=['9sec',], value=20)

    cmds.setKeyframe(c[0], attribute='rotateX', t=['0sec',], value=-90)
    cmds.setKeyframe(c[0], attribute='rotateX', t=['15sec',], value=0)
예제 #31
0
def makeCamera(name_, environment):
    '''
    Creates a camera with the given background colour. 
    
    name_: The name the camera is given.
    environment: The colour the backround for the camera will have.
    On exit: A camera with the given background colour has been created and 
             made active.
    '''
    camera_ = cmds.camera(n = name_)
    cmds.setAttr(camera_[1] + ".backgroundColor", environment[0], environment[1],environment[2])
    cmds.camera(camera_[0], edit = True, position = [0,100,250], rotation = [-23,0,0])
    cmds.lookThru(camera_[0])
예제 #32
0
def maintainCamera(panel, camera):
    """Context Manager to allow the client to set the current modelpanel to a 
    different camera temporary before setting back to the original camera.

    :param panel: the maya model panel
    :type panel: str
    :param camera: the fullpathName of the camera.
    :type camera: str
    """
    view = om2ui.M3dView()
    currentCamera = view.getM3dViewFromModelPanel(panel)
    cmds.lookThru(panel, camera)
    yield
    cmds.lookThru(panel, currentCamera.fullPathName())
예제 #33
0
	def setUI(self, mode, arg = None) : 

		# multi frame
		multi = mc.checkBox('%s_multiCB' % self.ui, q = True, v = True)

		if mode == 'getCurrentCamera' : 
			camera = mc.lookThru(q = True)
			mc.textField('%s_crrCameraTX' % self.ui, e = True, tx = camera)

		if mode == 'get2DCamera' : 
			camera = mc.lookThru(q = True)
			mc.textField('%s_cameraTX' % self.ui, e = True, tx = camera)

		if mode == 'getCurrentTime' : 
			if multi : 
				currentTime = str(int(mc.currentTime(q = True)))
				currentTimes = self.checkMultiFrame()

				if not currentTime in currentTimes : 
					text = (',').join(currentTimes)
					text = (',').join([text, str(currentTime)])
					mc.textField('%s_frameTX' % self.ui, e = True, tx = text)

			else : 
				currentTime = int(mc.currentTime(q = True))
				mc.textField('%s_frameTX' % self.ui, e = True, tx = currentTime)

		if mode == 'getCurrentCameraOM' : 
			camera = mc.optionMenu('%s_crrCameraOM' % self.ui, q = True, v = True)
			mc.textField('%s_crrCameraTX' % self.ui, e = True, tx = camera)

		if mode == 'get2DCameraOM' : 
			camera = mc.optionMenu('%s_cameraOM' % self.ui, q = True, v = True)
			mc.textField('%s_cameraTX' % self.ui, e = True, tx = camera)


		if mode == 'getNewCamera' : 
			sel = mc.ls(sl = True)

			if sel : 
				namespace = mayaTools.getNamespace(sel[0])
				text = '%s_cam' % namespace
				mc.textField('%s_newCameraTX' % self.ui, e = True, tx = text)


		if mode == 'onAddLayers' : 
			mc.textScrollList('%s_renderLayerTSL' % self.ui, e = True, en = True)

		if mode == 'offAddLayers' : 
			mc.textScrollList('%s_renderLayerTSL' % self.ui, e = True, en = False)
예제 #34
0
 def OK_button(self):
     input_file_name = self._example.name_line_edit_file.text()
     out_file_name = self._example.name_line_edit_file1.text()
     cmds.file(input_file_name, reference=True)
     currentPose = self.countPose()
     Start_Frame = self._example.name_line_edit_frame.text()
     End_Frame = self._example.name_line_edit_to.text()
     ComboBox_format_name1 = self._example.ComboBox_format.currentText()
     ComboBox_format_name = str(ComboBox_format_name1)
     ComboBox_resolution_value = self._example.ComboBox_resolution.currentText(
     )
     ComboBox_resolution_value1 = ComboBox_resolution_value.split("*", 1)
     width_value = int(ComboBox_resolution_value1[0])
     higth_value = int(ComboBox_resolution_value1[1])
     camera_name = cmds.camera(p=(currentPose[0] * 2 + 5,
                                  currentPose[1] * 2 + 5,
                                  currentPose[2] * 2 + 5),
                               wci=(0, 0, 0))
     cmds.move(currentPose[0], currentPose[1], currentPose[2],
               camera_name[0] + ".scalePivot",
               camera_name[0] + ".rotatePivot")
     cmds.playbackOptions(min=int(Start_Frame), max=int(End_Frame))
     cmds.rotate(0,
                 '0',
                 0,
                 camera_name[0],
                 pivot=(currentPose[0], currentPose[1], currentPose[2]))
     cmds.setKeyframe(camera_name[0], at='rotateY', t=int(Start_Frame))
     cmds.rotate(0,
                 '360',
                 0,
                 camera_name[0],
                 pivot=(currentPose[0], currentPose[1], currentPose[2]))
     cmds.setKeyframe(camera_name[0], at='rotateY', t=int(End_Frame))
     cmds.rotate("-17",
                 0,
                 0,
                 camera_name[0],
                 pivot=(currentPose[0], currentPose[1], currentPose[2]),
                 ws=1)
     cmds.lookThru(camera_name[0])
     cmds.playblast(p=60,
                    wh=(width_value, higth_value),
                    v=False,
                    format=ComboBox_format_name,
                    viewer=False,
                    f=out_file_name,
                    cc=1,
                    st=int(Start_Frame),
                    et=int(End_Frame))
예제 #35
0
	def switchCamera(self, arg = None) : 
		cam3D = mc.textField('%s_crrCameraTX' % self.ui, q = True, tx = True)
		cam2D = mc.textField('%s_cameraTX' % self.ui, q = True, tx = True)

		print cam3D, cam2D

		if cam3D and cam2D : 
			cam = {cam2D: cam3D, cam3D: cam2D}
			setting = {cam3D: 'self.setRenderSetting()', cam2D: 'self.restoreRender()'}
			currentCam = mc.lookThru(q = True)

			if currentCam : 
				mc.lookThru(cam[currentCam])
				eval(setting[currentCam])
예제 #36
0
 def adjustLights(self, *args):
     """Function that looks through the next light for Camera adjustment"""
     #Look through a light for easy adjustment
     print("adjustLights called\n")
     for l in self.lights:
         if l == self.currentLight:
             lxform = cmds.listRelatives(l, p=1)
             print("DEBUG: looking thru: " + lxform[0])
             cmds.lookThru("modelPanel4", lxform[0],  nc=.001, fc=1000)
     if self.currentLight == "keyLightShape":
         self.currentLight = "fillLightShape"
     elif self.currentLight == "fillLightShape":
         self.currentLight = "backLightShape"
     else:
         self.currentLight = "keyLightShape"
예제 #37
0
def _maintain_camera(panel, camera):
    state = {}

    if not _in_standalone():
        cmds.lookThru(panel, camera)
    else:
        state = dict((camera, cmds.getAttr(camera + ".rnd"))
                     for camera in cmds.ls(type="camera"))
        cmds.setAttr(camera + ".rnd", True)

    try:
        yield
    finally:
        for camera, renderable in state.iteritems():
            cmds.setAttr(camera + ".rnd", renderable)
예제 #38
0
def _maintain_camera(panel, camera):
    state = {}

    if not _in_standalone():
        cmds.lookThru(panel, camera)
    else:
        state = dict((camera, cmds.getAttr(camera + ".rnd"))
                     for camera in cmds.ls(type="camera"))
        cmds.setAttr(camera + ".rnd", True)

    try:
        yield
    finally:
        for camera, renderable in state.iteritems():
            cmds.setAttr(camera + ".rnd", renderable)
예제 #39
0
    def runImportLight(self, arg = None) : 
        title = 'Light Template'
        allRefs = mc.file(q = True, r = True)
        rigGrp = 'Rig:Geo_Grp'
        selLight = str(self.ui.light_comboBox.currentText())
        self.selLightPath = '%s/%s' % (self.lightRig, selLight)

        if not mc.objExists('Light_Grp') : 
            if not self.selLightPath in allRefs : 
                mc.file(self.selLightPath,r=True, uns=True, dns=True )
            
            mc.setAttr( "vraySettings.relements_usereferenced", 1)

        else : 
            self.messageBox('Warning', 'Light Rig Exists')

        if not mc.objExists('cam_grp') : 
            if not self.turnTableCamera in allRefs : 
                mc.file(self.turnTableCamera, r=True, uns=True, dns=True)

            mc.playbackOptions( min=1 ) 
            mc.playbackOptions( max=100 ) 
            mc.lookThru('turntable_cam')
            mc.setAttr('turntable_camShape.renderable', 1)
            allCams = mc.listCameras()

            for eachCam in allCams : 
                shape = mc.listRelatives(eachCam, s = True)[0]
                mc.setAttr('%s.renderable' % shape, 0)

                if eachCam == 'turntable_cam' : 
                    mc.setAttr('%s.renderable' % shape, 1)
                    mc.setAttr('%s.displayFieldChart' % shape, 1)
                    mc.setAttr('%s.displayResolution' % shape, 1)
                    mc.setAttr('%s.overscan' % shape, 1.3)
                    mc.setAttr('%s.backgroundColor' % shape, 0.5, 0.5, 0.5, type = 'double3')
                    # mc.eval('setAttr "turntable_camShape.backgroundColor" -type double3 0.5 0.5 0.5 ;')

                    if mc.objExists(rigGrp) : 
                        mc.select(rigGrp)
                        mm.eval('fitPanel -selected;')

                    mc.currentTime(9)

            self.setStatus(title, True)        

        else : 
            self.messageBox('Warning', 'Turntable Camera Exists')
 def CameraToPopDist( self ):
     camPos = Vector(mc.xform(mc.lookThru(q=True),q=True,t=True))
     if self.nearestRoot:
         popPos = Vector(mc.objectCenter(self.nearestRoot))
     else:
         popPos = self.FindNearestObjectToCamera()
     return (camPos-popPos).mag()
예제 #41
0
    def duplicate_camera(self, camera=None, name="shotCam_#"):

        camera = camera or self.name

        duplicate = cmds.duplicate(camera, name=name + '_#')[0]

        for attr in ('translate', 'rotate'):
            cmds.setAttr(duplicate + '.' + attr, lock=0)
            for ax in ('X', 'Y', 'Z'):
                cmds.setAttr(duplicate + '.' + attr + ax, lock=0)

        if (cmds.listRelatives(duplicate, parent=True)):
            cmds.parent(duplicate, world=True)
        cmds.lookThru(duplicate)

        return duplicate
예제 #42
0
def lookThruAndFrame(obj):
    """
    Looks through the given obj and moves the obj so that it frames the viewport objects.
    :param obj: The camera or light object.
    :return: None
    """
    cmds.lookThru(obj)
    # Position the active camera to view the active objects
    pm.viewFit()

    # Position cameraShape-1 to view all objects
    pm.viewFit(obj, all=True)

    # Fill 50 percent of the active view with active objects
    pm.viewFit(f=0.5)
    pm.viewFit(all=True)
예제 #43
0
 def HbImportReCam(self, projectInfo, Name):
     questSets = mc.optionMenu("EPNUM", q=True, v=True)
     questEP = mc.optionMenu("EP", q=True, v=True)
 
     AllObj = mc.ls(sl=1)
     path = "//file-cluster/GDC/Projects/" + projectInfo + "/" + projectInfo + "_Scratch/TD/SetCam/" + questEP + "/" + questSets + "/"
     questMat = mc.ls(Name.split(".")[0])
     if len(questMat) == 0:
         try:
             file(path + Name.replace(".bmp", ".mb"), i=True)
             mc.lookThru (Name.split(".")[0])
         except:
             pass
     if len(questMat) != 0:
         result = mc.confirmDialog(title='Confirm', message='there hase the same camera in the sences', button=['Yes'], defaultButton='Yes')
         return
예제 #44
0
def createCtrl():
	animFixCtrl=mc.textCurves(ch=0,o=1,f='Times New Roman|w400|h-1',t='AnimFixCtrl',n='Ctrl_AnimFix')
	curveShapes=mc.listRelatives(animFixCtrl,allDescendents=1,type='nurbsCurve')
	children=mc.listRelatives(animFixCtrl,children=1)
	makeCurve=mc.listConnections(children[0],s=1)
	mc.delete(makeCurve)
	mc.makeIdentity(animFixCtrl,apply=1)
	for i in curveShapes:
		mc.parent(i,animFixCtrl,s=1,add=1)
	mc.delete(children)
	animFixCtrl=mc.rename(animFixCtrl,'animFixCtrl')
	mc.setAttr(animFixCtrl+".overrideEnabled",1)
	mc.setAttr(animFixCtrl+".overrideColor",17)
	mc.setAttr("animFixCtrl.tx",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.ty",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.tz",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.rx",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.ry",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.rz",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.sx",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.sy",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.sz",keyable=0,channelBox=1)
	mc.setAttr("animFixCtrl.v",keyable=0,channelBox=1)
	activeCam=mc.lookThru(q=1)
	ctrlGrp=mc.group(animFixCtrl,n='animFixCtrlGRP')
	mainGrp=mc.group(em=1,n='animFixGrp')
	mc.parent(ctrlGrp,activeCam)
	mc.xform(ctrlGrp,a=1,os=1,t=[0.3,0.7,-5],ro=[0,0,0])
	mc.parent(ctrlGrp,mainGrp)
	mc.parentConstraint(activeCam,ctrlGrp,mo=1)
	mc.select(animFixCtrl,r=1)
예제 #45
0
def lookThruAndFrame(obj):
    """
    Looks through the given obj and moves the obj so that it frames the viewport objects.
    :param obj: The camera or light object.
    :return: None
    """
    cmds.lookThru(obj)
    # Position the active camera to view the active objects
    pm.viewFit()

    # Position cameraShape-1 to view all objects
    pm.viewFit(obj, all=True)

    # Fill 50 percent of the active view with active objects
    pm.viewFit(f=0.5)
    pm.viewFit(all=True)
예제 #46
0
    def saveScreenshot(self, name, directory):
        """
        Saves screenshot out to disk
        Args:
            name: Name of the screenshot
            directory: Directory to save into
        """
        # get camera, current position and focus object
        cameraName = cmds.lookThru(q=True)
        prevPosition = cmds.getAttr("{0}.translate".format(cameraName))
        objName = cmds.ls(sl=True, l=True)
        if objName:
            objName = objName[0]
        else:
            cmds.error("No object has been selected")

        # frame camera to object
        cmds.viewFit()  # 'f' on keyboard
        distance = lib.distanceBetween(cameraName, objName)
        frameDistance = distance * 0.5
        cmds.dolly(cameraName, d=-frameDistance)

        # take screenshot
        screenshotDir = mnpr_system.renderFrame(os.path.join(directory, name),
                                                100, 100, 1, ".jpg")

        # bring camera back to normal
        lib.setAttr(cameraName, "translate", prevPosition)
        return screenshotDir
예제 #47
0
def get_object_of_shot(shot):
    start_frame = int(mc.getAttr("%s.startFrame" % shot))
    end_frame = int(mc.getAttr("%s.endFrame" % shot))
    camera = mc.listConnections("%s.currentCamera" % shot)[0]
    if not camera:
        return
    mc.lookThru(camera)
    selected_objects = list()
    for frame in xrange(start_frame, end_frame + 1):
        select_current_view_objects.select_current_view_objects()
        frame_selected_objects = mc.ls(sl=1, r=1)
        selected_objects.extend(frame_selected_objects)
    if selected_objects:
        selected_objects.append(camera)
        selected_objects = list(set(selected_objects))
        return selected_objects
예제 #48
0
def getCam():
    """
    """
    panel = cmds.getPanel(wf=True)
    #cam = cmds.modelEditor(panel, q = True, camera = True)
    cam = cmds.lookThru(q=True)
    return cam
    def TraceGesturePress( self ):
        """ Procedure called on press """
        if debug>0: print("begin PRESS")
        # Clean up: if there are any locators or groups in the scene, delete them
        if( len(mc.ls("locator*")) > 0 ):
            mc.delete(mc.ls("locator*"))
        if( len(mc.ls("*Grp")) > 0 ):
            mc.delete(mc.ls("*Grp"))

        # find the position of the mouse click
        pressPosition = Vector( mc.draggerContext( 'TraceGesture', query=True, anchorPoint=True) )

        camPos = self.CameraPosition()
        viewAxis = self.CameraViewAxis()
        closestObj2Cam = self.FindNearestObjectToCamera()
        self.interactionPlane = Plane(viewAxis,closestObj2Cam)

        pressPosition = self.FindRayPlaneIntersect( camPos, pressPosition, self.interactionPlane )
        if debug > 0:
            mc.group(n="traceGrp",empty=True)
            loc = mc.spaceLocator(p=pressPosition)
            mc.parent(loc,"traceGrp")

        for root in self.xformRoots:
            # remember whether (or not) the motion paths for a root were visible when the interaction started
            self.motionPathsVisible[root] = mc.getAttr("%s_MotionTraces.visibility"%root)
            # set up all the traces
            self.trace[root].Clear()
            # set the trace normal to the viewing normal of the camera
            self.trace[root].normal = self.interactionPlane.normal #Vector( mc.xform(mc.lookThru(q=True), q=True, m=True)[8:11] )
            self.trace[root].planePt = self.interactionPlane.point #closestObj2Cam

        self.nearestRoot, rootDist = self.FindNearestRoot( pressPosition, self.interactionPlane )
        mc.setAttr("%s_MotionTraces.visibility"%self.nearestRoot, 1)   # vis the new display layer

        # make a group to hold the trace locators
        if debug > 0:
            mc.group(name="trace%sGrp"%self.nearestRoot,empty=True)
            loc = mc.spaceLocator(p=pressPosition)
            mc.parent(loc,"trace%sGrp"%self.nearestRoot)
        # reset the trace
        self.trace[self.nearestRoot].Clear()
        # start the timer
        self.startTime = time.time()
        # set the trace normal to the viewing normal of the camera
        self.trace[self.nearestRoot].normal = Vector( mc.xform(mc.lookThru(q=True), q=True, m=True)[8:11] )
        self.trace[self.nearestRoot].planePt = closestObj2Cam
                
        # add the initial click position to the trace
        self.trace[self.nearestRoot].AddPoint( pressPosition )
        
        self.nearestPath, pathDist = self.FindNearestMotionPath( pressPosition, self.nearestRoot )
        if not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl":
            self.trace[self.nearestRoot].SetUpDTWs()
            mc.refresh(currentView=True,force=True)
        if debug>0: print("end PRESS")
예제 #50
0
 def SetUpDTWs( self ):
     """ Initializes the DTWs """
     del self.dtws[:]
     do_subsequence = True
     selfData  = [ [self.points[t].x, self.points[t].y, self.points[t].z] for t in sorted(self.points.keys()) ]
     for joint in sorted(self.searchList.keys()):
         jointMotionPath = self.searchList[joint]
         currentCam = mc.lookThru(q=True)
         camPos = Vector(mc.xform(currentCam,q=True,t=True))
         otherData = [ Plane(self.normal,self.planePt).intersectWithRay( camPos, jointMotionPath.points[t] ).asList() for t in sorted(jointMotionPath.points.keys()) ]
         self.dtws.append( DTW( selfData, otherData, do_subsequence ) )
예제 #51
0
def init():
    """Initiate camera name comparison."""
    global customPBcamTmp
    customPBcamTmp = ""

    if customPBcam == "":
        if check_camera_name() is False:
            destroyWindow()
            blast()
        elif check_camera_name() is True:
            draw_warning('DefaultCameraChecker', pbContinue, setTempCam)
        else:
            cmds.warning("Activate a viewport and try again.")

    else:
        activepanel = cmds.getPanel(withFocus=True)
        cam = cmds.modelEditor(activepanel, query=True, camera=True)
        cmds.lookThru(activepanel, customPBcam)  # Global default PB cam
        blast()
        cmds.lookThru(activepanel, cam)  # Return to original camera
예제 #52
0
파일: panopticon.py 프로젝트: chirs/studio5
def set_camera1():
    """
    Set the camera.
    """

    #c = cmds.camera(rotation=[0,90,0], position=[100,0,0])
    c = cmds.camera(rotation=[60,90,0], position=[8, -7, 2])

    panels = cmds.getPanel( all=True )
    cmds.lookThru(c[0])

    cmds.setKeyframe(c, attribute='translateX', t='0sec', value=8)
    cmds.setKeyframe(c, attribute='translateY', t='0sec', value=-10)

    cmds.setKeyframe(c, attribute='centerOfInterest', t='0sec', value=12)


    cmds.setKeyframe(c, attribute='translateX', t='10sec', value=25)
    cmds.setKeyframe(c, attribute='translateY', t='10sec', value=-40)

    cmds.setKeyframe(c, attribute='centerOfInterest', t='10sec', value=45)
예제 #53
0
    def runRemoveLight(self, arg = None) : 
        files = mc.file(q = True, r = True)
        elements = mc.ls(type = 'VRayRenderElement')

        if elements : 
            mc.delete(elements)
            
        print 'Remove Elements %s' % elements

        if self.selLightPath in files : 
            mc.file(self.selLightPath, rr=True)
            print 'remove light rig'

        else : 
            if mc.objExists('Light_Grp') : 
                path = mc.referenceQuery('Light_Grp', f = True)
                mc.file(path, rr = True)

        if self.turnTableCamera in files : 
            mc.file(self.turnTableCamera, rr=True)
            mc.lookThru('persp')
            print 'remove camera'
예제 #54
0
파일: panopticon.py 프로젝트: chirs/studio5
def set_camera2():
    """
    Set the camera.
    """

    c = cmds.camera(rotation=[0,90,0], position=[0,0,0])

    panels = cmds.getPanel( all=True )
    cmds.lookThru(c[0])

    cmds.setKeyframe(c, attribute='translateX', t='0sec', value=100)
    cmds.setKeyframe(c, attribute='translateY', t='0sec', value=0)
    cmds.setKeyframe(c, attribute='translateZ', t='0sec', value=0)

    cmds.setKeyframe(c, attribute='translateX', t='12sec', value=100)
    cmds.setKeyframe(c, attribute='translateY', t='12sec', value=0)
    cmds.setKeyframe(c, attribute='translateZ', t='12sec', value=60)

    cmds.setKeyframe(c, attribute='translateX', t='20sec', value=18)
    cmds.setKeyframe(c, attribute='translateY', t='20sec', value=-50)
    cmds.setKeyframe(c, attribute='translateZ', t='20sec', value=100)

    cmds.setKeyframe(c, attribute='rotateX', t='13.5sec', value=0)
    cmds.setKeyframe(c, attribute='rotateX', t='20sec', value=75)
예제 #55
0
 def ClosestTimeTo( self, point, plane=None ):
     """ Returns the closest point in this trajectory to the given point in 3d space (or 2d if plane is defined) """
     if not type(point) == Vector:
         point = Vector(point)
     if plane:
         point = point.projectToPlane(plane.normal,planePt=plane.point)
     minDist = float("inf")
     ft = None
     camPos = Vector( mc.xform(mc.lookThru(q=True), q=True, t=True) )
     for i,t in enumerate(sorted(self.points.keys())):
         p = self.points[t]
         if plane:
             p = p.projectToPlane(plane.normal,planePt=plane.point)
             dist = (point-p).mag()
         else:
             ray = (p-camPos).norm()     # build a ray from the camera to the path point in question
             dist = ray.cross(point-p).mag()
         if minDist > dist:
             minDist = dist
             ft = t
     return ft   # return the key of the closest point in the points dictionary
예제 #56
0
def pbContinue(makeDefault, makeDefaultMenu, *args):
    """Confirm playblasting."""
    activepanel = cmds.getPanel(withFocus=True)
    cam = cmds.modelEditor(activepanel, query=True, camera=True)
    global customPBcam

    if cmds.checkBox(makeDefault, query=True, value=True) is True:
        customPBcam = customPBcamTmp
        cmds.lookThru(activepanel, customPBcam)  # Global default PB cam
        blast()
        cmds.lookThru(activepanel, cam)  # Return to original camera

        destroyWindow()

    else:
        if customPBcamTmp != "":
            cmds.lookThru(activepanel, customPBcamTmp)  # Temp PB cam
            blast()
            cmds.lookThru(activepanel, cam)  # Return to original camera

            destroyWindow()
        else:
            cmds.warning("Please select a camera from the dropdown menu")
    def TraceGestureDrag( self ):
        """ Procedure called on drag """
        # find the current position of the mouse drag
        if debug>0: print("begin DRAG")

        if not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == 'shift':
            if self.nearestRoot in self.selectedMotions.keys():
                for sm in self.selectedMotions[ self.nearestRoot ]:
                    if mc.objExists(sm):
                        mc.delete( sm )
                del self.selectedMotions[ self.nearestRoot ]

        currentCam = mc.lookThru(q=True)
        camPos = Vector(mc.xform(currentCam,q=True,t=True))
        dragPosition = Vector( mc.draggerContext( 'TraceGesture', query=True, dragPoint=True) )
        dragPosition = self.FindRayPlaneIntersect( camPos, dragPosition, Plane(self.trace[self.nearestRoot].normal,self.trace[self.nearestRoot].planePt) )
        # find the last recorded drag position
        lastDragPosition = self.trace[self.nearestRoot].points[ sorted(self.trace[self.nearestRoot].points.keys())[-1] ]
        # find the drag distance
        dragDist = (dragPosition-lastDragPosition).mag()
        # if far enough away from last drag position, add a new trace point and re-solve the DTWs
        if dragDist > self.dragDensity :
            self.trace[self.nearestRoot].AddPoint( dragPosition )
            if debug > 0:
                loc = mc.spaceLocator(p=dragPosition)
                mc.parent(loc,"traceGrp")
        if self.trace[self.nearestRoot].timespan and len(self.trace[self.nearestRoot].points) > 4*self.substeps and \
           not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl":        
            if debug > 0: print "DTW solved to timespan of ",trace[nearestRoot].timespan
            mc.currentTime( self.trace[self.nearestRoot].timespan[1] )
            if dragDist > self.dragDensity:
                mc.refresh(currentView=True,force=True)
        elif dragDist > self.dragDensity:
            if debug > 0: print "No DTW, attempting closest path... point..."
            self.ScrubToNearestTimeOnPath( dragPosition, self.nearestRoot, self.nearestPath )
        if debug>0: print("end DRAG")    
예제 #58
0
def switch_persp_panel():
	current_model = cmds.getPanel(wf=True)
	current_camera = cmds.modelEditor(current_model,q=True,cam=True)
	persp_cameras = cmds.listCameras(p=True)
	print persp_cameras
	try:
		if(camera_type(current_camera) == "orthographic"):
			cmds.lookThru("persp")
		else:
			if(len(persp_cameras) > 1):
				for c,n in itu.pairwise(persp_cameras):
					if(current_camera == c):
						if(persp_cameras.index(c) == (len(persp_cameras)-1)):
							cmds.lookThru(persp_cameras[0])
						else:	
							print n
							cmds.lookThru(n)
	except:
		print "No persp camera, create a new persp camera!"
예제 #59
0
    second_degrees = 60 * minute_degrees

def set_keyframes(t):
    cmds.setKeyframe(hours, attribute='rotateY', t=['0sec',], value=0)
    cmds.setKeyframe(minutes, attribute='rotateY', t=['0sec',], value=0)
    #cmds.setKeyframe(seconds, attribute='rotateY', t=['0sec',], value=0)

    cmds.setKeyframe(hours, attribute='rotateY', t=[str(t) + 'sec',], value=hour_degrees)
    cmds.setKeyframe(minutes, attribute='rotateY', t=[str(t) + 'sec',], value=minute_degrees)
    #cmds.setKeyframe(seconds, attribute='rotateY', t=[str(t) + 'sec',], value=second_degrees)


set_keyframes(10)


cmds.lookThru('top')


"""
c1 = cmds.circle(nr=(0,1,0), c=(1,0,0), r=1)
c2 = cmds.circle(nr=(0,1,0), c=(-1,0,0), r=1)
c3 = cmds.circle(nr=(0,1,0), c=(0,0,1.7), r=1)

c4 = cmds.circle(nr=(0,1,0), c=(0,0,.5), r=2)
c5 = cmds.circle(nr=(0,1,0), c=(0,0,0), r=.5)

g = cmds.group(c1,c2,c3,name='g')
g2 = cmds.group(g,c4,c5,name='g2')

cmds.setKeyframe('g2', attribute='rotateY', t=['0sec',], value=0)
cmds.setKeyframe('g2', attribute='rotateY', t=['3sec',], value=720)