Last active
April 9, 2019 16:25
-
-
Save kiryha/614f5829bb118ea2f1d2fbd29b8f9e69 to your computer and use it in GitHub Desktop.
Vertigo effect for Maya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.core as pm | |
import math | |
listLens = [8, 12, 24, 35, 50, 80, 135 ] | |
cam = pm.ls( pm.PyNode(pm.modelPanel(pm.getPanel(wf = True), q = True, cam = True)) )[0] # Getr current viewport as camera | |
#cam = pm.ls( pm.PyNode('camera1') )[0] # Getr current viewport as camera | |
camFL = cam.focalLength.get() | |
camCI = cam.centerOfInterest.get() | |
camHFA = round(25.4*cam.cameraAperture.horizontalFilmAperture.get()) # Camera Aperture (mm) | |
camA = round(cam.getHorizontalFieldOfView()) # Camera Angle of view | |
camB = 2 * camCI / (math.tan( (math.radians(180-camA)/2)) ) # object size (bottom of camera triangle) | |
# LOCK ACTIVE CAMERA | |
def lockCam(cam): | |
if (cam.tx.get(l=1) == 1): | |
cam.translate.set(l = 0) | |
cam.rotate.set(l = 0) | |
else: | |
cam.translate.set(l = 1) | |
cam.rotate.set(l = 1) | |
def vertigo(camFL): | |
camA = round( math.degrees( 2*math.atan( camHFA/(2*camFL) ) ) ) | |
distance = camB/2 * ( math.tan( math.radians((180-camA)/2)) ) | |
pm.dolly( cam, abs = 1, d = distance ) | |
cam.focalLength.set(camFL) | |
# print 'FL = {0} DIST = {1} CI = {2} A = {3} B = {4}'. format(camFL, distance, camCI, camA, camB) | |
def baseUI(*args): | |
if pm.window('vertigo', q = 1, ex = 1): | |
pm.deleteUI('vertigo') | |
win = pm.window('vertigo', t = 'DS Vertigo', rtf = True, w = 280 ) | |
with win: | |
mainLayout = pm.columnLayout() | |
camLayout = pm.rowColumnLayout(nc = 10, parent = mainLayout) | |
for i in listLens: | |
LB = pm.button(l = str(i), w = 30, h= 40) | |
LB.setCommand(pm.Callback (vertigo, i)) | |
lockCAM = pm.button(l = 'LOCK CAM', w = 70) | |
lockCAM.setCommand(pm.Callback (lockCam, cam)) | |
slidekLayout = pm.rowColumnLayout(nc = 1, parent = mainLayout) | |
zoom = pm.intSliderGrp( min = 5, max = 100, v = camFL , field = 1, step = 1, w = 280, h = 40, dc = vertigo ) | |
win.show() | |
baseUI() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment