Image_3D
[ class tree: Image_3D ] [ index: Image_3D ] [ all elements ]

Source for file dynamic_cubes.php

Documentation is available at dynamic_cubes.php

  1. <?php
  2.  
  3. require_once('Image/3D.php');
  4.  
  5. $world = new Image_3D();
  6. $world->setColor(new Image_3D_Color(0, 0, 0));
  7.  
  8. $light1 = $world->createLight('Light', array(-300, 0, -300));
  9. $light1->setColor(new Image_3D_Color(252, 175, 62));
  10.  
  11. $light2 = $world->createLight('Light', array(300, -300, -300));
  12. $light2->setColor(new Image_3D_Color(164, 0, 0));
  13.  
  14. $count = 3;
  15.  
  16. $size = 20;
  17. $offset = 10;
  18.  
  19. for ($x = -($count - 1) / 2; $x <= ($count - 1) / 2; ++$x) {
  20.     for ($y = -($count - 1) / 2; $y <= ($count - 1) / 2; ++$y) {
  21.         for ($z = -($count - 1) / 2; $z <= ($count - 1) / 2; ++$z) {
  22. //            if (max(abs($x), abs($y), abs($z)) < ($count - 1) / 2) continue;
  23.             if (max($x, $y, $z) <= 0) continue;
  24.             
  25.             $cube = $world->createObject('quadcube', array($size, $size, $size));
  26.             $cube->setColor(new Image_3D_Color(255, 255, 255, 75));            
  27.             $cube->transform($world->createMatrix('Move', array($x * ($size + $offset), $y * ($size + $offset), $z * ($size + $offset))));
  28.         }
  29.     }
  30. }
  31.  
  32. $world->transform($world->createMatrix('Rotation', array(220, 50, 0)));
  33. $world->transform($world->createMatrix('Scale', array(2, 2, 2)));
  34.  
  35. $world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, true);
  36. $world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true);
  37.  
  38. $world->createRenderer('perspectively');
  39. $world->createDriver('DynamicCanvas');
  40. $world->render(250, 250, 'Image_3D_Dynamic_Cubes.js');
  41.  
  42. echo $world->stats();

Documentation generated on Mon, 11 Mar 2019 15:48:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.