关闭

5.1 - Introduction to Functions

226人阅读 评论(0) 收藏 举报
分类:
import maya.cmds as cmds

def create_car(tx, ty, tz):
    body = cmds.polyPlane(w = 4, h = 2)
    tire1 = create_tire(1.6, 0, 1.3)
    tire2 = create_tire(1.6, 0, -1.3)
    tire3 = create_tire(-1.6, 0, 1.3)
    tire4 = create_tire(-1.6, 0, -1.3)
    
    car_name = cmds.group(body, tire1, tire2, tire3, tire4, name="car")
    cmds.select(clear=True)
    
    cmds.setAttr("{0}.translate".format(car_name), tx, ty, tz)
    
    return car_name
    
def create_tire(tx, ty, tz):
    tire = cmds.polyCylinder(ax=(0, 0, 1), sc = True)
    cmds.setAttr("{0}.translate".format(tire[0]), tx, ty, tz)
    cmds.setAttr("{0}.scale".format(tire[0]), 0.7, 0.7, 0.275)
    
    return tire[0]
    
car1 = create_car(5, 0, 5)
car2 = create_car(5, 0, -5)
car3 = create_car(-5, 0, 5)
car4 = create_car(-5, 0, -5)
                 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:414952次
    • 积分:10077
    • 等级:
    • 排名:第1812名
    • 原创:590篇
    • 转载:90篇
    • 译文:0篇
    • 评论:96条
    最新评论