Random walk pyramids

February 5th, 2009

MEL code follows:

// triangle face growth MEL script

//make a cone and select it
select `polyCone -r 1 -h 1.414214 -sx 3 -n "pCone1"`;

for ($i=0; $i<500; ++$i) {
  //get cone
  $cone = `ls -sl`;

  //select a random face
  int $r = rand(4);
  $sel = ( $cone[0] + ".f[" + $r + "]" );
  select $sel;

  //find approximate center of face
  float $bbox[] = `exactWorldBoundingBox $sel`;
  $fc = <<($bbox[3]+$bbox[0])/2,
          ($bbox[4]+$bbox[1])/2,
          ($bbox[5]+$bbox[2])/2>>;

  //instance cone
  select `instance $cone`;
  $new = `ls -sl`;

  //move instance to face
  //cheat values counteract face centering approximation, I think
  xform -t ($fc.x-.125) ($fc.y+.175) ($fc.z) $new;

  setKeyframe -attribute "visibility" -v 0 -t 0 $new;
  setKeyframe -attribute "visibility" -v 1 -t $i $new;
}
//eof
« previously: Random walk keyframed blocks in MEL | Home | next: Aligned faces pyramid worm »

Leave a Reply