Ejemplo n.º 1
0
<?php

set_time_limit(0);
require_once __DIR__ . '/../../vendor/autoload.php';
$world = new Image_3D();
$world->setColor(new Image_3D_Color(0, 0, 0));
$light1 = $world->createLight('Light', array(-300, 0, -300));
$light1->setColor(new Image_3D_Color(252, 175, 62));
$light2 = $world->createLight('Light', array(300, -300, -300));
$light2->setColor(new Image_3D_Color(164, 0, 0));
$count = 3;
$size = 20;
$offset = 10;
for ($x = -($count - 1) / 2; $x <= ($count - 1) / 2; ++$x) {
    for ($y = -($count - 1) / 2; $y <= ($count - 1) / 2; ++$y) {
        for ($z = -($count - 1) / 2; $z <= ($count - 1) / 2; ++$z) {
            //        	if (max(abs($x), abs($y), abs($z)) < ($count - 1) / 2) continue;
            if (max($x, $y, $z) <= 0) {
                continue;
            }
            $cube = $world->createObject('quadcube', array($size, $size, $size));
            $cube->setColor(new Image_3D_Color(255, 255, 255, 75));
            $cube->transform($world->createMatrix('Move', array($x * ($size + $offset), $y * ($size + $offset), $z * ($size + $offset))));
        }
    }
}
$world->transform($world->createMatrix('Rotation', array(220, 50, 0)));
$world->transform($world->createMatrix('Scale', array(2, 2, 2)));
$world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, true);
$world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true);
$world->createRenderer('perspectively');
Ejemplo n.º 2
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
// resize image according to this factor
$factor = 5;
$world = new Image_3D();
$world->setColor(new Image_3D_Color(255, 255, 255));
$light = $world->createLight('Light', array(-4 * $factor, -4 * $factor, 0));
$light->setColor(new Image_3D_Color(255, 255, 255, 100));
$lightSphere = $world->createObject('sphere', array('r' => $factor, 'detail' => 0));
$lightSphere->transform($world->createMatrix('Move', array(-4 * $factor, -4 * $factor, 0)));
$lightSphere->setColor(new Image_3D_Color(255, 255, 255, 100));
$light = $world->createLight('Light', array(4 * $factor, -4 * $factor, 0));
$light->setColor(new Image_3D_Color(255, 255, 255, 100));
$lightSphere = $world->createObject('sphere', array('r' => $factor, 'detail' => 0));
$lightSphere->transform($world->createMatrix('Move', array(4 * $factor, -4 * $factor, 0)));
$lightSphere->setColor(new Image_3D_Color(255, 255, 255, 100));
$p = array();
$bottom = $world->createObject('polygon', array(new Image_3D_Point(-5 * $factor, 3 * $factor, 5 * $factor), new Image_3D_Point(-5 * $factor, 3 * $factor, -5 * $factor), new Image_3D_Point(5 * $factor, 3 * $factor, -5 * $factor), new Image_3D_Point(5 * $factor, 3 * $factor, 5 * $factor)));
$bottom->setColor(new Image_3D_Color(200, 200, 200, 0, 0.6));
$top = $world->createObject('polygon', array(new Image_3D_Point(-5 * $factor, 5 * $factor, 5 * $factor), new Image_3D_Point(5 * $factor, 5 * $factor, 5 * $factor), new Image_3D_Point(5 * $factor, -5 * $factor, 5 * $factor), new Image_3D_Point(-5 * $factor, -5 * $factor, 5 * $factor)));
$top->setColor(new Image_3D_Color(200, 200, 200, 0, 0.5));
$redPlane = $world->createObject('polygon', array(new Image_3D_Point(-5 * $factor, 1 * $factor, 2 * $factor), new Image_3D_Point(-5 * $factor, 1 * $factor, -2 * $factor), new Image_3D_Point(-1 * $factor, -1 * $factor, -2 * $factor), new Image_3D_Point(-1 * $factor, -1 * $factor, 2 * $factor)));
$redPlane->setColor(new Image_3D_Color(255, 0, 0, 100, 0));
$bluePlane = $world->createObject('polygon', array(new Image_3D_Point(5 * $factor, 1 * $factor, 2 * $factor), new Image_3D_Point(5 * $factor, 1 * $factor, -2 * $factor), new Image_3D_Point(1 * $factor, -1 * $factor, -2 * $factor), new Image_3D_Point(1 * $factor, -1 * $factor, 2 * $factor)));
$bluePlane->setColor(new Image_3D_Color(100, 100, 255, 0, 0));
$world->transform($world->createMatrix('Rotation', array(10, 0, 0)));
if (!@$argv[1]) {
    // Create normal GD picture with projection
    echo "Render with projection.\n";
    $renderer = $world->createRenderer('perspectively');
Ejemplo n.º 3
0
<?php

set_time_limit(0);
require_once __DIR__ . '/../../vendor/autoload.php';
$world = new Image_3D();
$world->setColor(new Image_3D_Color(240, 240, 240));
$light = $world->createLight('Light', array(-20, -20, -20));
$light->setColor(new Image_3D_Color(100, 100, 255));
$text = $world->createObject('text', 'Image_3D_Object_Text');
$text->setColor(new Image_3D_Color(150, 150, 150));
$text->transform($world->createMatrix('Rotation', array(0, 10, 0)));
$text->transform($world->createMatrix('Move', array(-50, 0, 20)));
$text->transform($world->createMatrix('Scale', array(3, 3, 3)));
$world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, false);
$world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true);
$world->createRenderer('perspectively');
$world->createDriver('GD');
$world->render(400, 50, 'Image_3D_Object_Text.png');
echo $world->stats();
Ejemplo n.º 4
0
<?php

set_time_limit(0);
require_once __DIR__ . '/../../vendor/autoload.php';
$world = new Image_3D();
$world->setColor(new Image_3D_Color(50, 50, 50));
$light1 = $world->createLight('Light', array(-20, -20, -20));
$light1->setColor(new Image_3D_Color(255, 255, 255));
$light2 = $world->createLight('Light', array(20, 20, -20));
$light2->setColor(new Image_3D_Color(0, 200, 0));
$p1 = $world->createObject('polygon', array(new Image_3D_Point(-30, 100, 0), new Image_3D_Point(-30, -150, 0), new Image_3D_Point(80, 0, 30)));
$p1->setColor(new Image_3D_Color(100, 200, 100));
$p2 = $world->createObject('polygon', array(new Image_3D_Point(-100, 50, 30), new Image_3D_Point(-70, -100, -20), new Image_3D_Point(150, 90, 0)));
$p2->setColor(new Image_3D_Color(100, 100, 200));
$p2 = $world->createObject('polygon', array(new Image_3D_Point(-30, 20, -50), new Image_3D_Point(-50, -30, -80), new Image_3D_Point(50, 30, 40)));
$p2->setColor(new Image_3D_Color(200, 100, 100, 100));
$world->transform($world->createMatrix('Rotation', array(90, 90, 0)));
$world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, false);
$world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true);
$world->createRenderer('perspectively');
$world->createDriver('ZBuffer');
$world->render(400, 400, 'Image_3D_ZBuffer.png');
echo $world->stats();
Ejemplo n.º 5
0
<?php

set_time_limit(0);
require_once __DIR__ . '/../../vendor/autoload.php';
$world = new Image_3D();
$world->setColor(new Image_3D_Color(250, 250, 250));
$light = $world->createLight('Point', array(0, -200, 0, 'distance' => 300, 'falloff' => 2));
$light->setColor(new Image_3D_Color(150, 150, 255));
$steps = 10;
$step = 20;
for ($i = 0; $i < $steps; ++$i) {
    $y = $steps * $step / -2 + $i * $step;
    $p = $world->createObject('polygon', array(new Image_3D_Point(-100, $y, -30), new Image_3D_Point(-100, $y, 50), new Image_3D_Point(100, $y, 40)));
    $p->setColor(new Image_3D_Color(255, 255, 255));
}
$world->transform($world->createMatrix('Rotation', array(20, 0, 0)));
$world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, false);
$world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true);
$world->createRenderer('perspectively');
$world->createDriver('ZBuffer');
$world->render(400, 400, 'Image_3D_Pointlight.png');
echo $world->stats();
Ejemplo n.º 6
0
<?php

set_time_limit(0);
require_once __DIR__ . '/../../vendor/autoload.php';
$world = new Image_3D();
$world->setColor(new Image_3D_Color(80, 80, 80));
$light = $world->createLight('Light', array(-1000, -1000, -1000));
$light->setColor(new Image_3D_Color(255, 255, 255));
$redSpot = $world->createLight('Spotlight', array(0, 0, -200, 'aim' => array(0, -25, 0), 'angle' => 30, 'float' => 2));
$redSpot->setColor(new Image_3D_Color(255, 0, 0));
$blueSpot = $world->createLight('Spotlight', array(0, 0, -200, 'aim' => array(-35, 25, 0), 'angle' => 30, 'float' => 2));
$blueSpot->setColor(new Image_3D_Color(0, 0, 255));
$greenSpot = $world->createLight('Spotlight', array(0, 0, -200, 'aim' => array(35, 25, 0), 'angle' => 30, 'float' => 2));
$greenSpot->setColor(new Image_3D_Color(0, 255, 0));
$bezier = $world->createObject('bezier', array('x_detail' => 120, 'y_detail' => 120, 'points' => array(array(array(200, -150, -200), array(-100, 150, 600), array(-300, 150, -600), array(200, -150, 200)), array(array(0, -200, -100), array(0, 100, 250), array(0, 200, -250), array(0, -100, 100)), array(array(-150, -150, -200), array(200, 150, 300), array(200, 200, -300), array(-150, -150, 200)))));
$bezier->setColor(new Image_3D_Color(250, 250, 250));
$bezier->transform($world->createMatrix('Rotation', array(0, 120, 180)));
$renderer = $world->createRenderer('perspectively');
$world->createDriver('ZBuffer');
$world->render(400, 400, 'example.png');
echo $world->stats();