<?

// cube.php
// feedback to fatz@fatkids.com
// spits out a flash rotating cube rendered in perspective

  
$points = array(
          array( -
200, -100, -200) ,
          array( 
200, -100, -200),
          array( 
200, -100200),
          array( 
200, -100, -200),
          array( 
200100, -200),
          array( -
200100, -200),
          array( -
200100200),
          array( -
200100, -200),
          array( -
200, -100, -200),
                  array( -
200, -100200) ,
          array( 
200, -100200),
          array( 
200100200),
          array( 
200100, -200),
          array( 
200100200),
          array( -
200100200),
          array( -
200, -100200)
          );
                  

  
$t = new SWFText();
  
$t->moveTo(100100);
  
$t->setColor(0xff0xff0);
  
$t->setHeight(100);

  
$p = new SWFSprite();


  
$p->nextFrame();
  


  
$m = new SWFMovie();
  
$m->setRate(30);
  
$m->setBackground(0xff0xff0xff);
  
$m->setDimension(1000,1000);

  
$i3d = -1;
  for(
$roll 0$roll 360$roll++)
  {
    
$s[$roll] = new SWFShape();
    
$s[$roll]->setLine(2,255,0,0,100);
    if (
$i3d != -1)
    {
      
$m->nextFrame();
      
$m->remove($i3d);
    }
    
$distance 3000;
    
$max_x 800;
    
$max_y 800;
    
$point_num 0;
    foreach(
$points as $onepoint)
    {
     list(
$x,$y,$z) = $onepoint;
     
$a =  -15/180*3.1415926;
     
$b $roll/120*3.1415926;
    
$c $roll/120*3.1415926;
     list(
$x,$y,$z) = Array($x*Cos($c)-$z*Sin($c),$y,$z*Cos($c)+$x*Sin($c)); // rotate about y
    
$newpoint = Array($x,$y*Cos($a)-$z*Sin($a),$z*Cos($t)+$y*Sin($t));
     
$newpoint[2] += 300;
     
$newpoint[2] += 1900;
     if(
$newpoint[2] == 0) { $newpoint[2] = 0.001; }
     
$screen_x floor($max_x $distance*($newpoint[0] / $newpoint[2]));
     
$screen_y floor($max_y $distance*($newpoint[1] / $newpoint[2]));
     if((
$screen_x <= 10000) AND ($screen_x >= -10000) AND ($screen_y <= 10000) AND ($screen_x >= -10000)) {
     if (
$point_num++ < 1) {
        
$s[$roll]->movePen($screen_x,$screen_y);
       }
     else
       {
        
$s[$roll]->drawLineTo($screen_x,$screen_y); 
       }
     }
    } 
    
$i3d $m->add($s[$roll]);
  }
  
$m->add(new SWFAction("gotoFrame(1); play();"));
  
$m->nextFrame();




  
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  
header('Content-type: application/x-shockwave-flash');
  
$m->output();
?>