1<?php 2 3require_once('Image/3D/Paintable/Object.php'); 4 5class Image_3D_Object_Cone extends Image_3D_Object { 6 7 public function __construct($parameter) { 8 parent::__construct(); 9 10 $radius = 1; 11 $height = 1; 12 $detail = max(3, (int) $parameter['detail']); 13 14 // Generate points according to parameters 15 $top = new Image_3D_Point(0, $height, 0); 16 $bottom = new Image_3D_Point(0, 0, 0); 17 18 $last = new Image_3D_Point(1, 0, 0); 19 $points[] = $last; 20 21 for ($i = 1; $i <= $detail; ++$i) { 22 $actual = new Image_3D_Point(cos(deg2rad(360 * $i / $detail)), 0, sin(deg2rad(360 * $i / $detail))); 23 $points[] = $actual; 24 25 // Build polygon 26 $this->_addPolygon(new Image_3D_Polygon($top, $last, $actual)); 27 $this->_addPolygon(new Image_3D_Polygon($bottom, $last, $actual)); 28 $last = $actual; 29 } 30 31 // Build closing polygon 32 $this->_addPolygon(new Image_3D_Polygon($top, $last, $points[0])); 33 $this->_addPolygon(new Image_3D_Polygon($bottom, $last, $points[0])); 34 } 35} 36