cvs: pear /Image_3D/Image/3D Point.php /Image_3D/Image/3D/Paintable Object.php Polygon.php /Image_3D/docs/examples quadcube.php
| From: | Kore Nordmann | Date: | Wed, 22 Mar 2006 15:01:40 +0000 |
| Subject: | cvs: pear /Image_3D/Image/3D Point.php /Image_3D/Image/3D/Paintable Object.php Polygon.php /Image_3D/docs/examples quadcube.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39240@lists.php.net to get a copy of this message | ||
kore Wed Mar 22 15:01:40 2006 UTC
Modified files:
/pear/Image_3D/Image/3D Point.php
/pear/Image_3D/Image/3D/Paintable Object.php Polygon.php
/pear/Image_3D/docs/examples quadcube.php
Log:
- Finished: Algorithm for subdivision surfaces
Note: Creation of polygones is still errnous
http://cvs.php.net/viewcvs.cgi/pear/Image_3D/Image/3D/Point.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Image_3D/Image/3D/Point.php diff -u pear/Image_3D/Image/3D/Point.php:1.6 pear/Image_3D/Image/3D/Point.php:1.7 --- pear/Image_3D/Image/3D/Point.php:1.6 Fri Dec 2 16:01:29 2005 +++ pear/Image_3D/Image/3D/Point.php Wed Mar 22 15:01:40 2006 @@ -27,7 +27,7 @@ * @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.6 2005/12/02 16:01:29 kore Exp $ + * @version CVS: $Id: Point.php,v 1.7 2006/03/22 15:01:40 kore Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ @@ -128,7 +128,7 @@ } public function __toString() { - return sprintf('Point: %2.f %2.f %2.f', $this->_x, $this->_y, $this->_z); + return sprintf('Point: % 9.4f % 9.4f % 9.4f', $this->_x, $this->_y, $this->_z); } } http://cvs.php.net/viewcvs.cgi/pear/Image_3D/Image/3D/Paintable/Object.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Image_3D/Image/3D/Paintable/Object.php diff -u pear/Image_3D/Image/3D/Paintable/Object.php:1.7 pear/Image_3D/Image/3D/Paintable/Object.php:1.8 --- pear/Image_3D/Image/3D/Paintable/Object.php:1.7 Wed Mar 22 13:10:30 2006 +++ pear/Image_3D/Image/3D/Paintable/Object.php Wed Mar 22 15:01:40 2006 @@ -27,7 +27,7 @@ * @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.7 2006/03/22 13:10:30 kore Exp $ + * @version CVS: $Id: Object.php,v 1.8 2006/03/22 15:01:40 kore Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ @@ -148,86 +148,140 @@ } public function subdivisionSurfaces($factor = 1) { - $data = $this->_buildInzidenzGraph(); + for ($i = 0; $i < $factor; ++$i) { + $data = $this->_buildInzidenzGraph(); - // Additional hash maps - $edge_surfaces = array(); - $point_edges = array(); - - // New calculated points - $face_points = array(); - $edge_points = array(); - $old_points = array(); - - // Calculate "face points" - foreach ($data['surfaces'] as $surface => $edges) { - // Get all points - $points = array(); - foreach ($edges as $edge) { - $points = array_merge($points, $data['edges'][$edge]); - $edge_surfaces[$edge][] = $surface; - } - $points = array_unique($points); - - // Calculate average - $face_point = array(0, 0, 0); - $point_count = count($points); - foreach ($points as $point) { - $face_point[0] += $data['points'][$point]->getX() / $point_count; - $face_point[1] += $data['points'][$point]->getY() / $point_count; - $face_point[2] += $data['points'][$point]->getZ() / $point_count; - } + // Additional hash maps + $edge_surfaces = array(); + $edge_middles = array(); + $point_edges = array(); - // Create face point - $face_points[$surface] = new Image_3D_Point($face_point[0], $face_point[1], $face_point[2]); - } - - // Calculate "edge points" - foreach ($data['edges'] as $edge => $points) { - // Calculate middle of edge - $edge_middle = array(0, 0, 0); - $point_count = count($points); - foreach ($points as $point) { - $point_edges[$point][] = $edge; - $edge_middle[0] += $data['points'][$point]->getX() / $point_count; - $edge_middle[1] += $data['points'][$point]->getY() / $point_count; - $edge_middle[2] += $data['points'][$point]->getZ() / $point_count; - } - - // Calculate average of the adjacent faces - $average_face = array(0, 0, 0); - $point_count = count($edge_surfaces[$edge]); - foreach ($edge_surfaces[$edge] as $surface) { - $average_face[0] += $face_points[$surface]->getX() / $point_count; - $average_face[1] += $face_points[$surface]->getY() / $point_count; - $average_face[2] += $face_points[$surface]->getZ() / $point_count; + // New calculated points + $face_points = array(); + $edge_points = array(); + $old_points = array(); + + // Calculate "face points" + foreach ($data['surfaces'] as $surface => $edges) { + // Get all points + $points = array(); + foreach ($edges as $edge) { + $points = array_merge($points, $data['edges'][$edge]); + $edge_surfaces[$edge][] = $surface; + } + $points = array_unique($points); + + // Calculate average + $face_point = array(0, 0, 0); + $point_count = count($points); + foreach ($points as $point) { + $face_point[0] += $data['points'][$point]->getX() / $point_count; + $face_point[1] += $data['points'][$point]->getY() / $point_count; + $face_point[2] += $data['points'][$point]->getZ() / $point_count; + } + + // Create face point + $face_points[$surface] = new Image_3D_Point($face_point[0], $face_point[1], $face_point[2]); } - // Create edge point on this base - $edge_points[$edge] = new Image_3D_Point(($average_face[0] + $edge_middle[0]) / 2, ($average_face[1] + $edge_middle[1]) / 2, ($average_face[2] + $edge_middle[2]) / 2); - } + // Calculate "edge points" + foreach ($data['edges'] as $edge => $points) { + // Calculate middle of edge + if (isset($edge_middles[$edge])) { + $edge_middle = $edge_middles[$edge]; + } else { + $edge_middle = array(0, 0, 0); + $point_count = count($points); + foreach ($points as $point) { + $point_edges[$point][] = $edge; + $edge_middle[0] += $data['points'][$point]->getX() / $point_count; + $edge_middle[1] += $data['points'][$point]->getY() / $point_count; + $edge_middle[2] += $data['points'][$point]->getZ() / $point_count; + } + $edge_middles[$edge] = $edge_middle; + } - // Reposition old vertices - foreach ($data['points'] as $point => $value) { - // Calculate average of surrounding face points - $q = array(0, 0, 0); - // @TODO: implement - - // Calculate average of midpoints of adjacent edges - $r = array(0, 0, 0); - // @TODO: implement - - // Create new edge point - $n = count($point_edges[$point]); - $old_points[$point] = new Image_3D_Point( - ($q[0] / $n) + ((2 * $r[0]) / $n) + (($value->getX() * ($n - 3)) / $n), - ($q[1] / $n) + ((2 * $r[1]) / $n) + (($value->getY() * ($n - 3)) / $n), - ($q[2] / $n) + ((2 * $r[2]) / $n) + (($value->getZ() * ($n - 3)) / $n) - ); - } + // Calculate average of the adjacent faces + $average_face = array(0, 0, 0); + $point_count = count($edge_surfaces[$edge]); + foreach ($edge_surfaces[$edge] as $surface) { + $average_face[0] += $face_points[$surface]->getX() / $point_count; + $average_face[1] += $face_points[$surface]->getY() / $point_count; + $average_face[2] += $face_points[$surface]->getZ() / $point_count; + } + + // Create edge point on this base + $edge_points[$edge] = new Image_3D_Point(($average_face[0] + $edge_middle[0]) / 2, ($average_face[1] + $edge_middle[1]) / 2, ($average_face[2] + $edge_middle[2]) / 2); + } - // Create polygones on new points - // @TODO: implement + // Reposition old vertices + foreach ($data['points'] as $point => $value) { + // Calculate average of midpoints of adjacent edges + $r = array(0, 0, 0); + $surfaces = array(); + $point_count = count($point_edges[$point]); + foreach ($point_edges[$point] as $edge) { + $r[0] += $edge_middles[$edge][0] / $point_count; + $r[1] += $edge_middles[$edge][1] / $point_count; + $r[2] += $edge_middles[$edge][2] / $point_count; + $surfaces = array_merge($surfaces, $edge_surfaces[$edge]); + } + $surfaces= array_unique($surfaces); + + // Calculate average of surrounding face points + $q = array(0, 0, 0); + $surface_count = count($surfaces); + foreach ($surfaces as $surface) { + $q[0] += $face_points[$surface]->getX() / $surface_count; + $q[1] += $face_points[$surface]->getY() / $surface_count; + $q[2] += $face_points[$surface]->getZ() / $surface_count; + } + + // Create new edge point + $n = count($point_edges[$point]); + $old_points[$point] = new Image_3D_Point( + ($q[0] / $n) + ((2 * $r[0]) / $n) + (($value->getX() * ($n - 3)) / $n), + ($q[1] / $n) + ((2 * $r[1]) / $n) + (($value->getY() * ($n - 3)) / $n), + ($q[2] / $n) + ((2 * $r[2]) / $n) + (($value->getZ() * ($n - 3)) / $n) + ); + } + + // Create polygones on new points + $this->_polygones = array(); + foreach ($face_points as $surface => $face_point) { + // Get all points for face + $points = array(); + foreach ($data['surfaces'][$surface] as $edge) { + $points = array_merge($points, $data['edges'][$edge]); + } + $points = array_unique($points); + + // Create new polygones + foreach ($points as $point) { + $this->_addPolygon(new Image_3D_Polygon( + $old_points[$point], + $edge_points[$point_edges[$point][0]], + $face_point, + $edge_points[$point_edges[$point][1]] + )); + } + } + + // Debug output + echo "\nFace points:\n"; + foreach ($face_points as $point) echo $point, "\n"; + + echo "\nEdge points:\n"; + foreach ($edge_points as $point) echo $point, "\n"; + + echo "\nRepositioned points:\n"; + foreach ($old_points as $point) echo $point, "\n"; + + echo "\nCreated polygones:\n"; + foreach ($this->_polygones as $polygon) { + echo $polygon; + } + } } } http://cvs.php.net/viewcvs.cgi/pear/Image_3D/Image/3D/Paintable/Polygon.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Image_3D/Image/3D/Paintable/Polygon.php diff -u pear/Image_3D/Image/3D/Paintable/Polygon.php:1.6 pear/Image_3D/Image/3D/Paintable/Polygon.php:1.7 --- pear/Image_3D/Image/3D/Paintable/Polygon.php:1.6 Fri Dec 2 16:01:30 2005 +++ pear/Image_3D/Image/3D/Paintable/Polygon.php Wed Mar 22 15:01:40 2006 @@ -27,7 +27,7 @@ * @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.6 2005/12/02 16:01:30 kore Exp $ + * @version CVS: $Id: Polygon.php,v 1.7 2006/03/22 15:01:40 kore Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ @@ -173,6 +173,14 @@ foreach ($this->_points as $point) $z = max($point->getZ(), $z); return $z; } + + public function __toString() { + $string = "Polygon:\n"; + foreach ($this->_points as $point) { + $string .= "\t" . $point->__toString() . "\n"; + } + return $string; + } } ?> http://cvs.php.net/viewcvs.cgi/pear/Image_3D/docs/examples/quadcube.php?r1=1.2&r2=1.3&diff_format=u Index: pear/Image_3D/docs/examples/quadcube.php diff -u pear/Image_3D/docs/examples/quadcube.php:1.2 pear/Image_3D/docs/examples/quadcube.php:1.3 --- pear/Image_3D/docs/examples/quadcube.php:1.2 Wed Mar 22 13:10:30 2006 +++ pear/Image_3D/docs/examples/quadcube.php Wed Mar 22 15:01:40 2006 @@ -10,8 +10,12 @@ $light->setColor(new Image_3D_Color(255, 255, 255)); $cube = $world->createObject('quadcube', array(150, 150, 150)); -$cube->setColor(new Image_3D_Color(50, 50, 250, 150)); -$cube->subdivisionSurfaces(1); +$cube->setColor(new Image_3D_Color(50, 50, 250, 200)); + +$cube_s = $world->createObject('quadcube', array(150, 150, 150)); +$cube_s->subdivisionSurfaces(1); + +$cube_s->setColor(new Image_3D_Color(50, 50, 250, 100)); $world->transform($world->createMatrix('Rotation', array(15, 15, 0)));
http://cvs.php.net/viewcvs.cgi/pear/Image_3D/Image/3D/Point.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Image_3D/Image/3D/Point.php diff -u pear/Image_3D/Image/3D/Point.php:1.6 pear/Image_3D/Image/3D/Point.php:1.7 --- pear/Image_3D/Image/3D/Point.php:1.6 Fri Dec 2 16:01:29 2005 +++ pear/Image_3D/Image/3D/Point.php Wed Mar 22 15:01:40 2006 @@ -27,7 +27,7 @@ * @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.6 2005/12/02 16:01:29 kore Exp $ + * @version CVS: $Id: Point.php,v 1.7 2006/03/22 15:01:40 kore Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ @@ -128,7 +128,7 @@ } public function __toString() { - return sprintf('Point: %2.f %2.f %2.f', $this->_x, $this->_y, $this->_z); + return sprintf('Point: % 9.4f % 9.4f % 9.4f', $this->_x, $this->_y, $this->_z); } } http://cvs.php.net/viewcvs.cgi/pear/Image_3D/Image/3D/Paintable/Object.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Image_3D/Image/3D/Paintable/Object.php diff -u pear/Image_3D/Image/3D/Paintable/Object.php:1.7 pear/Image_3D/Image/3D/Paintable/Object.php:1.8 --- pear/Image_3D/Image/3D/Paintable/Object.php:1.7 Wed Mar 22 13:10:30 2006 +++ pear/Image_3D/Image/3D/Paintable/Object.php Wed Mar 22 15:01:40 2006 @@ -27,7 +27,7 @@ * @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.7 2006/03/22 13:10:30 kore Exp $ + * @version CVS: $Id: Object.php,v 1.8 2006/03/22 15:01:40 kore Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ @@ -148,86 +148,140 @@ } public function subdivisionSurfaces($factor = 1) { - $data = $this->_buildInzidenzGraph(); + for ($i = 0; $i < $factor; ++$i) { + $data = $this->_buildInzidenzGraph(); - // Additional hash maps - $edge_surfaces = array(); - $point_edges = array(); - - // New calculated points - $face_points = array(); - $edge_points = array(); - $old_points = array(); - - // Calculate "face points" - foreach ($data['surfaces'] as $surface => $edges) { - // Get all points - $points = array(); - foreach ($edges as $edge) { - $points = array_merge($points, $data['edges'][$edge]); - $edge_surfaces[$edge][] = $surface; - } - $points = array_unique($points); - - // Calculate average - $face_point = array(0, 0, 0); - $point_count = count($points); - foreach ($points as $point) { - $face_point[0] += $data['points'][$point]->getX() / $point_count; - $face_point[1] += $data['points'][$point]->getY() / $point_count; - $face_point[2] += $data['points'][$point]->getZ() / $point_count; - } + // Additional hash maps + $edge_surfaces = array(); + $edge_middles = array(); + $point_edges = array(); - // Create face point - $face_points[$surface] = new Image_3D_Point($face_point[0], $face_point[1], $face_point[2]); - } - - // Calculate "edge points" - foreach ($data['edges'] as $edge => $points) { - // Calculate middle of edge - $edge_middle = array(0, 0, 0); - $point_count = count($points); - foreach ($points as $point) { - $point_edges[$point][] = $edge; - $edge_middle[0] += $data['points'][$point]->getX() / $point_count; - $edge_middle[1] += $data['points'][$point]->getY() / $point_count; - $edge_middle[2] += $data['points'][$point]->getZ() / $point_count; - } - - // Calculate average of the adjacent faces - $average_face = array(0, 0, 0); - $point_count = count($edge_surfaces[$edge]); - foreach ($edge_surfaces[$edge] as $surface) { - $average_face[0] += $face_points[$surface]->getX() / $point_count; - $average_face[1] += $face_points[$surface]->getY() / $point_count; - $average_face[2] += $face_points[$surface]->getZ() / $point_count; + // New calculated points + $face_points = array(); + $edge_points = array(); + $old_points = array(); + + // Calculate "face points" + foreach ($data['surfaces'] as $surface => $edges) { + // Get all points + $points = array(); + foreach ($edges as $edge) { + $points = array_merge($points, $data['edges'][$edge]); + $edge_surfaces[$edge][] = $surface; + } + $points = array_unique($points); + + // Calculate average + $face_point = array(0, 0, 0); + $point_count = count($points); + foreach ($points as $point) { + $face_point[0] += $data['points'][$point]->getX() / $point_count; + $face_point[1] += $data['points'][$point]->getY() / $point_count; + $face_point[2] += $data['points'][$point]->getZ() / $point_count; + } + + // Create face point + $face_points[$surface] = new Image_3D_Point($face_point[0], $face_point[1], $face_point[2]); } - // Create edge point on this base - $edge_points[$edge] = new Image_3D_Point(($average_face[0] + $edge_middle[0]) / 2, ($average_face[1] + $edge_middle[1]) / 2, ($average_face[2] + $edge_middle[2]) / 2); - } + // Calculate "edge points" + foreach ($data['edges'] as $edge => $points) { + // Calculate middle of edge + if (isset($edge_middles[$edge])) { + $edge_middle = $edge_middles[$edge]; + } else { + $edge_middle = array(0, 0, 0); + $point_count = count($points); + foreach ($points as $point) { + $point_edges[$point][] = $edge; + $edge_middle[0] += $data['points'][$point]->getX() / $point_count; + $edge_middle[1] += $data['points'][$point]->getY() / $point_count; + $edge_middle[2] += $data['points'][$point]->getZ() / $point_count; + } + $edge_middles[$edge] = $edge_middle; + } - // Reposition old vertices - foreach ($data['points'] as $point => $value) { - // Calculate average of surrounding face points - $q = array(0, 0, 0); - // @TODO: implement - - // Calculate average of midpoints of adjacent edges - $r = array(0, 0, 0); - // @TODO: implement - - // Create new edge point - $n = count($point_edges[$point]); - $old_points[$point] = new Image_3D_Point( - ($q[0] / $n) + ((2 * $r[0]) / $n) + (($value->getX() * ($n - 3)) / $n), - ($q[1] / $n) + ((2 * $r[1]) / $n) + (($value->getY() * ($n - 3)) / $n), - ($q[2] / $n) + ((2 * $r[2]) / $n) + (($value->getZ() * ($n - 3)) / $n) - ); - } + // Calculate average of the adjacent faces + $average_face = array(0, 0, 0); + $point_count = count($edge_surfaces[$edge]); + foreach ($edge_surfaces[$edge] as $surface) { + $average_face[0] += $face_points[$surface]->getX() / $point_count; + $average_face[1] += $face_points[$surface]->getY() / $point_count; + $average_face[2] += $face_points[$surface]->getZ() / $point_count; + } + + // Create edge point on this base + $edge_points[$edge] = new Image_3D_Point(($average_face[0] + $edge_middle[0]) / 2, ($average_face[1] + $edge_middle[1]) / 2, ($average_face[2] + $edge_middle[2]) / 2); + } - // Create polygones on new points - // @TODO: implement + // Reposition old vertices + foreach ($data['points'] as $point => $value) { + // Calculate average of midpoints of adjacent edges + $r = array(0, 0, 0); + $surfaces = array(); + $point_count = count($point_edges[$point]); + foreach ($point_edges[$point] as $edge) { + $r[0] += $edge_middles[$edge][0] / $point_count; + $r[1] += $edge_middles[$edge][1] / $point_count; + $r[2] += $edge_middles[$edge][2] / $point_count; + $surfaces = array_merge($surfaces, $edge_surfaces[$edge]); + } + $surfaces= array_unique($surfaces); + + // Calculate average of surrounding face points + $q = array(0, 0, 0); + $surface_count = count($surfaces); + foreach ($surfaces as $surface) { + $q[0] += $face_points[$surface]->getX() / $surface_count; + $q[1] += $face_points[$surface]->getY() / $surface_count; + $q[2] += $face_points[$surface]->getZ() / $surface_count; + } + + // Create new edge point + $n = count($point_edges[$point]); + $old_points[$point] = new Image_3D_Point( + ($q[0] / $n) + ((2 * $r[0]) / $n) + (($value->getX() * ($n - 3)) / $n), + ($q[1] / $n) + ((2 * $r[1]) / $n) + (($value->getY() * ($n - 3)) / $n), + ($q[2] / $n) + ((2 * $r[2]) / $n) + (($value->getZ() * ($n - 3)) / $n) + ); + } + + // Create polygones on new points + $this->_polygones = array(); + foreach ($face_points as $surface => $face_point) { + // Get all points for face + $points = array(); + foreach ($data['surfaces'][$surface] as $edge) { + $points = array_merge($points, $data['edges'][$edge]); + } + $points = array_unique($points); + + // Create new polygones + foreach ($points as $point) { + $this->_addPolygon(new Image_3D_Polygon( + $old_points[$point], + $edge_points[$point_edges[$point][0]], + $face_point, + $edge_points[$point_edges[$point][1]] + )); + } + } + + // Debug output + echo "\nFace points:\n"; + foreach ($face_points as $point) echo $point, "\n"; + + echo "\nEdge points:\n"; + foreach ($edge_points as $point) echo $point, "\n"; + + echo "\nRepositioned points:\n"; + foreach ($old_points as $point) echo $point, "\n"; + + echo "\nCreated polygones:\n"; + foreach ($this->_polygones as $polygon) { + echo $polygon; + } + } } } http://cvs.php.net/viewcvs.cgi/pear/Image_3D/Image/3D/Paintable/Polygon.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Image_3D/Image/3D/Paintable/Polygon.php diff -u pear/Image_3D/Image/3D/Paintable/Polygon.php:1.6 pear/Image_3D/Image/3D/Paintable/Polygon.php:1.7 --- pear/Image_3D/Image/3D/Paintable/Polygon.php:1.6 Fri Dec 2 16:01:30 2005 +++ pear/Image_3D/Image/3D/Paintable/Polygon.php Wed Mar 22 15:01:40 2006 @@ -27,7 +27,7 @@ * @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.6 2005/12/02 16:01:30 kore Exp $ + * @version CVS: $Id: Polygon.php,v 1.7 2006/03/22 15:01:40 kore Exp $ * @link http://pear.php.net/package/PackageName * @since File available since Release 0.1.0 */ @@ -173,6 +173,14 @@ foreach ($this->_points as $point) $z = max($point->getZ(), $z); return $z; } + + public function __toString() { + $string = "Polygon:\n"; + foreach ($this->_points as $point) { + $string .= "\t" . $point->__toString() . "\n"; + } + return $string; + } } ?> http://cvs.php.net/viewcvs.cgi/pear/Image_3D/docs/examples/quadcube.php?r1=1.2&r2=1.3&diff_format=u Index: pear/Image_3D/docs/examples/quadcube.php diff -u pear/Image_3D/docs/examples/quadcube.php:1.2 pear/Image_3D/docs/examples/quadcube.php:1.3 --- pear/Image_3D/docs/examples/quadcube.php:1.2 Wed Mar 22 13:10:30 2006 +++ pear/Image_3D/docs/examples/quadcube.php Wed Mar 22 15:01:40 2006 @@ -10,8 +10,12 @@ $light->setColor(new Image_3D_Color(255, 255, 255)); $cube = $world->createObject('quadcube', array(150, 150, 150)); -$cube->setColor(new Image_3D_Color(50, 50, 250, 150)); -$cube->subdivisionSurfaces(1); +$cube->setColor(new Image_3D_Color(50, 50, 250, 200)); + +$cube_s = $world->createObject('quadcube', array(150, 150, 150)); +$cube_s->subdivisionSurfaces(1); + +$cube_s->setColor(new Image_3D_Color(50, 50, 250, 100)); $world->transform($world->createMatrix('Rotation', array(15, 15, 0)));