Make Marbel Texture..
Make variable colored grid..
Neon Text..
The micro bevel..
Rusted Type..
3D Text/Logo..
Techno-wave Effect..
Trendy Avatar..
Simple background..
Digital Effect..
Polar Coordinates..
Water drops..
LCD Screens..
Steel Type..
Pixelated Text..
Smooth Edges..
Vectorizing Photos..
Luminous Essence..
Transparency..
Digital Smoke..
Game cube logo..
Gradient Grids..
Sparkles..
Driping Slime..
Borders..
Cartoon Clouds..
Organic Tech..
Aqua Balls..
Kerning and Tracking text..
Getting rid of overlap..
Weaving a ribbon through text..
Blend layers w/ opacity mask..
Brilliant Color..
Create 3D Cylinder..
Creating Artistic Brushes..
Fine Lines Design..
Transition b/w two objects..
Distortion Effect..
Soft Proof your colors..
Knotworking..
Creating views..
Transforming shapes..
Creating Image map..
Optimizing web graphics..
Using Slice tool..
Creating web button..
Animation of scaling..
Ripple Animation..
Colors changes to animation..
Neon light animation..
Creating a Navigation bar..
Animated Imagemap Button..
Preloader with FlashMX..
Sound Control..
Steel Flash..
Using masks..
Loading an external movie..
Flash light effect..
Flash game techniques (P-1)..
Flash game techniques (P-2)..
Flash game techniques (P-3)..
Flash game techniques (P-4)..
Flash game techniques (P-5)..
Dropdown menu for FlashMX..
Zoom blur effect..
Dessolving words ..
Spotlight masking..
Passing variable to Flash..
Clear Text..
Create Time in Flash..
Change colors of movieclip..
Creating sites using CSS ..
Dreamweaver 4 Flash buttons..
Defining a site..
Dreamweaver Form tips..
Dreamweaver interface..
Creating nested tables..
Rollover form buttons..
Graphics Editing w/ DW & FW..
Inserting FW HTML into DW..
Working with templates..
Quick shapes in freehand..
Making a 3D pie-chart..
Exporting GIFs from Freehand..
Creating 3D Soccer Ball..
Creating Perspective shadows..
Chrome effect in Freehand..
Creating Hollow Envelopes..
Building Buttons..
Drawing a heart symbol..
3D Ball ..
Bouncing ball..
Automating Fireworks..
Text writing animation..
Fireworks 4 Popup menus..
Creating Gel Text..
Outline tool overview..
Cracked text..
Page curl ..
Contoured Text ..
Drop Shadows ..
Creating complex shapes..
Creating volumetric clouds..
Water/Fire/Smoke Effect ..
The Power of Radial array..
Modelling an Eye..
Welding vertices..
Animating a ball..
Realistic Texturing..
Polygon basics..
Lathe Tutorial ..
Emit geometry from a point emitter..
Creating a missile trail..
Animating a flying baloon..
Introduction to Expressions..
Making MEL Procedures..
Introduction to MEL Scripting..
Modeling a mechanical hand..
Build a spiral staircase..
Building leg skeletons..
Modeling a head..
Texturing the head..

How to make water ripple..
Create Ghost shader..
Using two bone IK Solver..
Using multi-texturing..

Making MEL Procedures:

This tutorial covers the basics of making your own MEL procedures, MEL procedures allow you to define your own language in MEL, creating your own commands instead of using the built in commands like 'move', 'rotate' and 'polyCube'. The power of being able to make your own procedures is the ablity to create a simple interface to a vast array of functionality and decision making. MEL procedures do this by allowing you to take a series of complicated commands, group them together and give them a name.

In this simple tutorial we are going to create a new MEL procedures called 'stair', this procedure will perform all of the calculations necessary to create a set of stairs based on height, number of steps and starting location. Once you have made this function, you can save it to a file and source it whenever you start Maya. If you do that, you can use it over and over again, wherever you need a staircase.

Step 1


Making stairs with a procedure


The first step in the tutorial is just to make a basic looping script that will create a set of stairs. After you have made this, you can encapsulate it in a MEL procedure that gives it a name. The script uses a 'while' loop, to reptetively call the 'polyCube' command and the 'move' command, creating 10 steps and moving them into a stair configuration. If you cut-and-paste the following code into your MEL scripting window you should get something resembling the image on the right.

$i = 0;

//loop through while $i is less that ten and create some cubes

while($i < 10){
polyCube;
scale 10 .1 1;
move 0 $i $i;
$i++;
}

Step 2

The second step in this step is to take the loop from step 1 and wrap it inside of a procedure. To create a procedure, just surround the loop with a procedure declaration. Place the statement 'proc stair(){' at the beginning and '}' at the end. This defines it as a procedure named 'stair()' (the parthesis will be explained later in the tutorial). When you copy-and-paste this script into the MEL scripting window, nothing will happen on the screen. However, once you have cut-and-paste the script, you will have a new function called 'stair()' that you can execute. Once you copy-and-paste, type 'stair();' into the MEL scripting window and it will create a stair.

proc stair(){

//create a function called 'stair()' that will perform the loop

//loop through while $i is less that ten and create some cubes

$i = 0;

while($i < 10){
polyCube;
scale 10 .1 1;
move 0 $i $i;
$i++;
}
}

If you add the word 'global' before your procedure declaration, then if you save it to a file you can use the files as a function library. Add a 'global' declararion before the 'proc' statement and save your script as a text-only file called 'stair.mel'. To load the stair function at any time, choose 'Source Script' from the 'File' menu in the MEL Scripting window and select you file.


Step 3

Now that you have defined your 'stair' procedure, you can refine its definition by providing for 'arguments'. 'Arguments' allow you to feed information or varaibles into your function so that it can have different behaviors. These arguments are the variables that come between the parenthesis when you call a procedure.

In this step you will redefine your function so that the number of stairs is variable. To do this change the function declaration to be 'global proc stair(float $numberofsteps)', this tells the function that is will receive a variable (which will be a floating point decimal) and that number will define how many steps should be in the stairs. Use the '$numberofsteps" variable inside of the function to limit the iterations of the loop.

global proc stair(float $numberofsteps){

//create a function called 'stair()' that will perform the loop

//this function will take the argument 'numberofsteps'

//loop through while $i is less that $numberofsteps and create some cubes

$i = 0;

//change the < to be less that $numberofsteps

while($i < $numberofsteps){
polyCube;
scale 10 .1 1;
move 0 $i $i;
$i++;
}
}

Arguments have to be defined by naming the variable, and defining its type. In the example above we define the variable as being '$numberofsteps' and we can use that variable inside of the procedure by referring to its name. The variable name is preceded by its type definition, there are many different type definitions in MEL, but the 3 most common are:

float - Floating point number. This is a decimal number, like 2.3457 or 0.0000045.

int - Integer. This is a whole number, like 2 or 345839.

If you define a definition as an 'int' and pass the procedure decimal number, it will automatically be rounded down to the closest whole number. For example. If you have a function defined as 'proc box(int $size)' and you call it with the following syntax 'proc box(4.56342)' the $size will be rounded down to 4 inside of the procedure.

string - Text string. This is a word or series of words, like "Hello" or "My name is ....".


Once you have cut-and-pasted the code into the MEL scripting window, you will have to call the stair command with a number as an argument, try 'stair(20);' and it will make 20 steps, 'stair(40);' will make 40 steps.

Step 4

The stair procedure can be further refined by adding additional arguments. In this step you will add arguments of '$locationx', '$locationy' and '$locationz'. These additional arguments will be used to position the staircase anywhere in space (instead of always being at 0,0,0), making the 'stair' procedure much more self-contained and usable in more situations.

global proc stair(float $numberofsteps,float $locationx,float $locationy,float $locationz){

//make function called 'stair' that takes arguments of 'numberofsteps', plus x,y,z coordinates of a starting point.

//loop through while $i is less than the number of steps.

$i = 0;

while($i < $numberofsteps){

polyCube;

scale 10 .1 1;

//use the arguments of locationx, locationy and locationz to position the steps.

$x = $locationx; // the x position
$y = $locationy + $i; // the y position is the starting y position, plus and offset for each step
$z = $locationz + $i; // the z position is the starting z position, plus and offset for each step

//move the step to x,y,z
move $x $y $z;
$i++;
}
}




When you call the stair command now in the MEL scripting window you will have to give it 4 arguments, such as 'stair(20,10,10,10)', which would make a staircase with 20 steps at location 10,10,10.

Step 6

The last step is to add some more intelligence to your stair function. Aadd the argument of '$height' to the function and use the height and the number of steps to determine the spacing between each individual step. Once you have done this you can make stairs anywhere you need and you only have to know the number of steps, height and location.

global proc stair(float $numberofsteps,float $height, float $locationx, float $locationy, float $locationz){

//add and argument of 'height' to the stair function.

//use the 'height' variable to calculate the step riser height. The riser height is equal to

//the overall height divided by the number of steps.

float $step = $height / $numberofsteps;

$i = 0;

while($i < $numberofsteps){
polyCube;
scale 10 .1 1;

$x = $locationx;
//use the 'step variable as a multiplier so that each step is based on the riser height
$y = $locationy + ($i * $step);
$z = $locationz + $i;
move $x $y $z;
$i++;
}
}

One of the real values of procedures is to provide a simple interface ot complex functionality and calculations like this stair. As a modeler, you do not want to have to calculate the stair spacing and other things to create a stair, all you know is how big you want the stairs and where they should be - the procedure should handle the rest. You can further refine your procedure to calculate for proper landings, railings and ballustrades.

Remember, save your stair procedure to a file and you can load it by selecting 'Source Script' each time you start Maya. If you quit Maya and restart, your custom function will not be available until you source the file again.

Partners

Flash Templates
Free Web Templates
FREE professional web templates
Website templates
Free Web Templates
Graphic Design
Tutorial Guide
Flash Templates

Flash Templates and Web Templates

 


Advertise | Submissions | Privacy Policy
All the contents and articles within this website are property of their respective authors and are submitted to us by them, we do not held any liability for the material including text and graphics submitted by them.
© Copyright Vecpix.com 2006-07. All rights reserved.