cvs: pear /Image_3D generate_package_xml.php package.xml package2.xml /Image_3D/Image 3D.php /Image_3D/Image/3D Color.php Coordinate.php Driver.php
Enlightenable.php Matrix.php Paintable.php Point.php Renderer.php Vector.php /Image_3D/Image/3D/Color Metal.php /Image_3D/Image/3D/Driver GD.php
SVG.php /Image_3D/Image/3D/Matrix Move.php Rotation.php Scale.php /Image_3D/Image/3D/Paintable Light.php Object.php Polygon.php
/Image_3D/Image/3D/Paintable/Object 3ds.php 3dsChunks.php Cube.php Map.php Pie.php Sphere.php Text.php /Image_3D/Image/3D/Renderer Isometric.php
Perspectively.php
| From: | Tobias Schlitt | Date: | Mon, 18 Jul 2005 15:35:31 +0000 |
| Subject: | cvs: pear /Image_3D generate_package_xml.php package.xml package2.xml /Image_3D/Image 3D.php /Image_3D/Image/3D Color.php Coordinate.php Driver.php Enlightenable.php Matrix.php Paintable.php Point.php Renderer.php Vector.php /Image_3D/Image/3D/Color Metal.php /Image_3D/Image/3D/Driver GD.php SVG.php /Image_3D/Image/3D/Matrix Move.php Rotation.php Scale.php /Image_3D/Image/3D/Paintable Light.php Object.php Polygon.php /Image_3D/Image/3D/Paintable/Object 3ds.php 3dsChunks.php Cube.php Map.php Pie.php Sphere.php Text.php /Image_3D/Image/3D/Renderer Isometric.php Perspectively.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-33125@lists.php.net to get a copy of this message | ||
toby Mon Jul 18 11:35:31 2005 EDT
Added files:
/pear/Image_3D generate_package_xml.php package.xml package2.xml
/pear/Image_3D/Image 3D.php
/pear/Image_3D/Image/3D Color.php Coordinate.php Driver.php
Enlightenable.php Matrix.php Paintable.php
Point.php Renderer.php Vector.php
/pear/Image_3D/Image/3D/Color Metal.php
/pear/Image_3D/Image/3D/Driver GD.php SVG.php
/pear/Image_3D/Image/3D/Matrix Move.php Rotation.php Scale.php
/pear/Image_3D/Image/3D/Paintable Light.php Object.php Polygon.php
/pear/Image_3D/Image/3D/Paintable/Object 3ds.php 3dsChunks.php
Cube.php Map.php Pie.php
Sphere.php Text.php
/pear/Image_3D/Image/3D/Renderer Isometric.php Perspectively.php
Log:
* Initial checkin of Image_3D.
http://cvs.php.net/co.php/pear/Image_3D/generate_package_xml.php?r=1.1&p=1 Index: pear/Image_3D/generate_package_xml.php +++ pear/Image_3D/generate_package_xml.php #!/usr/bin/php <?php // $make = 1; require_once('PEAR/PackageFileManager.php'); $pkg = new PEAR_PackageFileManager; // directory that PEAR CVS is located in $cvsdir = '/home/dotxp/dev/'; $packagedir = $cvsdir . 'Image_3D/trunk/'; // Filemanager settings $category = 'Image'; $package = 'Image_3D'; $version = '0.2.0'; $state = 'alpha'; $summary = 'This class allows the rendering of 3 dimensional images using PHP and ext/GD.'; $description = <<<EOT Image_3D is a highly object oriented PHP5 package that allows the creation of 3 dimensional images using PHP and the GD extension, which is bundled with PHP. Image_3D currently supports: * Creation of 3D objects like cubes, spheres, maps, text,... * Own object definitions possible * Own material definitions * Import of 3DSMax files * Unlimited number of light sources * Saving all output formats supported by GD EOT; $notes = <<<EOT * New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. EOT; $e = $pkg->setOptions( array('simpleoutput' => true, 'baseinstalldir' => '', 'summary' => $summary, 'description' => $description, 'version' => $version, 'license' => 'LGPL', 'packagedirectory' => $packagedir, 'pathtopackagefile' => $packagedir, 'state' => $state, 'filelistgenerator' => 'file', 'notes' => $notes, 'package' => $package, 'dir_roles' => array( 'docs' => 'doc'), 'ignore' => array('*.xml', '*.tgz', 'generate_package*', ), )); if (PEAR::isError($e)) { echo $e->getMessage(); exit; } $e = $pkg->addMaintainer('toby', 'lead', 'Tobias Schlitt', 'toby@php.net'); $e = $pkg->addMaintainer('kore', 'lead', 'Kore Nordmann', 'pear@kore-nordmann.de'); if (PEAR::isError($e)) { echo $e->getMessage(); exit; } $e = $pkg->addDependency('gd', null, 'has', 'ext'); $e = $pkg->addDependency('php', '5.0.0', 'ge', 'php'); $e = $pkg->addGlobalReplacement('package-info', '@package_version@', 'version'); $e = $pkg->addGlobalReplacement('pear-config', '@data_dir@', 'data_dir'); if (PEAR::isError($e)) { echo $e->getMessage(); exit; } // hack until they get their shit in line with docroot role $pkg->addRole('tpl', 'php'); $pkg->addRole('png', 'php'); $pkg->addRole('gif', 'php'); $pkg->addRole('jpg', 'php'); $pkg->addRole('css', 'php'); $pkg->addRole('js', 'php'); $pkg->addRole('ini', 'php'); $pkg->addRole('inc', 'php'); $pkg->addRole('afm', 'php'); $pkg->addRole('pkg', 'doc'); $pkg->addRole('cls', 'doc'); $pkg->addRole('proc', 'doc'); $pkg->addRole('sh', 'doc'); if (isset($make)) { $e = $pkg->writePackageFile(); } else { $e = $pkg->debugPackageFile(); } if (PEAR::isError($e)) { echo $e->getMessage(); } /* if (!isset($make)) { echo '<a href="' . $_SERVER['PHP_SELF'] . '?make=1">Make this file</a>'; } */ ?> http://cvs.php.net/co.php/pear/Image_3D/package.xml?r=1.1&p=1 Index: pear/Image_3D/package.xml +++ pear/Image_3D/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0" packagerversion="1.4.0a12"> <name>Image_3D</name> <summary>This class allows the rendering of 3 dimensional images using PHP and ext/GD.</summary> <description>Image_3D is a highly object oriented PHP5 package that allows the creation of 3 dimensional images using PHP and the GD extension, which is bundled with PHP. Image_3D currently supports: * Creation of 3D objects like cubes, spheres, maps, text,... * Own object definitions possible * Own material definitions * Import of 3DSMax files * Unlimited number of light sources * Saving all output formats supported by GD </description> <maintainers> <maintainer> <user>toby</user> <name>Tobias Schlitt</name> <email>toby@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>kore</user> <name>Kore Nordmann</name> <email>pear@kore-nordmann.de</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.2.0</version> <date>2005-07-08</date> <license>LGPL</license> <state>alpha</state> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> <deps> <dep type="ext" rel="has" optional="no">gd</dep> <dep type="php" rel="ge" version="5.0.0" optional="no"/> </deps> <filelist> <dir name="/" baseinstalldir=""> <dir name="data"> <file role="data" name="TextData.dat"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /data --> <dir name="docs"> <dir name="examples"> <dir name="models"> <file role="doc" name="cube.3ds"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="Image_3D.3ds"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/examples/models --> <dir name="tests"> <file role="doc" name="TestImage_iso,flat,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,flat,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,flat,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,flat,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,gauroud,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,gauroud,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,gauroud,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,gauroud,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/examples/tests --> <file role="doc" name="3ds.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="map.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="test_all.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="text.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/examples --> <dir name="pictures"> <file role="doc" name="all_objects.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="animation.gif"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="car.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="f1.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="mickey.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="mickey_trans.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sincos.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="spheres.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_4.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_5.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_6.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_7.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="text.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/pictures --> <file role="doc" name="AUTHORS"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="COPYING"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="README"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TODO"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs --> <dir name="Image"> <dir name="3D"> <dir name="Color"> <file role="php" name="Metal.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Color --> <dir name="Driver"> <file role="php" name="GD.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="SVG.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Driver --> <dir name="Matrix"> <file role="php" name="Move.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Rotation.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Scale.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Matrix --> <dir name="Paintable"> <dir name="Object"> <file role="php" name="3ds.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="3dsChunks.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Cube.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Map.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Sphere.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Text.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Paintable/Object --> <file role="php" name="Light.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Object.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Polygon.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Paintable --> <dir name="Renderer"> <file role="php" name="Isometric.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Perspectively.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Renderer --> <file role="php" name="Color.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Coordinate.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Driver.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Enlightenable.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Matrix.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Paintable.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Point.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Renderer.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Vector.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D --> <file role="php" name="3D.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image --> </dir> <!-- / --> </filelist> </release> <changelog> <release> <version>0.2.0</version> <date>2005-07-08</date> <license>LGPL</license> <state>alpha</state> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> </release> </changelog> </package> http://cvs.php.net/co.php/pear/Image_3D/package2.xml?r=1.1&p=1 Index: pear/Image_3D/package2.xml +++ pear/Image_3D/package2.xml <?xml version="1.0"?> <package packagerversion="1.4.0a12" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>Image_3D</name> <channel>pear.php.net</channel> <summary>This class allows the rendering of 3 dimensional images using PHP and ext/GD.</summary> <description>Image_3D is a highly object oriented PHP5 package that allows the creation of 3 dimensional images using PHP and the GD extension, which is bundled with PHP. Image_3D currently supports: * Creation of 3D objects like cubes, spheres, maps, text,... * Own object definitions possible * Own material definitions * Import of 3DSMax files * Unlimited number of light sources * Saving all output formats supported by GD </description> <lead> <name>Tobias Schlitt</name> <user>toby</user> <email>toby@php.net</email> <active>yes</active> </lead> <lead> <name>Kore Nordmann</name> <user>kore</user> <email>pear@kore-nordmann.de</email> <active>yes</active> </lead> <date>2005-07-08</date> <time>00:08:53</time> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> <contents> <dir name="/"> <dir name="data"> <file baseinstalldir="" name="TextData.dat" role="data"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /data --> <dir name="docs"> <dir name="examples"> <dir name="models"> <file baseinstalldir="" name="cube.3ds" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Image_3D.3ds" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/examples/models --> <dir name="tests"> <file baseinstalldir="" name="TestImage_iso,flat,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,flat,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,flat,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,flat,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,gauroud,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,gauroud,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,gauroud,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,gauroud,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/examples/tests --> <file baseinstalldir="" name="3ds.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="map.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="test_all.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="text.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/examples --> <dir name="pictures"> <file baseinstalldir="" name="all_objects.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="animation.gif" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="car.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="f1.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="mickey.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="mickey_trans.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sincos.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="spheres.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_4.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_5.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_6.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_7.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="text.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/pictures --> <file baseinstalldir="" name="AUTHORS" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="COPYING" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="README" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TODO" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs --> <dir name="Image"> <dir name="3D"> <dir name="Color"> <file baseinstalldir="" name="Metal.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Color --> <dir name="Driver"> <file baseinstalldir="" name="GD.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="SVG.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Driver --> <dir name="Matrix"> <file baseinstalldir="" name="Move.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Rotation.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Scale.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Matrix --> <dir name="Paintable"> <dir name="Object"> <file baseinstalldir="" name="3ds.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="3dsChunks.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Cube.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Map.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Sphere.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Text.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Paintable/Object --> <file baseinstalldir="" name="Light.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Object.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Polygon.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Paintable --> <dir name="Renderer"> <file baseinstalldir="" name="Isometric.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Perspectively.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Renderer --> <file baseinstalldir="" name="Color.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Coordinate.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Driver.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Enlightenable.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Matrix.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Paintable.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Point.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Renderer.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Vector.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D --> <file baseinstalldir="" name="3D.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image --> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>5.0.0</min> </php> <pearinstaller> <min>1.4.0a1</min> </pearinstaller> <extension> <name>gd</name> </extension> </required> </dependencies> <phprelease /> <changelog> <release> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <date>2005-07-08</date> <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> </release> </changelog> </package> http://cvs.php.net/co.php/pear/Image_3D/Image/3D.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D.php +++ pear/Image_3D/Image/3D.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: 3D.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable.php'); require_once('Image/3D/Enlightenable.php'); require_once('Image/3D/Color.php'); require_once('Image/3D/Coordinate.php'); require_once('Image/3D/Point.php'); require_once('Image/3D/Vector.php'); require_once('Image/3D/Renderer.php'); require_once('Image/3D/Driver.php'); require_once('Image/3D/Paintable/Object.php'); require_once('Image/3D/Paintable/Light.php'); require_once('Image/3D/Paintable/Polygon.php'); /** * Image_3D * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D { protected $_color; protected $_objects; protected $_lights; protected $_renderer; protected $_driver; protected $_option; protected $_optionSet; const IMAGE_3D_OPTION_FILLED = 1; const IMAGE_3D_OPTION_BF_CULLING = 2; public function __construct() { $this->_objects = array(); $this->_lights = array(); $this->_renderer = null; $this->_driver = null; $this->_color = null; $this->_option[self::IMAGE_3D_OPTION_FILLED] = true; $this->_option[self::IMAGE_3D_OPTION_BF_CULLING] = true; $this->_optionSet = array(); } public function createObject($type, $parameter = array()) { $name = ucfirst($type); $class = 'Image_3D_Object_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Paintable/Object/' . $name . '.php'; $user_path = dirname(__FILE__) . '/3D/User/Object/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Paintable/Object/' . $name . '.php'); } elseif (is_file($user_path) && is_readable($user_path)) { include_once('Image/3D/User/Object/' . $name . '.php'); } else { throw new Exception("Class for object $name not found."); } return $this->_objects[] = new $class($parameter); } public function createLight($x, $y, $z) { return $this->_lights[] = new Image_3D_Light($x, $y, $z); } public function createMatrix($type, $parameter = array()) { $name = ucfirst($type); $class = 'Image_3D_Matrix_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Matrix/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Matrix/' . $name . '.php'); } else { throw new Exception("Class for matrix $name not found."); } return new $class($parameter); } public function setColor(Image_3D_Color $color, $recusive = true) { $this->_color = $color; } public function createRenderer($type) { $name = ucfirst($type); $class = 'Image_3D_Renderer_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Renderer/' . $name . '.php'; $user_path = dirname(__FILE__) . '/3D/User/Renderer/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Renderer/' . $name . '.php'); } elseif (is_file($user_path) && is_readable($user_path)) { include_once('Image/3D/User/Renderer/' . $name . '.php'); } else { throw new Exception("Class for renderer $name not found."); } return $this->_renderer = new $class(); } public function createDriver($type) { $name = ucfirst($type); $class = 'Image_3D_Driver_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Driver/' . $name . '.php'; $user_path = dirname(__FILE__) . '/3D/User/Driver/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Driver/' . $name . '.php'); } elseif (is_file($user_path) && is_readable($user_path)) { include_once('Image/3D/User/Driver/' . $name . '.php'); } else { throw new Exception("Class for driver $name not found."); } return $this->_driver = new $class(); } public function setOption($option, $value) { $this->_option[$option] = $value; $this->_optionSet[$option] = true; foreach ($this->_objects as $object) $object->setOption($option, $value); } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_objects as $object) $object->transform($matrix, $id); } public function render($x, $y, $file) { if (!is_writable(dirname($file)) && (!is_file($file) || !is_writable($file))) throw new Exception('Cannot write outputfile.'); $x = min(1280, max(0, (int) $x)); $y = min(1280, max(0, (int) $y)); $this->_renderer->setSize($x, $y); $this->_renderer->setBackgroundColor($this->_color); $this->_renderer->addObjects($this->_objects); $this->_renderer->addLights($this->_lights); $this->_renderer->setDriver($this->_driver); return $this->_renderer->render($file); } public function stats() { printf(' Image 3D objects: %d lights: %d polygones: %d points: %d ', count($this->_objects), $this->_renderer->getLightCount(), $this->_renderer->getPolygonCount(), $this->_renderer->getPointCount() ); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Color.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Color.php +++ pear/Image_3D/Image/3D/Color.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Color.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Color * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Color { protected $_rgbaValue; // protected $_image; protected $_lastColorID; protected $_lights; protected $_light; public function __construct() { // $this->_image = null; $this->_lastColorID = 0; $this->_rgbaValue = array(); $this->_lights = array(); $this->_light = array(0, 0, 0); $arglist = func_get_args(); $argcount = func_num_args(); for ($i = 0; $i < 4; $i++) { if ($i >= $argcount) { $this->_rgbaValue[$i] = 0; } elseif (is_int($arglist[$i])) { $this->_rgbaValue[$i] = (float) min(1, max(0, (float) $arglist[$i] / 255)); } elseif (is_float($arglist[$i])) { $this->_rgbaValue[$i] = (float) min(1, max(0, $arglist[$i])); } else { $this->_rgbaValue[$i] = 0; } } } public function getValues() { return $this->_rgbaValue; } public function addLight(Image_3D_Color $color, $intensity = .5) { $this->_lights[] = array($intensity, $color); } protected function _calcLights() { foreach ($this->_lights as $light) { list($intensity, $color) = $light; $colorArray = $color->getValues(); $this->_light[0] += $colorArray[0] * $intensity * (1 - $colorArray[3]); $this->_light[1] += $colorArray[1] * $intensity * (1 - $colorArray[3]); $this->_light[2] += $colorArray[2] * $intensity * (1 - $colorArray[3]); } } protected function _mixColor() { $this->_rgbaValue[0] = min(1, $this->_rgbaValue[0] * $this->_light[0]); $this->_rgbaValue[1] = min(1, $this->_rgbaValue[1] * $this->_light[1]); $this->_rgbaValue[2] = min(1, $this->_rgbaValue[2] * $this->_light[2]); } public function calculateColor() { $this->_calcLights(); $this->_mixColor(); } public function tostring() { return sprintf("Color: r %.2f g %.2f b %.2f a %.2f\n", $this->_rgbaValue[0], $this->_rgbaValue[1], $this->_rgbaValue[2], $this->_rgbaValue[3]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Coordinate.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Coordinate.php +++ pear/Image_3D/Image/3D/Coordinate.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Coordinate.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Coordinate * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Coordinate { protected $_x; protected $_y; protected $_z; public function __construct($x, $y, $z) { $this->_x = (float) $x; $this->_y = (float) $y; $this->_z = (float) $z; } public function transform(Image_3D_Matrix $matrix, $id = null) { // Point already transformed? if (($id !== null) && ($this->_lastTransformation === $id)) return false; $this->_lastTransformation = $id; $point = clone($this); $this->_x = $point->getX() * $matrix->getValue(0, 0) + $point->getY() * $matrix->getValue(1, 0) + $point->getZ() * $matrix->getValue(2, 0) + $matrix->getValue(3, 0); $this->_y = $point->getX() * $matrix->getValue(0, 1) + $point->getY() * $matrix->getValue(1, 1) + $point->getZ() * $matrix->getValue(2, 1) + $matrix->getValue(3, 1); $this->_z = $point->getX() * $matrix->getValue(0, 2) + $point->getY() * $matrix->getValue(1, 2) + $point->getZ() * $matrix->getValue(2, 2) + $matrix->getValue(3, 2); $this->_screenCoordinates = null; } public function processed() { $this->_processed = true; } public function isProcessed() { return $this->_processed; } public function getX() { return $this->_x; } public function getY() { return $this->_y; } public function getZ() { return $this->_z; } public function setScreenCoordinates($x, $y) { $this->_screenCoordinates = array((float) $x, (float) $y); } public function getScreenCoordinates() { return $this->_screenCoordinates; } public function __toString() { return sprintf('Coordinate: %2.f %2.f %2.f', $this->_x, $this->_y, $this->_z); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Driver.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Driver.php +++ pear/Image_3D/Image/3D/Driver.php <?php abstract class Image_3D_Driver { protected $_image; public function __construct() { $this->_image = null; } abstract public function createImage($x, $y); abstract public function setBackground(Image_3D_Color $color); abstract public function drawPolygon(Image_3D_Polygon $polygon); abstract public function drawGradientPolygon(Image_3D_Polygon $polygon); abstract public function save($file); public function getSupportedShading() { return array(Image_3D_Renderer::SHADE_NO); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Enlightenable.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Enlightenable.php +++ pear/Image_3D/Image/3D/Enlightenable.php <?php /*** * * 3dlib - 3d libary in PHP * Copyright (C) 2004 Kore Nordmann - http://www.kore-nordmann.de (German) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * You may contact the author by mail: * 3dlib@kore-nordmann.de * * Or write to: * Kore Nordmann * Stockumer Strasse 404 * 44227 Dortmund * Germany * **/ interface enlightenable { public function getColor(); public function getNormale(); public function getPosition(); } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix.php +++ pear/Image_3D/Image/3D/Matrix.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Matrix.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Matrix * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix { public $matrix; public function __construct() { $this->setUnitMatrix(); } public function setValue($x, $y, $value) { if (!isset($this->_matrix[$x][$y])) return false; $this->_matrix[$x][$y] = (float) $value; } public function getValue($x, $y) { if (!isset($this->_matrix[$x][$y])) return false; return (float) $this->_matrix[$x][$y]; } public function setUnitMatrix() { $this->_matrix = array( array(1., 0., 0., 0.), array(0., 1., 0., 0.), array(0., 0., 1., 0.), array(0., 0., 0., 1.) ); } public function diff(Image_3D_Matrix $matrix) { $result = new Image_3D_Matrix(); for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { $result->setValue($i, $j, $matrix->getValue($i, $j) - $this->_getValue($i, $j)); } } return $result; } public function multiplySkalar($skalar) { for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { $this->_matrix[$i][$j] *= $skalar; } } } public function dump() { foreach ($this->_matrix as $row) { printf("|\t%2.2f\t%2.2f\t%2.2f\t%2.2f\t|\n", $row[0], $row[1], $row[2], $row[3]); } } public function setRotationMatrix($rotationX, $rotationY, $rotationZ) { $rotationY = (float) $rotationY; $rotationZ = (float) $rotationZ; if (!empty($rotationX)) { // Normalisierung der Rotation von Grad auf radiale Berechnung $rotationX = (float) $rotationX; $rotationX *= pi() / 180; // Setzen der Rotationsmatrix fuer Drehungen an der X-Achse $matrix = new Image_3D_Matrix(); $matrix->setValue(1, 1, cos($rotationX)); $matrix->setValue(1, 2, sin($rotationX)); $matrix->setValue(2, 1, -sin($rotationX)); $matrix->setValue(2, 2, cos($rotationX)); // Setzen der Transformationsmatrix $this->_multiply($matrix); unset($matrix); } if (!empty($rotationY)) { // Normalisierung der Rotation von Grad auf radiale Berechnung $rotationY = (float) $rotationY; $rotationY *= pi() / 180; // Setzen der Rotationsmatrix fuer Drehungen an der X-Achse $matrix = new Image_3D_Matrix(); $matrix->setValue(0, 0, cos($rotationY)); $matrix->setValue(0, 2, -sin($rotationY)); $matrix->setValue(2, 0, sin($rotationY)); $matrix->setValue(2, 2, cos($rotationY)); // Setzen der Transformationsmatrix $this->_multiply($matrix); unset($matrix); } if (!empty($rotationZ)) { // Normalisierung der Rotation von Grad auf radiale Berechnung $rotationZ = (float) $rotationZ; $rotationZ *= pi() / 180; // Setzen der Rotationsmatrix fuer Drehungen an der X-Achse $matrix = new Image_3D_Matrix(); $matrix->setValue(0, 0, cos($rotationZ)); $matrix->setValue(0, 1, sin($rotationZ)); $matrix->setValue(1, 0, -sin($rotationZ)); $matrix->setValue(1, 1, cos($rotationZ)); // Setzen der Transformationsmatrix $this->_multiply($matrix); unset($matrix); } } public function setMoveMatrix($moveX, $moveY, $moveZ) { $matrix = new Image_3D_Matrix(); $matrix->setValue(3, 0, (float) $moveX); $matrix->setValue(3, 1, (float) $moveY); $matrix->setValue(3, 2, (float) $moveZ); $this->_multiply($matrix); } public function setScaleMatrix($scaleX, $scaleY, $scaleZ) { $matrix = new Image_3D_Matrix(); $matrix->setValue(0, 0, (float) $scaleX); $matrix->setValue(1, 1, (float) $scaleY); $matrix->setValue(2, 2, (float) $scaleZ); $this->_multiply($matrix); } protected function _multiply(Image_3D_Matrix $matrix) { $new = clone($this); for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { $sum = 0; for ($k = 0; $k < 4; $k++) { $sum += $new->getValue($i, $k) * $matrix->getValue($k, $j); } $this->setValue($i, $j, $sum); } } } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable.php +++ pear/Image_3D/Image/3D/Paintable.php <?php /*** * * 3dlib - 3d libary in PHP * Copyright (C) 2004 Kore Nordmann - http://www.kore-nordmann.de (German) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * You may contact the author by mail: * 3dlib@kore-nordmann.de * * Or write to: * Kore Nordmann * Stockumer Strasse 404 * 44227 Dortmund * Germany * **/ interface paintable { public function getPolygonCount(); public function setColor(Image_3D_Color $color); public function setOption($option, $value); public function transform(Image_3D_Matrix $matrix, $id = null); } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Point.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Point.php +++ pear/Image_3D/Image/3D/Point.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Point.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Point * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Point extends Image_3D_Coordinate implements enlightenable { protected $_option; protected $_lastTransformation; protected $_screenCoordinates; protected $_processed; protected $_normale; protected $_vectors; protected $_colors; protected $_color; public function __construct($x, $y, $z) { parent::__construct($x, $y, $z); $this->_option = array(); $this->_lastTransformation = null; $this->_screenCoordinates = null; $this->_processed = false; $this->_colors = array(); $this->_color = null; } public function setOption($option, $value) { $this->_option[$option] = $value; } public function calculateColor($lights) { foreach ($lights as $light) $this->_color = $light->getColor($this); $this->_color->calculateColor(); } public function addVector(Image_3D_Vector $vector) { $this->_vectors[] = $vector; } protected function _calcNormale() { $this->_normale = new Image_3D_Vector(0, 0, 0); foreach ($this->_vectors as $vector) $this->_normale->add($vector); $this->_normale->unify(); } public function getNormale() { if (!is_a($this->_normale, 'Image_3D_Vector')) $this->_calcNormale(); return $this->_normale; } public function getPosition() { return new Image_3D_Vector($this->_x, $this->_y, $this->_z); } public function addColor(Image_3D_Color $color) { $this->_colors[] = $color; } protected function _mixColors() { $i = 0; $color = array(0, 0, 0, 0); foreach ($this->_colors as $c) { $values = $c->getValues(); $color[0] += $values[0]; $color[1] += $values[1]; $color[2] += $values[2]; $color[3] += $values[3]; $i++; } $this->_color = new Image_3D_Color($color[0] / $i, $color[1] / $i, $color[2] / $i, $color[3] / $i); } public function getColor() { if ($this->_color === null) $this->_mixColors(); return $this->_color; } public function __toString() { return sprintf('Point: %2.f %2.f %2.f', $this->_x, $this->_y, $this->_z); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Renderer.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Renderer.php +++ pear/Image_3D/Image/3D/Renderer.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Renderer.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Renderer * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ abstract class Image_3D_Renderer { protected $_polygones; protected $_points; protected $_lights; protected $_driver; protected $_size; protected $_background; protected $_shading; const SHADE_NO = 0; const SHADE_FLAT = 1; const SHADE_GAUROUD = 2; const SHADE_PHONG = 3; public function __construct() { $this->_objects = array(); $this->_polygones = array(); $this->_points = array(); $this->_lights = array(); $this->_size = array(0, 0); $this->_background = null; $this->_driver = null; $this->_shading = self::SHADE_PHONG; } protected function _getPolygones(Image_3D_Object $object) { $newPolygones = $object->getPolygones(); $this->_polygones = array_merge($this->_polygones, $newPolygones); // Add points unique to points-Array foreach ($newPolygones as $polygon) { $points = $polygon->getPoints(); foreach ($points as $point) { if (!$point->isProcessed()) { $point->processed(); array_push($this->_points, $point); } } } } // Calculate perspective abstract protected function _calculateScreenCoordiantes(Image_3D_Point $point); // Implement polygon-based Z-buffer abstract protected function _sortPolygones(); public function addObjects($objects) { if (is_array($objects)) { foreach ($objects as $object) { if (is_a($object, 'Image_3D_Object')) { $this->_getPolygones($object); } } } elseif (is_a($objects, 'Image_3D_Object')) { $this->_getPolygones($objects); } } public function addLights($lights) { $this->_lights = array_merge($this->_lights, $lights); } public function setSize($x, $y) { $this->_size = array($x, $y); } public function setBackgroundColor(Image_3D_Color $color) { $this->_background = $color; } public function setShading($shading) { $this->_shading = min($this->_shading, (int) $shading); } public function setDriver(Image_3D_Driver $driver) { $this->_driver = $driver; $this->setShading(max($driver->getSupportedShading())); } public function getPolygonCount() { return count($this->_polygones); } public function getPointCount() { return count($this->_points); } public function getLightCount() { return count($this->_lights); } protected function _calculatePolygonColors() { foreach ($this->_polygones as $polygon) { $polygon->calculateColor($this->_lights); } } protected function _calculatePointColors() { foreach ($this->_polygones as $polygon) { $normale = $polygon->getNormale(); $color = $polygon->getColor(); $points = $polygon->getPoints(); foreach ($points as $point) { $point->addVector($normale); $point->addColor($color); } } foreach ($this->_points as $point) $point->calculateColor($this->_lights); } protected function _shade() { switch ($this->_shading) { case self::SHADE_NO: foreach ($this->_polygones as $polygon) $this->_driver->drawPolygon($polygon); break; case self::SHADE_FLAT: $this->_calculatePolygonColors(); foreach ($this->_polygones as $polygon) $this->_driver->drawPolygon($polygon); break; case self::SHADE_GAUROUD: $this->_calculatePointColors(); foreach ($this->_polygones as $polygon) $this->_driver->drawGradientPolygon($polygon); break; default: throw new Exception('Shading type not supported.'); break; } } public function render($file) { if (empty($this->_driver)) return false; // Calculate screen coordinates foreach ($this->_points as $point) $this->_calculateScreenCoordiantes($point); $this->_sortPolygones(); // Draw background $this->_driver->createImage($this->_size[0], $this->_size[1]); $this->_driver->setBackground($this->_background); // Calculate Colors $this->_shade(); // Save $this->_driver->save($file); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Vector.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Vector.php +++ pear/Image_3D/Image/3D/Vector.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Vector.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Point.php'); /** * Image_3D_Vector * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Vector extends Image_3D_Coordinate { public function getAngle(Image_3D_Vector $vector) { $vector->unify(); $this->unify(); return acos($this->_x * $vector->getX() + $this->_y * $vector->getY() + $this->_z * $vector->getZ()) * 2 / pi(); } public function unify() { $value = sqrt(pow($this->_x, 2) + pow($this->_y, 2) + pow($this->_z, 2)); if ($value == 0) return false; $this->_x /= $value; $this->_y /= $value; $this->_z /= $value; } public function add(Image_3D_Vector $vector) { $this->_x += $vector->getX(); $this->_y += $vector->getY(); $this->_z += $vector->getZ(); } public function sub(Image_3D_Vector $vector) { $this->_x -= $vector->getX(); $this->_y -= $vector->getY(); $this->_z -= $vector->getZ(); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Color/Metal.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Color/Metal.php +++ pear/Image_3D/Image/3D/Color/Metal.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Metal.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Color.php'); /** * Image_3D_Color_Metal * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Color_Metal extends Image_3D_Color { protected $_metal; public function setMetal($metal) { $this->_metal = (float) $metal; } protected function _mixColor() { $this->_rgbaValue[0] = min(1, $this->_rgbaValue[0] * $this->_light[0] + $this->_metal * $this->_light[0]); $this->_rgbaValue[1] = min(1, $this->_rgbaValue[1] * $this->_light[1] + $this->_metal * $this->_light[1]); $this->_rgbaValue[2] = min(1, $this->_rgbaValue[2] * $this->_light[2] + $this->_metal * $this->_light[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Driver/GD.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Driver/GD.php +++ pear/Image_3D/Image/3D/Driver/GD.php <?php class Image_3D_Driver_GD extends Image_3D_Driver { protected $_filetype; public function __construct() { parent::__construct(); $this->_filetype = 'png'; } public function createImage($x, $y) { $this->_image = imagecreatetruecolor($x, $y); } protected function _getColor(Image_3D_Color $color) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); $values[3] = (int) round($values[3] * 127); if ($this->_rgbaValue[3] > 0) { // Tranzparente Farbe allokieren $color = imageColorExactAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]); if ($color === -1) { // Wenn nicht Farbe neu alloziieren $color = imageColorAllocateAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]); } } else { // Deckende Farbe allozieren $color = imageColorExact($this->_image, $values[0], $values[1], $values[2]); if ($color === -1) { // Wenn nicht Farbe neu alloziieren $color = imageColorAllocate($this->_image, $values[0], $values[1], $values[2]); } } return $color; } public function setBackground(Image_3D_Color $color) { $bg = $this->_getColor($color); imagefill($this->_image, 1, 1, $bg); } public function drawPolygon(Image_3D_Polygon $polygon) { // Get points $points = $polygon->getPoints(); $coords = array(); foreach ($points as $point) $coords = array_merge($coords, $point->getScreenCoordinates()); $coordCount = (int) (count($coords) / 2); if (true) { imageFilledPolygon($this->_image, $coords, $coordCount, $this->_getColor($polygon->getColor())); } else { imagePolygon($this->_image, $coords, $coordCount, $this->_getColor($polygon->getColor())); } } public function drawGradientPolygon(Image_3D_Polygon $polygon) { $this->drawPolygon($polygon); } public function setFiletye($type) { $type = strtolower($type); if (in_array($type, array('png', 'jpeg'))) { $this->_filetype = $type; return true; } else { return false; } } public function save($file) { switch ($this->_filetype) { case 'png': return imagepng($this->_image, $file); case 'jpeg': return imagejpeg($this->_image, $file); } } public function getSupportedShading() { return array(Image_3D_Renderer::SHADE_NO, Image_3D_Renderer::SHADE_FLAT); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Driver/SVG.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Driver/SVG.php +++ pear/Image_3D/Image/3D/Driver/SVG.php <?php class Image_3D_Driver_SVG extends Image_3D_Driver { protected $_x; protected $_y; protected $_id; protected $_gradients; protected $_polygones; public function __construct() { $this->_image = ''; $this->_id = 1; $this->_gradients = array(); $this->_polygones = array(); } public function createImage($x, $y) { $this->_x = (int) $x; $this->_y = (int) $y; $this->_image = <<<EOF <?xml version="1.0" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" width="{$this->_x}" height="{$this->_y}" x="0" y="0"> EOF; $this->_image .= "\n\n"; } public function setBackground(Image_3D_Color $color) { $this->_addPolygon(sprintf("\t<polygon id=\"background%d\" points=\"0,0 %d,0 %d,%d 0,%d\" style=\"%s\" />\n", $this->_id++, $this->_x, $this->_x, $this->_y, $this->_y, $this->_getStyle($color))); } protected function _getStyle(Image_3D_Color $color) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); $values[3] = 1 - $values[3]; return sprintf('fill: #%02x%02x%02x; fill-opacity: %.2f; stroke: none;', $values[0], $values[1], $values[2], $values[3]); } protected function _getStop(Image_3D_Color $color, $offset = 0, $alpha = null) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); if ($alpha === null) { $values[3] = 1 - $values[3]; } else { $values[3] = 1 - $alpha; } return sprintf("\t\t\t<stop id=\"stop%d\" offset=\"%.1f\" style=\"stop-color: rgb(%d, %d, %d); stop-opacity: %.4f;\" />\n", $this->_id++, $offset, $values[0], $values[1], $values[2], $values[3]); } protected function _addGradient($string) { $id = 'linearGradient' . $this->_id++; $this->_gradients[] = str_replace('[id]', $id, $string); return $id; } protected function _addPolygon($string) { $id = 'polygon' . $this->_id++; $this->_polygones[] = str_replace('[id]', $id, $string); return $id; } public function drawPolygon(Image_3D_Polygon $polygon) { $list = ''; $points = $polygon->getPoints(); foreach ($points as $point) { $pointarray = $point->getScreenCoordinates(); $list .= sprintf('%.2f,%.2f ', $pointarray[0], $pointarray[1]); } $this->_addPolygon(sprintf("\t<polygon points=\"%s\" style=\"%s\" />\n", substr($list, 0, -1), $this->_getStyle($polygon->getColor()))); } public function drawGradientPolygon(Image_3D_Polygon $polygon) { $points = $polygon->getPoints(); $list = ''; $pointarray = array(); foreach ($points as $nr => $point) { $pointarray[$nr] = $point->getScreenCoordinates(); $list .= sprintf('%.2f,%.2f ', $pointarray[$nr][0], $pointarray[$nr][1]); } // Groessen $xOffset = min($pointarray[0][0], $pointarray[1][0], $pointarray[2][0]); $yOffset = min($pointarray[0][1], $pointarray[1][1], $pointarray[2][1]); $xSize = max(abs($pointarray[0][0] - $pointarray[1][0]), abs($pointarray[0][0] - $pointarray[2][0]), abs($pointarray[1][0] - $pointarray[2][0])); $ySize = max(abs($pointarray[0][1] - $pointarray[1][1]), abs($pointarray[0][1] - $pointarray[2][1]), abs($pointarray[1][1] - $pointarray[2][1])); // Base Polygon $lg = $this->_addGradient(sprintf("\t\t<linearGradient id=\"[id]\" x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\">\n%s\t\t</linearGradient>\n", ($pointarray[0][0] - $xOffset) / $xSize, ($pointarray[0][1] - $yOffset) / $ySize, ($pointarray[1][0] - $xOffset) / $xSize, ($pointarray[1][1] - $yOffset) / $ySize, $this->_getStop($points[0]->getColor()) . $this->_getStop($points[1]->getColor(), 1))); $this->_addPolygon(sprintf("\t<polygon id=\"[id]\" points=\"%s\" style=\"fill: url(#%s); stroke: none; fill-opacity: 1;\" />\n", $list, $lg)); // Overlay Polygon $lg = $this->_addGradient(sprintf("\t\t<linearGradient id=\"[id]\" x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\">\n%s\t\t</linearGradient>\n", ($pointarray[2][0] - $xOffset) / $xSize, ($pointarray[2][1] - $yOffset) / $ySize, ((($pointarray[0][0] + $pointarray[1][0]) / 2) - $xOffset) / $xSize, ((($pointarray[0][1] + $pointarray[1][1]) / 2) - $yOffset) / $ySize, $this->_getStop($points[2]->getColor()) . $this->_getStop($points[2]->getColor(), 1, 1))); $this->_addPolygon(sprintf("\t<polygon id=\"[id]\" points=\"%s\" style=\"fill: url(#%s); stroke: none; fill-opacity: 1;\" />\n", $list, $lg)); } public function save($file) { $this->_image .= sprintf("\t<defs id=\"defs%d\">\n", $this->_id++); $this->_image .= implode('', $this->_gradients); $this->_image .= sprintf("\t</defs>\n\n"); $this->_image .= implode('', $this->_polygones); $this->_image .= "</svg>\n"; file_put_contents($file, $this->_image); } public function getSupportedShading() { return array(Image_3D_Renderer::SHADE_NO, Image_3D_Renderer::SHADE_FLAT, Image_3D_Renderer::SHADE_GAUROUD); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix/Move.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix/Move.php +++ pear/Image_3D/Image/3D/Matrix/Move.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Move.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix.php'); /** * Image_3D_Matrix_Move * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix_Move extends Image_3D_Matrix { public function __construct($parameter) { $this->setUnitMatrix(); $this->setMoveMatrix((float) @$parameter[0], (float) @$parameter[1], (float) @$parameter[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix/Rotation.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix/Rotation.php +++ pear/Image_3D/Image/3D/Matrix/Rotation.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Rotation.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix.php'); /** * Image_3D_Matrix_Rotation * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix_Rotation extends Image_3D_Matrix { public function __construct($parameter) { $this->setUnitMatrix(); $this->setRotationMatrix((float) @$parameter[0], (float) @$parameter[1], (float) @$parameter[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix/Scale.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix/Scale.php +++ pear/Image_3D/Image/3D/Matrix/Scale.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Scale.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix.php'); /** * Image_3D_Matrix_Scale * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix_Scale extends Image_3D_Matrix { public function __construct($parameter) { $this->setUnitMatrix(); $this->setScaleMatrix((float) @$parameter[0], (float) @$parameter[1], (float) @$parameter[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Light.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Light.php +++ pear/Image_3D/Image/3D/Paintable/Light.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Light.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Light * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Light extends Image_3D_Coordinate implements paintable { protected $_color; public function __construct($x, $y, $z) { parent::__construct($x, $y, $z); $this->_color = null; $this->_position = null; } public function getPolygonCount() { return 0; } public function setColor(Image_3D_Color $color) { $this->_color = $color; } public function setOption($option, $value) { $this->_option[$option] = $value; } public function getColor(Enlightenable $polygon) { $color = clone ($polygon->getColor()); $light = new Image_3D_Vector($this->_x, $this->_y, $this->_z); $light->sub($polygon->getPosition()); $normale = $polygon->getNormale(); $angle = abs(1 - $normale->getAngle($light)); $color->addLight($this->_color, $angle); return $color; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object.php +++ pear/Image_3D/Image/3D/Paintable/Object.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Object.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Object * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object implements paintable { protected $_polygones; public function __construct() { $this->_polygones = array(); } public function getPolygonCount() { return count($this->_polygones); } public function setColor(Image_3D_Color $color) { foreach ($this->_polygones as $polygon) $polygon->setColor($color); } public function setOption($option, $value) { foreach ($this->_polygones as $polygon) $polygon->setOption($option, $value); } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_polygones as $polygon) $polygon->transform($matrix, $id); } public function getPolygones() { return $this->_polygones; } protected function _addPolygon(Image_3D_Polygon $polygon) { $this->_polygones[] = $polygon; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Polygon.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Polygon.php +++ pear/Image_3D/Image/3D/Paintable/Polygon.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Polygon.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Polygon * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Polygon implements paintable, enlightenable { protected $_color; protected $_colorCalculated; protected $_option; protected $_points; protected $_visible; protected $_normale; protected $_position; public function __construct() { $this->_points = array(); $this->_option = array(); $this->_color = null; $this->_colorCalculated = false; $this->_visible = true; $this->_normale = null; $this->_position = null; if (func_num_args()) { $args = func_get_args(); for ($i = 0; $i < func_num_args(); $i++) { if (is_object($args[$i]) && is_a($args[$i], 'Image_3D_Point')) { $this->addPoint($args[$i]); } } } } public function calculateColor($lights) { foreach ($lights as $light) $this->_color = $light->getColor($this); $this->_color->calculateColor(); } public function getColor() { return $this->_color; } protected function _calcNormale() { if (count($this->_points) < 3) { $this->_normale = new Image_3D_Vector(0, 0, 0); return false; } $a1 = $this->_points[0]->getX() - $this->_points[1]->getX(); $a2 = $this->_points[0]->getY() - $this->_points[1]->getY(); $a3 = $this->_points[0]->getZ() - $this->_points[1]->getZ(); $b1 = $this->_points[2]->getX() - $this->_points[1]->getX(); $b2 = $this->_points[2]->getY() - $this->_points[1]->getY(); $b3 = $this->_points[2]->getZ() - $this->_points[1]->getZ(); $this->_normale = new Image_3D_Vector($a2 * $b3 - $a3 * $b2, $a3 * $b1 - $a1 * $b3, $a1 * $b2 - $a2 * $b1); // Backface Culling if (($this->_normale->getZ() <= 0) && ($this->_option[Image_3D::IMAGE_3D_OPTION_BF_CULLING])) $this->setInvisible(); } public function getNormale() { if (!is_a($this->_normale, 'Image_3D_Vector')) $this->_calcNormale(); return $this->_normale; } protected function _calcPosition() { $position = array(0, 0, 0); foreach ($this->_points as $point) { $position[0] += $point->getX(); $position[1] += $point->getY(); $position[2] += $point->getZ(); } $count = count($this->_points); $this->_position = new Image_3D_Vector($position[0] / $count, $position[1] / $count, $position[2] / $count); } public function getPosition() { if (!is_a($this->_position, 'Image_3D_Vector')) $this->_calcPosition(); return $this->_position; } public function getPolygonCount() { return 1; } public function setColor(Image_3D_Color $color) { $this->_color = $color; } public function isVisible() { return $this->isVisible(); } public function setInvisible() { $this->_visible = false; } public function setOption($option, $value) { $this->_option[$option] = $value; foreach ($this->_points as $point) $point->setOption($option, $value); } public function addPoint(Image_3D_Point $point) { $this->_points[] = $point; } public function getPoints() { return $this->_points; } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_points as $point) $point->transform($matrix, $id); } public function getMidZ() { $z = 0; foreach ($this->_points as $point) $z += $point->getZ(); return $z / count($this->_points); } public function getMaxZ() { $z = -500; foreach ($this->_points as $point) $z = max($point->getZ(), $z); return $z; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/3ds.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/3ds.php +++ pear/Image_3D/Image/3D/Paintable/Object/3ds.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: 3ds.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); require_once('Image/3D/Paintable/Object/3dsChunks.php'); /** * Image_3D_Object_3ds * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_3ds extends Image_3D_Object { protected $_file; protected $_fileSize; protected $_objects; protected $_chunks; public function __construct($file) { parent::__construct(); $this->_points = array(); $this->_chunks = array(); if (!is_file($file) || !is_readable($file)) return false; $this->_file = $file; $this->_readChunks(); } protected function _readChunks() { $this->_chunks = new Image_3D_Chunk(Image_3D_Chunk::MAIN3DS, substr(file_get_contents($this->_file), 6)); $this->_chunks->readChunks(); $editor = $this->_chunks->getFirstChunkByType(Image_3D_Chunk::EDIT3DS); $editor->readChunks(); $objects = $editor->getChunksByType(Image_3D_Chunk::EDIT_OBJECT); foreach ($objects as $object) { $object = new Image_3D_Chunk_Object($object->getType(), $object->getContent()); $object->readChunks($this); } } public function addObject($id) { $id = (string) $id; $this->_objects[$id] = new Image_3D_Object_3ds_Object(); return $this->_objects[$id]; } public function getObjectIDs() { return array_keys($this->_objects); } public function getObject($id) { if (!@isset($this->_objects[$id])) return false; return $this->_objects[$id]; } public function paint() { foreach ($this->_objects as $object) $object->paint(); } public function getPolygonCount() { $count = 0; foreach ($this->_objects as $object) $count += $object->getPolygonCount(); return $count; } public function setColor(Image_3D_Color $color) { foreach ($this->_objects as $object) $object->setColor($color); } public function setOption($option, $value) { foreach ($this->_objects as $object) $object->setOption($option, $value); } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_objects as $object) $object->transform($matrix, $id); } public function getPolygones() { $polygones = array(); foreach ($this->_objects as $object) $polygones = array_merge($polygones, $object->getPolygones()); return $polygones; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/3dsChunks.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/3dsChunks.php +++ pear/Image_3D/Image/3D/Paintable/Object/3dsChunks.php <?php class Image_3D_Chunk { protected $type; protected $content; protected $size; protected $chunks; //>------ Primary chunk const MAIN3DS = 0x4D4D; //>------ Main Chunks const EDIT3DS = 0x3D3D; // this is the start of the editor config const KEYF3DS = 0xB000; // this is the start of the keyframer config //>------ sub defines of EDIT3DS const EDIT_MATERIAL = 0xAFFF; const EDIT_CONFIG1 = 0x0100; const EDIT_CONFIG2 = 0x3E3D; const EDIT_VIEW_P1 = 0x7012; const EDIT_VIEW_P2 = 0x7011; const EDIT_VIEW_P3 = 0x7020; const EDIT_VIEW1 = 0x7001; const EDIT_BACKGR = 0x1200; const EDIT_AMBIENT = 0x2100; const EDIT_OBJECT = 0x4000; //>------ sub defines of EDIT_OBJECT const OBJ_TRIMESH = 0x4100; const OBJ_LIGHT = 0x4600; const OBJ_CAMERA = 0x4700; const OBJ_UNKNWN01 = 0x4010; const OBJ_UNKNWN02 = 0x4012; //>------ sub defines of OBJ_CAMERA const CAM_UNKNWN01 = 0x4710; const CAM_UNKNWN02 = 0x4720; //>------ sub defines of OBJ_LIGHT const LIT_OFF = 0x4620; const LIT_SPOT = 0x4610; const LIT_UNKNWN01 = 0x465A; //>------ sub defines of OBJ_TRIMESH const TRI_VERTEXL = 0x4110; const TRI_FACEL2 = 0x4111; const TRI_FACEL1 = 0x4120; const TRI_SMOOTH = 0x4150; const TRI_LOCAL = 0x4160; const TRI_VISIBLE = 0x4165; //>>------ sub defs of KEYF3DS const KEYF_UNKNWN01 = 0xB009; const KEYF_UNKNWN02 = 0xB00A; const KEYF_FRAMES = 0xB008; const KEYF_OBJDES = 0xB002; //>>------ these define the different color chunk types const COL_RGB = 0x0010; const COL_TRU = 0x0011; const COL_UNK = 0x0013; //>>------ defines for viewport chunks const TOP = 0x0001; const BOTTOM = 0x0002; const LEFT = 0x0003; const RIGHT = 0x0004; const FRONT = 0x0005; const BACK = 0x0006; const USER = 0x0007; const CAMERA = 0x0008; const LIGHT = 0x0009; const DISABLED = 0x0010; const BOGUS = 0x0011; public function __construct($type, $content) { $this->type = (int) $type; $this->size = strlen($content); $this->content = $content; } public function readChunks() { if (count($this->chunks) || ($this->size < 6)) return false; $position = 0; $string = $this->content; $length = $this->size - 6; while ($position <= $length) { $type = $this->getWord(substr($string, $position, 2)); $position += 2; $chunkLength = $this->getDWord(substr($string, $position, 4)) - 6; $position += 4; $this->chunks[] = new Image_3D_Chunk($type, substr($string, $position, $chunkLength)); $position += $chunkLength; } } public function debug() { printf("Typ: %6d (0x%04x) (%6d bytes) | Objects:%4d | Content:%6d\n", $this->type, $this->type, $this->size, count($this->chunks), strlen($this->content)); } protected function getWord($string) { return (ord($string{1}) << 8) | ord($string{0}); } protected function getDWord($string) { return ord($string{0}) | (ord($string{1}) << 8) | (ord($string{2}) << 16) | (ord($string{3}) << 32); } protected function getUnsignedInt($string) { return (ord($string{0}) << 8) | ord($string{1}); } protected function getFloat($string) { // Convert C-Float to PHP-Float return (ord($string{3}) & 128 ? -1 : 1) * (1 + (float) (ord($string{2}) & 127) / 127 + (float) (ord($string{1})) / 256 / 127 + (float) (ord($string{0})) / 256 / 256 / 127) * pow(2., ((((ord($string{3}) & 127) << 1) | (ord($string{2}) >> 7)) - 127)); } public function getChunks() { return $this->chunks; } public function getType() { return $this->type; } public function getContent() { return $this->content; } public function getFirstChunkByType($type) { if (!is_int($type)) $type = hexdec($type); foreach ($this->chunks as $chunk) if ($chunk->getType() === $type) return $chunk; return false; } public function getChunksByType($type) { if (!is_int($type)) $type = hexdec($type); $chunks = array(); foreach ($this->chunks as $chunk) if ($chunk->getType() === $type) $chunks[] = $chunk; return $chunks; } } class Image_3D_Chunk_Object extends Image_3D_Chunk { protected $name; public function __construct($type, $content) { parent::__construct($type, $content); $this->getName(); } protected function getName() { $i = 0; while ((ord($this->content{$i}) !== 0) && ($i < $this->size)) $this->name .= $this->content{$i++}; $this->content = substr($this->content, $i + 1); } public function readChunks(Image_3D_Object_3ds $k3ds) { $subtype = $this->getWord(substr($this->content, 0, 2)); $subcontent = substr($this->content, 6); switch ($subtype) { case self::OBJ_TRIMESH: $object = $k3ds->addObject($this->name); $this->chunks[] = new Image_3D_Chunk_TriMesh($subtype, $subcontent, $object); break; } } public function debug() { echo 'Object: ', $this->name, "\n"; parent::debug(); } } class Image_3D_Chunk_TriMesh extends Image_3D_Chunk { protected $matrix; protected $object; public function __construct($type, $content, $object) { parent::__construct($type, $content); $this->object = $object; $this->readChunks(); $this->getPoints(); $this->getFaces(); } protected function getPoints() { $vertexlists = $this->getChunksByType(Image_3D_Chunk::TRI_VERTEXL); foreach ($vertexlists as $vertexlist) { $points = $vertexlist->getContent(); $count = $this->getWord(substr($points, 0, 2)); $points = substr($points, 2); for ($i = 0; $i < $count; $i++) { $x = $this->getFloat(substr($points, 0, 4)); $y = $this->getFloat(substr($points, 4, 4)); $z = $this->getFloat(substr($points, 8, 4)); $this->object->newPoint($x, $y, $z); $points = substr($points, 12); } } } protected function getFaces() { $facelists = $this->getChunksByType(Image_3D_Chunk::TRI_FACEL1); foreach ($facelists as $facelist) { $faces = $facelist->getContent(); $count = $this->getWord(substr($faces, 0, 2)); $faces = substr($faces, 2); for ($i = 0; $i < $count; $i++) { $p1 = $this->getWord(substr($faces, 0, 2)); $p2 = $this->getWord(substr($faces, 2, 2)); $p3 = $this->getWord(substr($faces, 4, 2)); $this->object->newPolygon($p1, $p2, $p3); $faces = substr($faces, 8); } } } protected function getTranslations() { $translists = $this->getChunksByType(Image_3D_Chunk::TRI_LOCAL); foreach ($translists as $translist) { $trans = $translist->getContent(); echo "Trans: " . strlen($trans), "\n"; } } public function debug() { parent::debug(); printf("Trimesh with %d (0x%04x) points - Pointsize: %.2f\n", $this->pointCount, $this->pointCount, $this->size / $this->pointCount); } } class Image_3D_Object_3ds_Object extends Image_3D_Object { protected $_points; public function __construct() { parent::__construct(); $this->_points = array(); } public function newPoint($x, $y, $z) { $this->_points[] = new Image_3D_Point($x, $y, $z); // echo "New Point: $x, $y, $z -> ", count($this->_points), "\n"; } public function newPolygon($p1, $p2, $p3) { if (!isset($this->_points[$p1]) || !isset($this->_points[$p2]) || !isset($this->_points[$p3])) { // printf("ERROR: Unknown point (%d, %d, %d of %d)\n", $p1, $p2, $p3, count($this->_points) - 1); return false; } $this->_addPolygon(new Image_3D_Polygon($this->_points[$p1], $this->_points[$p2], $this->_points[$p3])); // echo "New Polygon: $p1, $p2, $p3 -> ", count($this->_polygones), "\n"; } public function debug() { printf("Points: %d | Polygones: %d (%d)\n", count($this->_points), count($this->_polygones), $this->_polygonCount); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Cube.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Cube.php +++ pear/Image_3D/Image/3D/Paintable/Object/Cube.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Cube.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Cube * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Cube extends Image_3D_Object { protected $_points; public function __construct($parameter) { parent::__construct(); $x = (float) @$parameter[0]; $y = (float) @$parameter[1]; $z = (float) @$parameter[2]; $this->_points = array(); $this->_points[1] = new Image_3D_Point(-$x / 2, -$y / 2, -$z / 2); $this->_points[2] = new Image_3D_Point(-$x / 2, -$y / 2, $z / 2); $this->_points[3] = new Image_3D_Point(-$x / 2, $y / 2, -$z / 2); $this->_points[4] = new Image_3D_Point(-$x / 2, $y / 2, $z / 2); $this->_points[5] = new Image_3D_Point( $x / 2, -$y / 2, -$z / 2); $this->_points[6] = new Image_3D_Point( $x / 2, -$y / 2, $z / 2); $this->_points[7] = new Image_3D_Point( $x / 2, $y / 2, -$z / 2); $this->_points[8] = new Image_3D_Point( $x / 2, $y / 2, $z / 2); // Oben & Unten $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[4], $this->_points[8])); $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[8], $this->_points[7])); $this->_addPolygon(new Image_3D_Polygon($this->_points[2], $this->_points[1], $this->_points[6])); $this->_addPolygon(new Image_3D_Polygon($this->_points[1], $this->_points[5], $this->_points[6])); // Links & Rechts $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[2], $this->_points[4])); $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[1], $this->_points[2])); $this->_addPolygon(new Image_3D_Polygon($this->_points[8], $this->_points[5], $this->_points[7])); $this->_addPolygon(new Image_3D_Polygon($this->_points[8], $this->_points[6], $this->_points[5])); // Rueck- & Frontseite $this->_addPolygon(new Image_3D_Polygon($this->_points[2], $this->_points[8], $this->_points[4])); $this->_addPolygon(new Image_3D_Polygon($this->_points[2], $this->_points[6], $this->_points[8])); $this->_addPolygon(new Image_3D_Polygon($this->_points[1], $this->_points[7], $this->_points[5])); $this->_addPolygon(new Image_3D_Polygon($this->_points[1], $this->_points[3], $this->_points[7])); } public function getPoint($int) { if (isset($this->_points[$int])) { return $this->_points[$int]; } else { return false; } } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Map.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Map.php +++ pear/Image_3D/Image/3D/Paintable/Object/Map.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Map.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Map * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Map extends Image_3D_Object { protected $_points; public function __construct($points = array()) { parent::__construct(); $this->_points = array(); foreach ($points as $row) { if (is_array($row)) { $this->_addRow($row); } else { $this->_addRow(array($row)); } } } public function addRow($row) { $rowNbr = array_push($this->_points, array()) - 1; foreach ($row as $point) { if (is_object($point) && is_a($point, 'Image_3D_Point')) $this->_points[$rowNbr][] = $point; } if (!count($this->_points[$rowNbr])) { unset($this->_points[$rowNbr]); return false; } if (count($this->_points) > 1) { $newRow = count($this->_points) - 1; $lastRow = $newRow - 1; $newCount = count($this->_points[$newRow]); $lastCount = count($this->_points[$lastRow]); if ($newCount < $lastCount) { $tmp = $newRow; $newRow = $lastRow; $lastRow = $tmp; $tmp = $newCount; $newCount = $lastCount; $lastCount = $tmp; } $top = (($newCount == 1) ? 1 : 1 / ($newCount - 1)); $bottom = (($lastCount == 1) ? 32768 : 1 / ($lastCount - 1)); $k = 0; for ($i = 1; $i < $newCount; $i++) { if (($i * $top) > ($k * $bottom + $bottom / 2)) { // Nach unten geoeffnetes Polygon einfuegen /\ $this->_addPolygon(new Image_3D_Polygon($this->_points[$newRow][$i - 1], $this->_points[$lastRow][$k + 1], $this->_points[$lastRow][$k])); $k++; } // Nach oben geoeffnetes Polygon einfuegen \/ $this->_addPolygon(new Image_3D_Polygon($this->_points[$newRow][$i - 1], $this->_points[$newRow][$i], $this->_points[$lastRow][$k])); } } return true; } public function getRow($int) { if (!isset($this->_points[$int])) return false; return $this->_points[$int]; } public function getPoint($x, $y) { if (!isset($this->_points[$x][$y])) return false; return $this->_points[$x][$y]; } public function setOption($option, $value) { // if ($option === Image_3D::IMAGE_3D_OPTION_BF_CULLING) $value = false; parent::setOption($option, $value); } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Pie.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Pie.php +++ pear/Image_3D/Image/3D/Paintable/Object/Pie.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Pie.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Pie * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Pie extends Image_3D_Object { public function __construct($parameter) { $parameter = $this->_checkParameter($parameter); if ($parameter['inside'] == 0) { $this->_createPie($parameter); } else { $this->_createDonutPie($parameter); } } protected function _createPie($parameter) { $step = ($parameter['end'] - $parameter['start']) / $parameter['detail']; // center $centerTop = new Image_3D_Point(0, 0, .5); $centerBottom = new Image_3D_Point(0, 0, -.5); // Add polygones for top and bottom of the pie $x = cos($parameter['start']) * $parameter['outside']; $y = sin($parameter['start']) * $parameter['outside']; $top = new Image_3D_Point($x, $y, .5); $bottom = new Image_3D_Point($x, $y, -.5); // Polygones for the opening side $this->_addPolygon(new Image_3D_Polygon($top, $centerTop, $centerBottom)); $this->_addPolygon(new Image_3D_Polygon($bottom, $top, $centerBottom)); for ($i = 1; $i <= $parameter['detail']; $i++) { $x = cos($parameter['start'] + $i * $step) * $parameter['outside']; $y = sin($parameter['start'] + $i * $step) * $parameter['outside']; $newTop = new Image_3D_Point($x, $y, .5); $newBottom = new Image_3D_Point($x, $y, -.5); $this->_addPolygon(new Image_3D_Polygon($centerTop, $top, $newTop)); $this->_addPolygon(new Image_3D_Polygon($centerBottom, $bottom, $newBottom)); // Rand $this->_addPolygon(new Image_3D_Polygon($top, $newBottom, $newTop)); $this->_addPolygon(new Image_3D_Polygon($top, $bottom, $newBottom)); $top = $newTop; $bottom = $newBottom; } // Polygones for the closing side $this->_addPolygon(new Image_3D_Polygon($top, $centerTop, $centerBottom)); $this->_addPolygon(new Image_3D_Polygon($bottom, $top, $centerBottom)); } protected function _checkParameter($array) { $array['detail'] = max(1, (int) $array['detail']); $array['outside'] = max(0, (int) $array['outside']); $array['inside'] = min(max(0, (int) $array['inside']), $array['outside']); $array['start'] = max(0, ((int) $array['start']) * pi() / 180); $array['end'] = max(0, ((int) $array['end']) * pi() / 180); return ($array); } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Sphere.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Sphere.php +++ pear/Image_3D/Image/3D/Paintable/Object/Sphere.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Sphere.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Sphere * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Sphere extends Image_3D_Object { protected $_points; protected $_virtualPolygon; protected $_radius; public function __construct($options) { parent::__construct(); $this->_lines = array(); $this->_points = array(); $this->_virtualPolygon = array(); $this->_radius = (float) @$options['r']; $detail = (int) @$options['detail']; $this->_createTetraeder(); for ($step = 0; $step < $detail; $step++) $this->_sierpinsky(); $this->_getRealPolygones(); } protected function _sierpinsky() { $newPolygones = array(); $proceededLines = array(); foreach ($this->_virtualPolygon as $points) { $lines = array( array(min($points[0], $points[1]), max($points[0], $points[1])), array(min($points[1], $points[2]), max($points[1], $points[2])), array(min($points[2], $points[0]), max($points[2], $points[0])) ); $new = array(); foreach ($lines as $line) { if (!isset($proceededLines[$line[0]][$line[1]])) { // Calculate new point $newX = ($this->_points[$line[0]]->getX() + $this->_points[$line[1]]->getX()) / 2; $newY = ($this->_points[$line[0]]->getY() + $this->_points[$line[1]]->getY()) / 2; $newZ = ($this->_points[$line[0]]->getZ() + $this->_points[$line[1]]->getZ()) / 2; $multiplikator = $this->_radius / sqrt(pow($newX, 2) + pow($newY, 2) + pow($newZ, 2)); $this->_points[] = new Image_3D_Point($newX * $multiplikator, $newY * $multiplikator, $newZ * $multiplikator); $proceededLines[$line[0]][$line[1]] = count($this->_points) - 1; } $new[] = $proceededLines[$line[0]][$line[1]]; } $newPolygones[] = array($points[0], $new[0], $new[2]); $newPolygones[] = array($points[1], $new[1], $new[0]); $newPolygones[] = array($points[2], $new[2], $new[1]); $newPolygones[] = array($new[0], $new[1], $new[2]); } $this->_virtualPolygon = $newPolygones; } protected function _createTetraeder() { $laenge = $this->_radius / sqrt(3); $this->_points[] = new Image_3D_Point(sqrt(2) * -$laenge, $laenge, 0); $this->_points[] = new Image_3D_Point(sqrt(2) * $laenge, $laenge, 0); $this->_points[] = new Image_3D_Point(0, -$laenge, sqrt(2) * -$laenge); $this->_points[] = new Image_3D_Point(0, -$laenge, sqrt(2) * $laenge); $this->_virtualPolygon[] = array(0, 1, 3); $this->_virtualPolygon[] = array(1, 2, 3); $this->_virtualPolygon[] = array(0, 2, 1); $this->_virtualPolygon[] = array(0, 3, 2); } protected function _getRealPolygones() { foreach ($this->_virtualPolygon as $points) { $this->_addPolygon(new Image_3D_Polygon($this->_points[$points[0]], $this->_points[$points[1]], $this->_points[$points[2]])); } } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Text.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Text.php +++ pear/Image_3D/Image/3D/Paintable/Object/Text.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Text.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix/Move.php'); require_once('Image/3D/Paintable/Object.php'); require_once('Image/3D/Paintable/Object/Cube.php'); /** * Image_3D_Object_Text * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Text extends Image_3D_Object { protected $_text; protected $_characterSpacing; protected $_chars; public function __construct($string) { parent::__construct(); $this->_text = (string) $string; $this->_points = array(); $this->_characterSpacing = 5.5; $this->_chars = unserialize(file_get_contents( // Dirty little trick for Kore's test env ;) (('@data_dir@' != '@'.'data'.'_'.'dir'.'@') ? '@data_dir@'.'TextData.dat' : 'data/TextData.dat'); )); $this->_generateCubes(); } public function setCharSpacing($charSpacing) { $this->_characterSpacing = 5 + (float) $charSpacing; } protected function _generateCubes() { $length = strlen($this->_text); for ($i = 0; $i < $length; $i++) { $char = $this->_chars[ord($this->_text{$i})]; foreach ($char as $x => $row) { foreach ($row as $y => $pixel) { //printf("Dot %d %.1f %.1f\n", $pixel, $x + $i * $this->_characterSpacing, $y); if ($pixel) { $tmp = new Image_3D_Object_Cube(array(1, 1, 1)); $tmp->transform(new Image_3D_Matrix_Move(array($x + $i * $this->_characterSpacing, $y, 0))); $polygones = $tmp->getPolygones(); foreach ($polygones as $polygon) $this->_addPolygon($polygon); unset($tmp); } } } } } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Renderer/Isometric.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Renderer/Isometric.php +++ pear/Image_3D/Image/3D/Renderer/Isometric.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Isometric.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Renderer_Isometric * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Renderer_Isometric extends Image_3D_Renderer { protected function _calculateScreenCoordiantes(Image_3D_Point $point) { $point->setScreenCoordinates( $point->getX() - ($point->getZ() * .35) + $this->_size[0] / 2, $point->getY() + ($point->getZ() * .35) + $this->_size[1] / 2 ); } protected function _sortPolygones() { $polygoneDepth = array(); foreach ($this->_polygones as $polygon) $polygoneDepth[] = $polygon->getMidZ(); array_multisort($polygoneDepth, SORT_DESC, SORT_NUMERIC, $this->_polygones); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Renderer/Perspectively.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Renderer/Perspectively.php +++ pear/Image_3D/Image/3D/Renderer/Perspectively.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Perspectively.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Renderer_Perspectively * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Renderer_Perspectively extends Image_3D_Renderer { protected function _calculateScreenCoordiantes(Image_3D_Point $point) { $viewpoint = 500.; $distance = 500.; $point->setScreenCoordinates( $viewpoint * $point->getX() / ($point->getZ() + $distance) + $this->_size[0] / 2, $viewpoint * $point->getY() / ($point->getZ() + $distance) + $this->_size[1] / 2 ); } protected function _sortPolygones() { $polygoneDepth = array(); foreach ($this->_polygones as $polygon) $polygoneDepth[] = $polygon->getMidZ(); array_multisort($polygoneDepth, SORT_DESC, SORT_NUMERIC, $this->_polygones); } } ?>
http://cvs.php.net/co.php/pear/Image_3D/generate_package_xml.php?r=1.1&p=1 Index: pear/Image_3D/generate_package_xml.php +++ pear/Image_3D/generate_package_xml.php #!/usr/bin/php <?php // $make = 1; require_once('PEAR/PackageFileManager.php'); $pkg = new PEAR_PackageFileManager; // directory that PEAR CVS is located in $cvsdir = '/home/dotxp/dev/'; $packagedir = $cvsdir . 'Image_3D/trunk/'; // Filemanager settings $category = 'Image'; $package = 'Image_3D'; $version = '0.2.0'; $state = 'alpha'; $summary = 'This class allows the rendering of 3 dimensional images using PHP and ext/GD.'; $description = <<<EOT Image_3D is a highly object oriented PHP5 package that allows the creation of 3 dimensional images using PHP and the GD extension, which is bundled with PHP. Image_3D currently supports: * Creation of 3D objects like cubes, spheres, maps, text,... * Own object definitions possible * Own material definitions * Import of 3DSMax files * Unlimited number of light sources * Saving all output formats supported by GD EOT; $notes = <<<EOT * New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. EOT; $e = $pkg->setOptions( array('simpleoutput' => true, 'baseinstalldir' => '', 'summary' => $summary, 'description' => $description, 'version' => $version, 'license' => 'LGPL', 'packagedirectory' => $packagedir, 'pathtopackagefile' => $packagedir, 'state' => $state, 'filelistgenerator' => 'file', 'notes' => $notes, 'package' => $package, 'dir_roles' => array( 'docs' => 'doc'), 'ignore' => array('*.xml', '*.tgz', 'generate_package*', ), )); if (PEAR::isError($e)) { echo $e->getMessage(); exit; } $e = $pkg->addMaintainer('toby', 'lead', 'Tobias Schlitt', 'toby@php.net'); $e = $pkg->addMaintainer('kore', 'lead', 'Kore Nordmann', 'pear@kore-nordmann.de'); if (PEAR::isError($e)) { echo $e->getMessage(); exit; } $e = $pkg->addDependency('gd', null, 'has', 'ext'); $e = $pkg->addDependency('php', '5.0.0', 'ge', 'php'); $e = $pkg->addGlobalReplacement('package-info', '@package_version@', 'version'); $e = $pkg->addGlobalReplacement('pear-config', '@data_dir@', 'data_dir'); if (PEAR::isError($e)) { echo $e->getMessage(); exit; } // hack until they get their shit in line with docroot role $pkg->addRole('tpl', 'php'); $pkg->addRole('png', 'php'); $pkg->addRole('gif', 'php'); $pkg->addRole('jpg', 'php'); $pkg->addRole('css', 'php'); $pkg->addRole('js', 'php'); $pkg->addRole('ini', 'php'); $pkg->addRole('inc', 'php'); $pkg->addRole('afm', 'php'); $pkg->addRole('pkg', 'doc'); $pkg->addRole('cls', 'doc'); $pkg->addRole('proc', 'doc'); $pkg->addRole('sh', 'doc'); if (isset($make)) { $e = $pkg->writePackageFile(); } else { $e = $pkg->debugPackageFile(); } if (PEAR::isError($e)) { echo $e->getMessage(); } /* if (!isset($make)) { echo '<a href="' . $_SERVER['PHP_SELF'] . '?make=1">Make this file</a>'; } */ ?> http://cvs.php.net/co.php/pear/Image_3D/package.xml?r=1.1&p=1 Index: pear/Image_3D/package.xml +++ pear/Image_3D/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0" packagerversion="1.4.0a12"> <name>Image_3D</name> <summary>This class allows the rendering of 3 dimensional images using PHP and ext/GD.</summary> <description>Image_3D is a highly object oriented PHP5 package that allows the creation of 3 dimensional images using PHP and the GD extension, which is bundled with PHP. Image_3D currently supports: * Creation of 3D objects like cubes, spheres, maps, text,... * Own object definitions possible * Own material definitions * Import of 3DSMax files * Unlimited number of light sources * Saving all output formats supported by GD </description> <maintainers> <maintainer> <user>toby</user> <name>Tobias Schlitt</name> <email>toby@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>kore</user> <name>Kore Nordmann</name> <email>pear@kore-nordmann.de</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.2.0</version> <date>2005-07-08</date> <license>LGPL</license> <state>alpha</state> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> <deps> <dep type="ext" rel="has" optional="no">gd</dep> <dep type="php" rel="ge" version="5.0.0" optional="no"/> </deps> <filelist> <dir name="/" baseinstalldir=""> <dir name="data"> <file role="data" name="TextData.dat"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /data --> <dir name="docs"> <dir name="examples"> <dir name="models"> <file role="doc" name="cube.3ds"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="Image_3D.3ds"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/examples/models --> <dir name="tests"> <file role="doc" name="TestImage_iso,flat,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,flat,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,flat,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,flat,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,gauroud,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,gauroud,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_iso,none,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,flat,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,gauroud,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,gauroud,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,bfculling.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,bfculling.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,nobfc.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TestImage_pers,none,nobfc.svg"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/examples/tests --> <file role="doc" name="3ds.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="map.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="test_all.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="text.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/examples --> <dir name="pictures"> <file role="doc" name="all_objects.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="animation.gif"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="car.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="f1.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="mickey.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="mickey_trans.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sincos.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="spheres.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_4.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_5.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_6.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="sphere_detail_7.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="text.png"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs/pictures --> <file role="doc" name="AUTHORS"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="COPYING"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="README"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="doc" name="TODO"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /docs --> <dir name="Image"> <dir name="3D"> <dir name="Color"> <file role="php" name="Metal.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Color --> <dir name="Driver"> <file role="php" name="GD.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="SVG.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Driver --> <dir name="Matrix"> <file role="php" name="Move.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Rotation.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Scale.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Matrix --> <dir name="Paintable"> <dir name="Object"> <file role="php" name="3ds.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="3dsChunks.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Cube.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Map.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Sphere.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Text.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Paintable/Object --> <file role="php" name="Light.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Object.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Polygon.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Paintable --> <dir name="Renderer"> <file role="php" name="Isometric.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Perspectively.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D/Renderer --> <file role="php" name="Color.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Coordinate.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Driver.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Enlightenable.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Matrix.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Paintable.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Point.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Renderer.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> <file role="php" name="Vector.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image/3D --> <file role="php" name="3D.php"> <replace type="package-info" from="@package_version@" to="version"/> <replace type="pear-config" from="@data_dir@" to="data_dir"/> </file> </dir> <!-- /Image --> </dir> <!-- / --> </filelist> </release> <changelog> <release> <version>0.2.0</version> <date>2005-07-08</date> <license>LGPL</license> <state>alpha</state> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> </release> </changelog> </package> http://cvs.php.net/co.php/pear/Image_3D/package2.xml?r=1.1&p=1 Index: pear/Image_3D/package2.xml +++ pear/Image_3D/package2.xml <?xml version="1.0"?> <package packagerversion="1.4.0a12" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>Image_3D</name> <channel>pear.php.net</channel> <summary>This class allows the rendering of 3 dimensional images using PHP and ext/GD.</summary> <description>Image_3D is a highly object oriented PHP5 package that allows the creation of 3 dimensional images using PHP and the GD extension, which is bundled with PHP. Image_3D currently supports: * Creation of 3D objects like cubes, spheres, maps, text,... * Own object definitions possible * Own material definitions * Import of 3DSMax files * Unlimited number of light sources * Saving all output formats supported by GD </description> <lead> <name>Tobias Schlitt</name> <user>toby</user> <email>toby@php.net</email> <active>yes</active> </lead> <lead> <name>Kore Nordmann</name> <user>kore</user> <email>pear@kore-nordmann.de</email> <active>yes</active> </lead> <date>2005-07-08</date> <time>00:08:53</time> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> <contents> <dir name="/"> <dir name="data"> <file baseinstalldir="" name="TextData.dat" role="data"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /data --> <dir name="docs"> <dir name="examples"> <dir name="models"> <file baseinstalldir="" name="cube.3ds" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Image_3D.3ds" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/examples/models --> <dir name="tests"> <file baseinstalldir="" name="TestImage_iso,flat,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,flat,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,flat,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,flat,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,gauroud,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,gauroud,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_iso,none,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,flat,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,gauroud,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,gauroud,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,bfculling.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,bfculling.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,nobfc.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TestImage_pers,none,nobfc.svg" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/examples/tests --> <file baseinstalldir="" name="3ds.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="map.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="test_all.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="text.php" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/examples --> <dir name="pictures"> <file baseinstalldir="" name="all_objects.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="animation.gif" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="car.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="f1.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="mickey.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="mickey_trans.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sincos.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="spheres.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_4.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_5.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_6.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="sphere_detail_7.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="text.png" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs/pictures --> <file baseinstalldir="" name="AUTHORS" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="COPYING" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="README" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="TODO" role="doc"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /docs --> <dir name="Image"> <dir name="3D"> <dir name="Color"> <file baseinstalldir="" name="Metal.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Color --> <dir name="Driver"> <file baseinstalldir="" name="GD.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="SVG.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Driver --> <dir name="Matrix"> <file baseinstalldir="" name="Move.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Rotation.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Scale.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Matrix --> <dir name="Paintable"> <dir name="Object"> <file baseinstalldir="" name="3ds.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="3dsChunks.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Cube.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Map.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Sphere.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Text.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Paintable/Object --> <file baseinstalldir="" name="Light.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Object.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Polygon.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Paintable --> <dir name="Renderer"> <file baseinstalldir="" name="Isometric.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Perspectively.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D/Renderer --> <file baseinstalldir="" name="Color.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Coordinate.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Driver.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Enlightenable.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Matrix.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Paintable.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Point.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Renderer.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> <file baseinstalldir="" name="Vector.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image/3D --> <file baseinstalldir="" name="3D.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> </dir> <!-- /Image --> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>5.0.0</min> </php> <pearinstaller> <min>1.4.0a1</min> </pearinstaller> <extension> <name>gd</name> </extension> </required> </dependencies> <phprelease /> <changelog> <release> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <date>2005-07-08</date> <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license> <notes>* New renderer interface, added a standard and an isometric renderer. * Driver based output format, supports now GD and SVG. * New shading API, supports modes "none", "flat" and "gauround" by now. * Highly refactored. </notes> </release> </changelog> </package> http://cvs.php.net/co.php/pear/Image_3D/Image/3D.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D.php +++ pear/Image_3D/Image/3D.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: 3D.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable.php'); require_once('Image/3D/Enlightenable.php'); require_once('Image/3D/Color.php'); require_once('Image/3D/Coordinate.php'); require_once('Image/3D/Point.php'); require_once('Image/3D/Vector.php'); require_once('Image/3D/Renderer.php'); require_once('Image/3D/Driver.php'); require_once('Image/3D/Paintable/Object.php'); require_once('Image/3D/Paintable/Light.php'); require_once('Image/3D/Paintable/Polygon.php'); /** * Image_3D * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D { protected $_color; protected $_objects; protected $_lights; protected $_renderer; protected $_driver; protected $_option; protected $_optionSet; const IMAGE_3D_OPTION_FILLED = 1; const IMAGE_3D_OPTION_BF_CULLING = 2; public function __construct() { $this->_objects = array(); $this->_lights = array(); $this->_renderer = null; $this->_driver = null; $this->_color = null; $this->_option[self::IMAGE_3D_OPTION_FILLED] = true; $this->_option[self::IMAGE_3D_OPTION_BF_CULLING] = true; $this->_optionSet = array(); } public function createObject($type, $parameter = array()) { $name = ucfirst($type); $class = 'Image_3D_Object_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Paintable/Object/' . $name . '.php'; $user_path = dirname(__FILE__) . '/3D/User/Object/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Paintable/Object/' . $name . '.php'); } elseif (is_file($user_path) && is_readable($user_path)) { include_once('Image/3D/User/Object/' . $name . '.php'); } else { throw new Exception("Class for object $name not found."); } return $this->_objects[] = new $class($parameter); } public function createLight($x, $y, $z) { return $this->_lights[] = new Image_3D_Light($x, $y, $z); } public function createMatrix($type, $parameter = array()) { $name = ucfirst($type); $class = 'Image_3D_Matrix_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Matrix/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Matrix/' . $name . '.php'); } else { throw new Exception("Class for matrix $name not found."); } return new $class($parameter); } public function setColor(Image_3D_Color $color, $recusive = true) { $this->_color = $color; } public function createRenderer($type) { $name = ucfirst($type); $class = 'Image_3D_Renderer_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Renderer/' . $name . '.php'; $user_path = dirname(__FILE__) . '/3D/User/Renderer/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Renderer/' . $name . '.php'); } elseif (is_file($user_path) && is_readable($user_path)) { include_once('Image/3D/User/Renderer/' . $name . '.php'); } else { throw new Exception("Class for renderer $name not found."); } return $this->_renderer = new $class(); } public function createDriver($type) { $name = ucfirst($type); $class = 'Image_3D_Driver_' . $name; $absolute_path = dirname(__FILE__) . '/3D/Driver/' . $name . '.php'; $user_path = dirname(__FILE__) . '/3D/User/Driver/' . $name . '.php'; if (is_file($absolute_path) && is_readable($absolute_path)) { include_once('Image/3D/Driver/' . $name . '.php'); } elseif (is_file($user_path) && is_readable($user_path)) { include_once('Image/3D/User/Driver/' . $name . '.php'); } else { throw new Exception("Class for driver $name not found."); } return $this->_driver = new $class(); } public function setOption($option, $value) { $this->_option[$option] = $value; $this->_optionSet[$option] = true; foreach ($this->_objects as $object) $object->setOption($option, $value); } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_objects as $object) $object->transform($matrix, $id); } public function render($x, $y, $file) { if (!is_writable(dirname($file)) && (!is_file($file) || !is_writable($file))) throw new Exception('Cannot write outputfile.'); $x = min(1280, max(0, (int) $x)); $y = min(1280, max(0, (int) $y)); $this->_renderer->setSize($x, $y); $this->_renderer->setBackgroundColor($this->_color); $this->_renderer->addObjects($this->_objects); $this->_renderer->addLights($this->_lights); $this->_renderer->setDriver($this->_driver); return $this->_renderer->render($file); } public function stats() { printf(' Image 3D objects: %d lights: %d polygones: %d points: %d ', count($this->_objects), $this->_renderer->getLightCount(), $this->_renderer->getPolygonCount(), $this->_renderer->getPointCount() ); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Color.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Color.php +++ pear/Image_3D/Image/3D/Color.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Color.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Color * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Color { protected $_rgbaValue; // protected $_image; protected $_lastColorID; protected $_lights; protected $_light; public function __construct() { // $this->_image = null; $this->_lastColorID = 0; $this->_rgbaValue = array(); $this->_lights = array(); $this->_light = array(0, 0, 0); $arglist = func_get_args(); $argcount = func_num_args(); for ($i = 0; $i < 4; $i++) { if ($i >= $argcount) { $this->_rgbaValue[$i] = 0; } elseif (is_int($arglist[$i])) { $this->_rgbaValue[$i] = (float) min(1, max(0, (float) $arglist[$i] / 255)); } elseif (is_float($arglist[$i])) { $this->_rgbaValue[$i] = (float) min(1, max(0, $arglist[$i])); } else { $this->_rgbaValue[$i] = 0; } } } public function getValues() { return $this->_rgbaValue; } public function addLight(Image_3D_Color $color, $intensity = .5) { $this->_lights[] = array($intensity, $color); } protected function _calcLights() { foreach ($this->_lights as $light) { list($intensity, $color) = $light; $colorArray = $color->getValues(); $this->_light[0] += $colorArray[0] * $intensity * (1 - $colorArray[3]); $this->_light[1] += $colorArray[1] * $intensity * (1 - $colorArray[3]); $this->_light[2] += $colorArray[2] * $intensity * (1 - $colorArray[3]); } } protected function _mixColor() { $this->_rgbaValue[0] = min(1, $this->_rgbaValue[0] * $this->_light[0]); $this->_rgbaValue[1] = min(1, $this->_rgbaValue[1] * $this->_light[1]); $this->_rgbaValue[2] = min(1, $this->_rgbaValue[2] * $this->_light[2]); } public function calculateColor() { $this->_calcLights(); $this->_mixColor(); } public function tostring() { return sprintf("Color: r %.2f g %.2f b %.2f a %.2f\n", $this->_rgbaValue[0], $this->_rgbaValue[1], $this->_rgbaValue[2], $this->_rgbaValue[3]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Coordinate.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Coordinate.php +++ pear/Image_3D/Image/3D/Coordinate.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Coordinate.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Coordinate * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Coordinate { protected $_x; protected $_y; protected $_z; public function __construct($x, $y, $z) { $this->_x = (float) $x; $this->_y = (float) $y; $this->_z = (float) $z; } public function transform(Image_3D_Matrix $matrix, $id = null) { // Point already transformed? if (($id !== null) && ($this->_lastTransformation === $id)) return false; $this->_lastTransformation = $id; $point = clone($this); $this->_x = $point->getX() * $matrix->getValue(0, 0) + $point->getY() * $matrix->getValue(1, 0) + $point->getZ() * $matrix->getValue(2, 0) + $matrix->getValue(3, 0); $this->_y = $point->getX() * $matrix->getValue(0, 1) + $point->getY() * $matrix->getValue(1, 1) + $point->getZ() * $matrix->getValue(2, 1) + $matrix->getValue(3, 1); $this->_z = $point->getX() * $matrix->getValue(0, 2) + $point->getY() * $matrix->getValue(1, 2) + $point->getZ() * $matrix->getValue(2, 2) + $matrix->getValue(3, 2); $this->_screenCoordinates = null; } public function processed() { $this->_processed = true; } public function isProcessed() { return $this->_processed; } public function getX() { return $this->_x; } public function getY() { return $this->_y; } public function getZ() { return $this->_z; } public function setScreenCoordinates($x, $y) { $this->_screenCoordinates = array((float) $x, (float) $y); } public function getScreenCoordinates() { return $this->_screenCoordinates; } public function __toString() { return sprintf('Coordinate: %2.f %2.f %2.f', $this->_x, $this->_y, $this->_z); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Driver.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Driver.php +++ pear/Image_3D/Image/3D/Driver.php <?php abstract class Image_3D_Driver { protected $_image; public function __construct() { $this->_image = null; } abstract public function createImage($x, $y); abstract public function setBackground(Image_3D_Color $color); abstract public function drawPolygon(Image_3D_Polygon $polygon); abstract public function drawGradientPolygon(Image_3D_Polygon $polygon); abstract public function save($file); public function getSupportedShading() { return array(Image_3D_Renderer::SHADE_NO); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Enlightenable.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Enlightenable.php +++ pear/Image_3D/Image/3D/Enlightenable.php <?php /*** * * 3dlib - 3d libary in PHP * Copyright (C) 2004 Kore Nordmann - http://www.kore-nordmann.de (German) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * You may contact the author by mail: * 3dlib@kore-nordmann.de * * Or write to: * Kore Nordmann * Stockumer Strasse 404 * 44227 Dortmund * Germany * **/ interface enlightenable { public function getColor(); public function getNormale(); public function getPosition(); } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix.php +++ pear/Image_3D/Image/3D/Matrix.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Matrix.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Matrix * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix { public $matrix; public function __construct() { $this->setUnitMatrix(); } public function setValue($x, $y, $value) { if (!isset($this->_matrix[$x][$y])) return false; $this->_matrix[$x][$y] = (float) $value; } public function getValue($x, $y) { if (!isset($this->_matrix[$x][$y])) return false; return (float) $this->_matrix[$x][$y]; } public function setUnitMatrix() { $this->_matrix = array( array(1., 0., 0., 0.), array(0., 1., 0., 0.), array(0., 0., 1., 0.), array(0., 0., 0., 1.) ); } public function diff(Image_3D_Matrix $matrix) { $result = new Image_3D_Matrix(); for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { $result->setValue($i, $j, $matrix->getValue($i, $j) - $this->_getValue($i, $j)); } } return $result; } public function multiplySkalar($skalar) { for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { $this->_matrix[$i][$j] *= $skalar; } } } public function dump() { foreach ($this->_matrix as $row) { printf("|\t%2.2f\t%2.2f\t%2.2f\t%2.2f\t|\n", $row[0], $row[1], $row[2], $row[3]); } } public function setRotationMatrix($rotationX, $rotationY, $rotationZ) { $rotationY = (float) $rotationY; $rotationZ = (float) $rotationZ; if (!empty($rotationX)) { // Normalisierung der Rotation von Grad auf radiale Berechnung $rotationX = (float) $rotationX; $rotationX *= pi() / 180; // Setzen der Rotationsmatrix fuer Drehungen an der X-Achse $matrix = new Image_3D_Matrix(); $matrix->setValue(1, 1, cos($rotationX)); $matrix->setValue(1, 2, sin($rotationX)); $matrix->setValue(2, 1, -sin($rotationX)); $matrix->setValue(2, 2, cos($rotationX)); // Setzen der Transformationsmatrix $this->_multiply($matrix); unset($matrix); } if (!empty($rotationY)) { // Normalisierung der Rotation von Grad auf radiale Berechnung $rotationY = (float) $rotationY; $rotationY *= pi() / 180; // Setzen der Rotationsmatrix fuer Drehungen an der X-Achse $matrix = new Image_3D_Matrix(); $matrix->setValue(0, 0, cos($rotationY)); $matrix->setValue(0, 2, -sin($rotationY)); $matrix->setValue(2, 0, sin($rotationY)); $matrix->setValue(2, 2, cos($rotationY)); // Setzen der Transformationsmatrix $this->_multiply($matrix); unset($matrix); } if (!empty($rotationZ)) { // Normalisierung der Rotation von Grad auf radiale Berechnung $rotationZ = (float) $rotationZ; $rotationZ *= pi() / 180; // Setzen der Rotationsmatrix fuer Drehungen an der X-Achse $matrix = new Image_3D_Matrix(); $matrix->setValue(0, 0, cos($rotationZ)); $matrix->setValue(0, 1, sin($rotationZ)); $matrix->setValue(1, 0, -sin($rotationZ)); $matrix->setValue(1, 1, cos($rotationZ)); // Setzen der Transformationsmatrix $this->_multiply($matrix); unset($matrix); } } public function setMoveMatrix($moveX, $moveY, $moveZ) { $matrix = new Image_3D_Matrix(); $matrix->setValue(3, 0, (float) $moveX); $matrix->setValue(3, 1, (float) $moveY); $matrix->setValue(3, 2, (float) $moveZ); $this->_multiply($matrix); } public function setScaleMatrix($scaleX, $scaleY, $scaleZ) { $matrix = new Image_3D_Matrix(); $matrix->setValue(0, 0, (float) $scaleX); $matrix->setValue(1, 1, (float) $scaleY); $matrix->setValue(2, 2, (float) $scaleZ); $this->_multiply($matrix); } protected function _multiply(Image_3D_Matrix $matrix) { $new = clone($this); for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { $sum = 0; for ($k = 0; $k < 4; $k++) { $sum += $new->getValue($i, $k) * $matrix->getValue($k, $j); } $this->setValue($i, $j, $sum); } } } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable.php +++ pear/Image_3D/Image/3D/Paintable.php <?php /*** * * 3dlib - 3d libary in PHP * Copyright (C) 2004 Kore Nordmann - http://www.kore-nordmann.de (German) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * You may contact the author by mail: * 3dlib@kore-nordmann.de * * Or write to: * Kore Nordmann * Stockumer Strasse 404 * 44227 Dortmund * Germany * **/ interface paintable { public function getPolygonCount(); public function setColor(Image_3D_Color $color); public function setOption($option, $value); public function transform(Image_3D_Matrix $matrix, $id = null); } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Point.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Point.php +++ pear/Image_3D/Image/3D/Point.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Point.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Point * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Point extends Image_3D_Coordinate implements enlightenable { protected $_option; protected $_lastTransformation; protected $_screenCoordinates; protected $_processed; protected $_normale; protected $_vectors; protected $_colors; protected $_color; public function __construct($x, $y, $z) { parent::__construct($x, $y, $z); $this->_option = array(); $this->_lastTransformation = null; $this->_screenCoordinates = null; $this->_processed = false; $this->_colors = array(); $this->_color = null; } public function setOption($option, $value) { $this->_option[$option] = $value; } public function calculateColor($lights) { foreach ($lights as $light) $this->_color = $light->getColor($this); $this->_color->calculateColor(); } public function addVector(Image_3D_Vector $vector) { $this->_vectors[] = $vector; } protected function _calcNormale() { $this->_normale = new Image_3D_Vector(0, 0, 0); foreach ($this->_vectors as $vector) $this->_normale->add($vector); $this->_normale->unify(); } public function getNormale() { if (!is_a($this->_normale, 'Image_3D_Vector')) $this->_calcNormale(); return $this->_normale; } public function getPosition() { return new Image_3D_Vector($this->_x, $this->_y, $this->_z); } public function addColor(Image_3D_Color $color) { $this->_colors[] = $color; } protected function _mixColors() { $i = 0; $color = array(0, 0, 0, 0); foreach ($this->_colors as $c) { $values = $c->getValues(); $color[0] += $values[0]; $color[1] += $values[1]; $color[2] += $values[2]; $color[3] += $values[3]; $i++; } $this->_color = new Image_3D_Color($color[0] / $i, $color[1] / $i, $color[2] / $i, $color[3] / $i); } public function getColor() { if ($this->_color === null) $this->_mixColors(); return $this->_color; } public function __toString() { return sprintf('Point: %2.f %2.f %2.f', $this->_x, $this->_y, $this->_z); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Renderer.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Renderer.php +++ pear/Image_3D/Image/3D/Renderer.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Renderer.php,v 1.1 2005/07/18 15:35:29 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Renderer * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ abstract class Image_3D_Renderer { protected $_polygones; protected $_points; protected $_lights; protected $_driver; protected $_size; protected $_background; protected $_shading; const SHADE_NO = 0; const SHADE_FLAT = 1; const SHADE_GAUROUD = 2; const SHADE_PHONG = 3; public function __construct() { $this->_objects = array(); $this->_polygones = array(); $this->_points = array(); $this->_lights = array(); $this->_size = array(0, 0); $this->_background = null; $this->_driver = null; $this->_shading = self::SHADE_PHONG; } protected function _getPolygones(Image_3D_Object $object) { $newPolygones = $object->getPolygones(); $this->_polygones = array_merge($this->_polygones, $newPolygones); // Add points unique to points-Array foreach ($newPolygones as $polygon) { $points = $polygon->getPoints(); foreach ($points as $point) { if (!$point->isProcessed()) { $point->processed(); array_push($this->_points, $point); } } } } // Calculate perspective abstract protected function _calculateScreenCoordiantes(Image_3D_Point $point); // Implement polygon-based Z-buffer abstract protected function _sortPolygones(); public function addObjects($objects) { if (is_array($objects)) { foreach ($objects as $object) { if (is_a($object, 'Image_3D_Object')) { $this->_getPolygones($object); } } } elseif (is_a($objects, 'Image_3D_Object')) { $this->_getPolygones($objects); } } public function addLights($lights) { $this->_lights = array_merge($this->_lights, $lights); } public function setSize($x, $y) { $this->_size = array($x, $y); } public function setBackgroundColor(Image_3D_Color $color) { $this->_background = $color; } public function setShading($shading) { $this->_shading = min($this->_shading, (int) $shading); } public function setDriver(Image_3D_Driver $driver) { $this->_driver = $driver; $this->setShading(max($driver->getSupportedShading())); } public function getPolygonCount() { return count($this->_polygones); } public function getPointCount() { return count($this->_points); } public function getLightCount() { return count($this->_lights); } protected function _calculatePolygonColors() { foreach ($this->_polygones as $polygon) { $polygon->calculateColor($this->_lights); } } protected function _calculatePointColors() { foreach ($this->_polygones as $polygon) { $normale = $polygon->getNormale(); $color = $polygon->getColor(); $points = $polygon->getPoints(); foreach ($points as $point) { $point->addVector($normale); $point->addColor($color); } } foreach ($this->_points as $point) $point->calculateColor($this->_lights); } protected function _shade() { switch ($this->_shading) { case self::SHADE_NO: foreach ($this->_polygones as $polygon) $this->_driver->drawPolygon($polygon); break; case self::SHADE_FLAT: $this->_calculatePolygonColors(); foreach ($this->_polygones as $polygon) $this->_driver->drawPolygon($polygon); break; case self::SHADE_GAUROUD: $this->_calculatePointColors(); foreach ($this->_polygones as $polygon) $this->_driver->drawGradientPolygon($polygon); break; default: throw new Exception('Shading type not supported.'); break; } } public function render($file) { if (empty($this->_driver)) return false; // Calculate screen coordinates foreach ($this->_points as $point) $this->_calculateScreenCoordiantes($point); $this->_sortPolygones(); // Draw background $this->_driver->createImage($this->_size[0], $this->_size[1]); $this->_driver->setBackground($this->_background); // Calculate Colors $this->_shade(); // Save $this->_driver->save($file); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Vector.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Vector.php +++ pear/Image_3D/Image/3D/Vector.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Vector.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Point.php'); /** * Image_3D_Vector * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Vector extends Image_3D_Coordinate { public function getAngle(Image_3D_Vector $vector) { $vector->unify(); $this->unify(); return acos($this->_x * $vector->getX() + $this->_y * $vector->getY() + $this->_z * $vector->getZ()) * 2 / pi(); } public function unify() { $value = sqrt(pow($this->_x, 2) + pow($this->_y, 2) + pow($this->_z, 2)); if ($value == 0) return false; $this->_x /= $value; $this->_y /= $value; $this->_z /= $value; } public function add(Image_3D_Vector $vector) { $this->_x += $vector->getX(); $this->_y += $vector->getY(); $this->_z += $vector->getZ(); } public function sub(Image_3D_Vector $vector) { $this->_x -= $vector->getX(); $this->_y -= $vector->getY(); $this->_z -= $vector->getZ(); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Color/Metal.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Color/Metal.php +++ pear/Image_3D/Image/3D/Color/Metal.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Metal.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Color.php'); /** * Image_3D_Color_Metal * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Color_Metal extends Image_3D_Color { protected $_metal; public function setMetal($metal) { $this->_metal = (float) $metal; } protected function _mixColor() { $this->_rgbaValue[0] = min(1, $this->_rgbaValue[0] * $this->_light[0] + $this->_metal * $this->_light[0]); $this->_rgbaValue[1] = min(1, $this->_rgbaValue[1] * $this->_light[1] + $this->_metal * $this->_light[1]); $this->_rgbaValue[2] = min(1, $this->_rgbaValue[2] * $this->_light[2] + $this->_metal * $this->_light[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Driver/GD.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Driver/GD.php +++ pear/Image_3D/Image/3D/Driver/GD.php <?php class Image_3D_Driver_GD extends Image_3D_Driver { protected $_filetype; public function __construct() { parent::__construct(); $this->_filetype = 'png'; } public function createImage($x, $y) { $this->_image = imagecreatetruecolor($x, $y); } protected function _getColor(Image_3D_Color $color) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); $values[3] = (int) round($values[3] * 127); if ($this->_rgbaValue[3] > 0) { // Tranzparente Farbe allokieren $color = imageColorExactAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]); if ($color === -1) { // Wenn nicht Farbe neu alloziieren $color = imageColorAllocateAlpha($this->_image, $values[0], $values[1], $values[2], $values[3]); } } else { // Deckende Farbe allozieren $color = imageColorExact($this->_image, $values[0], $values[1], $values[2]); if ($color === -1) { // Wenn nicht Farbe neu alloziieren $color = imageColorAllocate($this->_image, $values[0], $values[1], $values[2]); } } return $color; } public function setBackground(Image_3D_Color $color) { $bg = $this->_getColor($color); imagefill($this->_image, 1, 1, $bg); } public function drawPolygon(Image_3D_Polygon $polygon) { // Get points $points = $polygon->getPoints(); $coords = array(); foreach ($points as $point) $coords = array_merge($coords, $point->getScreenCoordinates()); $coordCount = (int) (count($coords) / 2); if (true) { imageFilledPolygon($this->_image, $coords, $coordCount, $this->_getColor($polygon->getColor())); } else { imagePolygon($this->_image, $coords, $coordCount, $this->_getColor($polygon->getColor())); } } public function drawGradientPolygon(Image_3D_Polygon $polygon) { $this->drawPolygon($polygon); } public function setFiletye($type) { $type = strtolower($type); if (in_array($type, array('png', 'jpeg'))) { $this->_filetype = $type; return true; } else { return false; } } public function save($file) { switch ($this->_filetype) { case 'png': return imagepng($this->_image, $file); case 'jpeg': return imagejpeg($this->_image, $file); } } public function getSupportedShading() { return array(Image_3D_Renderer::SHADE_NO, Image_3D_Renderer::SHADE_FLAT); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Driver/SVG.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Driver/SVG.php +++ pear/Image_3D/Image/3D/Driver/SVG.php <?php class Image_3D_Driver_SVG extends Image_3D_Driver { protected $_x; protected $_y; protected $_id; protected $_gradients; protected $_polygones; public function __construct() { $this->_image = ''; $this->_id = 1; $this->_gradients = array(); $this->_polygones = array(); } public function createImage($x, $y) { $this->_x = (int) $x; $this->_y = (int) $y; $this->_image = <<<EOF <?xml version="1.0" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" width="{$this->_x}" height="{$this->_y}" x="0" y="0"> EOF; $this->_image .= "\n\n"; } public function setBackground(Image_3D_Color $color) { $this->_addPolygon(sprintf("\t<polygon id=\"background%d\" points=\"0,0 %d,0 %d,%d 0,%d\" style=\"%s\" />\n", $this->_id++, $this->_x, $this->_x, $this->_y, $this->_y, $this->_getStyle($color))); } protected function _getStyle(Image_3D_Color $color) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); $values[3] = 1 - $values[3]; return sprintf('fill: #%02x%02x%02x; fill-opacity: %.2f; stroke: none;', $values[0], $values[1], $values[2], $values[3]); } protected function _getStop(Image_3D_Color $color, $offset = 0, $alpha = null) { $values = $color->getValues(); $values[0] = (int) round($values[0] * 255); $values[1] = (int) round($values[1] * 255); $values[2] = (int) round($values[2] * 255); if ($alpha === null) { $values[3] = 1 - $values[3]; } else { $values[3] = 1 - $alpha; } return sprintf("\t\t\t<stop id=\"stop%d\" offset=\"%.1f\" style=\"stop-color: rgb(%d, %d, %d); stop-opacity: %.4f;\" />\n", $this->_id++, $offset, $values[0], $values[1], $values[2], $values[3]); } protected function _addGradient($string) { $id = 'linearGradient' . $this->_id++; $this->_gradients[] = str_replace('[id]', $id, $string); return $id; } protected function _addPolygon($string) { $id = 'polygon' . $this->_id++; $this->_polygones[] = str_replace('[id]', $id, $string); return $id; } public function drawPolygon(Image_3D_Polygon $polygon) { $list = ''; $points = $polygon->getPoints(); foreach ($points as $point) { $pointarray = $point->getScreenCoordinates(); $list .= sprintf('%.2f,%.2f ', $pointarray[0], $pointarray[1]); } $this->_addPolygon(sprintf("\t<polygon points=\"%s\" style=\"%s\" />\n", substr($list, 0, -1), $this->_getStyle($polygon->getColor()))); } public function drawGradientPolygon(Image_3D_Polygon $polygon) { $points = $polygon->getPoints(); $list = ''; $pointarray = array(); foreach ($points as $nr => $point) { $pointarray[$nr] = $point->getScreenCoordinates(); $list .= sprintf('%.2f,%.2f ', $pointarray[$nr][0], $pointarray[$nr][1]); } // Groessen $xOffset = min($pointarray[0][0], $pointarray[1][0], $pointarray[2][0]); $yOffset = min($pointarray[0][1], $pointarray[1][1], $pointarray[2][1]); $xSize = max(abs($pointarray[0][0] - $pointarray[1][0]), abs($pointarray[0][0] - $pointarray[2][0]), abs($pointarray[1][0] - $pointarray[2][0])); $ySize = max(abs($pointarray[0][1] - $pointarray[1][1]), abs($pointarray[0][1] - $pointarray[2][1]), abs($pointarray[1][1] - $pointarray[2][1])); // Base Polygon $lg = $this->_addGradient(sprintf("\t\t<linearGradient id=\"[id]\" x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\">\n%s\t\t</linearGradient>\n", ($pointarray[0][0] - $xOffset) / $xSize, ($pointarray[0][1] - $yOffset) / $ySize, ($pointarray[1][0] - $xOffset) / $xSize, ($pointarray[1][1] - $yOffset) / $ySize, $this->_getStop($points[0]->getColor()) . $this->_getStop($points[1]->getColor(), 1))); $this->_addPolygon(sprintf("\t<polygon id=\"[id]\" points=\"%s\" style=\"fill: url(#%s); stroke: none; fill-opacity: 1;\" />\n", $list, $lg)); // Overlay Polygon $lg = $this->_addGradient(sprintf("\t\t<linearGradient id=\"[id]\" x1=\"%.2f\" y1=\"%.2f\" x2=\"%.2f\" y2=\"%.2f\">\n%s\t\t</linearGradient>\n", ($pointarray[2][0] - $xOffset) / $xSize, ($pointarray[2][1] - $yOffset) / $ySize, ((($pointarray[0][0] + $pointarray[1][0]) / 2) - $xOffset) / $xSize, ((($pointarray[0][1] + $pointarray[1][1]) / 2) - $yOffset) / $ySize, $this->_getStop($points[2]->getColor()) . $this->_getStop($points[2]->getColor(), 1, 1))); $this->_addPolygon(sprintf("\t<polygon id=\"[id]\" points=\"%s\" style=\"fill: url(#%s); stroke: none; fill-opacity: 1;\" />\n", $list, $lg)); } public function save($file) { $this->_image .= sprintf("\t<defs id=\"defs%d\">\n", $this->_id++); $this->_image .= implode('', $this->_gradients); $this->_image .= sprintf("\t</defs>\n\n"); $this->_image .= implode('', $this->_polygones); $this->_image .= "</svg>\n"; file_put_contents($file, $this->_image); } public function getSupportedShading() { return array(Image_3D_Renderer::SHADE_NO, Image_3D_Renderer::SHADE_FLAT, Image_3D_Renderer::SHADE_GAUROUD); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix/Move.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix/Move.php +++ pear/Image_3D/Image/3D/Matrix/Move.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Move.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix.php'); /** * Image_3D_Matrix_Move * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix_Move extends Image_3D_Matrix { public function __construct($parameter) { $this->setUnitMatrix(); $this->setMoveMatrix((float) @$parameter[0], (float) @$parameter[1], (float) @$parameter[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix/Rotation.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix/Rotation.php +++ pear/Image_3D/Image/3D/Matrix/Rotation.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Rotation.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix.php'); /** * Image_3D_Matrix_Rotation * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix_Rotation extends Image_3D_Matrix { public function __construct($parameter) { $this->setUnitMatrix(); $this->setRotationMatrix((float) @$parameter[0], (float) @$parameter[1], (float) @$parameter[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Matrix/Scale.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Matrix/Scale.php +++ pear/Image_3D/Image/3D/Matrix/Scale.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Scale.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix.php'); /** * Image_3D_Matrix_Scale * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Matrix_Scale extends Image_3D_Matrix { public function __construct($parameter) { $this->setUnitMatrix(); $this->setScaleMatrix((float) @$parameter[0], (float) @$parameter[1], (float) @$parameter[2]); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Light.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Light.php +++ pear/Image_3D/Image/3D/Paintable/Light.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Light.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Light * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Light extends Image_3D_Coordinate implements paintable { protected $_color; public function __construct($x, $y, $z) { parent::__construct($x, $y, $z); $this->_color = null; $this->_position = null; } public function getPolygonCount() { return 0; } public function setColor(Image_3D_Color $color) { $this->_color = $color; } public function setOption($option, $value) { $this->_option[$option] = $value; } public function getColor(Enlightenable $polygon) { $color = clone ($polygon->getColor()); $light = new Image_3D_Vector($this->_x, $this->_y, $this->_z); $light->sub($polygon->getPosition()); $normale = $polygon->getNormale(); $angle = abs(1 - $normale->getAngle($light)); $color->addLight($this->_color, $angle); return $color; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object.php +++ pear/Image_3D/Image/3D/Paintable/Object.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Object.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Object * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object implements paintable { protected $_polygones; public function __construct() { $this->_polygones = array(); } public function getPolygonCount() { return count($this->_polygones); } public function setColor(Image_3D_Color $color) { foreach ($this->_polygones as $polygon) $polygon->setColor($color); } public function setOption($option, $value) { foreach ($this->_polygones as $polygon) $polygon->setOption($option, $value); } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_polygones as $polygon) $polygon->transform($matrix, $id); } public function getPolygones() { return $this->_polygones; } protected function _addPolygon(Image_3D_Polygon $polygon) { $this->_polygones[] = $polygon; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Polygon.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Polygon.php +++ pear/Image_3D/Image/3D/Paintable/Polygon.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Polygon.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Polygon * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Polygon implements paintable, enlightenable { protected $_color; protected $_colorCalculated; protected $_option; protected $_points; protected $_visible; protected $_normale; protected $_position; public function __construct() { $this->_points = array(); $this->_option = array(); $this->_color = null; $this->_colorCalculated = false; $this->_visible = true; $this->_normale = null; $this->_position = null; if (func_num_args()) { $args = func_get_args(); for ($i = 0; $i < func_num_args(); $i++) { if (is_object($args[$i]) && is_a($args[$i], 'Image_3D_Point')) { $this->addPoint($args[$i]); } } } } public function calculateColor($lights) { foreach ($lights as $light) $this->_color = $light->getColor($this); $this->_color->calculateColor(); } public function getColor() { return $this->_color; } protected function _calcNormale() { if (count($this->_points) < 3) { $this->_normale = new Image_3D_Vector(0, 0, 0); return false; } $a1 = $this->_points[0]->getX() - $this->_points[1]->getX(); $a2 = $this->_points[0]->getY() - $this->_points[1]->getY(); $a3 = $this->_points[0]->getZ() - $this->_points[1]->getZ(); $b1 = $this->_points[2]->getX() - $this->_points[1]->getX(); $b2 = $this->_points[2]->getY() - $this->_points[1]->getY(); $b3 = $this->_points[2]->getZ() - $this->_points[1]->getZ(); $this->_normale = new Image_3D_Vector($a2 * $b3 - $a3 * $b2, $a3 * $b1 - $a1 * $b3, $a1 * $b2 - $a2 * $b1); // Backface Culling if (($this->_normale->getZ() <= 0) && ($this->_option[Image_3D::IMAGE_3D_OPTION_BF_CULLING])) $this->setInvisible(); } public function getNormale() { if (!is_a($this->_normale, 'Image_3D_Vector')) $this->_calcNormale(); return $this->_normale; } protected function _calcPosition() { $position = array(0, 0, 0); foreach ($this->_points as $point) { $position[0] += $point->getX(); $position[1] += $point->getY(); $position[2] += $point->getZ(); } $count = count($this->_points); $this->_position = new Image_3D_Vector($position[0] / $count, $position[1] / $count, $position[2] / $count); } public function getPosition() { if (!is_a($this->_position, 'Image_3D_Vector')) $this->_calcPosition(); return $this->_position; } public function getPolygonCount() { return 1; } public function setColor(Image_3D_Color $color) { $this->_color = $color; } public function isVisible() { return $this->isVisible(); } public function setInvisible() { $this->_visible = false; } public function setOption($option, $value) { $this->_option[$option] = $value; foreach ($this->_points as $point) $point->setOption($option, $value); } public function addPoint(Image_3D_Point $point) { $this->_points[] = $point; } public function getPoints() { return $this->_points; } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_points as $point) $point->transform($matrix, $id); } public function getMidZ() { $z = 0; foreach ($this->_points as $point) $z += $point->getZ(); return $z / count($this->_points); } public function getMaxZ() { $z = -500; foreach ($this->_points as $point) $z = max($point->getZ(), $z); return $z; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/3ds.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/3ds.php +++ pear/Image_3D/Image/3D/Paintable/Object/3ds.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: 3ds.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); require_once('Image/3D/Paintable/Object/3dsChunks.php'); /** * Image_3D_Object_3ds * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_3ds extends Image_3D_Object { protected $_file; protected $_fileSize; protected $_objects; protected $_chunks; public function __construct($file) { parent::__construct(); $this->_points = array(); $this->_chunks = array(); if (!is_file($file) || !is_readable($file)) return false; $this->_file = $file; $this->_readChunks(); } protected function _readChunks() { $this->_chunks = new Image_3D_Chunk(Image_3D_Chunk::MAIN3DS, substr(file_get_contents($this->_file), 6)); $this->_chunks->readChunks(); $editor = $this->_chunks->getFirstChunkByType(Image_3D_Chunk::EDIT3DS); $editor->readChunks(); $objects = $editor->getChunksByType(Image_3D_Chunk::EDIT_OBJECT); foreach ($objects as $object) { $object = new Image_3D_Chunk_Object($object->getType(), $object->getContent()); $object->readChunks($this); } } public function addObject($id) { $id = (string) $id; $this->_objects[$id] = new Image_3D_Object_3ds_Object(); return $this->_objects[$id]; } public function getObjectIDs() { return array_keys($this->_objects); } public function getObject($id) { if (!@isset($this->_objects[$id])) return false; return $this->_objects[$id]; } public function paint() { foreach ($this->_objects as $object) $object->paint(); } public function getPolygonCount() { $count = 0; foreach ($this->_objects as $object) $count += $object->getPolygonCount(); return $count; } public function setColor(Image_3D_Color $color) { foreach ($this->_objects as $object) $object->setColor($color); } public function setOption($option, $value) { foreach ($this->_objects as $object) $object->setOption($option, $value); } public function transform(Image_3D_Matrix $matrix, $id = null) { if ($id === null) $id = substr(md5(microtime()), 0, 8); foreach ($this->_objects as $object) $object->transform($matrix, $id); } public function getPolygones() { $polygones = array(); foreach ($this->_objects as $object) $polygones = array_merge($polygones, $object->getPolygones()); return $polygones; } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/3dsChunks.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/3dsChunks.php +++ pear/Image_3D/Image/3D/Paintable/Object/3dsChunks.php <?php class Image_3D_Chunk { protected $type; protected $content; protected $size; protected $chunks; //>------ Primary chunk const MAIN3DS = 0x4D4D; //>------ Main Chunks const EDIT3DS = 0x3D3D; // this is the start of the editor config const KEYF3DS = 0xB000; // this is the start of the keyframer config //>------ sub defines of EDIT3DS const EDIT_MATERIAL = 0xAFFF; const EDIT_CONFIG1 = 0x0100; const EDIT_CONFIG2 = 0x3E3D; const EDIT_VIEW_P1 = 0x7012; const EDIT_VIEW_P2 = 0x7011; const EDIT_VIEW_P3 = 0x7020; const EDIT_VIEW1 = 0x7001; const EDIT_BACKGR = 0x1200; const EDIT_AMBIENT = 0x2100; const EDIT_OBJECT = 0x4000; //>------ sub defines of EDIT_OBJECT const OBJ_TRIMESH = 0x4100; const OBJ_LIGHT = 0x4600; const OBJ_CAMERA = 0x4700; const OBJ_UNKNWN01 = 0x4010; const OBJ_UNKNWN02 = 0x4012; //>------ sub defines of OBJ_CAMERA const CAM_UNKNWN01 = 0x4710; const CAM_UNKNWN02 = 0x4720; //>------ sub defines of OBJ_LIGHT const LIT_OFF = 0x4620; const LIT_SPOT = 0x4610; const LIT_UNKNWN01 = 0x465A; //>------ sub defines of OBJ_TRIMESH const TRI_VERTEXL = 0x4110; const TRI_FACEL2 = 0x4111; const TRI_FACEL1 = 0x4120; const TRI_SMOOTH = 0x4150; const TRI_LOCAL = 0x4160; const TRI_VISIBLE = 0x4165; //>>------ sub defs of KEYF3DS const KEYF_UNKNWN01 = 0xB009; const KEYF_UNKNWN02 = 0xB00A; const KEYF_FRAMES = 0xB008; const KEYF_OBJDES = 0xB002; //>>------ these define the different color chunk types const COL_RGB = 0x0010; const COL_TRU = 0x0011; const COL_UNK = 0x0013; //>>------ defines for viewport chunks const TOP = 0x0001; const BOTTOM = 0x0002; const LEFT = 0x0003; const RIGHT = 0x0004; const FRONT = 0x0005; const BACK = 0x0006; const USER = 0x0007; const CAMERA = 0x0008; const LIGHT = 0x0009; const DISABLED = 0x0010; const BOGUS = 0x0011; public function __construct($type, $content) { $this->type = (int) $type; $this->size = strlen($content); $this->content = $content; } public function readChunks() { if (count($this->chunks) || ($this->size < 6)) return false; $position = 0; $string = $this->content; $length = $this->size - 6; while ($position <= $length) { $type = $this->getWord(substr($string, $position, 2)); $position += 2; $chunkLength = $this->getDWord(substr($string, $position, 4)) - 6; $position += 4; $this->chunks[] = new Image_3D_Chunk($type, substr($string, $position, $chunkLength)); $position += $chunkLength; } } public function debug() { printf("Typ: %6d (0x%04x) (%6d bytes) | Objects:%4d | Content:%6d\n", $this->type, $this->type, $this->size, count($this->chunks), strlen($this->content)); } protected function getWord($string) { return (ord($string{1}) << 8) | ord($string{0}); } protected function getDWord($string) { return ord($string{0}) | (ord($string{1}) << 8) | (ord($string{2}) << 16) | (ord($string{3}) << 32); } protected function getUnsignedInt($string) { return (ord($string{0}) << 8) | ord($string{1}); } protected function getFloat($string) { // Convert C-Float to PHP-Float return (ord($string{3}) & 128 ? -1 : 1) * (1 + (float) (ord($string{2}) & 127) / 127 + (float) (ord($string{1})) / 256 / 127 + (float) (ord($string{0})) / 256 / 256 / 127) * pow(2., ((((ord($string{3}) & 127) << 1) | (ord($string{2}) >> 7)) - 127)); } public function getChunks() { return $this->chunks; } public function getType() { return $this->type; } public function getContent() { return $this->content; } public function getFirstChunkByType($type) { if (!is_int($type)) $type = hexdec($type); foreach ($this->chunks as $chunk) if ($chunk->getType() === $type) return $chunk; return false; } public function getChunksByType($type) { if (!is_int($type)) $type = hexdec($type); $chunks = array(); foreach ($this->chunks as $chunk) if ($chunk->getType() === $type) $chunks[] = $chunk; return $chunks; } } class Image_3D_Chunk_Object extends Image_3D_Chunk { protected $name; public function __construct($type, $content) { parent::__construct($type, $content); $this->getName(); } protected function getName() { $i = 0; while ((ord($this->content{$i}) !== 0) && ($i < $this->size)) $this->name .= $this->content{$i++}; $this->content = substr($this->content, $i + 1); } public function readChunks(Image_3D_Object_3ds $k3ds) { $subtype = $this->getWord(substr($this->content, 0, 2)); $subcontent = substr($this->content, 6); switch ($subtype) { case self::OBJ_TRIMESH: $object = $k3ds->addObject($this->name); $this->chunks[] = new Image_3D_Chunk_TriMesh($subtype, $subcontent, $object); break; } } public function debug() { echo 'Object: ', $this->name, "\n"; parent::debug(); } } class Image_3D_Chunk_TriMesh extends Image_3D_Chunk { protected $matrix; protected $object; public function __construct($type, $content, $object) { parent::__construct($type, $content); $this->object = $object; $this->readChunks(); $this->getPoints(); $this->getFaces(); } protected function getPoints() { $vertexlists = $this->getChunksByType(Image_3D_Chunk::TRI_VERTEXL); foreach ($vertexlists as $vertexlist) { $points = $vertexlist->getContent(); $count = $this->getWord(substr($points, 0, 2)); $points = substr($points, 2); for ($i = 0; $i < $count; $i++) { $x = $this->getFloat(substr($points, 0, 4)); $y = $this->getFloat(substr($points, 4, 4)); $z = $this->getFloat(substr($points, 8, 4)); $this->object->newPoint($x, $y, $z); $points = substr($points, 12); } } } protected function getFaces() { $facelists = $this->getChunksByType(Image_3D_Chunk::TRI_FACEL1); foreach ($facelists as $facelist) { $faces = $facelist->getContent(); $count = $this->getWord(substr($faces, 0, 2)); $faces = substr($faces, 2); for ($i = 0; $i < $count; $i++) { $p1 = $this->getWord(substr($faces, 0, 2)); $p2 = $this->getWord(substr($faces, 2, 2)); $p3 = $this->getWord(substr($faces, 4, 2)); $this->object->newPolygon($p1, $p2, $p3); $faces = substr($faces, 8); } } } protected function getTranslations() { $translists = $this->getChunksByType(Image_3D_Chunk::TRI_LOCAL); foreach ($translists as $translist) { $trans = $translist->getContent(); echo "Trans: " . strlen($trans), "\n"; } } public function debug() { parent::debug(); printf("Trimesh with %d (0x%04x) points - Pointsize: %.2f\n", $this->pointCount, $this->pointCount, $this->size / $this->pointCount); } } class Image_3D_Object_3ds_Object extends Image_3D_Object { protected $_points; public function __construct() { parent::__construct(); $this->_points = array(); } public function newPoint($x, $y, $z) { $this->_points[] = new Image_3D_Point($x, $y, $z); // echo "New Point: $x, $y, $z -> ", count($this->_points), "\n"; } public function newPolygon($p1, $p2, $p3) { if (!isset($this->_points[$p1]) || !isset($this->_points[$p2]) || !isset($this->_points[$p3])) { // printf("ERROR: Unknown point (%d, %d, %d of %d)\n", $p1, $p2, $p3, count($this->_points) - 1); return false; } $this->_addPolygon(new Image_3D_Polygon($this->_points[$p1], $this->_points[$p2], $this->_points[$p3])); // echo "New Polygon: $p1, $p2, $p3 -> ", count($this->_polygones), "\n"; } public function debug() { printf("Points: %d | Polygones: %d (%d)\n", count($this->_points), count($this->_polygones), $this->_polygonCount); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Cube.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Cube.php +++ pear/Image_3D/Image/3D/Paintable/Object/Cube.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Cube.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Cube * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Cube extends Image_3D_Object { protected $_points; public function __construct($parameter) { parent::__construct(); $x = (float) @$parameter[0]; $y = (float) @$parameter[1]; $z = (float) @$parameter[2]; $this->_points = array(); $this->_points[1] = new Image_3D_Point(-$x / 2, -$y / 2, -$z / 2); $this->_points[2] = new Image_3D_Point(-$x / 2, -$y / 2, $z / 2); $this->_points[3] = new Image_3D_Point(-$x / 2, $y / 2, -$z / 2); $this->_points[4] = new Image_3D_Point(-$x / 2, $y / 2, $z / 2); $this->_points[5] = new Image_3D_Point( $x / 2, -$y / 2, -$z / 2); $this->_points[6] = new Image_3D_Point( $x / 2, -$y / 2, $z / 2); $this->_points[7] = new Image_3D_Point( $x / 2, $y / 2, -$z / 2); $this->_points[8] = new Image_3D_Point( $x / 2, $y / 2, $z / 2); // Oben & Unten $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[4], $this->_points[8])); $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[8], $this->_points[7])); $this->_addPolygon(new Image_3D_Polygon($this->_points[2], $this->_points[1], $this->_points[6])); $this->_addPolygon(new Image_3D_Polygon($this->_points[1], $this->_points[5], $this->_points[6])); // Links & Rechts $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[2], $this->_points[4])); $this->_addPolygon(new Image_3D_Polygon($this->_points[3], $this->_points[1], $this->_points[2])); $this->_addPolygon(new Image_3D_Polygon($this->_points[8], $this->_points[5], $this->_points[7])); $this->_addPolygon(new Image_3D_Polygon($this->_points[8], $this->_points[6], $this->_points[5])); // Rueck- & Frontseite $this->_addPolygon(new Image_3D_Polygon($this->_points[2], $this->_points[8], $this->_points[4])); $this->_addPolygon(new Image_3D_Polygon($this->_points[2], $this->_points[6], $this->_points[8])); $this->_addPolygon(new Image_3D_Polygon($this->_points[1], $this->_points[7], $this->_points[5])); $this->_addPolygon(new Image_3D_Polygon($this->_points[1], $this->_points[3], $this->_points[7])); } public function getPoint($int) { if (isset($this->_points[$int])) { return $this->_points[$int]; } else { return false; } } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Map.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Map.php +++ pear/Image_3D/Image/3D/Paintable/Object/Map.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Map.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Map * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Map extends Image_3D_Object { protected $_points; public function __construct($points = array()) { parent::__construct(); $this->_points = array(); foreach ($points as $row) { if (is_array($row)) { $this->_addRow($row); } else { $this->_addRow(array($row)); } } } public function addRow($row) { $rowNbr = array_push($this->_points, array()) - 1; foreach ($row as $point) { if (is_object($point) && is_a($point, 'Image_3D_Point')) $this->_points[$rowNbr][] = $point; } if (!count($this->_points[$rowNbr])) { unset($this->_points[$rowNbr]); return false; } if (count($this->_points) > 1) { $newRow = count($this->_points) - 1; $lastRow = $newRow - 1; $newCount = count($this->_points[$newRow]); $lastCount = count($this->_points[$lastRow]); if ($newCount < $lastCount) { $tmp = $newRow; $newRow = $lastRow; $lastRow = $tmp; $tmp = $newCount; $newCount = $lastCount; $lastCount = $tmp; } $top = (($newCount == 1) ? 1 : 1 / ($newCount - 1)); $bottom = (($lastCount == 1) ? 32768 : 1 / ($lastCount - 1)); $k = 0; for ($i = 1; $i < $newCount; $i++) { if (($i * $top) > ($k * $bottom + $bottom / 2)) { // Nach unten geoeffnetes Polygon einfuegen /\ $this->_addPolygon(new Image_3D_Polygon($this->_points[$newRow][$i - 1], $this->_points[$lastRow][$k + 1], $this->_points[$lastRow][$k])); $k++; } // Nach oben geoeffnetes Polygon einfuegen \/ $this->_addPolygon(new Image_3D_Polygon($this->_points[$newRow][$i - 1], $this->_points[$newRow][$i], $this->_points[$lastRow][$k])); } } return true; } public function getRow($int) { if (!isset($this->_points[$int])) return false; return $this->_points[$int]; } public function getPoint($x, $y) { if (!isset($this->_points[$x][$y])) return false; return $this->_points[$x][$y]; } public function setOption($option, $value) { // if ($option === Image_3D::IMAGE_3D_OPTION_BF_CULLING) $value = false; parent::setOption($option, $value); } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Pie.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Pie.php +++ pear/Image_3D/Image/3D/Paintable/Object/Pie.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Pie.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Pie * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Pie extends Image_3D_Object { public function __construct($parameter) { $parameter = $this->_checkParameter($parameter); if ($parameter['inside'] == 0) { $this->_createPie($parameter); } else { $this->_createDonutPie($parameter); } } protected function _createPie($parameter) { $step = ($parameter['end'] - $parameter['start']) / $parameter['detail']; // center $centerTop = new Image_3D_Point(0, 0, .5); $centerBottom = new Image_3D_Point(0, 0, -.5); // Add polygones for top and bottom of the pie $x = cos($parameter['start']) * $parameter['outside']; $y = sin($parameter['start']) * $parameter['outside']; $top = new Image_3D_Point($x, $y, .5); $bottom = new Image_3D_Point($x, $y, -.5); // Polygones for the opening side $this->_addPolygon(new Image_3D_Polygon($top, $centerTop, $centerBottom)); $this->_addPolygon(new Image_3D_Polygon($bottom, $top, $centerBottom)); for ($i = 1; $i <= $parameter['detail']; $i++) { $x = cos($parameter['start'] + $i * $step) * $parameter['outside']; $y = sin($parameter['start'] + $i * $step) * $parameter['outside']; $newTop = new Image_3D_Point($x, $y, .5); $newBottom = new Image_3D_Point($x, $y, -.5); $this->_addPolygon(new Image_3D_Polygon($centerTop, $top, $newTop)); $this->_addPolygon(new Image_3D_Polygon($centerBottom, $bottom, $newBottom)); // Rand $this->_addPolygon(new Image_3D_Polygon($top, $newBottom, $newTop)); $this->_addPolygon(new Image_3D_Polygon($top, $bottom, $newBottom)); $top = $newTop; $bottom = $newBottom; } // Polygones for the closing side $this->_addPolygon(new Image_3D_Polygon($top, $centerTop, $centerBottom)); $this->_addPolygon(new Image_3D_Polygon($bottom, $top, $centerBottom)); } protected function _checkParameter($array) { $array['detail'] = max(1, (int) $array['detail']); $array['outside'] = max(0, (int) $array['outside']); $array['inside'] = min(max(0, (int) $array['inside']), $array['outside']); $array['start'] = max(0, ((int) $array['start']) * pi() / 180); $array['end'] = max(0, ((int) $array['end']) * pi() / 180); return ($array); } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Sphere.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Sphere.php +++ pear/Image_3D/Image/3D/Paintable/Object/Sphere.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Sphere.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Paintable/Object.php'); /** * Image_3D_Object_Sphere * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Sphere extends Image_3D_Object { protected $_points; protected $_virtualPolygon; protected $_radius; public function __construct($options) { parent::__construct(); $this->_lines = array(); $this->_points = array(); $this->_virtualPolygon = array(); $this->_radius = (float) @$options['r']; $detail = (int) @$options['detail']; $this->_createTetraeder(); for ($step = 0; $step < $detail; $step++) $this->_sierpinsky(); $this->_getRealPolygones(); } protected function _sierpinsky() { $newPolygones = array(); $proceededLines = array(); foreach ($this->_virtualPolygon as $points) { $lines = array( array(min($points[0], $points[1]), max($points[0], $points[1])), array(min($points[1], $points[2]), max($points[1], $points[2])), array(min($points[2], $points[0]), max($points[2], $points[0])) ); $new = array(); foreach ($lines as $line) { if (!isset($proceededLines[$line[0]][$line[1]])) { // Calculate new point $newX = ($this->_points[$line[0]]->getX() + $this->_points[$line[1]]->getX()) / 2; $newY = ($this->_points[$line[0]]->getY() + $this->_points[$line[1]]->getY()) / 2; $newZ = ($this->_points[$line[0]]->getZ() + $this->_points[$line[1]]->getZ()) / 2; $multiplikator = $this->_radius / sqrt(pow($newX, 2) + pow($newY, 2) + pow($newZ, 2)); $this->_points[] = new Image_3D_Point($newX * $multiplikator, $newY * $multiplikator, $newZ * $multiplikator); $proceededLines[$line[0]][$line[1]] = count($this->_points) - 1; } $new[] = $proceededLines[$line[0]][$line[1]]; } $newPolygones[] = array($points[0], $new[0], $new[2]); $newPolygones[] = array($points[1], $new[1], $new[0]); $newPolygones[] = array($points[2], $new[2], $new[1]); $newPolygones[] = array($new[0], $new[1], $new[2]); } $this->_virtualPolygon = $newPolygones; } protected function _createTetraeder() { $laenge = $this->_radius / sqrt(3); $this->_points[] = new Image_3D_Point(sqrt(2) * -$laenge, $laenge, 0); $this->_points[] = new Image_3D_Point(sqrt(2) * $laenge, $laenge, 0); $this->_points[] = new Image_3D_Point(0, -$laenge, sqrt(2) * -$laenge); $this->_points[] = new Image_3D_Point(0, -$laenge, sqrt(2) * $laenge); $this->_virtualPolygon[] = array(0, 1, 3); $this->_virtualPolygon[] = array(1, 2, 3); $this->_virtualPolygon[] = array(0, 2, 1); $this->_virtualPolygon[] = array(0, 3, 2); } protected function _getRealPolygones() { foreach ($this->_virtualPolygon as $points) { $this->_addPolygon(new Image_3D_Polygon($this->_points[$points[0]], $this->_points[$points[1]], $this->_points[$points[2]])); } } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Paintable/Object/Text.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Paintable/Object/Text.php +++ pear/Image_3D/Image/3D/Paintable/Object/Text.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Text.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ require_once('Image/3D/Matrix/Move.php'); require_once('Image/3D/Paintable/Object.php'); require_once('Image/3D/Paintable/Object/Cube.php'); /** * Image_3D_Object_Text * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Object_Text extends Image_3D_Object { protected $_text; protected $_characterSpacing; protected $_chars; public function __construct($string) { parent::__construct(); $this->_text = (string) $string; $this->_points = array(); $this->_characterSpacing = 5.5; $this->_chars = unserialize(file_get_contents( // Dirty little trick for Kore's test env ;) (('@data_dir@' != '@'.'data'.'_'.'dir'.'@') ? '@data_dir@'.'TextData.dat' : 'data/TextData.dat'); )); $this->_generateCubes(); } public function setCharSpacing($charSpacing) { $this->_characterSpacing = 5 + (float) $charSpacing; } protected function _generateCubes() { $length = strlen($this->_text); for ($i = 0; $i < $length; $i++) { $char = $this->_chars[ord($this->_text{$i})]; foreach ($char as $x => $row) { foreach ($row as $y => $pixel) { //printf("Dot %d %.1f %.1f\n", $pixel, $x + $i * $this->_characterSpacing, $y); if ($pixel) { $tmp = new Image_3D_Object_Cube(array(1, 1, 1)); $tmp->transform(new Image_3D_Matrix_Move(array($x + $i * $this->_characterSpacing, $y, 0))); $polygones = $tmp->getPolygones(); foreach ($polygones as $polygon) $this->_addPolygon($polygon); unset($tmp); } } } } } } http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Renderer/Isometric.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Renderer/Isometric.php +++ pear/Image_3D/Image/3D/Renderer/Isometric.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Isometric.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Renderer_Isometric * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Renderer_Isometric extends Image_3D_Renderer { protected function _calculateScreenCoordiantes(Image_3D_Point $point) { $point->setScreenCoordinates( $point->getX() - ($point->getZ() * .35) + $this->_size[0] / 2, $point->getY() + ($point->getZ() * .35) + $this->_size[1] / 2 ); } protected function _sortPolygones() { $polygoneDepth = array(); foreach ($this->_polygones as $polygon) $polygoneDepth[] = $polygon->getMidZ(); array_multisort($polygoneDepth, SORT_DESC, SORT_NUMERIC, $this->_polygones); } } ?> http://cvs.php.net/co.php/pear/Image_3D/Image/3D/Renderer/Perspectively.php?r=1.1&p=1 Index: pear/Image_3D/Image/3D/Renderer/Perspectively.php +++ pear/Image_3D/Image/3D/Renderer/Perspectively.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * 3d Library * * PHP versions 5 * * LICENSE: * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version CVS: $Id: Perspectively.php,v 1.1 2005/07/18 15:35:30 toby Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ /** * Image_3D_Renderer_Perspectively * * * * @category Image * @package 3D * @author Kore Nordmann <3d@kore-nordmann.de> * @copyright 1997-2005 Kore Nordmann * @license http://www.gnu.org/licenses/lgpl.txt lgpl 2.1 * @version Release: @package_version@ * @link http://pear.php.net/package/PackageName * @since Class available since Release 0.1.0 */ class Image_3D_Renderer_Perspectively extends Image_3D_Renderer { protected function _calculateScreenCoordiantes(Image_3D_Point $point) { $viewpoint = 500.; $distance = 500.; $point->setScreenCoordinates( $viewpoint * $point->getX() / ($point->getZ() + $distance) + $this->_size[0] / 2, $viewpoint * $point->getY() / ($point->getZ() + $distance) + $this->_size[1] / 2 ); } protected function _sortPolygones() { $polygoneDepth = array(); foreach ($this->_polygones as $polygon) $polygoneDepth[] = $polygon->getMidZ(); array_multisort($polygoneDepth, SORT_DESC, SORT_NUMERIC, $this->_polygones); } } ?>