Lecture Maya dynamics basics: Lab 5 - Khieu Van Bang

33 34 0
Lecture Maya dynamics basics: Lab 5 - Khieu Van Bang

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 5 - MEL and expression. The topics discussed in this chapter are: Why using MEL & expressions? Differences between MEL and expression, What you can do by using MEL and Expression? How Maya Uses MEL, script editor, MEL commands, variables, return values,...

Author: Khieu Van Bang Email: tribang.nd@gmail.com Maya Dynamics Basics Lab 5: MEL and Expression CONTENTS  Basics: Why using MEL & expressions? Differences between MEL and expression What you can by using MEL and Expression ?  MEL Basics:  How Maya Uses MEL  Script Editor  MEL Commands  Variables  Return Values  Expression: Create expression  Helpful Resources  MEL and Expression 1) BASICS 1.1) What is MEL and Expressions? 1.2) Differences between MEL and Expression 1.3) What you can by using MEL and Expression ? 1) MEL and Expression 1.1) What is MEL and Expressions?  MEL stands for Maya Embedded Language MEL is a scripting language which can embody "open architecture" of maya By using MEL, user can control maya functions directly/indirectly Even maya's GUI (graphic user interface) can be controlled by MEL Therefore user can add new functions that maya doesn't have OR customize GUI as their needs  Expression controls attribute of object User can control an animation which cannot be key framed (e,g particle) Using expression is similar to script MEL We will mainly learn how to work with Expression 1) MEL and Expression 1.2) Differences between MEL and Expression MEL Expression MEL is more likely completely independent programme Expression is a correlation with objects MEL needs complete structure of grammar Expression needs only the least rules MEL is executed no matter animation is played or not Expression is executed only while animation playing MEL is saved separately with the scene Expression is saved as a part of the scene MEL access to the attribute indirectly Expression access to the attribute directly 1) MEL and Expression 1.3) What we can by using MEL and Expression  MEL : control an attribute of object accurately, create new macro, create new user interface, customize maya GUI  Expression : control attributes of object apart from key framing by numerical expression, control attributes by conditions, It can use MEL command in expression However, it can't control the attribute that controlled by existing key, set driven key, constraint, motion path or other expression It can occur an error if you run MEL commands such as connection/disconnection of attribute or creation/deletion of object within the expression  Grammar of MEL is very similar to other programming languages like C, C++ Not only the MEL, most script based languages are descended from C It is not essential to learn programming language for MEL Although if you have experience with scripting language, it will be easier to understand the structure 1) MEL and Expression  Do not worry ! o I know you are designers  Expression is very easy to use MEL and Expression 2) MEL BASICS 2.1) How Maya Uses MEL 2.2) Script Editor 2.3) MEL Commands 2.4) Variables 2.5) Return Values 2) MEL Basics 2.1) How Maya Uses MEL      Menus Shelf Buttons Hotkeys Expressions GUI 2) MEL Basics 2.2) Script Editor  You get to it by hitting  Top area displays the MEL that Maya just did  Bottom area is a work area where you type code interactively  Selecting text and hitting „ctrl + Enter‟ executes code  Make a shelf button by selecting text and middle mouse dragging to the shelf 2) MEL Basics Example  The for-construct int $i; for ($i = 0; $i < 20; $i++) { sphere -pivot $i 0; }  A spiral surface select -all; delete; circle -center 0; int $i; for($i = 0; $i < 60; $i++) { duplicate; rotate -r 0; move -r 0; } select -all; loft; MEL and Expression 3) EXPRESSION 3) Expression What is Particle expression ?  Are more complex than other types of expressions For example, we can write an expression to control all particles in an object the same way, or you can control each particle differently 3) Expression 3.1) Attributes Notes  Per Particle (Array) Attributes o Are created with Radius, Mass, Opacity, Color, and Incandescence per-particle ramps already added to the nParticleShape node  Add dynamic attributes(Modify > Add Attribute) o Control dynamic and custom attributes you add to a particle shape node o When we add a dynamic attribute to an object, the attribute names appear in the Expression Editor’s Attributes list 3) Expression 3.1) Create expression  Step 1: Create a object o Example: Type "sphere" in command line and press enter It will create a new nurbs sphere  Step 2: Change object attributes o Example: Change the name of the sphere in channel box as "Ball"  Step 3: Create expression o Select the ball Go to Window > Animation Editor > Expression Editor, run Expression Editor o Type in "ScaleBallWidth" in the box of Expression Name o Type "Ball.scaleX = Ball.scaleZ = time +1;" in the expression box 3) Expression 3.1) Create expression  Step 4: Click "Create" and playback the animation 3) Expression 3.1) Create expression 3) Expression Example : Random Colored Particle 3) Expression How to create it ? Random colored fireworks shot up into the sky every time 3) Expression Example 2: Control the moon orbiting the earth 3) Expression How to create it ? MEL and Expression Helpful Resources  Books  Complete Maya Programming by David A D Gould  Websites  area.autodesk.com  fundza.com  ewertb.soundlinker.com MEL and Expression Helpful Resources MEL and Expression Helpful Resources Thanks! ... -w -h -d -sx -sy -sz -ax -tx -ch 1;  Command options move -r -os -wd 0 5. 109298 ; move -r 0 pCube2; 2) MEL Basics Example  Variable declarations int $height = 2; polyCube -w -h $height -d 1;... polySphere -edit -radius “Rambo”; - Query polySphere -query -radius “Rambo”; 2) MEL Basics 2.4) Variables - Are for storing data - Always start with a „$‟ - Data Types - Int (Stands for Integer) - Float... -flags values; Variable type Default value int float 0.0 string "" Example 1: sphere -radius 3; Example 2: polySphere -radius 2 .5 -subdivisionsX 10 -subdivisionsY 30 -name "Rambo";

Ngày đăng: 30/01/2020, 06:11

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan