Raytracer
Loading...
Searching...
No Matches
Camera.hpp
1#include <chrono>
2#include "Common.hpp"
3#include "core/Ray.hpp"
4#include "interfaces/IHittable.hpp"
5#include "utils/VecN.hpp"
6
7#ifndef __CAMERA_HPP__
8 #define __CAMERA_HPP__
9
10namespace Raytracer::Core
11{
12 class Camera {
13 private:
14 double _aspectRatio = 1.0;
15 int _imageWidth = 100;
16 int _samplesPerPixel = 10;
17 int _maxDepth = 10;
18 Utils::Color _backgroundColor = Utils::Color(0, 0, 0);
19
20 double _vFov = 90;
21 Utils::Point3 _lookFrom = Utils::Point3(0, 0, 0);
22 Utils::Point3 _lookAt = Utils::Point3(0, 0, -1);
23 Utils::Vec3 _vUp = Utils::Vec3(0, 1, 0);
24
25 double _defocusAngle = 0;
26 double _focusDistance = 10;
27
28 int _imageHeight;
29 double _pixelSampleScale;
30
31 Utils::Point3 _center;
32 Utils::Point3 _pixelZeroLoc;
33 Utils::Vec3 _pixelDeltaU;
34 Utils::Vec3 _pixelDeltaV;
35 Utils::Vec3 _u, _v, _w;
36 Utils::Vec3 _defocusDiskU;
37 Utils::Vec3 _defocusDiskV;
38
39 public:
40 Camera() = default;
41 void setup();
42 void render(const Interfaces::IHittable &world);
43 Core::Ray getRay(double u, double v) const;
45 Utils::Vec3 sampleDisk(double radius) const;
47 Utils::Color rayColor(const Ray ray, int depth,
48 const Interfaces::IHittable &world) const;
49 void progress(
50 const std::chrono::steady_clock::time_point &start, int j) const;
51 GET_SET(double, aspectRatio)
52 GET_SET(int, imageWidth)
53 GET_SET(int, samplesPerPixel)
54 GET_SET(int, maxDepth)
55 GET_SET(Utils::Color, backgroundColor)
56 GET_SET(double, vFov)
57 GET_SET(Utils::Point3, lookFrom)
58 GET_SET(Utils::Point3, lookAt)
59 GET_SET(Utils::Vec3, vUp)
60 GET_SET(double, defocusAngle)
61 GET_SET(double, focusDistance)
62 GET_SET(int, imageHeight)
63 GET_SET(double, pixelSampleScale)
64 GET_SET(Utils::Point3, center)
65 GET_SET(Utils::Vec3, pixelZeroLoc)
66 GET_SET(Utils::Vec3, pixelDeltaU)
67 GET_SET(Utils::Vec3, pixelDeltaV)
68 GET_SET(Utils::Vec3, u)
69 GET_SET(Utils::Vec3, v)
70 GET_SET(Utils::Vec3, w)
71 GET_SET(Utils::Vec3, defocusDiskU)
72 GET_SET(Utils::Vec3, defocusDiskV)
73 };
74} // namespace Raytracer::Core
75
76#endif /* __CAMERA_HPP__ */
Definition Camera.hpp:12
void progress(const std::chrono::steady_clock::time_point &start, int j) const
Print the progress of the rendering.
Definition Camera.cpp:216
void render(const Interfaces::IHittable &world)
Render the scene with the given camera.
Definition Camera.cpp:70
Utils::Color rayColor(const Ray ray, int depth, const Interfaces::IHittable &world) const
Get the color of the ray.
Definition Camera.cpp:176
Utils::Vec3 sampleDisk(double radius) const
Sample a disk.
Definition Camera.cpp:143
Core::Ray getRay(double u, double v) const
Get the ray for the given pixel.
Definition Camera.cpp:106
Utils::Vec3 sampleDefocusDisk() const
Sample the defocus disk.
Definition Camera.cpp:155
Utils::Vec3 sampleSquare() const
Sample a square.
Definition Camera.cpp:128
void setup()
Set up the camera with the given parameters.
Definition Camera.cpp:24
Definition Ray.hpp:9
Definition IHittable.hpp:11
Definition VecN.hpp:40