获取3维点在屏幕投射位置


import maya.OpenMaya as om
import maya.OpenMayaUI as omui

def get_view_position(pos):
    # 传入一个三维数组
    view = omui.M3dView.active3dView()
    x_ref = om.MScriptUtil()
    y_ref = om.MScriptUtil()
    x_ptr = x_ref.asShortPtr()
    y_ptr = y_ref.asShortPtr()
    view.worldToView(om.MPoint(pos), x_ptr, y_ptr)
    vectorx = x_ref.getShort(x_ptr)
    vectory = y_ref.getShort(y_ptr)
    return(vectorx, vectory)

评论
  目录