Example #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;
 }
Example #2
0
 public function getColor(Image_3D_Interface_Enlightenable $polygon)
 {
     $color = clone $polygon->getColor();
     // Create vector from polygons point to light source
     $light = new Image_3D_Vector($this->_x, $this->_y, $this->_z);
     $light->sub($polygon->getPosition());
     // Create vector from polygons point to camera
     //        $camera = new Image_3D_Vector(0, 0, -100);
     //        $camera->sub($polygon->getPosition());
     // Compare with polygones normale vector
     $normale = $polygon->getNormale();
     $angle = $normale->getAngle($light);
     // Use angle as light intensity
     $color->addLight($this->_color, $angle);
     return $color;
 }
Example #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());
     $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;
 }
Example #4
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;
 }
Example #5
0
 public function getColor(Image_3D_Interface_Enlightenable $polygon)
 {
     $color = clone $polygon->getColor();
     $color->addLight($this->_color, 1);
     return $color;
 }