Exemple #1
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $stl = new AsciiSTL($input->getArgument('stl'));
     $scene = new Scene();
     $scene->addObject((new Grid())->asObject(new Color('#1F1F1F')));
     $scene->addObject((new Axis())->asObject(new Color('#00FF00')));
     $scene->addObject($stl->asObject()->position(0, 10000, 0)->rotate(0, 0, 180));
     $scene->camera->position(0, 10000, -23000)->rotate(rand(-20, 20), rand(-20, 20), 0);
     (new Renderer($scene))->render($input->getArgument('output'));
 }
Exemple #2
0
 /**
  * @param $object
  */
 private function renderWireframe($object)
 {
     foreach ($object->polygons as $polygon) {
         $point_count = count($polygon->points);
         for ($n = 0; $n < $point_count; $n++) {
             $a = $this->scene->project($polygon->points[$n]);
             $b = $this->scene->project($polygon->points[($n + 1) % $point_count]);
             if (-$a->z > 1 && -$b->z > 1) {
                 $this->image->line($a, $b, $object->color);
             }
         }
     }
 }