示例#1
0
 public function getColor(Image_3D_Interface_Enlightenable $polygon)
 {
     $color = clone $polygon->getColor();
     $light = new Image_3D_Vector($this->_x, $this->_y, $this->_z);
     $light->sub($polygon->getPosition());
     $light->unify();
     $angle = $light->getAngle($this->_direction);
     if ($angle > $this->_angle) {
         return $color;
     }
     if ($this->_float) {
         $factor = 1 - pow($angle / $this->_angle, $this->_float);
     } else {
         $factor = 1;
     }
     $light->add(new Image_3D_Vector(0, 0, -1));
     $normale = $polygon->getNormale();
     $angle = abs(1 - $normale->getAngle($light));
     $color->addLight($this->_color, $angle * $factor);
     return $color;
 }