Lesson 2

todo:
//+if statement
//+functions + attributes
//+adding keys

proc makeGrid(int $dimensions){
int $i;
int $k;
for($i = 0; $i < $dimensions; $i++)
    {
        for( $k = 0; $k < $dimensions; $k++)
        {
        CreatePolygonCube;
        move -r $k 0 $i;
        }
    }
};
makeGrid(50);
 
 
global float $buffer1[];
global float $buffer2[];
global float $temp[];
global float $damping = 0.95;
 
 
 
global proc step(){
	global float $buffer1[];
	global float $buffer2[];
	global float $damping;
	int $width = 50;
	int $count;
 
 
	for($y = 1; $y < $width -1; $y++)
	{
		for($x = 1; $x < $width - 1; $x++)
 
		{	
			$i = $y *50+$x;		
			//if($buffer2[$i] > 0)
			//	print($buffer2[$i] + "\n");
 
			float $tdlu = $buffer1[$i-1] + $buffer1[$i+1] + $buffer1[$i - $width] + $buffer1[$i + $width];
			 $buffer2[$i] = ($tdlu/2  - $buffer2[$i]);
			 $buffer2[$i] = int($buffer2[$i]) * $damping;
 
			setAttr ("pCube"+$i+".translateY") ($buffer2[$i]/(140/15));
			setKeyframe ("pCube"+$i+".ty");
		}
	}	
}
 
int $steps = 1;
int $maxSteps = 100;
while($steps < $maxSteps)
{
	step();
	int $u;
	for($u = 0; $u < 2500; $u++){
		$temp[$u] 	 = $buffer1[$u];
		$buffer1[$u] = $buffer2[$u];
		$buffer2[$u] = $temp[$u];
		//add some impact points in relation to time and radius
		if($steps == 50 && $u ==540)			
			$buffer2[$u] = 300;
		else if($steps == 23 && $u == 561)
			$buffer2[$u] = 30;
		else if($steps == 35 && $u == 685)
			$buffer2[$u] = 10;
		else if($steps == 30 && $u == 685)
			$buffer2[$u] = 60;
		else if($steps == 28 && $u == 1294)
			$buffer2[$u] = 90;
		else if($steps == 48 && $u == 1767)
			$buffer2[$u] = 200;
		else if($steps == 60 && $u == 1265)
			$buffer2[$u] = 120;
	}
$steps++;
currentTime $steps -update false;
print("steps left " + ($maxSteps - $steps) + "\n");
}

No Comments

Add Comment