追加したパーティクル アトリビュートをテストする

スクリプト作成: Ramsey Harris(Autodesk (旧 Alias) Santa Barbara Development Center)

スクリプト dynTestAddAttr.mel は、ダイナミクスを試します。tailSize という追加アトリビュートにキーフレームを設定してパーティクルのシェイプを追加します。パーティクルは単純なポイント エミッタから放出されます。

dynTestAddAttr.mel

// dynTestAddAttr.mel
//
// Alias 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;
 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 //