RayTracer 1.0
Ray tracing is a technique used to generate realistic digital images by simulating the inverse path of light. Our goal is to create a program able to generate an image from a file describing the scene.
 
Loading...
Searching...
No Matches
RayTracer::DirectionalLight Class Reference

#include <DirectionalLight.hpp>

Inheritance diagram for RayTracer::DirectionalLight:
RayTracer::ILight

Public Member Functions

 DirectionalLight (const Math::Vector3D &direction, float intensity)
 
Math::Vector3D getDirection () const
 
Color illuminate (const Ray &ray, const IPrimitive &object, const Math::Point3D &point) const override
 
- Public Member Functions inherited from RayTracer::ILight
virtual ~ILight ()=default
 

Private Attributes

Math::Vector3D _direction
 
float _intensity
 

Detailed Description

Definition at line 13 of file DirectionalLight.hpp.

Constructor & Destructor Documentation

◆ DirectionalLight()

RayTracer::DirectionalLight::DirectionalLight ( const Math::Vector3D & direction,
float intensity )

Definition at line 10 of file DirectionalLight.cpp.

10 : _direction(direction), _intensity(intensity)
11{}

References _direction, and _intensity.

Member Function Documentation

◆ getDirection()

Math::Vector3D RayTracer::DirectionalLight::getDirection ( ) const

Definition at line 24 of file DirectionalLight.cpp.

25{
26 return _direction;
27}

References _direction.

◆ illuminate()

Color RayTracer::DirectionalLight::illuminate ( const Ray & ray,
const IPrimitive & object,
const Math::Point3D & point ) const
overridevirtual

Implements RayTracer::ILight.

Definition at line 13 of file DirectionalLight.cpp.

14{
15 (void)point;
16 Color base = object.getBaseColor();
17 return Color(
18 static_cast<int>(std::clamp(base.r * _intensity, 0.0f, 255.0f)),
19 static_cast<int>(std::clamp(base.g * _intensity, 0.0f, 255.0f)),
20 static_cast<int>(std::clamp(base.b * _intensity, 0.0f, 255.0f))
21 );
22}
int r
Definition Color.hpp:13
int g
Definition Color.hpp:13
int b
Definition Color.hpp:13

References _intensity, Color::b, Color::g, and Color::r.

Member Data Documentation

◆ _direction

Math::Vector3D RayTracer::DirectionalLight::_direction
private

Definition at line 20 of file DirectionalLight.hpp.

◆ _intensity

float RayTracer::DirectionalLight::_intensity
private

Definition at line 21 of file DirectionalLight.hpp.


The documentation for this class was generated from the following files: