📄 1028a.mel
字号:
float $tailSize = ‘getAttr myParticle.tailSize‘;
if ( $tailSize != 0 ) // Warning Magic#
{
print( "dynTestAddAttr: Failure: Start of test: The tail "
+ "size ("+ $tailSize + ") should be 0.\n" );
$errors += 1;
}
// Set up the playback options.
//
float $frames = 50;
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);
// Check for correct tail size at middle of test.
//
$tailSize = ‘getAttr myParticle.tailSize‘;
if ( ($tailSize < 9.9) || ($tailSize > 10.1) ) // Warning Magic#
{print( "dynTestAddAttr: Failure: Frame 50: The tail size ("
+ $tailSize + ") should be about 10.\n" );
$errors += 1;
}
// Print the frames per second (fps) in the form X.X of subtest.
//
print( "dynTestAddAttr: Subtest 1. (" + (int)($fps * 10)/10.0 +
" fps)\n");
// Set up the playback options.
//
$frames = 100;
playbackOptions -min 1 -max $frames -loop once;
currentTime -e 1;
// 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.
//
$startTime = ‘timerX‘;
play -wait;
$elapsed = ‘timerX -st $startTime‘;
$fps = ($elapsed == 0.0 ? 0.0 : $frames/$elapsed);
// Check for correct tail size at end of test.
//
$tailSize = ‘getAttr myParticle.tailSize‘;
if ( $tailSize > 0.1 )
{
print( "dynTestAddAttr: Failure: End of test: The "
+ "tail size (" + $tailSize + ") should be close to 0.\n");
$errors += 1;
}
// If there are no errors, the addAttr passed this test.
//
if ( $errors == 0 )
print( "dynTestAddAttr: Passed. (" );
else
print( "dynTestAddAttr: Failed. (" );
// Print the frames per second (fps) in the form X.X.
//
print((int)($fps * 10)/10.0 + " fps)\n");
// Reset the current time to zero so user can replay the test.
//
currentTime -e 1;
return $errors;
} // dynTestAddAttr //
// dynTestEvent.mel
//
// Alias|Wavefront Script File
// MODIFY THIS AT YOUR OWN RISK
//
//
// Creation Date: 4 September 1996; Modified 09 January 2000
// Author: robt, js
//
// Procedure Name:
// dynTestEvent
//
// Description:
// Test the basic functionality of collision events.
//
// Input Arguments:
// None.
//
// Return Value:
// Number of errors that occurred in the test.
// ========== dynTestEvent ==========
//
// SYNOPSIS
// Test the basic functionality of collision events.
//
global proc int dynTestEvent()
{
// First delete anything that might be left over
// from a previous test.
//
file -force -new;
currentTime -e 1;
int $errors = 0;
// Create the planes to bounce off.
nurbsPlane -d 3 -p 0 0 0 -w 1.5cm -lr 1 -axis 0cm 0cm 0cm
-name table;
scale 10 10 10;
rotate -1.5708rad 0rad 0rad;
move -os 0.5 0.5 0;
move -r -5 0 5;
rotate -r 10 0 0;
// Create the particle shapes to do the bouncing and splitting.
// Material assignments will be interesting only if the lighting is
// set.
//
particle -inherit 1.0 -p 0 5 -3 -n blueParticles;
addAttr -ln colorBlue -dv 1.0 -at double blueParticlesShape;
particle -inherit 1.0 -p 0 5 -3.5 -n redParticles;
addAttr -ln colorRed -dv 1.0 -at double redParticlesShape;
particle -inherit 1.0 -p 0 5 -3.5 -n greenParticles;
addAttr -ln colorGreen -dv 1.0 -at double redParticlesShape;
gravity -pos 10 10 10 -m 20 -name gravityField;
// Warning: Changing resilience will change the (hardcoded)
// number of particles that this test expects to create.
//
collision -r 1.0 -f 0.01 table;
connectDynamic -f gravityField -c table blueParticles redParticles
greenParticles;
event -split 2 -sp 0.2 blueParticles;
event -emit 3 -die true -sp 0.2 redParticles;
event -emit 1 greenParticles;
// Set up the playback options.
//
float $frames = 55;
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);
// Check whether any blue particles went through the boundary.
//
if ( ‘getAttr blueParticles.boundingBoxMinZ‘
< ‘getAttr table.boundingBoxMinZ‘ )
{
print( "dynTestEvent: Failure: \"blueParticles\" particles "
+ "went through boundary.\n" );
$errors += 1;
}
// Check whether any red particles went through the boundary.
if ( ‘getAttr redParticles.boundingBoxMinZ‘
< ‘getAttr table.boundingBoxMinZ‘ )
{
print( "dynTestEvent: Failure: \"redParticles\" particles "
+ "went through boundary.\n" );
$errors += 1;
}
// Make sure that the blue particle hit one Z wall, creating two
// particles that each hit the other Z wall to create four total particles.
// This is visually apparent from the side and front views together.
//
int $blueParticles_i = ‘particle -count -q blueParticles‘;
if ( $blueParticles_i != 4 && ! $errors ) // Warning Magic#
{
print( "dynTestEvent: Failure: There are " + $blueParticles_i
+ " \"blueParticles\" particles instead of the correct "
+ "value, 4.\n" );
$errors += 1;
}
// Test that the number of events resulting in a red particle
// creation is correct.
//
int $redParticles_i = ‘particle -count -q redParticles‘;
if ( $redParticles_i != 9 && ! $errors ) // Warning Magic#
{
print( "dynTestEvent: Failure: There are " + $redParticles_i
+ " \"redParticles\" particles instead of the correct "
+ "value, 9.\n" );
$errors += 1;
}
// Check the totalEventCount variable.
//
if ((‘getAttr redParticles.totalEventCount‘ != 4) ||
(‘getAttr blueParticles.totalEventCount‘ != 3))
{
print( "dynTestEvent: Failure: Event count attributes had " +
"incorrect value(s).\n" );
$errors += 1;
}
// Check the event attribute on the green particles.
//
float $event[] = ‘particle -at event -order 0 -q greenParticlesShape‘;
if ($event[0] != 2)
{
print( "dynTestEvent: Failure: Event attribute had incorrect" +
"value(s).\n" );
$errors += 1;
}
// If there are no errors, the events passed this test.
//
if ( $errors == 0 )
{
print( "dynTestEvent: Passed. (" );
}
else
{
print( "dynTestEvent: Failed. (" );
}
// Print the frames per second (fps) in the form X.X.
//
print( (int)($fps * 10)/10.0 + " fps)\n" );
// Reset the current time to zero so user can replay the test.
//
currentTime -e 1;
return $errors;
} // dynTestEvent //
// Alias|Wavefront Script File
// MODIFY THIS AT YOUR OWN RISK
//
// Creation Date: 8 May 1996
// Author: rh
//
// Description:
// Playback from frame 0 to frame <n> and return the
// the playback rate in frames/sec. If a negative frame
// count is given, this indicates silent mode. In silent
// mode, no output is printed.
//
// This version is intended for use in batch tests of dynamics.
// It requests particle and rigid body positions every frame.
//
// RETURN
// Frame rate in frames/sec
//
global proc float dynTimePlayback( float $frames )
{
int $silent;
// Get the list of particle shapes.
//
string $particleObjects[] = ‘ls -type particle‘;
int $particleCount = size( $particleObjects );
// Get the list of transforms.
// This will include rigid bodies.
//
string $transforms[] = ‘ls -tr‘;
int $trCount = size( $transforms );
// Check for negative $frames. This indicates
// $silent mode.
//
if ($frames < 0)
{
$silent = 1;
$frames = -$frames;
}
else
{
$silent = 0;
}
// Setup the playback options.
//
playbackOptions -min 1 -max $frames -loop "once";
currentTime -edit 0;
// Playback the animation using the timerX command
// to compute the $elapsed time.
//
float $startTime, $elapsed;
$startTime = ‘timerX‘;
// play -wait;
int $i;
for ($i = 1; $i < $frames; $i++ )
{
// Set time
//
currentTime -e $i;
int $obj;
// Request count for every particle object.
//
for ($obj = 0; $obj < $particleCount; $obj++)
{
string $cmd = "getAttr " + $particleObjects[$obj]+".count";
eval( $cmd );
}
// Request position for every transform
// (includes every rigid body).
//
for ($obj = 0; $obj < $trCount; $obj++)
{
string $cmd = "getAttr " + $transforms[$obj]+".translate";
eval ($cmd);
}
}
$elapsed = ‘timerX -st $startTime‘;
// Compute the playback frame $rate. Print results.
//
float $rate = ($elapsed == 0 ? 0.0 : $frames / $elapsed) ;
if ( ! $silent)
{
print( "Playback time: " + $elapsed + " secs\n" );
print( "Playback $rate: " + $rate + " $frames/sec\n" );
}
return ( $rate );
} // timePlayback //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -