Пример #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();
     $light->add(new Image_3D_Vector(0, 0, -1));
     $normale = $polygon->getNormale();
     $angle = abs(1 - $normale->getAngle($light));
     $color->addLight($this->_color, $angle);
     return $color;
 }
Пример #2
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());
     $distance = $light->length();
     if ($distance > $this->_distance) {
         return $color;
     }
     $factor = 1 - pow($distance / $this->_distance, $this->_falloff);
     $light->unify();
     $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;
 }
Пример #3
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;
 }
Пример #4
0
 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();
 }