Source for file raytrace.php
Documentation is available at raytrace.php
require_once 'Image/3D.php';
// resize image according to this factor
$light = $world->createLight ('Light', array (-4 * $factor, -4 * $factor, 0 ));
$lightSphere = $world->createObject ('sphere', array ('r' => $factor, 'detail' => 0 ));
$lightSphere->transform ($world->createMatrix ('Move', array (-4 * $factor, -4 * $factor, 0 )));
$light = $world->createLight ('Light', array (4 * $factor, -4 * $factor, 0 ));
$lightSphere = $world->createObject ('sphere', array ('r' => $factor, 'detail' => 0 ));
$lightSphere->transform ($world->createMatrix ('Move', array (4 * $factor, -4 * $factor, 0 )));
$bottom = $world->createObject ('polygon', array (
$top = $world->createObject ('polygon', array (
$redPlane = $world->createObject ('polygon', array (
$bluePlane = $world->createObject ('polygon', array (
$world->transform ($world->createMatrix ('Rotation', array (10 , 0 , 0 )));
// Create normal GD picture with projection
echo "Render with projection.\n";
$renderer = $world->createRenderer ('perspectively');
$driver = $world->createDriver ('GD');
$world->render (15 * $factor, 15 * $factor, 'Image_3D_No_Raytrace.png');
// Raytrace advanced crazy picture
$renderer = $world->createRenderer ('Raytrace');
// Define the cameras position
// define antialiasing level
$renderer->setRaysPerPixel (2 );
// Set recursive scan depth
$renderer->enableShadows (true );
$world->render (15 * $factor, 15 * $factor, 'Image_3D_Raytrace.png');
Documentation generated on Mon, 11 Mar 2019 15:48:14 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|