###### 5.7 - Simple Car Example Using Functions
import maya.cmds as cmds

def create_car(name, length =2 , width = 1):
body = create_body(length, width)
tires = create_tires(length, width)
final_name = assemble_car(name, body, tires)

cmds.select(clear=True)

return final_name

def create_body(length, width):
body = cmds.polyPlane( w = length, h = width, name = "body")
return body[0] # transform node

def create_tires(body_length, body_width):
tire_width = 0.25 * body_width
x_pos = 0.5 * body_length
z_pos = 0.5 * body_width + 0.5 * tire_width

fl_tire = create_tire("front_left_tire", tire_width, tire_radius, x_pos, 0, -z_pos)
fr_tire = create_tire("front_right_tire", tire_width, tire_radius, x_pos, 0, z_pos)
rl_tire = create_tire("rear_left_tire", tire_width, tire_radius, -x_pos, 0, -z_pos)
rr_tire = create_tire("rear_right_tire", tire_width, tire_radius, -x_pos, 0, z_pos)

return [fl_tire, fr_tire, rl_tire, rr_tire]

def create_tire(name, width, radius, tx, ty, tz):
tire = cmds.polyCylinder(h = width, r = radius, ax = (0, 0, 1), sc = True, name = name)
cmds.setAttr("{0}.translate".format(tire[0]), tx, ty, tz)
return tire[0]

def assemble_car(name, body, tires):
body_grp = cmds.group(body, name = "body_grp")
tires_grp = cmds.group(tires, name = "tires_grp")

car_grp = cmds.group(body_grp, tires_grp, name = name)
return car_grp

if __name__ == "__main__":
final_name = create_car("test_car")
print(" Car created: {0}".format(final_name))

#### Mycar using Ogre and Newton

2009年06月30日 6.46MB 下载

#### SAS functions by example

2014年08月06日 9.34MB 下载

#### AutoCompleteTextView

2013年03月26日 1021KB 下载

#### 72.Which tasks can be performed using SQL functions built into Oracle Database ? (Choose three.)

2016-03-02 16:14:23

#### RocketMQ / rocketmq-example / src / main / java / com / alibaba / rocketmq / example / simple /

2014-09-05 11:01:01

#### Rapid Object Detection using a Boosted Cascade of Simple Features

2013年10月28日 195KB 下载

#### 73.Which tasks can be performed using SQL functions that are built into Oracle database ? (Choose th

2016-03-02 16:25:57

#### Rapid object detection using a boosted cascade of simple features-简译

2015-04-06 08:29:27

#### 整理Rapid object detection using a boosted cascade of simple features论文中的要点

2017-02-08 17:51:16

#### Rapid Object Detection using a Boosted Cascade of Simple Features 部分翻译

2014-11-27 10:11:38

## 不良信息举报

5.7 - Simple Car Example Using Functions