当前位置:首页 > IT技术 > Windows编程 > 正文

blender api 获取当前3d视图矩阵
2021-09-19 22:46:13

 

 

import bpy
from bpy import context as C
from mathutils import *

sns=C.screen
areas=sns.areas
area=None

for i in areas:
   if i.type=='VIEW_3D':
       area=i
       break
       
spaces=area.spaces
for i in spaces:
   if i.type=='VIEW_3D':
       space=i
       break
       
region=space.region_3d

vecz0=Vector( (0,0,1) )
vecz1=Vector( (0,0,1) )
vecz0.rotate( region.view_rotation )

maxv=max([abs(i) for i in vecz0])
idn=[abs(i) for i in vecz0].index(maxv)

vecRst=Vector( (0,0,0) )
vecRst[idn]=-1
if vecz0[idn]>0:vecRst[idn]=1


region.view_rotation = vecz1.rotation_difference(vecRst)

 

本文摘自 :https://www.cnblogs.com/

开通会员,享受整站包年服务立即开通 >