-
///////////////////////////////////////////
///////////////////////////////////////////
// ANIMATING WITH TRANSFORMATIONS
///////////////////////////////////////////
//////////////////////////////////////////////
///////////////////////////////////////////////
///Animating a object to move along a path
//make a spiral
$turtle = aa_turtle_newturtle("CURVE");
$i = 0;
while($i++ < 10){
aa_turtle_turn($turtle,40,0);
aa_turtle_move($turtle,($i * 5));
}
///////////////////////////////////////////////
//how to use the currentTime
currentTime 1;
//"animate the curve"
$turtle = aa_turtle_newturtle("CURVE");
$i = 0;
while($i++ < 20){
aa_turtle_turn($turtle,40,0);
aa_turtle_move($turtle,($i * 5));
currentTime $i;
}
///////////////////////////////////////////////
//use that spiral to position spheres
$turtle = aa_turtle_newturtle("CURVE");
$sphere = `sphere`;
scale 10 10 10;
$i = 0;
while($i++ < 20){
aa_turtle_turn($turtle,40,0);
aa_turtle_move($turtle,($i * 5));
$position = aa_turtle_getPosition($turtle);
move $position[0] $position[1] $position[2] $sphere[0];
currentTime 1;
}
///////////////////////////////////////////////
//use that spiral to position spheres & animate
//NOTE MUST SET CURRENT TIME BEFORE MOVING
$turtle = aa_turtle_newturtle("CURVE");
$sphere = `sphere`;
scale 10 10 10;
$i = 0;
while($i++ < 50){
aa_turtle_turn($turtle,40,0);
aa_turtle_move($turtle,($i * 5));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 10);
move $position[0] $position[1] $position[2] $sphere[0];
setKeyframe $sphere;
}
///////////////////////////////////////////////
//keyframe scale as well
$turtle = aa_turtle_newturtle("CURVE");
$sphere = `sphere`;
scale 10 10 10;
$i = 0;
while($i++ < 20){
aa_turtle_turn($turtle,40,0);
aa_turtle_move($turtle,($i * 5));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 10);
move $position[0] $position[1] $position[2] $sphere[0];
scale $i $i $i $sphere[0];
setKeyframe $sphere[0];
}
///////////////////////////////////////////////
//alter the curve
$turtle = aa_turtle_newturtle("CURVE");
$sphere = `sphere`;
scale 10 10 10;
aa_turtle_turn($turtle,0,20);
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,40,0);
aa_turtle_move($turtle,($i * 5));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 2);
move $position[0] $position[1] $position[2] $sphere[0];
scale $i $i $i $sphere[0];
setKeyframe $sphere[0];
}
///////////////////////////////////////////////
//try using random curves
$turtle = aa_turtle_newturtle("CURVE");
$sphere = `sphere`;
scale 10 10 10;
aa_turtle_turn($turtle,0,20);
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(20,50),0);
aa_turtle_move($turtle,($i * 5));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 2);
move $position[0] $position[1] $position[2] $sphere[0];
scale $i $i $i $sphere[0];
setKeyframe $sphere[0];
}
///////////////////////////////////////////////
//random spacing
$turtle = aa_turtle_newturtle("");
$sphere = `sphere`;
scale 10 10 10;
aa_turtle_turn($turtle,0,20);
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(20,50),0);
aa_turtle_move($turtle,($i * rand(1,5)));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 2);
move $position[0] $position[1] $position[2] $sphere[0];
scale $i $i $i $sphere[0];
setKeyframe $sphere[0];
}
///////////////////////////////////////////////
//you can even being to create your own 'particle' systems
global proc particle(){
$turtle = aa_turtle_newturtle("");
$sphere = `sphere`;
scale 10 10 10;
aa_turtle_turn($turtle,0,20);
$i = 0;
while($i++ < 80){
aa_turtle_turn($turtle,rand(20,50),0);
aa_turtle_move($turtle,($i * rand(1,5)));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 4);
move $position[0] $position[1] $position[2] $sphere[0];
scale ($i * rand(1,4)) ($i * rand(1,4)) ($i * rand(1,4)) $sphere[0];
setKeyframe $sphere[0];
}
}
$i = 0;
while($i++ < 20){
particle();
}
///////////////////////////////////////////
///////////////////////////////////////////
// ANIMATING WITH VISIBILITY AND DUPLICATION
///////////////////////////////////////////
//////////////////////////////////////////////
$turtle = aa_turtle_newturtle("CURVE");
$sphere = `sphere`;
scale 10 10 10;
aa_turtle_turn($turtle,0,20);
$i = 0;
while($i++ < 50){
aa_turtle_turn($turtle,rand(20,50),0);
aa_turtle_move($turtle,($i * 5));
$position = aa_turtle_getPosition($turtle);
currentTime ($i * 2);
move $position[0] $position[1] $position[2] $sphere[0];
scale $i $i $i $sphere[0];
if($i % 10 > 5){
setAttr ($sphere[0] + ".visibility") 0;
}else{
setAttr ($sphere[0] + ".visibility") 1;
}
setKeyframe $sphere[0];
}
$turtle = aa_turtle_newturtle("LINE");
$i=0;
while($i++ < 100){
aa_turtle_turn($turtle,20,0);
aa_turtle_move($turtle,($i));
aa_turtle_snapshotAtKeyframe($turtle,$i*10);
}
///////////////////////////////////////////
///////////////////////////////////////////
// ANIMATING MUTIPLE OBJECTS WITH TRANSFORMATIONS
///////////////////////////////////////////
///////////////////////////////////////////
/////////////////////////////////////////////////////////
///Animating a string of objects to 'swing'
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//grow a line of spheres
$turtle = aa_turtle_newturtle("");
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
aa_turtle_move($turtle,10);
$position = aa_turtle_getPosition($turtle);
$sphere = `sphere`;
move $position[0] $position[1] $position[2] $sphere[0];
scale 5 5 5 $sphere[0];
currentTime 1;
}
/////////////////////////////////////////////////////////
//get a list of all the spheres
$turtle = aa_turtle_newturtle("");
string $spheres[];
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
aa_turtle_move($turtle,10);
$position = aa_turtle_getPosition($turtle);
$sphere = `sphere`;
$spheres[$i] = $sphere[0];
currentTime 1;
move $position[0] $position[1] $position[2] $spheres[$i];
scale 5 5 5 $spheres[$i];
setKeyframe $spheres[$i];
}
/////////////////////////////////////////////////////////
//take list of spheres and keyframe them into another position
$turtle = aa_turtle_newturtle("");
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
aa_turtle_move($turtle,10);
$position = aa_turtle_getPosition($turtle);
currentTime 20;
move $position[0] $position[1] $position[2] $spheres[$i];
setKeyframe $spheres[$i];
}
/////////////////////////////////////////////////////////
//wrap in function so it is easy to loop
global proc keyframespheres(string $spheres[],int $keyframe){
$turtle = aa_turtle_newturtle("");
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
aa_turtle_move($turtle,10);
$position = aa_turtle_getPosition($turtle);
currentTime $keyframe;
move $position[0] $position[1] $position[2] $spheres[$i];
$scale = rand(10,15);
scale $scale $scale $scale $spheres[$i];
setKeyframe $spheres[$i];
}
}
/////////////////////////////////////////////////////////
//get a list of all the spheres
$turtle = aa_turtle_newturtle("");
string $spheres[];
$i = 0;
while($i++ < 40){
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
aa_turtle_move($turtle,10);
$position = aa_turtle_getPosition($turtle);
$sphere = `sphere`;
$spheres[$i] = $sphere[0];
currentTime 1;
move $position[0] $position[1] $position[2] $spheres[$i];
scale 10 10 10 $spheres[$i];
setKeyframe $spheres[$i];
}
$turtle = aa_turtle_newturtle("");
$i = 0;
while($i++ < 20){
keyframespheres($spheres,($i * 20));
}
///////////////////////////////////////////
///////////////////////////////////////////
// ANIMATING WITH HISTORY
///////////////////////////////////////////
///////////////////////////////////////////
/////////////////////////////////////////////
// making tubes
//////////////////////////////////////////////
/////////////////////////////////////////////
// make one tube using turtles and extrusion
//////////////////////////////////////////////
//make a circle to use in the extrusion command. Get its name
$ecircle = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1`;
rotate 0 0 90;
scale 10 10 10;
////////////////////////////////////
// Draw the first line and make the extrusion
//make a turtle drawing tool
$turtle = aa_turtle_newturtle("CURVE");
//start a loop, this loops will draw 30 points in a random curve
$i = 0;
while($i < 30){
//move and turn to make points in the curve
aa_turtle_move($turtle,10);
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
$i++;
}
//get the name of the curve and use it to extrude
$ourcurve = aa_turtle_getCurve($turtle);
extrude -ch true -rn false -po 0 -et 2 -ucp 0 -fpt 0 -upn 1 -rotation 0 -scale .1 -rsp 1 $ecircle[0] $ourcurve;
/////////////////////////////////////////////
// animate one step using extrusion
//////////////////////////////////////////////
//make a circle to use in the extrusion command. Get its name
$ecircle = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1`;
rotate 0 0 90;
scale 10 10 10;
////////////////////////////////////
// Draw the first line and make the extrusion
//make a turtle drawing tool
$turtle = aa_turtle_newturtle("CURVE");
//start a loop, this loops will draw 30 points in a random curve
$i = 0;
while($i < 30){
//move and turn to make points in the curve
aa_turtle_move($turtle,10);
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
$i++;
}
//get the name of the curve and use it to extrude
$ourcurve = aa_turtle_getCurve($turtle);
extrude -ch true -rn false -po 0 -et 2 -ucp 0 -fpt 0 -upn 1 -rotation 0 -scale .1 -rsp 1 $ecircle[0] $ourcurve;
////////////////////////////////////
// animate the extrusion
//create a new turtle
$turtle = aa_turtle_newturtle("");
currentTime 1;
//start a loop, , this loops will draw 30 points in a random curve
$i = 0;
while($i < 30){
//move, turn
aa_turtle_move($turtle,10);
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
//get the position of the point
$position = aa_turtle_getPosition($turtle);
//use this position and move the CV from the original curve to match this position
$cv= $ourcurve + ".cv[" + $i + "]";
move $position[0] $position[1] $position[2] $cv;
//key frame it.
setKeyframe $cv;
$i++;
}
/////////////////////////////////////////////
// make the animation tool a function so you can loop it
//////////////////////////////////////////////
//make a circle to use in the extrusion command. Get its name
$ecircle = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1`;
rotate 0 0 90;
scale 10 10 10;
////////////////////////////////////
// Draw the first line and make the extrusion
//make a turtle drawing tool
$turtle = aa_turtle_newturtle("CURVE");
//start a loop, this loops will draw 30 points in a random curve
$i = 0;
while($i < 30){
//move and turn to make points in the curve
aa_turtle_move($turtle,10);
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
$i++;
}
//get the name of the curve and use it to extrude
$ourcurve = aa_turtle_getCurve($turtle);
extrude -ch true -rn false -po 0 -et 2 -ucp 0 -fpt 0 -upn 1 -rotation 0 -scale .1 -rsp 1 $ecircle[0] $ourcurve;
global proc animatetentacle(string $ourcurve,int $keyframe){
////////////////////////////////////
// animate the extrusion
//create a new turtle
$turtle = aa_turtle_newturtle("");
currentTime $keyframe;
//start a loop, , this loops will draw 30 points in a random curve
$i = 0;
while($i < 30){
//move, turn
aa_turtle_move($turtle,10);
aa_turtle_turn($turtle,rand(-20,20),rand(-20,20));
//get the position of the point
$position = aa_turtle_getPosition($turtle);
//use this position and move the CV from the original curve to match this position
$cv= $ourcurve + ".cv[" + $i + "]";
move $position[0] $position[1] $position[2] $cv;
//key frame it.
setKeyframe $cv;
$i++;
}
}
$i = 0;
while($i++ < 30){
animatetentacle($ourcurve,($i * 10));
}
|
class_08
|