Blender Python UV 学习

Blender Python UV 学习

1. bmesh面转换

bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
bm.faces.ensure_lookup_table()

2. 面选择

# Index of face to texture
face_ind = 0
bpy.ops.mesh.select_all(action='DESELECT')
bm.faces[face_ind].select = True

3. uv展开

# Unwrap to instantiate uv layer (对选择表面, 展开uv层)
bpy.ops.uv.unwrap()

4. 得到uv BMLayerItem

# Grab uv layer
uv_layer = bm.loops.layers.uv.active

bm.loops <bmesh.types.BMLoopSeq>

    This meshes loops (read-only).
Note: Loops must be accessed via faces, this is only exposed for layer access.

bm.loops.layers <bmesh.types.BMLayerAccessLoop>

    custom-data layers (read-only).

bm.loops.layers.uv <bmesh.types.BMLayerCollection>

    Accessor for BMLoopUV UV (as a 2D Vector).

bm.loops.layers.uv.active <bmesh.types.BMLayerItem>

    The active layer of this type (read-only).

bmesh.types.BMLayerItem

    Exposes a single custom data layer, their main purpose is for use as item accessors to custom-data when used with vert/edge/face/loop data.

5. 开始uv映射

# Begin mapping...
loop_data = bm.faces[face_ind].loops

bm.faces <bmesh.types.BMFaceSeq>

    This meshes face sequence (read-only).

bm.faces[face_ind] <bmesh.types.BMFace>

bm.faces[face_ind].loops <bmesh.types.BMElemSeq of BMLoop>

bmesh.types.BMLoop

This is normally accessed from BMFace.loops where each face loop represents a corner of the face.
# bottom right
uv_data = loop_data[0][uv_layer].uv
uv_data.x = 1.0
uv_data.y = 0.0

文章来源地址https://www.yii666.com/article/758086.html文章地址https://www.yii666.com/article/758086.html网址:yii666.com<网址:yii666.com文章来源地址:https://www.yii666.com/article/758086.html

版权声明:本文内容来源于网络,版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。文本页已经标记具体来源原文地址,请点击原文查看来源网址,站内文章以及资源内容站长不承诺其正确性,如侵犯了您的权益,请联系站长如有侵权请联系站长,将立刻删除

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信图片_20190322181744_03.jpg

微信扫一扫打赏

请作者喝杯咖啡吧~

支付宝扫一扫领取红包,优惠每天领

二维码1

zhifubaohongbao.png

二维码2

zhifubaohongbao2.png