Location: PHPKode > projects > PHP Cad and Drawing Program > pov.php
<?php
session_start();
$pfilez=$_SESSION[pfilez];
$zz=fopen("p.pov", "w");

$ot =
"//
//  $pfilez - POV-RAY 3D File
//\n";
fwrite($zz,$ot);

// This is necessary to include the povray include files
// my as well include them all
$b = opendir("./povray");
$inclist = array();
while($file = readdir($b)) {
    if (ereg("inc",$file)) array_push($inclist,$file);
}
foreach ($inclist as $incname) {
    $a="./povray/$incname";
    $ot="#include " . '"' . $a . '"' . "\n";
    fwrite($zz,$ot);
}


$ot=<<<BLOCK
#include "colors.inc"
#include "textures.inc"
#include "metals.inc"
#include "skies.inc"
#include "glass.inc"
#include "woods.inc"
#include "stones.inc"
// Setup Sky
sky_sphere{S_Cloud2}
// Setup camera location, and coordinate system
// Coordinate System is
// <0,10,0> is top left corner of phpcad drawing with a z of 10.
// <left-right on phpcad picture or X, verticle or Z, up-down on phpcad picture or Y>
camera {
    location <45,20,120>
    right  <-1,0,0>
    look_at <45,5,25>
 }

// I haven't tested this in a while
// To do a circle fly around.
// You need to edit the .ini file to do movies.
// camera {
    // location <50*sin(2*pi*clock)+30,30,-50*cos(2*pi*clock)+30>
    // right <0,0,-1>
    // look_at <30,0,30>
// }

light_source{<50,200,500> 1}
global_settings { assumed_gamma 1 }
// global_settings { ambient_light <2,2,2> }

background{rgb 1}
BLOCK;
fwrite($zz,$ot);

    $ccccc="";
    $b = opendir("./functions");
    $inclist = array();
    while($file = readdir($b)) {
        if (ereg("inc",$file)) array_push($inclist,$file);

    }
    sort($inclist);
    foreach ($inclist as $incname) {
        $zzz = file("./functions/$incname");
        foreach ($zzz as $lineitem) {
            if (substr_count($lineitem,"C")>15) $ptr="c";
            if (substr_count($lineitem,"D")>15) $ptr="d";
            if ($ptr=="C") $ccccc=$ccccc . $lineitem;
            if ($ptr=="c") $ptr="C";
        }
    }
// what this should do is load all the povray functions into memory.
eval($ccccc);
$ot=<<<BLOCK
#declare LandArea =
    texture { T_Stone13 //T_Grnt19
        normal { bumps 2 scale 20 }
        finish { phong .1}
    }

plane{y,0 texture{LandArea}}
BLOCK;
fwrite($zz,$ot);

//$twall="texture{T_Grnt1}";
$troof="texture {T_Silver_1B}";
$troof="texture {T_Silver_1E}";
$twall="texture{T_Grnt1} pigment{White}";
$tfoundation="texture{T_Wood11}";
$image="zzz";
$floor=0;
include ("./files/$pfilez");
fclose($zz);
chmod("./p.pov",0666);
header("Location: ./p.pov");
?>
Return current item: PHP Cad and Drawing Program