MY BLOG DIRECTORY:
YivanLee:专题概述及目录INTRODUCTION:
上一卷花了三小时入门了Maya python脚本编程,这一部分主要是在Maya中用脚本做一些功能,这些一个个的功能经过封装和UI制作就能成插件。
MAIN CONTENT:
【1】在模型顶点上再生成模型
![v2-047fa309c80f192c42f248b4cd088e8a_b.jpg](https://i-blog.csdnimg.cn/blog_migrate/70a324a40c648693cf47b50debb3bfd4.jpeg)
import maya.cmds as cmd
vertexes = cmd.ls(selection = True, fl = True)
for vet in vertexes:
pos = cmd.xform(vet, query = True, translation = True, worldSpace = True)
print pos
ball = cmd.polySphere(sx = 10, sy = 10, r = 0.5, name = str(vet))
cmd.move(pos[0],pos[1], pos[2], ball)
【2】给模型设置随机顶点色
操作之前需要打开顶点色预览
![v2-bef976d57470bd950ebd2ca6ed575d3f_b.jpg](https://i-blog.csdnimg.cn/blog_migrate/9284d83b2ae9011823c238063d1a1bab.jpeg)
![v2-b4ffdb83b344627d34aa70e9f8225ae0_b.jpg](https://i-blog.csdnimg.cn/blog_migrate/66c9c4e0b366cbd287e7406c6db4b5e5.jpeg)
import maya.cmds as cmd
import random
random.seed(1234)
vertexes = cmd.ls(selection = True, fl = True)
for vet in vertexes:
cmd.select('%s' % vet)
r = random.uniform(0, 1)
g = random.uniform(0, 1)
b = random.uniform(0, 1)
cmds.polyColorPerVertex(rgb=(r, g, b))
【3】把世界坐标烘焙到定点色里
![v2-e798deca24be4086d6a47202c3e582e3_b.jpg](https://i-blog.csdnimg.cn/blog_migrate/3e85ee62c620fa0acc90a5ae467440b8.jpeg)
import maya.cmds as cmd
import random
random.seed(1234)
vertexes = cmd.ls(selection = True,