⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1028a.mel

📁 MAYA的MEL编程
💻 MEL
📖 第 1 页 / 共 2 页
字号:
global string $gHeadsUpDisplayMenu;
// Add a divider to separate Maya items from custom items menuItem -parent\
$gHeadsUpDisplayMenu -divider true;
// Add one menu item per heads up display object created above
menuItem -parent $gHeadsUpDisplayMenu
-checkBox true
-label "Object Position"
-command "headsUpDisplay -e -vis #1 HUDObjectPosition"
-annotation "Object Postion: Toggle the display of object position"\myObjectPostionItem;

float $Tmp[] =‘getParticleAttr -at position FireShape.pt[0]‘;
vector $particlePosition = <<$Tmp[0], $Tmp[1], $Tmp[2]>>;
setParticleAttr -at position -vv 0 0 7 FireShape.pt[0];

window -widthHeight 300 200 TestWindow2;
string $form = ‘formLayout -numberOfDivisions 100‘;
string $b1 = ‘button -label "A"‘;
string $b2 = ‘button -label "B"‘;
string $b3 = ‘button -label "C"‘;
string $b4 = ‘button -label "D"‘;
string $b5 = ‘button -label "E"‘;
formLayout -edit
-attachForm $b1 "top" 5
-attachForm $b1 "left" 5
-attachControl $b1 "bottom" 5 $b2
-attachPosition $b1 "right" 0 75
-attachNone $b2 "top"
-attachForm $b2 "left" 5
-attachForm $b2 "bottom" 5
-attachForm $b2 "right" 5
-attachOppositeControl $b3 "top" 0 $b1
-attachPosition $b3 "left" 5 75
-attachNone $b3 "bottom"
-attachForm $b3 "right" 5
-attachControl $b4 "top" 0 $b3
-attachOppositeControl $b4 "left" 0 $b3
-attachNone $b4 "bottom"
-attachOppositeControl $b4 "right" 0 $b3
-attachControl $b5 "top" 0 $b4
-attachOppositeControl $b5 "left" 0 $b4
-attachNone $b5 "bottom"
-attachOppositeControl $b5 "right" 0 $b4
$form;
showWindow TestWindow2;

float $frame = ‘currentTime -q‘;
string $timeFormat = ‘currentUnit -query -time‘;
currentUnit -time sec;
float $time = ‘currentTime -q‘;
currentUnit -time $timeFormat;


$listOfThings=‘ls‘;
// Note that if listOfThings hasn’t been declared
// yet, it will be dynamically typed based on the
// result of the "ls" command.
for ($i=0; $i < size($listOfThings); ++$i) {
foo $listOfThings[$i];
}
Alternatively, do this:
$listOfThings=‘ls‘;
for ($thing in $listOfThings) {
foo $thing;
}


proc foo ( float $f[], string $s[]) {
print("size of f=" + size($f) + "\n");
for ( $i=0; $i < size($f); ++$i ) {
print("f[" + $i + "]=" + $f[$i] + "\n");
}
print("size of s=" + size($s) + "\n");
for ( $i=0; $i < size($s); ++$i ) {
print("s[" + $i + "]=" + $s[$i] + "\n");
}
}
float $ff[2]={0.9, 1.2};
float $gg[];
for ( $i=0; $i < 10; ++$i ) {
$gg[$i] = $i;
}
foo $ff {}; // passes the array "$ff" and the empty array to foo.
foo $gg {"hello", "world"}; // passes the array "$gg" and an array of 2 strings
// to foo.
foo {} {}; // calls foo with 2 empty arrays.
Note that array expressions get their base type from the type of the first element in
the list. So, to force your array expression to be of a certain type, you can cast the
first element:
foo {(float)1, 2, 3} {"hello"}; // make first array an array of float, not int.


global proc uiDeletionCallback ()
{
print "Window has been deleted\n";
}
window -t "Master Gizmo" -w 200 masterGizmoWin;
rowLayout;
button -l "Close" -align "center" -c "window -edit -visible false masterGizmoWin";
showWindow masterGizmoWin;
scriptJob -runOnce true -uiDeleted masterGizmoWin uiDeletionCallback;



global proc dynFuncBoundary()
{
// Clear the scene and reset the timeline.
//
file -f -new;
currentTime -e 1;
// Display information to the user about what to expect from this
// subtest and give some time for the user to read this information.
//
print( "\nParticles fall and collide with ball and plane.\n" );
system( "sleep 1" );
// Create the bottom plane.
//
nurbsPlane -name plane;
scale 7.01291 7.01291 7.01291;
rotate 0rad 0rad -1.5708rad;
move 0 0.2 0;
// Create the ball above the plane.
//
polySphere -name ball;
scale 1.20479 1.20479 1.20479;
move 0 2.7 0;
// Create the emitter above the ball and plane. Make the particles
// affected by gravity and have them bounce off the ball and the
// bottom plane.
//
emitter -type omni -r 100 -mnd 0 -mxd 0.7 -spd 1 -pos 0 5 0 -name emitter;
particle -name particles;
connectDynamic -em emitter particles;
gravity -dx 0 -dy -1 -dz 0 -m 9.8 -pos 10 10 0 -name gravity;
connectDynamic -f gravity particles;
collision -r 0.50 -f 0.14 plane;
collision -r 0.50 -f 0.14 ball;
connectDynamic -c plane -c ball particles;
// Make the picture a pretty one and play the test.
//
select -r particles;
selectMode -component;
hide plane ball;
// Set up the playback options.
//
float $frames = 150;
playbackOptions -min 1 -max $frames -loop once;
// Time how long it takes to play the scene and then determine the
// playback frame rate. Make sure when getting the frame rate
// that no values are divided by zero.
//
float $startTime = ‘timerX‘;
play -wait;
float $elapsed = ‘timerX -st $startTime‘;
float $fps = ($elapsed == 0.0 ? 0.0 : $frames/$elapsed);
// Print the frames per second (fps) of the subtest in the form X.X.
//
print("dynFuncBoundary: Done. (");
print( (int)($fps * 10)/10.0 + " fps)\n" );
} // dynFuncBoundary //



global proc dynFuncExplosion()
{
// First delete anything that might be left over
// from a previous test.
//
file -f -new;
currentTime -e 1;
// Display information to the user about what to expect from this
// subtest and give some time for the user to read this information.
//
print( "\nBOOM!\n" );
system( "sleep 1" );
// Create emitter to be the source of the particles eminating from
// the explosion. Add an internal variable to the emitter to
// control amplitude attributes of the emitter. Render the particles
// as multi streaks.
//
emitter -type omni -r 100 -mnd 0 -mxd 0 -spd 1 -pos 0 0 0 -n Explosion;
addAttr -sn "ii" -ln "InternalIntensity" -dv 5 -min 0
-max 100 Explosion;
particle -name ExplosionParticle;
connectDynamic -em Explosion ExplosionParticle;
setAttr ExplosionParticleShape.particleRenderType 1; // MultiStreak
// Link some renderable attributes to the particles.
//
addAttr -ln colorAccum -dv true ExplosionParticleShape;
addAttr -ln lineWidth -dv 1.0 ExplosionParticleShape;
addAttr -ln multiCount -dv 10.0 ExplosionParticleShape;
addAttr -ln multiRadius -dv 0 ExplosionParticleShape;
addAttr -ln normalDir -dv 2.0 ExplosionParticleShape;
addAttr -ln tailFade -dv 0 ExplosionParticleShape;
addAttr -ln tailSize -dv 3 ExplosionParticleShape;
addAttr -ln useLighting -dv false ExplosionParticleShape;
// Create some user-modifiable attributes to modify the
// explosion.
//
select -replace "Explosion";
addAttr -sn "st" -ln "Start" -dv 10 -min 0 -max 100 Explosion;
addAttr -sn "du" -ln "Duration" -dv 20 -min 0 -max 200 Explosion;
addAttr -sn "in" -ln "Intensity" -dv 10 -min 0 -max 100 Explosion;
addAttr -sn "fu" -ln "Fullness" -dv 10 -min 1 -max 100 Explosion;
addAttr -sn "po" -ln "Power" -dv 10 -min 0 -max 100 Explosion;
// Create the time the explosion has been alive for
// and the fraction of the full explosion for that time.
// Make the explosion intensity a curve instead of
// linear interpolation for the explosion fraction.
// BEWARE of MAGIC NUMBERS!!!!
//
expression -ae true -s " \
Explosion.rate = Explosion.Fullness * 40 * \
Explosion.InternalIntensity; \
ExplosionParticleShape.multiRadius = \
Explosion.Fullness * Explosion.Intensity * 0.005; \
Explosion.speed = Explosion.InternalIntensity \
* Explosion.Power / 10.0; ";
expression -ae true -s " \
if (frame >= Explosion.Start \
&& frame <= Explosion.Start + Explosion.Duration) \
{ \
float $ExplosionLife = frame - Explosion.Start; \
float $ExplosionFraction = 1 - (abs($ExplosionLife - \
Explosion.Duration/2) / (Explosion.Duration/2)); \
Explosion.InternalIntensity = Explosion.Intensity * \
pow($ExplosionFraction, \
121 / pow(Explosion.Power + 1, 2)); \
} \
else \
{ \
Explosion.InternalIntensity = 0; \
}; " -o Explosion;
// Set up the playback options.
//
float $frames = 70;
playbackOptions -min 1 -max $frames -loop once;
// Time how long it takes to play the scene and then determine the
// playback frame rate. Make sure when getting the frame rate
// that no values are divided by zero.
//
float $startTime = ‘timerX‘;
play -wait;
float $elapsed = ‘timerX -st $startTime‘;
float $fps = ($elapsed == 0.0 ? 0.0 : $frames/$elapsed);
// Print the frames per second (fps) of the subtest in the form X.X.
//
print("dynFuncExplosion: Done. (");
print((int)($fps * 10)/10.0 + " fps)\n");
} // dynFuncExplosion //



// dynTestAddAttr.mel
//
// Alias|Wavefront Script File
// MODIFY THIS AT YOUR OWN RISK
//
//
// Creation Date: 31 May 1996; Modified 08 January 2000
// Author: rh
//
// Procedure Name:
// dynTestAddAttr
//
// Description:
// Test adding user attributes to a particle shape.
// Create a particle object, set its render type to
// streak, and add a dynamic attribute "tailSize".
// The streak render plug-in will use the attribute
// "tailSize" if it is available.
//
// Input Arguments:
// None.
//
// Return Value:
// Number of errors that occurred in the test.
// ========== dynTestAddAttr ==========
//
// SYNOPSIS
// Test adding user attributes to a particle shape.
// Create a particle object, set its render type to
// streak, and add a dynamic attribute "tailSize".
// The streak render plug-in will use the attribute
// "tailSize" if it is available.
//
global proc int dynTestAddAttr()
{
// First delete anything that might be left over
// from a previous test.
file -force -new;
currentTime -e 1;
// Create emitter and particle object.
//
emitter -type omni -r 90 -mnd 0 -mxd 0.5 -spd 5 -pos 2 0 2
-n myEmitter;
particle -n myParticle;
connectDynamic -em myEmitter myParticle;
// Set the render mode to streak and add a dynamic
// attribute for the tail size.
//
setAttr myParticleShape.particleRenderType 6; // Streak
addAttr -ln tailSize -dv 4 myParticleShape;
// Set some keyframes on the dynamic attribute.
//
setKeyframe -t 0 -v 0 -at tailSize myParticleShape;
setKeyframe -t 10 -v 1 -at tailSize myParticleShape;
setKeyframe -t 20 -v 2 -at tailSize myParticleShape;
setKeyframe -t 30 -v 5 -at tailSize myParticleShape;
setKeyframe -t 50 -v 10 -at tailSize myParticleShape;
setKeyframe -t 70 -v 5 -at tailSize myParticleShape;
setKeyframe -t 90 -v 1 -at tailSize myParticleShape;
setKeyframe -t 100 -v 0 -at tailSize myParticleShape;
// Check for correct tail size at start of test.
//
//
currentTime -e 0;
int $errors = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -