/*************************************************** Daniel Loran 01-09-2006 Lab 3 Falling letters effect: Inputs: $textString = text string to animate $topY = initial string y coordinate (falling from) $bottomY = destination y coordinate (falling to) $maxLetterTime = time in frames (range: 30-120, default 60) $letterTimeInterval = waiting time between letters (10-30, default 10) $letterRotationDegree = rotation around Y axis (180 or 360, default 360) Preconditions: 1) $textString is not empty 2) $topY - $bottomY >= 10 ****************************************************/ proc fallingLetters( string $textString, int $topY, int $bottomY, int $maxLetterTime, int $letterTimeInterval, int $letterRotationDegree ){ // open new scene file -f -new; // check precondition (1) if($textString == ""){ error "Text string cannot be empty."; } // check precondition (2) int $deltaY = $bottomY - $topY; if(abs($deltaY) < 10){ error "$topY - $bottomY must be >= 10."; } // warnings if($maxLetterTime < 30 || $maxLetterTime > 120){ $maxLetterTime = 60; warning "$maxLetterTime must be in range 30-120, is now 60."; } if($letterTimeInterval < 10 || $letterTimeInterval > 30){ $letterTimeInterval = 10; warning "$letterTimeInterval must be in range 10-30, is now 10."; } if($letterRotationDegree != 180 && $letterRotationDegree != 360){ $letterRotationDegree = 360; warning "$letterRotationDegree must be 180 or 360, is now 360."; } // get text curve nodes string $nodes[] = `textCurves -text $textString`; string $rootNode = $nodes[0]; // get children of $rootNode string $letters[] = `listRelatives $rootNode`; // move to initial position move -absolute 0 $topY 0 $nodes; // calculate and set total movie time int $minLetterTime = 1; int $maxMovieTime = $maxLetterTime + (size($letters) - 1) * $letterTimeInterval; playbackOptions -minTime $minLetterTime -maxTime $maxMovieTime; // animate curves of each letter for($letter in $letters){ string $curves[] = `listRelatives $letter`; for($curve in $curves){ eval("setKeyframe -time " + $minLetterTime + " -value 0 " + $curve + ".translateY"); eval("setKeyframe -time " + $maxLetterTime + " -value " + $deltaY + " " + $curve + ".translateY"); eval("setKeyframe -time " + $minLetterTime + " -value 0 " + $curve + ".rotateY"); eval("setKeyframe -time " + $maxLetterTime + " -value " + $letterRotationDegree + " " + $curve + ".rotateY"); } $minLetterTime += $letterTimeInterval; $maxLetterTime += $letterTimeInterval; } // set playback options playbackOptions -loop "oscillate"; play; }