本文整理汇总了Python中BPyMesh.pickMeshRayFace方法的典型用法代码示例。如果您正苦于以下问题:Python BPyMesh.pickMeshRayFace方法的具体用法?Python BPyMesh.pickMeshRayFace怎么用?Python BPyMesh.pickMeshRayFace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPyMesh
的用法示例。
在下文中一共展示了BPyMesh.pickMeshRayFace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import BPyMesh [as 别名]
# 或者: from BPyMesh import pickMeshRayFace [as 别名]
def main():
scn = bpy.data.scenes.active
ob = scn.objects.active
if not ob or ob.type!='Mesh':
return
is_editmode = Window.EditMode()
if is_editmode:
Window.EditMode(0)
mousedown_wait() # so the menu items clicking dosnt trigger the mouseclick
Window.DrawProgressBar (0.0, '')
Window.DrawProgressBar (0.1, '(1 of 3) Click on a face corner')
# wait for a click
mouse_buttons = Window.GetMouseButtons()
while not mouse_buttons & LMB:
sys.sleep(10)
mouse_buttons = Window.GetMouseButtons()
# Allow for RMB cancel
if mouse_buttons & RMB:
return
while mouse_buttons & LMB:
sys.sleep(10)
mouse_buttons = Window.GetMouseButtons()
Window.DrawProgressBar (0.2, '(2 of 3 ) Click confirms the U coords')
mousedown_wait()
obmat= ob.matrixWorld
screen_x, screen_y = Window.GetMouseCoords()
mouseInView, OriginA, DirectionA = mouseViewRay(screen_x, screen_y, obmat)
if not mouseInView or not OriginA:
return
me = ob.getData(mesh=1)
# Get the face under the mouse
face_click, isect, side = BPyMesh.pickMeshRayFace(me, OriginA, DirectionA)
if not face_click:
return
proj_z_component = face_click.no
if not face_click:
return
# Find the face vertex thats closest to the mouse,
# this vert will be used as the corner to map from.
best_v= None
best_length = 10000000
vi1 = None
for i, v in enumerate(face_click.v):
l = (v.co-isect).length
if l < best_length:
best_v = v
best_length = l
vi1 = i
# now get the 2 edges in the face that connect to v
# we can work it out fairly easerly
if len(face_click)==4:
if vi1==0: vi2, vi3= 3,1
elif vi1==1: vi2, vi3= 0,2
elif vi1==2: vi2, vi3= 1,3
elif vi1==3: vi2, vi3= 2,0
else:
if vi1==0: vi2, vi3= 2,1
elif vi1==1: vi2, vi3= 0,2
elif vi1==2: vi2, vi3= 1,0
face_corner_main =face_click.v[vi1].co
face_corner_a =face_click.v[vi2].co
face_corner_b =face_click.v[vi3].co
line_a_len = (face_corner_a-face_corner_main).length
line_b_len = (face_corner_b-face_corner_main).length
orig_cursor = Window.GetCursorPos()
Window.SetCursorPos(face_corner_main.x, face_corner_main.y, face_corner_main.z)
SHIFT = Window.Qual.SHIFT
MODE = 0 # firstclick, 1, secondclick
mouse_buttons = Window.GetMouseButtons()
project_mat = Matrix([0,0,0], [0,0,0], [0,0,0])
def get_face_coords(f):
f_uv = f.uv
return [(v.co-face_corner_main, f_uv[i]) for i,v in enumerate(f.v)]
if me.faceUV==False:
me.faceUV= True
#.........这里部分代码省略.........