Академический Документы
Профессиональный Документы
Культура Документы
MEL Scripting
for Maya Animators
Mark R. Wilkins
Chris Kazmier
With contribution from
Stephan Osterburg .
. ,
MAYA:
MEL
-
2004
. ,
Maya: MEL /. . - : -, 2004. - 480 .
, MEL - Maya .
no MEL, , .
, , .
, ,
.
Maya, - .
ISBN 1-55860-841-9
ISBN 5-93378-097-9
. ,
Maya: MEL
-
. . .
. .
-.
! 19034, , ., . 21, 1. .: 333-82-11, ok@kudits.ru
16.06.04
70x90/16. . r i i " i ; i i i . ^-
. . . 35,1. 2000. : 1302
ISBN 1-55860-841-9
ISBN 5-93378-097-9
-, 2004
.
117623, . , . , . 10.
Maya: MEL
MEL.
, , MEL. ,
.
- (Doug Cooper), ,
Dreamworks Feature Animation
Maya: MEL , , . , .
,
.
-
Electronic Arts
(Henry
LaBounta),
,
Maya (MEL) . :
MEL
,
.
,
. , ,
,
, , , , , MEL.
MEL Maya
:
,
;
,
;
,
MEL.
Maya www.nikp.com/MELscripting/
. (Mark R. Wilkins) PDI/DreamWorks.
, Walt Disney Feature Animation
, Dinosaur (), Mission Impossible 2 ( 2),
A.I.: Artificial Intelligence ( ) Minority Report (
). , Harvey Mudd College.
(Chris Kazmier) /
DreamWorks Feature Animation. PDI/DreamWorks Intel Aliens, Fox Animation Studios Titan
(: ), Bartok the Magnificent ( ) Anastasia ().
. (Mark R. Wilkins)
PDI/DreamWorks,
Maya.
, Maya. Walt Disney
Feature Animation , . , Dinosaur (), The Legend of Bagger Vance ( ),
Mission Impossible 2 ( 2), .: Artificial Intelligence ( ) Minority Report ( ).
(Chris Kazmier) / DreamWorks Feature Animation,
, . PDI/DreamWorks
Intel Aliens, 3D Fox Animation Studios,
Titan AE (: ),
Bartok the Magnificent ( ) Anastasia ().
, 3D
.
1997 2002 Maya Alias/Wavefront
, ,
,
! (plug-ins) Maya - Maya Embedded Language (MEL). , Disney, DreamWorks, ILM Sony Pictures Imageworks,
MEL.
, , 2001
MEL-. MEL , Maya, MEL .
MEL Maya. , , ,
MEL Maya ; MEL , , .
,
Maya. Maya, ,
, , ,
- Learning Maya
Alias]Wavefront , .
MEL ,
.
, , , 1-3, , MEL-. 6, 7 9, , , MEL - , , . . . .
, 4 5,
. ,
, , .
12, , , .
, ,
4 5,
, ,
MEL-, .
MEL 6-11 (character setup). 12-14, . 2
(crowd system) 18 , 19 , MEL .
, ,
.
, , , ,
, .
Crowd system , , - , , ,
: >. - . . .
10
MEL Maya
, (Aron Warner), (Susan Rogers)
(Ken Pearce),
. (Ed Gavin),
(Kate LaBore), (Chris Rock) (Doug Cooper) , .
Morgan Kaufmann, , (Belinda Breyer),
(Mona Buehler), (Diane Cerra) (Cheri Palmer)
.
.
, , , , .
P. VWIKUHC (Mark R. Wilkins)
Kpuc (Chris Kazmier)
(Stephan Osterburg), .
2 19 .
, .
1
MAYA
:
Maya , (nodes) ,
(dependency graph).
, ,
(transform hierarchy),
.
, , NURBS-4, .
Maya, , , (timeline) . .,
MEL.
?
, MEL-
, ,
.
. -. . .
- ( ,
).
12
MEL Maya
() , , Maya . , Maya
.
, Maya,
, MEL-.
, Maya-, ,
. ,
Maya ,
MEL-, , , MEL Maya ,
.
,
,
, , , (expression relationship), , ,
,
(node), , ,
(DG-). (attribute), , .
(dependency graph), (scene graph)
(. . 1,1.).
DG- DG Node Reference no Maya, Help.
, , Maya,
, ,
, . (locked),
. keyable (),
, nonkeyable (), .
keyable nonkeyable .
, keyable Channel Box, a to
nonkeyable - , , nonkeyable - . . - . . .
1. Maya
13
. 1.1.
(Node - ; Connection - )
(data type), ,
. Maya :
(Integer) ( ).
(Floatingpoint) - .
(String), .
(Boolean) - , /
(on/off) / (true/false).
(Enumerated) ,
, .
, ,
(array), (vector) (matrice).
MEL - DG- .
, , , , Maya
. , MEL, , . , Maya, ,
, .
MEL Maya
Ls.
;-
Sea ID X 1
Scale V l"
Scale Z i '
Visibility
' SHAPES
dire cti onalLlg TtShepd
Color R 1
Color G -J
Color 1
Menslty i
Use Ray Trace S off
, , Shad Cotor R __
Shad Color
Shed Color 6"
sa
Selected Focus
Attributes
Help
Intaisty Sample
$ ErnirSpeoda
j Shadow*
! Piv 1haHJnn/4hniir^.BU,
Select
Load Attributes
Copy Tab
1. Maya
Attribute Editor ,
, . ,
. 1.3, Directional Light Attributes .
, Attribute
Editor, , , .
Attribute Editor
Attributes. To, MEL, .
,
.
, . ,
, , , , , ,
,
.
Connection Editor (. . 1.4.).
Options Left 5 Filet! R.fjh: Sde Filers
!'
FleloM Right
horn > to
0(4ts
"=
Help
'-.
Reload Lalt
locator!
Inputs
i
|
Caching
Cactog
Node Stale
Node E w-s
t>
Bwndng Box
Visbidlj
t>
Intermediate Object
Matrix
Template
Inverse Matrix
Ghcslrig
WoridMaliix
>
P"rtM**-
nil ]biRn'jpi
Use Object Col
'
"^J
Clb;ecl Cctar
fimovs
16
MEL Maya
, , 3D Studio Max
Softimage .
Hypergraph (. . 1.5.), ,
Window > Hypergraph... . Hypergraph
, , Graph >
7
Up and Downstream Connections .
. 1.5. Hypergraph
, Up and Downstream
Connections .
, Hypergraph , ,
Hypergraph . ,
, ,
.
, Maya ,
, , .
, .
(. . 1.6.) , , , 10- 20-
.
1. Maya
= 0
= 10
17
= 20
. 1.6.
. , . 1.7,
.
makeNurbSpherel
nurbsSphereShapel
nurbsSpherel
. 1.7. ,
(. . 1,8), ,
translate Y n u r b s S p h e r e l . , timel Maya - - , . translate Y . , Maya
, .
timel
makeNurbSpherel
nurbsSpherel jranslateY
(animation curve)
nurbsSphereShapel
nurbsSpherel
. 1.8. ,
IS
MEL Maya
, Maya,
, .
MEL ,
.
Maya ,
, Maya
, MEL.
.
?
Expression Editor Channel Box , .
. , node2 nodel, , . 1.9. 3.
nodel
expression!
node2
. 1.9.
1:
Hypergroph
, Hypergraph ,
. :
.
1. , File > New Scene .
2. , Sphere
Create > NURBS Primitives > Sphere.
3. , 10 Translate Y
Channel Box.
4. 10 Translate Y Channel Box. Key Selected , Translate Y
,
5. Frame 10 , .
Frame 10, ,
Frame 0.
6. 0 Translate Y, Enter, , Key Selected.
1, Maya
. 1.10.
Hypergraph
Hypergraph, .
Alt + + , Alt + - -. , ,
, .
. . ,
Backspace Delete. ,
,
- , - . - .
. .
, - . - . . .
' , 4.5 Input and Output Connection. . . .
MEL Maya
() (Connection Editor) ,
.
, ,
(), ()
(), .
. 1.10 nurbsSphere1_translate Y
nurbsSpherel.
(transform node), nurbsSphereShapel
(shape node).
, , ,
, .
, , Hypergraph Up and
Downstream connection. - , - Maya, time!, . ,
.
. (joint), ,
.
1. .
2. , XZ; .
3. ScaleX, 3.
4. Joint .
Enter.
5. , Skin > Bind Skin > Rigid Bind (
> > ).
6. , Rotate, , , (. , 1.11).
7. Window > Hypergraph ( > ) .
8. Graph > Up and Downstream Connections ( > ) Hypergraph. . 1.12.
, , ,
Maya
. . 1.12 makeNurbSpherel,
nurbsSphereShapel, nurbsSphereShapelOrig . Hypergraph .
1. Maya
21
. 1.11. ,
. 1.12. Hypergraph
tweak, group joint, Maya
, Rigid Bind, nurbsShpereShapel.
. , Hypergraph
, , Set,
, .
MEL Maya
,
, Maya , , NURBS-, , . ,
(transform hierarchy), . Maya
, , ,
Hypergraph .
, , /. /
, ,
, . . ,
, ,
Grandparent (), Parent () Child ().
X Y . 1.13.
Grandparent
tx= 0 1=
Parent
tx = 1 ty =
Child
tx = 1 ty
. 1.13. /
, X Y Parent Grandparent ( ),
X = 1 Y = 2. Child,
translate X translate Y, X = 2 Y = 4.
1. Maya
23
, . 1.13, , , . :
,
,
.
,
, , . .
.
, , , :
, , , , , , ,
, , , , ()
. Maya
(instancing). , , , , , .
, ,
.
, , , ;
, , ,
. .
,
, (constraint)
(object set), .
. ,
, Maya ,
,
, .
, , .
MEL Maya
24
Maya ,
. -, Scene Hierarchy Hypergraph
. , Window >
Hypergraph... , - Graph > Scene Hierarchy
Hypergraph.
. Scene Hierarchy , ,
, !
Outliner Window > Outliner... Outliner
, , , ,
[+] [-]
(. . 1.14).
1^ Maya
25
2:
, Maya ,
, Maya ,
.
-, :
1. Maya File > New Scene.
2. Create > NURBS Primitives > Sphere.
, .
Channel Box, nurbsShperel - .
Outliner:
3. Window > Outliner...
, nurbsSpherel .
- nurbsSpheral.
Outliner:
4. Outliner Display > Shapes.
5. [+], nurbsSpherel .
. 1.15,
, . , n u r b s S p h e r e l ,
, , nurbsSphereShapel, ( , NURBS-). , , , NURBS, ,
NURBS-, ,
.
26
MEL Maya
JiP persp
top
ffl
3jf
tFDnt
JJ?
side
nurbsSphereShapel
(2)
defaullLightSel
(5
defaullObjectSet
1. Maya
27
, !
, , .
, , :
1. rbsSptiere2 Outliner Move.
2. , n u r b s S p h e r e l .
3. Select by Component Type.
4. .
, . ,
, - , , ,
, , .
^Qutliner
'
<;
':
61
persp
jj^
w top
-1
Ircnl
side
Z7 nufbsSpherel
j
nurbsSphereShapel
J'
b
/ / 1481
nurbsSphereShape!
defaultLightSet
defaultDbiecfSet
. 1.16. Outliner
, , Outliner.
1. , n u r b s S p h e r e S h a p e l , Outliner.
2. Window > Hypergraph...
3. Graph > Up and Downstream Connections.
Hypergraph n u r b s S p h e r e S h a p e l .
makeNurbSpherel , . -
initialShadingGroup.
28
[ MEL Maya
Maya,
(history). ,
, .
Edit > Delete by Type > History,
, ,
.
, makeNurbSpherel, - , Maya
,
, , . Hypergraph makeNurbSpherel
:
1. makeNurbSpherel Attribute Editor...
.
2. Attribute Editor ,
, , , .
3. Attribute Editor.
4. nurbsSphereShapel, .
5. Maya Edit > Delete By Type > History,
Hypergraph .
Hypergraph , makeNurbSphsrel .
6. nurbsSphereShapel Attribute Editor...
, NURBS Surface History , ,
.
MEL Maya
Maya, , MEL. , Maya
MEL-, ; MEL-
, Maya, - ,
Maya.
MEL-,
, , Script Editor
Window > General Editors > Script Editor...
. Script > Echo All Commands Script
Editor. , MEL MEL, Script Editor.
1. Maya
29
2 , MEL-, , .
, May
Maya, Maya , ,
,
, .
.
MEL -
, , ,
.
Hypergraph ,
Upstream ( ), Downstream ( ), Up and Downstream
Connections.
, / (parenting)
(grouping), .
Outliner
Hypergraph ( (Scene Hierarchy)).
,
(Connection view) Hypergraph .
, , .
(joint), >. Outliner
, Display > Shapes.
MEL Maya,
, .
MEL-
:
MEL- .
Maya ,
, ,
MEL- " (shelf button).
MEL-, .
Maya MEL .
MEL-, .
MEL
?
MEL-, , ,
,
.
-, Maya , , .
Maya ,
, , .
-, MEL-,
. ,
no MEL ,
, , Maya.
Maya Shelf () -
Maya. ,
, , , , , . -. . .
2. MEL -
31
, . MEL,
, , , .
, Enter,
Return Enter - .
, Enter,
Return Enter , Enter
, Enter .
(Script Editor), Return Enter
, Enter MEL-,
( ), MEL- (
MEL-, ).
Script Editor, Enter
-,
, *.
, , Enter
. -
MEL-, Enter,
.
(command line)
(command feedback line)
(command line) Maya
MEL-. , MEL- Enter.
(command feedback line) Maya, , MEL-
.
:
1. File > New Scene (, , )
2. .
3. sphere Enter.
nurbsS&herel, :
Result: nurbsSpherel makeNurbSpherel
sphere, , , ( -
32
MEL Maya
, MEL-, ).
nurbsSpherel - , a makeNurbSpheral - .
,
nurbsSphereShapel, Maya
.
(Command Shell)
Irix Windows Maya ,
Maya. Window >
General Editors > Command Shell..., ,
Maya, , , .
1. Window > General Editors > Command Shell...
.
2. sphere Enter.
, .
3. , .
.
,
,
, .
4. Enter .
.
(Script Editor)
(Script Editor)
, .
, .
-
(status message) (command input) .
,
.
Bt: , MEL-
, . , . ,
,
.
,
:
2. MEL -
33
-1302
34
MEL Maya
&
Maya MEL-
, . :
, .
, , ,
, (shelf) ,
,
.
:
,
Enter Enter ,
- .
, , ,
, , ^
MEL
,
, ,
MEL-. , Maya, MEL-,
, .
MEL, -
,
, , .
,
sphere Enter . :
sphere;
//Result: nurbsSpherel makeNurbSphere"!//
2. MEL ~
35
36
MEL Maya
MEL-c,
, .
MEL , , :
1. .
2. Edit > Copy Script Editor.
3. ( ).
4. Edit > Paste Script Editor.
5. Enter .
Maya , Z,
.
(shelf button)
MEL-
,
MEL-. :
1. , ,
.
2. () , , .
, (+), , , .
3. .
MEL.
, Help Line ,
, ,
(, !).
, ,
.
4. , ,
MEL , .
MEL .
2. MEL -
57
MEL-
MEL- ,
MEL- .
, ;
MEL- .
Maya, .
MEL MEL.
, MEL . MEL- , , , , .
Script Editor, :
1. MEL, , .
2. Script Editor File > Save Selected...
3. test.mel Save.
38
MEL Maya
. , ,
, Maya ,
, .
MEL-.
, , , MEL ,
, . , Create >
Locator Maya .
, , , - MEL ? , .
, Maya, , , MEL , .
Maya MEL-, ,
Edit > Show All Commands Script Editor. Create > Locator . ,
:
createLocator;
createPrimitive nullObject;
spaceLocator -p ;
// Result: locator! //
editMenuUpdate M a y a W i n d o w j m a i n E d i t M e n u ;
autoUpdateAttrEd;
, , , .
, MEL- ,
. createLocator,
createPrimitivenullObject spaceLocator - - ,
, , . editMenuUpdate
autoUpdateAttrEd Maya
.
, ,
MEL-, Maya ,
. , , MEL, , Maya , , , . ,
Show All Commands, Maya , .
2. MEL -
whatls
whatls , ,
Maya,
. , , editMenuUpdate,
:
whatls editMenuUpdate;
Enter. :
//Result: Mel procedure f o u n d in: C:/AW/Maya4, 0/scripts/ startup/buildEditMenu.mel//
, MEL- editMenuUpdate, , . :
whatls spaceLocator
:
//Result : Command//
, spaceLocator - MEL-
, , MEL
Command Reference Maya.
MEL-
(argument), , . , Maya - ,
. ,
select nurbsSpherel;
40
MEL Maya
, Maya nurbsSphere 1,
. select MEL-, a nurbsSpherel - , .
(flag), .
, ;
spaceLocator - ;
- , ,
, 0 0 0 X, Y Z , . . :
Is -si;
Is ( list) (-si selection - ).
, . ' :
Is -selection;
MEL, , : -, -q -. - (create) , -q (query)
, - (edit)
.
, .
2. MEL -
Web-
www. h igh en d3 d. . coirt/m ay a/
HighendSD - , , Web- Maya,
Softimage, Softimage XSI, Alias
Studio Renderman and Jig . Highend2D, www.highend2d.com
Shake Combustion.
Maya HighendSD MEL-, ,
Maya, , ,
. - Maya
Highend3D, .
www .po stforum. m
Postforum.com Macintosh, , 2D
3D , Maya. Postforum.com Maya,
Maya Macintosh.
w ww . aliaswave front .
Alias] Wave front. Alias j Wave front
, Maya, ,
.
MEL-,
MEL-, , . mel. ,
maya ( Windows My Documents maya ). maya
scripts, .
,
(script path) Maya.
15.
42
MEL Maya
, , MEL, , MEL .
, ,
. ,
MEL ( .mel) Enter. , Maya, , .
, , , ,
(, blah, mel):
source blah.mel
MEL-, . mel, .
, , , MEL-.
MEL- ,
, , .
, MEL
,
, .
,
, MEL-.
, , Maya , Maya.
3
:
(custom)
.
?
Maya - ,
. :
(particle expression), (per-partide
attribute) (particle object), (object
attribute expression), .
, -.
,
( ). 4
, , .
:
1. Maya.
2. , Create > NURBS Primitives > Sphere.
3. Channel Box Translate X,
, 0.
4. Channels Expressions...
44
MEL Maya
?
, :
nurbsSpherel.translateX - time;
, 2,
Maya . , (statement), (;). , MEL-, .
,
nurbsSpherel translatoX time,
, . , .
, , nurbsSpherel.translateX, . X.
:
, (=). . , ,
X = 4, , ,
X 4 .
, Maya MEL, , , , ,
, . ,
3.
45
.
, , (assignment),
( )
( ), , , , . time , Maya
, . ,
, , nurbsSpheret.transl.ateX.
, , , , . , :
nurbsSpherel.translateX = 4;
:
4 = nurbsSpherel.translateX;
, , ,
4 , .
,
, .
, - , , , - . ( BASIC) , Maya MEL (= ==) , , Maya
.
MEL :
if (3 = = 4) print "Hello!' 1 .
Maya , 3 4 (, ,
), Hello!
. , , ,
, , .
= MEL, , ,
, , .
MEL Maya
46
Mm/a
, ,
nurbsSpherel.translateX Channel Box ,
, (
12
I) . ,
, ,
, - .
Maya ,
: , ,
, (
),
( , ).
, ,
Hypergraph .
. 3.1, Hypergraph expression!,
. , ,
, Hypergraph, , 6
( timel, Maya )
nurbsSpherel. , .
Edit Bookmarksi Graph Rendering; Optiors 5ho Help
. .1.
Maya 5.0 ,
, . , , -,
- . - . . .
3.
, Maya ,
. , , Maya
, (, ),
.
,
Maya.
Maya - , MEL?
, Maya MEL .
, Maya
,
. MEL
getAttr ,
setAttr
. , , 5,
, MEL -
.
Maya MEL , ,
. MEL- ,
, MEL- , , Maya ,
, , ,
getAttr setAttr (
s) .
, , , . Maya 13,
, , getAttr
setAttr. Maya -
, Maya , , . . , - MEL-
getAttr setAttr. . -. . .
48
MEL Maya
, Maya ,
14
( ).
, MEL
getAttr setAttr, ,
. MEL ,
, ,
( , MEL
$), .
( )
, Maya, .
:
, ,
. , X , Y .
, - .
,
, Y , ,
Y .
, MEL-,
.
:
,
( , ).
, ,
.
, .
. Maya .
,
,
. - . . .
3. ^
49
,
, (driven keys) .
, , , (constraints).
, - .
,
, ,
Connection Editor (,
, , Connection Editor - ).
, , , ,
, (utility node)
.
. Hypershade Editor.
, . Maya
, ( ) - (scaling) (offsetting)
.
, ,
revolutions. revolutions 0 1,
Y.
Y rotateY 0 360, revolutions
360. rotateY. :
mysphere.rotateY - mysphere. revolutions * 360;
( , *).
, , :
1. Maya.
2. NURBS- Create > NURBS Primitives >
Sphere.
3. mysphere.
SO
MEL Maya
4. , Attribute Editor
Window > Attribute Editor.
5. Attributes > Add Attributes... Attribute Editor.
6. revolutions , ,
(float) .
Channel Box mysphere
revolutions.
7. Channel Box RotateY, .
8. Expression Editor, Expressions...
Channels Channel Box.
9. Expression Editor:
mysphere.rotateY - mysphere.revolutions * 360;
1Q Create, Close,
Expression Editor.
Revolutions Channel Box.
0.5 (, !) Enter, , Rotate Y 180. 1, Rotate Y 360.
,
, .
revolutions - 25 25 .
Rotate Y 25 , 9000, .
, .
* / .
(offsetting) .
, , mysphere mysphere2,
mysphere2 Y
mysphere 45 . :
mysphere2.rotateY - mysphere.rotateY - 45;
,
:
inysphereS. rotateY = (mysphere, revolutions * 360) - 45;
, , .
3.
51
?
, Maya (operator precedence)
, .
: 2 + 3 * 4, , Maya , 2 + 3 ( ), 4.
20.
Maya :
print (2 + 3 - 4 ) ;
Enter , ,
14. Maya , ,
. . Maya
3 * 4 ( 12), 2 14.
,
. print, , 20:
print ((2 + 3) * 4 ) ;
2 + 3 , Maya
, .
Maya,
.
, .
, ,
.
!
*
+
<
[]
++-/ %
<= > >=
_ __ i _
&&
,
.
52
_ MEL Maya
May
, , Maya.
, .
,
Maya, MEL-, . , , , MEL.
:
(variable) (
).
.
, . .
,
, ,
. , .
.
, .
, , , ,
. :
float $xval = time;
float $yval;
Syval = sin ($xval);
translateX = $xval;
translateY - $yval;
,
.
(variable definitions). ,
, . , ,
(, ,
3.
S3
). Maya ,
, ,
.
, Maya MEL,
, .
,
.
Maya ,
.
, .
Maya MEL- -
.
($), , . $ , ( Maya- ).
, $rotation_value,
, :
float $rotation_value;
, ($) . , .
(=), , :
$rotation_value = 4.0;
, $rotation_value ,
, :
$rotation_value = $rotation_value * 2;
, , ,
, ,
, . , $rotation_value 4.0, ( 8.0), $rotation_value.
$rotation_value.
,
1, 2, 3 . . -
, , , -;
54
MEL Maya
, . (int)
:
int
$number_of_spheres;
, .
, , (, , -),
( -9999),
,
- . , ;
int $num_oranges = 4;
string, ,
( ). vector,
4.
, :
string $my_name = "Mark W i l k i n s " ;
, ,
.
( ), (+). , Maya , , (+), (
), ( ). , ,
, :
string $first_name - "Mark"
s t r i n g $last_name = " W i l k i n s "
string $my_name = $first_name + " " + $last_narne;'
,
, .
$first_name + $last_name, : MarkWilkms.
, \. , testing \n 1 2 3,
, :
Testing
1 2 3
.
Maya ( ) ,
,
3.
55
. Maya ,
, .
, , $ . $
Maya ( $ )
( ).
, , .
(scope) ,
, .
, , , ,
,
. 10 (procedure),
.
, (global),
Maya .
float Sxval = time;
float $yval;
.
, Sxval Syval. Sxval , , (
, .
24 , 24, time).
, time , MEL-.
, ,
,
timel, .
,
, :
Syval = sin ($xval);
Sxval ,
translateX, Syval. ,
Sxval Syval. , Sxval,
Syval 1 -1.
,
, Arithmetic, Logic, and Relational
Operators Using Maya; Expressions. ,
, Functions.
56
MEL Maya
, ,
. , MEL-c.
:
translateX = $xval;
translateY - Syval;
MEL-, ,
. setAttr, Set Attribute. MEL :
setAttr nurbsSpherel.translateX $xval;
setAttr n u r b s S p h e r e l . t r a n s l a t e Y $yval;
MEL-, ,
, ( time Sxval). , MEL-,
, getAttr :
$xval = 'getAttr expressionl.time 1 ;
, MEL- ,
' expressionl. time,
('')
. , , , .
Maya getAttr setAttr ,
,
, . getAttr setAttr
MEL-, .
1:
, . , . ,
.
3.
57
, , -
, -
, , , (aim constraint) .
. :
,
, , .
, .
, . 0, , , . 0, .
, , .
, , . , , , , ,
,
, , , .
.
-, , ,
. , ,
, , , ,
, .
, ,
, , . Maya , (weight), 0 1, ,
. , , ,
,
, .
I . ' , Create > NURBS Primitives > Sphere.
2. , translatex Channel Box -3, X.
MEL Maya
58
3. 3 translateX.
4. , , ,
Create > Locator , .
5. targetl translateY 10.
6. , Shift, , ,
.
7. , Animation, Constrain > Aim .
Aim.
8. Aim - , 1 0 .
9.
Add/Remove, .
.
, , .
1Q , , Shift, ,
. Constrain > Aim,
, .
, , ,
. .
,
(. . 3.2) Shading
> Shade Options > Wireframe on shaded ( Wireframe on shaded -
).
. 3.2. ,
3.
59
.
1. Create > Locator.
2. target2.
3. target2 , Constrain > Aim.
4. target2 Constrain > Aim .
. , (. . 3.3).
. 3.3. ,
5. , , Attribute Editor,
n u r b s S p h e r e 1 _ a i m C o n s t r a i n t 1 . Extra Attributes .
, Targetl WO Target2 W1.
,
.
6. Target2 W1 0, Enter
, .
7. Attribute Editor , . Attribute Editor
nurbsSphere2_airnConstraintl.
Target2 W1 0.
8. , Target2 0, Attribute
Editor , , .
60
MEL Maya
1
target !,
. target2 ,
0 (, , ,
, ).
, , ,
:
target"! 1
target2 0, targeti.
targeti target2 ,
.
targeti target2
, . .
, ,
.
. ,
, ;
1. Create > Locator eyes.
2. , eyes Edit > Parent.
3. .
eyes.
targeti, , eyes , .
,
.
-, eyes target.
target 1, targeti, target 2,
target2.
-, eyes coordination.
coordination 0, ,
target, 1,
, target.
3.
- , () .
, , , coordination ( ) 1, ,
. ,
, - ,
Script Editor Expression Editor, ,
.
-, ,
:
float $eye1_coord_target1_weight;
float $eye1_coord_target2_weight;
float $eye2_coord_ta rget1_weight;
float $eye2_coord_target2_weight;
, , , ,
, .
, , ( ). , -
.
62
MEL Maya
0 ,
, 1 ,
, targets
eyes.target - 1. , eyes, target 2, target2 1, eyes, target 1,
target2 0.
, . , , //, ,
, ,
. , ,
, ,
, , ,
, .
// target2
// eyes.target ,
// target2, eyes.target 2,
// , eyes.target 1
$eye1_coord_target2_weight = eyes.target - 1;
$eye2_coord_target2_weight = eyes.target - 1;
targetl 1
target2. , , target2 ,
, targetl, target2
1, , target2.
0.5, .
// targetl target2 ,
// 1
$eye1,coord_target1_weight = 1 - $eye1_caord_target2_wetght;
Seye2_coord_target1_weight = 1 - $eye2_coord_target2_weight;
, 0 1
1 0 1 - ,
(inversion).
.
, coordination.
, , -
, , , , .
3.
63
,
.
- :
1. , ,
Maya.
2. . Channel Box
, .
3. Channel Box Channels > Channel Names > Long. ,
MEL- ( ,
, ).
, ,
.
// aimConstraint
nurbsSpherel_aimConstraint1.targetlWO - $eye1_coord_target1_weight;
nurbsSphere2_aimConstraint1.targetlWO = $eye2_coord_target1_weight;
nurbsSpnere1_aimConstraint1,target2W1 - $eye"Lcoord_target2_weight;
nurbsSphere2_aimConstraint1.target2W1 - $eye2_coord_target2_weight;
.
float $eye1_coord_target1_weight;
float $eye1_coord_target2_weight;
float $eye2_coord_target1_weight;
float $eye2_coord_target2_weight;
// target2
// eyes.target ,
// target2, eyes.target 2,
// , ^yes.target 1
$eye1_coord_target2_weight = eyes,target - 1;
Seye2_coord_target2_weight - eyes.target - 1;
// target"! target2 ,
// 1
$eye1_coord_target1_weight = 1 - $eyel_coord_target2_weight;
$eye2_coord_target1_weight - 1 - $eye2_coord_target2_weight;
64
MEL Maya
I/ aimConstralnt
nurbsSphere1_aimConstraint1.target1WO =
rbsSphere2_aimConstraint1. target"! WO -~
nurbsSphere1_aimConstraint1,target2W1 =
nurbsSphere2_aimConstraint1.target2W1 -
$eyel_coord_targetl_weight;
$eye2_coord_target1_weight;
$eye1_coord_target2_welght;
$eye2_coord_target2_weight;
target eyes:
1. eyes.
2. Attribute Editor.
3. Attributes > Add Attribute... Attribute Editor.
4. target, float, scalar, - 1, - 2,
- 1.
5. Add, Add Attribute Attribute Editor.
Channel Box target.
6. target Channel Box
Expressions...
7. Create. , ,
- ,
. , , , //Result: expression! , Create Expression Editor
Edit.
8. targetl t a r g e t 2 .
9. 0,
1, 2.
IQ ( ,
, ).
,
target eyes.
coordination, . coordination ,
, nurbsSpherel targetl, a nurbsSphere2
targetO. ,
, :
3.
float
float
float
float
$eye1_uncoord_targett_weight
$eye1_uncoord_target2_weight
$eye2_uncoord_target~l_weight
$eye2_uncoord_target2_weight
65
= 1;
- 0;
= 0;
- 1;
targetl, - target2.
, ,
0 1. ()
0 1 , , :
<> = ( * ) + ((1 - ) * )
( * ) , ,
((1 - ) * ) , 0.3, 30%,
30% 70% , ((1 -30%) * ).
, , () , .
nurbsSphere1_aimConstraint1.targetlWQ =
(eyes,coordination * $eye1_coord_target1_weight) +
((1 - eyes.coordination) * $eye1_unccord_target1_weight);
nurbsSphere2_aimConstraint1.targetlWO (eyes.coordination * $eye2_coord_target1_weight) +
((1 - eyes.coordination) * $eye2_unccord_target1_weight);
nurbsSphere1_aimConstraint1.target2W1 =
(eyes.coordination * $eye1_coord_target2_weight) +
((1 - eyes.coordination) * $eye1_unccord_target2_weight);
nurbsSpnere2_aimConstraint1.target2W1 =
. (eyes.coordination * $eye2_coord_target2j/ight) +
((1 - eyes.coordination) * $eye2_unccord_target2_weight);
eyes.coordination ,
. eyes.coordination 1,
. , , 0.5 .
3 - 1302
66
MEL Maya
:
target2
eyes.target ,
target2, eyes.target 2.
, eyes.target 1
$eye1_coord_target2_weight = eyes,target - 1;
$eye2_coord_target2__weight - eyes.tarcet - 1;
$eye1_coord_target1_weight = 1 - $eye1_coord_target2_weight;
$eye2_coord_target1_weight = 1 - $eye2_coord_target2_weight;
//
//
nurbsSphere1_aimConstraint1.targetlWO (eyes.coordination * $eye1_coord_target1_weight) +
((1 - eyes.coordination) * $eye"Lunccord_target1_weight);
3.
67
,
, . ,
, , , .
, ,
,
, . ,
, , . , , ,
.
, -
,
, getAttr setAttr,
,
( , Maya , , ,
, ,
getAttr setAttr).
, MEL-, , .
getAttr setAttr.
'
:
(per-object) (per-particle)
.
.
.
, ,
.
.
.
.
.
:
. , Translate X , X.
, . ,
Translate X, Y Z,
, ,
position (). , ,
(vector), ,
. , , (position), (velocity) (acceleration), ,
4.
69
, ,
. Maya - ,
. X, Y
Z, , ,
, ,
.
, MEL- , , :
vector Srnyvec;
,
, :
$myvec - $myvec2;
,
:
Smyvec - 1, 2, 3;
X, Y Z, 15.
,
. , ,
Smyvec, Maya
, $myvec.x, $myvec.y $rayvec.z. ,
, , , :
vector Smyvec = 0,1,2;
$test = Smyvec.z;
// $test 2
print (Smyvec.);
// 1
$myvec.x = 3;
// '
:
$myvec.x - 3;
. -. . ,
MEL Maya
70
, :
Imyvec.x = 3, myvec.y, myvec.z;
Y Z Smyvec ,
X , 3.
.
.
, :
vector Smyvec = 1,2,3;
vector $myvec2 = 3,4,5;
vector $myvec3 = $myvec + $myvec2;
// $myvec3 4,6,8;
,
. . 4.1, X, Y Z, ,
, ,
.
1, ,
1, 2.
-
Ill
1, 2. f 1, 0, 0 = 2, 2,
. 4.1.
,
, , . (, . 4.2) 2, 2, 0 1, 2, 0 -1, , .
1. Z, 0 - 2, ', 0 = -1, ,
. 4.2.
, : unit, mag, angle, cross, dot rot:
unit unit ,
, , . :
vector $myvec - 0,0,3;
vector $myvec2 = unit ($myvec); // $myvec2
0,0,1
,
, , , 16. , ,
Smyvec, :4
.
vector $myvec_eight = 8 * unit ($myvec);
mag mag, magnitude, . :
float $myvec_length = mag ($myvec);
// $myvec_length 3
float $myvec_eight_length = mag ($myvec_eight);
// $myvec_eigth_length 8
16
. - .
. .
72
MEL Maya
$yvec
// 90
$xvec
// 0,0,1
, cross 1 ( (unit vector)),
, . , ,
(. . 4.4) :
mag ($vector1) * nag ($vector2) * sin ( a n g l e (Svectorl, $vector2))
unit (cross (Svectorl, $vector2))
, Svectorl $vector2. , ,
, , , , , .
4.
73
'
$yvec
$xvec
, 4.4.
dot dot ( ):
dot ($vectorl, $vector2)
:
mag($vector1) * mag($vector2) * cos(angle ($vector1, $vector2))
,
0, - .
, ,
:
dot (unit ($vector1), unit($vector2))
0, ,
I - . 0 1,
, .
rot rot, rotate, . , (. . 4.5). , :
vector Smyvec = 0,1,1;
20 X, :
$pi - 3.141593;
$twenty_degrees = 20 * $pi / 180;
// !!
vector Smyvec = 0,1,1;
vector $z_axis = 0,0,1;
vector $rot_vec = rot ($myvec, $z_axis, $twenty_degrees);
MEL Maya
- o9
i
Imyvec
$z axis
. 4.5. Rot
He rot.
:
.
, , 3.
-, . ,
, , , (runtime particle expression), , ,
, ,
.
,
, , (creation particle expression),
- .
,
, - , . ,
, .
, .
4.
,
, ,
, . .
,
. , , ,
,
, ,
.
1:
,
, ,
. , , . ,
, (,
Z = -5),
.
,
- , , ,
Z = -5. , , ,
,
.
-, , :
1. File > New Scene.
2. Particle tool 10 20 ,
Enter, .
3. Particle Render Type spheres Channel Box
(. . 4.6).
4. .
MEL Maya
. 4.6.
5. , .
6. Component Editor (. . 4.7), Window >
General Editors > Component Editor...
4.
77
. 4.8.
:
1. 0.
2. Channel Box Translation X, Y Z, ,
, Key selected ( ),
3. .
4. Move. ,
, Z -5, . -6
.
5. Channel Box Translation X, Y Z, ,
, Key selected (. . 4.9).
6. . , , .
, :
1. .
2. , Magnitude Channel
Box, Expression Editor (. . 4.10).
3. :
if (tz > -5) {
magnitude = 5.0;
} else {
magnitude - - 35.0;
MEL Maya
78
[[^--.-^^^.^""^^^"!
. 4.9.
-11
Select Ntet Object Filter Attribute Ffcer Insert Functions Help
Creating Expte)ian
Extiesiicn Name I
*>| Selection
ffl^erti.
Attributes ,
attenuation
inaxOistence
appljf erVertra
uieMexDistarK
volumes haoe
.
?
newtonFieldl
7 Always Evaluate
Convert U rate 1* At
I" Norm
*"* 'Angular only .
;
'teitiff P" Riiiiiin-e
1!
Editor
1 EnpiesiionEdHof ^M
'itaKajon
(it (tz
lugnitudl - S . O ;
}
!
i .
J
negnicud - -3S.O;
JJ
' " :
'
-. 1 - - ' -'
Qeote
> jwtt
fs^iiw.
Oeai
Cbse
4. Create.
5. Expression Editor (. . 4.11).
. 4.11. z = -5
. - . if(tz>-5)
, ,
Translate Z -5 . ,
5.0, , 35.0.
Maya , Translate Z
,
5.0 -35.0. , , Translate Z, -5, .
81}
MEL Maya
-
:
,
.
, ,
.
Maya 3.0, ,
ramp.
,
Setting Particle Attributes with a Ramp Texture Maya:
Dynamics.
2:
,
.
, (omni emitter), .
-, :
1. File > New Scene.
2. Dynamics.
3. Particles > Create Emitter (options).
4. Omni () (emitter).
.
5. Create.
6.
.
, .,
(. . 4.12).
, , : Y = 2 + Z A 2.
X Z, Y ( ).
4.
. 4.12.
:
1. ,
.
2. particlel..., Attribute
Editor.
3. General Control Attributes ( )
Expressions After Dynamics ( )
(. . 4.13).
panicle! parlicleShapel
pariide: IpaflicleSbapel
MEL Maya
82
-I
rampVetoeily
acceteiation }
rarnpAcceleiation
mass
lietpatiPP
. Load Attributes
1
Copy Tab
. 4.14.
,
, .
. -, ,
, . -,
- ,
. ,
, Attribute Editor,
,
.
.
5. , position, Runtime expression...
6. .
Create:
vector $pos = position;
float $posY = (Spos.x) * C$pos.x) + (Spos.z) * ($pos.z);
position = Spos.x, $posY, $pos.z;
1. , position,
Runtime expression... .
,
, ( ,
4.
S3
). , , ,
Creation expression (
) .
8. Ctrl-C, .
9. , Creation, , .
10. Ctrl-V, , Create.
,
(. . 4.15).
. 4.15.
,
,
. ,
, , , .
,
( ), :
vector $pos - position;
tpos , . , -
, position., -
$pos, $pos. x, :
float $posY = (Spos.x) * (Spos.x) + (Spos.z) * (Spos.z);
84
MEL __
( )
$posY. , , $. , Y- ,
. Y- X Z
.
,
$pos.x Spos.z , , $posY:
position - $pos.x, $posY, $pos.z,
Expressions After Dynamics .
, ( ).
, , ,
, . ,
,
, .
Expressions After Dynamics, , ,
. , , , , , , , .
,
.
(emitter rate) 10 000
(. . 4.16).
. 4.16.
, .
,
, -
4. ^
85
. , Y-
, , , :
1. Expression Editor
, .
2. :
vector $vel = velocity;
velocity = Svel.x, 0, $vel.z;
3. .
- , 17.
, , 2. ,
- . ,
Expressions After Dynamics -
. .
,
.
, , .
, ,
. .
,
, , . 3 , , ,
, .
-
, . :
1. ( speed), 0.
2. :
float $speed = l:
vector $vel - sphrand($speed):
velocity =$vel.x, 0, Svel.z;
. . .
86
MEL Maya
: ,
:
, NURBS-.
MEL
.
Maya, ,
, .
,
, , , .
, :
, ,
.
,
,
. , ,
, , .
, ,
, ,
, Curve Flow, ,
(control vertices -- CVs).
,
- , .
1. (. . 4.17).
, ,
. , , , (inflection point), , .
4.
87
. 4.17.
2. , emitterl curvel ,
.
3. 1 - 400 - .
4. ,
, .
5. , particlel... ,
.
6. Per Particle (Array) Attributes, ,
, . Runtime expression.
7.
:
float SscaleQffset = 0.2;
float $pos[] = 'pointOnCurve -pr Cage) -p curve!';
float $tan[] = 'pointOnCurve -pr (age) -nt curve!';
float $norm[] = 'pointOnCurve -pr (age) -nn curve!';
vector Sposvec = <<$pos[0], $pos[!J, $pos[2]>>;
vector $tanvec = <<$tan[0], $tan[1], $tan[2]>>;
vector Snormvec = <<$norm[0], $norm[1], $norm[2]>>;
vector $norm2vec = cross ($tanvec, Snormvec);
position - $posvec + ($scaleOffset'$normvec*cos(age*20))+
($scaleOffset*$norm2vec*sin(age'20));
88
MEL Maya
8. Create.
9. Expressions After Dynamics on Channel Box.
(. . 4.18).
. .
. 4.18.
.
float SscaleOffset - 0.2;
,
. , ,
.
.
SscaleOffsat ,
MEL- pointOnCurve curvet.
:
float $pos[] = 'pointOnCurve -pr (age) -p curve"! 1 ;
, , $pos []. ,
$pos , (array) . , MEL- pointOnCurve
. , ,
.
, U V NURBS , .
, ,
. , ,
pointOnCurve ,
.
4.
89
MEL-, ,
, ". pointOnCurve
curvel , , - (age) , , ,
( age, ), -
. , curvel
, .
, MEL Command Reference, Help. 5
MEL- .
MEL-
, pointOnCurve , X, Y Z.
, ,
pointOnCurve , ,
: X, Y Z ( ).
pointOnCurve , , :
float $tan[] = 'pointOnCurve - (age) -nt curvel';
float $norm[] = 'pointOnCurve *-pr (age) ~nn c u r v e l ' ;
pointOnCurve - (normalized tangent) . X, Y
HZ , .
, 1;
,
unit.
- (normalized normal) . , , . ,
, , 1.
,
position , $[], $tan[]
$[] :
vector Sposvec = <<$pos[0], $pos[1], $pos[2]>>;
vector $tanvec = <<$tan[0], $tan[1], $tan[2]>>;
vector $normvec = $norm[0], $norm[1], $norm[2];
: , , , ,
.
90
MEL
, , .
, , . , ,
. ,
, .
,
$norm2vec. - cross,
. 1
, , 1:
vector $norm2vec = cross ($tanvec, Snorrnvec);
, :
position - $posvec + (SscaleOffset * Snonr.vec * cos (age"20))+
(SscaleOffset * $norm2vec - sin (age*2Q));
(Sposvec),
($scaleOffset * cos(age*20)) Snormvec.
SscaleOffset , ,
acos(age*20) -1 1. , :
( 20), .
, (SscaleOffset * sin(age*20
$norm2vec.
.
,
, .
.
-, ,
.
(. . 4.19).
, .
.
, , , (, . 4.20).
4.
. 4.19.
. 4.20.
, , ,
.
Numeric :
1. , , Particle Render Type
Channel Box Numeric.
2. Attribute Editor,
particle 1... .
3. Render Attributes, (. . 4.21).
Per Particle (Array) Attributes.
MEL Maya
_>J tminion * beeat
Render Attribute*
Depth Soil
. Add Altibjtes r
Attribute Name [ a g e ^
Point Size p
~~ PJ
" SelacledOnlji
^>j Render Slab
. 4.22.
, , ,
1/24, ,
(. . 4.23). ,
,
.
. 4.23.
4,
93
, ,
, , , . , .
, , ,
.
. ,
pointOnCurve
, . ,
180 . . 4.24 ,
180 .
. 4.24.
.
, :
1. New Scene No, , .
2. curve"), ,
.
3. , curvel , (Script Editor)
:
offsetCurve -d 0.1 -n curvelduide
4. Enter.
MEL Maya
. 4.25 , ,
curvet.
. 4.25. offsetCurve
offsetCurve curvelguide, .
-d 0.1 , 0.1 . , ,
, .
pointOnCurve ,
curvel, pointOnCurve
curvelguide, ,
. , ,
pointOnCurve -, ,
cu rvel.
, , .
, .
, , , MEL-, ,
.
pointOnCurve - -ch on ( construction history on).
PointOnCurvelnfo
.
setAttr getAttr ,
. ? MEL- pointOnCurve
, ,
. ,
.
4,
1.
95
, , :
// Result: pointOnCurvelnfol
pointOnCurvelnfol, .
2. emitter!.
3. , Expressions After Dynamics On , ,
:
float SscaleOffset = 0.2;
setAttr pointOnCurvelnfol.parameter (age);
setAttr pointOnCurve!nfo2,parameter (age);
float $pos[] = 'getAttr pointOnCurvelnfol.position';
float $tan[] = 'getAttr pointOnCurvelnfol. riormalizedTangent';
float $normEnd[] = 'getAttr pointOnCurve!nfo2,position';
float $norm[];
$norm[0] = $normEnd[0] - $pos[0];
$norm[1] = $normEnd[1] - $pos[1];
$norm[2] = $normEnd[2] - $pos[2];
vector Sposvec = $pos[0]h $pos[1]. $pos[2]>>;
vector Stanvec = <<$tan[0]. $tan[1], $tan[2]>>;
vector $normvec = unit ($norm[0], $norm[1], $norm[2]>>);
vector $norm2vec - cross (Stanvec, $normvec);
position = Sposvec + (SscaleOffset* Snormvec * cos (age'*20))+
($5caleOffset*$norm2vec * sin (age*20));
4. , curve!,
Attribute Editor Min Max Value NURBS
Curve History . Max Value - ,
, , , (. . 4.26).
5. , Lifespan Mode Constant Channel Box
Lifespan ( Lifespan Random),
(. . 4.27).
MEL Maya
MAtttJbuteWitOKEurrel
'
HMIS!
rurteCurve; Icu:veShapel|
-|
_JtJ
Focus 1
'
jj NURBS CuiweHiiloiy
!jj
MhMaWaiue [O.OOO
J3.DOO
Spans |3
Form j Clfis^
-rj
Dearee 13
Select
Load Alliibutes
'LHJ
j
Copy Tab
Dose
. 4.26. curvel
Target Geometry [Particle Locaj
Goal Smoothnes J3
Cache Data [off
Particle Render jPoints
Lifespan
INPUTS
. 4.27. Lifespan
6.
. . 4.28, , , .
. 4.28. ,
4. ^
97
- , 1, 0.
Speed, 0 Channel Box.
7. . , ,
, .
8. , , , ,
Dynamics, Solvers > Create Panicle Disk Cache.
, ,
' .
, , , -
. ,
, . ,
MEL- pointOnCurvelnfo, MEL-,
, ,
.
May a
,
.
.
, ,
, . , , -,
.
, ,
.
MEL-,
.
.
, ,
, MEL-. , .
4 -1302
98
. MEL Maya
,
,
. , -
, ,
.
, . Expressions After Dynamics .
0, .
,
, , .
Numeric
.
Numeric.
5
MEL-
:
MEL- Maya.
MEL-
Maya.
MEL-.
MEL.
MEL.
, MEL.
MEL.
MEL.
MEL Maya:
, , ,
Maya.
MEL-. DG-, .
, Maya
, , .
MEL-, , . ,
, . MEL (script node), , , , , ,
, , MEL-
-, .
* MEL Maya
MEL- :
.
? ,
: , ,
, ,
.
MEL- , , , , ,
:
,
, .
, .
, .
,
, .
, .
, ,
.
, MEL- , 3.
, . ,
. , , , , , 15 20,
.
MEL-.
.
, ( ), ,
, ,
.
,
/.
MEL
, 4. ,
.
MEL-
, MEL- ,
-
5. MEL-
, .
MEL-, ,
. , ,
, , (, , getAttr setAttr).
MEL-
MEL- - , - . ,
MEL- :
, , , .
, , , .
, , ,
.
, ?
- ,
? , , , ? , (,
), ?
, ,
. ,
, :
, , ,
, .
,
.
, MEL- ,
.
, :
.
, . , ,
.
102
MEL Maya
. ,
, ,
.
, , ,
, .
- .
, , .
, - ,
.
, , , , .
. , , ,
. ,
. , , ,
-, , .
.
. ,
, ,
, , , ,
, .
. , , ,
- , .
,
, , ,
( ).
,
, , , ,
MEL-.
, 6-15
,
, MEL
.
5. MEL-
(user interface)
, Maya .
MEL , 12 - 14. , ,
Maya, - .
2, MEL-.
MEL-, .
,
.
MEL-, ,
( , 3D ,
NURBS-, DG-, -
). , , -
, ,
.
MEL Is, list. Is , . , Is
. Is
, , n u r b s S u r f a c e ,
mesh, expression . .
, , is
-selection :
Is -selection;
, ,
Script Editor. - :
Is -selection;
//Result: nurbsSpherel nurbsSphere2//
4, , , MEL- .
, , ,
:
string $selectionList[] = 'Is -selection';
MEL Maya
MEL-, -selection
, -si. , :
string $selectionList[] = "Is -si 1 ;
, nurbsSpherel nurb$Sphere2,
$selectionList[0] nurbsSpherel,
$selectionList[1] nurbsSphere2.
9 , . ,
, , .
,
&MEL
Maya , , (query) .
, NURBS-, ,
sphere.
( )
.
MEL-,
, - Maya - MEL Command Reference,
Maya. MEL Command Reference
, ,
, .
MEL- , , MEL (create mode). MEL-, , , ,
, Maya , .
:
sphere;
, NURBS-.
MEL-, ,
. MEL- (edit mode). ,
, :
sphere -edit -radius 3 nurbsSpherel;
5. MEL-
, . ,
:
sphere -radius 3;
. ,
, sphere. , ( ,
, MEL Command Reference, ), g e t A t t r setAttr.
(query mode) , , , :
sphere -query -radius n u r b s S p h e r e l ;
.
. MEL Command Reference , . ,
, , ( )
,
.
, ,
,
,
eMEL
3 4 ,
Add Attribute. MEL- ,
. MEL
addAttr. bounciness
nurbsSpherel, :
addAttr -attributeType "float" -longName "bounciness"
-defaultValue 2 nurbsSpherel;
:
addAttr -at "float" -In "bounciness" -dv 2 nurbsSpherel;
106
MEL Maya
, n u r b s S p h e r e l ,
Attribute Editor ( )
Extra Attributes ( ). ,
nurbsSpherel,
nurbsSphereShapel. ,
.
3 4, MEL- .
, .
, Maya ,
, (
, ,
, .
setAttr
).
MEL-, , ,
, . , :
nurbsSpherel.bounciness = 5;
Script Editor, MEL ,
:
//Error: n u r b s S p h e r e l . b o u n c i n e s s = 5;//
/ / E r r o r : Invalid use of Maya object " n u r b s S p h e r e l . b o u n c i n e s s " . / /
b o u n c i n e s s 5, setAttr:
setAttr nurbsSpherel.bounciness 5;
, setAttr MEL-
, ,
.
MEL-
. MEL-, getAttr.
:
getAttr n u r b s S p h e r e l . b o u n c i n e s s ;
, Maya .
MEL-, :
float Sbounceval = 'getAttr nurbsSpherel.bounciness';
$bounceval
getAttr .
5, MEL-
MEL
MEL connectAttr.
Connection Editor, .
Maya NURBS-. , Script Editor:
connectAttr nurbsSpherel.translateX nurbsSphere2.translateY;
nurbsSpherel X, , .
nurbsSpherel X, n u r b s S p h e r e 2 Y.
Maya , isConnected, listConnections connect ion Info,
. , , n u r b s S p h e r e l . t r a n s l a t e X
nurbsSphere2. translateY, isConnected integer:
int $tx_ty_connected = 'isConnected nurbsSpherel.translateX
nurbsSphere2.translateY';
, Maya ,
: , 0 1, 0 -
, I - . 9.
, , d i s c o n n e c t A t t r:
disconnectAttr nurbsSphere!.translateX n u r b s S p h e r e 2 . t r a n s l a t e Y ;
MEL
MEL , . , translateX nurbsSpherel
nurbs3phere2.translateY , nurbsSphere2.translateY nurbsSpherel, t ranslateX.
Maya ,
Expression Editor :
nurbsSphere2.translateY = pow(nurbsSphere1.translateX, 2);
t
( pow, ?
Functions Using
Maya: Expressions Maya.)
, MEL , ,
,
. ( , ,
,
Hypergraph , ).
Script Editor :
expression -string " n u r b s S p h e r e 2 . t y " = p o w ( n u r b s S p h e r e 1 . t x , 2)";
, .
108
MEL Maya
. :
MEL-, . ,
, , .
,
Maya. , (
),
( \), ,
.
dynExpression,
.
dynExpression , .
1: MEL .
,
, , 4,
, . ,
, , , . ,
.
, ,
MEL- , , ,
, , , .
,
. , ,
. :
,
, .
.
, MEL- .
, MEL- ,
. ,
4, , ,
, -
5. MEL-
109
. , ,
MEL-.
1. .
2. , (
, .
Maya ).
3. , .
4. MEL- offsetCurve,
4.
5. ,
. .
6. .
7. ,
.
8. , .
9. ,
( , ,
).
10. / , ( ,
).
11. pointOnCurvelnfo .
12 , ,
4.
13. , dynExpression .
, , , . , , ,
. , , , .
, MEL
. , .
1. .
2. , Save Selected to Shelf...
File Script Editor.
3. , , spiralParticles.
, ( -
MEL Maya
, ,
: vyww.mkp.com/MELscriptingl.
// -, ,
// ,
string $selection_list[] = *ls -si';
// ,
// ( ,
// , )
string ScurveSelected = $selection_Hst[0];
float SstartOffset = 0.1;
float Sspeed = (1.0 / 24.0);
offsetCurve -d $startOffset -n ($curveSelected + "guide");
float $startPoint[] = 'pointOnCurve -pr 0 -p ScurveSelected';
float $startTangent[] - *pointOnCurve -pr 0 -nt ScurveSelected';
float $startGuide[] = ' pointOnCurve -pr 0 -p UcurveSelected + "guide") 4 ;
float $startNormal[];
$startNormal[0] = $startGuide[0] - $startPoint[0];
$startNormal[1] = $startGuide[1] - $startPoint[1];
$startMormal[2] = $startGuide[2] - $startPoint[2];
emitter -pos $startGuide[0]
$startGuide[1] $startGuide[2]
-dx $startTangent[0] -dy $startTangent[l] -dz $startTangent[2]
-n (ScurveSelected + "emitter") -spd 0.0
-type dir;
5. MEL-
111
112
^ MEL Maya
-, ;
string $selection_list[] = "Is -si';
, $selection_list,
.
$selection_list[0], - $selection_list[1] . .
.
,
.
string ScurveSelected = $selection_list[0];
, $curveSelected.
3 ,
- , , ,
particles emitter .
, , .tx .
,
. , $speed .
float SstartQffset = 0 . 1 ;
float $speed = ( 1 . 0 / 24.0};
$startOffset ,
, ScurveSelected. $speed
, ,
^ MEL-
113
, . 1/24,
24 ,
.
, , ,
. ,
. ,
, ,
offsetCurve:
o f f s e t C u r v e -d SstartQffset -n ($curveSelected + " g u i d e " ) ;
, guide
. ,
curvel, curvelguide.
,
, $startOffset . SstartPoint
X, Y 2. SstartTangent -, Y- Z-
. $startfiuide
X, Y Z, a $startNormal - -, Y- Z-
.
float $startPoint[] = 'pointOnCurve - 0 - $curveSelected';
float $startTangent[] = 'pointOnCurve - 0 -nt ScurveSelected';
float $startGuide[] = ' pointOnCurve -pr 0 -p ($curveSelected + "guide")';
float $startNormal[]; '
$startNormal[0] = $startGuide[0] - $startPoint[0];
$startNormal[1] = $startGuide[1] - $startPoint[1];
$startNormal[2] = $startGuide[2] - $startPoint[2];
, ,
,
:
emitter -pos $startGuide[0]
$startGuide[1) $startGuide[2]
-dx $startTangent[0] -dy $startTangent[1] -dz $startTangent[2]
-n (ScurveSelected + "emitter") -spd 0.0
-type dir;
114
MEL Maya
-
. -dx, -dy -dz emitter, ,
, .
$curveSelected emitter; , 0 (
). , -type d i r emitter,
.
:
particle -n (ScurveSelected + "particles"};
setAttr ($curveSelected + "particlesShape expressionsAfterDynafrics") true;
particle , . expressionsAfterDynamics true. setAttr Maya. -, ,
, , curvel, , particle
curvel particles,
curveiparticlesShape. ,
expressionsAfterDynamics. true,
(, 4
).
< > particlesShape.
,
addAttr , . addAttr , ,
Maya , .
select - Maya ,
. ,
, :
select - (ScurveSelected + "particlesSnape");
addAttr speed
scaleOffset particleShape, setAttr , :
a d d A t t r -In "speed" -at "float";
setAttr ($curveSelected + "particlesShape.speed") $speed;
addAttr -In "scaleOffset" -at "float";
setAttr (ScurveSelected + "particlesShape.scaleOffset") $start()ffset;
, , , , . -
5. MEL-
us
connectDynamic. -em , :
connectDynamic -em ($curveSelected + "emitter")
(ScurveSelectecf + "particles"};
/
parent:
parent (ScurveSelected + "emitter") ScurveSelected;
4 pointOnCurve -ch or
pointOnCurvelnfo . MEL- , .
, ,
:
string SmainCurvelnfoNode = 'pointOnCurve -ch on -pr 0 ScurveSelected';
string SguideCurvelnfoNode = 'pointOnCurve -ch on -pr 0
(ScurveSelected + "guide")';
, . ,
, 4,
, ,
. ,
, ,
, .
, ,
, , ,
$curve_param. .
, \.
, , , Expression Editor . . , +
.
string $exrString =
"float $curve_param = " + ScurveSelected + "particlesShape.age * " +
ScurveSelected + "particlesShape,speed;\n" +
"setAttr" + $mainCurve!nfoNode + ".parameter $curve_param;\n" +
"setAttr" + $guideCurveInfoNode + ".parameter $curve_param; \n" +
"float $pos[] = 'getAttr " + SmainCurvelnfoNode + ".position';\n" +
"float $tan[] = 'getAttr " + SmainCurvelnfoNode + ".normalizedTangent';\n" +
116
MEL Maya
"(" + ScurveSelected +
"particlesShape.scaleOFfset * Snormvec * cos(" +
ScurveSelected + "particlesShape.age*20)) + \n" +
"(" + $curveSelected +
"particlesShape.scaleOFfset * sin(" +
$CurveSelected + "particlesShape.age*20)) + \n";
, MEL- dynExpression -
dynExpression - . , , .
d y n E x p r e s s i o n -r -s SexprString (IcurveSelected + "particles");
dynExpression - -s $exprString (ScurveSelected + "particles");
MEL.
. ,
MEL-,
,
. , , MEL
MEL- .
; MEL-
MEL ,
: , , .
, , , , , , , .
5. MEL-
117
: MEL . ,
, .
. ,
.
.
- .
, , , .
, - , .
. , .
. .
, .
. , , ,
. , , , .
.
.
, , .
MEL- .
Maya MEL.
MEL.
.
.
, , .
.
3-5 , . 3
, Maya , ,
. , , .
( )
, ,
Maya, . ,
$ , :
int $a;
.
$, ( ), ,
, Maya .
6.
, , .
- , Maya
, , ,
. ,
:
$t = 54;
$t = { 1, 2, 3 };
( ,
{}, Maya .)
, Maya :
//Error: Cannot cast data of type int[] to int//
( (type casting) - , Maya .) Maya 54 $t $t -
, Maya 54 , , $t
.
, $t, Maya
(. ,
$t ), . , , $t
.
, .
.
:
$rny_variable = 5;
$my_variable = 5.25;
'print ($my_variable + "\n");
5, 5.25! ? $my_variable, $my_variable
( , Script
Editor, Maya). , 5.25 $my_variable
,
Maya ,
:
$my_variable_2 = 5 . 0 ;
$my_variable_2 = 5.25;
MEL Maya
, 5.25. ,
5.0 ( Maya ,
) $my_variable_2, Maya
. Maya 5.25, $my_varlable_2,
.
.
$my_variable_2:
float $my_variable_3;
$my_variable_3 = 5;
$rny_variable_3 = 5.25;
print ($my_variable_3 + "\n");
, $rny_variable_3 ,
Maya , 5
5.0, , ,
, , ,
, . , Maya ,
,
.
, ,
, , MEL,
.
, Script Editor ,
Maya.
, :
declare_aaa ( ) {
int $aaa - 10;
print ($aaa);
:
// Error: "$aaa" is an undeclared variable.//
, , ,
. , ,
. ,
6.
121
MEL- , ,
:
int $bbb = 34;
print_bbb ()
print ($bbb);
}
print _bbb ();
:
//Error: "$bbb" is an undeclared variable.//
,
. , MEL, , , , , .
, , , .
, , ,
( ).
, ,
Maya .
, ,
, , , global
. , ,
:
int $bbb = 34;
print_bbb() {
print (Sbbb);
:
print_bbb();
$bbb , . , ,
, - , . $_2. Script Editor:
global int $bbb_2 - 34;
print_bbb_2() {
print ($bbb_2);
}
print_bbb_2();
_122_
1. Maya
! !
, .
, . , , , ( ).
, ,
( ),
, . :
global int $bbb_2 - 34;
print_bbb_2() {
global
int
$bbb_2;
print ($bbb^2);
}
print_bbb_2();
$bbb_2,
( ), (
).
Maya ,
, . ,
, :
global int $my_int = 25;
assign_four() {
$ray_int = 4 ; // 4 $my_tnt
assign_four();
print($my_int);
! 25, ,
, $my_int 4. ?
$my_int :
global int $my_int;
$my_int ,
$my_int 4, Maya
$my_int, ,
4, , , !
6.
123
, $my_int,
(, ), 25 4.
,
, :
global int $my_int = 25;
proc assign_four{) {
global int $my_int;
$my_int = 4; // 4 $my_int
}
assign_four();
print($my_int);
, .
, .
-, , ,
, ,
, .
-,
, ,
. ,
, , -
.
-, MEL- .
,
, .
,
,
,
, .
,
Maya. Maya. , ,
, .
, Channel Box Attribute Editor
.
124
MEL Maya
- Maya,
. Windows,
Mac OS, Irix Linux.
, Maya
Maya.
, getenv
putenv MEL.
MEL u
MEL . ,
, Maya , , ,
.
MEL-, , MEL-,
Maya -
. MEL- Maya,
, Maya , C++.
(procedure), 10, MEL- ,
. ,
,, , .
MEL- ,
, ,
.
(function) Maya,
. , ,
MEL ,
. (return value).
6.
, (operator) - , + -,
. , 3 + 3 + , 3 3 6.
MEL-, , , . , (argument) , - . . ,
Maya, 3 * 3 , ham * sausage - ,
* , .
MEL-, Maya , ,
, , , .
Maya , , ,
;' , , MEL Script Editor.
, Maya
MEL, , , ,
. ( +) , ( (),
) .
, MEL , . , ,
,
, - .
, Maya ,
,
, , .
: (integer),
(floating-point number) (string). ( , , Pascal, ,
. MEL -
.)
MEL (vector), (array)
(matrix). -
( ), , ,
, .
MEL Maya
. (1, 2, 3, 4 . .), ,
(-1, -2, -3, -4 . .).
.
:
int $i;
int $i = 3;
. +, -, * / , ,
. ,
, . - . , .
Script Editor, Enter:
print (3 + 4);
, , 7. :
print (3 - 4 ) ;
, - 1 .
, , :
print (3 * 4);
12. . ,
:
print (3 / 4 ) ;
0, 3 4 3 (0,75).
, , . , , . . float() (
, , , ,
MEL-).
, :
p r i n t (float(3));
6.
127
, 3, , 3 . Maya ,
0, , , Maya
. 3
float(3) :
print (float(3) / 4 ) ;
0,75, 0, ,
. ,
, .
,
, ().
, , . , $ $ :
int $a -14;
int $b = 3;
, :
print ($ - ($ * ($ / $)));
, 2, , .
, , :
print ($a % $);
(%) (modulus)
, , $ $.
: a mod b.
. ,
+=, -=, *=, /= %=. ,
$ = $ + 4;
, :
$ += 4;
,
$ - $ % 3;
, :
$ %= 3;
128
MEL ^
. ++ . :
$ = $ + 1;
:
$++;
:
$ = $ - 1;
, :
$--;
( )
,
, , Maya
.
. 9, , , .
.
:
print (5 > ); //
print (5 < 6); //
print (5 >= 6); //
print (5 <= ); //
print (5 = = 6); //
, 1
0. 1 , , 0 , .
( - ). MEL 1, - 0,
, .
not ( I ) , add (&&) or ( ) :
^
print (0 && 0);
//
print (1 0);
//
//
// 1
or (\\) or 1,
( ), 0, 0.
print (0 | | 0); //
print (1 | | 0); // 1
print (0 | | 1); // 1
print (1 | | 1); // 1
. ,
print (! ( S& (1 | | 0)});
// 1
. ,
float, ,
( 1.2 -5.4)
(, 1.0 1000).
. . :
float $m;
float $m = 3.2;
. , , , %,
. , MEL, .
,
, .
, , . . ,
$f $:
float $f = 36.0:
float $n = 3.2;
, ,
:
5-1302
13
MEL Maya
sqrt($f)
// $f
pow($f, $n) // Sf $
log($f)
// $f
Iog10($f)
// $f 10
abs($f)
//
sin($f)
// $f
cos($f)
// $f
tan($f)
// $f
, Maya,
Learning Maya: Expressions, 6.
.
= = ,
. , , .
,
, .
,
, , = =,
, ,
. , .
,
, , ,
, .
, , . :
f l o a t $a - 5 . 0 ;
f l o a t $b - 4.9999999999;
f l o a t Sslop = 0.0001;
print ($a = - S b ) ; //
print (($a > (Sb - $slop)) I! ($a < ($b + (Sslop))); // 1
, ,
,
;
.
(, 3 ),
, Maya -
6.
, Maya .
:
I
3
-4
3.0
2.5
-3.4
1-12
, , 2 * 3.0
6 , 6.
, int(). :
print (int ( 3 . 7 ) ) ;
3. ,
, , , ,
ceil($f) f l o o r ( J f ) , , $f , .
float(). :
p r i n t (float(7)/2);
3.5, 3, print (7/2).
9 Using Maya: MEL , MEL , . , ,
,
.
. Maya (vector) ,
, . 4 .
.
:
vector $ vector 1;
132
MEL Maya
, , , ,
. :
vector $testvector_2 = 3,4,5;
.
, ., $. $ :
$ = $testvector_2. + 2, // $ 5
:
$testvector_2.z = 4;
// !
, , , , :
$testvector_2 = $testvector_2.x, Stestvector2_.y, 4; // .
. +, -, *, / %, , .
, , .
,
. :
a.b.c + d , e , f = ( + d), ( + ), ( + f ) > >
, :
.. - d,e,f = ( - d), (b - ) , ( - f)
, ,
:
.. * d , e , f = ( * d) + (b ) + ( * f )
, (%) ,
:
a,b,c / d.e.f = ( / d ) , (b / ) , ( / f)
a.b.c % d.e.f = ( % d ) , (b % e). ( % f)
.
.
,
. :
vector $a_vec = 1,2,3;
print ($a_vec + 3 ) ; // 4
12
6.
133
, ,
.
. ,
, , ,
mag(), cross(), dot()n unit(). , rot()
, angie()
.
4, 6 Using Maya: Expressions.
. - , ,
. ,
, , , MEL, ,
, .
.
:
string $my_str;
, ,
, :
string Sgetteysburg - "fourscore and seven years...";
, ,
, ,
(, , Maya
- ). (
) +:
$string1 = "Testing 1";
p r i n t ($string1 + "testing 2 " ) ; // Testing 1testing 2
. , , , Testing1testing2Testing1testing2
. (\) , :
print ($string1 + "testing 2");
// Testing1testing2
,
,
:
p r i n t ("Here are some d o u b l e quotes: \" \ n " ) ;
134
MEL -Maya
, , (\), , , ,
, Maya, . \
- .
, ,
(escaped character). \ , . \",
" , . \ ,
, .
, , . = =, :
print ("testing" = = "testing"); // 1,
, ,
,
MEL- tokenize. tokenize ( ), (
, , )
:
string $myarray[];
tokenize "This is a test" Smyarray;
print $myarray[3]; // "test";
, -
, :
string $myarray2[];
tokenize "This is a test" "t" $2;
print $myarray2[1]; // "es";
es, 0 his is a,
I es, t.
MEL- 5 ,
MEL- . , MEL,
Script Editor.
. - ,
.
, , . ,
, .
.^1
135
Maya ,
(scalar). ,
Maya .
. .
, ([]), , , :
string $s[];
int $a[j;
float $f[];
,
, ,
. , ,
({}) :
string $str_list[] - {"this", "is", "a", "string", "array"};
int $int_list[] = {1, 2, 3, 4 } ;
float $lots_o_floats[] = (1.3, 1.5. 34, -23, 1E-29};
, :
string $str_list2[] = ("this",
"is",
"a",
"string",
"array"};
. , ,
, . , ,
:
int $[4] = 3; // !!
,
(, , ,
4, 0):
int $u[
$[4] = 3;
3,
0,
0 4 :
int $u2[] = (, , , , 3};
136
MEL Maya
. . , .
0, - 1 . .
,
:
print ($str_list2[2]);
$[1] = 4;
float $add_it_up = $lots_o^fioats[3] r 3 2 . 4 ;
(
9), , ,
, :
int $i - 2;
. , ,
:
print (size{$str_list2));
, , ,
5, . , 1, 0.
, , ,
.
( ,
, ):
int $ g r o w i n g _ a r r a y [ ] = {0, 1, 2 } ;
p r i n t (size($growing_array) + " \ n " ) ;
$growing_array[5] = 45;
print (size($growing_array) + "\n"J;
( 5, 0, )
. ,
, 0,
, 0,0,0, ,
"", .
. , , $i_am_too_long
$i_am_too_long[999999], Maya , 1
, .
Maya - , -
6.
137
, , Maya, .
,
MEL- clea . :
clear $ i_am_too_long;
, , Maya
.
,
. Maya ,
, ,
. ,
, . 4 .
,
, , ,
.
Maya , .
, ,
.
i
-
MEL
, , , , , .
. ,
, , ,
.
, ,
( ,
), ( , ),
( , ,
)
138
MEL Maya
( ,
, Maya Linux, Irix OS X).
MEL ,
, ,
. , , , , .
Maya
- ,
, .
,
- ().
,
, ,
.
.
MEL-, , Maya.
, ,
. clear .
MEL-
:
MEL-.
MEL-.
, .
MEL- .
', , MEL- .
MEL-?
MEL- MEL-. MEL- - ,
Maya. Maya, . ( , , MEL),
MEL- . , MEL, MEL- .
MEL- ,
,
. MEL-
, .
, MEL- MEL-
.
. MEL-
2, MEL- ,
,
Echo All Commands Script Editor.
MEL-. , , , , , ,
. , - ,
MEL Maya
140
, www.highend3d.com,
MEL-, ,
.
- .
, -, ,
, MEL-, . - NURBS-. ,
, .
. MEL-
MEL Command
Reference, - no Maya. MEL Command Reference
Maya, , , , , .
, ,
, .
Help > MEL Command Reference... Maya, Maya,
(. . 7.1).
MEL-, , , , , , .
jrJjuHfrnuiH
7. MEL-
MEL-
MEL- , , , , , , , , , , . :
sphere -radius 10. -sweep 180
sphere , -radius 10.0 - , , a -sweep 180 - , ,
.
MEL- , , . -
, - -q, - -. ,
.
,
sphere , ,
. sphere :
sphere -q -radius nurbsSpherel
; - .
:
sphere -e -radius 15 nur&sSpherel
, , .
getAttr setAttr .
MEL-
, , .
.
MEL Command Reference sphere - /radius,
, -radius, , -.
,
, .
MEL Command Reference
, , ( ,
), , .
142
MEL Maya
.-' j -j" /.' ,-'- " "- -"* --""- -,-'-,- '
, , ,
. , , , move, . , , X, Z.
sphere, , , .
MEL- MEL-
MEL-
, MEL- MEL- . MEL- ( ), ,
. , MEL- , 10 X :
cone -name testing;
move 10 0 0 testing;
select -cl;
cone ,
testing, makeNurbsConel,
, . cone MEL-, .
,
* ) . :
string $coneNodeNames[] = 'cone -name testing?';
$ c o n e N o d e N a m e s [ 0 ] ,
a $coneNodeNames[1] - .
MEL- : , .
, .
, ;
string $coneNodeNames[] = cone ( " - n a m e " , "testing?");
, , .
7. MEL-
143
.
MEL-,
. , , , .
, , , 10 X:
cone -name Cone;
move 10 0 0 Cone;
, , ,
Cone ?
, Maya 2,
cone . move Cone.
, , .
,
, , , ,
.
. ' , ' - . ' '--.,'. '\.- /\'-.---. -
',','--. '.
-,
.'
,- ,.'~
,'
- .,'
...',.;
'
eval
eval ,
MEL- MEL-. eval
, MEL-, .
:
string Sspherecommand = "phere"
string $nodenames[] = eval ($spherecommand);
, sphere Snodenames.
eval , MEL . , eval.
:
string StheCommand =
for ($x = 0 , $ < 5, $++);
switch ($whichShape)
144
MEL Maya
case 0:
StheCommand += " sphere;
break;
case 1:
StheCommand +- " c o n e ; " ;
break;
MEL-
3 4, MEL- . , Maya MEL ,
MEL-.
MEL- , Maya , . , MEL ,
. , , . , 4,
MEL-.
MEL-
MEL- Maya,
; MEL- Script Editor.
MEL- ,
,
- . -
Maya Maya,
, MEL-.
?. MEL-
145
MEL- , . ,
MEL-.
MEL-, , , . , MEL-
.
MEL- :
, , , ,
eval,
. , eval, ,
, MEL .
MEL- ,
Maya, ,
, .
8
MEI.
:
MEL- ,
MEL-.
5, MEL-
. 5 ,
, getAttr setAttr,
MEL-. ,
.
Is
,
is, ,
Maya ,
.
,
, , . , ,
: < > <. >. ,
bill bill
:
8. / MEL
bill_joint1
billj.oint2
billjointa
bill_skin
bill_eye_1
bill_eye_r
147
Is
, , bill_, '*,
, . ,
, :
string $bill_nodes[] = .'ls ("bill.*")';
:
//Result: bill_eye_1 bill_eye_r bill_joint1 bill_joint2 bill_joint3 bill^jointShapel
bill_jointShape2 bill_skin bill_skin|bill_skinShape//
Is *, . , *
.
,
. ,
, $character_name j
, :
string $character_nodes[] = 'Is ($character_name + " _ * " ) ' ;
,
, is ,
.
, ,
, ,
j o i n t .
:
string $joint_list[] = 'Is * j o i n t * ' ;
: (?) ; (*)
. - . . .
148
MEL Maya
-
, , ,
:
string $selection[] = 'Is -si";
, , ,
:
string $selection_joints[] = "Is -si *joint*';
, Is, showType:
string $bill_skin_listing[ ] = 'Is -showType "bill_skin"';
//Result: bill^skin transform//
, : ,
, , . . ,
$bill_skin_listing[0] , a $bill_skin_.listing[l] - ,
$bill_skin_listing[0]. Is ,
2, 4, 6 . ., 3, 5, 7 . . , bili_skin
transform. ,
nu rbsSu rf , , .
-type .
, nurbsSurface,
-type:
string $nurbs_surface_list[] - 'Is -type nurbsSurface';
, -type, , showType. , , ,
:
Is -si -showType
. -type.
Is, , , ,
MEL-,
objectType.
Is ,
, , - t r a n s f o r m s , shapes , . is MEL Command Reference.
8. MEL
'
149
, ,
, -dag (dag directed acyclic graph - ). Maya ( Outliner) ,
DAG, , . bill
bill,
:
string $bill_nodes[] = 'Is -dag b i l l ' ;
/ / R e s u l t : bill b i l l _ j o i n t 1 bill_JointShape1 b i l l _ s k i n o i l l _ s k i n j i D i l l _ s k m S h a p e
bill_joint3 bill_eye_1 bill_Joint2 bill_joiritSnape2 bill_eye_r//
, -showType
, -type .
Is ,
-long. , -allPaths:
string $full_bill_skin_path[] = 'Is -long bill_skin';
// Result: | b i l l | b i l l _ j o i n t 1 | b i l l _ s k i n //
select /
, ,
, MEL- , , ,
.
.
, , Is -si
. :
select -cl;
.
Maya , .
ISO
MEL Maya
, ,
,
select.
string $bill_nodes[], ,
bill, :
select $bill_nodes;
, , ,
.
, , ; . -
,
.
select , Select Maya
.
-add -af, . -add ,
, ,
. -addFirst ,
, , .
select -add " b i l l _ j o i n t 1 "
select -addFirst $joint_list;
-add
, , Shift, , Select, .
-d select ,
, :
select -d "bill_eye_l";
, , Shift, , Select.
8, MEL
, (, ,
), -all:
select -all;
MEL-
,
MEL, . , .
:
sphere
cone
torus
nurbsPlane
nurbsCube
- ( -constructionHistory), , .
sphere -ch on;
//
/'/
,
ch on
MEL- , , , , .
, 4, ,
pointOnCurve.
, pointOnCurve, , . ,
-ch on :
string SnodeName ~ 'pointOnCurve -ch on c u r v e " ! ' ;
, 4, , MEL-. MEL Command Reference,
, -ch.
152
MEL Maya
createNode
,
createNode. . , , , , -
-. ,
locTransform loci:
createNode transform -n locTransform;
createNode locator -n loci -p locTransform;
//Result: Ioc5//
, createNode getAttr set Aft ,
, .
, listRelatives.
listRelatives ,
. , (
-), ( -), ( -s)
( , . .)
-allDescendants.
listRelatives , .
, listRelatives, :
sphere -name firstSphere;
sphere -name secondSphere;
parent secondSphere f i r s t S p h e r e ;
listRelatives,
:
string $firstSphereChildren[] = 'listRelatives - firstSphere',
// Result: firstSphereShape secondSphere //
string SsecondSphereParents [] = 'listRelatives -p secondSphere';
// Result: firstSphere //
string SfirstSphereShape [] = 'listRelatives -s firstSphere';
// Result: firstSphereShape //
string $firstSphereDescendants [] = 'listRelatives -ad firstSphere';
// Result: firstSphereShape secondSphereShape secondSphere //
8. MEL
153
5 , connectAttr. MEL
,
.
, , ,
, . listConnections, connectionlnfo isConnected.
listConnections
listConnections ,
. listConnections,
:
sphere -n myspherel;
sphere -n mysphere2;
select myspherel mysphere2;
string $myConstraintNode[] - 'aimConstraint';
aimConstraint ( $myConstraintNode[0]), listConnections aimConstraint
- on - on; -s on listConnections , , - on ,
, ( ):
listConnections - on -p on $myConstraintNode[G];
// Result: (nysphere2_aimConstraint1.constraintftotateX mysphere2.rotateX
mysphere2_aimConstraint1.constraintRotateY mysphere2.rotateY
mysphere2_aimConstraint1.constraintRotateZ ..//
connectionlnfo
connectlnfo ,
, , . ,
listConnections, :
connectionlnfo -isSource
mysphere2_aimConstraint1.constraintRotateX;
// Result: 1 //
connectionlnfo -isDestiriation
154
i MEL Maya
ir,ysphere2_aimConstraint1. constraintRotateX;
// Result: 0 //
connectionlnfo -destinationFromSource
rcysphere2_airnConstraint1.constraintRotateX;
// Result: mysphere2'. rotateX //
connectlnfo , ;
c o n n e c t i o n l n f o -isLocked
mysphere2_aimConstraint"l. const raintRotateX:
// R e s u l t : 0 //
c o n n e c t l n f o , . comectionlnfo
MEL Command Reference.
isConnected
isConnected , .
, .
, - ,
connectionlnfo -isSource -isDestination.
mysphere2_aimConstraint1.constraintRotateX mysphere2. rotateX.
:
isConnected mysphere2_aimConstraint1 cor.straintRotateX mysphere2.RotateX;
// Result: 1 //
1 (),
mysphere2_aimConstraint1.constraintRotateX mysphere2.RotateX .
:
isConnected mysphere2.RotateX mysphere2_aimConstraint1.constra:.ntRotateX;
/,/ Result: 0 //
(), .
DG node reference
, ,
, MEL-
createNode, ,
is -si -showType ,
createNode.
, , ,
, . -
8. / MEL
155
eMEL
, , , Is. is ,
,
. ,
, .
select
.
, .
listRelatives ,
. listRelatives
, .
if then/else.
, ,
. , ,
.
, MEL (conditional operation),
, .
, MEL (loop operation), ,
, .
. 9.1 , .
if-else (switch statement)
. if-else ,
-
.
, , , ,
, .
9.
, ,
if,
.
157
, ,
if,
,
. 9.1.
(If (test) {-If () {)
, , , ,
.
. . 9.2, , for-in,
.
: if-else
. 9.1, ,
, - ,
.
Maya: if-else .
158
MEL Maya
,
for-in, ,
.
. 9.2.
(element in array - )
if-else , ,
, . if-then-else, Maya , , , , -
(. . 9.3). , ,
, ,
.
.
9.
,
else.
159
,
,
if, else.
. 9.3.
(if-else (If (test) {- If () {)
, , .
, ,
. ,
, (. . 9.4).
MEL Maya
160
i cjf variable?
,
. ,
.
. 9.4.
(Switch (variable) { - Switch (] {;
Case <value 1>: - Case < 1>\)
if-else
if-else , , , . $number, , ,
(<) , . , .
int $number = 14;
if ($number < 25}
print ($number + " ");
9.
161
Script Editor
Enter . , , 14 25. ,
, $number 25:
int Snumber = 27;
if (Snumber < 25)
{
print (Snumber + " ");
}
, , , -
,
, , () Edit (),
Paste () Edit ().
. ,
, . (, Snumber 25) , if .
, ,
:
int $number - 27;
if ($number < 25)
{
if else,
, Maya ,
. else, 27 25.
, , , , else else if
:
int Snumber = 27;
if ($number < 25)
{
6 - 1302
162
MEL Maya
, Snumber .
Snumber ,
. , .
else if, .
,
. else , , :
ant Snumber = 27;
if (Snumber < 23)
print (Snumber + " ");
>
}
else if (Snumber 25)
{
else
{
.^ _
163
if-else, ,
, , , Maya
.
,
if , ( ) :
if ($number > 10)
{
print " ! \"};
if. (Snumber > 20)
{
if,
( ) if.
if-else, , ,
, , $number 10, 20.
, , :
if (Snumber > TO)
{
164
^ ^ Maya
:
if (Snumber < 30)
{
if (Inurnber < 20)
print (" ");
if (Snumber == 13)
,
,
. Maya , , .
if -else ,
i f . >, , , , , ;
<, , ,
, , ; ==, , .
if-else, Maya , . Maya , (3 = = 4) (2 >
7), , . ,
1, , 0.
9.
165
, :
print (2 == 4);
print (3 > 2);
print (4.5 < 4 . 7 ) ;
if-else , if , 0, , 0, ,
if. ,
Script Editor ,
, Enter:
int $test =23;
if (Stest)
{
print " !\";
. :
$test = 0;
if (Stest)
{
print " !\";
,
6 ,
.
, if-then, . , ( !), ( [ | or).
not. , ! (3 < 4) , . not, if ,
0, ,
- . :
Stest = 0;
if (! Stest)
{
print " !\";
166
MEL Maya
. or , :
if ((3 < 4) || (3 < 5))
,
6.
switch , , ,
. , ,
$number, 1,2,3 - :
switch ($number)
{
case 1:
print " !\";
break;
case 2:
print " !\";
break;
case 3:
print " !\";
break;
default:
print " , !\";
break;
9.
167
switch
Snumber. 1, ( case 1),
2, ( case 2), 3,
( case 3). $number - 1 , 2 , 3,
, -27, switch case, default,
, , d e f a u l t .
if-else, switch, ,
. ,
switch, case ( default) ,
break.
switch
break. :
switch (Snumber)
{
case 1:
print " !\";
2:
print " !\";
break;
case 3:
print " ! \";
break;
default:
print " , !\";
break;
I
s w i t c h b r e a k case 1.
$number 1 switch,
, .
, Snumber 1, !,
!. switch , break
, , case 1 break,
2. . , , , ,
.
168
MEL Maya
- ,
. , MEL, while, for-in for.
while , - .
for-in ,
, , .
for , , , -
, , .
.
while
{
$test_int -
$test_int * 3;
9.
$test_int =
169
$test_int / 3;
}'
$test_int 100,
, Maya ( Ctrl-Alt-Delete Windows, Cmd-Option-Esc
Macintosh Ctrl-C , Maya Linux Irix).
, while , , ,
for-in
for-in , - . , , :
Is -si
Script Editor Enter .
Is -si ,
. , ,
Is -si for-in :
s t r i n g $selectedList[] = 'Is -;
string $currentObject;
for (ScurrentObject in SselectedList)
{
print (" " + ScurrentObject + "\n");
>
for-in ,
SselectedList, ScurentObject.
for-in ,
while, .
,
. .
/or
f o r ,
for-in. for , , , . ,
, , .
170
MEL Maya
f o r for,
:
for (Jcounter = 1; $counter < 100; $counter++)
>
<>
{
<>
9.
171
, ,
100:
for (Scounter = 1; $counter <= 100; $counter++)
<>
, .
0 99, 1 100.
, , , .
f o r ,
Enter :
int Scounter;
for (Scounter = 0; Scounter < 100; $counter++)
{
print (Scounter + "/n"};
}
, 0 99!
MEL
if-else , ,
.
switch , , .
while , ,
, .
for-in ,
, , ,
Is -si.
f o r ,
,
.
10
(top-down design).
MEL .
, , ,
(recursion).
. MEL ,
Maya , ,
, .
, ,
, MEL, (top-down design). , ,
, ,
, .
,
, .
.
MEL-,
.
10.
173
,
. , , ,
Maya, .
1:
, ,
, . ,
,
. .
:
. . :
, , .
.
:
, .
, .
, .
, , ,
.
, ? ? ,
, ? ?
,
, , , -,
,
, ,
.
,
.
. ,
, . , ,
. ,
.
174
MEL Maya
. ?: :
, .
1. ,
.
2. , .
3. , , .
4. .
, .
1. , .
2. .
3. 10 .
) , .
) , .
, .
1. .
2. , , .
3. .
4. ,
5. .
6. .
7. , , .
,
'. ,
, .
, , .
-
, . , , , , ,
. ,
, , , ,
10.
175
,
.
MEL-. , , , MEL
.
?
(procedure) (function) MEL- , . ( )
MEL-, ,
,
.
,
, .
(return value) . , , , .
,
, (argument). ,
, MEL-,
, , .
-, MEL-.
. , Maya
, , MEL-
Maya, ,
MEL ( ,
, Maya).
. MEL-, , , - , , ,
.
. , , .
, Maya,
, .
Maya , , (
) ,
176
MEL
Maya
( ) MEL- , Maya
.
() .
, , ,
.
, print_hello(),
! .
Script Editor Enter :
print_hello()
{
print " !\";
}
, ,
( , ) . print_hello( ) , , :
p r i n t _ h e l l o ( );
Enter.
, , . ,
, . ,
, +
. , ,
, ,
\.
hello_name(string $name)
{
print ("" + $name +
hello_name ("");
hello_name ("");
$name , .
, ,
, . , , .
, , , :
10.
177
178
MEL Maya
, , - hello^name , . ? Maya ,
(, , )
, :
4096!
; !
2;
, .
, , .
:
, .
, . , , , ,
,
, . ,
, , NURBS,
, .
, :
- ,
.
.
.
,
.
, .
.
.
, ,
MEL-. sphere ,
10.
179
-name, ,
, . , $mySptiere, X , :
string $my$phere = "sphere"!";
sphere -name SmySphere;
move 5 0 0 ;
sphere!, - ,
spherel (,
sphere, , Maya
).
MEL- , .
() ( )
X, Y Z:
proc makeSphere (string $sphereName, float $xval,
{
sphere -name SsphereName;
Script Editor
Enter .
, , . , , z . ,
:
rnakeSphere ("myNewSphere", 3, 3, 3);
myNewSphere , .
, MEL. , ,
, - Show All Commands
.
Maya MEL Command Reference,
, .
, -
MEL Command Reference .
:
spaceLocator -name "myNewSphereLocator";
geometryConstraint "myNewSphere" "myNewSphereLocator";
aimConstraint "myNewSphere" "myNewSphereLocator";
ISO
MEL Maya
, . <HMa>Locator,
<> - , .
,
, , ,
, JgeometryName, :
string SlocatorName - (SgeometryName + " L o c a t o r " ) ;
,
:
proc makeConstrainedLocator (string SgeometryName)
string SlocatorName - (SgeometryName + "Locator");
spaceLocator -name SlocatorName;
geometryConstraint SgeometryName SlocatorName;
aimConstraint SgeometryName SlocatorName,
Script Editor Enter
.
:
makeSphere ("spherel", 4, , );
makeConst rainedLocator ("spherel");
makeSphere ("sphere2", 0, 4, 0);
makeConstrainedLocator ("sphere2");
makeSphere ("sphereS", 0, 0, 4);
makeConstrainedLocator ("sphereS");
, :
proc makeSphere (string $sphereName, float $xval, float $yval, float Szval)
proc makeConstrainedLocator (string $geometryName)
{
string SlocatorName = (SgeometryName + "Locator");
spaceLocator -name $1ocatorName;
geometryConstraint SgeometryName SlocatorName;
aimConstraint SgeometryName SlocatorName;
10.
181
makeSphere ("sphere!", 4, , );
makeConstrainsdLocator ("spherel");
makeSphere ("sphere?", 0, 4, 0);
makeConstrained Locator ("sphere2");
makeSphere ("sphereS". 0, 0, 4);
makeConstrainedLocator ("sphereS");
, , .
, , .
(
makeSphere makeConstrainedLocator) , .
, , ,
, .
, , -
. (recursion)
, .
,
, ,
Maya .
Maya 4.0 ,
, ,
Maya (, ,
!):
test )
{
test();
}
, ( )
, Maya , ,
Script Editor
Enter :
test{);
182
MEL Maya
,
, ,
. , ,
.
3'
, ,
.
(. . 10.1).
Rotation angle
. 10.1.
(Rotation angle - )
, , ,
:
1. , , , , 1.
2. .
3. , , .
4. (, 95%).
5. X 1 + , (
,
,
).
10.
183
6. ,
.
7. , 2, . , ,
, , , , ,
, 0,1 .
, , , ,
, , . ,
, -
. , , , ,
,
, , . , ,
. ,
. .
,
, , 0,
, 1, (
).
:
makeAn.tenna (string $parentSphere, float Sparentfiadius, float $rotAngle, float
Sscale, int SfirstSphere)
{
<>
, , . -,
, .
.
,
.
, ,
SfirstSphere, SparentSphereName
SparentRadius . SrotAngle ,
.
, if (<>) , ,
<> 0, , <> 0.
:
184
MEL Maya
if (SfirstSpnere)
<
.
, ,
JfirstSphere 0.
, duplicate.
duplicate ,
, .
$duplicateName[].
, $duplicateName[0], .
6 .
select - SparentSphereName;
string $duplicateName[] = 'duplicate';
$duplicateName[0],
$childSphereName.
$childSphere , :
string $childSphereName= $duplicateName[0];
select -cl; //
select SchildSphereName JiparentSphereName; // ,
7/
parent;
select SchildSphereName;
, ,
$scale*$parentRadius. SchildSize:
float SchildSize = Sscale * SparentRadius;
scale $scale
$scale
$scale;
, $scale ,
, .
, ,
X. nrov
10,
185
, , ,
. ,
,
, .
move -localSpace (1 + $scale) 0 0;
, X
:
select SparentSphereName;
rotate 0 0 SrotationAngle;
.
, . .
if ($childSize > 0.05)
{
,
. ,
, , ,
$firstSphere 0.
:
makeAntenna (string SparentSphere, float $parentRadius, float SrotAngle, float
$scale, int SfirstSphere)
{
if (SfirstSphere)
{
sphere -name SparentSphereName;
scale SparentRadius SparentRadius SparentRadius;
}
select -r SparentSphereName;
string $dupiicateName[] = 'duplicate';
string $childSphereNane= $duplicateName[0];
select -cl; //
select SchildSphereName SparentSphereName; //
// ,
MEL Maya
186
I/
//
parent;
select $childSphereName;
float SchildSize = $scale * SparentRadius;
scale Sscale
Sscale
$scale;
move -localSpace (1 + Sscale) 0 0;
select SparentSphereName;
rotate 0 0 $rotationAngle; // Z,
// X
if (SchildSize > 0 , 0 5 )
{
, Enter , (. . 10.2). , .
makeAntenna ("firstSphere", 1, 20, 0.75, 1);
. 10.2.
10.
187
,
MEL
,
,
,
,
.
: -, ,
, -, ,
.
- , , .
, , , .
11
,
:
.
.
.
, .
Maya
, . ,
, Maya ,
, .
, MEL-,
,
, ,
.
:
, , , , , , .
, .
, .
, , ,
,
, - . -
11, ,
3.89
, ,
MEL- , - Maya .
, ,
, , .
,
.
, ,
:
,
,
, , .
, . , :
Myfunction
__
a_proc_nanie2
_myfunction
:
1st_function
rry$f unction
,
, . -, , . ,
.
, ,
, ,
, .
-, , , , ,
, . ,
rename, -
190
^ Maya
, , , rename_geom,
renamejoint.
, ,
, ,
. , Bozz Studios
rename BOZZ_rename_ioint BOZZ_rename_geom.
-, , , , highend3d.com. ,
, , ,
Web- ,
.
-,
, , ,
- .
, ,
, , , , - .
($), ,
, , .
$ , , $ . :
SMyvar
$a_var_narce
$a_var_name2
$_myvar
- :
$1st_variable
$my[variable
a bad variable
11. ,
191
,
.
. - ?
select $bozo_left_hand_geom_node_name;
select Sblhgnn;
:
, ,
, .
, , -
, .
, , ,
,
,
.
, , , ,
:
global string $particle_node;
- , ,
, !
, ( )
.
global string $particle_node;
:
global string $BQZZ_particle_node;
, . ,
.
192
MEL Maya
, ,
. , :
1. NURBS-, .
2. NURBS-, .
3. Move .
4. .
5. , - .
6. Outliner, Window > Outliner.
7. nurbsSpherel sphere.
8. nurbsSphere2 sphere.
sphere.
Script Editor :
select - "sphere";
:
// Error: More than one object matches name: sphere //
, , ,
, , Maya
, .
' , (transform path). :
1 sphere , .
| s p h e r e | s p h e r e , .
(, ,
, ),
Maya, . |, , | sphere, sphere, ().
, , |, . , |node1|node2,
node2, nodel,
/.
, ,
. , -
11. ,
193
, , Outliner (, . 11.1).
sphere, ,
| sphere |sphere2] sphere.
, , ,
.
sphere2 ,
sphere, , sphere2|sphere. sphers2 , Maya ,
sphere.
Display Show Help
" ii
sphere2
sphere
delauHightSef
delauJObjeclSel
. 11.1.
|sphere|sphere2|sphere
,
Maya. MEL-
rename. rename :
rename "|spherefsphere2|sphere" "mysphere";
rename sphere, ,
mysphere . ,
- , rename
. , rename
,
.
, Maya
, .
7 -1302
194
MEL Maya
, .
, . nurbsCylinder23 j o i n t l 4 ,
, left_arm_geom left_arm_joint, .
, ,
- ,
.
,
, . ,
, ,
. , ,
.
1:
,
. , bill j o i n t i ,
b i l l j o i n t l , , , , ,
.
,
,
.
1. , .
2. Outliner / (. . 11.2).
3. ,
Enter :
global proc add_prefix_to_selection(string $prefix){
string $nodes[] = 'is -si -dag' ;
for ($current_name in $nodes) {
rename -ignoreShape $current_name
(Sprefix + "_" +Scurrent_nans);
11. ,
195
4. , nurbsSpherel :
add_prefix_to_selection("spheres");
Enter .
nurbs Sphere?
nurbsSphere4
nubsSphereS
defaultLighlSe*
defaultObjeclSel
. 11.2.
, spheres,-
, : -, , , -, .
is,
MEL Command Reference.
, MEL Command Reference rename,
. .
-, , ,
MEL-, , MEL-,
, . , :
global proc add_prefix_to_selection(string $ p r e f i x ) {
, -
, . Is ,
. -si ( -selection), -
196
MEL Maya
Is , -dag ( -dagdbjects), Is
.
Is -si -dag , , . , nurbsSpherel. Is :
string $nodes[] = 'is -si -dag';
for-in ,
:
for ($CLjrrent_name in $nodes) {
rename -ignoreShape $current_name
, Is,
MEL- rename . ignoreSphape
rename, , , . , ,
, is, ,
,
, .
2:
. sphere., . :
global proc change_selection_prefix (string $newprefix){
string $nodes[] = *ls -si -dag'; //
//
for ($current_name in $nodes) {
//
//
string $parts_list[]; //
II ,
//
//
int $num_parts = 'tokenize $current_name ".." $parts_list";
if ($num_parts > 1) ( // , ,
//
11.
^^
197
//
string $old_prefix = $parts_list[0]; //
//
string $no_prefix_name = $parts_list[1]: //
// // //
for ($count = 2; $count < $num_parts; Scount--) {
//
$no_prefix_name = ($no_prefix_name + "_"
+ $parts_list[$count]);
}
//
:
change_selection_prefix ("spheresyak")
,
. Is
, , rename.
tokenize. ,
.
, , :
spheres_test_node_name
tokenize ,
( _ ). ,
Script Editor:
print $resulting_parts[0];
p r i n t $resulting_parts[1];
print $resulting_parts[2];
print $resulting_parts[3];
, , Is
for-in . ,
198
MEL Maya
, tokenize , :
int $num_parts = 'tokenize $current_name "_" $parts_list';
//
tokenize $current_name
, $parts_list, ,
, .
$num_parts 1, , .
, . , if:
if ( $ n u r n _ p a r t s > 1) { // ,
, tokenize , ,
,
. spheres_test_node_name ,
tokenize ( $parts_list[0]), - spheres, ,
test, node name .
spheres_test_node_name,
o t h e r p r e f i x _ t e s t _ n o d e _ n a m e ,
. t o k e n i z e ,
.
. , Perl, ,
MEL- - match, gmatch substitute, -
. .
':
string $old_prefix - $parts_list[0]; //
string $no_prefix_name - $parts_Hst[l]; //
//
11. ,
199
, , $no_prefix_name. ,
$no_pref ix^name test, test node, test_node_name.
, rename, (
$current_name) ( Snewprefix, , $no_prefix_name).
rename -ignoreShape ($current_name) (Snewprefix + "_" + $no_prefix_name);
. ,
, , , .
tokenize _ -, , ,
match.
?
- , Maya
,
. , , , .
, . , , my_namespace:, my_namespace:
< (:),
Maya .
. ,
, ,
, - . ,
my_namespace:your_namespace:, your_namespace. my_namespace.
,
,
, (:).
| s p h e r e | s p h e r e 2 | s p h e r e ,
, : | sphere |spfiere2| sphere.
, , J,
, , .
. ,
,
, Maya ,
.
(:), .
MEL Maya
200
Maya, ,
,
.
, File > Import ... > ( > ... > ),
, . 11.3.
; Import Options
*' ^- L,
Group * {!
Use Namespaces "
Name daih options:
Reso1
^ j clashing noc
Fife Type
I Best Gue:
Apply
. 11.3.
, Use Namespaces (
). Maya,
, , . , , , test.,
test ( Create
Reference.., Use Namespaces).
, ,
. , rbsSphere1,
test:nurbsSpherel.
, Maya
, ,
test_<HHH>.
, , ,
, , . , ,
, . ,
, getAttr setAttr, , Maya ,
.
11. ,
201
nameSpacelnfo Maya :
namespacelnfo -currentNamespace.
,
, namespacelnfo -parent.
,
, ,
namespacelnfo -listNamespace.
, , namespacelnfo -HstOnlyNamespaces.
,
, namespacelnfo -listOnlyDependencyNodes.
,
MEL-
,
namespace.
, ,
. ,
,
.
22
MEL ^
, , , ,
. ,
^
, .
, ,
,
.
.,
,
, ,
.
, , , , , ,
. , , .
,
.
,
,
, , , .
, , .
, ,
, .
-
.
, ,
. ,
, Maya , ,
.
12
MEL
:
Maya .
,
.
1984-, Apple Macintosh , , , ,
, , , ,
. ,
- , ,
, , , ,
, , , , .
, :
, ?
,
, ?
204
MEL Maya
,
?
, , ?
. , MEL- . , MEL-
Maya, , , .
May MEL-.
,
, Maya, ,
.
,
, .
i:
, Maya, ,
, Move Edit > Parent, :
-, .
- (, Move,
) ,
.
Maya, Sphere,
, - . , ,
MEL , , - ,
.
, ,
- ,
, ,
- .
12. MEL
205
2i
.
-, , .
.
, , ,
(. . 12.1).
, , ,
Accept () , .
Maya , , , ,
, ,
(). .
1 Add Attribute; j nurbrtiihere I
Help.
New 1 Parifcle -Jiol j
ASribule Name |
(5 Make Attribute
JData Type
i Vector
j (f Float
~ Inlegei
'
Boolea-,
Attribute Type
i G Scab,
.', :-,.,
-1!-.-
Cancel
. 12.1.
.
(...).
206
MEL Maya
3'
, , : .
, , , ,
.
Add Attribute ( ), . 12.1,
. Add
(), Add ,
, , .
4*
, ,
. MEL
, , ,
MEL-
, Maya (API -- Application
Programming Interface) C++.
, Maya API Reference,
Maya.
,
,
MEL- , , ,
, .
,
, , ,
.
, .
:
, , , ?
? ,
?
, , ?
, , , ,
12. MEL
207
, ? , ? ( , ).
?
, , ,
.
, ,
.
, , , ,
, :
1. ,
.
2. , , , . ,
, I.
3. , , . MEL-.
, , .
, -.
4. , ,
, . , , -
. , , .
, .
5. , Maya.
6. Maya
.
. ,
.
28
MEL Maya
.
, , . , , , , .
, .
, , , ,
. ,
, , ,
, ,
.
.
,
, ,
, .
, , .
, . , , , ,
. , ,
,
, .
, .
,
, . . , ,
, . 14 .
.
,
. , , ,
, ,
, .
12. MEL
29
,
(layout).
, , , . 14 ,
, (. . 12.2).
. 12.2.
, Maya.
,
MEL-.
-
, .
, ,
, Data Type, . 12.2.
( ) ,
, .
210
MEL Maya
,
, , ( ) .
,
. ,
, , ,
.
. , ( . 12.2 ). , , , , ,
.
, , , , . ? ?
MEL
Maya. ,
,
Maya.
, . ?
? , ?
?
, ,
, . - MEL, ,
.
, , ,
. - ,
, .
13
MEL
:
,
.
, .
warning error , .
, , , .
12 ,
. , , - . (, , ), . ,
, , ,
, .
, , .
212
MEL Maya
, . , ,
, :
, .
, , .
; .
, - .
, , ,
, , ,
, .
Maya MEL- ,
,
, , .
.
, 14 ,
.
: .
, ,
, .
, (,
. .), , , , Maya
, - .
Maya
, , . , ,
,
243.4 ,
0.0 0.1.
13. MEL
, , , ,
.
,
Maya , Maya
, - ,
Maya , , ,
, .
,
. :
,
.
, , (,
, ,
). , , ,
( , -).
, , .
, , , ,
.
, , (
) , ,
.
, , , , , :
', ,
( , ) .
, ,
.
,
, , ,
. ,
, ,
, , ,
, , .
, .
214
8_ MEL Maya
, MEL,
, , .
( ).
,
, - .
MEL, . ,
, .
confirmDialog
, MEL- confirmDialog, ,
.
, Default button ( ),
( , Windows Linux, ,
Mac OS). Default button Enter.
Cancel button ( ),
Cancel button Esc, Cancel
button .
, '
confirmDialog , . , confirmDialog
dismiss. , , confirmDialog .
, :
string Sretu'rnVal = 'confirmDialog
-title "Identify and Destroy All Termite Species! "
-message "Are you sure?"
-button "Yes"
-button "No"
-button "I'm not sure"
-button "Maybe"
-defaultButton "Yes"
-cancelButton "I'm not sure"
-dismissString "Oops"';
13. MEL
215
c o n f i r m D i a l o g ,
, . 13.1. ,
SreturnVal. Enter Yes, Esc
' m not sure. Oops SreturnVal.
Identify and Destroy Termite
Are jjou suie?
Ho
Maybe
. 13.1. , confirmDialog
confirmDialog, switch if-else , ,
.
, c o n f i r m D i a l o g
, , :
c o n f i r m D i a l o g -title " W a r n i n g "
-message " E v e r y t h i n g is about to be deleted"
-button "OK";
, ,
. , . 13.2. ,
, Cancel, , .
Wanting
Everything Is about to be deleted
. 13.2. , confirmDialog
,
MEL- warning, . , , , , .
216
MEL Maya
promptDialog
promptDialog confirmDialog, , .
promptDialog , ,
, .
confirmDialog, promptDialog , , . ,
, promptDialog ,
.
, ,
.
:
string $buttonResponse = 'promptDialog -title "Make Sphere"
-message
"Name for your new sphere?"
-button "OK"
-button "Cancel"
-defaultButton "OK"';
string StextResponse = 'promptDialog -q';
promptDialog (,
, ,
, ), , ,
, 13.3.
(, Cancel, , ,
JbuttonResponse. promptDialog ,
.
StextResponse.
Make Sphere
Name for your new sphere?
. 13.3. , promptDialog
13. MEL
217
Sbutton Response, , (
- ) , .
(, Cancel),
, $textResponse,
.
-title, -message, - b u t t o n , -defaultButton, -cancelButtonH -dismissString
promptDialog, confirmDialog. , -text " s t r i n g " ,
, -scrollableField true,
, .
fileDialog
,
, MEL fileDialog. confirmDialog promptDialog, fileDialog
.
-directoryMask, , , .
;
string SfilePath = ' f i l e D i a l o g -directoryMask " * . m a " ' ;
, ,
,, Maya Ascii. ,
SfilePath.
, fileDialog, , .
Warning Error
, , - . warning ,
, ,
. . warning
print.
:
warning , ;
218
MEL Maya
, ,
, , :
// Warning: ", " /./
-showLineNumber true ,
, ,
. mel.
, ,
e r r o r :
e r r o r " ;
:
/7 E r r o r : //
.
error, , ,
(, ,
- ), E r r o r .
-showLineNumber true Error , W a r n i n g ,
, , . mel.
,
, , .
Maya .
, , ,
, , , .
, , Maya
, ,
. , , .
, Perl,
,
, . , ,
.
MEL , , match. ,
, ,
match .
13, MEL
219
, ,
. , ,
,
.
, ,
,
,
,
. match , , .
,
.
, match ,
. , match . Script Editor:
match "blah" "abcdblahhaha"
,
(blah):
// Result: blah //
match, , , , :
match "blah" "abcdefghi"
, "blah" , , "abcdefghi".
match,
, , , .
, , ,
.
, ,
, , , ,
"blah" (, !).
,int Skeepgoing = 1;
w h i l e {Skeepgoing) {
promptDialog -message
"type a string containing the word blah please!";
string JtypedString = 'promptDialog - q ' ;
String $matches_blah = 'match "blah" StypedString';
220
MEL Maya
if ($found_match) {
Skeepgoing = 0;
}
\
print "Found blahf\n";
match
"blah" strcmp, ,
, .
, strcmp 0, . ,
"blah" "blah",
match ( ), "bla.fi"
( ). , strcmp, ,
.
. +
, , :
match "(blah)+" " a b c d b l a h b l a h b l a h e f g " ;
// R e s u l t : blahblahblah //
- ,
. :
+ 1
(2, 4} .
Maya ?,
, {, 1),
0, 1 .
Maya 3 4,
. , (0, 1}.
, , .
(character class). ,
a, b , [abc]. , , , , , ,
, , , , :
[abc]+
13. MEL
221_
, .
, ,
;
[A-Z]
,
, (.), , , , $, . ', , ,
.
, intFieldGrp (
14). , prompt
, ,
.
,
, :
global int validlnteger (string StestString) {
s t r i n g SmatchingPart = 'match "~[+\-]{0,1}[0-9J+$" $ t e s t S t r i n g ' ;
int $goodMatch = ! ' s t r c m p $matchingPart StestString';
// , , strcmp
return JgoodMatch;
}
, "[+
-] {0,1} [0-9]+$" ( ), ( $). (+), (-), (
{0,1}), , , 0 9
( [0-9]+).
strcmp, , , , (, , , ,
, , , .
, ).
:
validrnteger("123s");
// Result: 0 //
validlnteger("-125");
// Result: 1 //
222
MEL
Maya
,
0, , , , 1,
.
, , .
, fioatFieldGrp (
14). , prompt , , .
, ,
:
+5, -3, +25
, , , - :
23., 245.32
, ,
, , :
-23.3424, 1.0-34, 3.4+24
,
. - ( -
):
! , :
global proc int validFloat (string $testString) {
string SmatchingPart =- 'match
StestString';
int SgoodMatch = ! 'strcmp $matchingPart StestString';
// , , strcmp
return SgoodMatch;
, ,
, .
13. MEL _
223
( )
, ,
, .
,
.
, ( ) ($)
. , , [a-zA-Z]
,
([0-9a-zA-Z]*). , :
global proc int validObjectName (string StesiString) {
string SmatchingPart = 'match "~[a-zA-Z][0-9a-zA-ZJ*$"
StestString';
int SgoodMatch - ! 'strcmp $matchingPart StestString ' ;
// , , strcmp
return SgoodMatch;
i:
, , X . ,
.
, makeSpheres, :
,
(, sphere, sphere! , sphere2,
spheres . .).
, , , , , .
, .
, ,
, , ,
.
224
MEI-
Maya
, validObjectName, validlnteger
promptDialog. , , ,
.
// -,
//
int validQbjectName (string StestString) {
string SmatchingPart = 'match ""[a-zA-Z][0-9a-zA-Z_]*$"
StestString';
int SgoodMatch = ! 'strcmp $matchingPart StestString';
// , , strcmp
return SgoodMatch;
}
global makeSpheresUI()
{
//
string SgetBaseNameButton = 'promptDialog -title "makeSpheres
-message " ?"
-text "mySphere" ' ;
string $baseName = 'promptDialog -q';
if (! validObjectName($haseName)) {
// ,
confirmDialog -title "Error"
13, MEL
225
//
string SgetSphereNumButton = 'promptDialog -title "nakeSpheres"
-message " ?"
-text "5"';
string SnumSpheresString - 'promptDialog - q ' ;
if (! validInteger($numSpheresString)) {
// ,
//
// ,
//
int SnumSpheres = SnumSpfieresString;
// , ,
// :
if (SnumSpheres <= 0) {
confirmDialog -title "Error"
-message " !"
-button "OK";
error " !";
}
// ,
makeSpneres($baseName, SnumSpheres);
}
, makeSpheres Script Editor:
makeSpheresO;
, ,
.
8 -1302
226
MEL
Maya
:
int validObjectName (string $test3tring) {
string SmatchingPart - 'match ""[a-zA-Z][0-9a-zA-Z_]*$"
StestString';
int $goodMatch = ' 'strcmp SrnatchingPart $testString' ;
// , , strcmp
return SgoodMatch;
i -
{
int $COunt = 0;
makeSpheresUI:
global proc makeSpheresUIQ
{
makeSpheresUI ,
.
13. MEL
227
makeSpheresUI :
string SgetBaseNameButton = 'promptDialog -title "makeSpheres"
-message " ?"
-text "mySphere"';
string SbaseName - 'promptDialog -q';
, promptDialog
,
SbaseName.
.
, , ,
, , , E r r o r :
if (! v a l i d O b j e c t N a m e ( $ b a s e N a m e } ) {
// , ,
confirmDialog -title " E r r o r "
-message " !"
-button "OK";'
error " !";
}
, , :
//
string SgetSphereNumButton = ' p r o m p t D i a l o g -title "makeSpheres"
-message " ?"
-text " 5 " 1 ;
string SnumSpheresString = 'promptDialog - q ' ;
if (! validInteger($numSpheresString)} {
// , ,
//
confirmDialog -title "Error"
-message " !"
-button "OK";
error " !";
}
// ,
//
int SnurnSpheres = JnumSpheresString;
228
MEL Maya
, , $numSpheres
, , . -
, .
// , ,
// nf.
if (SnumSpheres <= 0) {
confirmDialog -title "Error"
-message " !"
-button " O K " ;
error " !";
, makeSpheresUl makeSpheres,
:
// ,
makeSpheres(SbaseName, $numSpheres):
.
, , ,
. , ,
sphere, , .
,
, .
, , , .
, , , , . 14
.
MEL
,
, c o n f i r n D i a l o g promptDialog
c o n f i r m D i a l o g :
, ,
, .
,
13, MEL
229
, , ,
.
.
, ,
, , ,
.
,
.
14
,
.
, , , .
,
.
,
, 13, ,
, .
, .
, ,
.
, , :
, , ( Cancel), , ,
, .
14.
231
,
, .
MEL- ,
, Maya
.
: , , . ,
, , :
.
, .
.
.
,
.
.
,
.
,
.
Close,
.
.
Yes No ,
.
.
.
,
,
, , ,
.
,
.
MEL-,
.
. ,
MEL Maya
232
, ,
( )
.
:
. (window), , . (layout), ,
. , (control), (group)
(collection), . ,
Maya.
. 14.1 ,
. , , , ,
, ,
. .
| Window 1
Menu 1 Menu 2
^_j
i Layout 1
l&eckbtt jj
Checkbox 2
Checks 3
ame Layout 2
Radio Button Group <~ Radio 1
'Layout 3
--r-r
Cheskhon4
Radio2
i* Fadc3
TeU! |Testiigl"2:
12 |T!ing45E
' ' Button 1
Button 2
Button 4
. 14.1.
,
. rowLayouts, columnUyouts
rowColumnLayouts, .
f rameLayout ,
, , . frameLayout rowLayout,
columnLayout rowColumnLayout. , . 14.2,
f rameLayout.
"
ane Layout 2
Radio Button Group
. 14.2. f rameLayout,
14.
'
233
. 14.3, tabLayout .
,
.
J T a b 2 J
(
"""Button"!
. 14.3.
i|
Button 2
, tabLayout
,
, .
,
. ,
, . ,
.
MEL ,
(. . 14.4).
, MEL ,
.
Text2 JTesting456
Radio Button Group
Radio 1
Radb2
RadioS
, MEL , . , .
, , r a d i o B u t t o n G r p
, ,
. ,
, ,
radioButtonGrp, .
, r a d i o B u t t o n G r p . , ,
radioButtonGrp .
234
MEL Maya
, , , , .
, - , , ,
.
1:
, , -
, , , ,
. 14.1. ,
.
. Maya , frameLayout
collapsible.
. .. ' '
." v ~~^
//
string $window_name = 'window -title "Window 1"
-menuBar true
-widthHeight 483 203';
// , ,
// , ,
// showWindow. .
// .
menu -label "Menu 1";
menultem -label "Menu Item V;
menultem -label "Menu Item 2";
menu -label "Menu 2";
menultem -label "Menu Item 3";
menultem -label "Menu Item 4";
columnLayout;
frameLayout -collapsable true -label "Frame Layout 1" -width 475;
rowColumnLayout -no 4;
checkBox -label "Checkbox 1";
checkBox -label "Checkbox 2";
checkBox -label "Checkbox 3";
14.
235
, ,
. , MEL,
, ,
, , .
, ,
, ,
showWindow, window,
setParent... setParent... Maya
, ,
.
, .
236
MEL Maya
window,
, showWindow .
, ,
:
string $w'indow^name = 'window -title "Window 1"
-menuBar true
-widthHeight 483 203';
showWindow $window_name;
- window showWindow.
, , , window,
showWindow. ,
window window
showWindow, , .
, :
//
menu -label "Menu 1";
rnenultem -label "Menu Item 1";
nenultem -label "Menu Item 2";
menu -label "Menu 2";
menultem -label "Menu Item 3";
menultern -label "Menu Item 4";
, , window showWindow
:
string $window_name - 'window -title "Window 1"
-menuBar true
-widthHeight 483 203';
//
menu -label "Menu 1";
menultem -label "Menu Item 1";
menultem -label "Menu Item 2";
menu -label "Menu 2";
menultem -label "Menu Item 3";
menultem -label "Menu Item 4";
showWindow Swindow^name;
. 14.5.
14.
Mehg i
237
Menu 2
. 14.5. ,
, , , :
columnLayout;
, MEL , . window ,
showWindow , ,
, .
,
.
column Layout showWindow :
frameLayout -collapsable true -label "Frame Layout 1" -width 4 7 5 ;
rowColumnLayout -nc 4;
checkBox -label "Checkbox 1";
checkBox -label "Checkbox 2";
checkBox -label "Checkbox 3";
checkBox -label "Checkbox 4";
,
, ,
. , f r a m e L a y o u t
, , rowColumnLayout
rowColumnLayout frameLayout.
, frame-Layout.
. ,
. , , , .
, , , MEL
.
238
MEL Maya
rowColumnLayout .
,
rowLayout columnLayout, rowColumnLayout ,
, -,
.
rowColumnLayout , , -label. ,
.
.
columnLayout, f rameLayout, , rowColumnLayout, ,
showWindow.
string $window^name = 'window -title "Window 1"
-menuBar true
-widthHeight 483 2 0 3 ' ;
(I
menu -label "Menu 1";
menultem -label "Menu Item 1";
menultem -label "Menu Item 2";
menu -label "Menu 2";
menultem -label "Menu Item 3";
menultem -label "Menu Item 4";
columnLayout;
frameLayout -collapsable true -label "Frame Layout 1" -width 475;
rowColumnLayout -nc 4;
checkBox -label "Checkbox 1";
checkBox -label "Checkbox 2";
checkBox -label "Checkbox 3";
checkBox -label "Checkbox 4";
showWindow $window_name;
. 14.6. , .
.JfiJij
Checkbox 3
Chertow
. 14.6. ,
14.
239
rowColumnLayout,
MEL, columnLayout, .
setParent..., Maya
, :
SetParent...; // frameLayout
SetParent...; // columnLayout
columnLayout, rowColumnLayout f rameLayout. ,
columnLayout rowColumnLayout, ,
, .
, columnLayout,
f rameLayout. , f rameLayout .
frameLayout -collapsable true -label "Frame Layout 2" -width 475;
radioButtonGrp -numberOfRadioButtons 3
-label "Radio Button Group"
-labelArrayS "Radio 1" "Radio 2" "Radio 3" "Radio 4";
radioButtonGrp , , ,
. -numberOfRadioButtons , , -label , , -11
. , ,
, , -114.
radioButtonGrp,
MEL Command Reference.
:
string $window_name = 'window -title "Window 1"
-menuBar true
-widthHeight 433 203';
//
menu -label "Menu 1";
menultem -label "Menu Item 1";
menultern -label "Menu Item 2";
menu -label "Menu 2";
menultem -label "Menu Item 3";
menultem -label "Menu Item 4";
columnLayout;
frameLayout -collapsable true -label "Frame Layout 1"
-width 475;
MEL Maya
240
rowColumniayout _ n c 4;
checkBox -label "Checkbox 1";
checkBox -label "Checkbox 2";
checkBox -label "Checkbox 3";
checkBox -label "Checkbox 4";
setParent...; // framelayout
setParent...; // columnLayout
frameLayout -collapsable true -label "Frame Layout 2" -width 475;
radioButtonGrp -numberQfRadioButtons 3
-label "Radio Button Group"
-labelArrayS "Radio 1" "Radio 2" "Radio 3"
"Radio 4";
showWindow $window_name;
,
. 14.7.
______
.-'
[JFieme Layoul ?
Radio Gioup Radio !
. 14.7.
Checkbox^
Radio 2
Raifo 3
, f rameLayoui:
,
, . ,
- .
, -1> . , -select!
.
frameLayout,
textFieldGrp, :
SetParent...; // frameLayout
frameLayout -collapsable true -label "Frame Layout 3" -width 475;
columnLayout;
textFieldGrp -label "Text 1" -text "Testing 1 2 3";
textFieldGrp -label "Text 2" -text "Testing 4 5 6";
14.
241
, setParent...
frameLayout columnLayout, .
setParent..., frameLayout frameLayout, .
, textFieldGrp , columnLayout frameLayout.
textFieldGrp, ,
.
, .
rowColumnLayout, . ,
rowLayout, , rowColumnLayout, , , ,
, ,
.
setParent...;
// frameLayout
setParent...;
// columnLayout
rowColumnLayout -nc 4;
button
button
button
button
-label
-label
-label
-label
"Button
"Button
"Button
"Button
1";
2";
3";
4";
.
, .
,
, , , .
, ,
, 2.
Maya
. , ,
.
, MEL Command Reference, 1: Windowing ( :
) Controls: Buttons, Sliders, etc. ( ; , . .).
MEL Maya
Maya , .
MEL, , ,
.
MEL
. -command,
Maya, .
, , :
string SmyWindow = 'window';
rowLayout;
button -label "Make me a sphere" -command "sphere";
showVJindow SmyWindow;
. 14.8 . ,
, - , Maya
. ,
, Maya sphere .
-I.Qjxi
iMakeme a sphere!
. 14.8. ,
checkBox
(checkBox) , , ,
. ,
, . chackBox ,
, .
, , :
String SmyWindow = ' w i n d o w ' ;
rowLayout;
string $myCheckbox = 'checkBox -label "Truth or Dare:'";
showWindow SmyWindow;
,
$myCheckbox. MEL- , . 14.9.
14.
243
It ruth or Dare:!
. 14.9. ,
, .
, :
checkBox -q -v $myCheckbox;
1, , 0,
.
, , . -onCommand, offCommand -changeCommand. :
string $myWindow = 'window';
rowlayout;
, blah,
, .
floatFieldGrp
textFieldGrp, floatFieldGrp , . floatFieldGrp
, .
, floatFieldGrp,
:
string SmyWindow = 'window';
rowLayout;
MEL Maya
244
. 14.10. , floatFieldGrp
, , , . ,
(Script Editor):
f l o a t F i e l d G r p -q -value SmyFloatFielcGrp;
.
floatSliderGrp
floatSlidsrGrp , . , -field true,
,
, :
string SnyWindow - ' w i n d o w 1 ;
rowLayout;
string $myFloatSliderGrp = 'floatSliderGrp -min 0
-max
-label
"Gimme a number:"
-field t r u e ' ;
showWindow SmyWindow;
-min -max,
. floatSlidarGrp
-fieldMinValue -fieldMaxValue,
, (,
0 1,
10, -fieldMaxValue I.
,
). floatSliderGrp . 14.11.
Gimme a nutvbei: [
. 14.11. , floatSliderGrp
14.
245
floatsliderGrp , floatFieldGrp;
floatSlederGrp -q -value SmyFloatSliderGrp;
intFieldGrp
intFieldGrp , floatFieldGrp, ,
, .
floatFieldGrp, intFieldGrp
, , , ,
.
intSliderGrp
intSliderfirp . floatsliderGrp, ,
, .
textFieldButtonGrp
textFieldButtonGrp ,
. - , ,
, ,
textFieldButtonGrp. , , :
sphere -name 'textFieldButtonGrp -q -text SmyTextFieldButtonGrp')
textFieldButtonGrp -q -text , sphere .
, textFieldButtonGrp ,
:
string SmyWindow = 'window';
rowLayout;
string SmyTextFieldButtonGrp;
string $myButtonCoramand "sphere -name ('textFieldButtonGrp "+
"q -text SmyTextFieldButtonGrp.)":
SmyTextFieldButtonGrp = 'textFieldButtonGrp
-label "Sphere name:"
-text "Sphere"
-buttonLabel "Make Sphere"
-buttonCommand SmyButtonCommand';
showWindow $myWindow;
246
HMEL Maya
, 14.12 , .
Make Sphere, , .
. Sphere name:
. 14.12. , textFieldButtorGrp
textFieldGrp
textFieldGrp , intFieldGrp floatFieldGrp,
, . textFieldGrp
, ,
.
, textFieldGrp :
s t r i n g SmyWindow - ' w i n d o w ' ;
rowLayout;
$myTextGrp = 'textFieldGrp -label "Gimme some text:"
-text "OK, text 1 ";
showWindow $myWindow;
. 14.13 , . ,
:
textFieldGrp -q -text SrnyTextGrp;
11 windowl
Gimme some text JOK, lexl
. 14.13.
, textFieldGrp
, .
rctdioButtonGrp
, ,
radioButtonGrp, .
radioButtonGrp , :
string SmyWindow - 'window 1 ;
r
owLayout;
14.
247
, -select, , . ,
. 14.14.
dqjou leet? -.< IGoocj,
. 14.14.
Bad.
, radioButtonGrp
radioButtonGrp , ,
:
radioButtonGrp -q -select SnyRatiioButtonGrp;
, 1, -2.
, ,
, ,
.
, , ;
string SmyWindow - ' w i n d o w ' ;
columnLayout;
JmyRadioButtonGrp - 'radioButtonGrp -numberOfRadioButtons 2
-label "How do you feel''"
-labelArray2 "Good" "Bad"
-select 1';
$myRadioButtortGrp2 = 'radioButtonGrp -numberOfRadioButtons 2
-label ""
-labelArray2 "OK" "Don't Know"
-shareCollection $myRadioButtonGrp';
showWindow $myWindow;
radioButtonGrp, . 14.15.
. 14.15. radioButtonGrp
, ,
radioButtonGrp. , 0. , I 2 , .
248^
_1-___
, radioButtonGrp.
radioButton radioCollection.
radioButtonGrp .
MEL ,
. , -
.
, MEL,
MEL Command Reference . Ul: Windowing
Layouts: Organizing UI Components ,
.
columnLayout
column Layout .
:
string SmyWindow = 'window';
coluranLayout;
button -label "button";
button -label "button";
button -label "button";
button -label "button";
button -label "button";
button -label "button";
showWindow SmyWindow;
. 14.16 , .
14.
, 14.16.
249
, columnLayout
formLayout
formLayout , , ,
. f o r m L a y o u t .
, , ,
f o r m L a y o u t , MEL Command Reference,
, .
frameLayout
frameLayout , .
:
string SmyWincfow - 'window';
frameLayout -borderStyle "etchedln";
rowColumnLayout -nc 4;
Dutton -label "button";
button -label "button";
button -label "button";
button -label "button";
button -label "button";
button -label "button";
showWindow SmyWindow;
MEL Maya
250
. 14.17 , .
;
" - iPJ xi
liameLayouO
button
button.
button
button
. 14.17.
ballon
button
, f rameLayout
-collapsable.
rowColumnLayout
rowColumnLayout , , . frameLayout rowColumnLayout.
rowLayout
rowLayout , , , .
:
string SmyWindow = 'window';
rowLayout -nc 6;
button -label "button";
button -label "button";
button -label "button";
button -label "button";
button -label "button";
button -label "button";
showWindow $rnyWindow;
. 14.18 .
. 14.18. , rowLayout
rowLayout -
-numberOfColumns. , rowLayout
, .
14,
253.
2;
, , , , . , , -
, .
,
, .
, :
makePrimitive(int $type, float $x, float $y, float $z) {
// make Primitive
// Stype, 1 ,
//2 3 . X, // Z
switch {Stype) {
case 1 : sphere;
break;
case 2; cone;
break;
case 3: polyCube;
break;
default: error -showLineNumber true "Invalid object type";
break;
}
// ,
// , ,
// ,
// move
move $x $y $z;
(Script Editor),
Enter, , :
252
^ MEL Maya
14.
253
, makePrimitiveUI(} Enter.
-rtf true window.
, , . , , . 14.19.
mCreate Primitive
0.0
0.0
254
MEL Maya
,
, . ,
:
button -label "Sphere";
button -label "Cone";
button -label "Cube";
:
button -label "Sphere" -command "buttonAction(1, $positionGrp)";
button -label "Cone" -command "buttonAction(2, SpositionGrp)";
button -label "Cube" -command "buttonAction(3, $positioriGrp)";
, , :
makePrimitive(int $type, float $x. float $y, float $z) {
// makePrirriitive
// $type, 1 ,
// 2 3 . X, // Y Z
switch (Stype) {
case 1: sphere;
break;
case 2: cone;
break;
case 3: polyCube;
break;
,
, ,
,
move
move $x $y $z;
}
buttonAction (int SwhichButton, string SfloatFieldGrpName) {
14.
__
255
// , z
float $xval = 'floatFieldGrp -q -valuel SfloatFieldGrpName';
float $yval = 'floatFieldGrp -q -value2 SfloatFieldGrpName';
float $zval = 'floatFieldGrp -q -values $floatFieldGrpNaroe';
//
makePrimitive($whichButton, $xval, $yval, $zval);
global proc makePrimitiveUIO {
// positionGrp floatFieldGrp name
global string $positionGroup;
// makePrimitiveLJI
// makePrimitive
string $dialog8oxWindow = 'window -title "Create Primitive"
-rtf true' ;
columnLayout;
SpositionGroup = 'floatFieldGrp -numberOfFields 3';
rowLayout -nc 3;
button -label "Sphere" -command
"buttonAction(1, SpositionGroup)";
button -label "Cone" -command
"buttonAction(2, SpositionGroup)";
button -label "Cube" -command
"buttonAction(3, SpositionGroup)";
showWindow SdialogBoxWindow;
}
, , makePrimitiveUIO, Enter
.
,
, .
256
MEL Maya
MEL
, ,
.
, formLayout.
. ,
, .
.
Maya .
.
.
, ,
.
,
, , .
, .
MEL Command
Reference.
15
MEL-
:
Maya.
,
.
MEL- .
,
,
Maya,
, ,
. mel.
Save selected...( ) .mel.
source, .mel, . ,
source , (script path) Maya.
- , Maya MEL-,
.
Maya.
Maya,
Script Editor :
geteny "MAYA_SCRIPT_PATH";
( , Maya ):
9- 13112
258
MEL Maya
, , ,
.msl < ! ( < > -
).
,
. mel .
,
, . userPrefs.mel, .
userPrefs.mel , .
maya/<version>/prefs ( V/indows, ). <version> , , , 4.0.
userPrefs.mel,
, userPrefs.mel,
, , , , - , . , , Window > Animation Editors > Expression Editor... ( >
> ...). Expression Editor ( ) Filter > By Script Node Name ( > ). ,
(. . 15.1).
15. MEL-
259
m Editor
Select Filter
Jsf'te'
Insert Functions
Script Nodej
Execute On:
Setae
Tett Script
Edkoc
I ENp'essionEditor -j
Scnpt
1LJ
ear
. 15.1.
,
, ,
, , MEL-, . Execute
On: (:) , .
(Before) (After),
.
,
, /
(Open/Close), Script Before. .
, ,
, . ,
, MEL-,
, (
Enter ,
).
260
MELjyin Maya
,
.
Maya.
Maya
SgMainWindow. setParant , ,
, ,
:
global string SgMainWindow;
setParent $gMainWindow;
menu -label "Mark's Menu2";
menulten -label "Make a Sphere" -command "sphere";
menultem -divider true;
menultem -label "Hake a Cone" -command "cone";
, / (Open/Close)
. , ,
. ,
userSetup.mel, < nani<a>/maya/scripts.
, Maya , .
MEL-
Tool Shelf, MEL-
(. . 15.2). MEL-,
. ,
, , ,
Shelf Editor... ( ) (. . 15.'!).
, .
., MEL-
Change Image... ( ) Shelf Editor ( ). ,
, , .
IS. MEL-
Options
261
Shelves
EPCiJiveTool
Extrude
Revolve
Loft
Stitch Tool
Move Down
Delftieltem
Close
MEL-
, , . Maya , , .
,
userSetup.mel, Maya
$gMainWindow . Maya
, .
,
, Shelf Editor
.
16
MEL
4,
, ,
,
MEL . ,
.
, , , , ,
.
, , .
i:
? ,
. , . , ,
, (. . 16.1).
, .
, .
-, Script Editor :
particle -p -5 0 5 -name partOne;
particle -p 5 0 -5 -name partTwo;
(He Enter
MEL- Script Editor, Return,
.)
16. MEL
263
. 16.1. ,
particle , - (-) - 5 X, 0 Y 5 Z. , , .
. partOne
partTwo :
goal -goal partTwo -weight 0 . 5 partOne;
partOne
partTwo. (weight) partOne,
partTwo. 0 1,
0 , 1 - particle2. 0 I
, , , , , ;: . 0 , 1 .
,
sphere (). , :
setAttr partOneShape.particleRenderType 4;
setAttr partTwoShape.prt 4;
,
partTwoShape , partOneShape.
, .
,
300- . , MEL :
playbackOptions -min 1 -max 300;
264
MEL Maya
(. . 16.2). , partdne
partTwo, ,
, partTwo. -
, ,
.
. 16.2.
partOne, partTwo
,
1 :
setAttr p a r t O n e , g o a l W e i g h t [ 0 ] 1 . 0 ;
partOne partTwo.
partTwo partOne, ,
.
, . goalWeight[0] ,
. [0] , [1] - . .
0.5
partTwo partOne :
setAttr partOne.goalWeight[0] 0,5;
goal -w 0.5 -g partOne partTwo;
(. . 16.3). partTwo partOne
, , ,
, partOne .
. ,
.
, .
16. MEL
265
. 1S.3.
Maya,
, .
. -, Script Editor
:
addAttr -longName colorGreen -defaultValue 1
-attributeType double partOneShape;
addAttr -In colorRed -dv 1 -at double partTwoShape;
, Maya (shaded mode), Shading () .
(particleRenderType4).
0.5.
addAttr -longName radius -defaultValue 0.5 partOneShape;
addAttr -In radius -dv 0.5 partTwoShape;
'"-.-'-
-,"'
- . . : ' - - -
-/-
.-'
...
>
''_-.
."
-.-
:':.-
'.
~~ /
.'
\/^.
'
" .
.,
,-'
-^ '
,^ ''' . - \
'
''
'
'
.'l
-'
'\.
Y , , . ,
(velocity) :
MEL Maya
266
0. -Z, 0
. 16.4.
, . Script Editor
:
setAttr partOne.goalWeight[0] 0,2;
setAttr partTwo.goalWeight[0] 0 , 2 ;
, , . (. . 16.5).
16. MEL
267
,
, , . . 16.6
, Maya .
partOne
ector , - I , 0
VI
partOne result
. 16.6. Maya
(Goal vector - ; Vector - ; Goal - ; Result vector ; partOne result- partOne.)
MEL-
, Maya.
helloGoal. mel. .
// MEL-
/
, ,
300- .
" "*/
268
MEL Maya
I/
addAttr -In colorGreen -dv 1 -at double partOneShape;
addAttr -In colorRed -dv 1 -at double partTwoShape;
// : 1 2, 2 1
goal -g partTwo -w 0.2 partOne;
goal -g partOne -w 0.2 partTwo;
//
// Y
particle -e -at velocity -id 0 -vv 0 3 0 partOne;
particle -e -at velocity -id 0 -vv 0 - 3 0 partTwo;
//
// '-
setAttr partOneShape.goalSmoothness 4.0;
setAttr partTwoShape.goalSmoothness 4.0;
// 1-300-
playbackQptions -min 1 -max 300;
}
, ,
Maya. helloGoal Maya.
Script Editor, Source, (. . 16.7).
16. MEL
269
2:
, , , NURBS- (. . 16.8). -,
(patch) ,
U V (UV). . 16.9 , UV
NURBS-.
. 16.8, ,
.
I V II
. 16.9. . U V NURBS-
, , , , UV 1 9 ,
UV , . 16.10.
- - , , , - ,
. - . . .
MEL Maya
270
. 16.10. U V
,
U V, , goall) goaiv.
NURBS-. NURBS- Maya, UV
. ,
,
, UV . NURBS, Script Editor:
nurbsPlane - 0 0 0 - 0 1 0 -w 1 -Ir 1 -d 3 - 1 -v 1 -ch 1;
, ,
- MEL. . 16.11 . , ,
. UV . , 3,
.
. 16.11.
16. MEL
273.
.
, Maya MEL. Panicles
(), Dynamics (), Create
Emitter ( ) , Omni
2. Create (), .
3 ,
. MEL- . , Maya
:
emitter -type omni - 0 3 0 - 2;
particle -n p a r t i c l e l ;
connectDynamic -en emitter"! p a r t i c l e l ;
n u r b s P l a n e . Maya MEL. Window > Outliner.
, , .
particlel, Ctrl, nurbsPlane.
Particles Goal. ,
MEL , Script Editor
Enter:
goal -w 1.0 -utr 0 -g n u r b s P l a n e l particlel;
(sphere),
. Attribute Editor ( ),
Particle Render Type ( ),
sphere (). , MEL, Script Editor Enter:
setAttr particlelShape.particleRenderType 4;
Current Render Type ( ), .
, . , 0.5 .
MEL- 1 ?
addAttr -is true -In radius -at "float" -min 0 -max 1
-dv 0 - 5 particlelShape;
, (nurbsPlane) ,
1, - 200
Maya,
MEL-:
playbackOptions -min 1 -max 360;
272
MEL Afaya
. . 16.12 .
. 16.12. ,
nurbsPlane ,
F9, , (control vertices (CVs)). UV-
UV-
. , ,
UV ,
(particlel), Attribute Editor (Ctrl-), .
Per Particle (Array) Attributes ( ()) General (). Particle ().
, ,
, . goalU
goalV. , Ctrl, (. . 16.13).
Add (), Close ().
Per Particle (Array) Attributes.
MEL- :
addAttr -In goalU -dt doubleArray particlelShape;
addAttr -In goalUO -dt doubleArray particlelShape;
addAttr -In goalV -dt doubleArray particlelShape;
addAttr -In goalVO -dt doubleArray particlalShape;
16. MEL
273
Hf.'
?<;
(j Bender Stli
_j P Particle |AiraV) Attrbut
podt
IhPoahon UiWo'UPoMbn.
cotuiaiU '
cotofAcdjm:.!/ .
V| Md Dynamic AtUbiMBI
Genaal
P-*:
LoKdAtlibulei
. 16.13.
addAttr goalU goalV goalUO goalVO. Maya goalUO
goalVO . goalU goalV.
, , . : .
, ,
, , , .
, , , , , ;
274
MEL Maya
II
//
- , (. . 16.14).
particlel Attribute Editor.
Per Particle (Array) Attributes. , ,
. , , goalU.
velocity () . Creation, Runtime
Component Editor. Creation, Expression Editor ( ).
:
//
goalU = 0.0;
goalV - 0 . 0 ;
Selected UbilAllr
- 'j-v?
__
An
<" Qe-atbn
Expiesslon:
tl Creation
goalU=0.0;
goalV^O.O;
. 16.14.
16. MEL
275
Expression Editor
Insert F
Creating Ex
Egression Name
I_
.1
: GJSelecliott
. pnpressiwis
1- particle IS
^.f-VU:,.'-''- f~
Default Object f
Runtime
Editor
Ar:g
Creation
I Expression Editor j
Expression:
. 16.16. Runtime
, . 16.17.
//
goalU = age;
goalV = age;
Create, Close.
Age . , , , UV- . Script Editor :
select - nurbsPlane1.cv[1:2][1:2];
move -a 0 4.0 0;
MEL Maya
276
tS
Al
N-^s
Panicle: ^Runtime
Ar.
<"* Creation
E upretsicri
/Runtme
goalU= age;
goalV* age;
. 16.17.
, , Y .
4.0
Y, [1:2][1:2] . -
(replace) ,
, . -
(absolute), . . 16.18 .
.
. 16.18. ,
16. MEL
277
. , , .
numeric (), - ., UV-.
setAttr particlelShape.particleRenderType 2;
addAttr -is true -In pointSize -at long -min 1
-max 60 -dv 2 particlelShape;
addAttr -is true -In selectedOnly -at bool -dv false particlelShape;
addAttr -is true -dt "string" -In attributeName particlelShape;
setAttr -type "string" particlelShape.attriDuteName age;
Attribute Editor,
(. . 16.19).
_VJ Emission Random Stream Seed*
] Render Attributes
Pailicle Render Type [.Numeric1
AddAllrbutes F
,
''
Rsds-j;
. "\
;K!
. 16.19. Numeric
goalU goaiv , . - , ,
, (velocity), (position) id. ,
, , Script Editor.
Expression Editor Maya. , Maya
. , goalU particleShapel.goalU.
:
//
//
278^
^ MEL Maya
particlelShape.goalU = 0.0;
particleTShape.goalV = 0.0;
//
//
particlelShape.goalU = particlelShape.age;
particlelShape.goalV = particlelShape.age,
Maya , ,
; ,
.
. , ,
, goalU goalV 1.0, UV .
,
lifeSpanPP. Lifespan Mode lifespanPP only,
. 16.20.
DieOnEmi)sionVolum*El
<| 1- Attribute* (tee alto pct-patticle tab]
Uespan Made | ifesparPP only -A
16. MEL
. 16.21.
279
,
U V .
UuVc
, . sin (), U
. ,
, sin U -1.0
1.0. U, abs.
0.0 1.0. age
, , , 6
.
. Maya Expression
Editor.
Window > Settings/Preferences > Hotkeys, Shift
+ Ctrl .
Expression Editor :
//
//
goalU = abs(sin(age * )};
goalV - age;
MEL Maya
280
II UV
// V
if (goalV > 1.0) {
lifespanPP - 0.0;
}
100
sphere:
setAttr emitterl.rate 100;
setAttr particlelShape.particleRenderType 4;
(. . 16.22).
. 16.22.
, UV
. , , ,
3-
NURBS- . 2, goalWeights, UVs. ,
, . , NURBS- ,
(. . 16.23).
16. MEL
. 16.23.
281
. nurbsPlane planel 0 0 0
:
nurbsPlane - - 0 1 0 -w 1 -1 1 -d 3 - 1 -v 1 -name planel;
planel 10 5. ,
xform, ,
.
xform -scale 5 5 5 planel;
xform -rotation 90 0 0 planel;
xform -translation 0 0 10 planel;
, plane2, -90 :
nurbsPlane - 0 0 0 - 0 1 0 -w 1 -1 1 -d 3 - 1 -v 1 -name planeS;
xform -scale 5> 5 5 plane2;
xform -rotation -90 0 0 plane2; //
xform -translation 0 0 -10 planeS;
. 16.24.
ball sphere () 0.4:
particle - -name ball;
setAttr ballShape.prt 4;
addAttr -is true -In radius -at "loat"-dv 0.4 ballShape;
:
goal -w 0 . 5 -utr 0 -g planel ball;
goal -w 0.5 -utr 0 -g plane2 ball;
282
. 16.24.
MEL Maya
1- 500- :
playbackQptions -min 1 -max 500;
16. MEL
", "
283
i .i f
. 16.25.
goalU goalV
, planel .
, MEL,
5. MEL-
; :
dynExpression -s (
"// \" +
"goalU = 0 . 5 ; \ " +
"goalV = 0 . 5 ; \ " +
"goalWeight[0] = 1 . 0 ; \ " +
"goalWeight[1] = 0 . 0 ; "
) -creation ballShape;
, dynExpression , , , Maya.
,
, .
, , , Expression Editor,
Maya ballShape . ,
, goalV ballShape. goalV , Expression Editor.
2
, , , goalWeights 0.0 1.0. sin (),
2,
(. . 16.26).
MEL Maya
284
sin(x)
*
-2
-1
. 16.26.
;
time. Expression Editor :
//
goalWeight[Q] = sin(time);
goalWeight . Script Editor,
. , :
print ( " \ " ;
print ("Goal one = " + goalWeight[0] + "\);
Script Editor . . 16.27
.
1 - -0-5792077686
. 16.27. 1
, goalWeight ,
abs ( ) . abs sin , 0.
, ,
, ,
16. MEL
285
oal an* - 0 . e S 7 4 9 6 S 6 * 6
on* -
0.9799763
. 16.28. 1 abs
. 16.29.
goalWeight[1]. ,
:
//
goa!Weight[0] = abs(sin(time});
goalWeight[1] = abs(cosCtime));
print("\n">;
print ("goal one - " + goalWeight[0] + "\n");
print ("goal two = " + goalWeight[1] + "\n");
286
MEL Maya
. 16.30 .
. 15.30.
,
.
f req ,
.
Attribute Editor Add Dynamic Attribute ( ). General ,
. , Channel Box, ,
Expression (). f req Attribute Name ( ).
. ,
Float. Attribute Type ( ) Scalar ()
, .
Numeric Attribute Properties ( ) 1.0 Minimum
(), 12.0 Maximum () 1.0 Default ( ) ,
. 16.31.
Add OK: Maya ballShape.
Channel Box, freq
. MEL
:
addAttr -In freq -at double -min 1 -max 12 -dv 1.0 ballShape;
setAttr -e -keyable true ballShape.freq;
16. MEL
287
.]
Alt*meNemt j&eq
P MakaAHnbule|(.ayable
Oi* TjfpB
f* Vactof
.'ff ftoal
f" Iniedr
^ Slmg
<" Eoolem
*" from
Pe,partide(Anjy|
^Dda^_
EnumNamn
. 16.31. f req
Channel Box. Expression Editor
. :
//
goalWeight[0] = abs(sin(time * freq)};
goalWeight[1] = abs(cos(time * freq)};
print, .
print .
Edit Close . Channel Box
freq, (. . 16.32).
GoalActive[1J
Cache Data
* Depth
Particle Render [Spheres
Lifespan ji
Radius (o.4
Freq fe"~~"
288
MEL ^
. f req
, , 4, 8 12, ,
. , /
.
, ,
. f req.
4> , 2
,
, . MEL-, NURBS- (. . 16.33).
. 16.33. ,
,
.
, , . , ,
, -, , ,
.
, ,
,
.
16. MEL
289
Maya . Maya chapter!6.ma
- www.m_kp.com/MELscripting. 1- 150- , . 16.34.
, ,
50, 100- , , , 50-, 150- .
. 16.34, Outliner
, (Ball, 3) plane! !,
plane4 plane2, planel. MEL- ,
.
, p l a n e l ,
. planel .
,
SPstart xform. planel .
, Script Editor Script Editor
Maya (. . 16.35). :
float SPstart[] = ' x f o r m -q -a -translation p l a n e l ' ;
:
$Pstart = ' x f o r m -q -a -translation p l a n e l ' ;
// Result; 0 5 14 //
. 16.35.
10- 132
Script Editor
MEL Maya
290
MEL- $Pstart. -q ,
- , xform . , SPstart.
print:
print SPstart;
MEL :
print $Pstart;
5
14
, , , SPstart
, .
SPstart $Pstart[0], $Pstart[1] $Pstart[2],
goalWeights . $Pstart[0] 0, $Pstart[l] 5,
a $Pstart[2] 14. SPstart X, Y Z, xf rm.
Ball ,
X, Y Z, SPstart, sphere.
:
particle -n Ball -p $Pstart[0] $Pstart[1] $Pstart[2] - 1;
setAttr BallShape.particleRenderType 4;
Ball plane! (. . 16.36).
. 16.36.
16. MEL
291
, .
,
, , .
, MEL- ,
. Maya planel , . 16.37, Shift .
. 16.37.
(Pick first - ; Pick second - ;
Pick third - ; Pick fourth - )
Script Editor :
string $planes[] = 'Is -si';
Is -si , , . $planes , ,
. , , S
print $planes;
MEL :
print $planes;
planel
planeS
plane4
plane2
292
MEL Maya
MEL :
whatls "Splanes";
//Result: string[] variable//
:
whatls "$Pstart";
MEL :
whatls "SPstart";
//Result: float[] variable//
, , MEL
. , [] ,
- , - . whatls //Result; float variable//,
, .
. , Splanes .
goal -w 0 -utr 0 -g $planes[0] Ball;
goal -w 0 -utr 0 -g $planes[1] Ball;
goal -w 0 -utr 0 -g $planes[2] Ball;
goal -w 0 -utr 0 -g $planes[3] Ball;
, .
16. MEL
293
,
. goalU goalV ,
3. MEL
Maya.
addAttr -In goalU -dt doubleArray BallShape;
addAttr -In goalLJO -dt doubleArray BallShape;
addAttr -In goalV -dt doubleArray BallShape;
addAttr -In goalVO -dt doubleArray BallShape;
MEL.
, Expression Editor ,
, - . 3?
:
dynExpression -s (
"// \\" +
" goalU - 0.5;\" +
" goalV = 0.5;\n\n"
} -creation BallShape;
\n , Expression
Editor (. . 16.38). Expression Editor.
d Bodies
fo
General Editors
Rendering Editors
Animation Editors
Relationship Editors
Settings/Preferences
Attribute Editor...
Outliner,..
Hypergraph...
Pant Effects..;
UV Texture Editor.,.
Effects''
7.
yi:,l,
^~*
"
flat
i S5S
ir-jar:
Graph Editor.,
Trax Editor...
Dope Sheet..'
Blend Shape..
Expression Editor...
Devlcs Editor^. ^
J-
294
MEL Maya
Convert Units: (* All
"" Ncne
" Angn
Particle: < Runtime
<*" Creation
Editor
I Expression Editor |
Expression:
// Creation
BallShape.goalU = O.S;
BallShape. goalV = 0 - 5 ;
. 16.39.
Expression Editor
, . .
goalWeigtits, , ,
. , 3:
abs(sin(time));
abs(cos(time));
,
.
, ,
. linstep (linear step - ) .
linstep :
linstep (value_from. value_to, percentage)
, goalWeights :
goalWeight[0] - linstep(0.0. 1.0, sin(time)};
goalWeight[1] = linstep(0.0, 1.0, cos(time));
. 16.40 sin, cos linstep. sin cos
, linstep , , 0.0 1.0, 1.0 0.0. sin cos,
, 0.0 1.0 0.0.
. time Maya. time sin cos.
, , :
goalWeight[0] = linstep'CO. , 1 . 0 , c o s ( t i m a ) ) ;
goalWeight[1] = linstep(0,0, 1.0, sin(tine));
g o a l W e i g h t [ 2 ] - l i n s t e p f O . O , 1.0, s i n ( ( t i m e ) + 2 4 ) ) ;
goalWeight[3] - linstep(0.0, 1.0. c o s ( ( t i m e ) + 46));
16. MEL
295
296
MEL Maya
MEL :
dynExpression -s (
"// \\" +
"// freq 4.\\" +
"float $freq = 4.0;\n\rT +
"// '\\" +
"goalWeight[0] = linstep(0.0, 1.0, cos((time $freq)));\n" +
"goalWeight[1] = linstep(0. 0, 1.0, sin((time $ f r e q ) ) ) ; \ n " +
"goalWeiQht[2] = linstepCO.O, 1.0, sin((time $freq) + 24));\n" +
"goalWeight[3] = linstep(0.0, 1.0, cos((time $freq) + 46));"
) -runtime BallShape;
MEL-.
:
//
// MEL-: ballTravel
//
// : chapter16.ma
//
// : NURBS-
//
//
// : $freq
// Expression Editor
//
global proc ballTravel( } {
//
string $planes[] = 'Is -si';
// ,
if (size($planes != 4) {
error " \"; // .
II
16. MEL
/!
297
298
MEL Maya
, ,
ball-Travel Script Editor,
(. . 16.42).
. 16.42. ,
17
MEL
, ,
. MEL , ,
.
, MEL ,
,
, ,
, , .
1:
,
.
(. . 17.1).
NURBS, .
. 17.1. ,
MEL Maya
300
(polygon
grid) .
Create > Polygon Primitives > Plane D ( >
> ). Polygon Plane Options ( ).
4X4, . 17.2.
nmiwes
Vatme PrimlBves
Lights
'
afcere
Cube
Cylinder
CV Cif *e Too!
EO Qjrva Tcol
Panel! Curve Tacl
..
r Kit
17, MEL
'Channels., Object
301
' ' -
Floor
Translate X
Translate V 0
Translate Z 0- .
Rcrtate X D
Rotate Y "o"~
^
Rotate Z 0
Scale X 12
Scale V 12
Scab! '12
Visibility on
4.0: -\untitl
511 , .d.[*: Codify Cre
7)
. 17.5.
(. . 17.6). () Directional (), Rate () 30, a Directions () X = , Y = -1.0 Z = 0.
Spread () 0.2, 4
Y, , Floor.
302
MEL Maya
Errilta Name
Eniltei Attributes
^
Erria
Rate'jParbd/Ssc|
.^^"
~,r
- j DirtanoWDitui.tinn Attribute*
'MDiilaice WOCO
... 'j
. 17.6.
MEL- . ,
, Y -position.
, ,
, . , . Emit 0,
EmitShape 1.
string SeObject [] = 'emitter -position 0 4 0 -type direction
-name Emit -rate 30 -speed 1 -spread 0.2 -dx 0 -cty -1.0 -dz 0 ' ;
Maya, . MEL . , , , , (particlei) . ,
connectDynamic:
s t r i n g $pObject[] = ' p a r t i c l e 1 ;
connecrtDynamic -em $eObject[0] $pObject[0];
1-500
. (. . 17.7).
17, MEL
. 17.7.
303
, , ,
MEL-:
playbackOptions -min 1 -max 500;
particlel. , Shift, Floor.
Particles () Make Collide ( )
(. . 17.8).
Particle Tool
Create Emitter
Uss Selected Emitter
Per-Pdint Emission Rates
Particle Collision Events.,.
. 17.8.
Make Collide
MEL- :
collision -resilience 1.0 -friction 0.0 Floor;
connectDynamic -collisions Floor particlel;
MEL ^^
. 17.9. Hypergraph
. 17.11. geoConnector,
, , particlel ,
(. . 17.12).
17. MEL
305
. 17,12. ,
:
MEL, , . -, geoConnectorl,
. Floor Maya Channel
Box, geoConnectorl. ,
Tessellation Factor ( ), 200. Floor . tessellation 20 '{ ), .
, (. . 17.13).
. 17.13.
. . . .
306
^ MEL Maya
"^/^VV'rX^V\X^\x
^.^'-'^
geoConnector
, geoConnector, Resilience () Friction (). , - .
, . Floor geoConnectorl Channel Box.
Resilience 0.0, a Friction 0.5 (. . 17.14).
OUTPUTS
geoConnectorl
Tessellation Factor [200
Resilience
, Friction f
. 17.14.
geoConnsctor!
MEL :
setAttr geoConnectorl.resilience 0.0;
setAttr geoConnectorl.friction 0.2;
. 17.15 . particle!
.
17. MEL
. 17.15.
307
MEL
, Floor ,
particle! .
, .
Floor -26.00 X:
xforn -rotation -26 Floor;
Floor 3.0 Z, -3.0
Y. 26.0 X.
duplicate -name Floor"! Floor;
xform -a translation 0 -3 -3 Floor!;
xform -a rotation 26 0 0 Floorl;
particle! Floor!,
geoConnector
, geoConnectorl.
collision -resilience 0 -friction 0 . 2 Floorl;
connectDynamic -collisions Floorl particle!;
particle!, Floor:
gravity -magnitude 3 -attenuation 0.0;
connectDynamic -fields gravityFieldl particle!;
308
^ MEL Maya
. 17.16.
:
(event). . 17.17 .
. MEL-.
. File > Open ( > ) chapter 17.ma Web-, :
www. mki^com/MELscriotins.
17. MEL
. 17.17.
309
. 17.18.
chapterl 7.ma
MEL Maya
310
, ,
, bucket!, bucket 1
bucket2.- bucket2
, buckets. MEL-, .
Dynamics () (. . 17.19) ,
Particles > Create Emitter > ( > > ).
waterEmi-t 100, -1.0 Y 0.2 (. . 17.20).
'File i Edit-,Modify
Dynamic*
Create
Display VWiidQW'
! j
. 17.19.
Create Emitter
35 Help
EnnKiB Name jnat1 [
'.-I Basic Emitter AKribulet
j Directional [
Hals particles/See) (TOO '
DieqtonZ (.1
; '
. 17.20.
bucketi, ,
X = , Y = 9.0 Z = 0. , MEL.
17. MEL
311
Script Editor :
string $eQbject[] = 'emitter -name waterEmit -position 0 9 0
-type direction -rate 100
-spread 0.2 -dx 0 -dy -1.0 -dz 0';
string SpObject + [] = 'particle';
connectOynamic -emitter $e'0bject[0] $pObject[0];
1 500 , . ,
bucket! (. . 17.21).
. 17.21.
bucketl
sphere. , ,
, 0.
collision -resilience 0.3 - f r i c t i o n 0.0 bucketl;
connectDynamic -collisions bucketl particlel;
setAttr particlel.particleRenderType 4;
addAttr -longName radius -defaultValue 0.1 particleShapel;
. . 17.22 ,
.
MEL Maya
312
. 17.22. ,
1 , MEL-. ,
connectDynamic. Window > Relationship Editors > Dynamic Relationships
( > > ) (. . 17.23).
RendeTinq Editors
Animation Editors
Attribute, Editor.
Cutliner.,,-'
Hypergrapb...
Paint Effects...
uVTextire Editor,,.
17. MEL
M Dynamic Relationships
front
.,*c
\
SELECTO'N MODES -
Fields ff ICoifeionsj f. Emitleis
v
313
pa;'.ic!e1
IIJ!J| bucketl Shape
/;"!' ;
''$
bucket2
^\buckets
1
delaultLigKtSet
, 150 . ,
Max Count particlel 150. Channel Box (
-1, Maya ).
MEL- :
setAttr particleShapel.maxCount 150;
MEL, Script Editor. particlel, MEL-:
gravity -magnitude 10 -attenuation 0.3 -dx 0 -dy -1 -dz 0;
connectDynamic -fields gravityFieldl particlel;
. 17.25 .
. 17.25. bucketl
314
MEL Maya
'
(2 3) .
., . MEL:
collision -resilience 0.3 -friction 0.0 bucket2;
collision -resilience 0.3 -friction 0.0 buckets;
connectDynamic -collisions bucket2 particlel;
connectDynamic -collisions buckets particlel;
particlel , bucketl.
, bucketl.
(split) (emit) .
. , ,
MEL-, , .
(event object), ,
Maya . MEL- particlel -, MEL, Maya .
( ):
event -name mainEvent -die 0 -count 0 - eventProc p a r t i c l e l ;
, eventProc MEL-. -name
. -die 0 ,
, . , -count
, , , , ,
.
MEL-, ,
eventProc, : -, , -, , Id , , -,
. ,
:
17. MEL
315
. 17.26.
eventProc
, , , , , .
, .
, eventProc
.
Script Editor :
addAttr -In collisionCheck -at long -min 0 -max 1 -keyable 1
-dv 0 bucket"!;
addAttr -In collisionCheck -at long -min 0 -max 1 -keyable 1
-dv 0 bucket2;
addAttr -In collisionCheck -at long -min 0 -max 1 -keyable 1
-dv 0 buckets;
,
eventProc 0 1 . , . , Channel Box .
eventProc , .
if, , , Id
120, bucket"!. , bucketl.collisionCheck 0 1.
, . 17.27, eventProc.
316
MEL Maya
QeventProe - Notepad
// eventProc
global proc eventProc (string Spartide, hit $ld, string $geoCbj)
'
. 17.27. eventProc no
, " bucketl"
b u c k e t l . - , Maya
eventProc.
if (( $Id == 120) && (SgeoObj == " bucketl")) {
setAttr (SgeoObj + ".collisionCheck") 1;
}
. eventProc ,
.
eventProc. mel, Maya , MEL- , , . , , getenv("MAYA_SCRIPT_PATH") Script
Editor. , Maya , ,
, Maya,
, .
// eventProc
global proc eventProc (string Sparticle, int $Id, string SgeoCbj)
{
if (( $Id == 120) && (SgeoObj == " bucketl")) {
setAttr ($geoObj + ".collisionCheck") 1;
}
if (( $Id == 120) && (SgeoObj == " bucket2")) {
setAttr (SgeoObj + ".collisionCheck") 1;
}
if (( $Id == 120) && (SgeoObj == " bucket3")) {
setAttr (SgeoObj + ".collisionCheck") 1;
17, MEL
317
Script Editor
eventProc (. . 17.28). , , , .
MEL, Script Editor :
source eventProc.mel;
. 17.28.
Source Script
event MEL
, eventProc, :
event -name mainEvent -die 0 -count 0 -proc eventProc particlel;
, , 1,
Id 120 , ,
, 1.
. -, ,
collisionCheck 0 1.
, collisionCheck 0
. -,
0 0 0 1.
Expression Editor, Window > Animation Editors > Expression Editor
( > > ) (. . 17.29).
. 17.29.
Expression Editor
318_
MEL
Maya
:
// bucket(1-3). collisionCheck
//
if (frame == 1) { // , 1
setAttr bucketl. collisionCheck 0;
setAttr bucket2. collisionCheck 0;
setAttr buckets. collisionCheck 0;
// collisionChecks
//
if (frame 1) { // , 1
bucketl . rotateX = 0;
bucket2.rotateX - 0;
buckets. rotateX = 0; // rotateX -
\
collisionCheck
.
, , collisionCheck. , setAttr
collisionCheck. ,
collisionCheck,
eventProcO .
bucket. collisionCheck = 1
.
rotateX , collisionCheck
. :
// +=,
// rotateX
if (bucketl. collisionCheck != 0) { // ,
//
if (bucketl. rotateX > -111) { // -111 rotateX
bucketl. rotateX += -2; // X -2
17. MEL
319
bucket2. rotateX += 2;
if (buckets. collisionCheck != 0) {
// , bucketl
if (buckets. rotateX > -111) {
buckets. rotateX += -2;
. 17.30.
.
. - geoConnectors 600. , ,
. MEL:
setAttr geoConnectoM, tessellationFactor 600;
setAttr geoConnector2.tessellationFactor 600;
setAttr geoConnectorS.tessellationFactor 600;
bucket2 0.2,
. :
setAttr geoConnector2.friction 0.2;
320^
MEL Maya
, - , , , , .
Playblast,
. ,
Scale Playblast. Playblast , Windows > Playblast .
;
2 .
,
, . . 17.31
.
3 x 3 . Create > Polygon Primitives > Plane ( > >
), 4 . Plane (. . 17.32).
. 17.31.
17. MEL
. 17.32.
321
Effects
Solver
^^1^^
General Editor
Relationship bit*s
1 s jSetfiricis/Freferences
Attribute Editor... :
r.*4^." i
Render View,,.
Hardware Render Buffer,
Render Gtabals. ..,-
Renders Elans...
. 17.33. Hypershade
21
- , , . - . . .
11- 1303
MEL Maya
322
. 17.34.
grid ,
, ,
, .
, , shadingHap
. ,
shadingMap.
:
global g r i d D u p (} {
,
:
SgridArray = {"-4 0 -4", "-4 0 0", "-4 0 4", " 0 -4", " 0 4",
eval, SgridArray , -
17. MEL
323
xform. , grid
shadingHap, . Maya
.
for ($i - 0; $i < 8; $i++) {
// duplicate -rr grid;
$cmd = "xform -worldSpace -translation" +
($gridArray[$i] + " grid"-*- ($i + 1));
eval(Scmd);
// shadingMap
//
duplicate -name ("shadingMap" + $i + "SG") -upstreamNodes shadingMapSG;
sets -e -forceElement ("shadingMap" + $i + "SG") ("grid" + ($i + 1});
} //
}; //
, gridt, grid2, grids . .
$i 0, $i + 1
. $i 0, , ,
gridl . ,
$1 $1.
, "grid" .
, gridDup.mel. Script Editor
Source Script (. . 17.35). , .
seripis'
MEL Maya
324
. ,
. ,
. , , , ,
grid shadingMapl.
Script Editer g r i d D u p .mel Enter . ,
. . 17.36 , Maya. . 17.37 , HyperShade.
. 17.36.
. 17.37. Hypershade
17. MEL
325
, .
Script Editor poiyCube :
polyCube -name collisionBox -w 1 -h 1 -cf 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0
-tx 1 -ch 1;
, :
x f o r n -worldSpace -scale 12 12 12 collisionBox;
x f o r m -worldSpace -translation 0 5 0 collisionBox;
Shading > Smooth Shade All Shade Options > WireFrame on Shaded
(persp Panel). ,
, .
Hypershade lambertl,
collisionBox . lambertl Transparency ()
(. . 17.38). . 17.39 , .
. 17.38.
lambertl
. 17.39.
MEL Maya
326
collisionBox
collisionBox Display > Polygon Components > Normals ( > > ) (. . 17.40).
, . , ,
.
Tentijrjng
RsnOsr
''!
Hide
Show
IKHV Panels
Wireframe Color..,
DbJactBfesHf
f
I IF.'.. (1
"-|..[
Border Edges"
| * Surfaca ^^ ^
L?^!w S^^!?1^.^^
Fast Interaction
ight Manpjlatcr
Fie Centers
Ws
Lonq Normals
. 17.41. ,
17, MEL
327
View
. 17.42. Select by Object Type
Flipped Normal I
. 17.43.
, Display > Polygon
Components > Normals ( > > )
collisionBox.
. -,
Ball. Script Editor :
polySphere -name Ball ~r 1 -subdivisionsX 12 -subdivisionsY 12
-ax 0 1 0 -tx 1 -ch 1;
328
MEL Maya
Particle Collision ;
W Aclive
Mass |10DO;~"
Sal Cento olMass
_
'Static Friction J01 '"""
J
J
,j
Damping |oiOO
Impulse: X |~~
* '"
Spn Impulse: !
Y|O.OOO
z (aoop;.
17. MEL
329
Initial Stifling*
Initial SpKX [0.000
. 17,45.
Ball
. 17.46.
Ball
MEL- :
rigidBody -active -m 1 -dp 0.1 -sf 0.1 -df 0.2 -b 0.8 -1 0 -tf 500
-iv 12 0 -12
-lav 0 0 360 -c 0 -pc 0 -i 0 0 0 -imp 0 0 0 -si
. 17.47.
Hypergraph
330
MEL Maya
collisionBox .
collisionBox. ,
Ball , Passive Rigid Body > ( > CJ). ,
, , Stand In none,
Initial Settings 0.
MEL- :
rigidBody -passive -m 1 -dp 0.1 -sf 0.2 -df 0.2 -b 0.7 -1 0 -tf 600
-iv
-iav 0 0 0 -c 0 -pc 0 -i 0 0 0 -imp 0 0 0 -si
-sio none collisionBox;
, gravity 3
HturbulenceField 20. Attenuation () ,
, . MEL ( Maya,
Ball, Ball):
gravity -pos 0 0 0 -m 3 -att 0 -dx 0 -dy -I -dz 0 -mxd -1;
turbulence -pos 0 0 0 -m 20 -att 0 -f 1 -mxd -1;
connectDynamic -f g r a v i t y F i e l d l Ball;
connectDynamic -f turbulenceFieldt Ball;
1 300 :
playbackOptions -min 1 -max 300;
, Ball
collisionBox. Script
Editor:
// Warning: Cycle on 'Ball.worldMatrix[0]' may not evaluate as
expected. (Use 'cycleCheck -e off to disable this warning.) //
cycleCheck -e off Script Editor.
, Ball
.
-sio none;
17. MEL
331
for, , . , ,
MEL- ,
, ,
, .
grid
gridl grids, grid , , .
Script Editor rigidBody,
:
rigidBody -passive -m 1 -dp 0.1 -sf 0 . 2 -df 0 . 2 -b 0.7 -1 0 -tf 600
-iv 0 0 0 -iav 0 0 0 -c 0 -pc 0 -i 0 0 0 -imp 0 0 0 -si
-sio none g r i d ;
for:
for ($i = 1; $i < 9; $i++) {
rigidBody -passive -m 1 -dp 0.1 -sf 0 . 2 -df 0.2 -b 0 . 7 -1 0 -tf 600
-iv
-iav 0 0 0 -c 0 -pc 0 -i 0 0 0 -imp 0 0 0 -si
, Ball
, '!. , Solvers > Rigid Body
Solver ( > ) Display Label (
). , ,
(. . 17.48).
* js,*!,^ I
CJIHIB ! Botif!
11
!___
rodbohir- |ii*S!i(
^&J i-
, (*Hq [.TRigMSDlye
332
MEL Maya
. 17.49.
, Attribute Editor rigidSolver. Solvers > Rigid
Body Solver ( > ) Contact Data
( ) Rigid Solver States ( )
(. . 17.50). ,
.
.
. 17.50.
^ MEL
333
, RGB-
shadingMap Ball, Bal . , . ,
rigidBodyS - rigidBodyfl.
rigidBody3, Expression Editor ( )
Windows > Animation Editors > Expression Editor ( > > ). rigidBodyS, Outliner
Display Shapes ( ).
+, , (. . 17.51).
Isplay Show..'Panels
gridSShepo
. 17.51.
Expression Editor :
// , 1- ,
//
if (frame == 1) {
MEL Maya
334
, contactcount 0 . 1, 2 . . .
, , 0, ,
.
,
, Create. Play,
,
Ball, (turbulence). ,
Script Editor:
setAttr r i g i d B o d y l . i n i t i a l V e l o c i t y X 0;
setAttr rigidBodyl. initialVel-ocityZ 0;
setAttr rigidBodyl.initialSpinZ 0;
setAttr t u r b u l e n c e F i e l d l . m a g n i t u d e 0;
Shading ()
Hardware Texturing ( ),
(. . 17.52). , Display >
Grid ( > ), .
. 17.53 .
Wireframe
Smooth Shade All'
Smooth Shade Selected Items
Flat Shade All
Flat Shade Selected Its ms
Bounding Box
Points
Shade Options
.InteracSveShad hg'.:=: .
,' Dense Wireframe Acceleration
" Culling
17. MEL
. 17.53.
335
};
, , , , ,
, . , expression, // , ;
print Sexpstring
336
MEL Maya
, Enter.
Ball,
:
setAttr rigidBodyl.initialVelocityX 12;
setAttr rigidBodyl.initial.VelocityZ -12;
setAttr rigidBodyl.initialSpinZ 360;
setAttr turbulenceFieldl.magnitude 20;
. 17.54 . . ,
rigidBodyl ,
.
. 17.54.
4'
. . 17.55 . MEL- .
. Script Editor NURBS-
:
nurbsPlane -name panel -p 0 0 0 - 0 1 0 -w 1 -lr 1 -d 3 -u 1 -v 1 -ch 1;
xform -worldSpace -scale 20 20 20 panel;
xform -worldSpace -rotation 0 0 -90 panel;
17. MEL
. 17.55.
337
X, .
gun. Script Editor :
emitter -pos 25 0 0 -type direction -name gun - 30 -spd 50 -mxd 0
-dx -1
1- 300-
Play. . 17.56 .
. 17.56.
338
MEL Maya
MEL
MEL- ,
Y g u n ,
. -, . 30 30 , ,
. , ,
, -30 30.
MEL-.
MEL- .
:
window -title "Gun Control" -width 400 -height 50;
columnLayout;
floatSliderGrp -label "aim" -field true
-minValue -30.0 -maxValue 30.0 rotY;
connectControl rotY gun.rotateY;
showWindow;
, ,
Script Editor , , .
BBAI 14.
window -title "Gun Control" - , .
-width -height 400 50 .
,
,
columnLayout , .
floatSliderGrp
.
-label .
-minValue -maxValue
.
rotY , floatSliderGrp.
connectControl rotY gun.rotateY rotY
g u n . rotateY,
.
showWindow Maya.
17. ^,
339
, ,
(Ctrl+C Ctrl+V Windows) Script Editor. Enter. . 17.57 ,
.
. 17.58. gun
Maya,
. Script Editor ,
(, ,
). Script Editor
. , Maya
(. . 17.59).
Gun Control MEL- . . , Shelf Editor ( ),
, .
exSstart scenes ( ),
.
MEL Maya
34
I
'anels
iMStrlpt tell tor
Ffle Edt I Script
63
Help
. 17.59. MEL-
,
. ,
, Modify > Convert > NURBS
to Polygons > D ( > > NLUBS > )
(. . 17.60).
. 17.60.
NURBS
17. MEL
341
. 17.61. NURBS-,
, . MEL
, , . select, "*".
polyPanel:
select - polyPanel.f["*"];
filterExpand -select ion Mask 34 , , $facel.ist.
filterExpand
, selectionHask.
filterExpand MEL Command Reference,
, selectionMask 34 .
SfaceList = 'filterExpand -sm 34';
size( ):
size($faceList);
Script Editor,
:
size($faceList);
// Result: 16 //
MEL Maya
342
, polyPanel.
SfaceList , 16 ,
0 15 polyPanel.f[]. , ,
polyChipOff,
. Script Editor :
polyChipOff -keepFacesTogether 0 polyPanel.f[0:(size($faceList) + 1)];
, . :
polySeparate -name smPanels polyPanel;
polyPanel Outliner (. . 17.62).
. 17.62.
, polyPanel
,
smPanels .
smPanelsl - smPanels16. :
delete smPanels;
for, smPanelsl - smPanelsl 6
, , . , .
1. .
2. particlel ,
.
17. 1^
3. , , ,
X Z .
, , Script Editor.
:
for ($i = 1; $i <= size($faceList); $ ! + + ) {
rigidBody -active -damping 1 -collisions 0 -particleCollislon 1
("smPanels" + $i);
collision -r 0.2 -f 0.2 ("smPanels" + $i);
connectDynamic -c ("smPanels" + $i) particlet;
, . , .
smPanel + $i rigidBody , . ,
1
particle !. smPanels ,
-collisions 0 off rigidBody.
, smPanel ,
0 X ( X).
, X 2, Z -2.
. , X. , , .
, ,
, 1-.
Expression Editor.
expression
, panel.
if ( f r a m e == 1) {
rigidBodyl. particleCollision = 1;
rigidBodyl. impulseX = 0;
rigidBodyl. impulseZ = 0;
}\
344
MEL Maya
, . ,
, :
Sexpstring = "\nif (frame == 1) {\n";
Sexpstring += ("rigidBody" + Si + ".particleCollision");
Sexpstring += " = 1;\n";
Sexpstring += ("rigidBody" + Si + ".impulseX");
Sexpstring += " = 0;\n";
Sexpstring += ("rigidBody" + Si + ".impulseZ");
Sexpstring += " = 0;\n";
Sexpstring += "};\n";
Sexpstring += "\nif (";
Sexpstring += ("rigidBody" + Si + velocity*"};
Sexpstring += " < 0) {\n";
Sexpstring += ("rigidBody" + $i + particleCollision"
Sexpstring += " = 0;\n";
$expstring += ("rigidBody" + $i + impulseX"^
Sexpstring += " = 2;\n";
Sexpstring += ("rigidBody" + $i + impulseZ"
Sexpstring +- " = -2;\n";
Sexpstring += "};\n";
expression -s Sexpstring -o ("expression" + Si) -ae true -uc all;
:
, Script Editor.
Enter , .
, particlel,
. :
setAttr particleShapel.lifespanMode 1;
setAttr particleShapel.lifespan 1.0;
, , .
Gun Control (. . 17.63).
litfQun Control
. 17.63.
17. MEL
345
, , 30, (. . 17.64).
. 17.64. gun
MEL-
, , MEL-
, panel. :
global proc panelBreakup( ) {
print " \";
nurbsToPoly -name polyPanel -polygonType 1 -delta 0.13 panel;
print " \";
select - polyPanel.f[""];
SfaceList = 'filterExpand -sm 34';
polyChipOff -keepFacesTogether 0 polyPanel.f[0:(size(SfaceList) + 1)];
polySeparate -name smPanels polyPanel;
print " \";
delete smPanels;
print " rigidBodies \"
for ($i - 1; $i <= size($faceList); $i ++ ) {
rigidBody -active -damping 1 -collisions 0 -particleCollision 1
("smPanels" + $i);
collision -r 0.2 -f 0.2 ("smPanels" + $i);
connectDynamic -c ("smPanels" + $i) particle!;
Sexpstring = "\nif (frame == 1) {\n";
Sexpstring += ("rigidBody" + $i + ".particleCollision");
MEL Maya
346
+ $i + .impulseX");
+ $i *- -impulseZ");
+ $i + . velocityX");
+ $i + .particleCollision");
+ Si + .impulseX");
1;
print " \";
hide panel;
setAttr particleShapel.lifespanHode 1;
setAttr particleShapel.lifespan 1.0;
setAttr gun. spread 0.2; // ,
// gun, ,
cycleCheck -e off;
playbackOptions -min 1 -max 300 -loop continuous;
print " Gun Control . .. ,\n";
panelBreakup. mel scripts
, File > Source Script ( > ) Script
Editor (. . 17.65).
17. MEL
347
:;
. 17.65.
Source Script
exBstart, , File >
Open Scene ( > ) (. . 17.66).
*1
Save Scene
Open (...Mid SettirtQS\Ownert,My DQOI
Save Scene As..,
Save Preferences ' and SeffingsSOwner\Mji Docunents\
ocurnenls\i
Scena S~
import...
Look h: tJ scenes
Export All...
Export Setectlcn.;.
. 17.66.
Script Editor panelBreakup:
panelBreakup;
348
MEL Maya
. 17.67 ,
. 17.67.
panelBreakup
, -delta , .
.
Float e panelBreakup
'
-delta. panelBreakup :
global proc panelBreakup (float $myDelta) {
:
nurbsToPoly -name polyPanel -polygonType 1 -delta SmyDelta panel;
.
Maya,
Script Editor :
source panelBreakup;
ex8start :
panelBreakup 0.1;
,
panelBreakup:
// Error: panelBreakup; //
// Error: Wrong number of arguments on call to panelBreakup. //
18
, . ,
Maya MEL-,
. , .
. . 18.1.
. 18.1.
,
.
, - , , ,
, .
, ,
XZ.
350
MEL Maya
1:
-, , .
,
, Maya . ,
(. . 18.2).
. 18.2.
, ,
. Display > Grid > (
> > ) , . 18.3.
unili
unils
'
J~
. 18.3.
, , Window > View
Arrangement > Four Panes ( > > ) (. . 18.4).
. 18.5 .
18.
General Editors
Render-tig Editors
Animation Editors
Rslatfcnshti Editors .
Setthgs/Pr efer ences
351
Editor...
'Outlner,,,
Wypergraph...
P*it Effects..,
UV Texture Editor,..
Playbtet...
- .
Saved Layouts
Ssvs Curent Uyout..,
Frame All h Al Views
Frame Selection t\ Al Views
Rase Maki Window ;_ :
Balsa Atotten windows'
Pane
Two Panes adetJy..Side ,
Two Panes Stacked
TTrree Paries Spit Top
Three Panes Belt Left
Three Panes Spit Bottom
:
Three Panes clt Ritfit
. 18.5.
, (. . 18.6). Script Editor :
polyCube -name vehicle_1 -width 2 -height 2.5 -depth 2;
352
MEL Maya
. 18.6.
vehicle_l 2 X, 2.5 Y 2 Z.
, ,
_1. ,
,
Maya .
rigidBody vehicle.!,
rigidVehicle_1. (impulse) (
, ) rigidVehicle_1.
. Script Editor ;
rigidBody -name rigidVehiclO -active -mass 1 -bounciness 0
-damping 1.5 -position -10
-impulse 0.15 0 . 0 0 . 0 vehicle_1;
// Result: rigidVehicleJ //
rigidSolver rigidVehicle_1 .
rigidSolver , . rigidSolver
rigidVehicles, Maya .
Solvers > Rigid Body Solver ( > )
Dynamics () Maya Rigid Solver Display Options (
). Display Velocity (
) (. . 18.7).
18.
353
. 18.8.
12 -1302
354
MEL Maya
vehicle_1 , () 0.15 .
Outliner, Window > Qutliner, vehicle_l. Channel Box
Shapes rigldVehicle_l.
Impulse Z -0.15 Rewind () . MEL, setAttr:
setAttr rigidVehicle_1.impulseZ -0.15;
. 18.9 . ,
, vehicle_1.
. 18.9. ,
Z
Impulse X Impulse Z. , 0.1 1.0 , (. . 18.10).
. 18.10.
18.
355
vehicle_l
vehicle_1 . ,
. Window > Animation Editors > Expression
Editor ( > > ).
rigidVehicle_1:
r i g i d V e h i c l e _ 1 . i m p u l s e X = sin(time);
wander Expression Name ( ) (. . 18.11).
[]-jS election
Ibjeett
MnbuUt
Default Obiecl j
Always Evaluale
ff Al ' I
Pafcla P
[ JIOI
Urn
-f~
Expiiitin.Edita *]
t - .-
. 18.11.
wander
. 18.12.
MEL Maya
356
Attribute FJ:e;
Insert Functtons,
Editing Expiession
Expression Name |war,der
8
New Exp
YI Selection
^Expressions
Default Object j
P1 Always Evaluate
. 18.13.
Expressions () wander .
Impulse Z :
rigidVehicle_1.inpulseX = s i n ( t i n e ) ;
r i g i d V e h i c l e _ 1 . i m p u l s e Z = cos(time);
Edit () (. . 18.14).
(. . 18.15).
. ,
, :
rigidVehicle_1. inpulseX = sin(tirne);
rigidVehicel_1.impulseZ = cos(time * 2);
rigidVehicle_1-i(npulse* = sinftime):
rigidVthklO.ImpulstZ cos{tim):
. 18.14.
Edit
18.
. 18.15.
357
X Z
Edit (. . 18.16).
. 18.16.
vehicle_1
noise. noise ,
,
.
, . Expression Editor :
MEL Maya
358
rigidVehicle_1.impulseX = sin(time);
rigidVehicle_1.impulseZ = noise(time);
Edit (. . 18.17).
.
>
IS.
359
. 18.18. impulse X Z
vehicle_i
vehicle_1 , ,
. vehicle_1, , . ,
Y vehicle_1,
rigidVehiclejI. -, Attribute Editor rigidVehicle_1, Outliner
vehicle_1 Ctrl-A. Allow Disconnection ( ) Rigid Body Attributes ( ), ,
, (vehicie_i)
(rigidVehicle_l) (. . 18.19).
MjAltrDUte Editor: vf+!kte_l
i selected .Focus AftCutK^Hep_
vehicle,! | vehdTls4fe':>ifli<b'*deJ
HgidBody: iq*ehielej
. 18.19.
360
MEL Maya
setAttr MEL, :
setAttr rigidSolver.allowDisconnection 1;
rigidVetiicle_1 rotateY
:
disconnectAttr rigidVehicle_1ry.output vehicle_1. rotateY;
, Rotate Y Channel Box , ,
. vehicle_1
Y rigidVehicleJ. , ,
, , Rotate
Channel Box. , Maya
,
.
. 18.20 , . , , X Z.
. 18.20. ,
X Z, ,
, , . :
disconnectAttr rigidVehicle_1rx.output vehicle_1.rotateX;
disconnectAttr r i g i d V e h i c l e _ 1 r z . o u t p u t vehicle_1.rotateZ;
Expression Editor wander Select
Filter > By Expression Name ( > ).
. ,
, (
):
18.
361
//
float SxMuLt = 2.0;
//
float $fVel[ ] = 'getAttr rigidVehicleJ.velocity';
vehicle_1, rotateX = 0;
vehicleJ.rotateY = atan2d( JfVel[0], $fVel[2] );
vehicle_1.rotateZ = 0;
Edit, . ,
, , , ,
float $fVel[ ] = 'getAttr rigitiVehicleJ. velocity';
$fVel rigidVehicle_1 X, Y 2,
. , Maya , .
venicle_1.rotateX = 0;
0 X.
vehicle_1.rotateY - atan2d( $fVel[0], $fVel[2] ) );
( )
Z X Y, XZ.
vehtcle_1. rotateZ = 0;
0 Z, XZ, vehicle_1.
,
(. . 18.21).
? ,
-
MEL-, , Alias|Wavefront,
Highend3D.com . ,
MEL, MEL
, Maya. atan2d
Using Maya: Expressions.
MEL Maya
362
. 18.21.
. ,
, , .
2:
, ,
,
:
,
, ,
(followers), ,
(leaders). . 18.22
.
. 18.22.
18.
363
i
-, , , File > New Scene
( > ). MEL-:
file -force -new;
MEL- 1
, .
MEL-, rlgidSolver,
, ,
XZ.
// crowdSolver
rigidSolver -create -current -name crowdSolver
-velocityVectorScale 0-5
-displayVelocity on;
setAttr crowdSolver.allowOisconnection 1;
//
polyCube -name vehicle_1 -width 2 -height 2.5 -depth 2;
//
rigidBody -name rigidVehicle_1 -active -mass 1 -bouncineas 0
-damping 1-5 -position -10 0 0 -impulse 0.0 0.0 0.0
-solver crowdSolver vehicle_1;
disconnectAttr rigidVehicle_1ry.output vehicle_1.rotateY;
disconnectAttr rigidVehicle_1rx.output vehicle_1.rotateX;
disconnectAttr rigidVenicle_1rz.output vehicle_1. rotateZ;
//
SexpString = "//
.\";
$expString += "float $xMult = 2.0;\n";
SexpString += "float SzMult = 1.5;\n";
SexpString += "rigidVehicle_1.impulseX = sin(time * $xMult);\n";
SexpString += "rigidVehicle_1.impulseZ = (noise(tine} * $zMult);\n\n";
SexpString += "// Vehicle .\";
SexpString +=
"float $fVel[ ] = 'getAttr rigidVehicle_1.velocity';\n\n";
SexpString += "vehicle_1. rotateX = 0;\n";
SexpString += "vehic-. rotateY = atan2d( $fVel[0], $fVel[2] );\n";
SexpString += "vehicle."!. rotateZ = 0;\n";
364
MEL Maya
vehicle_i
.
, ,
, , . , ,
.
(radial field)
, // ,
polyCube.
//
polyCube -name vehicle_1 -width 2 -height 2 . 5 -depth 2;
//
radial -position 0 0 0 -name vehicleForce_1 -magnitude 50
-attenuation 0.3 -maxDistance 8.0;
parent vehicleForce_1 vehicle_1;
18,
365
,
vehicle.!. , , .
vehicle_1 ,
.
File > New Scene ( > ) .
MEL- Script Editor Enter
.
,
, , Outlmer
(. . 18.24).
,
. , ,
, . ,
, .
366
MEL Maya
(
):
//
// crowdSolver
rigidSolver -create -current -name crowdSolver
-velocityVectorScale 0.5 -displayVelocity on;
setAttr crowdSolver.alloy/Disconnection 1;
// :
polyCube -name vehicleF_1 -width 2 -height 2.5 -depth 2;
//
//
radial -position 0 0 0 -name vehicleFForce_1 -magnitude 50
-attenuation 0.3 -rnaxDistance 8.0;
parent vehicleFForce_1 vehicleF_1;
//
rigidBody -name rigidVehicleF_1 -active -mass 1 -bounciness 0
-damping 1.5 -position -10 0 0 -impulse 0.15 0.0 0.0
-standlnObject cube -solver crowdSolver vehicleF_1;
disconnectAttr rigidVehicleF_1ry.output vehicleF_1. rotateY;
disconnectAttr rigidVehicleF_1rx.output vehicleF_1. rotateX;
disconnectAttr rigidVehicleF_1rz.output vehicleF_1.rotateZ;
// VehicleF_1
texpString = "// ; ";
$expString += "//
.\";
$expString += "float SxHultl = 2 . 0 ; \ n " ;
SexpString += "float $zMult1 = 1 . 5 ; \ n " ;
SexpString += "rigidVehicleF_1.impulseX = sin(time * $xMult1);\n";
$expString +"rigidVehicleF^l.impulseZ = (noise(time) - $zMult1);\n\n";
$expString +=
"// Vehicle ,\";
$expString += "float $fVel1[];\n";
SexpString += "$fVe!1 = 'getAttr rigidVehicleF_1.velocity';\n\r";
SexpString += "vehicleFJ. rotateX = 0;\n":
SexpString += "vehicleF_1.rotateY = atan2d( $fVe!1[0], $fVel1[2] };\n";
$expString += "vehicleF_1.rotateZ = 0;\n";
expression -s SexpString -name wanderF_exp1 -alwaysEvaluate true
18.
-unitConversion all;
// :
polyCube -name vehicleL_1 -width 2 -height 2.5 -depth 2;
//
radial -position 0 0 0 -name vehicleLForce_1 -magnitude 50
-attenuation 0.3 -maxDistance 8.0;
parent vehiclel_Force_1 vehicleL_1;
//
radial -position 0 0 0 -name vehicleLeadGlobalForce_1 -magnitude -1
-attenuation 1.2;
parent vehicleLeadGlobalForce_1 vehicleL_1;
rigidBody -name rigidVehicleL_1 -active -mass 1 -bounciness 0
-damping 1.5 -position 10 0 0 -impulse 0.15 0.0 0.0
-standlnObject cube -solver crowdSolver vehicleL_1;
disconnectAttr rigidVehicleL_1ry.output vehicleL_1.rotateY;
disconnectAttr rigidVehicleL_1rx.output vehicleL_1.rotateX;
disconnectAttr rigidVehicleL_1rz.output vehicleL_1.rotateZ;
// VehicleL_1
SexpString = "// : ";
SexpString += "//
.\";
SexpString += "float $xMult2 = -2.0;\n";
$expString += "float $zMult2 = 2.5;\n";
SexpString += "rigidVehicleL_1.impulseX = sinftime * $xHult2);\n";
SexpString +=
"rigidVehicleL_1.impulseZ = (noise(time) * $zMult2);\n\n";
SexpString +=
"// Vehicle .\";
SexpString += "float $fVe!2[];\n";
SexpString += "$fVe!2 = 'getAttr rigidVehicleL_1.velocity';\n\n";
SexpString += "vehicleL_1.rotateX = 0;\n";
SexpString += "vehicleLJ. rotateY = atan2d( $fVe!2[0], $fVe!2[2] );\n";
SexpString += "vehicleL_1.rotateZ - 0;\n";
expression -s SexpString -name wanderL_exp1 -alwaysEvaluate true
-unitConversion all;
// ,
connectDynamlc -fields vehicleLForce_1 rigidVehicleF_1 ;
connectDynamic -fields vehicleGlobalLeadForce_1 rigidVehicleF_1 ;
connectDynamic -fields vehicleFForce_1 rigidVehicleL_1 ;
cycleCheck -e off;
367
368
TwoVehicles.meL
Script Editor Enter. ,
(. . 18.25). -,
, ,
wander.
. 18.25.
, , ,
.
wander, ,
, ,
, , .
, , ! .
, ,
. ,
.
, .
, ,
Create (). .
-
. / formLayout, . createCrowd.
. createCrowd -
18.
369
,
crowdSystem. ( ):
// createCrowd
global proc createCrowd ( )
<
// crowdSolver
(TwoVehicles.mel body)
cycleCheck -e off;
crowdSystem .
//
global proc crowdSystem { )
window
-title "Crowd System"
-widthHeight 300 200
crowdWin;
// Create
string $button1 = 'button -label "Create"';
//
formLayout -edit
-attacnForm $button1 "bottom" 10
-attachForm $button1 "right" 10
formLayout;
// createCrowd,
//
button -edit -command ("createCrowd; deleteUI crowdWin;") $button1;
showWindow crowdWin;
crowdSystem.mel.
, , File > New Scene ( >
), Script Editor:
file -f -new;
MEL Maya
370
, ,
, , :
source crowdSystem;
crowdSystern;
, (. . 18.26).
Create ().
Close (), .
i .:
. 18.26.
Crowd System
, .
, , ,
, , , . .
-
Script Editor ,
. mel , .
source crowdSystem;
crowdSystem;
,
(crowdSystem. mel),
crowdSystem, .
,
. ,
source.
,
, , Maya
18.
373.
, ,
MEL-, .
-, ,
,
; .
,
, (. . 18.27).
. 18.27. MEL-
.
, Shelf Editor ( )
, , .
:
// createCrowd
global createCrowd ( )
//
// crowdSolver
rigiuSolver -create -current -name crowdSolver
-velocityVectorScale 0.5 -displayVelocity on;
setAttr crowdSolver. alloy/Disconnection 1;
// :
polyCube -name vehicleF_1 -width 2 -height 2 . 5 -depth 2;
//
//
radial -position 0 0 0 -name vehicleFForce_1 -magnitude 50
-attenuation 0 . 3 -maxDistance 8.0;
parent vehicleFForce_1 vehicleF_1;
//
rigidBody -name rigidVehicleF_1 -active -mass 1 -bounciness 0
-damping 1.5 -position -10 0 0 -impulse 0.15 0.0 0.0
-standlnObject cube -solver crowdSolver vehicleF_1;
372
______ MEL _
18.
II VehicleL_1
Sexpstring = "//
. \";
Sexpstring += "float $xMult2 = -2.0;\n";
Sexpstring += "float $zMult2 = 2.5;\n";
SexpString += "rigidVehicleL_1 . impulseX = sin(time * $xMult2);\n";
Sexpstring +=
_ 373
MEL Maya
374
$form;
//
button -edit -command ("createCrowd")
showWindow crowdWin;
\
. (global field),
. . 18.28 .
. 18.28.
crowdSystem.mel
, 1 2 ,
Maya -
. , crowdSystem.mel
. , ,
MEL- crowdSystem .
-, Script Editor :
f i l e -f "-new;
, , MEL, 2, (. . 18.29).
Crowd System (. . 18.30) .
, .
18.
375
. 18.29. MEL-
,
. , X, polyCube 20 X Y Z 50 4 1 . Script Editor :
polyCube -name -sx 2 -sy 2 -sz 1;
376
MEL Maya
. 18.31.
(bounciness) 2.0, . -current
crowdSolver, .
,
.
, ,
(. . 18.32). ( 1- 500-
). , ,
, , .
. 18.32. ,
18.
377
, , ,
, ,
wander.
, ,
, .
.
, . 18.33.
MEL-, :
polyCube -name ob2 -sx 2 -sy 2 -sz 1;
polyCube -name ob3 -sx 2 -sy 2 -sz 1; polyCube -name ob4 -sx 2 -sy 2 -sz 1;
xform -worldSpace -translation 0 0 -20 -scale 50 4 1 ob2;
xform -worldSpace -translation 30 0 0 -scale 30 4 1
-rotation 0 90 0 ob3;
xform -worldSpace -translation -30 0 0 -scale 30 4 1
-rotation 0 -90 0 ob4;
. 18.33.
:
polyCube -name ob5 -sx 2 -sy 2 -sz 1;
polyCube -name ob6 -sx 2 -sy 2 -sz 1;
xform -worldSpace -translation 17 0 0 -scale 3 4 8 ob5;
xform -worldSpace -translation -17 0 0 -scale 3 4 8 ob6;
MEL Maya
378
. 18.34 5 .
. 18.34.
, ,
. , crowdSystem.mel, , - .
Script Editor MEL-,
collectObstacles. -, , polyCube ( ) . Is
, for, . polyCube Maya
ScollectObjects, :
string $collectObjects[ ] = 'Is -si';
p r i n t $collectObjects[0];
. :
string $collectObjects[ ] - 'Is -si';
// Result: ob4 ob2 ob6 5 //
print $collectObjects[0];
ob4
, , , Is
. , , , ,
for , , .
size(). :
size(ScollectObjects);
18.
379
:
size($collectObjects);
// Result: 5 //
for, ,
:
for ( $i = 0; $i < size($collectObjects); $i++) {
rigidBody -passive -name ($collectObjects[$i] + "RigidB" + $i)
-bounciness 2.0 ($collectOb]ects[$i]);
. Outliner, ,
, ', , (. . 18.35).
. 18.35.
. 18.36 .
, .
. 18.36. ,
380
MEL Maya
collectObstacles crowdSystem.mel
crowdSystem.mel
collectObstacles global proc createCrowd (
):
connectDynanic -fields vehicleFForce_1 rigidVehicleL_1;
cycleCheck -e off;
} II createCrowd
global proc collectObstaclesC) {
string ScollectObjects = "is -si';
for ( $i = 0; $i < size($collectObjects); $1++) {
rigidBody -passive -name ($collectObjects [$i] + "RigidB" + $i)
-bounciness 2.0 (ScollectObjects [$i]);
};
I
crowdSystem.mel, 4
, collectObstacles
.
, .
.,
, .
, . ,
. 150 X, -X, Z -Z.
.
,
(matrix) - ;
, .
, .
,
,
.
.
, ,
X, Y Z . Script Editor :
matrix $gFp[4][3] = 0, 0, -150; 0, 0, 150; 150, 0, 0; -150, , ;
18.
381
,
:
matrix $gFp[4][3] = , , -150;
, 0, 150;
150, , ;
-150, , ;
4 3 ,
.
0
-150
150
150
-150
, ,
:
print $gFp[0][0];
0, ,
. , 0. :
print $gFp[3][0];
-1 50, .
. for, . , , .
$compassForce,
. :
matrix $gFp[4][3] = , 0, -150; 0, 0, 150; 150, 0, 0; -150, ,
382
MEL Maya
, ,
. . 18.37
.
. 18.37.
.
, ,
.
connectDynamic -fields GforceN rigidVehicleF_1;
connectDynamic -fields GforceS rigidVehicleF_1;
connectDynamic -fields GforceE rigidVehicleF_1;
connectDynarnic -fields GforceW rigidVehicleF_1;
connectDynamic -fields GforceN rigidVehicleL_1;
connectDynamic -fields GforceS rigidVehicleL_1;
connectDynamic -fields GforceE rigidVehicleL_1;
connectDynamic -fields GforceW rigidVehicleL_J;
, ,
gun 17.
, ,
, ,
. ,
,
, ,
. , .
18.
383
, Script Editor,
.
string Swindow =
'window -t "Global forces control" -w 450 -h 150 GforceWin';
columnLayout;
floatSliderGrp -label "Force north" -field false -minValue 0.0
-maxValue 0.3 -value 0.0 magForceN;
floatSliderGrp -label "Force south" -field false -minValue 0.0
-maxValue 0.3 -value 0.0 magForceS;
floatSliderGrp -label "Force east" -field false -minValue 0.0
-rnaxValue 0.3 -value 0.0 magForceE;
floatSliderGrp -label "Force west" -field false -minValue 0.0
-rnaxValue 0.3 -value 0.0 magForceW;
//
connectControl magForceS GforceS.magnitude;
connectControl magForceN GforceN.magnitude;
connectControl magForceW GforceW.magnitude;
connectControl magForceE GforceE.magnitude;
showWindow $window;
. 18.38 , . 0.0 - 0.3,
- .
. 18.38.
384
MEL Maya
.
, ,
.
croivdSystem.mel
collectObstaclesO
crowdSystem.mel (, , ):
rigidBody -passive -name ($collection[$i] + "RigidB" + $i)
-bounciness 3.0 ($collection[$i]};
};
} // collectObstacles
global proc makeGforcesO {
//
matrix $gFp[4][3] = , 0, -150; 0, 0, 150; 150, 0, 0; -150, ,
18.
385
, ,
, ,
//Launch window control, Script Editor Enter.
, .
string $window = 'window -t "Global forces control" -w 450 -h 150
showWindow $window;
4:
,
.
, - , . . 18.39
.
. 18.39.
13-1302
MEL Maya
386
, crowdSystem.mel,
(. . 18.40 18.41).
. 18.40.
CrSys
, 18.41.
/ Crowd System
, 3, collectObstacles()
makeGforcesO, ,
, source MEL- , ,
crowdSystem. mel . Script Editor
, .
:
-, , 10 20 .
20 4 16 .
10 2 8 .
18.
387
{
window
-title "Crowd System"
-widthHeight 300 200
crowdWin;
string Sform = 'formLayout';
string $form = 'formLayout';
, 10 20
. 10
-select radioCollection.
radioButtonGrp
:
string $txt;
$txt = 'text -label "Number of Vehicles'";
string $collection = 'radioCollection';
string $radiob1, $radiob2;
$radiob1 = 'radioButton -label "10"';
$radiob2 = 'radioButton -label "20"';
setParent ..; setParent ..;
radioCollection -edit -select $radiobt $collection;
// 10
formLayout -edit
-attachForm $txt "top" 20
-attachForm $txt "left" 70
Sform;
formLayout -edit
-attachForm $radiob1 "top" 10
-attachForm $radiob1 "left" 20
-attachForm $radiob2 "top" 30
-attachForm $radiob2 "left" 20
Sform;
Script Editor window showWindow
crowdWindow, Enter. . 18.42 , . , . 18.43.
MEL Maya
388
! -
I
// -
string 1 = 'Button -label
') tol;
. 18.42.
IffilCrawd System
20
Number of Vehicles
. 18.43.
, ,
, .
, , , ,
. , , :
deleteUI -window crowdWin;
.
18.
389
10 20,
. radioButton -query. ,
, ,
, , ,
$radiob1 = $radiob2 = -onCommand :
Sradiobl = 'radioButton -label "10" -onCommand "SvNumber = 10"';
$radiob2 = ' r a d i o B u t t o n -label "20" -onCommand "SvNumber = 2 0 " ' ;
Script Editor Enter. , 10 radioButton
:
print SvNumber;
, Maya, ;
print SvNumber;
10
, 20,
SvNumber print:
print SvNumber;
, Maya, :
print SvNumber;
20
, , , 10
. 10 :
radioCollection -edit -select $radiob1 $collection;
, ,
, ,
.
setParent, radioCollection, ,
( ):
$radiob2 - 'radioButton -label "20" -onCommand "int SvNumber = 20'";
setParent . . ; setParent . . ;
string $txtOB = "text -label "Obstacles'";
string $collection2 = 'radioCollection';
string $radiob3, $radiob4;
$radiob3 = 'radioButton -label "On" -onCommand "tobst = 1"';
390
MEL Maya
18.
391
MCrowd System
& 20
Numbet of Vehicles
Obstacles
On
Global Forces
On
. 18.44, Crowd-System
print, $obst $gforces
Script Editor ' :
print $obst;
print Sgforces;
0, Off (), radioCollection -select
$radiob4 SradiobS. On radioButton, print , , , ,
1, On ().
Cancel
, Close, , .
Maya, Cancel Create, . ,
, ,
. ,
deleteUl, Maya Cancel.
// ,
:
//
string $button1 = 'button -label "Create"';
string $button2 = 'button -label "Cancel"';
$buttonl, , :
formLayout -edit
-attachForm $button2 "bottom" 10
MEL Maya
392
, 20:
Number oi Vehicles
Obstacles
Global Forces
. 18.45.
(* On f7 Off
Dn <? Off
Cancel
Maya ,
Cancel Create . ,
formLayout -edit , MEL-
:
formLayout -edit
-attachForm $button1 "bottom" 10
-attachForm $button1 "left" 185
$form;
formLayout -edit
-attachForm $button2 "bottom" 10
-attachForm $button2 "right" 10
$form;
formLayout, . -attachForm Maya,
, . ,
, left, right, top bottom.
crowdSystem.mel File > New (
> ) :
f i l e -f -new;
18.
, , ,
, . .
:
//
global proc crowdSystem()
{
window
-title "Crowd System"
-widthHeight 300 200
crowdWin;
string $form = 'formLayout ' ;
string $txt = 'text -label "Number of Vehicles'";
string Scollection = ' radioCollection' ;
string Sradiobl, $radiob2;
$radiob1 = 'radioButton -label "10" -onCommand "SvNumber = 10'
$radiob2 - 'radioButton -label "20" -onCommand "SvNumber = 20'
setParent . . ; setParent . . ;
string $txtOB = 'text -label "Obstacles'";
string $collection2 = 'radioCollection';
string $radiob3, $radiob4;
SradiobS = 'radioButton -label "On" -onCorrirnand "$obst - 1"';
$radiob4 = 'radioButton -label "Off" -onCommand "$obst = 0 " ' ;
setParent . . ; setParent . . ;
string StxtGF = 'text -label "Global Forces'";
string $collection3 = 'radioCollection 1 ;
string $radiob5, $radiob6;
SradiobS = 'radioButton -label "On" -onCommand "$gforces - V"
$radiob6 = 'radioButton -label "Off" -onCommand "$gforces = 0'
setParent . . ; setParent . . ;
radioCollection -edit -select $radiob1 $collection;
radioCollection -edit -select $radiob4 $collection2;
radioCollection -edit -select $radiob6 $collection3;
//
formLayout -edit
-attachForm $txt "top" 20
394
formLayout -edit
-attachForm $radiob3 "top" 80
-attachForm $radiob3 "left" 150
-attachForm $radiob4 "top" 80
-attachForm $radiob4 "left" 190
$form;
formLayout -edit
-attachForm StxtGF "top" 110
-attachForm $txtGF "left" 63
Sform;
formLayout -edit
-attachForm SradiobS "top" 110
-attachForm SradiobS "left" 150
-attachForm SradiobG "top" 110
-attachForm $radiob6 "left" 190
$form;
//
string $birtton1 = 'button -label "Create'
string $button2 = 'button -label "Cancel'
//
formLayout -edit
-attachForm Sbuttonl "bottom" 10
-attachForm Sbuttonl "left" 185
$form;
MEL Maya
18.
395
formlayout -edit
-attachForm .$buttori2 "bottom" 10
-attachForm $button2 "right" 10
$form;
//
button -edit -command ("createCrowd;deleteUI crowdWin;") $button1:
button -edit -command ("deleteUI crowdWin;") $button2;
showWindow crowdWin;
} // crowdSystem proc
, 10, 20 , .
, , . 10 20
, ,
3. 30 -30
X 20 -20 Z. , 120 -120 X Z.
, createCrowd().
crowdSystem.mel , crowdSolver.
, ,
,
, .
switch
Number of Vehicles ( ), $FvNumber JLvNumber , $vNumber
10 20. proc createC'rowdO (
):
rigidSolver -create -current -name crowdSolver
-velocityVectorScale 0.5 -displayVelocity on;
setAttr crowdSolver.allowDisconnection 1;
//
int $FvNumber;
int $LvtJumber;
switch (SvNumber)
{
case 1 0 :
396
MEL Maya
$FvNumber = 8; //
$LvNumber = 2; //
break;
case 20:
$FvNumber = 16; //
$LvNumber = 4; //
break;
.
// :
for ($i = 0; $i < SFvNumber; $i++) {
polyCube -name ("vehicleF_" + $i) -width 2 -height 2.5 -depth 2;
//
//
radial -position 0 0 0 -name ("vehicleFForce_" + $i)
-magnitude 50 -attenuation 0,3 -maxDistance 8.0;
parent ("vehicleFForce_" + $i) ("venicleF_" t $i);
//
//
rigidBody -name ("rigidVehicleFJ' + $i) -active -mass 1
-bounciness 0 -damping 1.5 -position
(rand(-120,120)) 0 (randC-120.120 -impulse 0 0 0 -standlnObject cube
-solver crowdSolver ("vehicleF," + $i);
disconnectAttr ("rigidVehicleF_" + $i + "ry.output")
("vehicleF_" + $i + ".rotateY");
disconnectAttr ("rigidVehicleF_" + $i + "rx.output")
("vehicleF_" + $i + ".rotateX");
disconnectAttr ("rlgidVehicleF_" + $i + "rz.output")
("vehicleFJ' + $i + ".rotateZ");
// VehicleF ,
// <
float $randX = rand(-3,3);
float SrandZ = rand(3,-3);
SexpString =
"//
.\";
JexpString += ("rigidVehicleF_" + $i + ".impulseX");
$expString += " = sin{time * ";
SexpString += ($randX);
SexpString += ");\n";
SexpString += ("rigidVehicleF_" + $i + ".impulseZ");
SexpString += " = (noise(time) * ";
18.
397
$expString += ($randZ);
$expString += ");\\";
SexpString +=
"// Vehicle . \";
JexpString += "float $fVel" + $r + "[];\n";
SexpString += "JfVelL" + $i +" = 'getAttr rigidVehicleF_" + $i +
",veloclty';\n\n";
SexpString t= "vehicleF_" + $i + ".rotateX = 0;\n";
SexpString += "vehicleF_" + $i + ".rotateY = atan2d( $fVel" + $i +
"[0], SfVel" + $i + "[2] };\n";
SexpString += "vehicleF_" + $i + ".rotateZ = 0;\n";
expression -s SexpString -name ("wanderF_exp" + $i)
-alwaysEvaluate true -unitConversion all;
} //
, rand - . , wander wander.
, $>:Mult
$zMult, .
. ,
,
, . , , L
(leader), F, (follower).
$fVel, . $fVe!L<>[], <> - . , SfVelL
$fVelL1[], -$fVe!2[] . .
, ,
GlobalLeadForce . , , , .
, attenuation
maxDistance 50 .
(
):
} //
// :
for ($i = 0 ; $i < $LvNumber; $i++) {
398
MEL Maya
18.
399
MEL Maya
400
. 18.46.
, 10 20 . ,
,
. ,
,
wander.
,
01.>
,
. int crowdSystem(),
createCrowd( ) .
// , 3,
:
for ($i = 0 ; Si < $LvNumber; $i++ ) {
// ,
for ( $j = 0; $j < SFvNumber; $j++) {
connectDynamic -fields ("vehicleLForce_" + $i)
("rigidVehicleF_" + $j);
connectDynamic -fields ("vehicleGloballeadForce_" + $i)
("rigidVehicleF_" + $j);
\
18.
401
for ($j = 0; $] < SLvMumber; $j++) {
connectDynamic -fields ("vehicleFForce_" + $i)
("rlgidVehicleL_" + $j ) ;
f o r . ,
.
crowdSystem.mel . MEL (. . 18.47). ,
,
, .
: 18.47.
, , 3. ,
. :
// ,
//
for ($i = 0 ; $i < SLvNumber; $i++) {
for <$j = 0 ; $j < SLvNumber; $j++) {
connectDynamic -fields ("vehicleLForce_" + $i)
402
MEL Maya
("rigidVehicleL_" + $j);
}
connectDynamic -delete -fields ("vehicleLForce_" + $i)
("rigidVehicleL." + $i);
}
for ($i ^ 0; $i < SFvNumber; $i++) {
//
for ($j - 0; $j < SFvNumber; $j++) {
connectDynanic -fields ("vehicleFForce_" + $i)
("rigibVehicleF_" + $j);
}
connectDynamic -delete -fields ("venicleFForce_" + $i)
("rigidVehicleFJ1 + $i);
}
(-delete) ,
.
, , , , ,
.
,
, , .
SgForces, ,
makeGforces(). global proc tnakeGforcesO,
,
// . -, ,
. twitch (
):
break;
if (Sgforces == 1) makeGforces; //
// :
int createCrowdQ,
crowdSystem(). createCrowd(),4To6bi
, :
18.
_______
_ ____ _
crowdSystemO $gforces (
):
button -edit -command
f "createCrowd IvNumber $gforces; deleteUI crowdWin;"} $button1;
, Jgforces 1 ( ,
Global Fields ( )). //
if ( .):
connectDynamic -delete -fields ("vehicleFForce_" + $i)
("rigidVehicleF_" + $1);
// ,
//
if (Sgforces == 1) {
string $compass[4] = { "N", "S", "E", "W" };
for ($i =0; $i < $LvNumber; $i++) {
for (So = 0 ; $c < size($compass); $c++) <
connectDynamic -fields ("Gforce" + $compass[$c])
("rigidVehicleL_" + $i);
)
for ($1 = 0 ; Si < $FvNumber; $it+) {
for ($c = 0 ; $c < size($compass); $c++) {
connectDynamic -fields ("Gforce" + $compass[$c])
("rigidVehicleF_" t $i);
}
;
}
,
, , Scompass, ,
.
, , Global
Forces ,
. MEL- . , Global Forces Create (. . 18. 48).
MEL Maya
44
. 18.48.
,
. ,
, Window > Relationship Editors > Dynamic Relationships...
( > > ...) (. . 18.49).
General Editors
Rendering Editors
*" ll
ition Editor:
... > Settings/Preferences
Attribute Editor... .
Outliner,.,
Hypergraph...
, s Paint Effects..,
UV Texture Editor.,,
. 18.49.
*
Sets...
Deformer Bets...
Character Sets...
Partitions,..
Display Layers...
Render Layers..,
Dynamic Relationships
vehicleF_0 ,
(. . 18.50).
18.
405
ELECTION MODES
1f
hiclsfFacn.5
. 18.50.
, vehicleF_0
, . -, ,
Maya
. ,
. Main ,
. , , ,
.
makefilobalForces () ;
//
//
46
MEL
Maya
} else {
ScollectObjects - 'Is -si'; //
crowdSystem; // crowdSystem
confirmDialog ,
. , Confirm.
,
Script Editor Enter (. . 18.51):
confirmDialog -t "Already running!"
-m "Please close Crowd System window and create a New Scene";
-~~~-~~~-~-~~~~-
Already running!
. 18.51.
ScollectObjects
,
.
, , }', ,
.
,
crowdMainO, crowdSystemO MEL crowdMainO.
, , ,
. Script Editor
, ,
.
source crowdSystem;
crowdMain;
collectObstacles
collectObstacles,
,
. createCrowd
( ):
18.
407
cycleCheck -e off;
} // createCrowd
//
. 18.52.
48
MEL Maya
Obstacles (). polyCubes (. . 18.53).
. 18.53.
, , ,
-120 120 X Z.
(. . 18.54).
Obstacles () Global Forces
( ), Create ().
Global Forces , (. . 18.55).
18^^
. 18.55.
409
, ,
, ,
, . !
,
- ,
,
. ,
. rand
.
croivdSystem.mel
.
hide
.
^^^S^\S\S\S\^y\jS\S^j^^^
I/ createCrowd
//
global createCrowdfint JvNumber, int Sgforces, int Sobst)
//
<
//
// crowdSolver
rigidSolver -create -current -name crowdSolver
-veiocityVectorScale 0.5 -displayVelocity on;
41
1._
SLvNumber;
switch (SvNurnber)
{
case 10:
SFvNumber - 8; //
SLvN'jmber = 2; //
break;
case 20;
SFvNumber = 16; // "'
$l_vNurnber = 4; //
break;
Maya
18.
// VehicleF ,
//
float $randX - rand(-3, 3);
float SrandZ = rand(3,-3);
SexpString =
"//
. \";
SexpString += ("rigidVehicleF_" + $i + ". impulseX");
SexpString += " = sinftime * ";
SexpString += (SrandX);
SexpString += ");\n";
SexpString += ("rigidVehicleF_" + $i + ". impulseZ");
$expString +- " - (noise(time) * ";
SexpString += ($randZ);
$expString += "); \n\n";
SexpString +=
"//
. \";
SexpString += "float $fVel" + $1 + "[];\n";
SexpString += "$fVel" + $i +" = 'getAttr rigidVehicleF_" + $i +
". velocity' ; \n\n";
SexpString += "vehicleF_" + $i + ".rotateX = 0;\n";
SexpString += "vehicleF_" + $i + ".rotateY = atan2d( SfVel" + $i +
"[0]. SfVel" + $i + "[2] );\n";
411
412
MEL Maya
18.
//
//
for ($i = 0; $i <- SLvMumber; $i++) {
//
for ($j - 0; $j < SLvNumber; $j++) {
413
414
MEL
// ,
if ($obst 1) collectObstacles;
//
cycleCheck -e off;
} II createCrowd
//
global proc collectQbstaclesQ {
global string $collectObjects[];
//
if (size($collectdbjects) == 0) {
warning "No obstacle objects were selected.";
} else {
for ( $i = 0; $1 < size($coLlectObjects); $i++) {
rigidBody -passive -name (ScollectObj3cts[$i] + "RigidB" + $i)
-bounciness 2.0 ($collectObjects[$i]);
\
\
} collectObstacles
Maya
18.
II
global makeGforces() {
//
matrix $gFp[4][3] = , 0, -150; 0, 0, 150; 150, , ;
string $compassForce[] = {"N", "S", "E", "W"};
for ($i = 0; $i <4; $i++) {
radial -name ("Gforce" + $compassForce[$i]} -position $gFp[$i][0]
$gFp[$i][1] $gFp[$i][2] -m 0 -att 0;
hide ("Gforce" + $compassForce[$i]);
};
// createCrowd
//
if ('window -exists GforceWin') // ,
//
deleteUI -window GforceWin;
string {window = 'window -t "Global forces control" -w 450 -h 150
GforceWin' ;
columnLayout;
floatSliderGrp
-label "Force north" -field false -minValue 0.0
-maxValue 0. 3
-value 0.0 magForceN;
floatSliderGrp
-label "Force south" -field false -minValue 0.0
-maxValue 0. 3
-value 0.0 magForceS;
floatSliderGrp
-label "Force east" -field false -minValue 0.0
-maxValue 0. 3
-value 0.0 magForceE;
floatSliderGrp
-label "Force west" -field false -minValue 0.0
-maxValue 0, 3
-value 0.0 magForceW;
//
//
connectControl nagForceS GforceS. magnitude;
connectControl magForceN GforceN. magnitude;
415
416
MEL Maya
/I
global proc crowdSystem()
window
-title "Crowd System"
-widthHeight 300 200
crowdWin;
string $form = 'formLayout';
string $txt = 'text -label "Number of Vehicles'";
string $collection = 'radioCollection';
string $radiob1, $radiob2;
$radiob1 = 'radioButton -label "10" -onCoromand "SvNumber = 10'
$radiob2 = 'radioButton -label "20" -onCommand "SvNumber = 20'
setParent , . ; setParent ..;
string ItxtGB = 'text -label "Obstacles'";
string $collection2 - 'radioCollection';
string SradiobS, $radiob4;
$radiob3 = 'radioButton -label "On" -onCommand "$obst = 1'";
$radiob4 = 'radioButton -label "Off" -onComrnand "Sobst = 0"';
setParent ...;setParent ...;
string StxtGF = 'text -label "Global Forces'";
18.
string $collection3 = 'radioCollection';
string $radiob5, $radiob6;
$radiob5 = VadioButton -label "On" -onCommand "Sgforces = 1"';
$radiob6 = 'radioButton -label "Off" -onCommand "Sgforces = 0"';
setParent ...; setParent ...;
radioCollection -edit -select $radiob1 Scollection;
radioCollection -edit -select $radiob4 $collection2;
radioCollection -edit -select $radiob5 ScollectionS;
//
forrnLayout -edit
-attachForm $txt "top" 20
-attachForm $txt "left" 70
Sform;
formLayout -edit
-attachForm Sradiobl "top" 10
-attachForm $radiob1 "left" 20
-attachForm $radiob2 "top" 30
-attachForm $radiob2 "left" 20
Sform;
//
formLayout -edit
-attachForm $txtOB "top" 60
-attachForm $txtOB "left" 80
Sform;
formLayout -edit
-attachForm $radiob3 "top" 80
-attachForm $radiob3 "left" 150
-attachForm $radiob4 "top" 80
-attachForm $radiob4 "left" 190
Sform;
formLayout -edit
417
418
MEL Maya
$form;
//
string $button1 = 'button -label "Create"';
string $button2 = 'button -label "Cancel"';
//
formLayout -edit
-attachForm $button1 "bottom" 10
-attachForm Sbuttonl "left" 185
Sform;
formLayout -edit
-attachForm $uutton2 "bottom" 10
-attachForm $button2 "right" 10
Sform;
//
button -edit -command
("createCrowd SvNumber $gforces $obst; deleteUI crowdWin;")
Sbuttonl;
button -edit -command ("deleteUI crowdWin;") $button2;
showWindow crowdWin;
} // crowdSystem
19
MEL
MEL ,
,
. , , ,
, .
MEL- , ,
. . , MEL-,
, MEL
,
.
, Maya
.
, ,
. ,
Maya. . 19.1 ,
.
1:
,
, , ,
. 2 .
-, mrBlah.mb. File > Open Scene ( >
) mrBlah.mb, Web-.
i
420
MEL Maya
. 19.1.
. 19.2 , .
Maya -. , Display > Joint Size > 25% ( >
> 25%). Hypergraph
, ,
.
. 19.2. mrBlah.
19. MEL
421
mrBlah ,
.
mrBlah_skeleton, mrBlah.
, Show ()
Polygon () (. . 19.3).
mrBlah_skeleton, , (IK handles) .
. 19.3.
mrBlah
.
mrBlah,
.
. , . , , ,
Transform (), , (. . 19.4).
MEL Maya
422
. 19.4. r_foot
Outliner r_foot.
Outliner (. . 19.5) ( ,
, Shift
+).
/7
Z7
!
Z7
7
Uot
r_heelPivot
MoePivoi
r_ankle
r_ankle!K
L-toe
rJoelK
19. MEL
423
. 19.6. IK-
, r_foot,
Roll. r^foot Attribute Editor ( )
(Ctrl-a), Roll Extra Attributes (
) (. . 19.7).
Node Behavior
Extra Attributes
Roll 0.000
424
MEL Maya
. 19.8. Roll
, Roll ,
Graph. Editor ( ), Windows > Animation Editors > Graph Editor
( > > ), r_h eel Pivot,
r_toePivot r_ankle Outliner. Graph Editor ,
RotateX (. . 19.9).
. 19.9. , Roll
Roll 0, rjtoePivot
( Hide Selection ( ) Ctrl-h).
.
19. MEL
425
Attribute Editor r_foot, ,
Scale 1.0. ,
.,
. Channel Box, , Scale .
,
.
- , - ,
. r_wristLocator r_elbowLocator.
r_wristLocator mrBlati, a r_elbowLocator
m_pelvisShift. , m_elbowLocator mrBlah .
Move, , . ,
r_wristLocator Outliner, (. . 19.10).
426
MEL Maya
. 19.11. ,
, mrBlah
.
,
, . Outliner
spineCtrl mrBlah (. . 19.12 . 19.13).
delaiJlLighlS*t
defaullDbiectSet
19. MEL
427
. 19.13. spineCtrl
Script Editor MEL,
. MEL-
Enter :
addAttr -In Side -at double -keyable 1 |rnrBlah|spineCtrl;
, |
, . ,
, ,
.
,
.
,
,
. Script Editor :
a d d A t t r -In Twist -at double -keyable 1 | m r B l a h | s p i n e C t r l ;
addAttr -In Bend -at double -keyable 1 | m r B l a h | s p i n e C t r l ;
spineCtrl Attribute Editor ( )
Extra Attributes ( ) (. . 19.14).
428
MEL Maya
Bend jO.000
. 19.14.
,
. . 19.15 , , m_backO m_back4.
,
X, Y Z 0 4. Expression Editor, Window
> Animation Editors > Expression Editor ( > > ), :
//
// Side. Twist Bend
m_backO.rotateZ = -spineCtrl.Bend;
m_back1.rotateZ = -spineCtrl. Bend;
n_back2.rotateZ = -spineCtrl.Bend;
m_back3.rotateZ = -spineCtrl.Bend;
m_back4. rotateZ = -spineCtrl.Bend;
m_backO. rotateX = spineCtrl.Twist;
m_back1. rotateX = spineCtrl.Twist;
m_back2. rotateX = spineCtrl.Twist;
m_back3. rotateX = spineCtrl.Twist;
m_back4.rotateX - spineCtrl.Twist;
m_backO.rotateY = -spineCtrl.Side;
m_back1.rotateY = -spineCtrl.Side;
m_back2. rotateY = -spineCtrl.Side;
m_back3.rotateY = -spineCtrl.Side;
m_back4. rotateY - -spineCtrl.Side;
19, MEL
429
. 19.15.
mrBlah_expression Expression Name ( )
Create () (. . 19.16).
fsetect Filler
Object F
dealing Express ion
. 19.16.
MEL Maya
430
spineCtrl
Bend .0
SHAPES
19. MEL
431
mrBlati ,
. Expression Editor
( ) Select Filter > By Name ( > ).
mrBlah_expression (. . 19.19).
j Select ion
Objects
_^
"""
Allibutes
. 19.19.
mrBlah_expression no
, :
//
m_backRoot. rotateY = { l_foot.translateY * 2)
- ( r^foot.translateY * 2);
m_backRoot.translateX = (-l_foot.translateY / 4)
- (-r_foot.translateY / 4);
Edit (), .
r_foot, Move,
Y (. . 19.20).
, . , ,
r_foot l_foot Y,
Y 2, , ,
Y. , .
r_foot l_foot no Y 4,
, . , .
MEL Maya
432
. 19.20.
. 19.21.
19. MEL
433
, ,
. 2 mrBlah.
2:
, mrBlah.
, Bend, Twist Side,
. , ,
, ,
. ,
, (. . 19.22).
. 19.22.
mrBlah
, mrBlah 1, , File > Load Scene ( > ),
mrBlah..
, ,
. , . Script
Editor :
hide mrBlah^skeleton;
MEL Maya
434
, , , 1, ,
Windows > Animation Editors > Expression Editor > Select Filter ( > > > ), By Name
( ). rarBlah_expression (. . 19.23).
1<
fcr
. Dealing Enpiettion
ixpietsion Name |
^JsrfSin
Dbiecli
_*
,__^
. 19.23.
^,
**
AUiibulei
mrBlah_expression no
', - ,
, . , , .
, .
. 19.24 .
,
, .
r_wrist Locator 1 wrist Locator
r_eiboLocator
l_elbowLocator
r_foot
l_foot
m_backRoot
spineCt rl
Side, Twist Bend
19. MEL
. 19.24.
435
mrBlah
. ,
;
HiRes: NURBS- , .
LoRes: ,
, .
Joints: .
Key ,
.
mrBlahControls.mel
mrBlahControls. mel. mrBlahControls():
global mrBlahControls ( ){
window
-title "mrBlah Controls"
-widthHeight 450 450
MBcontrols;
436
MEL Maya
mrBlahControls .
:
string Sforrn = 'formLayout';
//
1
string $txt1 = 'text -label "Right Arm
Left Arm ";
1
string $txt2 = 'text -label "Waist" ;
string $txt3 = 'text -label "Right Foot
Left Foot"';
1
string $txt4 = 'text -label "Display ";
$form formLayout,
formLayout. , Right Arm Left
Arm, , Right Arm Left Arm
49 - ,
, .
, :
//
//
string $ = 'button -label "Arm"
-command "select - r_wristLocator r_elbowLocator"';
string $b2 = 'button -label "Wrist"
-command "select -r r_wristLocator"';
//
string $ = 'button -label "Arm"
-command "select -r l_wristLocator l_elbowLocator'";
string $b4 = 'button -label "Wrist"
-command "select -r l_wristLocator"';
//
string $b5 = 'button -label "Waist" -command "select -r m_backRoot"';
//
string $6 = 'button -label "Foot" -command "select -r Mxjot"';
//
string $7 = 'button -label "Foot" -command "select -r l_foot"';
//
string $6 = 'button -label "HiRes"
-command "int $dis = 1;displayFunc($dis)'";
string $b9 = 'button -label "LoRes"
-command "int $dis = 2;displayFunc($dis)'" ;
string $b10 = 'button -label "Joints"
-command "int $dis = 3;displayFunc($dis)"';
19. MEL
___
437
$dis;
switch (Sdis) {
case 1 :
HideJoints;
hide "*_stdin";
Sdis switch ,
. case 1 , , , , , mrBlah . *_stdin , , _stdin .
, ,
.
438
MEL Maya
,
, case 2 , case 3
, , .
// global proc
Key, ,
. MEL- :
//
s t r i n g $KEYframe = 'symbolButton -image "setKey.xprn"
-parent S f o r m
-command setkeys';
columnLayout;
symbolButton Maya, setKey.xpm, (. . 19.25).
. 19.25.
setKey. xpm
setKey.xpm , Maya
, . , ,
, , .
columnLayout.
-command keyframe setkeys . , ,
:
global proc setkeys() {
string $names[ ] = ' l s -si';
if ($names[0] != "m_backRoot") {
string Sname;
f o r ($name in $names) {
setKeyframe ($name + " . t x " ) ;
setKeyframe ($name + " . t y " ) ;
setKeyframe (Sname + ".tz");
}
} else {
setKeyframe m_backRoot.ty;
setKeyframe m_backRoot.tz;
19. MEL
439
setkeys , is -si
'
$names[ ]. , m_backRoot, , ,
X.
m_backRoot [0] ,
, for-in. for-in
, z . setkeys
, , Arm, ,
, , , .
m_backRoot ,
.
spinCtrl
Bend, Key Twist. columnLayout :
// spineCtl
floatSliderButtonGrp -label "Side" -field true -buttonLabel "Key"
-buttonCommand "select -r spineCtrl; setKeyframe spineCtrl.Side"
-minValue -20.0 -maxValue 20.0
-value 0.0 Side;
connectControl Side spineCtrl.Side;
floatSliderButtonGrp -label "Twist" -field true -buttonLabel "Key"
-buttonCommand "select -r spineCtrl; setKeyframe spineCtrl.Twist"
-minValue--20,0 -maxValue 20.0
-value 0.0 Twist;
connectControl Twist spineCtrl.Twist;
floatSliderButtonGrp -label "Bend" -field true -buttonLabel "Key"
-buttonCommand "select -r spineCtrl; setKeyframe spineCtrl.Bend"
-minValue -45.0 -maxValue 45.0
-value 0.0 Bend;
connectControl Bend spineCtrl.Bend;
Key,
setkeys. , select -
setKeyframe. , ,
, (. . 19.26).
440
MEL Maya
. 19.26.
MEL-, ,
. formLayoijt,
(top) (left) , .
formLayout -edit,
, :
//
formLayout -edit
-attachForm $txt1 "top" 80
-attachForm $txt1 "left" 100
-attachForm $txt2 "top" 160
-attachForm $txt2 "left" 100
-attachForm $txt3 "top" 220
-attachForm $txt3 "left" 100
-attachForm $txt4 "top"-280
-attachForm $txt4 "left" 100
$form;
, , , ,
, ,
. :
//
int SbOffsetW = 180;
int $bOffsetH1 = 80;
int $bOffsetH2 = 140;
formLayout -edit
-attachForm $b1 "top" 98
-attachForm $ "left" 80
-attachForm $b2 "top" 120
-attachForm $b2 "left" 80
$form;
formLayout -edit
-attachForm $b3 "top" 98
-attachForm $b3 "left" (80 + SbOffsetW)
19. MEL
441
Script Editor ,
, :
source mrBlahControls;
mrBlahControls;
. 19.27 , , .
MEL Maya
442
. 19.27.
mrBlah
. Move
, . Display
Key, , .
, :
deleteUI MBcontrols;
, 1.- ,
.
Show () . , .
Show , . 19.28,
.
19. MEL
443
. 19.28.
Close () ,
, ,
. .
scriptNode, .
Script Editor )':
scriptNode -beforeScript "source mrBlahControls;mrBlahControls;"
-n Controls;
setAttr Controls.scriptType 2;
scriptType 2 ,
Maya. ,
.
File > Save Scene As ( > )
m r Blah Animation. mb scenes (. . 19.29).
MEL Maya
444
Save Preferences
,
, , ,
. Script Editor :
if ( ' w i n d o w -exists Mbcontrols') deleteLII MBcontrols;
source m r B l a h C o n t r o l s ;
nrBlahControls;
He , , , (. . 19.30).
Igph
hfMTSS
.'< ;
MScript Editor
if ('window-adstsMBojnMs'Jtteieteui MBcontrols;
source mrBlahContrals;
mrBlahControjs;
. 19.30.
mrBlah
19. MEL
mrBlahControls.mel
global setkeysf) {
string $names[J ='ls -si';
if ($narnes[0] != "m_backRoot") {
string $name;
for ($name in $names) {
setKeyframe ($name + ",tx");
setKeyframe ($name + ".ty");
setKeyframe ($name + ".tz");
}
} else {
setKeyframe m_backRoot. ty;
setKeyfrarne m_backRoot.tz;
__
445
446
MEL Maya
MBcontrols;
string Sform - 'formLayout';
//
string $txt1 = 'text -label "Right Arm
Left Arm'";
string $txt2 = 'text -label "Waist"';
string $txt3 = 'text -label "Right Foot
Left Foot"';
string $txt4 - 'text -label "Display"';
//
//
string $b1 - 'button -label "Arm" -command
"select -r r_wristLocator r_elbowLocator"';
string $b2 = 'button -label "Wrist" -command
"select -r r_wristLocator"';
//
string $ = 'button -label "Arm "-command
"select -r l_wristLocator l^elbowLocator"';
string $b4 - 'button -label "Wrist" -command
"select -r l^wristLocator1";
//
string $b5 = 'button -label "Waist" -command "select -r m_backFoot"';
//
string $6 = 'button -label "Foot" -command select -r r_foot'";
//
string $7 - 'button -label "Foot" -command select -r l_foot"';
//
string $8 - 'button -label "HiRes" -command
"int $dis = 1 ;displayFunc($dis)'";
string $b9 = 'button -label "LoRes" -command
"int $dis = 2;displayFunc($dis)"';
string $ = 'button -label "Joints" -command
"int $dis = 3;displayFu'nc($dis)'";
// Keyframe
string $KEYframe = 'symbolButton -image "setKey.xpm"
-parent $form -command setkeys';
ColumnLayout;
// spineCtl
floatSliderButtonGrp -label "Side" -field true -buttonLabel ""
19. MEL
-buttonCommand "select - spineCtrl; setKeyframe spineCtrl.Side"
-minValue -20.0 -maxValue 20.0
-value 0.0 Side;
-45.0
-maxValue 45.0
447
448
Sform;
formLayout -edit
-attachForm $b5 "top" (98 + $bOffsetH1)
-attachForm $b5 "left" 80
$form;
formLayout -edit
-attachForm $b6 "top" (98 + $bOffseth2)
-attachForm $b6 "left" 80
$forrn;
formLayout -edit
-attachForm $b? "top" (98 + $bOffsetH2)
-attachForm $b7 "left" (80 + $bOffsetW)
$forrn;
formLayout -edit
-attachForm $b8 "top" 305
-attachForm $b8."left" 80
-attachForm $b9 "top" 305
-attachForm $b9 "left" 118
-attachForm $ "top" 305
-attachForm $b10 "left" 158
$form;
formLayout -edit
-attachForm SKEYframe "top" 170
-attachForm $KEYfrarne "left" 360
Sform;
show/Window MBcontrols;
MEL Maya
.
MEL-
, ,
. ,
MEL-.
1. ?
2. ?
3. , ?
4. ?
, ?
, ?
, ?
5. ,
, ?
1. ?
?
2. ?
-
-
-
15-1302
450
MEL
-
-
-
3. , ?
1. ?
2. ,
, ?
3. ?
,
, ?
, , , ?
,
?
4. , ?
[ ?
?
?
5. ,
, ,
?
, , ,
, MEL.
MEL,
, ,
. - , Maya, ,
.
MEL- , , .
MEL
, , Web-
USENET, 2.
Alias|Wavefront,
, ,
.
MEL Maya (API), , Morgan Kaufhiann,
Complete Maya Programming: An Extensive Guide to MEL and the C++
API, (David Gould) ( 2002, ISBN 1-55860-835-4).
,
Maya MEL API
, .
15-
-- (
), 128
! ( not), 128,165
" (), 108
$ ( ), 53
% ( ), 127,129,132
&& ( and), 128,166
* ( ), 49
... (), 205
.m el , 257
/ ( ), 50,126
// ( ), 35
: (), 199
; ( ), 35
\ ( ), 54,115
" ( ), 56, 89
| ( ), 192
|| ( or), 129,166
++ ( ), 128
= ( ), 44-45
= = ( ), 45
$,, 284
addAttr, , 105,114
age, , 91-92
Alias|Wavefront, Web-, 41
allowDisconnect, , 359-360
and, (&&), 128,166
angle, , 72
Attribute Editor ( )
Extra Attributes (
), , 106
, , 286
, 50, 286-288
, 14-15
, 50, 87
, , 81, 272-276
Boolean () , 13
Boolean () , 128-129,
165-166
break, , 166-167
- (create), , 40,141
Cancel, , 214, 391-392
case, , 166-167
Channel Box
, .
Expression Editor ( )
, 14
, 300-301
, , 24-25
columnLayouts, 232-233,237-241,
248-249,252
Component Editor
( ), 76
conflrmDialog, , 214-215
connectAttr, , 107
connectDynamic, , 115, 302,
312-313
Connection Editor ( ), 15,49
Create Particle Disk Cache, , 97,98
create Node, , 152,154
cross, , 72-73, 90
crowdSystem.mel, 409-418
Curve Flow, cnoiiCTBo, 86
D
DG- .
DG Node Reference, 12,155
dot, , 73
duplicate, , 184
Duplicate, , Edit
(), 26
Dynamic Relationships (
), , 312-313
dynExpression, , 283
- (edit), , 40,104-105
else, , 157-164
Enter, , 31
eval, , 143-144
Expression Editor (
)
, 293-294
, , 83
, 279
, 44, 50
, , 258-259
expression, , 107
F
fileDialog, , 217
float .
floatSIiderGrp, ,
244-245
, , 131
for
, , 400-402
, 335
, 168
, 169-171
for-in 168,169
form Layouts
-attachForm, , 392
, 249
, , 440^141
, 368-369
frameLayouts, 232-233, 237-240, 249-250
Friction (), , 306, 311
G
geometry-Constraint, , 179*180
getAttr, , 47-48, 56, 67,106
getenv, , 258
453
Highend3D, Web-, 41
Hypergraph
Scene Hierarchy ( ), , 24
, 18-21
, 16
, 16
, , 24-25
, 20
, 18-19
, 19
I
if-else, , 157-164
int(), , 131
intFieldGrp, , 221, 245
isConnected, , 107,154
Key, , 438
L
Lifespan Mode, , 95
linstep, , 294-295
list (Is), , 103,146-149
listConnections, , 153
listRelatives, , 152-153,155
Is, , 103,146-149
mag, , 71
makeSpheres, , 223-228
match, , 218-228
MEL, Maya, 99-101
MEL command Reference, 105,140
MEL- .
eval, , 143-144
Script Editor, , 34-39
Source, , 37, 42
whatls, , 39
, 141
, 144
, 31
, 105, 141
, 139
454
Object () , , 327
offsetCurve, , 93-94
or, (|{), 129, 166
Outliner, , 24-25
particle, , 114,262
pointOnCurve, , 88-89, 94-95
polyCube, , 325, 351, 375
polyNormal, , 326-328
poly Plane, , 300
polySphere, , 327
Postforum.com, Web-, 41
proc, , 177
promptDialog, , 216-217
Q
-q (query) , 40, 105,141
R
ramp, , 80
rename, , 193
Resilience (), , 306,311
Rigid Body Solver, 331-332,352, 407
rot, , 73-74
rowColumnLayouts, 232-233,237-241,250
rowLayouts, 232-233, 237-241, 250, 252
S
Scale ,
, 425
Script Editor ( )
Enter, , ., 33
source, , 37, 42
, 36
, , 34
, 34
, 32
, 32, 38-39
, 38-39
, 32-33
, 33, 2(9
, 38
, 4
, 109
, 268
setAttr, , 47-48, 56, 67,106
setParent, , 235, 239-240
showWindow, , 338
source, , 37,42
switch, , 157-160,
166-167
Tessellation Factor ( ),
, 305
time, , 55, 284
tokenize, , 134,197-198
Trace Depth ( ),
, 306
turbulence, , 330
U
U, V, , (UVs),
269-270, 279-280
unit, , 71, 72
W
warning, , 215, 217-218
Web-, Maya, 41-42
whatls, , 39, 292
while, , 168-169
X
xform,
,
, 281
, 321
, 323
, 289
, 328-329, 343
. ,
, 57-60
455
, 69-74
, , 127, 129, 132
, 128
, 126-127
, 128
, 127
, 126-128
* ( ), 49
/ ( ), 50
Expression Editor ( ), 44
getAttr, 47-48, 56
MEL Maya, 47-48
selAttr, 47-48, 56
, 49
, 46-47
, 55
, 48
, 66-67
, 44
, 50
, 48
, 43
, 49-50
, 52-55
, 67
, 61-65
, 48
, 51
, 44-45, 56
(= =). 45
, 46-47
, 50
, 43-44
, 52
456
, 12
, , 63
, 49-50
, 12
, 68, 75-79
, 12
, , 49-50
14
, 105-106, 286-288
, 106
, 59
, , 200
, 12
Editor . Attribute Editor
( )
MEL-, 100
.
, 50
, 107
, 13
, 107
, 106
, 12-15
, 123
.
, , 328-329, 343
, 352
, , 330-332
, 360-361
angle, , 72
cross, , 72-73, 90
dot, , 73
mag, , 71
rot, , 73-74
unit, , 71, 72
, 70-71
,
, 132-133
, , 69-70,
83-84, 132
, , 89
, , 137
, 72
, 131-132
,)33
, 69, 131
,
, 73
, 69
,
, 73
, 69-70, 132
, 265-267
, 70
, 59-60
, 263-265,282-285,294-397
, 350
, 15
rot, , 73-74
, 359-360
, , 428-430
,
, 263
,
makeSphereS; , 223-228
, 222
, 223, 226-228
, 212-214
, 218-221
, 450
, 22) -222, 226, 227
, 124
select, , 49-151
, 151
, 150
, 114
, ,
103-104, 148
, 149
, 150
, 112
, 150
, 175
, 179
, 251-252
, 177
, 257
, , 107-108
dynExpression, , 116
gelAttr, 47-48, 56, 67, 106
MEL Maya, 47-48
MEL- , 144
setAttr, 47-48, 56, 67, 106
.
, 46-47
, 48
, 66-67, 107-108
, 108
, 44
expression, 107
, , 318-319
, , 354-359
, 48
, 62
.
, 43
, 49-50
, , 99
, 64
, 52-55
.
, 428-430
, 67
, 48
, 51
457
, 44-45, 56
, 44-45
(= =), 45
, 46-47
. Expression Editor
( )
. 18
, 18,43-44, 107-108, 116
, 61-65
.
,, 115
, MEL-, 100
, 52
. ,
,
, 178-181
.
,
, 251-255
, , 56-67
, , 405-406
, 121-123
, 55
, 121-123
, 191
.
.
, 12
, 15
.
, 147
, , 233, 235
(:), 199
(/), 50, 126
458
floatFieldGrp, , 243-244,
252-255
floatSliderGrp, , 244-245
, 52-53, 129
, 126-127
, 129-130
, 13, 129-130
, 222
, 130-131
, 130
, 222
, 129
-attachForm, , 392
Cancel, , 214, 391-392
columnLayouts, 232-233, 237-241,
248-249, 252
confirmDialog, , 214-215
error, , 218
fileDialog, , 217
floatFieldGrp, , 243-244,
252-255
floatSliderGrp, , 244-245
formLayouts . fonnLayouts
frameLayouts, 232-233,237-240,249-250
Gun, , 337339
intFieidGrp, 245
intSliderGrp, 245
makeSpheres, , 223-228
match, , 218-228
promptDialog, , 216-217
rowCotumnLayouts, 232-233,
237-241,250
rowLayouts, 232-233,237-241, 250, 252
setParent, , 235, 239-240
warning, , 215, 217-218
, 230
, ,
251-255
, 233, 235
, 209
.
, 208
, 232
, 449-450
, 209, 232, :!36-237
, 233
,
, 232, 235-241, 253
, 212-214
, 406
.
, 29, 232-233, 235-241,
248-250
, 231
, 206
, 234-235
, 209
, 392-395
, .
, , 235,239-240
, 211-212
.
, 214
, 230-232
, 209-210
.
, , 436
, , 368-374,
386-409
. ,
.
, 207
.
,
.
. ,
connectDynamic, , 115,302,312-313
Friction (), , 306, 311
Resilience (),
, 306, 311
, 328-329, 343
, 307
.
,
, 308-320
. ,
,
, 299-308
,
.
,
,
NURBS,
, 340-342
NURBS-, , 336-337
, 347
, 344
, , 337
, , 339-340
,
, 338-340
, , 348
, 341-342
, 345-346
, , 343
, 336
, , 342-344
, , 342-343
($), 53
, 152-153
, 22-24
459
, 278-279,344
3
(locked) , 12
(turbulence), , 334
, 209
, 105,141
, 258
, , 425-426
, 200
, , 352-354
,62
-, 40-42
Cancel, , 214
columnLayouts, 232-233, 237-241, 252
confirmDialog, , 214-215
error, , 218
fiieDialog, , 217
Gun Control, , 337-339
makeSpheres,
, 223-228
match, , 218-228
Maya API, 206
MEL-, , 28-29
promptDialog, , 216-217
warning, , 215, 217-218
, 208
, 103-104
, , 204
, ,
251-255
.
, 209
.
, 203-204
, , 209
460
, 208
, 204-206
, 203
. ,
, , 208
, 212-214
. ,
, 231
, 206
, 214-215
, 206-207, 449-450
, , 103-104
, 218-228
.
MEL-, 100, 101
, 211-212
.
, ,
368-374, 386-409
, 207-208
, , 108
.
, 210, 237-240,
242-243
.
, , 32
, , 94-95, 151
, 28
, , 94, 151
,
338-339
, , 114,
301-302
, 80
, 90-93
, 114-115, 302
, 113-1 , 271
("), 108
, , 89
, 130
, 16--18
-attachForm, , 392
Cancel, 391-392
-command, , 242, 437
textFieldButtonGrp, 245-246
, , 233, 235
, 242
, 210
, 253-255
, 392
.
, 36
, 214
, , 241
, 31
, 31-32
Script Editor ( ),
, 34
, 3 2
MEL. MEL-
Script Editor ( ),
, 32
, 31-.J2
, 38, 42
, 35, 6:1
, 449-450
;, 41
, , 308-320
, , 285
, 130
, 121,123
, 57-58,178-181
, 137
, , 89
, 380-382
, 88, 135
, 134
, , 136-137
, 135-137
, , 136
, 112, 291
, 49-50
,
, 321
.
;
, 380-382
, 13
, 233
MEL-, 99-101
(nonkeyable)
, 12
,
, 280-298
, 172-175
, 15
, , 363
461
, 72
, 89
, 94
, , 326-328
, 89
, 75-79, 307, 313
, 55,
120-123
("), 56, 89, 142
, 54,112,133
, 75-79
, 68
.
, 146-149
, 148
, 223,
226-228
, 131-132
, 135
, 52-55, 61, 118-120
, 133-134
, 126
, 129
, 75-79
geometryConstraint, ,
179-180
- ,
, 178-181
, 67
, 179-180
, , 83
, 57-58
.
, 204-206
, , 232, 235-241,
253, 338-339
462
, 126-128
, 128-129, 165-166
, 131-133
, 125
, 51
,
, 85, 97
, , 94-95
, , 405-406
,
, 449-450
, 127
, MEL-, 100
,
,128
error, , 218
, 64
, 106
, 54-55, 118-119
, 131
, , 41
.
, 327-332,331,
375-380
whatls, , 292
.
, 124
, 55,121-123,191, 405-406
, 121, 123
, , 405-406
.
, 380-382
, 190
, 55, 120-123
, 52-55, 61, 138-120
, 52
, 123
, 123
, , 124
, 118-120
, 54-55
, , 175-177
([]) .
, 61, 190-191
, 124
.
, 124
, 13
dynExpression, , 116
, 8
, 74
, 83
, 275, 294-297
,
formLayouts, 440-441
key, , 438
mrBlahControls.mel, , 445-448
setkeys, , 438-439
, , 434-435
, 436
, 443
,1
, 444
, , 434-435
, 433
, 437
, 440-441
, . 439-440
, 442-443
, 433
, , 443-444
, 436
, 441-442
1-, 422-423
Roll, , 42.1-424
Scale, , 425
,
, 427-428
, 428-430
. ,
, , 425-426
, .
, 431-433
, , 425-426
, , 421-424
, , 426-430
MEL , 419
, 420
, , 425-426
, , 420
.
, 30-31
, , 60-61
, 67
, 101-102
, 449-450
, 101-102
, 101-102
planes
NURBS-, , 270,
280-281
, , 299-300, 320-321
. NURBS-
, , 451
, 328
, 303-305
makeSpheres, , 223-228
, 222
, 223, 226-228
, 212-214
, 218-221
, 450
, 221-222, 226, 227
, , 38,42
463
NURBS, , 340-342
polyChipOff, , 342
polySeparate, , 342
Tessellation Factor
( ), , 305
, 307
, 341
, 322-323
, , 321
, 310
, , 326-327
, 330-332
, 299-300, 320-321
, 341-342
, , 299-308
, , 321-322
, , 351
,
MEL-, , 260
Shelf Editor ( ), 260-261
, 260
, 103
, 36, 109
, 260
, 193
, 68, 83-84
,
, 258
, , 209, 232-233.,
235-241,248-250
DG Node Reference, 12
MEL command Reference, 105, 140
whatls, , 39
-, 40-42
, 138
, 123
-,
. Boolean ()
464
MEL-, 99-101
, 118-120,131
,
, 375-380
, 194-199
, 118-120,131
, 118-120,131
, 51
, 128
, 44-45, 56,106,127
, 75-79,307, 313
, 449
If-else, , ,
, 164-166
, 134
(= =), 45
, 328
, 130
, 206-209
, 172-175
MEL-, 449-450
, , 325
, 328-329
, 199
, 200
, , 201
, 199
, 201
, 201-202
, 199,201
, 201
, 201
, 125
, , 177
, 175-177,399
, 179,251-252
, 121-123
, 175-177, 179
, 176
, , 179-180
, 175
, 124,175
, 399
, 231
, 18 , 288
, 181-186
, 314-317
, 189
, , 178-179
, , 230
, , 182-186
, , 316
, 41, 257-258
, , 149
, (=),44-45
, (= =), 45
, 380-382
,
402-403
, 397
, 364-368
, 209
, , 24
, 80
, 56-67
makeSpheres,
, 223-228
, 223,226-228
, 218-221
, 221-222
, 222
floatSliderGrp, ,
243-244, 383
Gun Control, , 337-339
intSliderGrp, 245
, 210
,
, 439-440
, 104-105
, 12
,
, 31-32
,181-186
, Rigid Body Solver, 331-332,
352,407
, , 265
/,
listRelatives, , 152-153, 155
parent, , 115
, 23, 26-27
, 22-24
connectAttr, , 107
connectDynamic,
, 115, 302, 312-313
connectionlnfo, , 153-154
disconnectAttr, , 107
isConnected, , 107, 154
listConnections, , 153
, 15, 18, 107
, 19-20
MEL-, 100
, 49
, 343
, 329,342
, 153
, 114-115, 302, 312-313
radioButton, , 387-389
radioButtonGrp, , 239-240,246-248
, 233
, 210
, , 389
, 386-392
,
.
, 220
465
MEL-, 39-40
, , 283-286
, 135
, 41 -42
.
, 353
, 359-362
, 85
, 320
noise, , 357-358
rand, , 397
, (//), 35
, 50
-count, , 314
event, , 314
, 317-319
, 315-316
, 314
, 308, 314
, 314-317
, 314
, , 314
( ), 192
rename, , 193
, 188
, , 189-191,193-194
, 202
, . 189-191,193-194
,
, 147
, , 190
, 190-191
, 188-189
, 194-199
, 189
, , 190-191
,189-190
466
, , 193-194
, 192-194
, 191-194
, 194
, 189
, MEL, 99-101
, 104
dynExpression, , 116, 283
, 83
, 98
, 74
, 273-276, 283
.
, 37
,
, 108-118
, 86-97
,
, 108-116
, 86-97
.
collision, , 303-304
Friction (), , 306, 311
NURBS-, 306
Resilience (),
, 306, 311
Tessellation Factor
( ), , 305
Trace Depth ( ),
, 306
, 299-308
, 308, 314-320
,
.
,
, 305-306
, 214
-current, , 376
, 328-329
, 320
, 328-329
, , 326-328
, 327,
330-332, 375-380
, , 320-321
, , 328-329
, , 332
,
, 333-334
, 54,115
\ ( ) , 133-134
match, , 218-221
tokenize, , 134, 197-198
, 103-104
, 220
} , 335
, 112, 291
, 133-134
, 133
, 213
, 134
, 134
, 198, 218-221
, 220
, 13
MEL-, 39-40
polySphere, , 327
sphere, , 178-179
, 263
, 328-329
, , 25
, 25 7-258
, 99,258-259,261,443-444
, 189-190
, 37
floatFieldGrp, 243-244, 252-255
intFieldGrp, 244-245
promptDialog, ,
, 216-217, 227
textFieldButtonGrp, 245-246
texlFieldGrp, 241,246
, 210
, , 268
, 199
float .
int .
string .
whatls, , 292
, , 286
, 55, 118-119
.
, 118-120
, 125
, 135
, 13
, 52-55
, , 103
,
allowDisconnect, , 359-360
Cancel, , 391-392
Create, , 368-370
rigidSolver,yinbi, 352
wander, , 355-358, 360-361
, 357-358
, 353
,
, 405-406, 406-407
, 354-359
, ,
384-385,402-403
, ,
405-406
, 368-374,
386-409
467
, , 352-354
, 368-374,
386-409
, 371
, 397-399
, 380-382
, 349
, , 409
.
, 354-359
,
359-362
, , 405-4(36
, 385-409
, 375-380
, 365-368
,
, 359-360'
, 409-418
, , 375-380,
405-406, 406-407
, 364-368, 380-382, 397,
400-402
, 382-384
, , 350
, 402-403
, 397,
400-402
, 386-392
, 406
, , 374-385
,
, 362-374
,
, 350-352
,
, 395-399
,
, 363-364
-, 370-371
, , 352
468
, 408-409
, 360-361
,
, 402
(;), 35
, , 230
, 87
, 90-91, 93-94
Hypergraph, , 24
listRelatives, , 152-153, 155
Outliner, , 24-25
, 23
, 22
,
, 194-199
/, , 22-24
, 192-194
, 192-194
, , 31 -32
, 24
, 20
, 25
, 130
(...),205
, (|), 192
, 107,
360-361
DG Node Reference, 12
createNode, , 152, 154
listRelatives, , 152-153, 155
Is, , 103, 146-149
select, , 149.-151
.
, 15
, , 151
.
, 97
.
, , 94-95, 151
,
, 31-32
, 12
, 149
, 146-149
, 191
Hyperf;raph, 16
, 199-202
, 22-23
MEL-, 100
. (
, 191-194
, 17-18, 151, 154
, 12
, 154
, 192-194
.
.
, 268
i *), 49
, , 182-1 }(6
,, 166-167
case, , 166-167
if-else, . 157-164
switch, , 157-160, 166-167
, 165-166
if, 163-164
, 156-157
, 156
.
MEL-, ;;57-261
, 66-67, 107-108
, 258
, 261
, 258-259, 261
. setAttr,
, 49
, 101
, , 316
, 40
, MEL-, 40,141-142, 256.
, 210,237-240, 242-243
, 24-25
, 20
, 25-26
.
MEL, 41
, -, 40-42
, , 177
, 175-177
, 175
, 177
, 177
, 176
, 175
, 124, 175
, 187
, 129
, 189
, 333-334
, , 265
469
, 272-273
, 263-265,
282-285, 294-297
NURBS-, 271-272
Expression Editor (
), 293-294
, 275, 294-297
, 273-276,283
, , 280-288
, , 278-279
, (CV), 272, 275-276
, , 273
, 280-298
, 262-263
, 262-263
, , 265-267
, 291-292
intFieldurp, 245
intSliderGrp, 245
, 53-54, 118, 126
, 126-128
, 13, 53, 126
, 221-222,
226, 227
, 130-131
, 221
. . for
for-in, , 168, 169
while, , 168-169
, , 400-402
, 156-157
, 156
,168
ramp, , 80
.
, 272-273
, 68
, 85
82, 83
470
Attribute Editor
( ), 272
, 74
dynExpression, , 116
Expressions After Dynamics, ,
.
. 80
, 97, 98
, , 85
, 98
, 84-85, 97
, 74
, 74
, ,
85, 97, 98
, 98
, , 80-83
, 80
, 74
, , 86-97, 108-116
,, 115
.
. ,
, 265
,
Trace Depth ( ),
, 306
.
,
, 180-288
,
, 280-298
, 75-79
, 68
, 75-79
, 80-81
, 68
,
, ''5, 114
, , 86-97, 108-116
.
.
,
, 321-322
,
Duplicate, ! , 26
-, 23, 26-27
, 26-17
.
floatFieldGrp, 243-244, 252-255
floatSliderGrp, 244-245
Gun Control, , 337-339
intFieldGrp, 245
intSUderGrp, 245
.
, 209, 234
. -
.
.
, 210, 237-240, 242-243
, 101
Web-
Maya: MEL.
: Maya 3.0 .
Maya: MEL, Maya, .
MEL- ,
, MEL-. , ,
, .
. ,
adcLprefixjto_seletion.mel change_selection_prefix,mel 11
, a validFloat, validObjectName
validlnteger
. .
, ,
, . .
,
melscnrjling@yaliQQ.com,
, , .
3'
eyes_vl. mel - 1 , ,
.
eyes_v2. mel - 2 ,
472
4*
newtonfield.mel - , 4, , , , , ,
, .
paraboloid, mel - .
splralpartlcles_v1. rael 1 .
spiralparticles_v2.mel - 2 .
5' MEL-
spiralparticies_v3.mel - MEL-
.
. 7* MEL-
eval_example. mel - MEL-, eval.
;
geom._const_loc.mel , , , .
makeAntenna.mel -
MEL-.
it: ,
add_prefix_to_seletion.mel - , ,
<prefix>_<name>.
change_selection_pref ix. mel - <pref ix> <name>, <prefix> .
13: MEL
hunt_for_blah.mel - , prtimptDialog,
, >;
, blah.
Web-
473
makeSpheresUI.mel , promptDialog
confirmDialog ,
, , , .
validFloat.mel - , , ,
Maya ,
validlnteger.mel-, , ,
Maya .
validObjectName.mel - , , Maya.
14:
exampleDialog.mel - MEL-,
,
,
makePrimitivelll.inel - , ,
(makePrinitive), )',
, (butt on Act ion), ,
.
i6t MEL
helloGoal. nel - helloGoalQ,
,
Ctiapter16Example2.mel - , 2
. ,
, ,
, , .
Chapter16Example3. mel - , 3
. ,
, ,
, ,
ballTravel.mel MEL-, ,
chapter16.ma.
chapter16. ma-, 4.
474
MEL ^
Chapter16Example4.mel ~ , 4
. ,
, ,
, , ,
17' MEL
Chapter17Example1. mel , 1
. ,
, ,
, , .
chapterl?. - , 2.
Ctiapter17Example2.mel - , 2
. ,
, ,
, , .
Chapter17Example3.rael - , 3
. ,
, ,
, , .
Chapter17Example4. mel - , 4
. ,
, ,
, , .
panelflreakup.mel - MEL-, NURBS, , 4, .
18: t
Chapter18Exaraple1. mel - , 1
. ,
, ,
, , .
crowdSystemi.mel - crowdSystem
- ( 1).
OWeb-
475
1 MAYA
.,
?
,
,
,
MEL Maya
, Maya
,
2 MEL-
11
12
22
24
24
28
29
30
MEl- ?
(command line)
(command feedback line)
,
(Command Shell)
,
(Script Editor)
MEL
(shelf button) MEL-
MEL-...
whatls
MEL-
Maya MEL
, MEL
8
11
..;:.,
?
..;...
?
:
Maya
Maya- , MEL?
30
30
31
32
32
34
34
36
37
38
39
39
40
42
43
43
43
44
44
46
47
477
( )
?
Maya
48
49
51
52
67
68
;
:
Maya
68
68
69
74
85
97
5 MEL-
99
MEL Maya:
MEL-
, MEL
, MEL
MEL
MEL
MEL-
99
99
101
103
104
105
107
107
116
118
( )
MEL
MEL
118
118
124
124
125
137
7 MEL-
MEL-?
MEL-
MEL- MEL-
MEL-
MEL-
139
139
139
:...,. 141
142
144
144
8 MEL
Is
select
MEL-
146
.146
146
,.149
.151
152
153
478
MEL Maya
154
155
156
:
,
: if-else
'.
,
MEL
10
156
156
157
168
171
172
?
,
MEL
'.
172
172
175
11 ,
188
187
188
188
189
190
191
199
201
12 MEL
203
Maya MEL-
,
,
MEL
13 MEL
203
203
204
206
207
209
210
211
211
,
211
:
212
confirm Dialog
214
promptDialog ...216
fileDialog...217
Warning Error
.
217
218
219
221
( )
MEL
14
,
,
MEL
15 MEL-
,
Maya
MEL-
16 MEL
17 MEL
18
crowdSystem.mel
19 MEL .....
mrBlahControls.mel
.
MEL-
-.
Web-
479
222
,223
,.228
230
,.230
230
232
241
248
256
257
257
257
258
,.258
260
260
261
262
,.,.265
265
299
349
409
419
445
449
449
449
450
451
452
471
476
-
.: (095) 333-82-11; ok@kudit:;.tu http://books.kudits.ru
V
. . -,
(81622) 73-188 . 34
000 "" - ,
. , . 9 (8172)75-21-43
,
(10-380-62) 381-9232
812
"
' ^ ( ) 312-01-84
" ,.00,107,
(812)567-70-25,567-70*6
"';-,;;2,(8452)32-98-14
*
"",. , 147
"", ./: (3472)50-39-00
"", . , 100, (8612) 5941-32
. ^ 70
"", . , 88
""
"", . , 106
., 9,
-
{375-17} 219-73-90, 219-74-01
"", .,39
hooks@tut.by,
(375-17) 219-73-S8
" ", . , 28,
(0572) 549-116
"+",
-8-
,
.
Jamagic
.
Jamagic:
ISBN 5-93378-095-2
ISBN 5-9579-0008-7
AYA
. .
. . II
Maya:
gmax:
ISBN 5-9579-0026-5
ISBN 5-93378-098-7
.
Maya 4:
30 3D
.
ISBN 5-9579-0006-0
ISBN 5-93378-057-
. . .
. . , . .
.
Cfj
#.
:
ISBN 5-9579-0011-7
ISBN 5-9579-0001-
.: 333-82-11,
11 17. : . , . 84/32, . 6, . 11
(
ISBN 5-93378-097-9
-
./: (095) 333-82-11,333-65-67
E-mail: ok@kudits.ru; http://books.kudits.ru
121354, , / 18, "-"