Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maya Python API图像平面数学_Python_Api_Math_Maya_Plane - Fatal编程技术网

Maya Python API图像平面数学

Maya Python API图像平面数学,python,api,math,maya,plane,Python,Api,Math,Maya,Plane,有人知道基于相机外光圈、焦距、过扫描和分辨率计算图像平面的数学吗 基本上,我只是尝试创建一个平面,它基于表示图像平面的当前视口 谢谢你的帮助。 花了很多时间才找到它 您几乎肯定会遇到一个令人恼火的问题,即Maya将摄影机后光圈存储为英寸,而焦距存储为毫米。因此: import math import maya.cmds as cmds import maya.OpenMaya as OpenMaya # maya uses INCHES for camera backs # but MILL

有人知道基于相机外光圈、焦距、过扫描和分辨率计算图像平面的数学吗

基本上,我只是尝试创建一个平面,它基于表示图像平面的当前视口

谢谢你的帮助。


花了很多时间才找到它

您几乎肯定会遇到一个令人恼火的问题,即Maya将摄影机后光圈存储为英寸,而焦距存储为毫米。因此:

import math
import maya.cmds as cmds
import maya.OpenMaya as OpenMaya


# maya uses INCHES for camera backs
# but MILLIMETERS for focal lenghts. Hence the magic number 25.4

def get_vfov (camera):
    ''' 
    returns the vertical fov the supplied camera, in degrees.
    '''

    fl = cmds.getAttr(camera + ".focalLength")
    vfa = cmds.getAttr(camera + ".vfa") *  25.4  # in mm
    return math.degrees ( 2 * math.atan(vfa / (2 * fl)))

def get_hfov (camera):
    ''' 
    returns the horizontal fov the supplied camera, in degrees.
    '''

    fl = cmds.getAttr(camera + ".focalLength")
    vfa = cmds.getAttr(camera + ".hfa") *  25.4  # in mm
    return math.degrees ( 2 * math.atan(vfa / (2 * fl)))


def get_persp_matrix (FOV, aspect = 1, near = 1, far = 30):
    '''
    give a FOV amd aspect ratio, generate a perspective matrix
    '''
    matrix = [0.0] * 16   
    fov = math.radians(FOV)
    yScale = 1.0 / math.tan(fov / 2)
    xScale = yScale / aspect
    matrix[0] = xScale
    matrix[5] = yScale
    matrix[10] = far / (near - far)     
    matrix[11] = -1.0
    matrix[14] = (near * far) / (near - far)

    mmatrix = OpenMaya.MMatrix()
    OpenMaya.MScriptUtil.createMatrixFromList( matrix, mmatrix )
    return mmatrix