Mel Keyframe & Expression Animation

 

Mel
Keyframe & Expression Animation


return to main index



 

Introduction

This tutorial provides mel scripts that demonstrate the general principles of using keyframes and expressions for animation. The object that is animated in listings 1 and 2 is created by the ring() procedure that was introduced in the tutorial "Mel: Modeling with Smart Transforms".


Mel Keyframe & Expression Animation_第1张图片
Figure 1


 

Listing 1 (keyframe.mel)

source "FULL_PATH/ring.mel";
select -all;
delete;
  
// Get the "master" object
ring(5, 4);
 
for($i = 0; $i < 5; $i++)
    {
    string $temp[] = `instance -st`;
        
    //_____ keyframing _________________
    currentTime 1;
    xform -os -t 0 0 0; // <<<--- IMPORTANT
    setKeyframe ($temp[0] + ".translate");
    
    currentTime 30;
    xform -os -t 0 $i 0;
    setKeyframe ($temp[0] + ".translate");
    //__________________________________
    }
  
playbackOptions -min 1 -max 30;
//play;


Listing 2 (expression.mel)

 
source "FULL_PATH/ring.mel";
select -all;
delete;
  
string $exp = "";
int    $fcount = 30;
  
// Get the "master" object
ring(5, 4);
  
for($i = 0; $i < 5; $i++)
    {
    string $temp[] = `instance -st`;
    //_____ expression _________________
    $exp += $temp[0] + ".translateY = ((frame - 1) * " +
            $i + "/" + $fcount + ");\n";
    //__________________________________
    }
expression -s $exp -ae 1;
// print the expression
//print($exp + "--------------------\n");
  
playbackOptions -min 1 -max $fcount;
//play;


© 2002- Malcolm Kesson. All rights reserved.

你可能感兴趣的:(Maya,mel)