maya cod mel

484

Upload: mihail-filipenco

Post on 20-Oct-2015

225 views

Category:

Documents


3 download

DESCRIPTION

Programare maya

TRANSCRIPT

  • "-"

  • MEL Scriptingfor Maya Animators

    Mark R. WilkinsChris KazmierWith contribution fromStephan Osterburg .

    MORGAN KAUFMANN PUBLISHERSAN IMPRINT OF ELSEVIER SCIENCE

    www.mkp.com

  • . ,

    MAYA:

    MEL

    -

    2004

  • . ,

    Maya: MEL /. . - : -, 2004. - 480 . , -

    MEL - Maya . no MEL, - , .

    , -

    , .

    , ,

    .

    Maya, - .

    ISBN 1-55860-841-9ISBN 5-93378-097-9

    . ,

    Maya: MEL-

    . . .

    . .

    -.

    ! 19034, , ., . 21, 1. .: 333-82-11, [email protected] 16.06.04 70x90/16. . r i i " i ; i i i . ^- .. . . 35,1. 2000. : 1302 117623, . , . , . 10.

    ISBN 1-55860-841-9ISBN 5-93378-097-9 -, 2004

    Copyright 2003 by Elsevier Science (USA)Translation Copyright 2004by.KUDITS-OBRAZA l l rights reserved. 2003 Elsevier Science () 2004 - .

  • Maya: MEL MEL.

    , -

    , MEL. - ,

    .

    - (Doug Cooper), ,Dreamworks Feature Animation

    Maya: MEL , - , . -

    , .

    ,

    .

    - (Henry LaBounta), ,Electronic Arts

    ,

    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 DisneyFeature 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, . - (crowd system)2 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).

    (dependency graph node) , 3D .

    Channel Box3 Attribute Editor Maya, - .

    , ,

    (transform hierarchy), .

    Outliner, Hypergraph Connection Editor , .

    , , -

    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

    Channel Box, Maya, ( directionalLlghtl directionalLightShapel), (. . 1.2.). Channel Box keyable , . -

    Attribute Editor(. . 1..). . - MEL- .Channels Object cti onalL ia til

    Translate xTranslate VTranslate Z

    Rotate XRotate VRotate 7.Sea ID XScale VScale ZVisibility

    ' SHAPESdire cti onalLlg

    Color RColor GColor

    MensltyUse Ray Trace S, , Shad Cotor R

    Shad Color Shed Color

    Use Do pi hi Map SDmap Bias

    ' Ls.0

    6 ' Attribute fdito.; directkmoltiflhEl ~List Selected Focus Attributes Help

    dnectionaliflhtl drectsnoH-ight Shape! I delaullLighlSel |

    direclionalLighl: pwclionaLighlShape!

    Intaisty Sample

    7! Dileclional Light Attribute!Type I Directional Light ]Cota

    h.OOOinale* bjiDelaul

    Em*Diffuse $ ErnirSpeoda j Shadow*

    ! Piv 1haHJnn/4hniir^ .BU,

    Select Load Attributes Copy Tab

    . 1.. Attribute Editor

  • 1. Maya

    Attribute Editor , , . ,

    . 1.3, Directional Light Attributes . , AttributeEditor, , -, .

    Attribute Editor Attributes. To, - MEL, .

    ,

    .

    , . ,

    , , , -

    , , ,

    ,

    .

    Connection Editor (. . 1.4.).

    Options Left 5 Filet! R.fjh: Sde Filers Help!' Reload Lalt '-.

    0(4ts horn >"= locator! i|

    CachingNode Stale

    t> Bwndng Boxt>

    MatrixInverse MatrixWoridMaliixWorld Ir.eise Mahi nil ]biRn'jpiUse Object ColClb;ecl Cctar

    (

    3

    ifimovs

    . 1.4. Connection Editor

    , .

    , -

    , , -

    . , ,

    (upstream) , , , (downstream) 6. , May ,

    Maya, 4.5, upstream () downstream (), , input output ( ). - . . .

  • 16 MEL Maya

    , , 3D Studio Max Softimage .

    -

    Hypergraph (. . 1.5.), , Window > Hypergraph... . Hypergraph , , Graph >Up and Downstream Connections7 .

    . 1.5. Hypergraph

    , Up and DownstreamConnections . , Hypergraph - , ,

    Hypergraph . , , ,

    .

    , Maya , , , .

    , .

    (. . 1.6.) - , , , 10- 20- .

    , 4.5, Input and Output Connections. -. . .

  • 1. Maya 17

    = 0 = 10 = 20

    . 1.6.

    . , . 1.7, .

    makeNurbSpherel nurbsSphereShapel nurbsSpherel

    . 1.7. ,

    (. . 1,8), , translate Y nurbsSpherel . , timel Maya - - - , . -

    translate Y . , Maya , .

    timel nurbsSpherel jranslateY(animation curve)

    makeNurbSpherel 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. Frame 20, , Translate Y - 10.

    8. ,9. , , Window > Hypergraph...

    Hypergraph, Alt + 8, - , . ,

    , 9.

    10. Graph > Up and Downstream Connections10 Hypergraph. , ,

    , . 1.10.

    . 1.10.

    Hypergraph Hypergraph, . Alt + + , Alt + - - -. , ,

    , .

    . -

    . ,

    Backspace Delete. , ,

    - , - . - .

    . .

    , - -

    . - . . .

    ' , 4.5 Input and Output Connection. -. . .

  • 2 . MEL Maya

    () (Connection Editor) , .

    , ,

    (), () (), .

    . 1.10 nurbsSphere1_translate Y n u r b s S p h e r e l . (transform node), nurbsSphereShapel (shape node). , , ,

    , .

    , , Hypergraph Up andDownstream 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 m a k e N u r b S p h e r e l , 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.

    Grandparenttx= 0 1=

    Parenttx = 1 ty =

    Childtx = 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 , ,

    , .

    , , -

    .

  • 24 MEL Maya

    Maya , . -, Scene Hierarchy Hypergraph . , Window >Hypergraph... , - Graph > Scene Hierarchy Hypergraph.

    . Scene Hierarchy , ,, !

    Outliner Window > Outliner... Outliner , , , ,

    [+] [-] (. . 1.14).

    . 1.14. Outliner Hypergraph

    .

    , ,

    , ,

    : , , ,

    . .

    , Outliner , : (transform node), ,

    , (shape node), - , . -

    . 1.6, , , NURBS- , nurbsSphereShapel , -

  • 1^ Maya 25

    nurbsSpherel, Outliner. n u r b s S p h e r e l , a nurbsSphereShape- NURBS.

    ( NURBS-, - , , , ), . , ,

    MEL, -, .

    Outliner, Display > Shapes . Hypergraph, Options >Display > Shape Nodes Hypergraph.

    2: ,

    , Maya , , -

    Maya , .

    -, :

    1. Maya File > New Scene.2. Create > NURBS Primitives > Sphere.

    , .

    Channel Box, n u r b s S h p e r e l - . 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

    Display. Show Help

    JiP persp

    w top

    ffl 3jf tFDnt JJ? side

    -

    ^ nurbsSphereShapel(2) defaullLightSel(5 defaullObjectSet

    . 1.15. nurbsSpherei Outliner

    , , n u r b s S p h e r e i , Channel Box , m a k e N u r b S p h e r e l , , -. Channel Box, , .

    Duplicate :1. nurbsSpherei Outliner, .1. Edit > Duplicate > .3. Duplicate Instance Geometry Type.4. Apply.5. , Geometry Type, .

    . , -

    , , ,

    !

    Outliner, , nurbsSphere2. . , [+]. - , nurbsSpherei(. . 1.16). ,Maya , ,

  • 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 ' 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, , ,

    .

    , m a k e N u r b S p h e r e l , - , Maya ,

    , , -

    . Hypergraph m a k e N u r b S p h e r e l :

    1. m a k e N u r b S p h e r e l Attribute Editor... .

    2. Attribute Editor , , , , .

    3. Attribute Editor.4. nurbsSphereShapel, .5. Maya Edit > Delete By Type > History,

    Hypergraph .

    Hypergraph , makeNurbSphsre l .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 ScriptEditor. , MEL- MEL, Script Editor.

  • 1. Maya 29

    2 , MEL-, - , .

    , May

    Maya, Maya , , ,

    , .

    .

    MEL - , , ,

    .

    Hypergraph , Upstream ( -), Downstream ( ), Up and DownstreamConnections.

    , / (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.

    1 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&here l , :Result: nurbsSpherel makeNurbSpherel

    sphere, , - , ( -

  • 32 - MEL Maya

    , MEL-, ). nurbsSpherel - , a m a k e N u r b S p h e r a l - . ,

    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

    1. File > New Scene No, .2. ,

    Window > General Editors > Script Editor...3. , ,

    ,

    , - , .

    4. sphere Enter .Maya . )'

    :

    sphere;//Resul t : n u r b s S p h e r e l makeNurbSpherel//

    , .

    Enter Ctrl Enter Return , , .

    , -

    , , Maya -. , Enter, - . :

    1. sphere.2. Enter .3. .4. Enter.5. cylinder.6. Enter.7. cone, , Enter -

    .

    , . ,

    , Enter .

    - .

    , -

    , , Enter , -! , Maya .

    ,

    .

    -1302

  • 34 MEL Maya

    &

    Maya MEL- , -

    . -

    :

    , .

    .

    , , ,

    , (shelf) , ,

    .

    :

    ,

    Enter Enter , - .

    , , -

    ,

    , , ^

    MEL ,

    , ,

    MEL-. , Maya, MEL-, , .

    MEL, - ,

    , , -

    .

    ,

    sphere Enter . - :

    sphere;//Result: nurbsSpherel makeNurbSphere"!//

  • 2. MEL ~ 35

    , Maya (;) . MEL- (expression) . ,

    .

    ,

    (, , sphere; sphere Enter ).

    Maya (//). MEL- , , -

    . , ,

    .

    , ,

    , , .

    , Maya - , ,

    MEL-. - MEL , -, MEL , - Maya -, -, , .

    , :

    1. File > New Scene.

    2. , Create > NURBS Primitives > Sphere.

    3. Move.

    4. Z .

    5. , ( Maya, , , Raise Application Windows Window , ). ( )

    ( , , , , sphere, ,, ):f i le -f -new;// Resul t : / u n t i t l e d //sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;objectMoveCommand;move -r 0 0 3.001753;

  • 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.

    Maya scripts maya ( D o c u m e n t s Windows). , Maya .

    , :

    source test.mel Enter . Maya .

    . MEL- ( ) , Notepad Wordpad (Windows NT), jot (Irix) TextEdit (Macintosh), Maya, . , , , -

    .

  • 38 MEL Maya

    . , ,

    , Maya , , .

    MEL-. , , , MEL-

    ,

    , . , Create >Locator Maya ., , , - MEL- ? , . , Maya, , , MEL- , .

    Maya MEL-, , Edit > Show All Commands Script Editor. - Create > Locator . , :

    createLocator;createPrimitive nul lObject ;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 -

    -

    Maya , . , - Maya Edit , (undo), Maya MEL .

    MEL- , Maya Edit , - .

    , -

    Maya , , , . , .

    MEL, , . ,

    , .

    whatls whatls , ,

    Maya, . , , editMenuUpdate, :

    whatls editMenuUpdate; Enter. :

    //Resul t : Mel p r o c e d u r e f o u n d in : C : / A W / M a y a 4 , 0/scripts/ startup/buildEditMenu.mel// , MEL- editMenuUpdate, -

    , . :

    whatls spaceLocator :

    //Result : Command// , spaceLocator - MEL-

    , , MELCommand 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) .

    , .

    Maya MEL & ,

    Maya , . , -

    .

    , , , -

    -

    . - ,

    - , ,

    .

    , , -

    ,

    . , ,

    ,

    .

    . , , -

    , .

  • 2. MEL -

    Web-www. h igh en d3 d. . coirt/m ay a/HighendSD - , , Web- Maya,

    Softimage, Softimage XSI, AliasStudio Renderman and Jig . Highend2D, www.highend2d.com Shake Combustion.

    Maya HighendSD MEL-, , Maya, , , . - Maya Highend3D, .

    www .po stforum. mPostforum.com Macintosh, -

    , 2D 3D , Maya. Postforum.com - Maya, Maya Macintosh.

    w ww . aliaswave front . Alias] Wave front. -

    Alias j Wave front , Maya, , .

    . graphics, apps. alias , comp.graphics'.apps. alias, Netscape,

    Outlook Express . , Maya, , . graphics. apps. alias 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 b l a h . m e l

    MEL-, . mel, - .

    , , -

    , MEL-.MEL- , , -

    , .

    , MEL

    ,

    , .

    ,

    , MEL-. Show Commands MEL-

    , , Maya, -

    .

    MEL- , . -, . ,

    , ,

    , ,

    .

    , , -

    Maya , - Maya.

  • 3

    :

    .

    .

    .

    .

    .

    (custom) .

    ? Maya - ,

    . :

    (particle expression), (per-partideattribute) (particle object), (objectattribute expression), .

    , -

    -.

    ,

    ( ). 4 , , -

    .

    :

    1. Maya.2. , Create > NURBS Primitives > Sphere.3. Channel Box Translate X,

    , 0.4. Channels Expressions...

  • 44 MEL Maya

    5. Maya Expression Editor. Expression Editor - , ,

    .

    6. Expression Editor, Expression:, :nurbsSpherel.translateX = time;

    7. Create .8. , Expression Editor, Close.

    . ,

    X X .

    ? , :

    nurbsSpherel.translateX - time; , 2,

    Maya . , - (statement), (;). , - MEL-, - .

    ,

    nurbsSpherel translatoX time, , . -

    , .

    , , nurbsSphere l . t rans la teX, -. 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) pr int "Hel lo ! ' 1 .

    Maya , 3 4 (, , ), Hello! . , , ,

    , , .

    = MEL-, , ,

    , , .

  • 46 MEL Maya

    Mm/a , ,

    nurbsSphere l . t rans la teX Channel Box , , ( I)12. , , ,

    , - .

    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 -

    1 , Maya -

    , , . . -

    , - MEL-getAttr setAttr. - . -. . .

  • 48 MEL Maya

    , Maya , ( ).14

    , MEL getAttr setAttr, , . MEL , , ,

    ( , MEL $), .

    ( )

    , Maya, - .

    :

    , -

    ,

    . , -

    X , Y . , -

    - .

    ,

    , Y , , Y .

    , MEL-, .

    :

    ,

    ( , ). , ,

    .

    , .

    1 . 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 - m y s p h e r e . r o t a t e Y - 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 = t ime;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 -, , (+), (), ( - ). , , , :

    st r ing $f irst_name - " M a r k "s t r i n g $last_name = " W i l k i n s "str ing $my_name = $f i rs t_name + " " + $ las t_narne; '

    ,

    , .

    $first_name + $last_name, : MarkWilkms. , -

    \. , testing \n 1 2 3, , :

    Testing1 2 3

    .

    Maya ( ) , ,

  • 3. 55

    . Maya , , .

    , , -

    $ . $ Maya ( $ ) ( ).

    , , .

    (scope) , , .

    , , , ,

    ,

    . 10 (procedure), .

    , -

    (global), Maya .

    float Sxval = time;f loat $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 RelationalOperators Using Maya; Expressions. , , Functions.

  • 56 MEL Maya

    , ,

    . -

    , MEL-c. :

    translateX = $xval;translateY - Syval;

    MEL-, , . -

    setAttr, Set Attribute. MEL- :

    setAttr n u r b s S p h e r e l . t r a n s l a t e X $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 express ionl . t ime 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.

  • 58 MEL Maya

    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_airnConstraint l . Target2 W1 0.

    8. , Target2 0, AttributeEditor , , .

  • 60 MEL Maya

    target1!, . 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.

    - , -

    () . eyes, target 1 eyes, coordination - 1, , -

    targsti 1, target2 - 0 ( targetl).

    eyes, target 2, a eyes, coordination - 1, , targetl 0, targets - 1 .

    eyes. target 1 2, a eyes, coordination 1, , targetl target2 0 1 , , targetl, 1, target2, 2 ( , - 1 2 - ).

    eyes. coordination 0, , target l , - ta rget2 .

    eyes, coordination 0 1, , - ,

    .

    , -

    , , 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;

    i// 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 = $eyel_coord_targetl_weight; rbsSphere2_aimConstraint1. target"! WO -~ $eye2_coord_target1_weight;nurbsSphere1_aimConstraint1,target2W1 = $eye1_coord_target2_welght;nurbsSphere2_aimConstraint1.target2W1 - $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 target2 .9. 0,

    1, 2.IQ ( ,

    , ). ,

    target eyes. coordination, -

    . coordination , , n u r b s S p h e r e l targetl, a nurbsSphere2 targetO. , , -

    :

  • 3. 65

    float $eye1_uncoord_targett_weight = 1;float $eye1_uncoord_target2_weight - 0;float $eye2_uncoord_target~l_weight = 0;float $eye2_uncoord_target2_weight - 1;

    targetl, - target2. , -

    ,

    0 1. () 0 1 , -, :

    = ( * ) + ((1 - ) * ) ( * ) , ,

    ((1 - ) * ) , 0.3, 30%, 30% 70% , ((1 -30%) * ).

    , , (-) , .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 . t a r g e t l W Q =

    (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

    :

    1. eyes, Attribute Editor coordination , target . , , - 0, - 1, - 1.

    2. Expression Editor, By Expression Name Selection Filter expression!. :

    // // , 1

    float $eye~l_coord_target1_weight;float $eye"l_coord_target2_weignt;float $eye2_coord_target1_weight;float $eye2_coord_target2_weight;// coordination , 1 // target"!, a eye2 target2

    float $eye1_uncoord_target1_weight = 1;float $eye1__uncoord_target2_weight = 0;float $eye2_uncoord_target1jeight = 0;float $eye2_uncoord_target2_weignt - 1;// 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

    nurbsSphere2_ainConstraint1.target1WO -(eyes.coordination * $eye2_coord__target1_weight) +((1 - eyes.coordination) * $eye2_unccord_target1_weight);

    nurbsSpnere1_aimConstraint1.target2W1 =(eyes.coordination * $eye1_coord_target2_weight) +((1 - eyes.coordination) * $eye1_unccord_target2_weight);

    nurbsSphere2_aimConstraint1.target2W1 =(eyes.coordination * $eye2_coord_target2_weight) +((1 - eyes.coordination) * $eye2_unccord_target2_weight);

    . ,

    0 1 ( ) (- , ).

    ,

    , . ,

    , , , -

    .

    , ,

    ,

    , . ,

    , , -

    . , -

    , ,

    .

    , -

    ,

    , getAttr setAttr, ,

    ( , Maya - , , ,

    , ,

    getAttr setAttr). , MEL-, -

    , .

    getAttr setAttr.

  • '4

    :

    (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 2print (Smyvec.); // 1$myvec.x = 3; // '

    :

    $myvec .x - 3;

    . -. . ,

  • 70 MEL Maya

    , :

    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.

    1, 2. f 1, 0, 0 = 2, 2,

    - Ill

    . 4.1.

    ,

    , , -

    . (, . 4.2) - 2, 2, 0 1, 2, 0 -1, , .

  • .

    1. Z, 0 - 2, ', 0 = -1, ,

    . 4.2.

    , -

    : unit, m a g , 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

    angle angle (. . 4.3). , ,

    (180/), :

    vector $xvec = 1,0,0; // Xvector $yvec = 0,1,0; // Yfloat $xy_angle = angle ($xvec, $yvec); // 1.570796 $pi = 3.141593;float $xy_angle_degrees = $xy_angle * 180/$pi; // 90

    $yvec 90 degrees (1.570798 radians)

    $xvec

    . 4.3. (Degrees - ; Radians - )cross cross . -

    - , (normal), - , :

    vector $xvec = 1,0,0;vector $yvec = 0,1,0;vector $zvec = cross (Sxvec, $yvec); // 0,0,1

    , cross -

    1 ( (unit vector)), , . , ,

    (. . 4.4) :mag ($vector1) * nag ($vector2) * sin (angle (Svectorl, $vector2))

    unit (cross (Svectorl, $vector2)) , Svectorl $vector2. , ,, , , , , .

  • 4. 73

    '

    $yvec

    $xvec

    cross ($xvec, $yvec)z

    , 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);

  • rot {Smyvec. $z axis, (twenty degrees)

    MEL Maya

    - o9i

    :

    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.7. Component Editor

    7. Velocity Y , , ,

    8. 1.0 , Y, 1.9. Component Editor.10. .11. , , Fields > Newton.12 , ,

    (. . 4.8).

  • 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;

  • 78 MEL Maya

    [[^ --.-^ ^ .^^ ""^ ^^"!

    . 4.9.

    Select Ntet Object Filter Attribute Ffcer Insert Functions Help-11

    Creating Expte)ianExtiesiicn Name I

    *>| Selectionffl^erti. Attributes ,

    attenuationinaxOistenceappljf erVertrauieMexDistarKvolumes haoe

    Selected Obi Atff newlonFieULrnagnludeDelau Otiecl newtonFieldl

    7 Always Evaluate

    j .

    ?

    Convert U rate 1* At I" Norm *"* 'Angular only .;

    Editor'itaKajon(it (tz

    } !j

    JJ

    'teitiff P" Riiiiiin-e 1!1 EnpiesiionEdHof ^M

    lugnitudl - S . O ;1negnicud - -3S.O;

    ' " : ' :-. 1 - - ' -'

    Qeote > jwtt fs^iiw.

    I

    i .J

    r

    Oeai Cbse

    . 4.10. Expression Editor

  • .

    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 + ZA2.

    X Z, - Y ( ).

  • 4.

    . 4.12.

    :

    1. , .

    2. particlel..., AttributeEditor.

    3. General Control Attributes ( ) Expressions After Dynamics ( )(. . 4.13).

    panicle! parlicleShapel

    pariide: IpaflicleSbapel Q

    TJ Geneial Control Attribute* b Dynamic

    Dynamics Weisht |1 000Conserve

    R ExpiBssioris After I" Cache Data

    .1| !*. 4.13. Expression after dynamics particleShapel4. , Per Particle (Array) Attributes (-

    ()) , , (. . 4.14).

  • 82 MEL Maya

    Attribute Editor: pWUCMl

    particle! partideSriapsI 1 Erniuel I

    particle: jpaihcleShapel

    Per Particle (Array) Attributesposition j

    rafnpPosilicn f

    velocityrampVetoeilyacceteiation }

    rarnpAcceleiation

    mass

    lietpatiPP

    -I

    Add Dynamic Attributes

    Select . . Load Attributes

    1Copy Tab

    . 4.14.

    ,

    , .

    . -, ,

    , . -,

    - -

    ,

    . ,

    , Attribute Editor, ,

    .

    .

    5. , position, - Runtime expression...

    6. . Create:vector $pos = position;float $posY = (Spos.x) * C $ p o s . 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 = ( S p o s . x ) * (Spos .x) + (Spos.z) * (Spos .z) ;

  • 84 MEL __

    ( ) $posY. , , $. , - Y- , . Y- X Z .

    ,

    $pos.x Spos.z , , $posY:position - $pos.x, $ p o s Y , $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 ( ) Dynamics - 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 = ;vector $tanvec = ;vector Snormvec = ;

    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. :

    f loat $pos[] = 'po intOnCurve -pr (age) -p c u r v e " ! 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[] = ' p o i n t O n C u r v e *-pr (age) ~nn c u r v e l ' ;

    pointOnCurve - - (normalized tangent) . X, YHZ , . , 1; ,

    unit . - -

    (normalized normal) . , - , . ,

    , , 1. ,

    position , $[], $tan[]$[] :vector Sposvec = ;vector $tanvec = ;vector $normvec = $norm[0], $norm[1], $norm[2];

    : , , -

    , ,

    .

  • 90 ; MEL

    , -

    , .

    , , -

    . , ,

    . ,

    , .

    ,

    $norm2vec. - cross, . 1 , , -

    1:vector $norm2vec = cross ($tanvec, S n o r r n v e c ) ;

    , :

    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 * beeatRender Attribute*

    Depth SoilParticle Rendei Type

    . 4.21. Render Attributes

    4. Add Attributes For [Current Render Type].5. , Attribute Name,

    Attribute Name age Enter (. . 4.22).6. Attribute Editor.

    . r i emission *^'"Rende"r"AltributeV" ~

    Depth Sort.Pailicle Render Numeiic _

    . Add Altibjtes Fr Cwrert Render TypeAttribute Name [ a g e ^

    Point Size p ~~ PJ

    ^>j Render Slab" SelacledOnlji

    . 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 curvelduide4. 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, 95

    1. Script Editor Enter:pointOnCurve -ch on -pr 0 curve"!; .pointOnCurve -ch on -pr 0 curvelguide; , , :

    // 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 = ;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 NURBSCurve History . Max Value - , , , , -

    (. . 4.26).5. , Lifespan Mode Constant Channel Box

    Lifespan ( Lifespan Random), (. . 4.27).

  • MEL Maya

    MAtttJbuteWitOKEurrel ' HMIS!List Selected Focus Attributes Help

    CUVB! rajiveSliepel | poinlOnCurvelnfol 1 oHselCiivei )

    rurteCurve; Icu:veShapel| -| Focus 1_JtJ '

    :jj NURBS CuiweHiiloiy !jjMhMaWaiue [O.OOO J3.DOO

    Spans |3Form j Clfis^ -rj

    Dearee 13 'LHJ

    Select Load Alliibutes j Copy Tab Dose

    -

    . 4.26. curvel

    Target Geometry [Particle LocajGoal Smoothnes J3

    Cache Data [off

    Particle Render jPointsLifespan

    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. , , -

    Create Particle Disk Cache 1 .

  • 5

    MEL-

    :

    MEL- Maya. MEL-

    Maya. MEL-. MEL. MEL. , MEL. MEL. MEL.

    MEL Maya: , , ,

    Maya. MEL-. - DG-, - .

    , Maya , , .

    MEL-, , . ,, . MEL- (script node), , -, , , ,

    , , MEL- -, .

  • 1 * 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;//Resul t : nurbsSpherel nurbsSphere2//

    4, , , - MEL- ., , ,

    :

    string $selectionList[] = 'Is -selection';

  • 4 MEL Maya

    MEL-, -selection , -si. , :string $selectionList[] = "Is -si1;

    , 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 n u r b s S p h e r e l ;

  • 5. MEL-

    , . ,

    :

    sphere -radius 3; . ,

    , sphere. - , ( , , MEL Command Reference, - ), getAt 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 " f loat " - longName "bounciness"

    -defaul tValue 2 nurbsSphere l ; :

    addAttr -at "float" -In "bounciness" -dv 2 nurbsSpherel; addAttr, MEL Command Reference,

    -

    , AddAttribute, .

  • 106 MEL Maya

    , nurbsSphere l , Attribute Editor ( ) Extra Attributes ( ). , nurbsSphere l , nurbsSphereShapel . , .

    3 4, MEL- - .

    , .

    , Maya - ,

    , (, ,

    , .

    setAttr ).

    MEL-, , , , . , :

    n u r b s S p h e r e l . b o u n c i n e s s = 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 " . / /

    bounciness 5, setAttr:setAttr n u r b s S p h e r e l . b o u n c i n e s s 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- 7

    MEL MEL connectAttr .

    Connection Editor, . Maya NURBS-. , -

    Script Editor:connectAttr nurbsSpherel.translateX nurbsSphere2.translateY;

    nurbsSphere l 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 sconnectAtt r:disconnectAttr nurbsSphere ! . t rans lateX n u r b s S p h e r e 2 . t r a n s l a t e Y ;

    MEL MEL , -

    . , t rans lateX nurbsSphere l nurbs3phere2. t rans lateY , nurbsSphere2 . t rans la teY - nurbsSphere l , t ranslateX.

    Maya , Expression Editor :nurbsSphere2.translateY = pow(nurbsSphere1.translateX, 2); t

    ( pow, ? Functions UsingMaya: 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, .

    dynExpress ion , .

    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;

    particle -n (ScurveSelected + "particles");

    setAttr (ScurveSelected + "particlesShape.expressionsAfterDynarnics") true;

    Select -r (ScurveSelected + "particlesShape");

  • 5. MEL- 111

    addAttr -In "speed" -at "float":

    setAtt (ScurveSelected + "particlesShape.speed") Sspeed;

    addAttr -In "scaleQffset" -at "float";

    setAttr ($curveSelected + "particlesShape.scaleOffset") $startQffset;connectDynamic -em ($curveSelected + "emitter")

    ($curve$elected + "particles");parent (ScurveSeLected + "emitter") ScurveSelected;

    string SmainCurvelnfoNode = 'pointOnCurve -ch on -pr 0 ScurveSelected';

    string SguideCurvelnfoNode = 'pointOnCurve -ch on -pr 0 ($curveSelected + "guide")";//

    string $exrString ="float $curve_param = " + $curveSelected + "particlesShape.age * " +ScurveSelected + "particlesShape.speed;\n" +

    "setAttr" + $mainCurve!nfoNode + ".parameter $curve_param;\n" +"setAttr " + SguideCurvelnfoNode + ".parameter $curve_pararn;\n" +

    "float $pos[] = 'getAttr " * SmainCurvelnfoNode + ". position'; \n" +"float $tan[] = %getAttr " + SmainCurvelnfoNode + ".normalizedTangent';\n" +."float $normEnd[] - 'getAttr " + $guideCurve!nfoNode + ". position';\n" +"float $norm[];\n" +"$norm[0] = $normEnd[0] - $pos[0];\n" +"$[1] = $normEnd[1] - $pos[1];\n" +"$norm[2] = $normEnd[2] - $pos[2];\n" 4-"vector Sposvec = $pos[0j, $pos[1]

    s $pos[2];\n" +

    "vector Stanvec =

  • 112 ^ MEL Maya

    "particlesShape.scaleOFfset * $normvec * cos(" +ScurveSelected + "particlesShape.age*20}} + \n" +" (" + ScurveSelected +"particlesShape.scaleOFfset * sin("+ScurveSelected + "particlesShape.age-20)) + \n";//

    dynExpression - -s SexprString (ScurveSelected + "particles"};dynExpression -c -s $exprString ($curveSelected + "particles"};

    4. . , spiralParticles .

    5. , .

    -, ;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 , . - express ionsAfterDynamics true. setAttr - Maya. -, , , , curvel , , particle curvel particles, curveipart iclesShape. , expressionsAfterDynamics. true, (, 4 ).

    particlesShape. ,

    addAttr , -. addAttr , ,Maya , .

    select - Maya , . ,

    , :

    select - (ScurveSelected + "part ic lesSnape") ; addAttr speed

    scaleOffset particleShape, setAttr - , :

    a d d A t t r -In "speed" -at " f loat" ;

    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- - , .

    , ,

    :

    str ing S m a i n C u r v e l n f o N o d e = '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

    "float $normEnd[] = 'getAttr " + $guitieCurveInfoNode + "-positicn';\n" +"float $norm[];\n" + "$norm[0] - $norrnEnd[0] - $pos[0];\n" +"$norm[1] = $normEnd[1] - $pos[1];\n" +"$norra[2] = $normEnd[2] - $pos[2];\rT +"vector Sposvec =

  • 5. MEL- 117

    : MEL - . ,

    , .

    . -

    ,

    .

    .

    - .

    , -

    , , .

    , - , .

    . , -

    .

    . .

    , .

    . -

    , , ,

    . , , , -

    .

  • 6

    :

    .

    .

    , -

    , .

    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 ( , ScriptEditor, Maya). , 5.25 $my_variable ,

    Maya , :

    $my_variable_2 = 5 . 0 ;$my_variable_2 = 5.25;

    print ($my_variable_2 + "\n");

  • MEL Maya

    , 5.25. , 5.0 ( Maya , ) $my_variable_2, Maya . Maya 5.25, $my_varlable_2, .

    .

    $my_variable_2:f loat $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, (option variable). MEL- optionVar ,

    , . , , -

    , -

    .

    MEL Command Reference, optionVar.

    - 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 f loat(3) :print (float(3) / 4);

    0,75, 0, , . ,

    , .

    ,

    , ()., , . -

    , $ $ :int $a -14;int $b = 3;

    , -

    :

    print ($ - ($ * ($ / $))) ; , 2, -

    , .

    , , :

    pr int ($a % $ ) ; (%) ( m o d u l u s )

    , , $ $. : a mod b.

    . -

    ,

    +=, -=, *=, /= %=. ,$ = $ + 4;

    , :

    $ += 4; ,

    $ - $ % 3; , :

    $ %= 3;

  • 128 MEL ^

    . -

    ++ . :

    $ = $ + 1; :

    $++; :

    $ = $ - 1; , :

    $--; ( )

    ,

    , , Maya .

    . 9, - , , .

    .

    :

    print (5 > ); // print (5 < 6); // print (5 >= 6); // print (5

  • ^

    print (0 && 0); // print (1 0); // print (0 && 1); // print (1 && 1); // 1

    or (\\) or 1, ( ), 0, 0.

    print (0 | | 0); // print (1 | | 0); // 1print (0 | | 1); // 1print (1 | | 1