當(dāng)前位置:首頁 > IT技術(shù) > Windows編程 > 正文

blender api 獲取當(dāng)前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/

開通會員,享受整站包年服務(wù)立即開通 >